1 (function(angular
, $, _
) {
5 angular
.module('statuspage').controller('statuspageStatusPage',
6 function($scope
, $location
, crmApi
, crmStatus
, crmUiHelp
, statuses
, crmNavigator
, preferences
) {
7 // The ts() and hs() functions help load strings for this module.
8 var ts
= $scope
.ts
= CRM
.ts('statuspage');
9 var hs
= $scope
.hs
= crmUiHelp({file
: 'CRM/statuspage/StatusPage'}); // See: templates/CRM/statuspage/StatusPage.hlp
11 $scope
.path
= $location
.path();
12 $scope
.navigator
= crmNavigator
;
13 $scope
.statuses
= statuses
;
14 $scope
.preferences
= preferences
;
16 // 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
17 $scope
.hush = function(name
, severity
) {
19 { start
: ts('Saving Status Preference...') , success
: ts('Preference Saved') },
20 crmApi('StatusPreference', 'create', {
23 "ignore_severity": severity
,
26 .then(function(){rmStatus($scope
, name
);})
30 // will reset ignore_severity to 0 to unhush the status alert.
31 $scope
.unhush = function(name
, severity
) {
33 { start
: ts('Saving Status Preference...') , success
: ts('Preference Saved') },
34 crmApi('StatusPreference', 'create', {
40 .then(function(){rmStatus($scope
, name
);})
44 // 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
45 $scope
.snooze = function(status
) {
46 $scope
.showSnoozeOptions(status
);
48 { status
: ts('Saving Status Preference...') , success
: ts('Preference Saved') },
49 crmApi('StatusPreference', 'create', {
52 "ignore_severity": status
.snoozeOptions
.severity
,
53 "hush_until": status
.snoozeOptions
.until
54 }) .then(function(){rmStatus($scope
, status
.name
);})
57 $scope
.showSnoozeOptions = function(status
) {
58 status
.snoozeOptions
.show
= !status
.snoozeOptions
.show
;
64 * remove a status after it has been hushed/snoozed
65 * @param {type} $scope
66 * @param {type} statusName
69 function rmStatus($scope
, statusName
) {
70 $scope
.statuses
.values
= _
.reject($scope
.statuses
.values
,
72 return status
.name
=== statusName
;
76 })(angular
, CRM
.$, CRM
._
);