indent and title fix
[civicrm-core.git] / ang / crmStatusPage / StatusPageCtrl.js
index 48242a59eac3e28cafbce528a8a99246d039d795..f1d2966706f7705e927c2dcc1288321db9014e78 100644 (file)
@@ -1,32 +1,32 @@
 (function(angular, $, _) {
 
   angular.module('statuspage').controller('statuspageStatusPage',
-    function($scope, crmApi, crmStatus, statusData, statuspageSeverityList) {
-
-      var ts = $scope.ts = CRM.ts();
-      $scope.alert = CRM.alert;
+    function($scope, crmApi, crmStatus, statusData) {
+      $scope.ts = CRM.ts();
+      $scope.help = CRM.help;
+      $scope.formatDate = CRM.utils.formatDate;
       $scope.statuses = statusData.values;
 
-      _.each($scope.statuses, function(status) {
-        status.severity_id = status.severity;
-        status.severity = statuspageSeverityList[status.severity];
-      });
-
-      // updates a status preference
+      // updates a status preference and refreshes status data
       $scope.setPref = function(status, until, visible) {
-        crmApi('StatusPreference', 'create', {
-          "name": status.name,
-          "ignore_severity": visible ? 0 : status.severity,
-          "hush_until": until
-        }, true)
-          .then(function() {
-            status.is_visible = visible;
+        // Use an array because it's important that one api call executes before the other
+        var apiCalls = [
+          ['StatusPreference', 'create', {
+              "name": status.name,
+              "ignore_severity": visible ? 0 : status.severity,
+              "hush_until": until
+            }],
+          ['System', 'check', {sequential: 1}]
+        ];
+        crmApi(apiCalls, true)
+          .then(function(result) {
+            $scope.statuses = result[1].values;
           });
       };
       
       $scope.countVisible = function(visibility) {
         return _.filter($scope.statuses, function(s) {
-          return s.is_visible == visibility && s.severity_id >= 3;
+          return s.is_visible == visibility && s.severity_id >= 2;
         }).length;
       };
     });