Commit 28bd6c8d authored by colemanw's avatar colemanw

CRM-13823 - Snooze/hush cleanup

parent f1e868f3
......@@ -13,7 +13,7 @@
resolve: {
statusData: function(crmApi) {
return crmApi('System', 'check', {sequential: 1});
return crmApi('System', 'check', {sequential: 1, options: {limit: 0}});
}
}
});
......
......@@ -10,7 +10,8 @@
<div crm-ui-tab-set>
<div
ng-repeat="tab in [{is_visible: 1, name: 'visible'}, {is_visible: 0, name: 'hidden'}]"
crm-ui-tab id="tab-{{tab.name}}"
crm-ui-tab
id="tab-{{tab.name}}"
crm-title="tab.is_visible ? ts('Active') : ts('Hushed/Snoozed')"
>
<div id="crm-status-list" ng-repeat="status in statuses | filter:{is_visible: tab.is_visible}" >
......@@ -22,8 +23,8 @@
</span>
<a ng-if="status.is_visible" ng-click="showSnoozeOptions(status)" ng-show="!status.snoozeOptions.show" class="crm-hover-button" crm-icon="fa-clock-o" title="{{ts('Snooze')}}"></a>
<a ng-click="showSnoozeOptions(status)" ng-show="status.snoozeOptions.show" class="crm-hover-button" crm-icon="fa-times" style="display: inline" title="{{ts('Close')}}"></a>
<a ng-if="status.is_visible" ng-click="hush(status.name, status.severity)" class="crm-hover-button" crm-icon="fa-bell-slash-o" title="{{ts('Hush')}}"></a>
<a ng-if="!status.is_visible" ng-click="unhush(status.name)" class="crm-hover-button" crm-icon="fa-bell-o" title="{{ts('Unhush And Unsnooze')}}"></a>
<a ng-if="status.is_visible" ng-click="hush(status)" class="crm-hover-button" crm-icon="fa-bell-slash-o" title="{{ts('Hush')}}"></a>
<a ng-if="!status.is_visible" ng-click="unhush(status)" class="crm-hover-button" crm-icon="fa-bell-o" title="{{ts('Unhush And Unsnooze')}}"></a>
</h3>
<h4>
<div class="crm-block">
......
(function(angular, $, _) {
// controller
angular.module('statuspage').controller('statuspageStatusPage',
function($scope, crmApi, crmStatus, statusData, statuspageSeverityList) {
......@@ -18,62 +16,46 @@
};
});
// will "hush" a status - gets the severity level of the status that is being hushed, and hushes all alerts for that check at and below the level of the current check
$scope.hush = function(name, severity) {
return crmStatus(
{ start: ts('Saving Status Preference...') , success: ts('Preference Saved') },
// will "hush" a status - gets the severity level of the status that is being hushed, and hushes all alerts for that check at and below the level of the current check
$scope.hush = function(status) {
crmApi('StatusPreference', 'create', {
"sequential": 1,
"name": name,
"ignore_severity": severity,
"name": status.name,
"ignore_severity": status.severity,
"hush_until": ""
})
.then(function(){rmStatus($scope, name);})
);
};
}, true)
.then(function() {
status.is_visible = 0;
});
};
// will reset ignore_severity to 0 to unhush the status alert.
$scope.unhush = function(name, severity) {
return crmStatus(
{ start: ts('Saving Status Preference...') , success: ts('Preference Saved') },
crmApi('StatusPreference', 'create', {
"name": name,
"ignore_severity": 0,
"hush_until": ""
})
.then(function(){rmStatus($scope, name);})
);
};
// will 'snooze' a status - will not show alerts at that level for that check + alerts below that level for that check until the specified date
$scope.snooze = function(status) {
$scope.showSnoozeOptions(status);
return crmStatus(
{ status: ts('Saving Status Preference...') , success: ts('Preference Saved') },
crmApi('StatusPreference', 'create', {
"name": status.name,
"ignore_severity": status.snoozeOptions.severity,
"hush_until": status.snoozeOptions.until
}) .then(function(){rmStatus($scope, status.name);})
);
};
$scope.showSnoozeOptions = function(status) {
status.snoozeOptions.show = !status.snoozeOptions.show;
$scope.unhush = function(status) {
crmApi('StatusPreference', 'create', {
"name": status.name,
"ignore_severity": 0,
"hush_until": ""
}, true)
.then(function() {
status.is_visible = 1;
});
};
});
/**
* remove a status after it has been hushed/snoozed
* @param {type} $scope
* @param {type} statusName
* @returns void
*/
function rmStatus($scope, statusName) {
$scope.statuses.values = _.reject($scope.statuses.values,
function(status) {
return status.name === statusName;
// will 'snooze' a status - will not show alerts at that level for that check + alerts below that level for that check until the specified date
$scope.snooze = function(status) {
$scope.showSnoozeOptions(status);
crmApi('StatusPreference', 'create', {
"name": status.name,
"ignore_severity": status.snoozeOptions.severity,
"hush_until": status.snoozeOptions.until
}, true)
.then(function() {
status.is_visible = 0;
});
};
$scope.showSnoozeOptions = function(status) {
status.snoozeOptions.show = !status.snoozeOptions.show;
};
});
}
})(angular, CRM.$, CRM._);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment