consul-templaterb 1.18.5 → 1.19.0
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/.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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c205b2067eaf6526b4885b4303c580e2b52d4e770371db3d9678908c013b19fd
|
|
4
|
+
data.tar.gz: 0fe4a33a112ff1801391d4c6df928d0f63a7bc606cd0b2aa57f1907bbb3a50d1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: abef2e2b0cf9dec0ab94aaa04ad3377c0f13171cc9ffc8fa83a47a99c6a99ff229834c76c4209d1ca3d854d8006450fd8bb745f7cb594b444e2c83fc7711ec61
|
|
7
|
+
data.tar.gz: 6c818a568ed87d660545a03f3308c4b97cd5b3e17a80d7d7d38c1c79453fd20e73a8912b6a1da9b259b368124fab3abad7c7930cca10f6eabc1dd0475874309a
|
data/.travis.yml
CHANGED
|
@@ -3,11 +3,16 @@ rvm:
|
|
|
3
3
|
- 2.4.7
|
|
4
4
|
- 2.5.6
|
|
5
5
|
- 2.6.4
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
jobs:
|
|
7
|
+
include:
|
|
8
|
+
- stage: Gem release
|
|
9
|
+
rvm: 2.5.6
|
|
10
|
+
script: echo "Publishing consul-templaterb on rubygems.org ..."
|
|
11
|
+
deploy:
|
|
12
|
+
provider: rubygems
|
|
13
|
+
api_key:
|
|
14
|
+
secure: l78H6Ow9HCeEz0hcAP2XCXaGGBNRXZ/QLFPNzwyNmHToko9WqZj6mbiNIcVwZ8aCcZEzFmtcB7m1lC1l+mvot3Snfh4OUErK7EXMLiNxUWybtA4qJqmsb2J8JGS69pTohPKagi1YyRbyVs2tJpM5OVazcNxEQDAVkWVxJuPVz6tsn4rXZsL77nTSVyB6YGKgguRGhtS/3M0ufk1ymOpuk8pxXKaotlYGRXmht2OHW+FDQczTMgqu6jiZubjWlNHVxtYn+CsLYNj1BswzD6fF1uous6nchV0if2QW5N4OJVyZCx3yEQ0RswfI8G1kG/Jm8wd2lSknY2wpnd1qkRnAcFlKBpUv8aQd6SdbSO84GTAOvucgK7Mcf0LRvYSE2FyagaAPFSfMybWd+GS26g5AuRPpkhtsS9ijfdIzpudiF18pvnJ+wQj+hWM/THWowYNyKv9NeckxdrULaHPisA346r5eM/EADOhyEUtPm11PFgcheGjff1H4qXGc9gcm50u6mNNHkWv38oGhAPpRk/bU7qybTKqRKNGWGP0MiT4WVIFXp62/JMY7AmufOdJx5Ca5JVsaWoN4fsS9r3+R+FxvRtV9NOrRJVKKaQhzi4UHEUDQ2hQjpLDijD5L0vUsl6arl+nufTt5G5jp9QvdY7fhYT1mpGgWj0hTBd8Pxsl3N8U=
|
|
15
|
+
gem: consul-templaterb
|
|
16
|
+
on:
|
|
17
|
+
tags: true
|
|
18
|
+
repo: criteo/consul-templaterb
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
## (UNRELEASED)
|
|
4
4
|
|
|
5
|
+
## 1.19.0 (October 14, 2019)
|
|
6
|
+
|
|
7
|
+
IMPROVEMENTS:
|
|
8
|
+
|
|
9
|
+
* Refactor JS code in consul-ui
|
|
10
|
+
* Removed old samples not used anymore
|
|
11
|
+
|
|
12
|
+
NEW FEATURES:
|
|
13
|
+
|
|
14
|
+
* Added new function `checks_for_node`
|
|
15
|
+
|
|
16
|
+
BUGFIXs:
|
|
17
|
+
|
|
18
|
+
* Avoid try publishing several times Gem on rubygems.org
|
|
19
|
+
|
|
5
20
|
## 1.18.5 (September 30, 2019)
|
|
6
21
|
|
|
7
22
|
IMPROVEMENTS:
|
data/README.md
CHANGED
|
@@ -251,19 +251,17 @@ by consul-templaterb.
|
|
|
251
251
|
Have a look into the [samples/](samples/) directory to browse example files which contains those
|
|
252
252
|
examples:
|
|
253
253
|
|
|
254
|
-
1. [List all nodes on Cluster](samples/
|
|
255
|
-
2. [Show all services in Cluster](samples/
|
|
256
|
-
3. [Show all
|
|
257
|
-
4. [
|
|
258
|
-
5. [
|
|
259
|
-
6. [
|
|
260
|
-
7. [
|
|
261
|
-
8. [Generate HaProxy Configuration](samples/ha_proxy.cfg.erb)
|
|
262
|
-
9. [Export Consul Statistics to Prometheus](samples/metrics.erb) : count all services, their state,
|
|
254
|
+
1. [List all nodes on Cluster](samples/consul-ui/consul_nodes.json.erb)
|
|
255
|
+
2. [Show all services in Cluster](samples/consul-ui/consul_services.json.erb)
|
|
256
|
+
3. [Show all Key/Values nicely](samples/consul-ui/consul_keys.json.erb)
|
|
257
|
+
4. [Services in XML](samples/consul_template.xml.erb)
|
|
258
|
+
5. [Services in JSON](samples/consul_template.json.erb)
|
|
259
|
+
6. [Generate HaProxy Configuration](samples/ha_proxy.cfg.erb)
|
|
260
|
+
7. [Export Consul Statistics to Prometheus](samples/metrics.erb) : count all services, their state,
|
|
263
261
|
datacenters and nodes and export it to prometheus easily to trigger alerts.
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
262
|
+
8. [List all services/Nodes with their statuses for all datacenters](samples/all_services.txt.erb)
|
|
263
|
+
9. [Show all services/instances not passing on all DCs](samples/tools/find_all_failing_services.txt.erb)
|
|
264
|
+
10. [List all rubygems consul versions from remote server JSON](samples/list_ruby_versions_from_rubygems.txt.erb)
|
|
267
265
|
|
|
268
266
|
If you want to test it quickly, you might try with (assuming your consul agent is listening on
|
|
269
267
|
`http://localhost:8500`):
|
data/TemplateAPI.md
CHANGED
|
@@ -226,6 +226,10 @@ Full example: [samples/consul_template.txt.erb](samples/consul_template.txt.erb)
|
|
|
226
226
|
[List all the services of a given Node](https://www.consul.io/api/catalog.html#list-services-for-node) using its
|
|
227
227
|
name or its ID. If DC is specified, will lookup for given node in another datacenter.
|
|
228
228
|
|
|
229
|
+
## checks_for_node(name, dc: nil, passing: false, tag: nil)
|
|
230
|
+
|
|
231
|
+
[Find all the checks](https://www.consul.io/api/health.html#list-checks-for-node) of a given node name.
|
|
232
|
+
|
|
229
233
|
## checks_for_service(name, dc: nil, passing: false, tag: nil)
|
|
230
234
|
|
|
231
235
|
[Find all the checks](https://www.consul.io/api/health.html#list-checks-for-service) of a given service.
|
|
@@ -133,6 +133,16 @@ module Consul
|
|
|
133
133
|
create_if_missing(path, query_params) { ConsulTemplateChecks.new(ConsulEndpoint.new(consul_conf, path, true, query_params, '[]')) }
|
|
134
134
|
end
|
|
135
135
|
|
|
136
|
+
# https://www.consul.io/api/health.html#list-checks-for-node
|
|
137
|
+
def checks_for_node(name, dc: nil, passing: false)
|
|
138
|
+
raise 'You must specify a name for a service' if name.nil?
|
|
139
|
+
path = "/v1/health/node/#{name}"
|
|
140
|
+
query_params = {}
|
|
141
|
+
query_params[:dc] = dc if dc
|
|
142
|
+
query_params[:passing] = passing if passing
|
|
143
|
+
create_if_missing(path, query_params) { ConsulTemplateChecks.new(ConsulEndpoint.new(consul_conf, path, true, query_params, '[]')) }
|
|
144
|
+
end
|
|
145
|
+
|
|
136
146
|
# https://www.consul.io/api/catalog.html#list-nodes
|
|
137
147
|
def nodes(dc: nil)
|
|
138
148
|
path = '/v1/catalog/nodes'
|
data/lib/consul/async/version.rb
CHANGED
|
@@ -36,12 +36,6 @@
|
|
|
36
36
|
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.11/css/all.css" integrity="sha384-p2jx59pefphTFIpeqCcISO9MdVfIm4pNnsL08A6v5vaQc4owkQqxMV8kg4Yvhaw/" crossorigin="anonymous">
|
|
37
37
|
<link rel="stylesheet" href="css/style.css">
|
|
38
38
|
<link rel="stylesheet" href="vendors/highlight/atom-one-dark.css">
|
|
39
|
-
<style id="css-states">
|
|
40
|
-
.service-tags { display: none; }
|
|
41
|
-
</style>
|
|
42
|
-
<style id="serviceCol">
|
|
43
|
-
.service-tags { display: none; }
|
|
44
|
-
</style>
|
|
45
39
|
</head>
|
|
46
40
|
<body>
|
|
47
41
|
<nav class="navbar navbar-expand-md navbar-dark bg-secondary">
|
|
@@ -30,10 +30,11 @@
|
|
|
30
30
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
|
31
31
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
|
|
32
32
|
<script src="js/utils.js"></script>
|
|
33
|
+
<script src="js/types.js"></script>
|
|
33
34
|
<script src="js/keys.js"></script>
|
|
34
35
|
<script src="vendors/highlight/highlight.pack.js"></script>
|
|
35
36
|
<script type="text/javascript">
|
|
36
|
-
|
|
37
|
+
consulKeysManager = new ConsulKeysManager('<%= datasource %>');
|
|
37
38
|
</script>
|
|
38
39
|
</body>
|
|
39
40
|
</html>
|
|
@@ -6,14 +6,20 @@
|
|
|
6
6
|
<div class="col-12 col-m-12">
|
|
7
7
|
<h2 class="text-center" id="service-title"></h2>
|
|
8
8
|
<div class="row mb-2">
|
|
9
|
-
<div class="input-group float-left col-
|
|
10
|
-
<input id="instance-filter" type="text" placeholder="filter nodes by name, service or tags" class="form-control"
|
|
9
|
+
<div class="input-group float-left col-7">
|
|
10
|
+
<input id="instance-filter" type="text" placeholder="filter nodes by name, service or tags" class="form-control" >
|
|
11
11
|
</div>
|
|
12
|
-
<
|
|
13
|
-
<
|
|
14
|
-
<
|
|
15
|
-
<
|
|
16
|
-
<
|
|
12
|
+
<select id="max-display-selector" class="form-control col-2">
|
|
13
|
+
<option selected="selected" value="100">Show 100</option>
|
|
14
|
+
<option value="500">Show 500</option>
|
|
15
|
+
<option value="1000">Show 1000</option>
|
|
16
|
+
<option value="all">All</option>
|
|
17
|
+
</select>
|
|
18
|
+
<div id="instance-statuses" class="float-right col-3">
|
|
19
|
+
<span id="service-status-passing" status="passing" class="badge mx-1 badge-success passing service-status">0</span>
|
|
20
|
+
<span id="service-status-warning" status="warning" class="badge mx-1 badge-warning warning service-status">0</span>
|
|
21
|
+
<span id="service-status-critical" status="critical" class="badge mx-1 badge-danger critical service-status">0</span>
|
|
22
|
+
<span id="service-status-total" status="total" class="badge mx-1 badge-dark service-status">0</span>
|
|
17
23
|
</div>
|
|
18
24
|
</div>
|
|
19
25
|
<div id="instances-wrapper">
|
|
@@ -27,9 +33,10 @@
|
|
|
27
33
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
|
28
34
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
|
|
29
35
|
<script src="js/utils.js"></script>
|
|
36
|
+
<script src="js/types.js"></script>
|
|
30
37
|
<script src="js/nodes.js"></script>
|
|
31
38
|
<script type="text/javascript">
|
|
32
|
-
|
|
39
|
+
consulNodesManager = new ConsulNodesManager('<%= datasource %>');
|
|
33
40
|
</script>
|
|
34
41
|
</body>
|
|
35
42
|
</html>
|
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
<div class="form-group">
|
|
8
8
|
<div class="form-check form-check-inline">
|
|
9
9
|
<label class="form-check-label">
|
|
10
|
-
<input id="showTagsInList" type="checkbox" title="show tags"
|
|
10
|
+
<input id="showTagsInList" type="checkbox" title="show tags" class="form-check-input" />
|
|
11
11
|
Show Tags
|
|
12
12
|
</label>
|
|
13
13
|
</div>
|
|
14
14
|
<div class="form-check form-check-inline">
|
|
15
15
|
<label class="form-check-label">
|
|
16
|
-
<input id="showProxiesInList" type="checkbox" title="show Consul Connect Proxies"
|
|
16
|
+
<input id="showProxiesInList" type="checkbox" title="show Consul Connect Proxies" class="form-check-input" />
|
|
17
17
|
Show Connect Proxies
|
|
18
18
|
</label>
|
|
19
19
|
</div>
|
|
@@ -32,14 +32,26 @@
|
|
|
32
32
|
<div class="col-8 col-m-9">
|
|
33
33
|
<h2 class="text-center" id="service-title"></h2>
|
|
34
34
|
<div class="row mb-2">
|
|
35
|
-
<div class="input-group float-left col-
|
|
36
|
-
<input id="instance-filter" type="text" placeholder="filter nodes by name or tags" class="form-control"
|
|
35
|
+
<div class="input-group float-left col-7">
|
|
36
|
+
<input id="instance-filter" type="text" placeholder="filter nodes by name, service or tags" class="form-control" >
|
|
37
|
+
</div>
|
|
38
|
+
<select id="max-display-selector" class="form-control col-2">
|
|
39
|
+
<option selected="selected" value="100">Show 100</option>
|
|
40
|
+
<option value="500">Show 500</option>
|
|
41
|
+
<option value="1000">Show 1000</option>
|
|
42
|
+
<option value="all">All</option>
|
|
43
|
+
</select>
|
|
44
|
+
<div id="instance-statuses" class="float-right col-3">
|
|
45
|
+
<span id="service-status-passing" status="passing" class="badge mx-1 badge-success passing service-status">0</span>
|
|
46
|
+
<span id="service-status-warning" status="warning" class="badge mx-1 badge-warning warning service-status">0</span>
|
|
47
|
+
<span id="service-status-critical" status="critical" class="badge mx-1 badge-danger critical service-status">0</span>
|
|
48
|
+
<span id="service-status-total" status="total" class="badge mx-1 badge-dark service-status">0</span>
|
|
37
49
|
</div>
|
|
38
50
|
</div>
|
|
39
51
|
<div class="progress">
|
|
40
|
-
<div id="service-progress-passing" status="passing"
|
|
41
|
-
<div id="service-progress-warning" status="warning"
|
|
42
|
-
<div id="service-progress-critical" status="critical"
|
|
52
|
+
<div id="service-progress-passing" status="passing" class="progress-status progress-bar bg-success" role="progressbar" style="width: 100%">passing</div>
|
|
53
|
+
<div id="service-progress-warning" status="warning" class="progress-status progress-bar bg-warning" role="progressbar" style="width: 0%">warning</div>
|
|
54
|
+
<div id="service-progress-critical" status="critical" class="progress-status progress-bar bg-danger" role="progressbar" style="width: 0%">critical</div>
|
|
43
55
|
</div>
|
|
44
56
|
<div id="instances-wrapper">
|
|
45
57
|
<div id="instances-list" class="list-group"></div>
|
|
@@ -52,9 +64,10 @@
|
|
|
52
64
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
|
53
65
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
|
|
54
66
|
<script src="js/utils.js"></script>
|
|
67
|
+
<script src="js/types.js"></script>
|
|
55
68
|
<script src="js/service.js"></script>
|
|
56
69
|
<script type="text/javascript">
|
|
57
|
-
|
|
70
|
+
consulServiceManager = new ConsulServiceManager('<%= datasource %>');
|
|
58
71
|
</script>
|
|
59
72
|
<script src="vendors/highlight/highlight.pack.js"></script>
|
|
60
73
|
</body>
|
|
@@ -91,7 +91,6 @@ td.serviceName {
|
|
|
91
91
|
|
|
92
92
|
#service-wrapper .list-group-item:last-child, #instances-wrapper .list-group-item:last-child,
|
|
93
93
|
#keys-wrapper .list-group-item:last-child {
|
|
94
|
-
border-bottom-width: 0px;
|
|
95
94
|
border-bottom-left-radius: 0px;
|
|
96
95
|
border-bottom-right-radius: 0px;
|
|
97
96
|
}
|
|
@@ -239,10 +238,15 @@ pre, code {
|
|
|
239
238
|
margin-bottom: 0px;
|
|
240
239
|
}
|
|
241
240
|
|
|
242
|
-
.
|
|
241
|
+
.service-list-item {
|
|
242
|
+
cursor: pointer;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.connect-enabled {
|
|
243
246
|
float:right;
|
|
244
247
|
border: 1px #ccc solid;
|
|
245
248
|
}
|
|
246
|
-
|
|
249
|
+
|
|
250
|
+
.connect-disabled {
|
|
247
251
|
display: none;
|
|
248
252
|
}
|
|
@@ -1,132 +1,88 @@
|
|
|
1
|
-
class
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
initRessource(data) {
|
|
20
|
-
this.data = data;
|
|
21
|
-
this.reloadKeysList();
|
|
22
|
-
console.log('Data generated at: ' + data['generated_at']);
|
|
1
|
+
class ConsulKeysManager extends ConsulUIManager {
|
|
2
|
+
constructor(resourceURL) {
|
|
3
|
+
super(resourceURL);
|
|
4
|
+
this.codeDisplayer = new CodeDisplayer(
|
|
5
|
+
$("#kv-data"),
|
|
6
|
+
$("#kv-title"),
|
|
7
|
+
)
|
|
8
|
+
this.sideSelector = new KeySideSelector(
|
|
9
|
+
this.codeDisplayer,
|
|
10
|
+
$("#keys-filter"),
|
|
11
|
+
$("#keys-list"),
|
|
12
|
+
$("#keys-counter"),
|
|
13
|
+
"filter",
|
|
14
|
+
"key"
|
|
15
|
+
);
|
|
16
|
+
this.fetchResource();
|
|
17
|
+
}
|
|
23
18
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if($(nodes[i]).find(".key-name").html() == urlParam) {
|
|
29
|
-
var selectedElement = $(nodes[i])
|
|
30
|
-
this.selectKey(selectedElement);
|
|
31
|
-
selectedElement.focus()
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
} else {
|
|
36
|
-
this.selectKey(document.getElementById('keys-list').firstElementChild);
|
|
19
|
+
async initResource(data) {
|
|
20
|
+
this.sideSelector.data = data["kv"];
|
|
21
|
+
this.sideSelector.prepareData();
|
|
22
|
+
this.sideSelector.refreshList();
|
|
37
23
|
}
|
|
24
|
+
}
|
|
38
25
|
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
class KeySideSelector extends SideSelector {
|
|
27
|
+
constructor(
|
|
28
|
+
codeDisplayer,
|
|
29
|
+
filterElement,
|
|
30
|
+
listElement,
|
|
31
|
+
counterElement,
|
|
32
|
+
URLLabelFilter,
|
|
33
|
+
URLLabelSelected
|
|
34
|
+
) {
|
|
35
|
+
super(
|
|
36
|
+
filterElement,
|
|
37
|
+
listElement,
|
|
38
|
+
counterElement,
|
|
39
|
+
URLLabelFilter,
|
|
40
|
+
URLLabelSelected,
|
|
41
|
+
false
|
|
42
|
+
);
|
|
43
|
+
this.codeDisplayer = codeDisplayer
|
|
41
44
|
}
|
|
42
|
-
}
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
matchElement(key, keyData, filter) {
|
|
47
|
+
return key.match(filter);
|
|
48
|
+
}
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
elementGenerator(key, data) {
|
|
51
|
+
var element = document.createElement("li");
|
|
49
52
|
|
|
50
|
-
|
|
51
|
-
listItem.setAttribute('type','button');
|
|
52
|
-
listItem.setAttribute('onfocus','consulKeys.onClickServiceName(this)');
|
|
53
|
-
listItem.setAttribute('onclick','consulKeys.onClickServiceName(this)');
|
|
54
|
-
listItem.setAttribute('value',key);
|
|
55
|
-
listItem.setAttribute('class','list-group-item list-group-item-action');
|
|
53
|
+
var CSSClass = "service-list-item list-group-item list-group-item-action";
|
|
56
54
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
var obj = this;
|
|
56
|
+
element.addEventListener("focus", function () {
|
|
57
|
+
obj.onClickElement(this, key);
|
|
58
|
+
});
|
|
59
|
+
element.addEventListener("click", function () {
|
|
60
|
+
obj.onClickElement(this, key);
|
|
61
|
+
});
|
|
61
62
|
|
|
62
|
-
|
|
63
|
-
this.keysList.append(listItem);
|
|
64
|
-
}
|
|
65
|
-
this.keysFilterCounter.html(this.keysFilterCount);
|
|
66
|
-
resizeWrapper('keys-wrapper', 'keys-list');
|
|
67
|
-
this.filterService();
|
|
68
|
-
}
|
|
63
|
+
element.setAttribute("value", key);
|
|
69
64
|
|
|
70
|
-
|
|
71
|
-
var filter = new RegExp(consulKeys.keysFilter.val());
|
|
72
|
-
consulKeys.keysFilterCount = 0;
|
|
73
|
-
consulKeys.keysList.children('button').each(function (){
|
|
74
|
-
var ui = $(this);
|
|
75
|
-
if(keyMatcher(this, filter)) {
|
|
76
|
-
ui.removeClass('d-none');
|
|
77
|
-
ui.addClass('d-block');
|
|
78
|
-
consulKeys.keysFilterCount += 1;
|
|
79
|
-
consulKeys.keysFilterCounter.html(consulKeys.keysFilterCount);
|
|
80
|
-
} else {
|
|
81
|
-
ui.removeClass('d-block');
|
|
82
|
-
ui.addClass('d-none');
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
}
|
|
65
|
+
element.setAttribute("class", CSSClass);
|
|
86
66
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
67
|
+
var nameItem = document.createElement("div");
|
|
68
|
+
nameItem.setAttribute("class", "service-name");
|
|
69
|
+
nameItem.appendChild(document.createTextNode(key));
|
|
70
|
+
element.appendChild(nameItem);
|
|
92
71
|
|
|
93
|
-
|
|
94
|
-
var newUrl = new URL(location.href);
|
|
95
|
-
if (this.selectedKeyName) {
|
|
96
|
-
newUrl.searchParams.set('key', this.selectedKeyName);
|
|
97
|
-
} else {
|
|
98
|
-
newUrl.searchParams.delete('key')
|
|
72
|
+
return element;
|
|
99
73
|
}
|
|
100
|
-
window.history.pushState({},"",newUrl.href);
|
|
101
|
-
}
|
|
102
74
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
displayKey(key) {
|
|
114
|
-
$("#kv-title").html(key);
|
|
115
|
-
if(this.data.kv[key] != null) {
|
|
116
|
-
var dataToDisplay = atob(this.data.kv[key]);
|
|
117
|
-
} else {
|
|
118
|
-
var dataToDisplay = 'NO DATA';
|
|
75
|
+
selectItem(element, key) {
|
|
76
|
+
super.selectItem(element, key);
|
|
77
|
+
if (this.data[key] != null) {
|
|
78
|
+
var dataToDisplay = atob(this.data[key]);
|
|
79
|
+
} else {
|
|
80
|
+
var dataToDisplay = 'NO DATA';
|
|
81
|
+
}
|
|
82
|
+
this.codeDisplayer.displayData(key, dataToDisplay);
|
|
119
83
|
}
|
|
120
|
-
|
|
121
|
-
$("#kv-data").text(dataToDisplay);
|
|
122
|
-
$("#kv-data").removeClass();
|
|
123
|
-
|
|
124
|
-
$('pre code').each(function(i, block) {
|
|
125
|
-
hljs.highlightBlock(block);
|
|
126
|
-
});
|
|
127
|
-
resizeWrapper('data-wrapper', 'kv-data');
|
|
128
|
-
}
|
|
129
84
|
}
|
|
130
85
|
|
|
131
|
-
|
|
132
|
-
|
|
86
|
+
|
|
87
|
+
$(window).resize(resizeData);
|
|
88
|
+
resizeData();
|