Skip to content
Browse files

add refreshing status and last refresh time

  • Loading branch information...
1 parent f8eaf60 commit 3d80e929c98e84e77d43ffa6ff74f93dc2313746 @davepacheco committed Apr 20, 2012
View
4 examples/webconsole/index.htm
@@ -15,7 +15,9 @@
<div class="kConsole">
<div class="kConsoleHeader">
<span class="kHeader">kang console</span>
- <a href="javascript:kFormRefreshAll()">refresh all</a><br />
+ <a href="javascript:kFormRefreshAll()">refresh all</a>
+ <span class="kLastUpdated">Last updated: <span id="kLastUpdateTime" class="kLastUpdateTime">never</span></span>
+ <br />
</div>
<div class="kHorizontalSeparator"></div>
View
20 examples/webconsole/resources/css/console.css
@@ -88,13 +88,21 @@ tr {
box-shadow: 3px 3px 4px #000;
}
-.kConsole > div {
- margin-bottom: 10px;
-}
+ .kConsoleHeader > * {
+ margin-right: 30px;
+ }
-.kDataContainer > div {
- margin-bottom: 10px;
-}
+ .kLastUpdated {
+ color: #666666;
+ }
+
+ .kConsole > div {
+ margin-bottom: 10px;
+ }
+
+ .kDataContainer > div {
+ margin-bottom: 10px;
+ }
/*
* Service summary table
View
9 examples/webconsole/resources/js/console.js
@@ -7,6 +7,7 @@ $(document).ready(kInit);
/*
* Important DOM elements
*/
+var kLastUpdateTime;
var kDataContainer;
var kServiceField;
var kServiceSummary;
@@ -18,10 +19,12 @@ var kDump;
*/
var kServiceUrls = []; /* list of URLs we're collecting data from */
var kServices = []; /* list of resolved services */
+var kUpdateTime;
var kSnapshot;
function kInit()
{
+ kLastUpdateTime = document.getElementById('kLastUpdateTime').firstChild;
kDataContainer = document.getElementById('kDataContainer');
kServiceField = document.getElementById('kAddServiceService');
kServiceTable = document.getElementById('kServiceTable');
@@ -221,7 +224,13 @@ function kRefresh()
return ('host=' + encodeURIComponent(url));
}).join('&');
+ kLastUpdateTime.nodeValue =
+ (kUpdateTime ? kUpdateTime : 'never') + ' (refreshing...)';
+
var rq = $.getJSON('proxy' + query, function (data) {
+ kUpdateTime = new Date();
+ kLastUpdateTime.nodeValue = kUpdateTime;
+
if (!data || !data['snapshot'] || !data['snapshot'].cs_objects)
return;

0 comments on commit 3d80e92

Please sign in to comment.
Something went wrong with that request. Please try again.