Commit e3c1885b authored by Stan Hu's avatar Stan Hu

Fix Geo Node admin screen no longer displaying data

As a result of f3ae99fa, SmartInterval was refactored to use a Promised-based
callback.

This MR also fixes a bug where objects were always showing "Not Available".

Closes #3987
parent 49a9bdbb
/* eslint-disable no-new*/ /* eslint-disable no-new*/
import './smart_interval'; import axios from 'axios';
import SmartInterval from '~/smart_interval';
import { parseSeconds, stringifyTime } from './lib/utils/pretty_time'; import { parseSeconds, stringifyTime } from './lib/utils/pretty_time';
const healthyClass = 'geo-node-healthy'; const healthyClass = 'geo-node-healthy';
...@@ -31,7 +32,7 @@ class GeoNodeStatus { ...@@ -31,7 +32,7 @@ class GeoNodeStatus {
this.$advancedStatus = $('.js-advanced-geo-node-status-toggler', this.$status); this.$advancedStatus = $('.js-advanced-geo-node-status-toggler', this.$status);
this.$advancedStatus.on('click', GeoNodeStatus.toggleShowAdvancedStatus); this.$advancedStatus.on('click', GeoNodeStatus.toggleShowAdvancedStatus);
this.statusInterval = new gl.SmartInterval({ this.statusInterval = new SmartInterval({
callback: this.getStatus.bind(this), callback: this.getStatus.bind(this),
startingInterval: 30000, startingInterval: 30000,
maxInterval: 120000, maxInterval: 120000,
...@@ -59,14 +60,24 @@ class GeoNodeStatus { ...@@ -59,14 +60,24 @@ class GeoNodeStatus {
static formatCount(count) { static formatCount(count) {
if (count !== null) { if (count !== null) {
gl.text.addDelimiter(count); return gl.text.addDelimiter(count);
} }
return notAvailable; return notAvailable;
} }
getStatus() { getStatus() {
$.getJSON(this.endpoint, (status) => { return axios.get(this.endpoint)
.then((response) => {
this.handleStatus(response.data);
return response;
})
.catch((err) => {
this.handleError(err);
});
}
handleStatus(status) {
this.setStatusIcon(status.healthy); this.setStatusIcon(status.healthy);
this.setHealthStatus(status.healthy); this.setHealthStatus(status.healthy);
...@@ -141,7 +152,13 @@ class GeoNodeStatus { ...@@ -141,7 +152,13 @@ class GeoNodeStatus {
} }
this.$status.show(); this.$status.show();
}); }
handleError(err) {
this.setStatusIcon(false);
this.setHealthStatus(false);
this.$health.html(`<code class="geo-health">${err}</code>`);
this.$status.show();
} }
setStatusIcon(healthy) { setStatusIcon(healthy) {
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
Geo nodes (#{@nodes.count}) Geo nodes (#{@nodes.count})
%ul.well-list.geo-nodes %ul.well-list.geo-nodes
- @nodes.each do |node| - @nodes.each do |node|
%li{ id: dom_id(node), class: node_class(node), data: { status_url: status_admin_geo_node_path(node) } } %li{ id: dom_id(node), class: node_class(node), data: { status_url: status_admin_geo_node_path(node, format: :json) } }
.node-block .node-block
= node_status_icon(node) = node_status_icon(node)
%strong= node.url %strong= node.url
......
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