From f1e868f30bf09617bb2643f678a66513b8c44ab8 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 22 Oct 2015 22:31:18 -0400 Subject: [PATCH] CRM-13823 - Simplify data loading --- ang/crmStatusPage.js | 7 ++--- ang/crmStatusPage/StatusPage.html | 3 +- ang/crmStatusPage/StatusPageCtrl.js | 18 ++++++++---- ang/crmStatusPage/StatusPageServices.js | 38 ------------------------- 4 files changed, 16 insertions(+), 50 deletions(-) diff --git a/ang/crmStatusPage.js b/ang/crmStatusPage.js index a821a13073..a83b201392 100644 --- a/ang/crmStatusPage.js +++ b/ang/crmStatusPage.js @@ -12,11 +12,8 @@ templateUrl: '~/statuspage/StatusPage.html', resolve: { - statuses: function(statuspageGetStatuses) { - return statuspageGetStatuses({sequential: 1}); - }, - preferences: function(statuspageGetPreferences){ - return statuspageGetPreferences(); + statusData: function(crmApi) { + return crmApi('System', 'check', {sequential: 1}); } } }); diff --git a/ang/crmStatusPage/StatusPage.html b/ang/crmStatusPage/StatusPage.html index 9100fcc849..f2ea1d79aa 100644 --- a/ang/crmStatusPage/StatusPage.html +++ b/ang/crmStatusPage/StatusPage.html @@ -1,6 +1,5 @@
-
@@ -14,7 +13,7 @@ crm-ui-tab id="tab-{{tab.name}}" crm-title="tab.is_visible ? ts('Active') : ts('Hushed/Snoozed')" > -
+

{{status.title}} diff --git a/ang/crmStatusPage/StatusPageCtrl.js b/ang/crmStatusPage/StatusPageCtrl.js index 52ec83b22e..5182cc6ca8 100644 --- a/ang/crmStatusPage/StatusPageCtrl.js +++ b/ang/crmStatusPage/StatusPageCtrl.js @@ -3,12 +3,20 @@ // controller angular.module('statuspage').controller('statuspageStatusPage', - function($scope, crmApi, crmStatus, crmUiHelp, statuses, preferences) { + function($scope, crmApi, crmStatus, statusData, statuspageSeverityList) { - var ts = $scope.ts = CRM.ts(); - $scope.statuses = statuses; - $scope.preferences = preferences; - $scope.alert = CRM.alert; + var ts = $scope.ts = CRM.ts(); + $scope.alert = CRM.alert; + $scope.statuses = statusData.values; + + _.each($scope.statuses, function(status) { + status.severity_id = status.severity; + status.severity = statuspageSeverityList[status.severity]; + status.snoozeOptions = { + show: false, + severity: status.severity + }; + }); // will "hush" a status - gets the severity level of the status that is being hushed, and hushes all alerts for that check at and below the level of the current check $scope.hush = function(name, severity) { diff --git a/ang/crmStatusPage/StatusPageServices.js b/ang/crmStatusPage/StatusPageServices.js index 1858a831b3..9a0c263b96 100644 --- a/ang/crmStatusPage/StatusPageServices.js +++ b/ang/crmStatusPage/StatusPageServices.js @@ -1,43 +1,5 @@ (function(angular, $, _) { - /** - * get status messages - * build snooze options object reconciled with preferences - * - */ - angular.module('statuspage').service('statuspageGetStatuses', function(crmApi, statuspageSeverityList) { - return function(apiFilter) { - return crmApi('System', 'check', apiFilter) - .catch(function(obj){console.log(obj);}) - .then(function(apiResults){ - _.each(apiResults.values, function(status){ - status.severity_id = status.severity; - status.severity = statuspageSeverityList[status.severity]; - status.snoozeOptions = { - show: false, - severity: status.severity - }; - }); - return apiResults; - }); - }; - }); - - angular.module('statuspage').service('statuspageGetPreferences', function(crmApi) { - return function() { - return crmApi('StatusPreference', 'get') - .then(function(apiResults) { - _.each(apiResults.values, function(pref){ - pref.snoozeOptions = { - severity: pref.ignore_severity - }; - }); - return apiResults; - }); - }; - }); - - angular.module('statuspage').filter('trusted', function($sce){ return $sce.trustAsHtml; }); angular.module('statuspage').service('statuspageSeverityList', function() { -- 2.25.1