From 28bd6c8dbcb20cd0843c58a89bdbc73014251386 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 23 Oct 2015 08:43:19 -0400 Subject: [PATCH] CRM-13823 - Snooze/hush cleanup --- ang/crmStatusPage.js | 2 +- ang/crmStatusPage/StatusPage.html | 7 ++- ang/crmStatusPage/StatusPageCtrl.js | 86 ++++++++++++----------------- 3 files changed, 39 insertions(+), 56 deletions(-) diff --git a/ang/crmStatusPage.js b/ang/crmStatusPage.js index a83b201392..781dff7bdd 100644 --- a/ang/crmStatusPage.js +++ b/ang/crmStatusPage.js @@ -13,7 +13,7 @@ resolve: { statusData: function(crmApi) { - return crmApi('System', 'check', {sequential: 1}); + return crmApi('System', 'check', {sequential: 1, options: {limit: 0}}); } } }); diff --git a/ang/crmStatusPage/StatusPage.html b/ang/crmStatusPage/StatusPage.html index f2ea1d79aa..ad5782c7ed 100644 --- a/ang/crmStatusPage/StatusPage.html +++ b/ang/crmStatusPage/StatusPage.html @@ -10,7 +10,8 @@
@@ -22,8 +23,8 @@ - - + +

diff --git a/ang/crmStatusPage/StatusPageCtrl.js b/ang/crmStatusPage/StatusPageCtrl.js index 5182cc6ca8..dabde92d42 100644 --- a/ang/crmStatusPage/StatusPageCtrl.js +++ b/ang/crmStatusPage/StatusPageCtrl.js @@ -1,7 +1,5 @@ (function(angular, $, _) { - // controller - angular.module('statuspage').controller('statuspageStatusPage', function($scope, crmApi, crmStatus, statusData, statuspageSeverityList) { @@ -18,62 +16,46 @@ }; }); - // 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') }, + // 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(status) { crmApi('StatusPreference', 'create', { - "sequential": 1, - "name": name, - "ignore_severity": severity, + "name": status.name, + "ignore_severity": status.severity, "hush_until": "" - }) - .then(function(){rmStatus($scope, name);}) - ); - }; + }, true) + .then(function() { + status.is_visible = 0; + }); + }; // 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', { - "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', { - "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; + $scope.unhush = function(status) { + crmApi('StatusPreference', 'create', { + "name": status.name, + "ignore_severity": 0, + "hush_until": "" + }, true) + .then(function() { + status.is_visible = 1; + }); }; - }); - - /** - * 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; + // 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); + crmApi('StatusPreference', 'create', { + "name": status.name, + "ignore_severity": status.snoozeOptions.severity, + "hush_until": status.snoozeOptions.until + }, true) + .then(function() { + status.is_visible = 0; + }); + }; + + $scope.showSnoozeOptions = function(status) { + status.snoozeOptions.show = !status.snoozeOptions.show; + }; }); - } })(angular, CRM.$, CRM._); -- 2.25.1