mirror of https://github.com/rancher/ui.git
parent
2af8a5e489
commit
1e3b8ca24a
|
|
@ -152,24 +152,28 @@
|
||||||
<li>
|
<li>
|
||||||
{{#link-to "global-admin.security.cloud-keys"}}
|
{{#link-to "global-admin.security.cloud-keys"}}
|
||||||
<span>{{t "nav.admin.security.cloudKeys"}}</span>
|
<span>{{t "nav.admin.security.cloudKeys"}}</span>
|
||||||
<i class="icon icon-secrets icon-fw"/>{{/link-to}}
|
<i class="icon icon-secrets icon-fw"/>
|
||||||
|
{{/link-to}}
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
{{#link-to "nodes.node-templates"}}
|
{{#link-to "nodes.node-templates"}}
|
||||||
<span>{{t "nav.nodeTemplates.link"}}</span>
|
<span>{{t "nav.nodeTemplates.link"}}</span>
|
||||||
<i class="icon icon-host icon-fw"/>{{/link-to}}
|
<i class="icon icon-host icon-fw"/>
|
||||||
|
{{/link-to}}
|
||||||
</li>
|
</li>
|
||||||
<li role="separator" class="divider"></li>
|
<li role="separator" class="divider"></li>
|
||||||
<li>
|
<li>
|
||||||
{{#link-to "authenticated.prefs"}}
|
{{#link-to "authenticated.prefs"}}
|
||||||
<span>{{t "nav.userPreferences.link"}}</span>
|
<span>{{t "nav.userPreferences.link"}}</span>
|
||||||
<i class="icon icon-gear icon-fw"/>{{/link-to}}
|
<i class="icon icon-gear icon-fw"/>
|
||||||
|
{{/link-to}}
|
||||||
</li>
|
</li>
|
||||||
<li role="separator" class="divider"></li>
|
<li role="separator" class="divider"></li>
|
||||||
<li>
|
<li>
|
||||||
{{#link-to "logout" class="user-logout"}}
|
{{#link-to "logout" class="user-logout"}}
|
||||||
<span>{{t "nav.user.logout"}}</span>
|
<span>{{t "nav.user.logout"}}</span>
|
||||||
<i class="icon icon-logout icon-fw"/>{{/link-to}}
|
<i class="icon icon-logout icon-fw"/>
|
||||||
|
{{/link-to}}
|
||||||
</li>
|
</li>
|
||||||
{{/dd.content}}
|
{{/dd.content}}
|
||||||
{{!-- </ul> --}}
|
{{!-- </ul> --}}
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ export default Component.extend(NewOrEdit, {
|
||||||
errors: null,
|
errors: null,
|
||||||
region: null,
|
region: null,
|
||||||
regionChoices: REGIONS,
|
regionChoices: REGIONS,
|
||||||
|
sinlgeCloudKeyChoice: null,
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
set(this, 'model', this.globalStore.createRecord({ type: 'cloudCredential' }));
|
set(this, 'model', this.globalStore.createRecord({ type: 'cloudCredential' }));
|
||||||
|
|
@ -79,9 +80,11 @@ export default Component.extend(NewOrEdit, {
|
||||||
|
|
||||||
let match = CRED_CONFIG_CHOICES.findBy('driver', driverName);
|
let match = CRED_CONFIG_CHOICES.findBy('driver', driverName);
|
||||||
|
|
||||||
|
|
||||||
next(() => {
|
next(() => {
|
||||||
set(this, 'cloudKeyType', get(match, 'name'));
|
setProperties(this, {
|
||||||
|
cloudKeyType: get(match, 'name'),
|
||||||
|
singleCloudKeyChoice: get(match, 'displayName'),
|
||||||
|
});
|
||||||
this.initCloudCredentialConfig();
|
this.initCloudCredentialConfig();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,11 @@
|
||||||
{{t "modalAddCloudKey.type"}}
|
{{t "modalAddCloudKey.type"}}
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
{{#if singleCloudKeyChoice}}
|
||||||
|
<div class="pt-10 pl-10">
|
||||||
|
{{singleCloudKeyChoice}}
|
||||||
|
</div>
|
||||||
|
{{else}}
|
||||||
<select
|
<select
|
||||||
class="form-control"
|
class="form-control"
|
||||||
onchange={{action "selectConfig" value="target.value"}}
|
onchange={{action "selectConfig" value="target.value"}}
|
||||||
|
|
@ -36,6 +41,7 @@
|
||||||
</option>
|
</option>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</select>
|
</select>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,6 @@ import {
|
||||||
import { alias } from '@ember/object/computed';
|
import { alias } from '@ember/object/computed';
|
||||||
import Component from '@ember/component';
|
import Component from '@ember/component';
|
||||||
import NodeDriver, { registerDisplayLocation, registerDisplaySize } from 'shared/mixins/node-driver';
|
import NodeDriver, { registerDisplayLocation, registerDisplaySize } from 'shared/mixins/node-driver';
|
||||||
import fetch from '@rancher/ember-api-store/utils/fetch';
|
|
||||||
import { addQueryParam, addQueryParams } from 'shared/utils/util';
|
|
||||||
import layout from './template';
|
import layout from './template';
|
||||||
import { inject as service } from '@ember/service';
|
import { inject as service } from '@ember/service';
|
||||||
|
|
||||||
|
|
@ -14,7 +12,6 @@ registerDisplayLocation(DRIVER, 'config.region');
|
||||||
registerDisplaySize(DRIVER, 'config.size');
|
registerDisplaySize(DRIVER, 'config.size');
|
||||||
|
|
||||||
const DRIVER = 'digitalocean';
|
const DRIVER = 'digitalocean';
|
||||||
const DIGITALOCEAN_API = 'api.digitalocean.com/v2';
|
|
||||||
const VALID_IMAGES = [
|
const VALID_IMAGES = [
|
||||||
'rancheros',
|
'rancheros',
|
||||||
'centos-7-x64',
|
'centos-7-x64',
|
||||||
|
|
@ -167,45 +164,4 @@ export default Component.extend(NodeDriver, {
|
||||||
|
|
||||||
set(primaryResource, 'digitaloceanConfig', config);
|
set(primaryResource, 'digitaloceanConfig', config);
|
||||||
},
|
},
|
||||||
|
|
||||||
apiRequest(command, opt, out) {
|
|
||||||
opt = opt || {};
|
|
||||||
|
|
||||||
let url = `${ get(this, 'app.proxyEndpoint') }/`;
|
|
||||||
let cloudCredentialId = get(this, 'primaryResource.cloudCredentialId');
|
|
||||||
|
|
||||||
if ( opt.url ) {
|
|
||||||
url += opt.url.replace(/^http[s]?\/\//, '');
|
|
||||||
} else {
|
|
||||||
url += `${ DIGITALOCEAN_API }/${ command }`;
|
|
||||||
url = addQueryParam(url, 'per_page', opt.per_page || 100);
|
|
||||||
url = addQueryParams(url, opt.params || {});
|
|
||||||
}
|
|
||||||
|
|
||||||
return fetch(url, {
|
|
||||||
headers: {
|
|
||||||
'Accept': 'application/json',
|
|
||||||
'x-api-cattleauth-header': `Bearer credID=${ cloudCredentialId } passwordField=accessToken`,
|
|
||||||
},
|
|
||||||
}).then((res) => {
|
|
||||||
let body = res.body;
|
|
||||||
|
|
||||||
if ( out ) {
|
|
||||||
out[command].pushObjects(body[command]);
|
|
||||||
} else {
|
|
||||||
out = body;
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-paging
|
|
||||||
if ( body && body.links && body.links.pages && body.links.pages.next ) {
|
|
||||||
opt.url = body.links.pages.next;
|
|
||||||
|
|
||||||
return this.apiRequest(command, opt, out).then(() => {
|
|
||||||
return out;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue