Blame SOURCES/bz1264360-02-web-ui-change-way-of-displaying-status-of-unmanaged-primitive-resources.patch

15f218
From 563a2c51877b9cf2a5ae419fc6d4eeb680eed04f Mon Sep 17 00:00:00 2001
15f218
From: Ondrej Mular <omular@redhat.com>
15f218
Date: Wed, 24 Aug 2016 10:04:01 +0200
15f218
Subject: [PATCH] web UI: change way of displaying status of unmanaged
15f218
 primitive resources
15f218
15f218
---
15f218
 pcsd/cluster_entity.rb        | 11 +----------
15f218
 pcsd/public/js/nodes-ember.js | 27 ++++++++++++++++++++++-----
15f218
 pcsd/public/js/pcsd.js        | 10 ++++++----
15f218
 pcsd/views/manage.erb         | 15 ++++++++++-----
15f218
 4 files changed, 39 insertions(+), 24 deletions(-)
15f218
15f218
diff --git a/pcsd/cluster_entity.rb b/pcsd/cluster_entity.rb
15f218
index 7216626..4ffcd4b 100644
15f218
--- a/pcsd/cluster_entity.rb
15f218
+++ b/pcsd/cluster_entity.rb
15f218
@@ -333,10 +333,6 @@ module ClusterEntity
15f218
         :val => 6,
15f218
         :str => 'unknown'
15f218
       },
15f218
-      :unmanaged => {
15f218
-        :val => 7,
15f218
-        :str => 'unmanaged'
15f218
-      },
15f218
     }
15f218
 
15f218
     def initialize(status=:unknown)
15f218
@@ -536,11 +532,8 @@ module ClusterEntity
15f218
     def get_status
15f218
       running = 0
15f218
       failed = 0
15f218
-      unmanaged = 0
15f218
       @crm_status.each do |s|
15f218
-        if !s.managed
15f218
-          unmanaged += 1
15f218
-        elsif s.active
15f218
+        if s.active
15f218
           running += 1
15f218
         elsif s.failed
15f218
           failed += 1
15f218
@@ -549,8 +542,6 @@ module ClusterEntity
15f218
 
15f218
       if disabled?
15f218
         status = ClusterEntity::ResourceStatus.new(:disabled)
15f218
-      elsif unmanaged >0
15f218
-        status = ClusterEntity::ResourceStatus.new(:unmanaged)
15f218
       elsif running > 0
15f218
         status = ClusterEntity::ResourceStatus.new(:running)
15f218
       elsif failed > 0 or @error_list.length > 0
