Commit | Line | Data |
---|---|---|
4d8e3559 NM |
1 | (function(angular, $, _) { |
2 | ||
4d8e3559 | 3 | angular.module('statuspage').controller('statuspageStatusPage', |
f1e868f3 | 4 | function($scope, crmApi, crmStatus, statusData, statuspageSeverityList) { |
4d8e3559 | 5 | |
f1e868f3 CW |
6 | var ts = $scope.ts = CRM.ts(); |
7 | $scope.alert = CRM.alert; | |
8 | $scope.statuses = statusData.values; | |
9 | ||
10 | _.each($scope.statuses, function(status) { | |
11 | status.severity_id = status.severity; | |
12 | status.severity = statuspageSeverityList[status.severity]; | |
f1e868f3 | 13 | }); |
4d8e3559 | 14 | |
c426a987 CW |
15 | // updates a status preference |
16 | $scope.setPref = function(status, until, visible) { | |
4d8e3559 | 17 | crmApi('StatusPreference', 'create', { |
28bd6c8d | 18 | "name": status.name, |
c426a987 CW |
19 | "ignore_severity": visible ? 0 : status.severity, |
20 | "hush_until": until | |
28bd6c8d CW |
21 | }, true) |
22 | .then(function() { | |
c426a987 | 23 | status.is_visible = visible; |
28bd6c8d CW |
24 | }); |
25 | }; | |
826f5ace | 26 | |
4cb29687 CW |
27 | $scope.countVisible = function(visibility) { |
28 | return _.filter($scope.statuses, function(s) { | |
29 | return s.is_visible == visibility && s.severity_id >= 3; | |
30 | }).length; | |
826f5ace | 31 | }; |
4d8e3559 | 32 | }); |
4d8e3559 NM |
33 | |
34 | })(angular, CRM.$, CRM._); |