Bug fixes

This commit is contained in:
Vincent Fiduccia 2015-06-29 12:51:44 -07:00
parent d4ab881161
commit 222a26b05f
4 changed files with 66 additions and 74 deletions

View File

@ -113,7 +113,7 @@ export default Ember.Route.extend({
}
else
{
this.replaceWith('index');
this.replaceWith('authenticated');
}
}).catch((err) => {
this.controllerFor('application').setProperties({

View File

@ -189,78 +189,70 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
return this.get('store').find('project', null, opt);
},
activate: function() {
this._super();
var store = this.get('store');
var boundTypeify = store._typeify.bind(store,0);
var url = "ws://"+window.location.host + this.get('app.wsEndpoint');
var session = this.get('session');
var projectId = session.get(C.SESSION.PROJECT);
if ( projectId )
{
url = Util.addQueryParam(url, 'projectId', projectId);
}
var socket = Socket.create({
url: url
});
socket.on('message', (event) => {
var d = boundTypeify(JSON.parse(event.data));
//this._trySend('subscribeMessage',d);
var action;
if ( d.name === 'resource.change' )
{
action = d.resourceType+'Changed';
}
else if ( d.name === 'ping' )
{
action = 'subscribePing';
}
if ( action )
{
this._trySend(action,d);
}
});
socket.on('connected', (tries, after) => {
this._trySend('subscribeConnected', tries, after);
});
socket.on('disconnected', () => {
this._trySend('subscribeDisconnected', this.get('tries'));
});
this.set('socket', socket);
socket.connect();
},
deactivate: function() {
this._super();
var socket = this.get('socket');
if ( socket )
{
socket.disconnect();
}
// Forget all the things
this.get('store').reset();
},
actions: {
activate: function() {
var store = this.get('store');
var boundTypeify = store._typeify.bind(store);
var url = "ws://"+window.location.host + this.get('app.wsEndpoint');
var session = this.get('session');
var projectId = session.get(C.SESSION.PROJECT);
if ( projectId )
{
url = Util.addQueryParam(url, 'projectId', projectId);
}
var socket = Socket.create({
url: url
});
socket.on('message', (event) => {
var d = JSON.parse(event.data, boundTypeify);
//this._trySend('subscribeMessage',d);
var str = d.name;
if ( d.resourceType )
{
str += ' ' + d.resourceType;
if ( d.resourceId )
{
str += ' ' + d.resourceId;
}
}
var action;
if ( d.name === 'resource.change' )
{
action = d.resourceType+'Changed';
}
else if ( d.name === 'ping' )
{
action = 'subscribePing';
}
if ( action )
{
this._trySend(action,d);
}
});
socket.on('connected', (tries, after) => {
this._trySend('subscribeConnected', tries, after);
});
socket.on('disconnected', () => {
this._trySend('subscribeDisconnected', this.get('tries'));
});
this.set('socket', socket);
socket.connect();
},
deactivate: function() {
var socket = this.get('socket');
if ( socket )
{
socket.disconnect();
}
// Forget all the things
this.get('store').reset();
},
error: function(err,transition) {
// Unauthorized error, send back to login screen
if ( err.status === 401 )

View File

@ -5,7 +5,7 @@ export default Ember.Route.extend({
this._super.apply(this,arguments);
if ( !this.get('app.authenticationEnabled') )
{
this.transitionTo('index');
this.transitionTo('authenticated');
}
},
});

View File

@ -22,7 +22,7 @@
"devDependencies": {
"broccoli-asset-rev": "^2.0.2",
"broccoli-sass": "0.6.2",
"ember-api-store": "^1.1.4",
"ember-api-store": "^1.1.5",
"ember-browserify": "^0.6.4",
"ember-cli": "0.2.7",
"ember-cli-app-version": "0.3.3",