From d1fa280a8d3e668293cf5a2672b3bb0c5c705b57 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 16 Nov 2015 20:56:58 -0500 Subject: [PATCH] System.check api - add severity_id to output --- CRM/Utils/Check/Message.php | 3 ++- ang/crmStatusPage/StatusPageCtrl.js | 4 +--- ang/crmStatusPage/StatusPageServices.js | 4 ---- api/v3/System.php | 6 ++++++ tests/phpunit/api/v3/SystemCheckTest.php | 14 +++++++------- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/CRM/Utils/Check/Message.php b/CRM/Utils/Check/Message.php index 1e50c4e99a..a3640928c1 100644 --- a/CRM/Utils/Check/Message.php +++ b/CRM/Utils/Check/Message.php @@ -158,7 +158,8 @@ class CRM_Utils_Check_Message { 'name' => $this->name, 'message' => $this->message, 'title' => $this->title, - 'severity' => $this->level, + 'severity' => CRM_Utils_Check::severityMap($this->level, TRUE), + 'severity_id' => $this->level, 'is_visible' => (int) $this->isVisible(), 'icon' => $this->icon, ); diff --git a/ang/crmStatusPage/StatusPageCtrl.js b/ang/crmStatusPage/StatusPageCtrl.js index 629681f755..ed14b872d6 100644 --- a/ang/crmStatusPage/StatusPageCtrl.js +++ b/ang/crmStatusPage/StatusPageCtrl.js @@ -1,12 +1,10 @@ (function(angular, $, _) { angular.module('statuspage').controller('statuspageStatusPage', - function($scope, crmApi, crmStatus, statusData, statuspageSeverityList) { + function($scope, crmApi, crmStatus, statusData) { function preprocessStatuses(apiData) { _.each(apiData.values, function(status) { - status.severity_id = status.severity; - status.severity = statuspageSeverityList[status.severity]; if (status.hidden_until) { var date = $.datepicker.parseDate('yy-mm-dd', status.hidden_until); status.hidden_until = $.datepicker.formatDate(CRM.config.dateInputFormat, date); diff --git a/ang/crmStatusPage/StatusPageServices.js b/ang/crmStatusPage/StatusPageServices.js index 0173484b5c..6bcc28d058 100644 --- a/ang/crmStatusPage/StatusPageServices.js +++ b/ang/crmStatusPage/StatusPageServices.js @@ -3,10 +3,6 @@ angular.module('statuspage') .filter('trusted', function($sce){ return $sce.trustAsHtml; }) - .service('statuspageSeverityList', function() { - return ['debug', 'info', 'notice', 'warning', 'error', 'critical', 'alert', 'emergency']; - }) - // Todo: abstract this into a generic crmUi directive? .directive('statuspagePopupMenu', function($timeout) { return { diff --git a/api/v3/System.php b/api/v3/System.php index 56ec8897dd..0a2f0a44a8 100644 --- a/api/v3/System.php +++ b/api/v3/System.php @@ -110,6 +110,12 @@ function _civicrm_api3_system_check_spec(&$spec) { ); $spec['severity'] = array( 'title' => 'Severity', + 'description' => 'Psr\Log\LogLevel string', + 'type' => CRM_Utils_Type::T_STRING, + 'options' => array_combine(CRM_Utils_Check::$severityMap, CRM_Utils_Check::$severityMap), + ); + $spec['severity_id'] = array( + 'title' => 'Severity ID', 'description' => 'Integer representation of Psr\Log\LogLevel', 'type' => CRM_Utils_Type::T_INT, 'options' => CRM_Utils_Check::$severityMap, diff --git a/tests/phpunit/api/v3/SystemCheckTest.php b/tests/phpunit/api/v3/SystemCheckTest.php index 40fbc4e731..bc2f878a67 100644 --- a/tests/phpunit/api/v3/SystemCheckTest.php +++ b/tests/phpunit/api/v3/SystemCheckTest.php @@ -63,7 +63,7 @@ class api_v3_SystemCheckTest extends CiviUnitTestCase { break; } } - $this->assertEquals($testedCheck['severity'], '3', ' in line ' . __LINE__); + $this->assertEquals($testedCheck['severity_id'], '3', ' in line ' . __LINE__); } /** @@ -89,7 +89,7 @@ class api_v3_SystemCheckTest extends CiviUnitTestCase { } /** - * Items hushed through tomorrow shouldn't show up. + * Items hushed through tomorrow shouldn't show up. */ public function testSystemCheckHushFuture() { $tomorrow = new DateTime('tomorrow'); @@ -113,7 +113,7 @@ class api_v3_SystemCheckTest extends CiviUnitTestCase { } /** - * Items hushed through today should show up. + * Items hushed through today should show up. */ public function testSystemCheckHushToday() { $today = new DateTime('today'); @@ -137,7 +137,7 @@ class api_v3_SystemCheckTest extends CiviUnitTestCase { } /** - * Items hushed through yesterday should show up. + * Items hushed through yesterday should show up. */ public function testSystemCheckHushYesterday() { $yesterday = new DateTime('yesterday'); @@ -161,7 +161,7 @@ class api_v3_SystemCheckTest extends CiviUnitTestCase { } /** - * Items hushed above current severity should be hidden. + * Items hushed above current severity should be hidden. */ public function testSystemCheckHushAboveSeverity() { $this->_params = array( @@ -183,7 +183,7 @@ class api_v3_SystemCheckTest extends CiviUnitTestCase { } /** - * Items hushed at current severity should be hidden. + * Items hushed at current severity should be hidden. */ public function testSystemCheckHushAtSeverity() { $this->_params = array( @@ -205,7 +205,7 @@ class api_v3_SystemCheckTest extends CiviUnitTestCase { } /** - * Items hushed below current severity should be shown. + * Items hushed below current severity should be shown. */ public function testSystemCheckHushBelowSeverity() { $this->_params = array( -- 2.25.1