From b3f85cfafd4a4ab6fb8d06ad596ff42e5adbd9ee Mon Sep 17 00:00:00 2001 From: GGGitBoy <1812041288@qq.com> Date: Fri, 27 Mar 2020 17:19:14 +0800 Subject: [PATCH] Update Aliyun-Driver --- .../components/driver-aliyunecs/component.js | 31 +++++++-- .../components/driver-aliyunecs/template.hbs | 66 ++++++++++++++----- translations/en-us.yaml | 6 +- translations/zh-hans.yaml | 8 ++- 4 files changed, 84 insertions(+), 27 deletions(-) diff --git a/lib/nodes/addon/components/driver-aliyunecs/component.js b/lib/nodes/addon/components/driver-aliyunecs/component.js index 81c498c97..34fb6b411 100644 --- a/lib/nodes/addon/components/driver-aliyunecs/component.js +++ b/lib/nodes/addon/components/driver-aliyunecs/component.js @@ -18,6 +18,7 @@ const OPT_DISK = [ ]; const DEFAULT_INSTANCE_TYPE = 'ecs.g5.large'; +const DEFAULT_INTERNET_CHARGE_TYPE = 'PayByBandwidth'; export default Component.extend(NodeDriver, { intl: service(), @@ -32,11 +33,22 @@ export default Component.extend(NodeDriver, { images: null, instanceTypes: null, - ecsClient: null, - step: 1, + showCustomApiEndpoint: false, + ecsClient: null, + step: 1, config: alias('model.aliyunecsConfig'), + init() { + this._super(...arguments); + if (!get(this, 'config.internetChargeType')) { + set(this, 'config.internetChargeType', DEFAULT_INTERNET_CHARGE_TYPE); + } + if (get(this, 'config.apiEndpoint')) { + set(this, 'showCustomApiEndpoint', true); + } + }, + actions: { alyLogin(cb) { setProperties(this, { @@ -299,6 +311,12 @@ export default Component.extend(NodeDriver, { } }), + showCustomApiEndpointDidChange: observer('showCustomApiEndpoint', function() { + if (!get(this, 'showCustomApiEndpoint')){ + set(this, 'config.apiEndpoint', ''); + } + }), + diskCategoryChoicesDidChange: observer('diskCategoryChoices.@each.value', function() { const systemDiskCategory = get(this, 'config.systemDiskCategory'); let found = get(this, 'diskCategoryChoices').findBy('value', systemDiskCategory); @@ -333,10 +351,11 @@ export default Component.extend(NodeDriver, { bootstrap() { const config = get(this, 'globalStore').createRecord({ - type: 'aliyunecsConfig', - accessKeySecret: '', - instanceType: DEFAULT_INSTANCE_TYPE, - ioOptimized: 'optimized', + type: 'aliyunecsConfig', + accessKeySecret: '', + instanceType: DEFAULT_INSTANCE_TYPE, + ioOptimized: 'optimized', + internetChargeType: DEFAULT_INTERNET_CHARGE_TYPE, }); set(this, 'model.engineInstallURL', 'http://dev-tool.oss-cn-shenzhen.aliyuncs.com/docker-install/1.13.1.sh'); diff --git a/lib/nodes/addon/components/driver-aliyunecs/template.hbs b/lib/nodes/addon/components/driver-aliyunecs/template.hbs index 16462c25d..ec3722e0b 100644 --- a/lib/nodes/addon/components/driver-aliyunecs/template.hbs +++ b/lib/nodes/addon/components/driver-aliyunecs/template.hbs @@ -54,15 +54,22 @@ {{t "nodeDriver.aliyunecs.apiEndpoint.label"}} {{#input-or-display - editable=(eq step 1) - value=config.apiEndpoint - }} - {{input - type="text" - class="form-control" + editable=(eq step 1) value=config.apiEndpoint - placeholder=(t "nodeDriver.aliyunecs.apiEndpoint.placeholder") - }} + }} + + {{#if showCustomApiEndpoint}} + + {{/if}} {{/input-or-display}} @@ -335,6 +342,21 @@ value=config.imageId }} +