Loading indicator
This commit is contained in:
parent
34b43b12ee
commit
f164c6afab
@ -12,26 +12,23 @@
|
|||||||
.title, td, th {
|
.title, td, th {
|
||||||
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||||
font-size: 1.3em;
|
font-size: 1.3em;
|
||||||
padding: 10px;
|
padding: 0.6em;
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
.title {
|
.title, table {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 10px;
|
|
||||||
left: 50%;
|
left: 50%;
|
||||||
width: 600px;
|
width: 650px;
|
||||||
margin-left: -300px;
|
margin-left: -325px;
|
||||||
|
}
|
||||||
|
.title {
|
||||||
|
top: 10px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 1.8em;
|
font-size: 1.8em;
|
||||||
font-weight: 300;
|
|
||||||
}
|
}
|
||||||
table {
|
table {
|
||||||
position: absolute;
|
|
||||||
top: 100px;
|
top: 100px;
|
||||||
left: 50%;
|
|
||||||
width: 600px;
|
|
||||||
margin-left: -300px;
|
|
||||||
border-spacing: 0;
|
border-spacing: 0;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
}
|
}
|
||||||
@ -45,8 +42,8 @@ tbody tr:nth-child(even) {
|
|||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
}
|
}
|
||||||
.name {
|
.name {
|
||||||
width: 300px;
|
width: 350px;
|
||||||
max-width: 300px;
|
max-width: 350px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
@ -55,14 +52,9 @@ tbody tr:nth-child(even) {
|
|||||||
.messages, .subscriptions {
|
.messages, .subscriptions {
|
||||||
width: 150px;
|
width: 150px;
|
||||||
max-width: 150px;
|
max-width: 150px;
|
||||||
font-weight: 400;
|
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
#placeholder td {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
.zero {
|
.zero {
|
||||||
font-weight: 300;
|
|
||||||
color: #aaa;
|
color: #aaa;
|
||||||
}
|
}
|
||||||
.fat {
|
.fat {
|
||||||
@ -72,6 +64,17 @@ tbody tr:nth-child(even) {
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #f20;
|
color: #f20;
|
||||||
}
|
}
|
||||||
|
#loading {
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
bottom: 10px;
|
||||||
|
right: 10px;
|
||||||
|
font-size: 0.5em;
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
#placeholder td {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
@ -93,17 +96,22 @@ tbody tr:nth-child(even) {
|
|||||||
<td colspan="3">Loading queues...</td>
|
<td colspan="3">Loading queues...</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
<div id="loading">Loading...</div>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
function loadStatus(callback) {
|
function loadStatus(callback) {
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest(),
|
||||||
|
loading = document.getElementById('loading');
|
||||||
|
|
||||||
|
loading.setAttribute('style', 'display: block;');
|
||||||
xhr.open('GET', '/status', true);
|
xhr.open('GET', '/status', true);
|
||||||
xhr.onreadystatechange = function() {
|
xhr.onreadystatechange = function() {
|
||||||
if (xhr.readyState === 4) {
|
if (xhr.readyState === 4) {
|
||||||
if (xhr.status === 200) {
|
if (xhr.status === 200) {
|
||||||
var queues = JSON.parse(xhr.responseText);
|
var queues = JSON.parse(xhr.responseText);
|
||||||
|
loading.setAttribute('style', 'display: none;');
|
||||||
callback(queues);
|
callback(queues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,37 +137,39 @@ function updateDashboard(queues) {
|
|||||||
if (!tr) {
|
if (!tr) {
|
||||||
tr = document.createElement('tr');
|
tr = document.createElement('tr');
|
||||||
tr.setAttribute('id', id);
|
tr.setAttribute('id', id);
|
||||||
for (var i = 0; i < 3; i++) {
|
|
||||||
tr.appendChild(document.createElement('td'));
|
var nameCol = document.createElement('td');
|
||||||
}
|
nameCol.appendChild(document.createTextNode(queue));
|
||||||
|
tr.appendChild(nameCol);
|
||||||
|
tr.appendChild(document.createElement('td'));
|
||||||
|
tr.appendChild(document.createElement('td'));
|
||||||
|
|
||||||
queuesList.appendChild(tr);
|
queuesList.appendChild(tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
var nmsg = parseInt(meta.messages, 10),
|
|
||||||
nsub = parseInt(meta.subscriptions, 10),
|
var cols = tr.getElementsByTagName('td'),
|
||||||
cols = tr.getElementsByTagName('td'),
|
|
||||||
nameCol = cols[0],
|
nameCol = cols[0],
|
||||||
messagesCol = cols[1],
|
messagesCol = cols[1],
|
||||||
subscriptionsCol = cols[2];
|
subscriptionsCol = cols[2];
|
||||||
|
|
||||||
nameCol.setAttribute('class', 'name');
|
|
||||||
nameCol.innerHTML = queue;
|
|
||||||
messagesCol.innerHTML = meta.messages;
|
messagesCol.innerHTML = meta.messages;
|
||||||
subscriptionsCol.innerHTML = meta.subscriptions;
|
subscriptionsCol.innerHTML = meta.subscriptions;
|
||||||
|
|
||||||
if (nmsg > hotThreshold) {
|
if (meta.messages > hotThreshold) {
|
||||||
nameCol.setAttribute('class', 'name hot');
|
nameCol.setAttribute('class', 'name hot');
|
||||||
messagesCol.setAttribute('class', 'messages hot');
|
messagesCol.setAttribute('class', 'messages hot');
|
||||||
} else if (nmsg > fatThreshold) {
|
} else if (meta.messages > fatThreshold) {
|
||||||
nameCol.setAttribute('class', 'name fat');
|
nameCol.setAttribute('class', 'name fat');
|
||||||
messagesCol.setAttribute('class', 'messages fat');
|
messagesCol.setAttribute('class', 'messages fat');
|
||||||
} else if (nmsg === 0) {
|
} else if (meta.messages === 0) {
|
||||||
messagesCol.setAttribute('class', 'messages zero');
|
messagesCol.setAttribute('class', 'messages zero');
|
||||||
} else {
|
} else {
|
||||||
|
nameCol.setAttribute('class', 'name');
|
||||||
messagesCol.setAttribute('class', 'messages');
|
messagesCol.setAttribute('class', 'messages');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nsub === 0) {
|
if (meta.subscriptions === 0) {
|
||||||
subscriptionsCol.setAttribute('class', 'subscriptions zero');
|
subscriptionsCol.setAttribute('class', 'subscriptions zero');
|
||||||
} else {
|
} else {
|
||||||
subscriptionsCol.setAttribute('class', 'subscriptions');
|
subscriptionsCol.setAttribute('class', 'subscriptions');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user