Commit a4eff55d authored by Annabel Dunstone Gray's avatar Annabel Dunstone Gray

Show health status when enabled; add new icons

parent 82941cf8
/* eslint-disable no-new*/ /* eslint-disable no-new*/
import './smart_interval'; import './smart_interval';
const healthyClass = 'geo-node-icon-healthy'; const healthyClass = 'geo-node-healthy';
const unhealthyClass = 'geo-node-icon-unhealthy'; const unhealthyClass = 'geo-node-unhealthy';
const healthyIcon = 'fa-check';
const unhealthyIcon = 'fa-close'
class GeoNodeStatus { class GeoNodeStatus {
constructor(el) { constructor(el) {
this.$el = $(el); this.$el = $(el);
this.$icon = $('.js-geo-node-icon', this.$el); this.$icon = $('.js-geo-node-icon', this.$el);
this.$healthStatus = $('.js-health-status', this.$el);
this.$status = $('.js-geo-node-status', this.$el); this.$status = $('.js-geo-node-status', this.$el);
this.$repositoriesSynced = $('.js-repositories-synced', this.$status); this.$repositoriesSynced = $('.js-repositories-synced', this.$status);
this.$repositoriesFailed = $('.js-repositories-failed', this.$status); this.$repositoriesFailed = $('.js-repositories-failed', this.$status);
...@@ -29,11 +32,14 @@ class GeoNodeStatus { ...@@ -29,11 +32,14 @@ class GeoNodeStatus {
getStatus() { getStatus() {
$.getJSON(this.endpoint, (status) => { $.getJSON(this.endpoint, (status) => {
this.setStatusIcon(status.healthy); this.setStatusIcon(status.healthy);
this.setHealthStatus(status.healthy);
this.$repositoriesSynced.html(`${status.repositories_synced_count}/${status.repositories_count} (${status.repositories_synced_in_percentage})`); this.$repositoriesSynced.html(`${status.repositories_synced_count}/${status.repositories_count} (${status.repositories_synced_in_percentage})`);
this.$repositoriesFailed.html(status.repositories_failed_count); this.$repositoriesFailed.html(status.repositories_failed_count);
this.$lfsObjectsSynced.html(`${status.lfs_objects_synced_count}/${status.lfs_objects_count} (${status.lfs_objects_synced_in_percentage})`); this.$lfsObjectsSynced.html(`${status.lfs_objects_synced_count}/${status.lfs_objects_count} (${status.lfs_objects_synced_in_percentage})`);
this.$attachmentsSynced.html(`${status.attachments_synced_count}/${status.attachments_count} (${status.attachments_synced_in_percentage})`); this.$attachmentsSynced.html(`${status.attachments_synced_count}/${status.attachments_count} (${status.attachments_synced_in_percentage})`);
this.$health.html(status.health); if (status.health !== 'Healthy') {
this.$health.html('<code class="geo-health">' + status.health + '</code>');
}
this.$status.show(); this.$status.show();
}); });
...@@ -41,17 +47,29 @@ class GeoNodeStatus { ...@@ -41,17 +47,29 @@ class GeoNodeStatus {
setStatusIcon(healthy) { setStatusIcon(healthy) {
if (healthy) { if (healthy) {
this.$icon.removeClass(unhealthyClass) this.$icon.removeClass(unhealthyClass + ' ' + unhealthyIcon)
.addClass(healthyClass) .addClass(healthyClass + ' ' + healthyIcon)
.attr('title', 'Healthy'); .attr('title', 'Healthy');
} else { } else {
this.$icon.removeClass(healthyClass) this.$icon.removeClass(healthyClass + ' ' + healthyIcon)
.addClass(unhealthyClass) .addClass(unhealthyClass + ' ' + unhealthyIcon)
.attr('title', 'Unhealthy'); .attr('title', 'Unhealthy');
} }
this.$icon.tooltip('fixTitle'); this.$icon.tooltip('fixTitle');
} }
setHealthStatus(healthy) {
if (healthy) {
this.$healthStatus.removeClass(unhealthyClass)
.addClass(healthyClass)
.html('Healthy');
} else {
this.$healthStatus.removeClass(healthyClass)
.addClass(unhealthyClass)
.html('Unhealthy');
}
}
} }
class GeoNodes { class GeoNodes {
......
...@@ -4,20 +4,18 @@ module EE ...@@ -4,20 +4,18 @@ module EE
unless node.primary? unless node.primary?
status = node.enabled? ? 'healthy' : 'disabled' status = node.enabled? ? 'healthy' : 'disabled'
icon 'check fw', if status == 'healthy'
icon = 'check'
else
icon = 'times'
end
icon "#{icon} fw",
class: "js-geo-node-icon geo-node-#{status} has-tooltip", class: "js-geo-node-icon geo-node-#{status} has-tooltip",
title: status.capitalize title: status.capitalize
end end
end end
def node_status(node)
status = node.enabled? ? 'healthy' : 'disabled'
content_tag :span, class: "geo-node-#{status}" do
status.capitalize
end
end
def toggle_node_button(node) def toggle_node_button(node)
btn_class, title, data = btn_class, title, data =
if node.enabled? if node.enabled?
......
...@@ -5,7 +5,7 @@ class GeoNodeStatusEntity < Grape::Entity ...@@ -5,7 +5,7 @@ class GeoNodeStatusEntity < Grape::Entity
expose :healthy?, as: :healthy expose :healthy?, as: :healthy
expose :health do |node| expose :health do |node|
node.healthy? ? 'No Health Problems Detected' : node.health node.healthy? ? 'Healthy' : node.health
end end
expose :attachments_count expose :attachments_count
......
...@@ -25,10 +25,11 @@ ...@@ -25,10 +25,11 @@
%span.help-block Primary node %span.help-block Primary node
- else - else
.js-geo-node-status{ style: 'display: none' } .js-geo-node-status{ style: 'display: none' }
%p - if node.enabled?
%span.help-block %p
Health Status: %span.help-block
%span= node_status(node) Health Status:
%span.js-health-status
%p %p
%span.help-block %span.help-block
Repositories synced: Repositories synced:
...@@ -46,7 +47,7 @@ ...@@ -46,7 +47,7 @@
Attachments synced: Attachments synced:
%span.node-info.js-attachments-synced %span.node-info.js-attachments-synced
%p %p
%code.geo-health.js-health .js-health
.node-actions .node-actions
- if Gitlab::Geo.license_allows? - if Gitlab::Geo.license_allows?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment