This commit is contained in:
Vincent Fiduccia 2017-08-18 14:29:43 -07:00
parent 295cfb14e6
commit 4069333ce1
No known key found for this signature in database
GPG Key ID: 2B29AD6BB2BB2582
6 changed files with 58 additions and 31 deletions

View File

@ -26,11 +26,7 @@ export default Ember.Route.extend({
}, },
goBack() { goBack() {
if ( this.get('backTo') === 'waiting' ) { this.send('goToPrevious','authenticated.clusters');
this.transitionTo('authenticated.project.waiting');
} else {
this.transitionTo('hosts');
}
} }
}, },

View File

@ -9,11 +9,7 @@ export default Ember.Controller.extend({
actions: { actions: {
newCluster() { newCluster() {
let cluster = this.get('userStore').createRecord({ this.get('modalService').toggleModal('modal-edit-cluster');
type: 'cluster',
});
this.get('modalService').toggleModal('modal-edit-cluster', cluster);
}, },
}, },

View File

@ -4,15 +4,7 @@ export default Ember.Component.extend({
projects: Ember.inject.service(), projects: Ember.inject.service(),
settings: Ember.inject.service(), settings: Ember.inject.service(),
clusters: null, cluster: Ember.computed.alias('projects.currentCluster'),
canCreate: Ember.computed.notEmpty('cluster.registrationToken.hostCommand'),
canCreate: true, canImport: Ember.computed.notEmpty('cluster.registrationToken.clusterCommand'),
canImport: true,
canReuse: Ember.computed.gt('clusters.length', 0),
init() {
this._super(),
this.set('clusters', this.get('store').all('cluster'));
},
}); });

View File

@ -5,14 +5,16 @@
<div class="row"> <div class="row">
<div class="col span-4 offset-2 text-center option option-primary {{unless canCreate 'option-disabled'}}"> <div class="col span-4 offset-2 text-center option option-primary {{unless canCreate 'option-disabled'}}">
<h2>Add Host</h2> <h2>Add Hosts</h2>
<div class="box"> <div class="box">
<p>Define and manage hosts inside {{settings.appName}}.</p> <p>Define and manage hosts inside {{settings.appName}}.</p>
<p>Supports on-premise, bare-metal, and cloud infrastructure.</p> <p>Supports on-premise, bare-metal, and cloud infrastructure.</p>
{{#if canCreate}}
<div class="links" style="top: auto; bottom: 47px;"> <div class="links" style="top: auto; bottom: 47px;">
{{#link-to "authenticated.clusters.cluster.host-templates" projects.currentCluster.id class="btn bg-primary"}}Select{{/link-to}} {{#link-to "authenticated.clusters.cluster.host-templates" projects.currentCluster.id class="btn bg-primary"}}Select{{/link-to}}
</div> </div>
{{/if}}
</div> </div>
<div class="bubble bg-body round"><img src="{{app.baseAssets}}assets/images/environment-advanced.svg" class="mt-5" /></div> <div class="bubble bg-body round"><img src="{{app.baseAssets}}assets/images/environment-advanced.svg" class="mt-5" /></div>
</div> </div>
@ -25,9 +27,11 @@
<p>Individual hosts are managed by cluster provider outside of {{settings.appName}}.</p> <p>Individual hosts are managed by cluster provider outside of {{settings.appName}}.</p>
<p>Supports hosted services like Google Container Engine.</p> <p>Supports hosted services like Google Container Engine.</p>
{{#if canImport}}
<div class="links" style="top: auto; bottom: 47px;"> <div class="links" style="top: auto; bottom: 47px;">
{{#link-to "authenticated.clusters.cluster.import" projects.currentCluster.id class="btn bg-primary"}}Select{{/link-to}} {{#link-to "authenticated.clusters.cluster.import" projects.currentCluster.id class="btn bg-primary"}}Select{{/link-to}}
</div> </div>
{{/if}}
</div> </div>
<div class="bubble bg-body round"><img src="{{app.baseAssets}}assets/images/environment-advanced.svg" class="mt-5" /></div> <div class="bubble bg-body round"><img src="{{app.baseAssets}}assets/images/environment-advanced.svg" class="mt-5" /></div>
</div> </div>

View File

@ -11,9 +11,37 @@ export default Ember.Component.extend(ModalBase, NewOrEdit, {
willInsertElement: function() { willInsertElement: function() {
this._super(...arguments); this._super(...arguments);
var orig = this.get('originalModel'); var orig = this.get('originalModel');
if ( orig ) {
var clone = orig.clone(); var clone = orig.clone();
this.set('model', clone); this.setProperties({
this.set('editing', !!this.get('model.id')); editing: true,
model: clone,
createProject: null,
});
} else {
this.setProperties({
editing: false,
model: this.get('userStore').createRecord({
type: 'cluster',
}),
createProject: this.get('userStore').createRecord({
type: 'project',
name: 'Default',
}),
});
}
},
didInsertElement() {
this.$('INPUT')[0].focus();
},
didSave() {
let project = this.get('createProject');
if ( project ) {
project.set('clusterId', this.get('model.id'));
return project.save();
}
}, },
doneSaving: function() { doneSaving: function() {

View File

@ -4,6 +4,7 @@ import PolledResource from 'ui/mixins/cattle-polled-resource';
var Cluster = Resource.extend(PolledResource, { var Cluster = Resource.extend(PolledResource, {
modalService: Ember.inject.service('modal'), modalService: Ember.inject.service('modal'),
userStore: Ember.inject.service('user-store'),
type: 'cluster', type: 'cluster',
@ -13,6 +14,16 @@ var Cluster = Resource.extend(PolledResource, {
} }
}, },
_allProjects: null,
init() {
this._super(...arguments);
this.set('_allProjects', this.get('userStore').all('project'));
},
projects: function() {
return this.get('_allProjects').filterBy('clusterId', this.get('id'));
}.property('_allProjects.@each.clusterId'),
availableActions: function() { availableActions: function() {
// let a = this.get('actionLinks'); // let a = this.get('actionLinks');
let l = this.get('links'); let l = this.get('links');