Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

0.0.10 top-color red on lost connection, loggin of changes only

  • Loading branch information...
commit dc728ea7f3b3d4fe3a1b5f160cf40a54263efb9f 1 parent 5684707
@haraldrudell authored
View
11 lib/appentity.js
@@ -40,6 +40,7 @@ function AppEntity(conf) {
PORT: 0,
URL: '',
}
+ var lastState = {}
// init file watchers
var myWatch = new watchit.WatchIt(doWatcherRestart, watchNotify)
@@ -205,7 +206,15 @@ function AppEntity(conf) {
}
function sendUpdate() {
- if (listener) listener(getState())
+ var state = logDifference(getState())
+ if (listener) listener(state)
+ }
+
+ function logDifference(state) {
+ var s = ['Update', state.name + ':']
+ for (var p in state) if (state[p] != lastState[p]) s.push(p + ':', state[p])
+ console.log(s.join(' '))
+ return lastState = state
}
}
View
2  lib/godsocket.js
@@ -67,7 +67,7 @@ function init(app, clientToControl) {
return send
function send(update) {
- console.log('update:', JSON.stringify(update))
+//console.log('update:', JSON.stringify(update))
socketManager.sockets.emit('fromgod', update)
}
}
View
2  package.json
@@ -8,7 +8,7 @@
"node",
"operations"
],
- "version": "0.0.9",
+ "version": "0.0.10",
"contributors": [
{
"name": "Harald Rudell",
View
24 public/javascripts/frontgod.js
@@ -71,6 +71,7 @@ if (typeof $ == 'undefined') alert ('jQuery is missing')
}
var crashMap = {}
+ var haveACrash = false
function updateCreateApp(app) {
var div = $('#app' + app.id)
@@ -108,7 +109,7 @@ if (typeof $ == 'undefined') alert ('jQuery is missing')
var newCrashMap = {}
// key: id, value: container div for app
var elMap = {}
- // overall state
+ // overall state: true means crashed
newCrashMap.all = false
elMap.all = $('.header')
var stateList = $('.state')
@@ -121,19 +122,35 @@ if (typeof $ == 'undefined') alert ('jQuery is missing')
if (isCrashed) newCrashMap.all = true
elMap[id] = container
})
+ haveACrash = newCrashMap.all
+
+ // merge in connection state
+ if (!isConnected()) newCrashMap.all = true
// update all changed apps
- var bad = 'background-color:#ffb3b3'
for (var id in newCrashMap) {
var isCrash = newCrashMap[id]
if (isCrash != crashMap[id]) {
- elMap[id].attr('style', isCrash ? bad : '')
+ setElementColor(elMap[id], isCrash)
}
}
crashMap = newCrashMap
}
+ function updateTopColor() {
+ var bad = haveACrash || !isConnected()
+ if (bad != crashMap.all) setElementColor($('.header'), crashMap.all = bad)
+ }
+
+ function isConnected() {
+ return getState() == 2
+ }
+
+ function setElementColor(el, isBad) {
+ el.attr('style', isBad ? 'background-color:#ffb3b3' : '')
+ }
+
var timezoneMinutesOffUtc = -new Date().getTimezoneOffset()
function dateString(value) {
var result = '?'
@@ -228,6 +245,7 @@ if (typeof $ == 'undefined') alert ('jQuery is missing')
reconnectEnable(newState != 2)
//$('.connected').text()
$('#status').text(texts[newState] + ' at ' + dateString(Date.now()))
+ updateTopColor()
}
}
function reconnectEnable(flag) {
Please sign in to comment.
Something went wrong with that request. Please try again.