From: Nikki Murray Date: Tue, 13 Oct 2015 14:43:41 +0000 (-0400) Subject: moving files from extension into namespaced ang file X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=4d8e35596cde89c46fe8a1699359a9bedeb3e555;p=civicrm-core.git moving files from extension into namespaced ang file --- diff --git a/ang/crmStatusPage.css b/ang/crmStatusPage.css new file mode 100644 index 0000000000..604037e833 --- /dev/null +++ b/ang/crmStatusPage.css @@ -0,0 +1,70 @@ +/* Add any CSS rules for Angular module "statuspage" */ + +/* Error Severity */ +#crm-status-list .crm-severity-emergency, +#crm-status-list .crm-severity-alert, +#crm-status-list .crm-severity-critical, +#crm-status-list .crm-severity-error{ + background-color: #E43D2B; + color: white; +} + +#crm-status-list .crm-severity-emergency:hover, +#crm-status-list .crm-severity-alert:hover, +#crm-status-list .crm-severity-critical:hover, +#crm-status-list .crm-severity-error:hover { + background-color: #DD0000; + color: white; +} + +/* Warning Severity */ +#crm-status-list .crm-severity-warning +{ + background-color: #EDA737; + color: white; +} + +#crm-status-list .crm-severity-warning:hover +{ + background-color: #F09E1A; + color: white; +} + + +/* Not Okay - Not Warning */ +#crm-status-list .crm-severity-notice +{ + background-color: #4A88DF; + color: white; +} + +#crm-status-list .crm-severity-notice :hover +{ + background-color: #41477E; + color: white; +} + +/* All OK Severity */ +#crm-status-list .crm-severity-info, +#crm-status-list .crm-severity-debug { + background-color: #00994D; + color: white; +} + + +#crm-status-list .crm-severity-info:hover, +#crm-status-list .crm-severity-debug:hover { + background-color: #006633; + color: white; +} + +/* over-riding divs for snooze-options so that inline-block looks better */ + +.crm-container .status-snooze-options .crm-section .content, +.crm-container .status-snooze-options .crm-section .label { + margin-left: inherit; + text-align: inherit; + float: inherit; + width: inherit; + display: inline-block; +} diff --git a/ang/crmStatusPage.js b/ang/crmStatusPage.js new file mode 100644 index 0000000000..eae10777a6 --- /dev/null +++ b/ang/crmStatusPage.js @@ -0,0 +1,46 @@ +(function(angular, $, _) { + // Declare a list of dependencies. + angular.module('statuspage', [ + 'crmUi', 'crmUtil', 'ngRoute' + ]); + + // router + + angular.module('statuspage').config( function($routeProvider) { + $routeProvider.when('/status', { + controller: 'statuspageStatusPage', + templateUrl: '~/statuspage/StatusPage.html', + + resolve: { + statuses: function(statuspageGetStatuses) { + return statuspageGetStatuses({is_visible: 1}); + }, + statusModel: function(statuspageStatusModel) { + return statuspageStatusModel(); + }, + preferences: function(statuspageGetPreferences){ + return statuspageGetPreferences(); + } + } + }); + + $routeProvider.when('/status/hushed', { + controller: 'statuspageStatusPage', + templateUrl: '~/statuspage/StatusPage.html', + + resolve: { + statuses: function(statuspageGetStatuses) { + return statuspageGetStatuses({is_visible: 0}); + }, + statusModel: function(statuspageStatusModel) { + return statuspageStatusModel(); + }, + preferences: function(statuspageGetPreferences){ + return statuspageGetPreferences(); + } + } + }); + + } +); +})(angular, CRM.$, CRM._); diff --git a/ang/crmStatusPage/SnoozeOptions.html b/ang/crmStatusPage/SnoozeOptions.html new file mode 100644 index 0000000000..7a890016a1 --- /dev/null +++ b/ang/crmStatusPage/SnoozeOptions.html @@ -0,0 +1,7 @@ + + + + + + + diff --git a/ang/crmStatusPage/StatusPage.html b/ang/crmStatusPage/StatusPage.html new file mode 100644 index 0000000000..327cc625b4 --- /dev/null +++ b/ang/crmStatusPage/StatusPage.html @@ -0,0 +1,37 @@ +
+
+
+ +
+ +
+

{{ts('Help messages will be displayed here')}}

+
+ +
+

Status Page


+ + +
+
+

{{status.title}} + +
+
+ + + + +

+

+
+
+
+
+
+


