Disabling UI when offline.
This commit is contained in:
@@ -48,6 +48,10 @@ body {
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
.disconnected .app-body {
|
||||
opacity: 0.25;
|
||||
pointer-events: none;
|
||||
}
|
||||
.tab-pane {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
</style>
|
||||
</head>
|
||||
<body ng-controller="AppController">
|
||||
<div class="app-main">
|
||||
<div class="app-main" ng-class="{disconnected: !app.session.dataSource || !app.session.dataSource.online}">
|
||||
<div class="app-header" ng-include="'assets/ui/navbar.html'"></div>
|
||||
<div class="app-body tab-content" ui-view></div>
|
||||
<div class="app-console navbar-default" ng-include="'assets/ui/console/console.html'"></div>
|
||||
|
||||
@@ -17,3 +17,45 @@ function inherits(childCtor, parentCtor) {
|
||||
childCtor.prototype = new tempCtor();
|
||||
childCtor.prototype.constructor = childCtor;
|
||||
};
|
||||
|
||||
var EventEmitter = function() {
|
||||
this.events_ = {};
|
||||
};
|
||||
EventEmitter.prototype.dispose = function() {
|
||||
this.events_ = {};
|
||||
};
|
||||
EventEmitter.prototype.on = function(name, listener, opt_scope) {
|
||||
var listeners = this.events_[name];
|
||||
if (!listeners) {
|
||||
listeners = this.events_[name] = [];
|
||||
}
|
||||
listeners.push({
|
||||
callback: listener,
|
||||
scope: opt_scope || null
|
||||
});
|
||||
};
|
||||
EventEmitter.prototype.off = function(name, listener, opt_scope) {
|
||||
var listeners = this.events_[name];
|
||||
if (!listeners) {
|
||||
return;
|
||||
}
|
||||
for (var n = 0; n < listeners.length; n++) {
|
||||
if (listeners[n].callback == listener) {
|
||||
listeners.splice(n, 1);
|
||||
if (!listeners.length) {
|
||||
delete this.events_[name];
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
EventEmitter.prototype.emit = function(name, args) {
|
||||
var listeners = this.events_[name];
|
||||
if (!listeners) {
|
||||
return;
|
||||
}
|
||||
for (var n = 0; n < listeners.length; n++) {
|
||||
var listener = listeners[n];
|
||||
listener.callback.apply(listener.scope, args);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -56,11 +56,13 @@ module.service('Breakpoint', function() {
|
||||
|
||||
module.service('DataSource', function($q) {
|
||||
var DataSource = function(source, delegate) {
|
||||
EventEmitter.call(this);
|
||||
this.source = source;
|
||||
this.delegate = delegate;
|
||||
this.online = false;
|
||||
this.status = 'disconnected';
|
||||
};
|
||||
inherits(DataSource, EventEmitter);
|
||||
DataSource.prototype.open = function() {};
|
||||
DataSource.prototype.dispose = function() {};
|
||||
DataSource.prototype.issue = function(command) {};
|
||||
@@ -181,6 +183,7 @@ module.service('RemoteDataSource', function(
|
||||
|
||||
this.online = true;
|
||||
this.status = 'connected';
|
||||
this.emit('online');
|
||||
d.resolve();
|
||||
}).bind(this));
|
||||
}).bind(this);
|
||||
@@ -194,6 +197,7 @@ module.service('RemoteDataSource', function(
|
||||
} else {
|
||||
this.status = 'disconnected';
|
||||
log.info('Disconnected');
|
||||
this.emit('offline');
|
||||
}
|
||||
}).bind(this));
|
||||
}).bind(this);
|
||||
|
||||
@@ -146,6 +146,12 @@ module.service('Session', function(
|
||||
}
|
||||
|
||||
this.dataSource = dataSource;
|
||||
this.dataSource.on('online', function() {
|
||||
//
|
||||
}, this);
|
||||
this.dataSource.on('offline', function() {
|
||||
this.setDataSource(null);
|
||||
}, this);
|
||||
|
||||
var ps = [];
|
||||
|
||||
|
||||
@@ -508,7 +508,9 @@ json_t* WSClient::HandleMessage(const char* command, json_t* request,
|
||||
// Check debugger meta commands.
|
||||
if (xestrcmpa(target_name, "debug") == 0) {
|
||||
succeeded = true;
|
||||
if (xestrcmpa(sub_command, "make_ready") == 0) {
|
||||
if (xestrcmpa(sub_command, "ping") == 0) {
|
||||
return json_true();
|
||||
} else if (xestrcmpa(sub_command, "make_ready") == 0) {
|
||||
MakeReady();
|
||||
return json_true();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user