15f218
diff --git a/pcsd/public/js/nodes-ember.js b/pcsd/public/js/nodes-ember.js
15f218
index f176c39..c650fe6 100644
15f218
--- a/pcsd/public/js/nodes-ember.js
15f218
+++ b/pcsd/public/js/nodes-ember.js
15f218
@@ -851,7 +851,9 @@ Pcs.ResourceObj = Ember.Object.extend({
15f218
   }.property("class_type"),
15f218
   res_type: Ember.computed.alias('resource_type'),
15f218
   status_icon: function() {
15f218
-    var icon_class = get_status_icon_class(this.get("status_val"));
15f218
+    var icon_class = get_status_icon_class(
15f218
+      this.get("status_val"), this.get("is_unmanaged")
15f218
+    );
15f218
     return "
";
15f218
   }.property("status_val"),
15f218
   status_val: function() {
15f218
@@ -867,19 +869,23 @@ Pcs.ResourceObj = Ember.Object.extend({
15f218
     }
15f218
   }.property('status', 'error_list.@each.message', 'warning_list.@each.message'),
15f218
   status_color: function() {
15f218
-    return get_status_color(this.get("status_val"));
15f218
+    return get_status_color(this.get("status_val"), this.get("is_unmanaged"));
15f218
   }.property("status_val"),
15f218
   status_style: function() {
15f218
-    var color = get_status_color(this.get("status_val"));
15f218
+    var color = get_status_color(
15f218
+      this.get("status_val"), this.get("is_unmanaged")
15f218
+    );
15f218
     return "color: " + color + ((color != "green")? "; font-weight: bold;" : "");
15f218
   }.property("status_val"),
15f218
   show_status: function() {
15f218
-    return '' + this.get('status') + '';
15f218
+    return ''
15f218
+      + this.get('status') + (this.get("is_unmanaged") ? " (unmanaged)" : "")
15f218
+      + '';
15f218
   }.property("status_style", "disabled"),
15f218
   status_class: function() {
15f218
     if (
15f218
       this.get("status_val") == get_status_value("ok") ||
15f218
-      ["disabled", "unmanaged"].indexOf(this.get("status")) != -1
15f218
+      this.get("status") == "disabled"
15f218
     ) {
15f218
       return (
15f218
         Pcs.clusterController.get("show_all_resources") ? "" : "hidden "
15f218
@@ -1003,6 +1009,17 @@ Pcs.PrimitiveObj = Pcs.ResourceObj.extend({
15f218
   instance_status: [],
15f218
   operations: [],
15f218
   utilization: [],
15f218
+  is_unmanaged: function() {
15f218
+    var instance_status_list = this.get("instance_status");
15f218
+    if (!instance_status_list) {
15f218
+      return false;
15f218
+    }
15f218
+    var is_managed = true;
15f218
+    $.each(instance_status_list, function(_, instance_status) {
15f218
+      is_managed = is_managed && instance_status.get("managed");
15f218
+    });
15f218
+    return !is_managed;
15f218
+  }.property("instance_status.@each.managed"),
15f218
   resource_type: function() {
15f218
     var agent = this.get("agentname");
15f218
     if (agent) {
15f218
diff --git a/pcsd/public/js/pcsd.js b/pcsd/public/js/pcsd.js
15f218
index 1060bd3..67a0bdb 100644
15f218
--- a/pcsd/public/js/pcsd.js
15f218
+++ b/pcsd/public/js/pcsd.js
15f218
@@ -1977,7 +1977,8 @@ function status_comparator(a,b) {
15f218
   return valA - valB;
15f218
 }
15f218
 
15f218
-function get_status_icon_class(status_val) {
15f218
+function get_status_icon_class(status_val, is_unmanaged) {
15f218
+  var is_unmanaged = typeof is_unmanaged !== 'undefined' ? is_unmanaged : false;
15f218
   switch (status_val) {
15f218
     case get_status_value("error"):
15f218
       return "error";
15f218
@@ -1985,15 +1986,16 @@ function get_status_icon_class(status_val) {
15f218
     case get_status_value("warning"):
15f218
       return "warning";
15f218
     case get_status_value("ok"):
15f218
-      return "check";
15f218
+      return is_unmanaged ? "warning" : "check";
15f218
     default:
15f218
       return "x";
15f218
   }
15f218
 }
15f218
 
15f218
-function get_status_color(status_val) {
15f218
+function get_status_color(status_val, is_unmanaged) {
15f218
+  var is_unmanaged = typeof is_unmanaged !== 'undefined' ? is_unmanaged : false;
15f218
   if (status_val == get_status_value("ok")) {
15f218
-    return "green";
15f218
+    return is_unmanaged? "orange" : "green";
15f218
   }
15f218
   else if (status_val == get_status_value("warning") || status_val == get_status_value("unknown") || status_val == get_status_value('disabled')) {
15f218
     return "orange";
15f218
diff --git a/pcsd/views/manage.erb b/pcsd/views/manage.erb
15f218
index 885b327..39ab41f 100644
15f218
--- a/pcsd/views/manage.erb
15f218
+++ b/pcsd/views/manage.erb
15f218
@@ -113,13 +113,18 @@
15f218
               
15f218
                 
15f218
                   
15f218
-                    RESOURCE
15f218
-                    STATUS
15f218
+                    RESOURCE
15f218
+                    STATUS
15f218
                   
15f218
                   {{#each r in Pcs.clusterController.cur_cluster.resource_list}}
15f218
                   
15f218
                     {{r.id}}
15f218
-                    {{{r.status_icon}}}{{r.status}}
15f218
+                    
15f218
+                      {{{r.status_icon}}}{{r.status}}
15f218
+                      {{#if r.is_unmanaged}}
15f218
+                        (unmanaged)
15f218
+                      {{/if}}
15f218
+                    
15f218
                   
15f218
                   {{else}}
15f218
                   
15f218
@@ -144,8 +149,8 @@
15f218
               
15f218
                 
15f218
                   
15f218
-                    FENCE-DEVICE
15f218
-                    STATUS
15f218
+                    FENCE-DEVICE
15f218
+                    STATUS
15f218
                   
15f218
                   {{#each f in Pcs.clusterController.cur_cluster.fence_list}}
15f218
                   
15f218
-- 
15f218
1.8.3.1
15f218