Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format TTL for humans #147

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 0 additions & 158 deletions Gemfile.lock

This file was deleted.

16 changes: 15 additions & 1 deletion lib/riemann/dash/public/eventPane.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
// Pane at the bottom of the dashboard for displaying events in context.

function format_ttl(ttl) {
if (parseInt(ttl) != ttl) {
return ttl;
}

if (ttl > 3600 * 48) {
return (ttl / 3600 / 24).toFixed(1) + " days";
} else if (ttl > 3600 * 2) {
return (ttl / 3600).toFixed(1) + " hours";
} else if (ttl > 60 * 2) {
return (ttl / 60).toFixed(1) + " minutes";
}
return ttl + " seconds";
}
var eventPane = (function() {
var el = $('#event-pane');
var fixedFields = ['host', 'service', 'time', 'state', 'metric', 'ttl', 'description', 'tags'];
Expand All @@ -11,7 +25,7 @@ var eventPane = (function() {
'<span class="state {{-state}}">{{-state}}</span>' +
'<span class="metric">{{-metric}}</span>' +
'<time class="absolute">{{-time}}</time>' +
'<span class="ttl">{{-ttl}}</span>' +
'<span class="ttl">{{-format_ttl(ttl)}}</span>' +
'<span class="tags">{{-tags}}</span>' +
'</div>' +
'<pre class="description">{{-description}}</pre>');
Expand Down
25 changes: 22 additions & 3 deletions lib/riemann/dash/views/css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ h2 {
left: 0;
right: 0;
bottom: 0;
overflow: auto;
}

.bar {
Expand Down Expand Up @@ -468,18 +469,36 @@ h2 {

th {
text-align: right;
background-color: #fff;
}

thead {
margin: 0;
padding: 0;

th {
// Work around https://bugs.webkit.org/show_bug.cgi?id=20040
position: relative;
top: 3px;
vertical-align: bottom;
text-align: left;
position: sticky;
top: 0;
z-index: 1;

&:first-child {
left: 0;
z-index: 2;
}
}
}

tbody {
tr:hover, tr:hover th {
background-color: $cream;
}

th {
position: sticky;
left: 0;
z-index: 1;
}
}
}
Expand Down
Loading