Commit f1e868f3 authored by colemanw's avatar colemanw

CRM-13823 - Simplify data loading

parent 5c20338a
......@@ -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});
}
}
});
......
<div class="crm-container">
<div crm-ui-debug="statuses"></div>
<div crm-ui-debug="preferences"></div>
<form name="crm-system-status" crm-ui-id-scope>
......@@ -14,7 +13,7 @@
crm-ui-tab id="tab-{{tab.name}}"
crm-title="tab.is_visible ? ts('Active') : ts('Hushed/Snoozed')"
>
<div id="crm-status-list" ng-repeat="status in statuses.values | filter:{is_visible: tab.is_visible}" >
<div id="crm-status-list" ng-repeat="status in statuses | filter:{is_visible: tab.is_visible}" >
<h3 class="crm-severity-{{status.severity}}">
<i ng-if="status.icon" class="crm-i {{status.icon}}"></i>
{{status.title}}
......
......@@ -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) {
......
(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() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment