Ember 1.12 updates

This commit is contained in:
Vincent Fiduccia 2015-06-25 10:29:54 -07:00
parent 3efe73cd1a
commit e57d8ecebb
45 changed files with 266 additions and 296 deletions

View File

@ -18,6 +18,7 @@ indent_style = space
indent_size = 2
[*.hbs]
insert_final_newline = false
indent_style = space
indent_size = 2

3
.watchmanconfig Normal file
View File

@ -0,0 +1,3 @@
{
"ignore_dirs": ["tmp"]
}

View File

@ -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');

View File

@ -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'),

View File

@ -25,12 +25,12 @@
<div class="form-group">
<label for="name">Name</label>
{{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"}}
</div>
<div class="form-group">
<label for="description">Description</label>
{{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"}}
</div>
{{partial "save-cancel"}}

View File

@ -1,4 +1,4 @@
{{#with controllers.authenticated.project as p controller="project"}}
{{#with controllers.authenticated.project controller="project" as |p|}}
<section class="header">
<h3>
<span class="right-divider">API &amp; Keys for &quot;{{p.displayName}}&quot; Environment</span>

View File

@ -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

View File

@ -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*/) {

View File

@ -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
{

View File

@ -6,7 +6,7 @@
{{model.ipAddress}}
{{else}}
{{#if model.instance}}
{{#with model.instance as container controller="container"}}
{{#with model.instance controller="container" as |container|}}
<i {{bind-attr class="container.stateIcon container.stateColor" tooltip=container.displayState}}></i>
{{#link-to "container" model.instanceId}}
{{container.displayName}}

View File

@ -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: {

View File

@ -81,7 +81,7 @@
<div class="btn-group project-btn">
<button type="button" class="btn btn-link dropdown-toggle text-left clip" data-toggle="dropdown" aria-expanded="false">
{{#if project}}
{{#with project as p controller="project"}}
{{#with project controller="project" as |p|}}
<i {{bind-attr class=":fa-fw p.icon"}}></i>&nbsp;{{p.displayName}}
{{/with}}
<span class="caret"></span>
@ -113,7 +113,7 @@
{{/if}}
{{#if projectIsMissing}}
<li role="presentation" class="dropdown-header text-uppercase">Selected Environment:</li>
{{#with project as p controller="project"}}
{{#with project controller="project" as |p|}}
<li {{bind-attr class="p.active:disabled p.active:selected"}}>
<a {{action "switchProject" p.id}} class="clip">
<i {{bind-attr class=":fa-fw p.icon"}}></i>

View File

@ -17,7 +17,7 @@
<div class="pod-info clearfix">
<div class="pod-info-line">
{{#each map in model.consumedServicesWithNames}}
{{#with map.service as service controller="service"}}
{{#with map.service controller="service" as |service|}}
<div class="pod-info-item">
{{#link-to "service" service.environmentId service.id}}
<i {{bind-attr class="service.activeIcon"}}></i>

View File

@ -1,7 +1,7 @@
import Ember from 'ember';
import EditContainer from 'ui/mixins/edit-container';
export default Ember.ObjectController.extend(EditContainer, {
export default Ember.Controller.extend(EditContainer, {
editing: true,
didSave: function() {

View File

@ -27,9 +27,15 @@ export default OverlayRoute.extend({
setupController: function(controller, model) {
var instance = model.get('instance');
controller.set('originalModel', instance);
model.set('instance', instance.clone());
controller.set('model', model);
controller.setProperties({
originalModel: instance,
model: model,
instance: model.instance,
ports: model.ports,
instanceLinks: model.instanceLinks,
allHosts: model.allHosts
});
controller.initFields();
},

View File

@ -1,4 +1,4 @@
{{#with instance as container controller="container"}}
{{#with instance controller="container" as |container|}}
<h2>
<i class="ss-file"></i> Logs: {{container.displayName}}
</h2>

View File

@ -1,4 +1,4 @@
{{#with instance as container controller="container"}}
{{#with instance controller="container" as |container|}}
<h1><i class="fa fa-terminal"></i> Shell: {{container.displayName}}</h1>
{{/with}}
<div class="console-body clearfix">

View File

@ -6,7 +6,7 @@
</div>
<span>
{{#if primaryHost}}
{{#with primaryHost as host controller="host"}}
{{#with primaryHost controller="host" as |host|}}
{{#link-to "hosts"}}Hosts:{{/link-to}}
{{#link-to "host" host.id}}{{host.displayName}}:{{/link-to}}
{{displayName}}
@ -35,7 +35,7 @@
<li>
<label>Host IP</label>
{{#if primaryHost}}
{{#with primaryHost as host controller="host"}}
{{#with primaryHost controller="host" as |host|}}
{{host.displayIp}} {{zero-clipboard text=host.displayIp}}
{{/with}}
{{else}}

View File

@ -1,7 +1,7 @@
import Ember from 'ember';
import EditContainer from 'ui/mixins/edit-container';
export default Ember.ObjectController.extend(EditContainer, {
export default Ember.Controller.extend(EditContainer, {
queryParams: ['environmentId','containerId'],
environmentId: null,
containerId: null,

View File

@ -77,8 +77,13 @@ export default Ember.Route.extend({
},
setupController: function(controller, model) {
controller.set('originalModel', null);
controller.set('model', model);
controller.setProperties({
originalModel: null,
model: model,
instance: model.instance,
healthCheck: model.healthCheck,
allHosts: model.allHosts,
});
controller.initFields();
},

View File

@ -1,4 +1,4 @@
{{#with environment as env controller="environment"}}
{{#with environment controller="environment" as |env|}}
{{environment-header model=env}}
{{/with}}

View File

@ -1,3 +1,3 @@
{{#with model as env controller="environment"}}
{{#with model controller="environment" as |env|}}
{{environment-header model=env}}
{{/with}}

View File

@ -1,8 +1,8 @@
{{#with model as env controller="environment"}}
{{#with model controller="environment" as |env|}}
{{environment-header model=env}}
{{#columns-section pods=view.pods emptyMessage="No services yet." as |item| }}
{{#with item as service controller="service"}}
{{#with item controller="service" as |service|}}
{{service-pod model=service}}
{{/with}}
{{/columns-section}}

View File

@ -9,7 +9,7 @@
{{#each item in this}}
{{project-section model=item collapseId=(dom-id item)}}
{{#columns-section pods=item.unremovedServices id=(dom-id item) classNames="collapse in" emptyMessage="No services yet." as |item| }}
{{#with item as service controller="service"}}
{{#with item controller="service" as |service|}}
{{service-pod model=service}}
{{/with}}
{{/columns-section}}

View File

@ -7,11 +7,11 @@
{{#columns-section pods=view.pods emptyMessage="No hosts or containers yet." as |item| }}
{{#if item.isPendingMachine}}
{{#with item.machine as machine controller="machine"}}
{{#with item.machine controller="machine" as |machine|}}
{{host-pod model=machine dot=dot}}
{{/with}}
{{else}}
{{#with item as host controller="host"}}
{{#with item controller="host" as |host|}}
{{host-pod model=host dot=dot}}
{{/with}}
{{/if}}

View File

@ -274,12 +274,21 @@ export default Ember.ObjectController.extend(NewHost, {
},
},
selectedZone: function(key, val/*, oldVal*/) {
selectedZone: Ember.computed('amazonec2Config.{region,zone}', {
get: function() {
var config = this.get('amazonec2Config');
if ( arguments.length > 1 )
if ( config.get('region') && config.get('zone') )
{
if ( val && val.length )
return config.get('region') + config.get('zone');
}
else
{
return null;
}
},
set: function(key, val) {
var config = this.get('amazonec2Config');
config.setProperties({
region: val.substr(0, val.length - 1),
zone: val.substr(val.length - 1),
@ -295,8 +304,6 @@ export default Ember.ObjectController.extend(NewHost, {
subnetId: null,
});
}
}
}
if ( config.get('region') && config.get('zone') )
{
@ -306,7 +313,8 @@ export default Ember.ObjectController.extend(NewHost, {
{
return null;
}
}.property('amazonec2Config.{region,zone}'),
}
}),
zoneChoices: function() {
return (this.get('allSubnets')||[]).map((subnet) => {return subnet.get('zone');}).sort().uniq();
@ -342,7 +350,8 @@ export default Ember.ObjectController.extend(NewHost, {
return out.sortBy('sortKey');
}.property('selectedZone','allSubnets.@each.{subnetId,vpcId,zone}'),
selectedSubnet: function(key, val/*, oldVal*/) {
selectedSubnet: Ember.computed('amazonec2Config.{subnetId,vpcId}', {
set: function(key, val) {
var config = this.get('amazonec2Config');
if ( arguments.length > 1 )
{
@ -374,7 +383,13 @@ export default Ember.ObjectController.extend(NewHost, {
}
return config.get('subnetId') || config.get('vpcId');
}.property('amazonec2Config.{subnetId,vpcId}'),
},
get: function() {
var config = this.get('amazonec2Config');
return config.get('subnetId') || config.get('vpcId');
},
}),
subnetById: function(id) {
return (this.get('allSubnets')||[]).filterProperty('subnetId',id)[0];

View File

@ -1,6 +1,9 @@
import Ember from 'ember';
import DriverRoute from 'ui/hosts/new/driver-route';
export default DriverRoute.extend({
prefs: Ember.inject.service(),
driverName: 'amazonec2',
newModel: function() {
var store = this.get('store');

View File

@ -1,47 +0,0 @@
import Ember from 'ember';
import C from 'ui/utils/constants';
export function initialize(container, application) {
application.deferReadiness();
var store = container.lookup('store:main');
var github = container.lookup('service:github');
var headers = {};
headers[C.HEADER.PROJECT] = undefined; // Explicitly not send project
// Find out if auth is enabled
store.rawRequest({
url: 'token',
headers: headers
})
.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];
application.set('authenticationEnabled', token.security);
application.set('githubClientId', token.clientId);
application.set('githubHostname', token.hostname );
if ( !token.security )
{
github.clearSessionKeys();
}
return Ember.RSVP.resolve(undefined,'API supports authentication');
})
.catch((obj) => {
// Otherwise this API is too old to do auth.
application.set('authenticationEnabled', false);
application.set('initError', obj);
return Ember.RSVP.resolve(undefined,'Error determining API authentication');
})
.finally(function() {
application.advanceReadiness();
});
}
export default {
name: 'authentication',
after: ['store','config'],
initialize: initialize
};

View File

@ -1,14 +1,14 @@
export function initialize(container/*, application*/) {
export function initialize(/*container, application*/) {
// Shortcuts for debugging. These should never be used in code.
window.l = function(name) {
return container.lookup(name);
return Ui.__container__.lookup(name);
};
window.lc = function(name) {
return container.lookup('controller:'+name);
return Ui.__container__.lookup('controller:'+name);
};
window.s = container.lookup('store:main');
window.s = Ui.__container__.lookup('store:main');
}
export default {

View File

@ -1,28 +0,0 @@
import UserPreferences from 'ui/utils/user-preferences';
import Serializable from 'ember-api-store/mixins/serializable';
// Don't serialize the injected prefs
Serializable.reopen({
reservedKeys: ['prefs'],
});
export function initialize(container, application) {
var prefs = UserPreferences.create({
// Store isn't automatically injected in
store: container.lookup('store:main'),
app: application,
});
// Inject GitHub lookup as 'github' property
container.register('prefs:main', prefs, {instantiate: false});
application.inject('controller', 'prefs', 'prefs:main');
application.inject('route', 'prefs', 'prefs:main');
application.inject('model', 'prefs', 'prefs:main');
application.inject('component', 'prefs', 'prefs:main');
}
export default {
name: 'prefs',
after: 'store',
initialize: initialize
};

View File

@ -5,7 +5,7 @@ Serializable.reopen({
reservedKeys: ['session'],
});
export function initialize(container, application) {
export function initialize(registry, application) {
application.inject('controller', 'session', 'service:session');
application.inject('route', 'session', 'service:session');
application.inject('model', 'session', 'service:session');
@ -14,6 +14,5 @@ export function initialize(container, application) {
export default {
name: 'session',
before: 'store',
initialize: initialize
};

View File

@ -5,7 +5,9 @@ import UnremovedArrayProxy from 'ui/utils/unremoved-array-proxy';
import ActiveArrayProxy from 'ui/utils/active-array-proxy';
import C from 'ui/utils/constants';
export function initialize(container, application) {
export function initialize(instance) {
var container = instance.container;
var application = container.lookup('application:main');
var store = container.lookup('store:main');
var session = container.lookup('service:session');
store.set('removeAfterDelete', false);

View File

@ -35,7 +35,7 @@
</td>
<td>
{{#if target.instance}}
{{#with target.instance as c controller="container"}}
{{#with target.instance controller="container" as |c|}}
{{#link-to "container" c.id}}{{c.displayName}}{{/link-to}}
{{/with}}
{{else}}

View File

@ -6,7 +6,7 @@
</section>
{{#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}}

View File

@ -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'));

View File

@ -1,13 +1,15 @@
import Ember from 'ember';
export default Ember.Route.extend({
enter: function() {
actions: {
activate: function() {
$('BODY').addClass('farm');
},
exit: function() {
deactivate: function() {
$('BODY').removeClass('farm');
},
},
model: function() {
return this.controllerFor('application').get('error');

View File

@ -1,7 +1,9 @@
import Ember from 'ember';
export default Ember.Route.extend({
enter: function() {
actions: {
activate: function() {
this.transitionTo('authenticated');
},
}
});

View File

@ -1,4 +1,4 @@
{{#with environment as env controller="environment"}}
{{#with environment controller="environment" as |env|}}
<section class="header">
<h3>
{{resource-actions-menu model=this choices=availableActions classNames="pull-right"}}

View File

@ -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();
},
});

View File

@ -1,9 +0,0 @@
{{#if isTransitioning}}
<div class="page-progress">
<div class="progress progress-striped active">
<div class="progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" {{bind-attr aria-valuenow=displayProgress style=progressStyle}}>
<span class="sr-only">{{displayProgress}}% Complete</span>
</div>
</div>
</div>
{{/if}}

View File

@ -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

View File

@ -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",

View File

@ -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",

View File

@ -1,6 +1,7 @@
{
"framework": "qunit",
"test_page": "tests/index.html?hidepassed",
"disable_watching": true,
"launch_in_ci": [
"PhantomJS"
],