diff --git a/app/application/route.js b/app/application/route.js index c69414640..ee50abcfd 100644 --- a/app/application/route.js +++ b/app/application/route.js @@ -113,7 +113,7 @@ export default Ember.Route.extend({ } else { - this.replaceWith('index'); + this.replaceWith('authenticated'); } }).catch((err) => { this.controllerFor('application').setProperties({ diff --git a/app/authenticated/route.js b/app/authenticated/route.js index f419cfec8..218cf2181 100644 --- a/app/authenticated/route.js +++ b/app/authenticated/route.js @@ -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 ) diff --git a/app/login/route.js b/app/login/route.js index 4b3027d23..5a5fb07c8 100644 --- a/app/login/route.js +++ b/app/login/route.js @@ -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'); } }, }); diff --git a/package.json b/package.json index c139766aa..b87e88f56 100644 --- a/package.json +++ b/package.json @@ -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",