Show information for each secondary node on Geo Nodes page

[ci skip]
parent 8419ebfb
.geo-node-icon-enabled { .geo-node-icon-healthy {
color: $gl-success; color: $gl-success;
} }
.geo-node-icon-disabled { .geo-node-icon-unhealthy {
color: $gl-danger; color: $gl-danger;
} }
.geo-node-icon-disabled {
color: $gray-darkest;
}
...@@ -3,7 +3,7 @@ class Admin::GeoNodesController < Admin::ApplicationController ...@@ -3,7 +3,7 @@ class Admin::GeoNodesController < Admin::ApplicationController
before_action :load_node, only: [:destroy, :repair, :toggle] before_action :load_node, only: [:destroy, :repair, :toggle]
def index def index
@nodes = GeoNode.all @nodes = GeoNode.all.map(&:present)
@node = GeoNode.new @node = GeoNode.new
unless Gitlab::Geo.license_allows? unless Gitlab::Geo.license_allows?
......
...@@ -2,9 +2,14 @@ module EE ...@@ -2,9 +2,14 @@ module EE
module GeoHelper module GeoHelper
def node_status_icon(node) def node_status_icon(node)
if node.primary? if node.primary?
icon 'star fw' icon 'star fw', class: 'has-tooltip', title: 'Primary node'
else else
status = node.enabled? ? 'enabled' : 'disabled' status =
if node.enabled?
node.healthy? ? 'healthy' : 'unhealthy'
else
'disabled'
end
icon 'globe fw', icon 'globe fw',
class: "geo-node-icon-#{status} has-tooltip", class: "geo-node-icon-#{status} has-tooltip",
......
class GeoNode < ActiveRecord::Base class GeoNode < ActiveRecord::Base
include Presentable
Status = Struct.new(:health, :repositories, :repositories_synced, :repositories_failed) Status = Struct.new(:health, :repositories, :repositories_synced, :repositories_failed)
belongs_to :geo_node_key, dependent: :destroy belongs_to :geo_node_key, dependent: :destroy
......
class GeoNodePresenter < Gitlab::View::Presenter::Delegated
presents :geo_node
def healthy?
health.blank?
end
def health
status.health
end
def repositories_synced
(status.repositories_synced.to_f / status.repositories.to_f) * 100.0
end
def repositories_failed
status.repositories_failed
end
private
def status
@status ||= begin
_, status = Geo::NodeStatusService.new.call(status_url)
status
end
end
end
...@@ -21,8 +21,15 @@ ...@@ -21,8 +21,15 @@
%span %span
= node_status_icon(node) = node_status_icon(node)
%strong= node.url %strong= node.url
- if node.primary?
%span.help-block Primary node
- else
%p %p
%span.help-block= node.primary ? 'Primary node' : 'Secondary node' %span.help-block= "Repositorie synced: #{number_to_percentage(node.repositories_synced, precision: 0)}"
%p
%span.help-block= "Repositorie failed: #{node.repositories_failed}"
%p
%span.help-block= node.healthy? ? 'No Health Problems Detected' : node.health
.pull-right .pull-right
- 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