629681f755933802e2261df2e19e8e787ee21da6
1 (function(angular
, $, _
) {
3 angular
.module('statuspage').controller('statuspageStatusPage',
4 function($scope
, crmApi
, crmStatus
, statusData
, statuspageSeverityList
) {
6 function preprocessStatuses(apiData
) {
7 _
.each(apiData
.values
, function(status
) {
8 status
.severity_id
= status
.severity
;
9 status
.severity
= statuspageSeverityList
[status
.severity
];
10 if (status
.hidden_until
) {
11 var date
= $.datepicker
.parseDate('yy-mm-dd', status
.hidden_until
);
12 status
.hidden_until
= $.datepicker
.formatDate(CRM
.config
.dateInputFormat
, date
);
15 $scope
.statuses
= apiData
.values
;
17 preprocessStatuses(statusData
);
20 $scope
.alert
= CRM
.alert
;
22 // updates a status preference and refreshes status data
23 $scope
.setPref = function(status
, until
, visible
) {
24 // Use an array because it's important that one api call executes before the other
26 ['StatusPreference', 'create', {
28 "ignore_severity": visible
? 0 : status
.severity
,
31 ['System', 'check', {sequential
: 1}]
33 crmApi(apiCalls
, true)
34 .then(function(result
) {
35 preprocessStatuses(result
[1]);
39 $scope
.countVisible = function(visibility
) {
40 return _
.filter($scope
.statuses
, function(s
) {
41 return s
.is_visible
== visibility
&& s
.severity_id
>= 3;
46 })(angular
, CRM
.$, CRM
._
);