1 (function(angular
, $, _
) {
3 angular
.module('statuspage').controller('statuspageStatusPage',
4 function($scope
, crmApi
, crmStatus
, statusData
) {
6 $scope
.help
= CRM
.help
;
7 $scope
.formatDate
= CRM
.utils
.formatDate
;
8 $scope
.statuses
= statusData
.values
;
10 // Refresh the list. Optionally execute api calls first.
11 function refresh(apiCalls
) {
12 apiCalls
= (apiCalls
|| []).concat([['System', 'check', {sequential
: 1}]]);
13 $('#crm-status-list').block();
14 crmApi(apiCalls
, true)
15 .then(function(result
) {
16 $scope
.statuses
= result
[result
.length
- 1].values
;
17 $('#crm-status-list').unblock();
21 // updates a status preference and refreshes status data
22 $scope
.setPref = function(status
, until
, visible
) {
24 ['StatusPreference', 'create', {
26 ignore_severity
: visible
? 0 : status
.severity
,
32 $scope
.countVisible = function(visibility
) {
33 return _
.filter($scope
.statuses
, function(s
) {
34 return s
.is_visible
== visibility
&& s
.severity_id
>= 2;
38 $scope
.doAction = function(action
) {
40 switch (action
.type
) {
42 window
.location
= CRM
.url(action
.params
.path
, action
.params
.query
, action
.params
.mode
);
46 refresh([action
.params
]);
54 message
: action
.confirm
55 }).on('crmConfirm:yes', run
);
62 })(angular
, CRM
.$, CRM
._
);