mirror of https://github.com/rancher/ui.git
Add new logic for service question types
This commit is contained in:
parent
3c7ad0e462
commit
c4bed1f445
|
|
@ -8,7 +8,7 @@ export default Ember.Component.extend(NewOrEdit, {
|
|||
templateResource: Ember.computed.alias('originalModel'),
|
||||
primaryResource: Ember.computed.alias('environmentResource'),
|
||||
editing: Ember.computed.notEmpty('primaryResource.id'),
|
||||
|
||||
allServicesService: Ember.inject.service('all-services'),
|
||||
actions: {
|
||||
cancel: function() {
|
||||
this.sendAction('dismiss');
|
||||
|
|
@ -34,6 +34,7 @@ export default Ember.Component.extend(NewOrEdit, {
|
|||
questionsArray: null,
|
||||
selectedTemplate: null,
|
||||
selectedTemplateModel: null,
|
||||
services: null,
|
||||
loading: false,
|
||||
previewOpen: false,
|
||||
|
||||
|
|
@ -58,6 +59,7 @@ export default Ember.Component.extend(NewOrEdit, {
|
|||
{
|
||||
this.set('selectedTemplateUrl', links[def]);
|
||||
}
|
||||
this.set('services', []);
|
||||
}),
|
||||
|
||||
templateChanged: function() {
|
||||
|
|
@ -77,7 +79,37 @@ export default Ember.Component.extend(NewOrEdit, {
|
|||
}
|
||||
else
|
||||
{
|
||||
item.answer = item.default;
|
||||
if (item.type === 'service') {
|
||||
this.set('loadingServices', true);
|
||||
// We need to check a stack/service exists that corresponds to the items default value
|
||||
// if so we can set the default of the drop down
|
||||
// if not we set the drop down to null and the user has to select one
|
||||
var dependencies = [
|
||||
this.get('allServicesService').choices(),
|
||||
];
|
||||
|
||||
Ember.RSVP.all(dependencies, 'Load container dependencies').then((results) => {
|
||||
var defaultStack = false;
|
||||
|
||||
results[0].forEach((stack) => {
|
||||
stack.stack = `${this.get('store').getById('environment', stack.obj.environmentId).name}/${stack.name}`;
|
||||
if (item.default === stack.stack) {
|
||||
defaultStack = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (defaultStack) {
|
||||
item.answer = item.default;
|
||||
} else {
|
||||
item.answer = null;
|
||||
}
|
||||
|
||||
this.set('services', results[0]);
|
||||
this.set('loadingServices', false);
|
||||
});
|
||||
} else {
|
||||
item.answer = item.default;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,22 @@
|
|||
{{#if (eq question.type "multiline")}}
|
||||
{{textarea value=question.answer rows="5" class="form-control"}}
|
||||
{{else}}
|
||||
Unknown question type: {{question.type}}
|
||||
{{#if (eq question.type 'service')}}
|
||||
{{#if loadingServices}}
|
||||
<i class="fa fa-spinner fa-spin" style="font-size:36px;"></i>
|
||||
{{else}}
|
||||
{{display-name-select
|
||||
classNames="form-control"
|
||||
content=services
|
||||
prompt="Choose a Service"
|
||||
optionLabelPath="content.stack"
|
||||
optionValuePath="content.stack"
|
||||
optionGroupPath="group"
|
||||
value=question.answer}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
Unknown question type: {{question.type}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,11 @@
|
|||
<h2>Adding your first Service</h2>
|
||||
<p>
|
||||
A service is simply a group of containers created from the same Docker image but extends Docker's "link" concept to leverage Rancher's lightweight distributed DNS service for service discovery.
|
||||
Services can be added individually or by deploying an item from the Catalog.
|
||||
A service is also capable of leveraging other Rancher built-in services such as load balancers, health monitoring, upgrade support, and high-availability.
|
||||
<a href="http://docs.rancher.com/rancher/rancher-ui/applications/stacks/adding-services/" target="_blank">Learn More</a>
|
||||
</p>
|
||||
{{#link-to "service.new" (query-params environmentId=model.environmentId) class="btn btn-default"}}Add Service{{/link-to}}
|
||||
{{#link-to "applications-tab.catalog" "all" class="btn btn-default"}}Add From Catalog{{/link-to}}
|
||||
</section>
|
||||
{{/unless}}
|
||||
|
|
|
|||
Loading…
Reference in New Issue