diff --git a/.editorconfig b/.editorconfig index 2fe4874a0..47c543840 100644 --- a/.editorconfig +++ b/.editorconfig @@ -18,6 +18,7 @@ indent_style = space indent_size = 2 [*.hbs] +insert_final_newline = false indent_style = space indent_size = 2 diff --git a/.watchmanconfig b/.watchmanconfig new file mode 100644 index 000000000..5e9462c20 --- /dev/null +++ b/.watchmanconfig @@ -0,0 +1,3 @@ +{ + "ignore_dirs": ["tmp"] +} diff --git a/Brocfile.js b/Brocfile.js index 30ce65ad9..ffedc38d3 100644 --- a/Brocfile.js +++ b/Brocfile.js @@ -47,7 +47,7 @@ app.import('bower_components/bootstrap-sass-official/assets/javascripts/bootstra app.import('bower_components/jgrowl/jquery.jgrowl.js'); app.import('bower_components/jgrowl/jquery.jgrowl.css'); app.import('bower_components/jquery.cookie/jquery.cookie.js'); -app.import('bower_components/ember-animate/ember-animate.js'); +//app.import('bower_components/ember-animate/ember-animate.js'); app.import('bower_components/d3/d3.js'); app.import('bower_components/c3/c3.js'); app.import('bower_components/c3/c3.css'); diff --git a/app/apikey/edit/controller.js b/app/apikey/edit/controller.js index 081b06cd6..0afd90b46 100644 --- a/app/apikey/edit/controller.js +++ b/app/apikey/edit/controller.js @@ -1,7 +1,7 @@ import Ember from 'ember'; import Cattle from 'ui/utils/cattle'; -export default Ember.ObjectController.extend(Cattle.NewOrEditMixin, { +export default Ember.Controller.extend(Cattle.NewOrEditMixin, { queryParams: ['justCreated'], justCreated: false, cancelAsClose: Ember.computed.alias('justCreated'), diff --git a/app/apikey/edit/template.hbs b/app/apikey/edit/template.hbs index 1bd2677b2..e6112ac20 100644 --- a/app/apikey/edit/template.hbs +++ b/app/apikey/edit/template.hbs @@ -25,12 +25,12 @@
- {{input id="name" type="text" value=name classNames="form-control" placeholder="e.g. App Servers"}} + {{input id="name" type="text" value=primaryResource.name classNames="form-control" placeholder="e.g. App Servers"}}
- {{textarea id="description" value=description classNames="form-control no-resize" rows="5" placeholder="e.g. This key is used by the app servers to deploy containers"}} + {{textarea id="description" value=primaryResource.description classNames="form-control no-resize" rows="5" placeholder="e.g. This key is used by the app servers to deploy containers"}}
{{partial "save-cancel"}} diff --git a/app/apikeys/template.hbs b/app/apikeys/template.hbs index 518268bec..3fe089028 100644 --- a/app/apikeys/template.hbs +++ b/app/apikeys/template.hbs @@ -1,4 +1,4 @@ -{{#with controllers.authenticated.project as p controller="project"}} +{{#with controllers.authenticated.project controller="project" as |p|}}

API & Keys for "{{p.displayName}}" Environment diff --git a/app/app.js b/app/app.js index 757df3899..8d66b9587 100644 --- a/app/app.js +++ b/app/app.js @@ -3,9 +3,11 @@ import Resolver from 'ember/resolver'; import loadInitializers from 'ember/load-initializers'; import config from './config/environment'; +var App; + Ember.MODEL_FACTORY_INJECTIONS = true; -var App = Ember.Application.extend({ +App = Ember.Application.extend({ modulePrefix: config.modulePrefix, podModulePrefix: config.podModulePrefix, Resolver: Resolver diff --git a/app/application/route.js b/app/application/route.js index a763c535b..c69414640 100644 --- a/app/application/route.js +++ b/app/application/route.js @@ -150,7 +150,38 @@ export default Ember.Route.extend({ if ( agent.indexOf('msie ') >= 0 || agent.indexOf('trident/') >= 0 || agent.indexOf('edge/') >= 0 ) { this.replaceWith('ie'); + return; } + + // Find out if auth is enabled + return this.get('store').rawRequest({ + url: 'token', + headers: { + [C.HEADER.PROJECT]: undefined + } + }) + .then((obj) => { + // If we get a good response back, the API supports authentication + var body = JSON.parse(obj.xhr.responseText); + var token = body.data[0]; + + this.set('app.authenticationEnabled', token.security); + this.set('app.githubClientId', token.clientId); + this.set('app.githubHostname', token.hostname ); + + if ( !token.security ) + { + this.get('github').clearSessionKeys(); + } + + return Ember.RSVP.resolve(undefined,'API supports authentication'); + }) + .catch((obj) => { + // Otherwise this API is too old to do auth. + this.set('app.authenticationEnabled', false); + this.set('app.initError', obj); + return Ember.RSVP.resolve(undefined,'Error determining API authentication'); + }); }, setupController: function(controller/*, model*/) { diff --git a/app/authenticated/route.js b/app/authenticated/route.js index edb865b55..f419cfec8 100644 --- a/app/authenticated/route.js +++ b/app/authenticated/route.js @@ -6,6 +6,8 @@ import ActiveArrayProxy from 'ui/utils/active-array-proxy'; import C from 'ui/utils/constants'; export default Ember.Route.extend(AuthenticatedRouteMixin, { + prefs: Ember.inject.service(), + socket: null, pingTimer: null, @@ -188,6 +190,77 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, { }, 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 ) @@ -355,77 +428,6 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, { }, }, - enter: 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(); - }, - - exit: function() { - var socket = this.get('socket'); - if ( socket ) - { - socket.disconnect(); - } - - // Forget all the things - this.get('store').reset(); - }, - _trySend: function(/*arguments*/) { try { diff --git a/app/components/loadbalancertarget-subpod/template.hbs b/app/components/loadbalancertarget-subpod/template.hbs index 7abd9221c..1b56412e9 100644 --- a/app/components/loadbalancertarget-subpod/template.hbs +++ b/app/components/loadbalancertarget-subpod/template.hbs @@ -6,7 +6,7 @@ {{model.ipAddress}} {{else}} {{#if model.instance}} - {{#with model.instance as container controller="container"}} + {{#with model.instance controller="container" as |container|}} {{#link-to "container" model.instanceId}} {{container.displayName}} diff --git a/app/components/page-articles/component.js b/app/components/page-articles/component.js index b95fdb282..3f8183e19 100644 --- a/app/components/page-articles/component.js +++ b/app/components/page-articles/component.js @@ -2,6 +2,7 @@ import Ember from 'ember'; import C from 'ui/utils/constants'; export default Ember.Component.extend({ + prefs: Ember.inject.service(), classNames: ['articles'], actions: { diff --git a/app/components/page-header/template.hbs b/app/components/page-header/template.hbs index 328fcee56..590e12a43 100644 --- a/app/components/page-header/template.hbs +++ b/app/components/page-header/template.hbs @@ -81,7 +81,7 @@

{{#columns-section pods=view.pods emptyMessage="No load balancers." as |item| }} - {{#with item as balancer controller="loadbalancer"}} + {{#with item controller="loadbalancer" as |balancer|}} {{loadbalancer-pod model=balancer}} {{/with}} {{/columns-section}} diff --git a/app/project/controller.js b/app/project/controller.js index 1484f4549..66a3804db 100644 --- a/app/project/controller.js +++ b/app/project/controller.js @@ -3,6 +3,8 @@ import Cattle from 'ui/utils/cattle'; import C from 'ui/utils/constants'; var ProjectController = Cattle.TransitioningResourceController.extend({ + prefs: Ember.inject.service(), + actions: { edit: function() { this.transitionToRoute('project.edit',this.get('id')); diff --git a/app/routes/fail-whale.js b/app/routes/fail-whale.js index 614fe39e4..689aa6718 100644 --- a/app/routes/fail-whale.js +++ b/app/routes/fail-whale.js @@ -1,12 +1,14 @@ import Ember from 'ember'; export default Ember.Route.extend({ - enter: function() { - $('BODY').addClass('farm'); - }, + actions: { + activate: function() { + $('BODY').addClass('farm'); + }, - exit: function() { - $('BODY').removeClass('farm'); + deactivate: function() { + $('BODY').removeClass('farm'); + }, }, model: function() { diff --git a/app/routes/index.js b/app/routes/index.js index b717abe14..b98162845 100644 --- a/app/routes/index.js +++ b/app/routes/index.js @@ -1,7 +1,9 @@ import Ember from 'ember'; export default Ember.Route.extend({ - enter: function() { - this.transitionTo('authenticated'); - }, + actions: { + activate: function() { + this.transitionTo('authenticated'); + }, + } }); diff --git a/app/service/template.hbs b/app/service/template.hbs index 2d4bacee4..e099ff4aa 100644 --- a/app/service/template.hbs +++ b/app/service/template.hbs @@ -1,4 +1,4 @@ -{{#with environment as env controller="environment"}} +{{#with environment controller="environment" as |env|}}

{{resource-actions-menu model=this choices=availableActions classNames="pull-right"}} diff --git a/app/utils/user-preferences.js b/app/services/prefs.js similarity index 91% rename from app/utils/user-preferences.js rename to app/services/prefs.js index 0882e1446..0688d3458 100644 --- a/app/utils/user-preferences.js +++ b/app/services/prefs.js @@ -1,14 +1,7 @@ -import Ember from "ember"; +import Ember from 'ember'; import UnremovedArrayProxy from 'ui/utils/unremoved-array-proxy'; -export default Ember.Object.extend({ - app: null, - store: null, - - init: function() { - this._super(); - }, - +export default Ember.Service.extend({ unremoved: function() { return UnremovedArrayProxy.create({ sourceContent: this.get('store').all('userpreference') @@ -80,4 +73,3 @@ export default Ember.Object.extend({ this.endPropertyChanges(); }, }); - diff --git a/app/templates/transitioning-progress.hbs b/app/templates/transitioning-progress.hbs deleted file mode 100644 index 07286efe8..000000000 --- a/app/templates/transitioning-progress.hbs +++ /dev/null @@ -1,9 +0,0 @@ -{{#if isTransitioning}} -
-
-
- {{displayProgress}}% Complete -
-
-
-{{/if}} diff --git a/app/utils/cattle.js b/app/utils/cattle.js index 08e88e673..597cf6ad9 100644 --- a/app/utils/cattle.js +++ b/app/utils/cattle.js @@ -488,21 +488,6 @@ var TransitioningResourceController = ResourceController.extend({ stateBackground: function() { return this.get('stateColor').replace("text-","bg-"); }.property('stateColor'), - - displayProgress: function() { - var progress = this.get('transitioningProgress'); - if ( progress === null || isNaN(progress) ) - { - progress = 0; - } - - return Math.max(0,Math.min(progress, 100)); - }.property('transitioningProgress'), - - progressStyle: function() { - return 'width: '+ Math.max(2, this.get('displayProgress')) +'%'; - }.property('displayProgress'), - }); // Override stateMap with a map of state -> icon classes diff --git a/bower.json b/bower.json index c0dd6b0be..a33455374 100644 --- a/bower.json +++ b/bower.json @@ -1,15 +1,15 @@ { "name": "ui", "dependencies": { - "ember": "1.10.0", - "jquery": "^2.1.3", + "ember": "1.12.0", + "jquery": "^2.1.4", "ember-data": "1.0.0-beta.15", - "ember-resolver": "~0.1.12", - "loader.js": "ember-cli/loader.js#3.2.1", + "ember-resolver": "~0.1.15", + "loader.js": "ember-cli/loader.js#3.2.0", "ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3", - "ember-cli-test-loader": "ember-cli/ember-cli-test-loader#0.1.3", - "ember-load-initializers": "ember-cli/ember-load-initializers#0.0.2", - "ember-qunit": "0.2.11", + "ember-cli-test-loader": "ember-cli-test-loader#0.1.3", + "ember-load-initializers": "ember-cli/ember-load-initializers#0.1.4", + "ember-qunit": "0.3.3", "ember-qunit-notifications": "0.0.7", "qunit": "~1.17.1", "ember-animate": "~0.3.6", diff --git a/package.json b/package.json index f723e2a4f..c139766aa 100644 --- a/package.json +++ b/package.json @@ -20,22 +20,22 @@ "author": "Rancher Labs", "license": "Apache 2", "devDependencies": { - "broccoli-asset-rev": "^2.0.0", + "broccoli-asset-rev": "^2.0.2", "broccoli-sass": "0.6.2", "ember-api-store": "^1.1.4", "ember-browserify": "^0.6.4", - "ember-cli": "0.2.0", + "ember-cli": "0.2.7", "ember-cli-app-version": "0.3.3", "ember-cli-auto-register-helpers": "0.0.3", - "ember-cli-babel": "^4.0.0", + "ember-cli-babel": "^5.0.0", "ember-cli-content-security-policy": "0.4.0", - "ember-cli-dependency-checker": "0.0.8", + "ember-cli-dependency-checker": "^1.0.0", "ember-cli-font-awesome": "0.0.9", - "ember-cli-htmlbars": "^0.7.0", + "ember-cli-htmlbars": "^0.7.6", "ember-cli-inject-live-reload": "^1.3.0", "ember-cli-moment": "0.0.1", - "ember-cli-qunit": "0.3.9", - "ember-cli-uglify": "1.0.1", + "ember-cli-qunit": "0.3.13", + "ember-cli-uglify": "^1.0.1", "ember-export-application-global": "^1.0.2", "ember-inline-svg": "^0.1.2", "ember-truth-helpers": "0.0.5", diff --git a/public/crossdomain.xml b/public/crossdomain.xml index 29a035d7f..0c16a7a07 100644 --- a/public/crossdomain.xml +++ b/public/crossdomain.xml @@ -1,15 +1,15 @@ - + - - + + - - + + diff --git a/testem.json b/testem.json index 42a4ddb22..0f35392cf 100644 --- a/testem.json +++ b/testem.json @@ -1,6 +1,7 @@ { "framework": "qunit", "test_page": "tests/index.html?hidepassed", + "disable_watching": true, "launch_in_ci": [ "PhantomJS" ],