consul-templaterb 1.18.5 → 1.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +13 -8
- data/CHANGELOG.md +15 -0
- data/README.md +10 -12
- data/TemplateAPI.md +4 -0
- data/lib/consul/async/consul_template.rb +10 -0
- data/lib/consul/async/version.rb +1 -1
- data/samples/consul-ui/common/header.html.erb +0 -6
- data/samples/consul-ui/consul-keys-ui.html.erb +2 -1
- data/samples/consul-ui/consul-nodes-ui.html.erb +15 -8
- data/samples/consul-ui/consul-services-ui.html.erb +21 -8
- data/samples/consul-ui/css/style.css +7 -3
- data/samples/consul-ui/js/keys.js +71 -115
- data/samples/consul-ui/js/nodes.js +224 -238
- data/samples/consul-ui/js/service.js +319 -343
- data/samples/consul-ui/js/timeline.js +12 -7
- data/samples/consul-ui/js/types.js +317 -0
- data/samples/consul-ui/js/utils.js +362 -334
- data/samples/tools/find_all_maintenance_nodes.txt.erb +25 -0
- metadata +4 -9
- data/samples/checks.html.erb +0 -130
- data/samples/common/footer.html.erb +0 -8
- data/samples/common/header.html.erb +0 -45
- data/samples/criteo_choregraphies.txt.erb +0 -49
- data/samples/keys.html.erb +0 -42
- data/samples/nodes.html.erb +0 -52
- data/samples/services.html.erb +0 -134
@@ -1,387 +1,363 @@
|
|
1
|
-
class
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
showProxies(showProxies) {
|
39
|
-
if (showProxies != this.showProxiesInList) {
|
40
|
-
this.showProxiesInList = showProxies;
|
41
|
-
console.log("showProxies:= "+this.showProxiesInList+", reloading list")
|
42
|
-
this.reloadServiceList();
|
43
|
-
}
|
44
|
-
}
|
45
|
-
|
46
|
-
async fetchRessource() {
|
47
|
-
const response = await fetch(this.resourceURL);
|
48
|
-
const result = await response.json();
|
49
|
-
await this.initRessource(result);
|
50
|
-
}
|
51
|
-
|
52
|
-
async initRessource(data) {
|
53
|
-
this.data = data;
|
54
|
-
await this.reloadServiceList();
|
55
|
-
console.log('Data generated at: ' + data['generated_at']);
|
56
|
-
|
57
|
-
var urlParam = this.selectedServiceName
|
58
|
-
if (urlParam) {
|
59
|
-
var nodes = document.getElementById('service-list').childNodes;
|
60
|
-
for (const node of nodes) {
|
61
|
-
if($(node).find(".service-name").html() == urlParam) {
|
62
|
-
var selectedElement = $(node);
|
63
|
-
this.selectService(selectedElement);
|
64
|
-
selectedElement.focus();
|
65
|
-
break;
|
66
|
-
}
|
67
|
-
}
|
68
|
-
} else {
|
69
|
-
var servicePrefix = '#service_';
|
70
|
-
if (location.hash.startsWith(servicePrefix)) {
|
71
|
-
urlParam = location.hash.substr(servicePrefix.length);
|
72
|
-
}
|
73
|
-
this.selectService(document.getElementById('service-list').firstElementChild);
|
1
|
+
class ConsulServiceManager extends ConsulUIManager {
|
2
|
+
constructor(resourceURL) {
|
3
|
+
super(resourceURL);
|
4
|
+
var flags = {};
|
5
|
+
this.mainSelector = new ServiceMainSelector(
|
6
|
+
$("#service-title"),
|
7
|
+
$("#instances-list"),
|
8
|
+
$("#instance-filter"),
|
9
|
+
$("#instance-counter"),
|
10
|
+
$("#max-display-selector"),
|
11
|
+
"node_filter",
|
12
|
+
"node_status_filter"
|
13
|
+
);
|
14
|
+
this.sideSelector = new ServiceSideSelector(
|
15
|
+
this.mainSelector,
|
16
|
+
flags,
|
17
|
+
$("#service-filter"),
|
18
|
+
$("#service-list"),
|
19
|
+
$("#service-counter"),
|
20
|
+
"filter",
|
21
|
+
"service"
|
22
|
+
);
|
23
|
+
var obj = this;
|
24
|
+
flags["showTags"] = new DisplayFlag(
|
25
|
+
$("#showTagsInList").get(0),
|
26
|
+
function () {
|
27
|
+
obj.sideSelector.prepareData();
|
28
|
+
obj.sideSelector.refreshList();
|
29
|
+
}
|
30
|
+
);
|
31
|
+
flags["showConnectProxies"] = new DisplayFlag(
|
32
|
+
$("#showProxiesInList").get(0),
|
33
|
+
function () {
|
34
|
+
obj.sideSelector.refreshList();
|
35
|
+
}
|
36
|
+
);
|
37
|
+
this.fetchResource();
|
74
38
|
}
|
75
|
-
|
76
|
-
|
39
|
+
|
40
|
+
async initResource(data) {
|
41
|
+
this.mainSelector.nodes = data["nodes"];
|
42
|
+
this.sideSelector.data = data["services"];
|
43
|
+
this.sideSelector.prepareData();
|
44
|
+
this.sideSelector.refreshList();
|
77
45
|
}
|
78
|
-
|
79
|
-
}
|
80
|
-
|
81
|
-
async reloadServiceList() {
|
82
|
-
this.serviceList.html('');
|
83
|
-
this.serviceFilterCount = 0;
|
84
|
-
|
85
|
-
if (!this.data || !this.data.services) {
|
86
|
-
console.log("No data to display");
|
87
|
-
} else {
|
88
|
-
const services = Object.values(this.data.services).map((service, index) => ({ service, index }));
|
89
|
-
const favorites = services.filter(({ service }) => this.favorites[service.name]);
|
90
|
-
const others = services.filter(({ service }) => !this.favorites[service.name]);
|
91
|
-
|
92
|
-
const appendServiceAsync = ({ service, index }) =>
|
93
|
-
new Promise(resolve =>
|
94
|
-
setTimeout(() => {
|
95
|
-
this.appendService(service, index);
|
96
|
-
resolve();
|
97
|
-
}, 0)
|
98
|
-
);
|
46
|
+
}
|
99
47
|
|
100
|
-
|
48
|
+
class ServiceSideSelector extends SideSelector {
|
49
|
+
constructor(
|
50
|
+
mainSelector,
|
51
|
+
flags,
|
52
|
+
filterElement,
|
53
|
+
listElement,
|
54
|
+
counterElement,
|
55
|
+
URLLabelFilter,
|
56
|
+
URLLabelSelected
|
57
|
+
) {
|
58
|
+
super(
|
59
|
+
filterElement,
|
60
|
+
listElement,
|
61
|
+
counterElement,
|
62
|
+
URLLabelFilter,
|
63
|
+
URLLabelSelected,
|
64
|
+
true
|
65
|
+
);
|
66
|
+
this.mainSelector = mainSelector;
|
67
|
+
this.flags = flags;
|
101
68
|
}
|
102
69
|
|
103
|
-
|
104
|
-
|
105
|
-
|
70
|
+
matchElement(serviceName, service, filter) {
|
71
|
+
if (
|
72
|
+
service["kind"] != undefined &&
|
73
|
+
!this.flags["showConnectProxies"].state
|
74
|
+
) {
|
75
|
+
return false;
|
76
|
+
}
|
106
77
|
|
107
|
-
|
108
|
-
|
109
|
-
|
78
|
+
if (service.name.match(filter)) {
|
79
|
+
return true;
|
80
|
+
}
|
110
81
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
listItem.setAttribute('data-index', index);
|
117
|
-
var listItemClass = 'serviceListItem list-group-item list-group-item-action';
|
82
|
+
for (var i in service.tags) {
|
83
|
+
if (service.tags[i].match(filter)) {
|
84
|
+
return true;
|
85
|
+
}
|
86
|
+
}
|
118
87
|
|
119
|
-
|
120
|
-
|
88
|
+
for (var status in service.status) {
|
89
|
+
if (status.match(filter)) {
|
90
|
+
return true;
|
91
|
+
}
|
92
|
+
}
|
121
93
|
|
122
|
-
|
123
|
-
statuses.appendChild(createBadge('badge-success passing', serviceStatus['passing']));
|
124
|
-
listItem.setAttribute('status', 'passing');
|
94
|
+
return false;
|
125
95
|
}
|
126
96
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
}
|
97
|
+
elementGenerator(serviceName, service) {
|
98
|
+
var element = document.createElement("li");
|
99
|
+
var CSSClass = "service-list-item list-group-item list-group-item-action";
|
131
100
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
101
|
+
var obj = this;
|
102
|
+
element.addEventListener("focus", function () {
|
103
|
+
obj.onClickElement(this, serviceName);
|
104
|
+
});
|
105
|
+
element.addEventListener("click", function () {
|
106
|
+
obj.onClickElement(this, serviceName);
|
107
|
+
});
|
136
108
|
|
137
|
-
|
109
|
+
element.setAttribute("value", serviceName);
|
138
110
|
|
139
|
-
|
111
|
+
element.appendChild(this.generateStatuses(service));
|
140
112
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
listItem.setAttribute('class', listItemClass);
|
113
|
+
if (!!service["kind"]) {
|
114
|
+
var kind = document.createElement("div");
|
115
|
+
kind.setAttribute("class", "kind float-right");
|
116
|
+
kind.appendChild(createBadge("badge-info kind", service["kind"]));
|
117
|
+
element.appendChild(kind);
|
118
|
+
CSSClass += " kind-" + service["kind"];
|
119
|
+
}
|
120
|
+
element.setAttribute("class", CSSClass);
|
150
121
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
122
|
+
var serviceNameItem = document.createElement("div");
|
123
|
+
serviceNameItem.setAttribute("class", "service-name");
|
124
|
+
serviceNameItem.appendChild(document.createTextNode(serviceName));
|
125
|
+
element.appendChild(serviceNameItem);
|
155
126
|
|
156
|
-
|
157
|
-
|
127
|
+
if (this.flags["showTags"].state) {
|
128
|
+
element.appendChild(this.generateServiceTags(service));
|
129
|
+
}
|
158
130
|
|
159
|
-
|
160
|
-
serviceTagsItem.appendChild(createBadge('float-right badge-' + (i%2?'secondary':'info') , service.tags[i]));
|
131
|
+
return element;
|
161
132
|
}
|
162
133
|
|
163
|
-
|
134
|
+
generateStatuses(service) {
|
135
|
+
var serviceStatus = buildServiceStatus(service);
|
136
|
+
var statuses = document.createElement("div");
|
137
|
+
statuses.setAttribute("class", "statuses float-right");
|
138
|
+
|
139
|
+
if (!!serviceStatus["passing"]) {
|
140
|
+
statuses.appendChild(
|
141
|
+
createBadge("badge-success passing", serviceStatus["passing"])
|
142
|
+
);
|
143
|
+
}
|
144
|
+
|
145
|
+
if (!!serviceStatus["warning"]) {
|
146
|
+
statuses.appendChild(
|
147
|
+
createBadge("badge-warning warning", serviceStatus["warning"])
|
148
|
+
);
|
149
|
+
}
|
164
150
|
|
165
|
-
|
151
|
+
if (!!serviceStatus["critical"]) {
|
152
|
+
statuses.appendChild(
|
153
|
+
createBadge("badge-danger critical", serviceStatus["critical"])
|
154
|
+
);
|
155
|
+
}
|
166
156
|
|
167
|
-
|
168
|
-
|
157
|
+
statuses.appendChild(
|
158
|
+
createBadge("badge-dark", serviceStatus["total"] || 0)
|
159
|
+
);
|
169
160
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
} catch (e) {
|
176
|
-
var safeReg = filterValue.replace(/[-[\]{}()*+?.,\\^$|]/g, "\\$&")
|
177
|
-
console.log("Failed to compile regexp for '" + filterValue + "', using strict lookup due to: " + e);
|
178
|
-
filter = new RegExp(safeReg);
|
161
|
+
if (this.activateFavorite) {
|
162
|
+
statuses.append(this.favorites.buildButton(service.name));
|
163
|
+
}
|
164
|
+
|
165
|
+
return statuses;
|
179
166
|
}
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
ui.removeClass('d-block');
|
193
|
-
ui.addClass('d-none');
|
194
|
-
}
|
195
|
-
})
|
196
|
-
}
|
197
|
-
|
198
|
-
onClickServiceName(source) {
|
199
|
-
this.selectService(source);
|
200
|
-
this.selectedServiceName = $(source).find(".service-name").html()
|
201
|
-
this.updateURL();
|
202
|
-
}
|
203
|
-
|
204
|
-
onClickFilter(source) {
|
205
|
-
var status = $(source).attr('status');
|
206
|
-
this.filterStatus = (this.filterStatus == status) ? null : status;
|
207
|
-
this.filterInstances();
|
208
|
-
}
|
209
|
-
|
210
|
-
filterInstances() {
|
211
|
-
updateFilterDisplay(consulService.filterStatus);
|
212
|
-
var filter = new RegExp(consulService.instanceFilter.val());
|
213
|
-
$('#instances-list').children('div').each(function() {
|
214
|
-
var status = $(this).attr('status');
|
215
|
-
if(instanceMatcher(this, filter)) {
|
216
|
-
if (consulService.filterStatus == null) {
|
217
|
-
$(this).removeClass('d-none');
|
218
|
-
$(this).addClass('d-block');
|
219
|
-
} else if (consulService.filterStatus == status) {
|
220
|
-
$(this).removeClass('d-none');
|
221
|
-
$(this).addClass('d-block');
|
222
|
-
} else {
|
223
|
-
$(this).removeClass('d-block');
|
224
|
-
$(this).addClass('d-none');
|
167
|
+
|
168
|
+
generateServiceTags(service) {
|
169
|
+
var serviceTagsItem = document.createElement("div");
|
170
|
+
serviceTagsItem.setAttribute("class", "service-tags");
|
171
|
+
|
172
|
+
for (var i = 0; i < service.tags.length; i++) {
|
173
|
+
serviceTagsItem.appendChild(
|
174
|
+
createBadge(
|
175
|
+
"float-right badge-" + (i % 2 ? "secondary" : "info"),
|
176
|
+
service.tags[i]
|
177
|
+
)
|
178
|
+
);
|
225
179
|
}
|
226
|
-
|
227
|
-
$(this).removeClass('d-block');
|
228
|
-
$(this).addClass('d-none');
|
229
|
-
}
|
230
|
-
})
|
231
|
-
}
|
232
|
-
|
233
|
-
updateURL() {
|
234
|
-
var newUrl = new URL(location.href);
|
235
|
-
if (this.selectedServiceName) {
|
236
|
-
newUrl.searchParams.set('service', this.selectedServiceName);
|
237
|
-
} else {
|
238
|
-
newUrl.searchParams.delete('service')
|
180
|
+
return serviceTagsItem;
|
239
181
|
}
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
}
|
245
|
-
window.history.pushState({},"",newUrl);
|
246
|
-
}
|
247
|
-
|
248
|
-
selectService(source) {
|
249
|
-
if (this.selectedService) {
|
250
|
-
$(this.selectedService).removeClass('active');
|
182
|
+
|
183
|
+
selectItem(element, service) {
|
184
|
+
super.selectItem(element, service);
|
185
|
+
this.mainSelector.initSelector(this.data[service]);
|
251
186
|
}
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
node_info = node_info.meta;
|
276
|
-
serviceHtml.appendChild(nodeMetaGenerator(node_info));
|
277
|
-
serviceHtml.appendChild(document.createElement('hr'));
|
278
|
-
}
|
279
|
-
if (instance.tags && instance.tags.length > 0) {
|
280
|
-
serviceHtml.appendChild(tagsGenerator(instance.tags));
|
281
|
-
serviceHtml.appendChild(document.createElement('hr'));
|
282
|
-
}
|
283
|
-
serviceHtml.appendChild(serviceMetaGenerator(instance.sMeta));
|
284
|
-
serviceHtml.appendChild(connectGenerator(instance));
|
285
|
-
serviceHtml.appendChild(checksStatusGenerator(instance, instance.name));
|
286
|
-
serviceHtml.setAttribute('status', state);
|
287
|
-
$("#instances-list").append(serviceHtml);
|
187
|
+
}
|
188
|
+
|
189
|
+
class ServiceMainSelector extends MainSelector {
|
190
|
+
constructor(
|
191
|
+
titleElement,
|
192
|
+
listElement,
|
193
|
+
filterElement,
|
194
|
+
counterElement,
|
195
|
+
maxDisplayed,
|
196
|
+
URLLabelFilter,
|
197
|
+
URLLabelStatus
|
198
|
+
) {
|
199
|
+
super(listElement, filterElement, counterElement, maxDisplayed, URLLabelFilter, URLLabelStatus);
|
200
|
+
this.titleElement = titleElement;
|
201
|
+
this.passingStatusBarElement = $("#service-progress-passing");
|
202
|
+
this.warningStatusBarElement = $("#service-progress-warning");
|
203
|
+
this.criticalStatusBarElement = $("#service-progress-critical");
|
204
|
+
this.passingStatusButtonElement = $("#service-status-passing");
|
205
|
+
this.warningStatusButtonElement = $("#service-status-warning");
|
206
|
+
this.criticalStatusButtonElement = $("#service-status-critical");
|
207
|
+
this.totalStatusButtonElement = $("#service-status-total");
|
208
|
+
this.initStatusButtons();
|
209
|
+
this.initStatusBar();
|
288
210
|
}
|
289
211
|
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
212
|
+
initStatusButtons() {
|
213
|
+
var obj = this;
|
214
|
+
this.passingStatusButtonElement
|
215
|
+
.get(0)
|
216
|
+
.addEventListener("click", function () {
|
217
|
+
obj.onClickFilter(this, "passing");
|
218
|
+
});
|
219
|
+
this.warningStatusButtonElement
|
220
|
+
.get(0)
|
221
|
+
.addEventListener("click", function () {
|
222
|
+
obj.onClickFilter(this, "warning");
|
223
|
+
});
|
224
|
+
this.criticalStatusButtonElement
|
225
|
+
.get(0)
|
226
|
+
.addEventListener("click", function () {
|
227
|
+
obj.onClickFilter(this, "critical");
|
228
|
+
});
|
229
|
+
this.totalStatusButtonElement.get(0).addEventListener("click", function () {
|
230
|
+
obj.onClickFilter(this, null);
|
231
|
+
});
|
310
232
|
}
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
233
|
+
|
234
|
+
initStatusBar() {
|
235
|
+
var obj = this;
|
236
|
+
this.passingStatusBarElement.get(0).addEventListener("click", function () {
|
237
|
+
obj.onClickFilter(this, "passing");
|
238
|
+
});
|
239
|
+
this.warningStatusBarElement.get(0).addEventListener("click", function () {
|
240
|
+
obj.onClickFilter(this, "warning");
|
241
|
+
});
|
242
|
+
this.criticalStatusBarElement.get(0).addEventListener("click", function () {
|
243
|
+
obj.onClickFilter(this, "critical");
|
244
|
+
});
|
321
245
|
}
|
322
|
-
localStorage.setItem('favorite_services', str);
|
323
|
-
}
|
324
246
|
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
247
|
+
initSelector(service) {
|
248
|
+
if (service) {
|
249
|
+
super.initSelector(service.instances);
|
250
|
+
this.generateTitle(service.name);
|
251
|
+
}
|
252
|
+
}
|
329
253
|
|
330
|
-
|
331
|
-
|
254
|
+
updateStatusCounters() {
|
255
|
+
updateStatusItem(this.selectorStatus);
|
256
|
+
this.passingStatusBarElement.css(
|
257
|
+
"width",
|
258
|
+
((this.selectorStatus["passing"] || 0) / this.selectorStatus["total"]) *
|
259
|
+
100 +
|
260
|
+
"%"
|
261
|
+
);
|
262
|
+
this.passingStatusBarElement.html(
|
263
|
+
"passing (" + (this.selectorStatus["passing"] || 0) + ")"
|
264
|
+
);
|
265
|
+
this.warningStatusBarElement.css(
|
266
|
+
"width",
|
267
|
+
((this.selectorStatus["warning"] || 0) / this.selectorStatus["total"]) *
|
268
|
+
100 +
|
269
|
+
"%"
|
270
|
+
);
|
271
|
+
this.warningStatusBarElement.html(
|
272
|
+
"warning (" + (this.selectorStatus["warning"] || 0) + ")"
|
273
|
+
);
|
274
|
+
this.criticalStatusBarElement.css(
|
275
|
+
"width",
|
276
|
+
((this.selectorStatus["critical"] || 0) / this.selectorStatus["total"]) *
|
277
|
+
100 +
|
278
|
+
"%"
|
279
|
+
);
|
280
|
+
this.criticalStatusBarElement.html(
|
281
|
+
"critical (" + (this.selectorStatus["critical"] || 0) + ")"
|
282
|
+
);
|
332
283
|
}
|
333
284
|
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
285
|
+
generateTitle(serviceName) {
|
286
|
+
var titleText =
|
287
|
+
serviceName +
|
288
|
+
' <a href="consul-timeline-ui.html?service=' +
|
289
|
+
serviceName +
|
290
|
+
'">timeline</a>';
|
291
|
+
this.titleElement.html(titleText);
|
292
|
+
resizeAll();
|
293
|
+
}
|
339
294
|
|
340
|
-
|
341
|
-
|
295
|
+
elementGenerator(instance) {
|
296
|
+
var element = document.createElement("div");
|
297
|
+
element.setAttribute("class", "list-group-item service-instance");
|
298
|
+
var state = nodeState(instance.checks);
|
299
|
+
element.appendChild(weightsGenerator(instance.weights, state));
|
300
|
+
element.appendChild(serviceTitleGenerator(instance));
|
301
|
+
var node_info = this.nodes[instance.name];
|
302
|
+
if (node_info != null) {
|
303
|
+
node_info = node_info.meta;
|
304
|
+
element.appendChild(nodeMetaGenerator(node_info));
|
305
|
+
element.appendChild(document.createElement("hr"));
|
306
|
+
}
|
307
|
+
if (instance.tags && instance.tags.length > 0) {
|
308
|
+
element.appendChild(tagsGenerator(instance.tags));
|
309
|
+
element.appendChild(document.createElement("hr"));
|
310
|
+
}
|
311
|
+
element.appendChild(serviceMetaGenerator(instance.sMeta));
|
312
|
+
element.appendChild(connectGenerator(instance));
|
313
|
+
element.appendChild(checksStatusGenerator(instance, instance.name));
|
314
|
+
element.setAttribute("status", state);
|
342
315
|
|
343
|
-
|
344
|
-
if (!el.length) {
|
345
|
-
return;
|
316
|
+
return element;
|
346
317
|
}
|
347
318
|
|
348
|
-
|
349
|
-
|
350
|
-
} else {
|
351
|
-
el.find('.favorite').removeClass('favorited');
|
352
|
-
}
|
353
|
-
el.attr('data-fav', fav ? 1 : 0);
|
354
|
-
|
355
|
-
const elIdx = parseInt(el.attr('data-index'));
|
356
|
-
|
357
|
-
let prev = fav ? null : this.serviceList.find('[data-fav="1"]').last();
|
358
|
-
const others = this.serviceList.find('[data-fav="' + (fav ? 1 : 0) + '"]');
|
359
|
-
for (var i = 0; i < others.length; i++) {
|
360
|
-
const idx = parseInt($(others[i]).attr("data-index"));
|
361
|
-
if (idx < elIdx) {
|
362
|
-
prev = $(others[i]);
|
363
|
-
} else if (idx > elIdx) {
|
364
|
-
break;
|
365
|
-
}
|
366
|
-
};
|
367
|
-
|
368
|
-
if (!prev || !prev.length) {
|
369
|
-
this.serviceList.prepend(el);
|
370
|
-
} else {
|
371
|
-
prev.after(el);
|
319
|
+
getStatus(instance) {
|
320
|
+
return nodeState(instance["checks"]);
|
372
321
|
}
|
373
322
|
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
323
|
+
matchElement(instance, filter) {
|
324
|
+
if (
|
325
|
+
this.statusFilter != null &&
|
326
|
+
nodeState(instance["checks"]) != this.statusFilter
|
327
|
+
) {
|
328
|
+
return false;
|
329
|
+
}
|
330
|
+
|
331
|
+
if (instance.name.match(filter)) {
|
332
|
+
return true;
|
333
|
+
}
|
334
|
+
|
335
|
+
if (instance.addr.match(filter)) {
|
336
|
+
return true;
|
337
|
+
}
|
381
338
|
|
382
|
-
|
383
|
-
|
339
|
+
for (var i in instance.tags) {
|
340
|
+
if (instance.tags[i].match(filter)) {
|
341
|
+
return true;
|
342
|
+
}
|
343
|
+
}
|
344
|
+
|
345
|
+
for (var key in instance.sMeta) {
|
346
|
+
if (key.match(filter) || instance.sMeta[key].match(filter)) {
|
347
|
+
return true;
|
348
|
+
}
|
349
|
+
}
|
350
|
+
|
351
|
+
var node = this.nodes[instance.name];
|
352
|
+
for (var key in node.meta) {
|
353
|
+
if ((key + ":" + node.meta[key]).match(filter)) {
|
354
|
+
return true;
|
355
|
+
}
|
356
|
+
}
|
357
|
+
|
358
|
+
return false;
|
359
|
+
}
|
384
360
|
}
|
385
361
|
|
386
|
-
$(
|
387
|
-
resizeAll();
|
362
|
+
$(window).resize(resizeAll);
|
363
|
+
resizeAll();
|