Adds a button to manually trigger Health Checks. Adds disabled state & inactive CSS class to ensure it cannot be triggered again whilst checks taking place.

This commit is contained in:
Warren Buckley
2016-07-12 13:32:16 +01:00
parent 856de5b9f3
commit d90426eb64
2 changed files with 40 additions and 13 deletions

View File

@@ -19,22 +19,38 @@
vm.checkAllInGroup = checkAllInGroup;
vm.openGroup = openGroup;
vm.setViewState = setViewState;
vm.triggerChecks = triggerChecks;
vm.checksRunning = false;
// Get a (grouped) list of all health checks
healthCheckResource.getAllChecks().then(
function(response) {
vm.totalGroups = 0;
vm.totalGroupsChecked = 0;
// set number of checks which has been executed
for (var i = 0; i < response.length; i++) {
var group = response[i];
group.checkCounter = 0;
checkAllInGroup(group, group.checks);
function triggerChecks(){
//Reset counter - inczse
//Checks running - hide button that triggers check
//So we can't invoke multiple times & make further blocking requests
vm.checksRunning = true;
// Get a (grouped) list of all health checks
healthCheckResource.getAllChecks().then(
function(response) {
//Total number of groups
vm.totalGroups = response.length;
// set number of checks which has been executed
for (var i = 0; i < response.length; i++) {
var group = response[i];
group.checkCounter = 0;
checkAllInGroup(group, group.checks);
}
vm.groups = response;
}
vm.groups = response;
}
);
);
}
function setGroupGlobalResultType(group) {
@@ -104,6 +120,15 @@
if (group.checkCounter === checks.length) {
setGroupGlobalResultType(group);
group.loading = false;
//This group of checks run - increment counter by one
vm.totalGroupsChecked++;
//Once we have all done all checks for this group
//Verify if this was last group or not with counters & reset button
if(vm.totalGroups === vm.totalGroupsChecked){
vm.checksRunning = false;
}
}
});

View File

@@ -3,6 +3,8 @@
<p>The health checker evaluates various areas of your site for best practice settings, configuration, potential problems, etc. You can easily fix problems by pressing a button. <br/>
You can add your own health checks, have a look at <a href="https://our.umbraco.org/documentation/Extending/Healthcheck/" class="btn-link -underline">the documentation for more information</a> about custom health checks.</p>
<button type="button" class="umb-era-button" ng-click="vm.triggerChecks()" ng-disabled="vm.checksRunning" ng-class="{'-inactive': vm.checksRunning}" ng-hide="vm.viewState === 'details'">Run Checks</button>
<div class="umb-healthcheck" ng-if="vm.viewState === 'list'">
<div class="umb-air" ng-repeat="group in vm.groups" ng-click="vm.openGroup(group);">