-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmy_template.html
More file actions
195 lines (168 loc) · 5.92 KB
/
my_template.html
File metadata and controls
195 lines (168 loc) · 5.92 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>SCE Service Status</title>
<style>
table {
border-collapse: collapse;
margin: 0;
padding: 0;
border-spacing: 0;
vertical-align: top;
}
th,
td {
margin: 0;
padding: 4px 8px;
vertical-align: top;
font-size: 16px;
line-height: 1.4;
}
tr{
border-bottom: 1px solid #ddd;
}
tr:hover{
background-color: #ADD8E6
}
.highlighted {
background-color: #ADD8E6;
}
.sticky-col {
position: sticky;
left: 0;
background: #ffffff;
z-index: 1;
}
h1{
margin-block-start: 0.0em;
margin-block-end: 0.0em;
display: inline-block;
}
.container {
margin: 0;
padding: 0;
}
* {
box-sizing: border-box;
}
#status_table {
overflow-x: auto;
white-space: nowrap;
}
#sce_logo {
width: 53px;
margin-right: 20px;
}
#outside_container {
display: flex;
}
#range_data_container {
margin-left: 20px;
}
.current_table_data {
margin-right: 2px;
}
#info_container{
display: inline-block;
}
</style>
</head>
<body>
<div id = "info_container">
<img id="sce_logo" alt="SCE_Logo">
<h1>How are our services doing ???</h1>
<h2>Current Time: <span id = "clock"></span></h2>
<h2 id="fetch_time">Fetch Time: {{ fetch_time }}</h2>
</div>
<div id="outside_container">
<div id="current_data_container">
<table id="status_table">
<tr><th class="sticky-col" style="text-align: left; padding-right: 2px">✅ Up | ❌ Down | ⚠️ No Data</th></tr>
<tr>
<th class="sticky-col" style="text-align: left; padding-right: 2px">Job Name</th>
<th style="text-align: left; padding-right: 2px">Status</th>
<th style="text-align: left; padding-right: 2px">Detail</th>
<th>
<div style="display: inline">Prev. Day</div>
<div style="display: inline"> ◀➖➖➖➖➖➖➖➖ </div>
<div style="display: inline">History of past 24 Hours</div>
<div style="display: inline"> ➖➖➖➖➖➖➖➖▶ </div>
<div style="display: inline">Now</div>
</th>
</tr>
{% for item in data %}
{% set job = item.job %}
{% if item.is_up %}
{% set status = "✅ UP" %}
{% else %}
{% set status = "❌ DOWN" %}
{% endif %}
{% set detail = item.instance %}
<tr class="current_table_data" onclick="highlightRow(this)">
<td class="sticky-col">{{ job }}</td>
<td>{{ status }}</td> {# This TD is for the "Status" column #}
<td>{{ detail }}</td>
{# THIS IS THE CORRECTED SECTION for the EMOJI HISTORY #}
<td>
{% for value in item.values %}
{% if value.value == "1" %}
✅
{% elif value.value == "0" %}
❌
{% else %}
⚠️
{% endif %}
{# the below if-statement adds a vertical line for every four entries #}
{% if (not loop.index % 4) and loop.index < 24%}
|
{% endif %}
{% endfor %}
</td>
{# END OF CORRECTED SECTION #}
{# The original template had an unclosed <td> and then {% endfor %}.
You also need to make sure you have enough <td> elements
to match your <th> headers.
Based on your <th>s: Job Name, Status, Detail, History.
You only had 2 <td>s initially.
#}
</tr>
{% endfor %}
</table>
</div>
</div>
<script>
const img = document.getElementById('sce_logo');
const imageUrl = new URL('static/img/sce.jpg', window.location.href);
img.src = imageUrl.href;
const timeElement = document.getElementById("clock");
function updateTime() {
const now = new Date();
const year = now.getFullYear();
const month = now.getMonth() + 1 ;
const date = now.getDate();
const hours = now.getHours();
const minutes = now.getMinutes();
const seconds = now.getSeconds();
// Format the string with leading zeroes
const dayStr = `${year.toString()}-${month.toString().padStart(2, '0')}-${date.toString().padStart(2, '0')}`
const clockStr = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
timeElement.innerText = `${dayStr} ${clockStr} - Local Time`;
}
// Call initially to display time immediately
updateTime();
// Update every second
setInterval(updateTime, 1000);
function highlightRow(clickedRow) {
if (clickedRow.classList.contains('highlighted')){
clickedRow.classList.remove("highlighted");
return;
}
document.querySelectorAll("tr").forEach(row => {
row.classList.remove("highlighted");
});
clickedRow.classList.add("highlighted");
}
</script>
</body>
</html>