consul-templaterb 1.5.0 → 1.5.1
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 +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/consul/async/version.rb +1 -1
- data/samples/consul-ui/consul-services-ui.html.erb +9 -2
- data/samples/consul-ui/consul_services.json.erb +3 -0
- data/samples/consul-ui/css/style.css +8 -0
- data/samples/consul-ui/js/service.js +41 -4
- data/samples/consul-ui/js/utils.js +27 -1
- 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: 66b33121c7949683986ddb7ff40573e6110ff98294bca01b944e9aa268a2dc66
|
4
|
+
data.tar.gz: e309df0ebc89ecf50c5e4c18733a1f617ba0f1714845822215c8a8871f335b42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e127b2aa026380d0acad164fc2263582609940e09d2554fdfb468bc63b4be1821f58124299e29d4e83dec42a2c16c62138a9828d728a4c89af63063dd1adb42a
|
7
|
+
data.tar.gz: b23008ed571d5172177332dbaf848db958bfedbbacfeeb7f7f01a056f753bfa8d047552ad8e9870e350caf328879fc6c105eb676c1ef5089a8a44c760b903972
|
data/CHANGELOG.md
CHANGED
data/lib/consul/async/version.rb
CHANGED
@@ -5,14 +5,20 @@
|
|
5
5
|
<div class="row mx-0">
|
6
6
|
<div id="filter-menu" class="col-4 col-m-3 px-4 pt-4">
|
7
7
|
<div class="form-group">
|
8
|
-
<div class="form-check">
|
8
|
+
<div class="form-check form-check-inline">
|
9
9
|
<label class="form-check-label">
|
10
10
|
<input id="showTagsInList" type="checkbox" title="show tags" onclick="consulService.showTags(this.checked)" class="form-check-input" />
|
11
11
|
Show Tags
|
12
12
|
</label>
|
13
13
|
</div>
|
14
|
+
<div class="form-check form-check-inline">
|
15
|
+
<label class="form-check-label">
|
16
|
+
<input id="showProxiesInList" type="checkbox" title="show Consul Connect Proxies" onclick="consulService.showProxies(this.checked)" class="form-check-input" />
|
17
|
+
Show Connect Proxies
|
18
|
+
</label>
|
19
|
+
</div>
|
14
20
|
<div class="input-group">
|
15
|
-
|
21
|
+
<input id="service-filter" type="text" placeholder="filter services by name or tags" class="form-control" />
|
16
22
|
<div class="input-group-append">
|
17
23
|
<span class="input-group-text" id="service-counter"></span>
|
18
24
|
</div>
|
@@ -50,5 +56,6 @@
|
|
50
56
|
<script type="text/javascript">
|
51
57
|
consulService = new ConsulService('<%= datasource %>','<%= refresh %>');
|
52
58
|
</script>
|
59
|
+
<script src="vendors/highlight/highlight.pack.js"></script>
|
53
60
|
</body>
|
54
61
|
</html>
|
@@ -82,11 +82,14 @@
|
|
82
82
|
id: snode['Service']['ID'],
|
83
83
|
name: snode['Node']['Node'],
|
84
84
|
sMeta: meta ? meta : {},
|
85
|
+
connect: snode['Service']['Connect'],
|
85
86
|
addr: snode.service_address,
|
86
87
|
port: snode['Service']['Port'],
|
87
88
|
tags: snode['Service']['Tags'],
|
88
89
|
checks: checks,
|
89
90
|
}
|
91
|
+
kind_of_service = snode['Service']['Kind']
|
92
|
+
service['kind'] = kind_of_service if kind_of_service
|
90
93
|
service[:instances] << server
|
91
94
|
end
|
92
95
|
end
|
@@ -11,7 +11,12 @@ class ConsulService {
|
|
11
11
|
this.filterStatus = null;
|
12
12
|
this.serviceFilterCounter = $("#service-counter");
|
13
13
|
this.serviceFilterCount = 0;
|
14
|
-
this.
|
14
|
+
this.showProxiesInList = false;
|
15
|
+
var cs = this
|
16
|
+
window.setTimeout(function(){
|
17
|
+
cs.showTags($('#showTagsInList:checked').length > 0);
|
18
|
+
cs.showProxies($('#showProxiesInList:checked').length > 0);
|
19
|
+
}, 100);
|
15
20
|
}
|
16
21
|
|
17
22
|
showTags(showTags) {
|
@@ -19,6 +24,14 @@ class ConsulService {
|
|
19
24
|
stylesheet.textContent = '.service-tags { display: ' + (showTags? 'block':'none') + ';}';
|
20
25
|
}
|
21
26
|
|
27
|
+
showProxies(showProxies) {
|
28
|
+
if (showProxies != this.showProxiesInList) {
|
29
|
+
this.showProxiesInList = showProxies;
|
30
|
+
console.log("showProxies:= "+this.showProxiesInList+", reloading list")
|
31
|
+
this.reloadServiceList();
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
22
35
|
fetchRessource() {
|
23
36
|
$.ajax({url: this.ressourceURL, cache: false, dataType: "json", sourceObject: this, success: function(result){
|
24
37
|
consulService.initRessource(result);
|
@@ -57,6 +70,9 @@ class ConsulService {
|
|
57
70
|
}
|
58
71
|
|
59
72
|
reloadServiceList() {
|
73
|
+
if (!this.data || !this.data.services) {
|
74
|
+
console.log("No data to display");
|
75
|
+
}
|
60
76
|
this.serviceList.html('');
|
61
77
|
this.serviceFilterCount = 0;
|
62
78
|
for (var serviceName in this.data.services) {
|
@@ -68,7 +84,7 @@ class ConsulService {
|
|
68
84
|
listItem.setAttribute('onfocus','consulService.onClickServiceName(this)');
|
69
85
|
listItem.setAttribute('onclick','consulService.onClickServiceName(this)');
|
70
86
|
listItem.setAttribute('value',serviceName);
|
71
|
-
|
87
|
+
var listItemClass = 'list-group-item list-group-item-action';
|
72
88
|
|
73
89
|
var statuses = document.createElement('div');
|
74
90
|
statuses.setAttribute('class','statuses float-right');
|
@@ -90,6 +106,14 @@ class ConsulService {
|
|
90
106
|
|
91
107
|
statuses.appendChild(createBadge('badge-dark', (serviceStatus['total'] || 0)));
|
92
108
|
listItem.appendChild(statuses);
|
109
|
+
if (!!service['kind']) {
|
110
|
+
var kind = document.createElement('div');
|
111
|
+
kind.setAttribute('class','kind float-right');
|
112
|
+
kind.appendChild(createBadge('badge-info kind', service['kind']));
|
113
|
+
listItem.appendChild(kind);
|
114
|
+
listItemClass+= " kind-" + service['kind'];
|
115
|
+
}
|
116
|
+
listItem.setAttribute('class', listItemClass);
|
93
117
|
|
94
118
|
var serviceNameItem = document.createElement('div');
|
95
119
|
serviceNameItem.setAttribute('class', 'service-name');
|
@@ -113,11 +137,20 @@ class ConsulService {
|
|
113
137
|
}
|
114
138
|
|
115
139
|
filterService() {
|
116
|
-
var filter
|
140
|
+
var filter;
|
141
|
+
var serviceVal = consulService.serviceFilter.val();
|
142
|
+
try {
|
143
|
+
filter = new RegExp(serviceVal);
|
144
|
+
} catch (e) {
|
145
|
+
var safeReg = serviceVal.replace(/[-[\]{}()*+?.,\\^$|]/g, "\\$&")
|
146
|
+
console.log("Failed to compile regexp for '" + serviceVal + "', using strict lookup due to: " + e);
|
147
|
+
filter = new RegExp(safeReg);
|
148
|
+
}
|
117
149
|
consulService.serviceFilterCount = 0;
|
150
|
+
var showProxiesInList = this.showProxiesInList;
|
118
151
|
consulService.serviceList.children('button').each(function (){
|
119
152
|
var ui = $(this);
|
120
|
-
if(serviceMatcher(this, filter)) {
|
153
|
+
if(serviceMatcher(this, filter, showProxiesInList)) {
|
121
154
|
ui.removeClass('d-none');
|
122
155
|
ui.addClass('d-block');
|
123
156
|
consulService.serviceFilterCount += 1;
|
@@ -196,6 +229,7 @@ class ConsulService {
|
|
196
229
|
serviceHtml.appendChild(serviceTitleGenerator(instance));
|
197
230
|
serviceHtml.appendChild(tagsGenerator(instance.tags));
|
198
231
|
serviceHtml.appendChild(serviceMetaGenerator(instance.sMeta));
|
232
|
+
serviceHtml.appendChild(connectGenerator(instance))
|
199
233
|
serviceHtml.appendChild(checksStatusGenerator(instance.checks));
|
200
234
|
var state = nodeState(instance.checks);
|
201
235
|
serviceHtml.setAttribute('status', state);
|
@@ -212,6 +246,9 @@ class ConsulService {
|
|
212
246
|
resizeWrapper('instances-wrapper', 'instances-list');
|
213
247
|
$('#instances-list .list-group-item').resize(resizeAll);
|
214
248
|
this.filterInstances();
|
249
|
+
$('pre code').each(function(i, block) {
|
250
|
+
hljs.highlightBlock(block);
|
251
|
+
});
|
215
252
|
}
|
216
253
|
}
|
217
254
|
|
@@ -104,6 +104,29 @@ function tagsGenerator(instanceTags) {
|
|
104
104
|
return tags;
|
105
105
|
}
|
106
106
|
|
107
|
+
function connectGenerator(instance) {
|
108
|
+
var connectItem = document.createElement('div');
|
109
|
+
var connectValue = instance['connect']
|
110
|
+
if (connectValue != null && connectValue["Proxy"]) {
|
111
|
+
connectItem.setAttribute('class', 'connect-enabled');
|
112
|
+
var badge = document.createElement("span");
|
113
|
+
badge.setAttribute("class", "badge badge-primary");
|
114
|
+
badge.appendChild(document.createTextNode("Consul Connect Enabled"));
|
115
|
+
connectItem.appendChild(badge);
|
116
|
+
var content = document.createElement("pre");
|
117
|
+
content.setAttribute("class", "connect-data");
|
118
|
+
var code = document.createElement("code");
|
119
|
+
code.setAttribute("class", "connect-source");
|
120
|
+
code.appendChild(document.createTextNode(JSON.stringify(connectValue)));
|
121
|
+
content.appendChild(code);
|
122
|
+
connectItem.appendChild(content);
|
123
|
+
return connectItem;
|
124
|
+
} else {
|
125
|
+
connectItem.setAttribute('class', 'connect-disabled');
|
126
|
+
}
|
127
|
+
return connectItem
|
128
|
+
}
|
129
|
+
|
107
130
|
function serviceMetaGenerator(instanceMeta) {
|
108
131
|
var top = document.createElement('div');
|
109
132
|
top.className = 'instance-meta';
|
@@ -248,8 +271,11 @@ function createBadge(classes, data) {
|
|
248
271
|
return badge;
|
249
272
|
}
|
250
273
|
|
251
|
-
function serviceMatcher(service, regex) {
|
274
|
+
function serviceMatcher(service, regex, showProxiesInList) {
|
252
275
|
if(service.getElementsByClassName('service-name')[0].innerHTML.match(regex)) {
|
276
|
+
if(!showProxiesInList && service.classList.contains('kind-connect-proxy')){
|
277
|
+
return false;
|
278
|
+
}
|
253
279
|
return true;
|
254
280
|
}
|
255
281
|
var tags = service.getElementsByClassName('service-tags')[0].getElementsByClassName('badge');
|
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.1
|
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-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: em-http-request
|