consul-templaterb 1.15.2 → 1.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGELOG.md +4 -0
- data/lib/consul/async/version.rb +1 -1
- data/samples/consul-ui/css/style.css +1 -1
- data/samples/consul-ui/js/keys.js +1 -1
- data/samples/consul-ui/js/nodes.js +1 -4
- data/samples/consul-ui/js/service.js +91 -94
- data/samples/consul-ui/js/timeline.js +2 -2
- data/samples/consul-ui/js/utils.js +13 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e5d7b1fe74f3740048aeef233a2f97097f90042fbdfa8a43776ec9b3ed1d3cab
|
4
|
+
data.tar.gz: 7bd5f3cea503187786e05b62d0748afaf0de8c1629333e70bec2689d88a2e79c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eabeef36879669e2dc937f06fcac7a7f92b1f107840a8717b11df2b9527df9da1b0bdc490c3db5c54b0e826502557e8a84f8ae72216e98736f95650893085d0a
|
7
|
+
data.tar.gz: f982bafbe7e6060f6db7ae0cf60b576ba4c3ff4c33b645636f6aa0b309108ba84f63fbc11941e3a0a692de1bb96343be18722611d21ca7f5ff09f330b67d030d
|
data/CHANGELOG.md
CHANGED
data/lib/consul/async/version.rb
CHANGED
@@ -4,7 +4,7 @@ class ConsulKeys {
|
|
4
4
|
this.fetchRessource();
|
5
5
|
this.keysList = $("#keys-list");
|
6
6
|
this.keysFilter = $("#keys-filter");
|
7
|
-
this.keysFilter.keyup(this.filterService);
|
7
|
+
this.keysFilter.keyup(debounce(this.filterService, 250));
|
8
8
|
this.refresh = parseInt(refresh);
|
9
9
|
this.keysFilterCounter = $("#keys-counter");
|
10
10
|
this.keysFilterCount = 0;
|
@@ -3,10 +3,7 @@ class ConsulNodes {
|
|
3
3
|
this.ressourceURL = ressourceURL;
|
4
4
|
this.fetchRessource();
|
5
5
|
this.instanceFilter = $("#instance-filter");
|
6
|
-
this.instanceFilter.keyup(
|
7
|
-
clearTimeout(consulNodes.timeout);
|
8
|
-
consulNodes.timeout = setTimeout(consulNodes.filterInstances, 400);
|
9
|
-
});
|
6
|
+
this.instanceFilter.keyup(debounce(this.filterInstances, 400));
|
10
7
|
this.refresh = parseInt(refresh);
|
11
8
|
this.filterStatus = null;
|
12
9
|
this.maxDisplayed = 100;
|
@@ -1,12 +1,12 @@
|
|
1
1
|
class ConsulService {
|
2
|
-
constructor(
|
3
|
-
this.
|
2
|
+
constructor(resourceURL, refresh) {
|
3
|
+
this.resourceURL = resourceURL;
|
4
4
|
this.fetchRessource();
|
5
5
|
this.serviceList = $("#service-list");
|
6
6
|
this.serviceFilter = $("#service-filter");
|
7
|
-
this.serviceFilter.keyup(this.filterService);
|
7
|
+
this.serviceFilter.keyup(debounce(this.filterService, 250));
|
8
8
|
this.instanceFilter = $("#instance-filter");
|
9
|
-
this.instanceFilter.keyup(this.filterInstances);
|
9
|
+
this.instanceFilter.keyup(debounce(this.filterInstances, 250));
|
10
10
|
this.refresh = parseInt(refresh);
|
11
11
|
this.filterStatus = null;
|
12
12
|
this.serviceFilterCounter = $("#service-counter");
|
@@ -33,135 +33,132 @@ class ConsulService {
|
|
33
33
|
}
|
34
34
|
}
|
35
35
|
|
36
|
-
fetchRessource() {
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
async fetchRessource() {
|
37
|
+
const response = await fetch(this.resourceURL);
|
38
|
+
const result = await response.json();
|
39
|
+
await this.initRessource(result);
|
40
40
|
}
|
41
41
|
|
42
|
-
initRessource(data) {
|
42
|
+
async initRessource(data) {
|
43
43
|
this.data = data;
|
44
|
-
this.reloadServiceList();
|
44
|
+
await this.reloadServiceList();
|
45
45
|
console.log('Data generated at: ' + data['generated_at']);
|
46
46
|
|
47
47
|
var urlParam = new URL(location.href).searchParams.get('service');
|
48
|
-
|
49
|
-
var servicePrefix = '#service_'
|
50
|
-
if (location.hash.startsWith(servicePrefix)) {
|
51
|
-
urlParam = location.hash.substr(servicePrefix.length)
|
52
|
-
}
|
53
|
-
}
|
48
|
+
|
54
49
|
if (urlParam) {
|
55
50
|
var nodes = document.getElementById('service-list').childNodes;
|
56
|
-
for(
|
57
|
-
if($(
|
58
|
-
var selectedElement = $(
|
51
|
+
for (const node of nodes) {
|
52
|
+
if($(node).find(".service-name").html() == urlParam) {
|
53
|
+
var selectedElement = $(node)
|
59
54
|
this.selectService(selectedElement);
|
60
55
|
selectedElement.focus()
|
61
56
|
break;
|
62
57
|
}
|
63
58
|
}
|
64
|
-
|
59
|
+
this.serviceFilter.val(urlParam);
|
60
|
+
this.filterService()
|
61
|
+
} else {
|
62
|
+
var servicePrefix = '#service_'
|
63
|
+
if (location.hash.startsWith(servicePrefix)) {
|
64
|
+
urlParam = location.hash.substr(servicePrefix.length)
|
65
|
+
}
|
65
66
|
this.selectService(document.getElementById('service-list').firstElementChild);
|
66
67
|
}
|
67
68
|
|
68
69
|
if(this.refresh > 0) {
|
69
70
|
setTimeout(this.fetchRessource, this.refresh * 1000);
|
70
71
|
}
|
71
|
-
|
72
|
-
let urlServiceParam = new URL(location.href).searchParams.get('filter');
|
73
|
-
if (urlServiceParam === null) {
|
74
|
-
return
|
75
|
-
} else if (urlServiceParam) {
|
76
|
-
this.serviceFilter.val(urlServiceParam);
|
77
|
-
this.filterService()
|
78
|
-
}
|
79
72
|
}
|
80
73
|
|
81
|
-
reloadServiceList() {
|
74
|
+
async reloadServiceList() {
|
82
75
|
this.serviceList.html('');
|
83
76
|
this.serviceFilterCount = 0;
|
84
77
|
|
85
|
-
let idx = 0;
|
86
|
-
let lastFav = null;
|
87
78
|
if (!this.data || !this.data.services) {
|
88
79
|
console.log("No data to display");
|
89
80
|
} else {
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
if (!!serviceStatus['passing']) {
|
106
|
-
statuses.appendChild(createBadge('badge-success passing', serviceStatus['passing']));
|
107
|
-
listItem.setAttribute('status', 'passing');
|
108
|
-
}
|
81
|
+
const services = Object.values(this.data.services).map((service, index) => ({ service, index }));
|
82
|
+
const favorites = services.filter(({ service }) => this.favorites[service.name]);
|
83
|
+
const others = services.filter(({ service }) => !this.favorites[service.name]);
|
84
|
+
|
85
|
+
const appendServiceAsync = ({ service, index }) =>
|
86
|
+
new Promise(resolve =>
|
87
|
+
setTimeout(() => {
|
88
|
+
this.appendService(service, index);
|
89
|
+
resolve();
|
90
|
+
}, 0)
|
91
|
+
);
|
92
|
+
|
93
|
+
await Promise.all([...favorites, ...others].map(appendServiceAsync));
|
94
|
+
}
|
109
95
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
96
|
+
this.serviceFilterCounter.html(this.serviceFilterCount);
|
97
|
+
resizeWrapper('service-wrapper', 'service-list');
|
98
|
+
this.filterService();
|
99
|
+
}
|
114
100
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
}
|
101
|
+
appendService(service, index) {
|
102
|
+
var serviceName = service.name;
|
103
|
+
var serviceStatus = buildServiceStatus(service);
|
119
104
|
|
120
|
-
|
105
|
+
var listItem = document.createElement('li');
|
106
|
+
listItem.setAttribute('onfocus','consulService.onClickServiceName(this)');
|
107
|
+
listItem.setAttribute('onclick','consulService.onClickServiceName(this)');
|
108
|
+
listItem.setAttribute('value', serviceName);
|
109
|
+
listItem.setAttribute('data-fav', this.favorites[serviceName] ? 1 : 0);
|
110
|
+
listItem.setAttribute('data-index', index);
|
111
|
+
var listItemClass = 'serviceListItem list-group-item list-group-item-action';
|
121
112
|
|
122
|
-
|
113
|
+
var statuses = document.createElement('div');
|
114
|
+
statuses.setAttribute('class','statuses float-right');
|
123
115
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
kind.appendChild(createBadge('badge-info kind', service['kind']));
|
129
|
-
listItem.appendChild(kind);
|
130
|
-
listItemClass+= " kind-" + service['kind'];
|
131
|
-
}
|
132
|
-
listItem.setAttribute('class', listItemClass);
|
116
|
+
if (!!serviceStatus['passing']) {
|
117
|
+
statuses.appendChild(createBadge('badge-success passing', serviceStatus['passing']));
|
118
|
+
listItem.setAttribute('status', 'passing');
|
119
|
+
}
|
133
120
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
121
|
+
if (!!serviceStatus['warning']) {
|
122
|
+
statuses.appendChild(createBadge('badge-warning warning', serviceStatus['warning']));
|
123
|
+
listItem.setAttribute('status', 'warning');
|
124
|
+
}
|
138
125
|
|
139
|
-
|
140
|
-
|
126
|
+
if (!!serviceStatus['critical']) {
|
127
|
+
statuses.appendChild(createBadge('badge-danger critical', serviceStatus['critical']));
|
128
|
+
listItem.setAttribute('status', 'critical');
|
129
|
+
}
|
141
130
|
|
142
|
-
|
143
|
-
serviceTagsItem.appendChild(createBadge('float-right badge-' + (i%2?'secondary':'info') , service.tags[i]));
|
144
|
-
}
|
131
|
+
statuses.appendChild(createBadge('badge-dark', (serviceStatus['total'] || 0)));
|
145
132
|
|
146
|
-
|
147
|
-
this.serviceFilterCount += 1;
|
133
|
+
statuses.append(this.buildFavButton(serviceName));
|
148
134
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
135
|
+
listItem.appendChild(statuses);
|
136
|
+
if (!!service['kind']) {
|
137
|
+
var kind = document.createElement('div');
|
138
|
+
kind.setAttribute('class','kind float-right');
|
139
|
+
kind.appendChild(createBadge('badge-info kind', service['kind']));
|
140
|
+
listItem.appendChild(kind);
|
141
|
+
listItemClass+= " kind-" + service['kind'];
|
142
|
+
}
|
143
|
+
listItem.setAttribute('class', listItemClass);
|
158
144
|
|
159
|
-
|
160
|
-
|
145
|
+
var serviceNameItem = document.createElement('div');
|
146
|
+
serviceNameItem.setAttribute('class', 'service-name');
|
147
|
+
serviceNameItem.appendChild(document.createTextNode(serviceName));
|
148
|
+
listItem.appendChild(serviceNameItem);
|
149
|
+
|
150
|
+
var serviceTagsItem = document.createElement('div');
|
151
|
+
serviceTagsItem.setAttribute('class', 'service-tags');
|
152
|
+
|
153
|
+
for (var i = 0; i < service.tags.length; i++) {
|
154
|
+
serviceTagsItem.appendChild(createBadge('float-right badge-' + (i%2?'secondary':'info') , service.tags[i]));
|
161
155
|
}
|
162
|
-
|
163
|
-
|
164
|
-
|
156
|
+
|
157
|
+
listItem.appendChild(serviceTagsItem);
|
158
|
+
|
159
|
+
this.serviceList.append(listItem);
|
160
|
+
|
161
|
+
this.serviceFilterCount += 1;
|
165
162
|
}
|
166
163
|
|
167
164
|
filterService() {
|
@@ -5,10 +5,10 @@ class ServiceTimeline {
|
|
5
5
|
this.fetchRessource(true);
|
6
6
|
this.serviceList = $("#service-list");
|
7
7
|
this.serviceFilter = $("#service-filter");
|
8
|
-
this.serviceFilter.keyup(this.filterService);
|
8
|
+
this.serviceFilter.keyup(debounce(this.filterService, 250));
|
9
9
|
this.serviceInstanceFilter = '';
|
10
10
|
this.instanceFilter = $("#instance-filter");
|
11
|
-
this.instanceFilter.keyup(this.doFilter);
|
11
|
+
this.instanceFilter.keyup(debounce(this.doFilter, 250));
|
12
12
|
this.refresh = parseInt(refresh);
|
13
13
|
this.filterStatus = null;
|
14
14
|
this.refreshTimeout = null;
|
@@ -12,6 +12,19 @@ function buildServiceStatus(service) {
|
|
12
12
|
return serviceStatus;
|
13
13
|
}
|
14
14
|
|
15
|
+
function debounce(func, wait) {
|
16
|
+
var timeout;
|
17
|
+
return function() {
|
18
|
+
var context = this, args = arguments;
|
19
|
+
var later = function() {
|
20
|
+
timeout = null;
|
21
|
+
func.apply(context, args);
|
22
|
+
};
|
23
|
+
clearTimeout(timeout);
|
24
|
+
timeout = setTimeout(later, wait);
|
25
|
+
};
|
26
|
+
};
|
27
|
+
|
15
28
|
function padDateUnit(x) {
|
16
29
|
return x > 9 ? x : '0' + x;
|
17
30
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: consul-templaterb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.15.
|
4
|
+
version: 1.15.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SRE Core Services
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: em-http-request
|
@@ -242,8 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
242
242
|
- !ruby/object:Gem::Version
|
243
243
|
version: '0'
|
244
244
|
requirements: []
|
245
|
-
|
246
|
-
rubygems_version: 2.6.14.4
|
245
|
+
rubygems_version: 3.0.4
|
247
246
|
signing_key:
|
248
247
|
specification_version: 4
|
249
248
|
summary: Implementation of Consul template using Ruby and .erb templating language
|