Skip to content

Commit e0edf95

Browse files
authored
Merge pull request #33 from aaronshaf/fix/25
Show popup with ISO date for values with assumed timestamps (fixes #25)
2 parents c06b78c + 143983c commit e0edf95

File tree

4 files changed

+50
-17
lines changed

4 files changed

+50
-17
lines changed

public/vendor/bootstrap/bootstrap.bundle.min.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/vendor/bootstrap/jquery-3.3.1.slim.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

views/partials/bootstrap-deps.ejs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<script src='/assets/vendor/bootstrap/jquery-3.3.1.slim.min.js'></script>
2+
<script src='/assets/vendor/bootstrap/bootstrap.bundle.min.js'></script>
3+
<script>
4+
$(function () {
5+
$('[data-toggle="tooltip"]').tooltip()
6+
})
7+
</script>

views/scan.ejs

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<html lang="en">
33
<head>
44
<% include ./partials/head %>
5+
<% include ./partials/bootstrap-deps %>
56
</head>
67
<body class="container-fluid">
78
<header>
@@ -115,9 +116,9 @@
115116
<div class="col-md-6">
116117
<button type="submit" class="btn btn-primary">Scan</button>
117118
</div>
118-
119+
119120
<div class="col-md-6">
120-
121+
121122
<nav style="float: right">
122123
<ul class="pagination" style="margin: 0">
123124
<% if (nextKey) { %>
@@ -129,11 +130,11 @@
129130
<div style="float: right; line-height: 48px; text-align:right; margin-right: 20px">Page <%= pageNum %> </div>
130131
</div>
131132
</div>
132-
133-
134-
135-
136-
133+
134+
135+
136+
137+
137138
</form>
138139
<script>
139140
const form = document.querySelector('#form')
@@ -152,8 +153,8 @@
152153
<thead>
153154
<tr>
154155
<td>Actions</td>
155-
<% for(let i = 0; i < primaryKeys.length; i++) { %>
156-
<td><%= primaryKeys[i] %></td>
156+
<% for(const primaryKey of primaryKeys) { %>
157+
<td><%= primaryKey %></td>
157158
<% } %>
158159
<% for(const key of UniqueKeys) { %>
159160
<% if (!ignored.includes(key)) { %>
@@ -163,19 +164,35 @@
163164
</tr>
164165
</thead>
165166
<tbody>
166-
<% for(let row = 0; row < Items.length; row++) { %>
167+
<% for(const item of Items) { %>
167168
<tr>
168169
<td>
169-
<a href="/tables/<%= Table.TableName %>/items/<%= encodeURIComponent(Object.values(Items[row].__key).join(',')) %>">View</a>
170+
<a href="/tables/<%= Table.TableName %>/items/<%= encodeURIComponent(Object.values(item.__key).join(',')) %>">View</a>
170171
</td>
171-
<% for(let i = 0; i < primaryKeys.length; i++) { %>
172-
<td><%= Items[row][primaryKeys[i]] %></td>
173-
<% } %>
174-
<% for(let column = 0; column < UniqueKeys.length; column++) { %>
175-
<% if (!ignored.includes(UniqueKeys[column])) { %>
176-
<td><%= Items[row][UniqueKeys[column]] %></td>
172+
<% for(const primaryKey of primaryKeys) { %>
173+
<td><%= item[primaryKey] %></td>
174+
<% } %>
175+
<% for(const column of UniqueKeys) { %>
176+
<% if (!ignored.includes(column)) { %>
177+
<td>
178+
<% const value = item[column];
179+
if (Number.isInteger(value) && value >= 0) {
180+
let dateValue;
181+
try {
182+
dateValue = new Date(value).toISOString();
183+
} catch (error) {
184+
dateValue = error.message;
185+
} %>
186+
<abbr data-toggle="tooltip" data-placement="top"
187+
title="<%= dateValue %>">
188+
<%= item[column] %>
189+
</abbr>
190+
<% } else { %>
191+
<%= item[column] %>
177192
<% } %>
193+
</td>
178194
<% } %>
195+
<% } %>
179196
</tr>
180197
<% } %>
181198
</tbody>

0 commit comments

Comments
 (0)