-
Notifications
You must be signed in to change notification settings - Fork 0
/
services.html
executable file
·80 lines (69 loc) · 2.75 KB
/
services.html
1
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<services-panel>
<pigod-panel>
<yield to="title">
Services ({last_udpated})
</yield>
<yield to="body">
<riot-table stretchcol="name" rows={services} context={model} defaultsort="name">
<riot-col key="stat" header="Stat" cls="text-center"
tpl={'<img src="images/{status2Icon[row.stat]}.png" width="16" height="16">'}/>
<riot-col key="name" header="Name" />
<riot-col key="commands" header="Commands" cls="text-center" tpl={'
<img src="images/play.png" width="16" height="16" class="button start { row.stat == \'+\' ? \'disabled\' : \'\' }" >
<img src="images/stop.png" width="16" height="16" class="button stop { row.stat == \'-\' ? \'disabled\' : \'\' }" >
<img src="images/restart.png" width="16" height="16" class="button restart { row.stat == \'-\' ? \'disabled\' : \'\' }" >
'} cellclick={parent.model.commandClick}/>
</riot-table>
</yield>
</pigod-panel>
<style scoped>
img.button {
cursor: pointer;
}
img.disabled {
-webkit-filter: grayscale(100%);
cursor: initial;
}
</style>
<script type="text/es6arrow">
start() {
opts.pubsub.subscribe('services', this.handler = data => this.updateProc(data));
}
stop() {
opts.pubsub.unsubscribe('services', this.handler);
}
this.status2Icon = {
'-' : 'error',
'+' : 'ok',
'?' : 'help'
};
updateProc(data) {
this.update({
last_udpated: new Date().toLocaleString(),
services: data.slice()
});
}
commandClick(value, row, col, evt) {
if (evt.target.tagName !== 'IMG' ) return;
['start', 'stop', 'restart'].forEach(cmd => {
if (evt.target.className.indexOf(' '+cmd) >= 0) {
this[cmd+'Click'](row);
}
});
}
startClick(item) {
if (item && item.stat != '+') this.serviceCall(item.name, 'start');
}
stopClick(item) {
if (item && item.stat != '-') this.serviceCall(item.name, 'stop');
}
restartClick(item) {
if (item && item.stat != '-') this.serviceCall(item.name, 'restart');
}
serviceCall(name, command) {
if (confirm(command + ' ' + name + ' ?')) {
opts.pubsub.publish('serviceCall', { name: name, command: command });
}
}
</script>
</services-panel>