+
+ +
+ +
diff --git a/ang/crmStatusPage/StatusPageServices.js b/ang/crmStatusPage/StatusPageServices.js new file mode 100644 index 0000000000..fe86fc8266 --- /dev/null +++ b/ang/crmStatusPage/StatusPageServices.js @@ -0,0 +1,64 @@ +(function(angular, $, _) { + +/** + * get status messages + * build snooze options object reconciled with preferences + * + */ + angular.module('statuspage').service('statuspageStatusModel', function(crmApi, statuspageGetStatuses, statuspageGetPreferences){ + return function() { + var statusModel = { + hushed: false, + getStatuses: statuspageGetStatuses, + getPreferences: statuspageGetPreferences, + }; + statusModel.statuses = statusModel + .getStatuses(statusModel.hushed) + .then(function(result){ + result.preferences = statuspageGetPreferences(); + return result; + }); + }; + }); + + 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.displayTitle = status.name+' - '+status.title +' - '+status.severity.toUpperCase(); + 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() { + return ['debug', 'info', 'notice', 'warning', 'error', 'critical', 'alert', 'emergency']; + }); + +})(angular, CRM.$, CRM._); diff --git a/ang/crmStatusPage/StatuspageCtrl.js b/ang/crmStatusPage/StatuspageCtrl.js new file mode 100644 index 0000000000..79c30b3523 --- /dev/null +++ b/ang/crmStatusPage/StatuspageCtrl.js @@ -0,0 +1,77 @@ +(function(angular, $, _) { + + // controller + + angular.module('statuspage').controller('statuspageStatusPage', + function($scope, $location, crmApi, crmStatus, crmUiHelp, statuses, crmNavigator, preferences) { + // The ts() and hs() functions help load strings for this module. + var ts = $scope.ts = CRM.ts('statuspage'); + var hs = $scope.hs = crmUiHelp({file: 'CRM/statuspage/StatusPage'}); // See: templates/CRM/statuspage/StatusPage.hlp + + $scope.path = $location.path(); + $scope.navigator = crmNavigator; + $scope.statuses = statuses; + console.log(preferences) + $scope.preferences = preferences; + + // 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) { + return crmStatus( + { start: ts('Saving Status Preference...') , success: ts('Preference Saved') }, + crmApi('StatusPreference', 'create', { + "sequential": 1, + "name": name, + "ignore_severity": severity, + "hush_until": "" + }) + .then(function(){rmStatus($scope, name);}) + ); + }; + + // will reset ignore_severity to 0 to unhush the status alert. + $scope.unhush = function(name, severity) { + return crmStatus( + { start: ts('Saving Status Preference...') , success: ts('Preference Saved') }, + crmApi('StatusPreference', 'create', { + "sequential": 1, + "name": name, + "ignore_severity": 0, + "hush_until": "" + }) + .then(function(){rmStatus($scope, name);}) + ); + }; + + // will 'snooze' a status - will not show alerts at that level for that check + alerts below that level for that check until the specified date + $scope.snooze = function(status) { + $scope.showSnoozeOptions(status); + return crmStatus( + { status: ts('Saving Status Preference...') , success: ts('Preference Saved') }, + crmApi('StatusPreference', 'create', { + "sequential": 1, + "name": status.name, + "ignore_severity": status.snoozeOptions.severity, + "hush_until": status.snoozeOptions.until + }) .then(function(){rmStatus($scope, status.name);}) + ); + }; + $scope.showSnoozeOptions = function(status) { + status.snoozeOptions.show = !status.snoozeOptions.show; + }; + }); + + + /** + * remove a status after it has been hushed/snoozed + * @param {type} $scope + * @param {type} statusName + * @returns void + */ + function rmStatus($scope, statusName) { + $scope.statuses.values = _.reject($scope.statuses.values, + function(status) { + return status.name === statusName; + }); + } + +})(angular, CRM.$, CRM._); diff --git a/ang/crmStatusPage/crmSnoozeOption.js b/ang/crmStatusPage/crmSnoozeOption.js new file mode 100644 index 0000000000..b11cfd8170 --- /dev/null +++ b/ang/crmStatusPage/crmSnoozeOption.js @@ -0,0 +1,13 @@ +// creates a directive for the snooze options page + +(function(angular, $, _) { + angular.module('statuapage').directive('crmSnoozeOptions', function(statuspageSeverityList) { + return { + templateUrl: '~/statuspage/SnoozeOptions.html', + transclude: true, + link: function(scope, element, attr) { + scope.severityList = statuspageSeverityList; + } + }; + }); +})(angular, CRM.$, CRM._);