mirror of https://github.com/rancher/ui.git
concurrency change
This commit is contained in:
parent
5f88b591b0
commit
426fbdf653
|
|
@ -4,6 +4,8 @@ import ShellQuote from 'npm:shell-quote';
|
||||||
import C from 'ui/utils/constants';
|
import C from 'ui/utils/constants';
|
||||||
import Util from 'ui/utils/util';
|
import Util from 'ui/utils/util';
|
||||||
import { compare as compareVersion } from 'ui/utils/parse-version';
|
import { compare as compareVersion } from 'ui/utils/parse-version';
|
||||||
|
import { task } from 'ember-concurrency';
|
||||||
|
|
||||||
|
|
||||||
export default Ember.Component.extend(NewOrEdit, {
|
export default Ember.Component.extend(NewOrEdit, {
|
||||||
intl: Ember.inject.service(),
|
intl: Ember.inject.service(),
|
||||||
|
|
@ -112,7 +114,7 @@ export default Ember.Component.extend(NewOrEdit, {
|
||||||
return null;
|
return null;
|
||||||
}.property('templateResource.defaultVersion','versionLinks'),
|
}.property('templateResource.defaultVersion','versionLinks'),
|
||||||
|
|
||||||
templateChanged: function() {
|
getTemplate: task(function * () {
|
||||||
var url = this.get('selectedTemplateUrl');
|
var url = this.get('selectedTemplateUrl');
|
||||||
|
|
||||||
if ( url === 'default' ) {
|
if ( url === 'default' ) {
|
||||||
|
|
@ -125,20 +127,20 @@ export default Ember.Component.extend(NewOrEdit, {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
this.set('loading', true);
|
|
||||||
|
|
||||||
var version = this.get('settings.rancherVersion');
|
var version = this.get('settings.rancherVersion');
|
||||||
|
|
||||||
if ( version ) {
|
if ( version ) {
|
||||||
url = Util.addQueryParam(url, 'rancherVersion', version);
|
url = Util.addQueryParam(url, 'rancherVersion', version);
|
||||||
}
|
}
|
||||||
|
|
||||||
var current = this.get('stackResource.environment');
|
var current = this.get('stackResource.environment');
|
||||||
|
|
||||||
if ( !current ) {
|
if ( !current ) {
|
||||||
current = {};
|
current = {};
|
||||||
this.set('stackResource.environment', current);
|
this.set('stackResource.environment', current);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.get('store').request({
|
var selectedTemplateModel = yield this.get('store').request({
|
||||||
url: url
|
url: url
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
if (response.questions) {
|
if (response.questions) {
|
||||||
|
|
@ -162,18 +164,23 @@ export default Ember.Component.extend(NewOrEdit, {
|
||||||
item.answer = item.default;
|
item.answer = item.default;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.set('selectedTemplateModel', response);
|
});
|
||||||
this.set('previewTab', Object.keys(response.get('files')||[])[0]);
|
|
||||||
this.updateReadme();
|
this.set('selectedTemplateModel', selectedTemplateModel);
|
||||||
this.set('loading', false);
|
this.set('previewTab', Object.keys(selectedTemplateModel.get('files')||[])[0]);
|
||||||
}, ( /*error*/ ) => {});
|
|
||||||
} else {
|
} else {
|
||||||
this.set('selectedTemplateModel', null);
|
this.set('selectedTemplateModel', null);
|
||||||
this.updateReadme();
|
|
||||||
this.set('readmeContent', null);
|
this.set('readmeContent', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.updateReadme();
|
||||||
|
}),
|
||||||
|
|
||||||
|
templateChanged: function() {
|
||||||
|
this.get('getTemplate').perform();
|
||||||
}.observes('selectedTemplateUrl','templateResource.defaultVersion'),
|
}.observes('selectedTemplateUrl','templateResource.defaultVersion'),
|
||||||
|
|
||||||
answers: function() {
|
answers: function() {
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@
|
||||||
optionLabelPath="version"
|
optionLabelPath="version"
|
||||||
optionValuePath="link"
|
optionValuePath="link"
|
||||||
value=selectedTemplateUrl
|
value=selectedTemplateUrl
|
||||||
disabled=loading
|
disabled=getTemplate.isRunning
|
||||||
}}
|
}}
|
||||||
<p class="text-info">{{t (if editing selectVersionUpgrade selectVersionAdd)}}</p>
|
<p class="text-info">{{t (if editing selectVersionUpgrade selectVersionAdd)}}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -84,14 +84,14 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<section class="{{sectionClass}}">
|
<section class="{{sectionClass}}">
|
||||||
{{#if loading}}
|
{{#if getTemplate.isRunning}}
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<i class="icon icon-spinner icon-spin" style="font-size:36px;"></i>
|
<i class="icon icon-spinner icon-spin" style="font-size:36px;"></i>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if selectedTemplateModel}}
|
{{#if selectedTemplateModel}}
|
||||||
<form {{action "submitTemplate" on="submit"}} class="{{if loading 'hide'}}">
|
<form {{action "submitTemplate" on="submit"}} class="{{if getTemplate.isRunning 'hide'}}">
|
||||||
<h4>{{t 'newCatalog.config'}}</h4>
|
<h4>{{t 'newCatalog.config'}}</h4>
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
||||||
|
|
@ -126,7 +126,7 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{{#if (and selectedTemplateModel (not loading))}}
|
{{#if (and selectedTemplateModel (not getTemplate.isRunning))}}
|
||||||
{{#if showPreview}}
|
{{#if showPreview}}
|
||||||
<section>
|
<section>
|
||||||
<div class="over-hr"><span {{action "togglePreview"}}>{{t 'newCatalog.preview'}} <i class="icon {{if previewOpen 'icon-chevron-up' 'icon-chevron-down'}}"></i></span></div>
|
<div class="over-hr"><span {{action "togglePreview"}}>{{t 'newCatalog.preview'}} <i class="icon {{if previewOpen 'icon-chevron-up' 'icon-chevron-down'}}"></i></span></div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue