consul-templaterb 1.5.6 → 1.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/consul/async/stats.rb +4 -4
- data/lib/consul/async/version.rb +1 -1
- data/samples/consul-ui/css/style.css +20 -0
- data/samples/consul-ui/js/service.js +101 -1
- data/samples/metrics.erb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ced33aa72d9f144f338dd896e962ad57577f0580a590a7cf9c4151ddf4f9c12c
|
4
|
+
data.tar.gz: 27627d161c46451eeb383d3d69797004eb3d2b9c7fda4d74e50315c332c5b9e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57472c838bcd831aced8a7331b058ea8a87bc4a50b1a61b5e62b6dd46dd7ac48712b626c374f5643d5ef2a7627fe9d268f05559af395d978a3ac35dcd74e28e5
|
7
|
+
data.tar.gz: '063973ff971f13077e2b8e8c41a93d107662b1154286933ad0211320f1a8bcb3d42ed0482ecebf3822fe545b8a6a24c2c48b4d7770df39aa75f426759de668f2'
|
data/CHANGELOG.md
CHANGED
data/lib/consul/async/stats.rb
CHANGED
@@ -25,14 +25,14 @@ module Consul
|
|
25
25
|
@errors += 1
|
26
26
|
end
|
27
27
|
|
28
|
-
def bytes_per_sec
|
29
|
-
diff = (
|
28
|
+
def bytes_per_sec(now = Time.now.utc)
|
29
|
+
diff = (now - start)
|
30
30
|
diff = 1 if diff < 1
|
31
31
|
(body_bytes / diff).round(0)
|
32
32
|
end
|
33
33
|
|
34
|
-
def bytes_per_sec_human
|
35
|
-
"#{Utilities.bytes_to_h(bytes_per_sec)}/s"
|
34
|
+
def bytes_per_sec_human(now = Time.now.utc)
|
35
|
+
"#{Utilities.bytes_to_h(bytes_per_sec(now))}/s"
|
36
36
|
end
|
37
37
|
|
38
38
|
def body_bytes_human
|
data/lib/consul/async/version.rb
CHANGED
@@ -18,6 +18,26 @@
|
|
18
18
|
overflow: hidden;
|
19
19
|
}
|
20
20
|
|
21
|
+
#service-list .favorite {
|
22
|
+
width: 20px;
|
23
|
+
height: 20px;
|
24
|
+
border: 0;
|
25
|
+
color: #f7d800;
|
26
|
+
cursor: pointer;
|
27
|
+
font-size: 1.3em;
|
28
|
+
vertical-align: middle;
|
29
|
+
line-height: 1;
|
30
|
+
background-color: transparent;
|
31
|
+
}
|
32
|
+
|
33
|
+
#service-list .favorite::before {
|
34
|
+
content: '☆';
|
35
|
+
}
|
36
|
+
|
37
|
+
#service-list .favorite.favorited::before {
|
38
|
+
content: '★';
|
39
|
+
}
|
40
|
+
|
21
41
|
.weights {
|
22
42
|
float: right;
|
23
43
|
}
|
@@ -13,6 +13,7 @@ class ConsulService {
|
|
13
13
|
this.serviceFilterCount = 0;
|
14
14
|
this.showProxiesInList = false;
|
15
15
|
var cs = this
|
16
|
+
this.loadFavorites();
|
16
17
|
window.setTimeout(function(){
|
17
18
|
cs.showTags($('#showTagsInList:checked').length > 0);
|
18
19
|
cs.showProxies($('#showProxiesInList:checked').length > 0);
|
@@ -75,6 +76,9 @@ class ConsulService {
|
|
75
76
|
}
|
76
77
|
this.serviceList.html('');
|
77
78
|
this.serviceFilterCount = 0;
|
79
|
+
|
80
|
+
let idx = 0;
|
81
|
+
let lastFav = null;
|
78
82
|
for (var serviceName in this.data.services) {
|
79
83
|
var service = this.data.services[serviceName];
|
80
84
|
var serviceStatus = buildServiceStatus(service);
|
@@ -84,6 +88,8 @@ class ConsulService {
|
|
84
88
|
listItem.setAttribute('onfocus','consulService.onClickServiceName(this)');
|
85
89
|
listItem.setAttribute('onclick','consulService.onClickServiceName(this)');
|
86
90
|
listItem.setAttribute('value',serviceName);
|
91
|
+
listItem.setAttribute('data-fav', this.favorites[serviceName] ? 1 : 0);
|
92
|
+
listItem.setAttribute('data-index', idx);
|
87
93
|
var listItemClass = 'list-group-item list-group-item-action';
|
88
94
|
|
89
95
|
var statuses = document.createElement('div');
|
@@ -105,6 +111,9 @@ class ConsulService {
|
|
105
111
|
}
|
106
112
|
|
107
113
|
statuses.appendChild(createBadge('badge-dark', (serviceStatus['total'] || 0)));
|
114
|
+
|
115
|
+
statuses.append(this.buildFavButton(serviceName));
|
116
|
+
|
108
117
|
listItem.appendChild(statuses);
|
109
118
|
if (!!service['kind']) {
|
110
119
|
var kind = document.createElement('div');
|
@@ -129,7 +138,18 @@ class ConsulService {
|
|
129
138
|
|
130
139
|
listItem.appendChild(serviceTagsItem);
|
131
140
|
this.serviceFilterCount += 1;
|
132
|
-
|
141
|
+
|
142
|
+
if (this.favorites[serviceName] && lastFav) {
|
143
|
+
lastFav.after(listItem);
|
144
|
+
lastFav = listItem;
|
145
|
+
} else if (this.favorites[serviceName] && !lastFav) {
|
146
|
+
this.serviceList.prepend(listItem);
|
147
|
+
lastFav = listItem;
|
148
|
+
} else {
|
149
|
+
this.serviceList.append(listItem);
|
150
|
+
}
|
151
|
+
|
152
|
+
idx++;
|
133
153
|
}
|
134
154
|
this.serviceFilterCounter.html(this.serviceFilterCount);
|
135
155
|
resizeWrapper('service-wrapper', 'service-list');
|
@@ -250,6 +270,86 @@ class ConsulService {
|
|
250
270
|
hljs.highlightBlock(block);
|
251
271
|
});
|
252
272
|
}
|
273
|
+
|
274
|
+
loadFavorites() {
|
275
|
+
const all = (localStorage.getItem('favorite_services') || '').split(',').filter(e => e != '');
|
276
|
+
this.favorites = {}
|
277
|
+
for (var i in all) {
|
278
|
+
this.favorites[all[i]] = true;
|
279
|
+
}
|
280
|
+
}
|
281
|
+
|
282
|
+
saveFavorites() {
|
283
|
+
let str = "";
|
284
|
+
for (var i in this.favorites) {
|
285
|
+
if (!this.favorites[i]) {
|
286
|
+
continue;
|
287
|
+
}
|
288
|
+
str == "" || (str += ",");
|
289
|
+
str += i;
|
290
|
+
}
|
291
|
+
localStorage.setItem('favorite_services', str);
|
292
|
+
}
|
293
|
+
|
294
|
+
buildFavButton(serviceName) {
|
295
|
+
const btn = document.createElement('button');
|
296
|
+
btn.className = 'favorite';
|
297
|
+
btn.setAttribute('title', 'Add/Remove from favorites');
|
298
|
+
|
299
|
+
if (this.favorites[serviceName]) {
|
300
|
+
btn.className += ' favorited';
|
301
|
+
}
|
302
|
+
|
303
|
+
$(btn).click(e => {
|
304
|
+
this.toggleFav(serviceName, !this.favorites[serviceName]);
|
305
|
+
});
|
306
|
+
return btn;
|
307
|
+
}
|
308
|
+
|
309
|
+
toggleFav(serviceName, fav) {
|
310
|
+
this.favorites[serviceName] = fav;
|
311
|
+
|
312
|
+
let el = this.serviceList.find('[value="' + serviceName + '"]');
|
313
|
+
if (!el.length) {
|
314
|
+
return;
|
315
|
+
}
|
316
|
+
|
317
|
+
if (fav) {
|
318
|
+
el.find('.favorite').addClass('favorited');
|
319
|
+
} else {
|
320
|
+
el.find('.favorite').removeClass('favorited');
|
321
|
+
}
|
322
|
+
el.attr('data-fav', fav ? 1 : 0);
|
323
|
+
|
324
|
+
const elIdx = parseInt(el.attr('data-index'));
|
325
|
+
|
326
|
+
let prev = fav ? null : this.serviceList.find('[data-fav="1"]').last();
|
327
|
+
const others = this.serviceList.find('[data-fav="' + (fav ? 1 : 0) + '"]');
|
328
|
+
for (var i = 0; i < others.length; i++) {
|
329
|
+
const idx = parseInt($(others[i]).attr("data-index"));
|
330
|
+
if (idx < elIdx) {
|
331
|
+
prev = $(others[i]);
|
332
|
+
} else if (idx > elIdx) {
|
333
|
+
break;
|
334
|
+
}
|
335
|
+
};
|
336
|
+
|
337
|
+
if (!prev || !prev.length) {
|
338
|
+
this.serviceList.prepend(el);
|
339
|
+
} else {
|
340
|
+
prev.after(el);
|
341
|
+
}
|
342
|
+
|
343
|
+
// if favorited, scroll to element new position
|
344
|
+
if (fav) {
|
345
|
+
const container = $('#service-wrapper');
|
346
|
+
const top = el.position().top;
|
347
|
+
const scroll = container.scrollTop();
|
348
|
+
container.scrollTop(scroll + el.offset().top - container.offset().top);
|
349
|
+
}
|
350
|
+
|
351
|
+
this.saveFavorites();
|
352
|
+
}
|
253
353
|
}
|
254
354
|
|
255
355
|
$( window ).resize(resizeAll);
|
data/samples/metrics.erb
CHANGED
@@ -71,7 +71,8 @@ consul_services_count <%= service_count %> <%= services(tag: service_tag_filter)
|
|
71
71
|
|
72
72
|
<%
|
73
73
|
json_backends = {}
|
74
|
-
now = Time.now.utc
|
74
|
+
now = Time.now.utc
|
75
|
+
now_ms = now.to_i * 1000
|
75
76
|
backends.each_pair do |service_name, service_info|
|
76
77
|
last_update = service_info[:stats].last_success_or_error.to_i * 1000
|
77
78
|
service_info[:state].each_pair do |state_name, state_count|
|
@@ -86,7 +87,7 @@ consul_services_count <%= service_count %> <%= services(tag: service_tag_filter)
|
|
86
87
|
<%
|
87
88
|
end
|
88
89
|
%>consul_service_stats_requests_bytes{service="<%= service_name %>"} <%= service_info[:stats].body_bytes %> <%= last_update %>
|
89
|
-
consul_service_stats_requests_bytes_per_sec{service="<%= service_name %>"} <%= service_info[:stats].bytes_per_sec %> <%=
|
90
|
+
consul_service_stats_requests_bytes_per_sec{service="<%= service_name %>"} <%= service_info[:stats].bytes_per_sec(now) %> <%= now_ms %>
|
90
91
|
|
91
92
|
<%
|
92
93
|
end
|
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.5.
|
4
|
+
version: 1.5.7
|
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: 2018-
|
11
|
+
date: 2018-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: em-http-request
|