--- /dev/null
+/* 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;
+}
--- /dev/null
+(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._);
--- /dev/null
+<span ng-form="snoozeOptions" crm-ui-id-scope style="display: inline">
+ <span crm-ui-field="{name: 'snoozeOptions.until', title: ts('Snooze until')}" style="display: inline" >
+ <input name="until" crm-ui-datepicker ng-model="status.snoozeOptions.until" style="display: inline" />
+ <a crm-icon="fa-floppy-o" ng-click="snooze(status)" class="crm-hover-button" title="{{ts('Save Preference')}}"></a>
+ <span>
+</span>
+ <!-- snooze options page, creates a box for picking a date you would like to snooze a status alert until -->
--- /dev/null
+<div class="crm-container">
+ <div crm-ui-debug="statuses"></div>
+ <div crm-ui-debug="preferences"></div>
+
+ <form name="myForm" crm-ui-id-scope>
+
+ <div class="help">
+ <p>{{ts('Help messages will be displayed here')}}</p>
+ </div>
+
+ <div>
+ <h1>Status Page</h1><br />
+ <button ng-if="(path === '/status/hushed')" ng-click="navigator.redirect('#/status')">Return home</button>
+ <button ng-if="(path === '/status')" ng-click="navigator.redirect('#/status/hushed')">Show snoozed and hushed</button>
+ </div>
+ <div id="crm-status-list" ng-repeat="status in statuses.values track by status.name" >
+ <h3 class="crm-severity-{{status.severity}}">{{status.title}}
+ <span class="status-snooze-options" ng-show="status.snoozeOptions.show" style="display: inline-block">
+ <div crm-snooze-options style="display: inline"></div>
+ </span>
+ <a ng-if="(path === '/status')" ng-click="showSnoozeOptions(status)" ng-show="!status.snoozeOptions.show" class="crm-hover-button" crm-icon="fa-clock-o" title="{{ts('Snooze')}}"></a>
+ <a ng-click="showSnoozeOptions(status)" ng-show="status.snoozeOptions.show" class="crm-hover-button" crm-icon="fa-times" style="display: inline" title="{{ts('Close')}}"></a>
+ <a ng-if="(path === '/status')" ng-click="hush(status.name, status.severity)" class="crm-hover-button" crm-icon="fa-bell-slash-o" title="{{ts('Hush')}}"></a>
+ <a ng-if="(path === '/status/hushed')" ng-click="unhush(status.name)" class="crm-hover-button" crm-icon="fa-bell-o" title="{{ts('Unhush And Unsnooze')}}"></a>
+ </h3>
+ <h4>
+ <div class="crm-block">
+ <div class="crm-group">
+ <div class="crm-status-message-body" ng-bind-html="status.message | trusted"></div>
+ </div>
+ </div>
+ </h4><br/>
+ </div>
+
+ </form>
+
+</div>
--- /dev/null
+(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._);
--- /dev/null
+(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._);
--- /dev/null
+// 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._);