-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
155 lines (138 loc) · 5.67 KB
/
index.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://unpkg.com/vue"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.js"></script>
<script type="text/javascript">
var groups = [];
var app = {
serverTime: '',
jobCount: 0
};
var jobModal = {
title: "Test Modal",
body: "HTTP Response goes here"
};
$(function() {
console.log('load page');
var view = new Vue({
el: '#app',
data: {
groups: groups,
app: app,
jobModal: jobModal
},
computed: {
classStatus: function() {
return {
'badge-info': this.lastStatus == 'OK',
'badge-danger': this.lastStatus != 'OK'
}
}
},
methods: {
modal: function(job) {
jobModal.title = job.title + ' - ' + job.statusCode + ': ' + job.lastStatus;
jobModal.body = job.body;
$("#modal").modal();
}
}
});
var socket = io();
socket.on('groups', function(data) {
for(var i=0; i<data.length; i++) {
Vue.set(groups, i, data[i]);
}
});
// Identify the job that was updated and set
socket.on('job', function(job) {
for(var i=0; i<groups.length; i++) {
for(var j=0; j<groups[i].Jobs.length; j++) {
if (groups[i].Jobs[j].cron === job.cron && groups[i].Jobs[j].url === job.url) {
Vue.set(groups[i].Jobs, j, job);
}
}
}
});
socket.on('tick', function(data) {
app.serverTime = data.serverTime;
$('#message').html(data.serverTime + '<br />');
});
socket.on('message', function(msg) {
$('#message').append(msg + '<br />');
});
socket.emit('register');
});
</script>
</head>
<body style="padding:40px">
<div id="app" class="container-fluid">
<div style="padding: 20px">
<h3>Server Time: {{ app.serverTime }}</h3>
</div>
<div id="accordion" role="tablist">
<div class="card" v-for="(group, key, index) in groups">
<div class="card-header" role="tab">
<h5 class="mb-0">
<a data-toggle="collapse" v-bind:href="'#group' + key">
{{ group.title }}
</a>
</h5>
</div>
<div v-bind:id="'group' + key" v-bind:class="{show: key == 0}" class="collapse" data-parent="#accordion">
<div class="card-body">
<table class="table">
<thead>
<tr>
<th>Title</th>
<th v-if="group.cron">Finished</th>
<th v-else>Cron</th>
<th>URL</th>
<th>Next Run</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr v-for="job in group.Jobs" v-bind:class="{'table-danger': job.statusCode != 200 && job.statusCode != 0}">
<td>{{ job.title }}</td>
<td>
<a v-if="job.cron" v-bind:href="job.guru" target="_blank">{{ job.cron }}</a>
<span v-else>{{ job.lastRun }}</span>
</td>
<td>{{ job.url }}</td>
<td>{{ job.nextRun }}</td>
<td><a href="#" v-bind:title="job.string"><span v-on:click="modal(job)" v-bind:class="{'badge-info': job.statusCode == 200, 'badge-danger': job.statusCode != 200 && job.statusCode != 0}" class="badge" v-bind:title="job.lastStatus">{{job.statusCode}}</span></a></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">{{ jobModal.title }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<pre>{{ jobModal.body }}</pre>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>