System.check api - add severity_id to output
authorColeman Watts <coleman@civicrm.org>
Tue, 17 Nov 2015 01:56:58 +0000 (20:56 -0500)
committerColeman Watts <coleman@civicrm.org>
Tue, 17 Nov 2015 02:26:49 +0000 (21:26 -0500)
CRM/Utils/Check/Message.php
ang/crmStatusPage/StatusPageCtrl.js
ang/crmStatusPage/StatusPageServices.js
api/v3/System.php
tests/phpunit/api/v3/SystemCheckTest.php

index 1e50c4e99aaf22a59818f741905d0b550267c4a5..a3640928c1802c1a71a18d21ecb725c23cfc3e00 100644 (file)
@@ -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,
     );
index 629681f755933802e2261df2e19e8e787ee21da6..ed14b872d63101ededee057ca268481120538781 100644 (file)
@@ -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);
index 0173484b5cb930acdbe3f3186c9e6dfa8b2d8109..6bcc28d0580e176f1b47cff6c05f0bf30934d870 100644 (file)
@@ -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 {
index 56ec8897dd74cb840937f8ab447e8e2239f059b6..0a2f0a44a809f8aa7a7c778dde6ecb5310dbd159 100644 (file)
@@ -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,
index 40fbc4e7313164a134d3d03bd14a6ae426240f56..bc2f878a67b7cb9bb4cab273e91bd67c62cf0cc2 100644 (file)
@@ -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(