Support add tags in AWS node template

https://github.com/rancher/rancher/issues/13069
This commit is contained in:
loganhz 2018-04-27 00:10:14 +08:00
parent 3aadeb1c87
commit 90e4e509b0
3 changed files with 38 additions and 1 deletions

View File

@ -1,6 +1,6 @@
import $ from 'jquery';
import { scheduleOnce } from '@ember/runloop';
import EmberObject, { computed, get, set, setProperties } from '@ember/object';
import EmberObject, { observer, computed, get, set, setProperties } from '@ember/object';
import { alias, equal } from '@ember/object/computed';
import { inject as service } from '@ember/service';
import Component from '@ember/component';
@ -169,6 +169,7 @@ export default Component.extend(NodeDriver, {
instanceTypes : INSTANCE_TYPES,
regionChoices : REGIONS,
step : 1,
tags : null,
bootstrap: function() {
let pref = get(this, 'prefs.amazonec2')||{};
@ -219,6 +220,17 @@ export default Component.extend(NodeDriver, {
selectedSecurityGroup : cur,
});
}
const tagsString = get(this, 'config.tags');
if( tagsString ) {
const array = tagsString.split(',');
const tags = {};
for (let i=0; i< array.length-1; i=i+2) {
tags[array[i]] = array[i+1];
}
debugger
set(this, 'tags', tags);
}
},
willDestroyElement: function() {
@ -508,4 +520,15 @@ export default Component.extend(NodeDriver, {
subnetById: function(id) {
return (get(this, 'allSubnets')||[]).filterBy('subnetId',id)[0];
},
tagsDidChange: observer('tags', function() {
const array = [];
const tags = get(this, 'tags') || {};
Object.keys(tags).forEach((key) => {
array.push(key);
array.push(tags[key]);
});
set(this, 'config.tags', array.join(','));
}),
});

View File

@ -282,6 +282,16 @@
</div>
{{/if}}
</div>
<div class="row">
<div class="col span-12">
{{form-key-value
addActionLabel="nodeDriver.amazonec2.tags.addActionLabel"
initialMap=tags
changed=(action (mut tags))
}}
</div>
</div>
{{/accordion-list-item}}
<div class="over-hr"><span>{{templateOptionsTitle}}</span></div>

View File

@ -4440,6 +4440,10 @@ nodeDriver:
defaultCreate: "Standard: Automatically create a <code>{groupName}</code> group"
next: "Next: Set Instance options"
loading: Loading Instance options...
tags:
addActionLabel: Add AWS Tag
valueLabel: Tags
placeholder: e.g. dev
instance:
title: 4. Instance
detail: Customize the EC2 Instance that will be created.