Merge pull request #9187 from sqweets/ExportHeadersRelationships
[civicrm-core.git] / ang / crmStatusPage / StatusPageCtrl.js
CommitLineData
4d8e3559
NM
1(function(angular, $, _) {
2
4d8e3559 3 angular.module('statuspage').controller('statuspageStatusPage',
d1fa280a 4 function($scope, crmApi, crmStatus, statusData) {
5db0114d 5 $scope.ts = CRM.ts();
2a243675 6 $scope.help = CRM.help;
4cf9188e
CW
7 $scope.formatDate = CRM.utils.formatDate;
8 $scope.statuses = statusData.values;
4d8e3559 9
5db0114d 10 // updates a status preference and refreshes status data
c426a987 11 $scope.setPref = function(status, until, visible) {
5db0114d
CW
12 // Use an array because it's important that one api call executes before the other
13 var apiCalls = [
14 ['StatusPreference', 'create', {
15 "name": status.name,
16 "ignore_severity": visible ? 0 : status.severity,
17 "hush_until": until
18 }],
19 ['System', 'check', {sequential: 1}]
20 ];
21 crmApi(apiCalls, true)
22 .then(function(result) {
4cf9188e 23 $scope.statuses = result[1].values;
28bd6c8d
CW
24 });
25 };
826f5ace 26
4cb29687
CW
27 $scope.countVisible = function(visibility) {
28 return _.filter($scope.statuses, function(s) {
eb94a576 29 return s.is_visible == visibility && s.severity_id >= 2;
4cb29687 30 }).length;
826f5ace 31 };
4d8e3559 32 });
4d8e3559
NM
33
34})(angular, CRM.$, CRM._);