From 0b3c59d9fb5b83ace5e397350b9be9e301275e4c Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Tue, 21 Mar 2017 15:39:51 -0700 Subject: [PATCH 1/9] Add missing route back in --- app/router.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/router.js b/app/router.js index dc2ea505a..f18843bd9 100644 --- a/app/router.js +++ b/app/router.js @@ -125,6 +125,9 @@ Router.map(function() { this.route('add', {path: '/add/:cloud_id'}); }); + this.route('new', {path: '/add'}, function() { + this.route('index', {path: '/'}); + }); this.route('host', {path: '/:host_id', resetNamespace: true}, function() { this.route('containers'); From 20121b1662e3207d9e0b2e67b97ae730ef1b2e39 Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Tue, 21 Mar 2017 15:40:16 -0700 Subject: [PATCH 2/9] specifically call 2.9.1 of ember --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 23f14e5c5..916e7c2d2 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "dotenv": "^4.0.0", "ember-api-store": "2.2.0", "ember-browserify": "^1.0.1", - "ember-cli": "^2.9.1", + "ember-cli": "2.9.1", "ember-cli-app-version": "^2.0.0", "ember-cli-babel": "^5.1.7", "ember-cli-clipboard": "0.4.1", @@ -60,7 +60,7 @@ "forever-agent": "^0.6.1", "glob": "^5.0.3", "http-proxy": "^1.11.1", - "liquid-fire": "0.26.4", + "liquid-fire": "0.27.1", "loader.js": "^4.0.10", "postcss-scss": "^0.4.0", "semver": "^5.3.0", From 6354d70bc2bb43914f599263ad2468bc44204648 Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Wed, 22 Mar 2017 17:14:46 -0700 Subject: [PATCH 3/9] Initial creation of host selection on catalog page --- app/components/add-host/component.js | 45 +++++ app/components/add-host/template.hbs | 44 +++++ .../modal-catalog-host/component.js | 25 +++ .../modal-catalog-host/template.hbs | 5 + app/components/schema/input-host/component.js | 11 ++ app/components/schema/input-host/template.hbs | 4 + app/hosts/new/controller.js | 39 ----- app/hosts/new/route.js | 148 +--------------- app/hosts/new/template.hbs | 45 +---- app/ll/service.js | 4 + app/services/host.js | 162 ++++++++++++++++++ app/utils/constants.js | 1 + .../components/add-host/component-test.js | 25 +++ .../schema/input-host/component-test.js | 25 +++ tests/unit/ll/service-test.js | 12 ++ translations/en-us.yaml | 2 + 16 files changed, 374 insertions(+), 223 deletions(-) create mode 100644 app/components/add-host/component.js create mode 100644 app/components/add-host/template.hbs create mode 100644 app/components/modal-catalog-host/component.js create mode 100644 app/components/modal-catalog-host/template.hbs create mode 100644 app/components/schema/input-host/component.js create mode 100644 app/components/schema/input-host/template.hbs create mode 100644 app/ll/service.js create mode 100644 app/services/host.js create mode 100644 tests/integration/components/add-host/component-test.js create mode 100644 tests/integration/components/schema/input-host/component-test.js create mode 100644 tests/unit/ll/service-test.js diff --git a/app/components/add-host/component.js b/app/components/add-host/component.js new file mode 100644 index 000000000..893be9780 --- /dev/null +++ b/app/components/add-host/component.js @@ -0,0 +1,45 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ + access: Ember.inject.service(), + projects: Ember.inject.service(), + driver: null, + hostId: null, + + allowCustom: true, + allowOther: true, + forCatalog: true, + + actions: { + switchDriver(name) { + if (this.get('hostId')) { + this.set('hostId', null); + this.set('model.clonedModel', null); + } + this.set('driver', name); + }, + }, + + driverObj: function() { + return this.get('model.availableDrivers').filterBy('name', this.get('driver'))[0]; + }.property('driver'), + + hasOther: function() { + return this.get('model.availableDrivers').filterBy('hasUi',false).length > 0; + }.property('model.availableDrivers.@each.hasUi'), + + showPicker: function() { + return !this.get('projects.current.isWindows') && ( + this.get('model.availableDrivers.length') + + (this.get('allowOther') && this.get('hasOther') ? 1 : 0) + + (this.get('allowCustom') ? 1 : 0) + ) > 1; + }.property('model.availableDrivers.length','allowOther','hasOther','allowCustom'), + + showManage: function() { + return !this.get('projects.current.isWindows') && this.get('access.admin'); + }.property('access.admin','projects.current.isWindows'), + + sortedDrivers: Ember.computed.sort('model.availableDrivers','sortBy'), + sortBy: ['name'], +}); diff --git a/app/components/add-host/template.hbs b/app/components/add-host/template.hbs new file mode 100644 index 000000000..69022b350 --- /dev/null +++ b/app/components/add-host/template.hbs @@ -0,0 +1,44 @@ +{{#if model.apiHostSet}} +
+ {{#if showPicker}} + + {{/if}} + {{#if (and access.admin (not forCatalog))}} +

+ {{#link-to "admin-tab.machine"}}{{t 'hostsPage.new.manageLink'}}{{/link-to}} +

+ {{/if}} +
+ + {{#if driver}} + {{component (if (or (not driverObj) driverObj.hasUi) (concat "machine/driver-" driver) 'machine/driver-other') + cancel=(route-action 'cancel') + goBack=(route-action 'goBack') + clonedModel=model.clonedModel + driver=(concat driver 'Config') + schemas=model.schemas + typeDocumentations=model.typeDocumentations + availableDrivers=model.availableDrivers + }} + {{/if}} +{{else}} +
+
+ {{host-settings saved="savedHost"}} +
+
+{{/if}} diff --git a/app/components/modal-catalog-host/component.js b/app/components/modal-catalog-host/component.js new file mode 100644 index 000000000..9d21ca1e8 --- /dev/null +++ b/app/components/modal-catalog-host/component.js @@ -0,0 +1,25 @@ +import Ember from 'ember'; +import ModalBase from 'ui/mixins/modal-base'; + +export default Ember.Component.extend(ModalBase, { + hostService : Ember.inject.service('host'), + classNames: ['full-modal'], + loading: true, + model: null, + didRender() { + var hs = this.get('hostService'); + + hs.loadAllDrivers().then((drivers) => { + this.set('machineDrivers', drivers); + hs.getModel().then((hash) => { + if (hash.transition) { + debugger; + // we shouldnt get here + } else { + this.set('loading', false); + this.set('model', hash); + } + }); + }); + } +}); diff --git a/app/components/modal-catalog-host/template.hbs b/app/components/modal-catalog-host/template.hbs new file mode 100644 index 000000000..22340201c --- /dev/null +++ b/app/components/modal-catalog-host/template.hbs @@ -0,0 +1,5 @@ +{{#if loading}} + fetching data wathc the spinner +{{else}} + {{add-host model=model driver='custom'}} +{{/if}} \ No newline at end of file diff --git a/app/components/schema/input-host/component.js b/app/components/schema/input-host/component.js new file mode 100644 index 000000000..3545a8321 --- /dev/null +++ b/app/components/schema/input-host/component.js @@ -0,0 +1,11 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ + modalService: Ember.inject.service('modal'), + hostConfig: null, + actions: { + launchHost() { + this.get('modalService').toggleModal('modal-catalog-host'); + } + } +}); diff --git a/app/components/schema/input-host/template.hbs b/app/components/schema/input-host/template.hbs new file mode 100644 index 000000000..e84d95dab --- /dev/null +++ b/app/components/schema/input-host/template.hbs @@ -0,0 +1,4 @@ +{{#if hostConfig}} +{{else}} + +{{/if}} diff --git a/app/hosts/new/controller.js b/app/hosts/new/controller.js index ae6abeeec..990b7ceb5 100644 --- a/app/hosts/new/controller.js +++ b/app/hosts/new/controller.js @@ -1,47 +1,8 @@ import Ember from 'ember'; export default Ember.Controller.extend({ - access: Ember.inject.service(), - projects: Ember.inject.service(), - queryParams : ['backTo', 'driver', 'hostId'], backTo : null, driver : null, hostId : null, - - allowCustom : true, - allowOther : true, - - actions: { - switchDriver(name) { - if (this.get('hostId')) { - this.set('hostId', null); - this.set('model.clonedModel', null); - } - this.set('driver', name); - }, - }, - - driverObj: function() { - return this.get('model.availableDrivers').filterBy('name', this.get('driver'))[0]; - }.property('driver'), - - hasOther: function() { - return this.get('model.availableDrivers').filterBy('hasUi',false).length > 0; - }.property('model.availableDrivers.@each.hasUi'), - - showPicker: function() { - return !this.get('projects.current.isWindows') && ( - this.get('model.availableDrivers.length') + - (this.get('allowOther') && this.get('hasOther') ? 1 : 0) + - (this.get('allowCustom') ? 1 : 0) - ) > 1; - }.property('model.availableDrivers.length','allowOther','hasOther','allowCustom'), - - showManage: function() { - return !this.get('projects.current.isWindows') && this.get('access.admin'); - }.property('access.admin','projects.current.isWindows'), - - sortedDrivers: Ember.computed.sort('model.availableDrivers','sortBy'), - sortBy: ['name'], }); diff --git a/app/hosts/new/route.js b/app/hosts/new/route.js index a35be927b..5ceb830f0 100644 --- a/app/hosts/new/route.js +++ b/app/hosts/new/route.js @@ -1,25 +1,11 @@ import Ember from 'ember'; -import C from 'ui/utils/constants'; -import Util from 'ui/utils/util'; const { getOwner } = Ember; -function proxifyUrl(url, proxyBase) { - let parsed = Util.parseUrl(url); - - if ( parsed.hostname.indexOf('.') === -1 || // No dot, local name like localhost - parsed.hostname.toLowerCase().match(/\.local$/) || // your-macbook.local - parsed.origin.toLowerCase() === window.location.origin // You are here - ) { - return url; - } else { - return proxyBase + '/' + url; - } -} - export default Ember.Route.extend({ access : Ember.inject.service(), projects : Ember.inject.service(), settings : Ember.inject.service(), + host : Ember.inject.service(), backTo : null, defaultDriver: 'custom', @@ -77,142 +63,24 @@ export default Ember.Route.extend({ beforeModel(/*transition*/) { this._super(...arguments); - let us = this.get('userStore'); - let drivers = []; + var hs = this.get('host'); - return us.find('machinedriver', null, {forceReload: true}).then((possible) => { - let promises = []; - - possible.filterBy('state','active').forEach((driver) => { - let schemaName = driver.get('name') + 'Config'; - promises.push(us.find('schema', schemaName).then(() => { - drivers.push(driver); - }).catch(() => { - return Ember.RSVP.resolve(); - })); - }); - - return Ember.RSVP.all(promises); - }).then(() => { + return hs.loadAllDrivers().then((drivers) => { this.set('machineDrivers', drivers); }); }, model(params) { this.set('backTo', params.backTo); + var hs = this.get('host'); - let promises = { - reloadHost: this.get('userStore').find('schema','host', {forceReload: true}), - loadCustomUi: this.loadCustomUi(), - schemas: this.get('userStore').find('schema'), - typeDocumentations: this.get('userStore').findAll('typedocumentation') - }; - - if ( params.hostId ) - { - promises.clonedModel = this.getHost(params.hostId); - } - - if ( this.get('access.admin') ) { - let settings = this.get('settings'); - promises.apiHostSet = settings.load(C.SETTING.API_HOST).then(() => { - return !!settings.get(C.SETTING.API_HOST); - }); - } else { - promises.apiHostSet = Ember.RSVP.resolve(true); - } - - return Ember.RSVP.hash(promises).then((hash) => { - hash.availableDrivers = this.get('machineDrivers'); - if ( this.get('projects.current.isWindows') ) { - hash.availableDrivers = []; - } - - let defaultDriver = this.get('defaultDriver'); - let targetDriver = params.driver || this.get('lastDriver') || defaultDriver; - - if ( ['custom','other'].indexOf(targetDriver) === -1 && hash.availableDrivers.filterBy('name', targetDriver).length === 0 ) - { - targetDriver = defaultDriver; - } - - if ( params.driver !== targetDriver ) - { - this.transitionTo('hosts.new', {queryParams: {driver: targetDriver}}); - } - else - { - return Ember.Object.create(hash); - } - }); - }, - - // Loads the custom UI CSS/JS for drivers that have a uiUrl, - loadCustomUi() { - return new Ember.RSVP.Promise((resolve, reject) => { - let completed = 0, expected = 0; - let timer = null; - - function loaded() { - completed++; - if ( completed === expected ) { - resolve(); - clearTimeout(timer); - } - } - - function errored(name) { - clearTimeout(timer); - reject({type: 'error', message: 'Error loading custom driver UI: ' + name}); - } - - // machineDrivers already contains only the active ones with a schema - this.get('machineDrivers').forEach((driver) => { - let id = 'driver-ui-js-' + driver.name; - if (driver.uiUrl && $(`#${id}`).length === 0 ) { - expected++; - let script = document.createElement('script'); - script.onload = function() { loaded(driver.name); }; - script.onerror = function() {errored(driver.name); }; - script.src = proxifyUrl(driver.uiUrl, this.get('app.proxyEndpoint')); - script.id = id; - document.getElementsByTagName('BODY')[0].appendChild(script); - - expected++; - let link = document.createElement('link'); - link.rel = 'stylesheet'; - link.id = id; - link.href = proxifyUrl(driver.uiUrl.replace(/\.js$/,'.css'), this.get('app.proxyEndpoint')); - link.onload = function() { loaded(driver.name); }; - link.onerror = function() { errored(driver.name); }; - document.getElementsByTagName('HEAD')[0].appendChild(link); - } - }); - - if ( expected === 0 ) { - resolve(); + return hs.getModel(params).then((hash) => { + if (hash.transition) { + this.transitionTo('hosts.new', {queryParams: {driver: hash.driver}}); } else { - timer = setTimeout(function() { - reject({type: 'error', message: 'Timeout loading custom machine drivers'}); - }, 10000); + return hash; } }); }, - getHost(hostId) { - let store = this.get('store'); - return store.find('host', hostId).then((host) => { - - let hostOut = host.cloneForNew(); - let src = host[`${host.driver}Config`]; - if ( src ) { - src.type = `${host.driver}Config`; - let config = store.createRecord(src); - hostOut.set(`${host.driver}Config`, config); - } - return hostOut; - }).catch(() => { - return Ember.RSVP.reject({type: 'error', message: 'Failed to retrieve cloned model'}) ; - }); - }, }); diff --git a/app/hosts/new/template.hbs b/app/hosts/new/template.hbs index 46d6d391b..8590c2563 100644 --- a/app/hosts/new/template.hbs +++ b/app/hosts/new/template.hbs @@ -5,47 +5,4 @@ -{{#if model.apiHostSet}} -
- {{#if showPicker}} - - {{/if}} - {{#if access.admin}} -

- {{#link-to "admin-tab.machine"}}{{t 'hostsPage.new.manageLink'}}{{/link-to}} -

- {{/if}} -
- - {{#if driver}} - {{component (if (or (not driverObj) driverObj.hasUi) (concat "machine/driver-" driver) 'machine/driver-other') - cancel=(route-action 'cancel') - goBack=(route-action 'goBack') - clonedModel=model.clonedModel - driver=(concat driver 'Config') - schemas=model.schemas - typeDocumentations=model.typeDocumentations - availableDrivers=model.availableDrivers - }} - {{/if}} -{{else}} -
-
- {{host-settings saved="savedHost"}} -
-
-{{/if}} +{{add-host model=model driver=driver hostId=hostId}} \ No newline at end of file diff --git a/app/ll/service.js b/app/ll/service.js new file mode 100644 index 000000000..b9261c61d --- /dev/null +++ b/app/ll/service.js @@ -0,0 +1,4 @@ +import Ember from 'ember'; + +export default Ember.Service.extend({ +}); diff --git a/app/services/host.js b/app/services/host.js new file mode 100644 index 000000000..67aa153b9 --- /dev/null +++ b/app/services/host.js @@ -0,0 +1,162 @@ +import Ember from 'ember'; +import C from 'ui/utils/constants'; +import Util from 'ui/utils/util'; + +function proxifyUrl(url, proxyBase) { + let parsed = Util.parseUrl(url); + + if ( parsed.hostname.indexOf('.') === -1 || // No dot, local name like localhost + parsed.hostname.toLowerCase().match(/\.local$/) || // your-macbook.local + parsed.origin.toLowerCase() === window.location.origin // You are here + ) { + return url; + } else { + return proxyBase + '/' + url; + } +} + +export default Ember.Service.extend({ + userStore: Ember.inject.service('user-store'), + access : Ember.inject.service(), + projects : Ember.inject.service(), + settings : Ember.inject.service(), + machineDrivers: null, + defaultDriver: 'custom', + loadAllDrivers() { + let us = this.get('userStore'); + let drivers = []; + + return us.find('machinedriver', null, {forceReload: true}).then((possible) => { + let promises = []; + + possible.filterBy('state','active').forEach((driver) => { + let schemaName = driver.get('name') + 'Config'; + promises.push(us.find('schema', schemaName).then(() => { + drivers.push(driver); + }).catch(() => { + return Ember.RSVP.resolve(); + })); + }); + + return Ember.RSVP.all(promises); + }).then(() => { + this.set('machineDrivers', drivers); + return Ember.RSVP.resolve(drivers); + }); + }, + getHost(hostId) { + let store = this.get('store'); + return store.find('host', hostId).then((host) => { + + let hostOut = host.cloneForNew(); + let src = host[`${host.driver}Config`]; + if ( src ) { + src.type = `${host.driver}Config`; + let config = store.createRecord(src); + hostOut.set(`${host.driver}Config`, config); + } + return hostOut; + }).catch(() => { + return Ember.RSVP.reject({type: 'error', message: 'Failed to retrieve cloned model'}) ; + }); + }, + getModel(params=null) { + let promises = { + reloadHost: this.get('userStore').find('schema','host', {forceReload: true}), + loadCustomUi: this.loadCustomUi(), + schemas: this.get('userStore').find('schema'), + typeDocumentations: this.get('userStore').findAll('typedocumentation') + }; + + if (params && params.hostId ) + { + promises.clonedModel = this.getHost(params.hostId); + } + + + if ( this.get('access.admin') ) { + let settings = this.get('settings'); + promises.apiHostSet = settings.load(C.SETTING.API_HOST).then(() => { + return !!settings.get(C.SETTING.API_HOST); + }); + } else { + promises.apiHostSet = Ember.RSVP.resolve(true); + } + + return Ember.RSVP.hash(promises).then((hash) => { + hash.availableDrivers = this.get('machineDrivers'); + if ( this.get('projects.current.isWindows') ) { + hash.availableDrivers = []; + } + + let defaultDriver = this.get('defaultDriver'); + let targetDriver = params && params.driver ? params.driver : defaultDriver; + + if ( ['custom','other'].indexOf(targetDriver) === -1 && hash.availableDrivers.filterBy('name', targetDriver).length === 0 ) + { + targetDriver = defaultDriver; + } + + if (params && params.driver !== targetDriver ) + { + return {transition: true, driver: targetDriver}; + } + else + { + return Ember.Object.create(hash); + } + }); + }, + // Loads the custom UI CSS/JS for drivers that have a uiUrl, + loadCustomUi() { + return new Ember.RSVP.Promise((resolve, reject) => { + let completed = 0, expected = 0; + let timer = null; + + function loaded() { + completed++; + if ( completed === expected ) { + resolve(); + clearTimeout(timer); + } + } + + function errored(name) { + clearTimeout(timer); + reject({type: 'error', message: 'Error loading custom driver UI: ' + name}); + } + + // machineDrivers already contains only the active ones with a schema + this.get('machineDrivers').forEach((driver) => { + let id = 'driver-ui-js-' + driver.name; + if (driver.uiUrl && $(`#${id}`).length === 0 ) { + expected++; + let script = document.createElement('script'); + script.onload = function() { loaded(driver.name); }; + script.onerror = function() {errored(driver.name); }; + script.src = proxifyUrl(driver.uiUrl, this.get('app.proxyEndpoint')); + script.id = id; + document.getElementsByTagName('BODY')[0].appendChild(script); + + expected++; + let link = document.createElement('link'); + link.rel = 'stylesheet'; + link.id = id; + link.href = proxifyUrl(driver.uiUrl.replace(/\.js$/,'.css'), this.get('app.proxyEndpoint')); + link.onload = function() { loaded(driver.name); }; + link.onerror = function() { errored(driver.name); }; + document.getElementsByTagName('HEAD')[0].appendChild(link); + } + }); + + if ( expected === 0 ) { + resolve(); + } else { + timer = setTimeout(function() { + reject({type: 'error', message: 'Timeout loading custom machine drivers'}); + }, 10000); + } + }); + }, + +}); diff --git a/app/utils/constants.js b/app/utils/constants.js index ec59da71a..f122f3ca4 100644 --- a/app/utils/constants.js +++ b/app/utils/constants.js @@ -405,6 +405,7 @@ C.SUPPORTED_SCHEMA_INPUTS= [ 'date', 'enum', 'float', + 'host', 'int', 'multiline', 'password', diff --git a/tests/integration/components/add-host/component-test.js b/tests/integration/components/add-host/component-test.js new file mode 100644 index 000000000..7c76cc9e9 --- /dev/null +++ b/tests/integration/components/add-host/component-test.js @@ -0,0 +1,25 @@ +import { moduleForComponent, test } from 'ember-qunit'; +import hbs from 'htmlbars-inline-precompile'; + +moduleForComponent('add-host', 'Integration | Component | add host', { + integration: true +}); + +test('it renders', function(assert) { + + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.on('myAction', function(val) { ... }); + + this.render(hbs`{{add-host}}`); + + assert.equal(this.$().text().trim(), ''); + + // Template block usage: + this.render(hbs` + {{#add-host}} + template block text + {{/add-host}} + `); + + assert.equal(this.$().text().trim(), 'template block text'); +}); diff --git a/tests/integration/components/schema/input-host/component-test.js b/tests/integration/components/schema/input-host/component-test.js new file mode 100644 index 000000000..e0a0e062c --- /dev/null +++ b/tests/integration/components/schema/input-host/component-test.js @@ -0,0 +1,25 @@ +import { moduleForComponent, test } from 'ember-qunit'; +import hbs from 'htmlbars-inline-precompile'; + +moduleForComponent('schema/input-host', 'Integration | Component | schema/input host', { + integration: true +}); + +test('it renders', function(assert) { + + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.on('myAction', function(val) { ... }); + + this.render(hbs`{{schema/input-host}}`); + + assert.equal(this.$().text().trim(), ''); + + // Template block usage: + this.render(hbs` + {{#schema/input-host}} + template block text + {{/schema/input-host}} + `); + + assert.equal(this.$().text().trim(), 'template block text'); +}); diff --git a/tests/unit/ll/service-test.js b/tests/unit/ll/service-test.js new file mode 100644 index 000000000..2717ff060 --- /dev/null +++ b/tests/unit/ll/service-test.js @@ -0,0 +1,12 @@ +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('service:ll', 'Unit | Service | ll', { + // Specify the other units that are required for this test. + // needs: ['service:foo'] +}); + +// Replace this with your real tests. +test('it exists', function(assert) { + let service = this.subject(); + assert.ok(service); +}); diff --git a/translations/en-us.yaml b/translations/en-us.yaml index 95db7077e..57caba930 100644 --- a/translations/en-us.yaml +++ b/translations/en-us.yaml @@ -3217,6 +3217,8 @@ schema: prompt: Choose a Certificate... inputEnum: option: Choose an option... + inputHost: + label: Select Host inputService: prompt: Choose a Service... inputSecret: From 066db4b43affed6bbe630182c702d7750ed9cf5f Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Fri, 24 Mar 2017 10:10:15 -0700 Subject: [PATCH 4/9] Rework the add host into a component this will allow the add host to be used in catalogs --- app/catalog-tab/launch/route.js | 10 ++++- app/components/add-host/component.js | 43 +++++++++++-------- app/components/add-host/template.hbs | 3 +- .../machine/driver-amazonec2/template.hbs | 2 +- .../modal-catalog-host/component.js | 30 +++++++------ .../modal-catalog-host/template.hbs | 6 ++- app/components/new-catalog/component.js | 4 ++ app/components/new-catalog/template.hbs | 2 +- app/components/schema/input-host/component.js | 11 +++-- app/components/schema/input-host/template.hbs | 1 + app/mixins/driver.js | 13 ++++++ app/services/host.js | 30 +++++++------ 12 files changed, 101 insertions(+), 54 deletions(-) diff --git a/app/catalog-tab/launch/route.js b/app/catalog-tab/launch/route.js index 09fd38132..904fdab37 100644 --- a/app/catalog-tab/launch/route.js +++ b/app/catalog-tab/launch/route.js @@ -2,10 +2,16 @@ import Ember from 'ember'; import C from 'ui/utils/constants'; export default Ember.Route.extend({ - catalog: Ember.inject.service(), + modalService: Ember.inject.service('modal'), + catalog: Ember.inject.service(), - parentRoute: 'catalog-tab', + parentRoute: 'catalog-tab', + actions: { + cancel() { + this.get('modalService').toggleModal(); + }, + }, model: function(params/*, transition*/) { var store = this.get('store'); diff --git a/app/components/add-host/component.js b/app/components/add-host/component.js index 893be9780..7ef382afe 100644 --- a/app/components/add-host/component.js +++ b/app/components/add-host/component.js @@ -1,14 +1,24 @@ import Ember from 'ember'; export default Ember.Component.extend({ - access: Ember.inject.service(), - projects: Ember.inject.service(), - driver: null, - hostId: null, + access: Ember.inject.service(), + projects: Ember.inject.service(), + hostService: Ember.inject.service('host'), + driver: null, + hostId: null, + allowCustom: true, + allowOther: true, + forCatalog: true, + inModal: false, - allowCustom: true, - allowOther: true, - forCatalog: true, + sortBy: ['name'], + sortedDrivers: Ember.computed.sort('model.availableDrivers','sortBy'), + + didReceiveAttrs() { + if (!this.get('driver')) { + this.set('driver', this.get('hostService.defaultDriver')); + } + }, actions: { switchDriver(name) { @@ -20,26 +30,23 @@ export default Ember.Component.extend({ }, }, - driverObj: function() { + driverObj: Ember.computed('driver', function() { return this.get('model.availableDrivers').filterBy('name', this.get('driver'))[0]; - }.property('driver'), + }), - hasOther: function() { + hasOther: Ember.computed('model.availableDrivers.@each.hasUi', function() { return this.get('model.availableDrivers').filterBy('hasUi',false).length > 0; - }.property('model.availableDrivers.@each.hasUi'), + }), - showPicker: function() { + showPicker: Ember.computed('model.availableDrivers.length','allowOther','hasOther','allowCustom', function() { return !this.get('projects.current.isWindows') && ( this.get('model.availableDrivers.length') + (this.get('allowOther') && this.get('hasOther') ? 1 : 0) + (this.get('allowCustom') ? 1 : 0) ) > 1; - }.property('model.availableDrivers.length','allowOther','hasOther','allowCustom'), + }), - showManage: function() { + showManage: Ember.computed('access.admin','projects.current.isWindows', function() { return !this.get('projects.current.isWindows') && this.get('access.admin'); - }.property('access.admin','projects.current.isWindows'), - - sortedDrivers: Ember.computed.sort('model.availableDrivers','sortBy'), - sortBy: ['name'], + }), }); diff --git a/app/components/add-host/template.hbs b/app/components/add-host/template.hbs index 69022b350..bde0c2860 100644 --- a/app/components/add-host/template.hbs +++ b/app/components/add-host/template.hbs @@ -27,12 +27,13 @@ {{#if driver}} {{component (if (or (not driverObj) driverObj.hasUi) (concat "machine/driver-" driver) 'machine/driver-other') cancel=(route-action 'cancel') - goBack=(route-action 'goBack') clonedModel=model.clonedModel driver=(concat driver 'Config') schemas=model.schemas typeDocumentations=model.typeDocumentations availableDrivers=model.availableDrivers + inModal=inModal + completed=(action completed) }} {{/if}} {{else}} diff --git a/app/components/machine/driver-amazonec2/template.hbs b/app/components/machine/driver-amazonec2/template.hbs index ddc42bd0f..1df27dc4b 100644 --- a/app/components/machine/driver-amazonec2/template.hbs +++ b/app/components/machine/driver-amazonec2/template.hbs @@ -297,5 +297,5 @@ {{top-errors errors=errors}} - {{save-cancel save="save" cancel="cancel"}} + {{save-cancel save=driverSaveAction cancel="cancel"}} diff --git a/app/components/modal-catalog-host/component.js b/app/components/modal-catalog-host/component.js index 9d21ca1e8..2b7ccfacb 100644 --- a/app/components/modal-catalog-host/component.js +++ b/app/components/modal-catalog-host/component.js @@ -2,23 +2,29 @@ import Ember from 'ember'; import ModalBase from 'ui/mixins/modal-base'; export default Ember.Component.extend(ModalBase, { - hostService : Ember.inject.service('host'), - classNames: ['full-modal'], - loading: true, - model: null, - didRender() { + modalService: Ember.inject.service('modal'), + hostService: Ember.inject.service('host'), + classNames: ['full-modal'], + loading: true, + model: null, + hostConfig: null, + actions: { + completed(hostConfig) { + this.get('modalService.modalOpts.callee').send('completed', hostConfig); + Ember.run.next(() => { + this.get('modalService').toggleModal(); + }); + } + }, + init() { + this._super(...arguments); var hs = this.get('hostService'); hs.loadAllDrivers().then((drivers) => { this.set('machineDrivers', drivers); hs.getModel().then((hash) => { - if (hash.transition) { - debugger; - // we shouldnt get here - } else { - this.set('loading', false); - this.set('model', hash); - } + this.set('model', hash); + this.set('loading', false); }); }); } diff --git a/app/components/modal-catalog-host/template.hbs b/app/components/modal-catalog-host/template.hbs index 22340201c..60a87f3a9 100644 --- a/app/components/modal-catalog-host/template.hbs +++ b/app/components/modal-catalog-host/template.hbs @@ -1,5 +1,7 @@ {{#if loading}} - fetching data wathc the spinner +
+ {{t 'generic.loading'}} +
{{else}} - {{add-host model=model driver='custom'}} + {{add-host model=model inModal=true completed=(action 'completed')}} {{/if}} \ No newline at end of file diff --git a/app/components/new-catalog/component.js b/app/components/new-catalog/component.js index 1f1477729..6c5cc00e7 100644 --- a/app/components/new-catalog/component.js +++ b/app/components/new-catalog/component.js @@ -57,6 +57,10 @@ export default Ember.Component.extend(NewOrEdit, { changeTemplate: function(tpl) { this.get('application').transitionToRoute('catalog-tab.launch', tpl.id); }, + + completed(value){ + debugger; + } }, didReceiveAttrs: function() { diff --git a/app/components/new-catalog/template.hbs b/app/components/new-catalog/template.hbs index a25daa3e5..68261834f 100644 --- a/app/components/new-catalog/template.hbs +++ b/app/components/new-catalog/template.hbs @@ -102,7 +102,7 @@ {{#if question.supported}} - {{component question.inputComponent field=question value=question.answer}} + {{component question.inputComponent field=question value=question.answer completed=(action "completed")}} {{else}} {{input type="text" value=question.answer class="form-control"}}

{{t 'newCatalog.unknownType'}} {{question.type}}

diff --git a/app/components/schema/input-host/component.js b/app/components/schema/input-host/component.js index 3545a8321..4102642e9 100644 --- a/app/components/schema/input-host/component.js +++ b/app/components/schema/input-host/component.js @@ -1,11 +1,16 @@ import Ember from 'ember'; export default Ember.Component.extend({ - modalService: Ember.inject.service('modal'), - hostConfig: null, + modalService: Ember.inject.service('modal'), + hostConfig: Ember.computed.alias('modalService.modalOpts.hostConfig'), actions: { launchHost() { - this.get('modalService').toggleModal('modal-catalog-host'); + this.get('modalService').toggleModal('modal-catalog-host', { + callee: this, + }); + }, + completed(value){ + this.set('hostConfig', value); } } }); diff --git a/app/components/schema/input-host/template.hbs b/app/components/schema/input-host/template.hbs index e84d95dab..daa1e00dd 100644 --- a/app/components/schema/input-host/template.hbs +++ b/app/components/schema/input-host/template.hbs @@ -1,4 +1,5 @@ {{#if hostConfig}} + {{pretty-json value=hostConfig}} {{else}} {{/if}} diff --git a/app/mixins/driver.js b/app/mixins/driver.js index 0f104f596..90d147ed2 100644 --- a/app/mixins/driver.js +++ b/app/mixins/driver.js @@ -19,6 +19,7 @@ export default Ember.Mixin.create(NewOrEdit, ManageLabels, { multiTemplate : null, clonedModel : null, useHost : true, + hostConfig : null, actions: { addLabel: addAction('addLabel', '.key'), @@ -28,6 +29,10 @@ export default Ember.Mixin.create(NewOrEdit, ManageLabels, { goBack() { this.attrs.goBack(); }, + passConfigBack(cb) { + this.sendAction('completed', this.get('model')); + cb(true); + }, setLabels(labels) { let out = {}; labels.forEach((row) => { @@ -52,6 +57,14 @@ export default Ember.Mixin.create(NewOrEdit, ManageLabels, { } }, + driverSaveAction: Ember.computed('inModal', function() { + if (this.get('inModal')) { + return 'passConfigBack'; + } else { + return 'save'; + } + }), + nameParts: function() { let input = this.get('prefix')||''; let count = this.get('count'); diff --git a/app/services/host.js b/app/services/host.js index 67aa153b9..b07174b67 100644 --- a/app/services/host.js +++ b/app/services/host.js @@ -26,22 +26,24 @@ export default Ember.Service.extend({ let us = this.get('userStore'); let drivers = []; - return us.find('machinedriver', null, {forceReload: true}).then((possible) => { - let promises = []; + return new Ember.RSVP.Promise((resolve, reject) => { + us.find('machinedriver', null, {forceReload: true}).then((possible) => { + let promises = []; - possible.filterBy('state','active').forEach((driver) => { - let schemaName = driver.get('name') + 'Config'; - promises.push(us.find('schema', schemaName).then(() => { - drivers.push(driver); - }).catch(() => { - return Ember.RSVP.resolve(); - })); + possible.filterBy('state','active').forEach((driver) => { + let schemaName = driver.get('name') + 'Config'; + promises.push(us.find('schema', schemaName).then(() => { + drivers.push(driver); + }).catch(() => { + reject(); + })); + }); + + Ember.RSVP.all(promises); + }).then(() => { + this.set('machineDrivers', drivers); + resolve(drivers); }); - - return Ember.RSVP.all(promises); - }).then(() => { - this.set('machineDrivers', drivers); - return Ember.RSVP.resolve(drivers); }); }, getHost(hostId) { From ada462298597c2daaffc1d7cb224f8773e5b6609 Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Fri, 24 Mar 2017 10:42:55 -0700 Subject: [PATCH 5/9] Fix tests and remove pretty json from input-host --- app/authenticated/project/controller.js | 1 - app/components/new-catalog/component.js | 4 --- app/components/new-catalog/template.hbs | 2 +- app/components/schema/input-host/component.js | 8 ++++-- app/components/schema/input-host/template.hbs | 2 +- app/new-stack/controller.js | 1 - app/scaling-groups/index/controller.js | 1 - .../components/add-host/component-test.js | 25 ------------------- .../schema/input-host/component-test.js | 25 ------------------- 9 files changed, 8 insertions(+), 61 deletions(-) delete mode 100644 tests/integration/components/add-host/component-test.js delete mode 100644 tests/integration/components/schema/input-host/component-test.js diff --git a/app/authenticated/project/controller.js b/app/authenticated/project/controller.js index 1e2b7d45b..0c2223df0 100644 --- a/app/authenticated/project/controller.js +++ b/app/authenticated/project/controller.js @@ -1,5 +1,4 @@ import Ember from 'ember'; -import C from 'ui/utils/constants'; export default Ember.Controller.extend({ tags: '', diff --git a/app/components/new-catalog/component.js b/app/components/new-catalog/component.js index 6c5cc00e7..1f1477729 100644 --- a/app/components/new-catalog/component.js +++ b/app/components/new-catalog/component.js @@ -57,10 +57,6 @@ export default Ember.Component.extend(NewOrEdit, { changeTemplate: function(tpl) { this.get('application').transitionToRoute('catalog-tab.launch', tpl.id); }, - - completed(value){ - debugger; - } }, didReceiveAttrs: function() { diff --git a/app/components/new-catalog/template.hbs b/app/components/new-catalog/template.hbs index 68261834f..a25daa3e5 100644 --- a/app/components/new-catalog/template.hbs +++ b/app/components/new-catalog/template.hbs @@ -102,7 +102,7 @@ {{#if question.supported}} - {{component question.inputComponent field=question value=question.answer completed=(action "completed")}} + {{component question.inputComponent field=question value=question.answer}} {{else}} {{input type="text" value=question.answer class="form-control"}}

{{t 'newCatalog.unknownType'}} {{question.type}}

diff --git a/app/components/schema/input-host/component.js b/app/components/schema/input-host/component.js index 4102642e9..d62f98bd4 100644 --- a/app/components/schema/input-host/component.js +++ b/app/components/schema/input-host/component.js @@ -2,7 +2,7 @@ import Ember from 'ember'; export default Ember.Component.extend({ modalService: Ember.inject.service('modal'), - hostConfig: Ember.computed.alias('modalService.modalOpts.hostConfig'), + hostConfig: null, actions: { launchHost() { this.get('modalService').toggleModal('modal-catalog-host', { @@ -10,7 +10,11 @@ export default Ember.Component.extend({ }); }, completed(value){ - this.set('hostConfig', value); + Object.keys(value).forEach((key) => { + if (key.indexOf('Config') >= 0) { + this.set('hostConfig', key.slice(0, key.indexOf('Config').capitalize())); + } + }); } } }); diff --git a/app/components/schema/input-host/template.hbs b/app/components/schema/input-host/template.hbs index daa1e00dd..45221960a 100644 --- a/app/components/schema/input-host/template.hbs +++ b/app/components/schema/input-host/template.hbs @@ -1,5 +1,5 @@ {{#if hostConfig}} - {{pretty-json value=hostConfig}} + {{hostConfig}} {{else}} {{/if}} diff --git a/app/new-stack/controller.js b/app/new-stack/controller.js index 7e1aaae0b..3a6f8cb19 100644 --- a/app/new-stack/controller.js +++ b/app/new-stack/controller.js @@ -1,6 +1,5 @@ import Ember from 'ember'; import NewOrEdit from 'ui/mixins/new-or-edit'; -import C from 'ui/utils/constants'; import {tagChoices, tagsToArray} from 'ui/models/stack'; export default Ember.Controller.extend(NewOrEdit, { diff --git a/app/scaling-groups/index/controller.js b/app/scaling-groups/index/controller.js index 15e6b23a2..81628351e 100644 --- a/app/scaling-groups/index/controller.js +++ b/app/scaling-groups/index/controller.js @@ -1,5 +1,4 @@ import Ember from 'ember'; -import C from 'ui/utils/constants'; import { tagsToArray } from 'ui/models/stack'; import { headersWithHost as containerHeaders } from 'ui/components/container-table/component'; diff --git a/tests/integration/components/add-host/component-test.js b/tests/integration/components/add-host/component-test.js deleted file mode 100644 index 7c76cc9e9..000000000 --- a/tests/integration/components/add-host/component-test.js +++ /dev/null @@ -1,25 +0,0 @@ -import { moduleForComponent, test } from 'ember-qunit'; -import hbs from 'htmlbars-inline-precompile'; - -moduleForComponent('add-host', 'Integration | Component | add host', { - integration: true -}); - -test('it renders', function(assert) { - - // Set any properties with this.set('myProperty', 'value'); - // Handle any actions with this.on('myAction', function(val) { ... }); - - this.render(hbs`{{add-host}}`); - - assert.equal(this.$().text().trim(), ''); - - // Template block usage: - this.render(hbs` - {{#add-host}} - template block text - {{/add-host}} - `); - - assert.equal(this.$().text().trim(), 'template block text'); -}); diff --git a/tests/integration/components/schema/input-host/component-test.js b/tests/integration/components/schema/input-host/component-test.js deleted file mode 100644 index e0a0e062c..000000000 --- a/tests/integration/components/schema/input-host/component-test.js +++ /dev/null @@ -1,25 +0,0 @@ -import { moduleForComponent, test } from 'ember-qunit'; -import hbs from 'htmlbars-inline-precompile'; - -moduleForComponent('schema/input-host', 'Integration | Component | schema/input host', { - integration: true -}); - -test('it renders', function(assert) { - - // Set any properties with this.set('myProperty', 'value'); - // Handle any actions with this.on('myAction', function(val) { ... }); - - this.render(hbs`{{schema/input-host}}`); - - assert.equal(this.$().text().trim(), ''); - - // Template block usage: - this.render(hbs` - {{#schema/input-host}} - template block text - {{/schema/input-host}} - `); - - assert.equal(this.$().text().trim(), 'template block text'); -}); From 9de66281f61dfce7009a8bb5fc8159e396f6f62f Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Fri, 24 Mar 2017 14:05:07 -0700 Subject: [PATCH 6/9] Refactor save for all templates, remove custom, and small fixes --- app/components/add-host/component.js | 7 ++++++- app/components/add-host/template.hbs | 3 ++- app/components/machine/driver-aliyunecs/template.hbs | 2 +- app/components/machine/driver-azure/template.hbs | 2 +- .../machine/driver-digitalocean/template.hbs | 2 +- app/components/machine/driver-exoscale/template.hbs | 2 +- app/components/machine/driver-other/template.hbs | 2 +- app/components/machine/driver-packet/template.hbs | 2 +- app/components/machine/driver-rackspace/template.hbs | 2 +- app/components/machine/driver-ubiquity/template.hbs | 2 +- .../machine/driver-vmwarevsphere/template.hbs | 2 +- app/components/modal-catalog-host/component.js | 1 + app/components/schema/input-host/component.js | 11 ++++++++++- app/components/schema/input-host/template.hbs | 2 +- app/hosts/new/controller.js | 3 +++ app/hosts/new/template.hbs | 2 +- app/mixins/driver.js | 4 +++- 17 files changed, 36 insertions(+), 15 deletions(-) diff --git a/app/components/add-host/component.js b/app/components/add-host/component.js index 7ef382afe..d80db68b5 100644 --- a/app/components/add-host/component.js +++ b/app/components/add-host/component.js @@ -10,13 +10,18 @@ export default Ember.Component.extend({ allowOther: true, forCatalog: true, inModal: false, + goBack: null, sortBy: ['name'], sortedDrivers: Ember.computed.sort('model.availableDrivers','sortBy'), didReceiveAttrs() { if (!this.get('driver')) { - this.set('driver', this.get('hostService.defaultDriver')); + if (this.get('inModal')) { + this.set('driver', this.get('sortedDrivers.firstObject.name')); + } else { + this.set('driver', this.get('hostService.defaultDriver')); + } } }, diff --git a/app/components/add-host/template.hbs b/app/components/add-host/template.hbs index bde0c2860..feb6b636a 100644 --- a/app/components/add-host/template.hbs +++ b/app/components/add-host/template.hbs @@ -2,7 +2,7 @@
{{#if showPicker}}
diff --git a/app/components/machine/driver-azure/template.hbs b/app/components/machine/driver-azure/template.hbs index 42eb0ff06..c74b32120 100644 --- a/app/components/machine/driver-azure/template.hbs +++ b/app/components/machine/driver-azure/template.hbs @@ -198,5 +198,5 @@ {{top-errors errors=errors}} - {{save-cancel save="save" cancel="cancel"}} + {{save-cancel save=driverSaveAction cancel="cancel"}} diff --git a/app/components/machine/driver-digitalocean/template.hbs b/app/components/machine/driver-digitalocean/template.hbs index 79ec46e4e..4d2f2f1da 100644 --- a/app/components/machine/driver-digitalocean/template.hbs +++ b/app/components/machine/driver-digitalocean/template.hbs @@ -109,6 +109,6 @@ {{top-errors errors=errors}} - {{save-cancel save="save" cancel="cancel"}} + {{save-cancel save=driverSaveAction cancel="cancel"}} {{/if}} diff --git a/app/components/machine/driver-exoscale/template.hbs b/app/components/machine/driver-exoscale/template.hbs index 97cd07d69..f44dff9e0 100644 --- a/app/components/machine/driver-exoscale/template.hbs +++ b/app/components/machine/driver-exoscale/template.hbs @@ -169,5 +169,5 @@ {{top-errors errors=errors}} - {{save-cancel save="save" cancel="cancel"}} + {{save-cancel save=driverSaveAction cancel="cancel"}} diff --git a/app/components/machine/driver-other/template.hbs b/app/components/machine/driver-other/template.hbs index 7b82b919e..bacdf4719 100644 --- a/app/components/machine/driver-other/template.hbs +++ b/app/components/machine/driver-other/template.hbs @@ -39,5 +39,5 @@ {{top-errors errors=errors}} - {{save-cancel save="save" cancel="cancel"}} + {{save-cancel save=driverSaveAction cancel="cancel"}} diff --git a/app/components/machine/driver-packet/template.hbs b/app/components/machine/driver-packet/template.hbs index dba848d36..0a06ef739 100644 --- a/app/components/machine/driver-packet/template.hbs +++ b/app/components/machine/driver-packet/template.hbs @@ -74,6 +74,6 @@ {{top-errors errors=errors}} - {{save-cancel save="save" cancel="cancel"}} + {{save-cancel save=driverSaveAction cancel="cancel"}} diff --git a/app/components/machine/driver-rackspace/template.hbs b/app/components/machine/driver-rackspace/template.hbs index 0740560bd..9234e53e7 100644 --- a/app/components/machine/driver-rackspace/template.hbs +++ b/app/components/machine/driver-rackspace/template.hbs @@ -64,5 +64,5 @@ {{partial "host/add-options"}} - {{save-cancel save="save" cancel="cancel"}} + {{save-cancel save=driverSaveAction cancel="cancel"}} diff --git a/app/components/machine/driver-ubiquity/template.hbs b/app/components/machine/driver-ubiquity/template.hbs index d6a360696..9698fbd25 100644 --- a/app/components/machine/driver-ubiquity/template.hbs +++ b/app/components/machine/driver-ubiquity/template.hbs @@ -113,5 +113,5 @@ {{top-errors errors=errors}} - {{save-cancel save="save" cancel="cancel"}} + {{save-cancel save=driverSaveAction cancel="cancel"}} diff --git a/app/components/machine/driver-vmwarevsphere/template.hbs b/app/components/machine/driver-vmwarevsphere/template.hbs index 7e3698c4f..bc2296d78 100644 --- a/app/components/machine/driver-vmwarevsphere/template.hbs +++ b/app/components/machine/driver-vmwarevsphere/template.hbs @@ -131,5 +131,5 @@ {{partial "host/add-options"}} - {{save-cancel save="save" cancel="cancel"}} + {{save-cancel save=driverSaveAction cancel="cancel"}} diff --git a/app/components/modal-catalog-host/component.js b/app/components/modal-catalog-host/component.js index 2b7ccfacb..9bbab572d 100644 --- a/app/components/modal-catalog-host/component.js +++ b/app/components/modal-catalog-host/component.js @@ -8,6 +8,7 @@ export default Ember.Component.extend(ModalBase, { loading: true, model: null, hostConfig: null, + goBack: null, actions: { completed(hostConfig) { this.get('modalService.modalOpts.callee').send('completed', hostConfig); diff --git a/app/components/schema/input-host/component.js b/app/components/schema/input-host/component.js index d62f98bd4..d180ded6c 100644 --- a/app/components/schema/input-host/component.js +++ b/app/components/schema/input-host/component.js @@ -3,16 +3,25 @@ import Ember from 'ember'; export default Ember.Component.extend({ modalService: Ember.inject.service('modal'), hostConfig: null, + hostName: null, actions: { launchHost() { + // we should reall not kill the previous driver if they edit, fix this in the future + if (this.get('hostConfig')) { + this.setProperties({ + hostConfig: null, + hostName: null + }); + } this.get('modalService').toggleModal('modal-catalog-host', { callee: this, }); }, completed(value){ + this.set('hostConfig', value); Object.keys(value).forEach((key) => { if (key.indexOf('Config') >= 0) { - this.set('hostConfig', key.slice(0, key.indexOf('Config').capitalize())); + this.set('hostName', key.slice(0, key.indexOf('Config')).capitalize()); } }); } diff --git a/app/components/schema/input-host/template.hbs b/app/components/schema/input-host/template.hbs index 45221960a..6db5d4973 100644 --- a/app/components/schema/input-host/template.hbs +++ b/app/components/schema/input-host/template.hbs @@ -1,5 +1,5 @@ {{#if hostConfig}} - {{hostConfig}} + {{hostName}} {{t 'generic.remove'}} {{else}} {{/if}} diff --git a/app/hosts/new/controller.js b/app/hosts/new/controller.js index 990b7ceb5..f79ae2dfb 100644 --- a/app/hosts/new/controller.js +++ b/app/hosts/new/controller.js @@ -5,4 +5,7 @@ export default Ember.Controller.extend({ backTo : null, driver : null, hostId : null, + actions: { + completed() {} + } }); diff --git a/app/hosts/new/template.hbs b/app/hosts/new/template.hbs index 8590c2563..42a85fb06 100644 --- a/app/hosts/new/template.hbs +++ b/app/hosts/new/template.hbs @@ -5,4 +5,4 @@ -{{add-host model=model driver=driver hostId=hostId}} \ No newline at end of file +{{add-host model=model driver=driver hostId=hostId completed=(action 'completed') goBack=(route-action 'goBack')}} \ No newline at end of file diff --git a/app/mixins/driver.js b/app/mixins/driver.js index 90d147ed2..b32e54ceb 100644 --- a/app/mixins/driver.js +++ b/app/mixins/driver.js @@ -27,7 +27,9 @@ export default Ember.Mixin.create(NewOrEdit, ManageLabels, { this.attrs.cancel(); }, goBack() { - this.attrs.goBack(); + if (Ember.typeOf(this.attrs.goBack) === 'function') { + this.attrs.goBack(); + } }, passConfigBack(cb) { this.sendAction('completed', this.get('model')); From 9f8d41530b61eb94c8cb01e91d2c40bdaa8d0ae8 Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Fri, 24 Mar 2017 14:26:21 -0700 Subject: [PATCH 7/9] modify value out for input-host questions --- app/components/schema/input-host/component.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/components/schema/input-host/component.js b/app/components/schema/input-host/component.js index d180ded6c..4539edbcb 100644 --- a/app/components/schema/input-host/component.js +++ b/app/components/schema/input-host/component.js @@ -4,6 +4,7 @@ export default Ember.Component.extend({ modalService: Ember.inject.service('modal'), hostConfig: null, hostName: null, + value: null, actions: { launchHost() { // we should reall not kill the previous driver if they edit, fix this in the future @@ -18,7 +19,10 @@ export default Ember.Component.extend({ }); }, completed(value){ - this.set('hostConfig', value); + this.setProperties({ + hostConfig: value, // probably use this when we are sending it back up on edit + value: JSON.stringify(value) + }); Object.keys(value).forEach((key) => { if (key.indexOf('Config') >= 0) { this.set('hostName', key.slice(0, key.indexOf('Config')).capitalize()); From 1fe58f5679efa9238e4766165ecec22c6b348318 Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Fri, 24 Mar 2017 14:55:32 -0700 Subject: [PATCH 8/9] Remove name and quanity --- app/components/machine/driver-aliyunecs/template.hbs | 4 +++- app/components/machine/driver-amazonec2/template.hbs | 4 +++- app/components/machine/driver-azure/template.hbs | 4 +++- app/components/machine/driver-digitalocean/template.hbs | 4 +++- app/components/machine/driver-exoscale/template.hbs | 4 +++- app/components/machine/driver-other/template.hbs | 4 +++- app/components/machine/driver-packet/template.hbs | 4 +++- app/components/machine/driver-rackspace/template.hbs | 4 +++- app/components/machine/driver-ubiquity/template.hbs | 4 +++- app/components/machine/driver-vmwarevsphere/template.hbs | 4 +++- app/components/schema/input-host/component.js | 1 + 11 files changed, 31 insertions(+), 10 deletions(-) diff --git a/app/components/machine/driver-aliyunecs/template.hbs b/app/components/machine/driver-aliyunecs/template.hbs index 42727e67e..0f043d376 100644 --- a/app/components/machine/driver-aliyunecs/template.hbs +++ b/app/components/machine/driver-aliyunecs/template.hbs @@ -1,7 +1,9 @@
- {{partial "host/add-common"}} + {{#unless inModal}} + {{partial "host/add-common"}} + {{/unless}}
{{t 'machine.driverAliyunecs.accountSection'}} diff --git a/app/components/machine/driver-amazonec2/template.hbs b/app/components/machine/driver-amazonec2/template.hbs index 1df27dc4b..efea1cf01 100644 --- a/app/components/machine/driver-amazonec2/template.hbs +++ b/app/components/machine/driver-amazonec2/template.hbs @@ -227,7 +227,9 @@ {{t 'machine.driverAmazon.instanceSection'}}
- {{partial "host/add-common"}} + {{#unless inModal}} + {{partial "host/add-common"}} + {{/unless}}
{{t 'machine.driverAmazon.instanceOptionsSection'}} diff --git a/app/components/machine/driver-azure/template.hbs b/app/components/machine/driver-azure/template.hbs index c74b32120..1d9c3d177 100644 --- a/app/components/machine/driver-azure/template.hbs +++ b/app/components/machine/driver-azure/template.hbs @@ -1,6 +1,8 @@
- {{partial "host/add-common"}} + {{#unless inModal}} + {{partial "host/add-common"}} + {{/unless}}
{{t 'machine.driverAzure.placementSection'}} diff --git a/app/components/machine/driver-digitalocean/template.hbs b/app/components/machine/driver-digitalocean/template.hbs index 4d2f2f1da..fd220ef8b 100644 --- a/app/components/machine/driver-digitalocean/template.hbs +++ b/app/components/machine/driver-digitalocean/template.hbs @@ -27,7 +27,9 @@ {{else}}
- {{partial "host/add-common"}} + {{#unless inModal}} + {{partial "host/add-common"}} + {{/unless}}
{{t 'machine.driverDigitalocean.regionSection'}} diff --git a/app/components/machine/driver-exoscale/template.hbs b/app/components/machine/driver-exoscale/template.hbs index f44dff9e0..d78fd2734 100644 --- a/app/components/machine/driver-exoscale/template.hbs +++ b/app/components/machine/driver-exoscale/template.hbs @@ -131,7 +131,9 @@ {{t 'machine.driverExoscale.instanceSection'}}
- {{partial "host/add-common"}} + {{#unless inModal}} + {{partial "host/add-common"}} + {{/unless}}
diff --git a/app/components/machine/driver-other/template.hbs b/app/components/machine/driver-other/template.hbs index bacdf4719..495534f0f 100644 --- a/app/components/machine/driver-other/template.hbs +++ b/app/components/machine/driver-other/template.hbs @@ -1,7 +1,9 @@
- {{partial "host/add-common"}} + {{#unless inModal}} + {{partial "host/add-common"}} + {{/unless}}
{{t 'machine.driverOther.driverSection'}} diff --git a/app/components/machine/driver-packet/template.hbs b/app/components/machine/driver-packet/template.hbs index 0a06ef739..2eff8ffe7 100644 --- a/app/components/machine/driver-packet/template.hbs +++ b/app/components/machine/driver-packet/template.hbs @@ -1,7 +1,9 @@
- {{partial "host/add-common"}} + {{#unless inModal}} + {{partial "host/add-common"}} + {{/unless}}
{{t 'machine.driverPacket.accountSection'}} diff --git a/app/components/machine/driver-rackspace/template.hbs b/app/components/machine/driver-rackspace/template.hbs index 9234e53e7..46b3482a0 100644 --- a/app/components/machine/driver-rackspace/template.hbs +++ b/app/components/machine/driver-rackspace/template.hbs @@ -2,7 +2,9 @@
- {{partial "host/add-common"}} + {{#unless inModal}} + {{partial "host/add-common"}} + {{/unless}}
{{t 'machine.driverRackspace.accountSection'}} diff --git a/app/components/machine/driver-ubiquity/template.hbs b/app/components/machine/driver-ubiquity/template.hbs index 9698fbd25..ce60b7056 100644 --- a/app/components/machine/driver-ubiquity/template.hbs +++ b/app/components/machine/driver-ubiquity/template.hbs @@ -67,7 +67,9 @@ {{t 'machine.driverUbiquity.instanceSection'}}
- {{partial "host/add-common"}} + {{#unless inModal}} + {{partial "host/add-common"}} + {{/unless}}
{{t 'machine.driverUbiquity.regionSection'}} diff --git a/app/components/machine/driver-vmwarevsphere/template.hbs b/app/components/machine/driver-vmwarevsphere/template.hbs index bc2296d78..5bb4fd4c3 100644 --- a/app/components/machine/driver-vmwarevsphere/template.hbs +++ b/app/components/machine/driver-vmwarevsphere/template.hbs @@ -2,7 +2,9 @@
- {{partial "host/add-common"}} + {{#unless inModal}} + {{partial "host/add-common"}} + {{/unless}}
{{t 'machine.driverVsphere.accountSection'}} diff --git a/app/components/schema/input-host/component.js b/app/components/schema/input-host/component.js index 4539edbcb..6563b16f0 100644 --- a/app/components/schema/input-host/component.js +++ b/app/components/schema/input-host/component.js @@ -19,6 +19,7 @@ export default Ember.Component.extend({ }); }, completed(value){ + //before we send this back just strip the name/quanity values out of the hostconfig this.setProperties({ hostConfig: value, // probably use this when we are sending it back up on edit value: JSON.stringify(value) From 29a9565913b06de1ab88a261c9d75e6f8b93738b Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Fri, 24 Mar 2017 15:01:11 -0700 Subject: [PATCH 9/9] remove comment --- app/components/schema/input-host/component.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/components/schema/input-host/component.js b/app/components/schema/input-host/component.js index 6563b16f0..4539edbcb 100644 --- a/app/components/schema/input-host/component.js +++ b/app/components/schema/input-host/component.js @@ -19,7 +19,6 @@ export default Ember.Component.extend({ }); }, completed(value){ - //before we send this back just strip the name/quanity values out of the hostconfig this.setProperties({ hostConfig: value, // probably use this when we are sending it back up on edit value: JSON.stringify(value)