mirror of https://github.com/rancher/ui.git
parent
2af8a5e489
commit
1e3b8ca24a
|
|
@ -10,22 +10,22 @@
|
|||
{{#if item.submenu.length}}
|
||||
{{! Has a submenu }}
|
||||
{{#hover-dropdown
|
||||
tagName="li"
|
||||
class="nav-item"
|
||||
as |dd|
|
||||
tagName="li"
|
||||
class="nav-item"
|
||||
as |dd|
|
||||
}}
|
||||
{{#dd.trigger}}
|
||||
{{#if (or (not item.resource) (rbac-allows resource=item.resource scope=item.resourceScope))}}
|
||||
{{#if item.route}}
|
||||
{{#link-to-as-attrs
|
||||
ourRoute=item.route
|
||||
ctx=item.ctx
|
||||
qp=item.qp
|
||||
currentWhen=item.currentWhen
|
||||
activeParent="LI"
|
||||
role="button"
|
||||
aria-haspopup="true"
|
||||
aria-expanded="false"
|
||||
ourRoute=item.route
|
||||
ctx=item.ctx
|
||||
qp=item.qp
|
||||
currentWhen=item.currentWhen
|
||||
activeParent="LI"
|
||||
role="button"
|
||||
aria-haspopup="true"
|
||||
aria-expanded="false"
|
||||
}}
|
||||
{{maybe-t item.localizedLabel item.label}}
|
||||
<span class="icon icon-chevron-down"/>
|
||||
|
|
@ -40,17 +40,17 @@
|
|||
{{/dd.trigger}}
|
||||
|
||||
{{#dd.content
|
||||
tagName="ul"
|
||||
tagName="ul"
|
||||
}}
|
||||
{{#each item.submenu as |subitem|}}
|
||||
{{#if subitem.route}}
|
||||
{{#if (or (not subitem.resource) (rbac-allows resource=subitem.resource scope=subitem.resourceScope))}}
|
||||
<li>
|
||||
{{#link-to-as-attrs
|
||||
ourRoute=subitem.route
|
||||
ctx=subitem.ctx
|
||||
qp=subitem.qp
|
||||
activeParent="LI"
|
||||
ourRoute=subitem.route
|
||||
ctx=subitem.ctx
|
||||
qp=subitem.qp
|
||||
activeParent="LI"
|
||||
}}
|
||||
<span>
|
||||
{{maybe-t subitem.localizedLabel subitem.label}}
|
||||
|
|
@ -80,12 +80,12 @@
|
|||
{{! No submenu }}
|
||||
<li class="nav-item">
|
||||
{{#link-to-as-attrs
|
||||
ourRoute=item.route
|
||||
ctx=item.ctx
|
||||
qp=item.qp
|
||||
activeParent="LI"
|
||||
currentWhen=item.currentWhen
|
||||
class="nav-link"
|
||||
ourRoute=item.route
|
||||
ctx=item.ctx
|
||||
qp=item.qp
|
||||
activeParent="LI"
|
||||
currentWhen=item.currentWhen
|
||||
class="nav-link"
|
||||
}}
|
||||
{{maybe-t item.localizedLabel item.label}}
|
||||
{{/link-to-as-attrs}}
|
||||
|
|
@ -134,8 +134,8 @@
|
|||
{{/dd.trigger}}
|
||||
|
||||
{{#dd.content
|
||||
class="text-right"
|
||||
tagName="ul"
|
||||
class="text-right"
|
||||
tagName="ul"
|
||||
}}
|
||||
{{#if accessEnabled}}
|
||||
<li role="presentation" class="user-auth">
|
||||
|
|
@ -146,30 +146,34 @@
|
|||
<li role="separator" class="divider"></li>
|
||||
<li>
|
||||
{{#link-to "authenticated.apikeys"}}
|
||||
<span>{{t "nav.api.link"}}</span>
|
||||
<i class="icon icon-key icon-fw"/>{{/link-to}}
|
||||
<span>{{t "nav.api.link"}}</span>
|
||||
<i class="icon icon-key icon-fw"/>{{/link-to}}
|
||||
</li>
|
||||
<li>
|
||||
{{#link-to "global-admin.security.cloud-keys"}}
|
||||
<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>
|
||||
{{#link-to "nodes.node-templates"}}
|
||||
<span>{{t "nav.nodeTemplates.link"}}</span>
|
||||
<i class="icon icon-host icon-fw"/>{{/link-to}}
|
||||
<span>{{t "nav.nodeTemplates.link"}}</span>
|
||||
<i class="icon icon-host icon-fw"/>
|
||||
{{/link-to}}
|
||||
</li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<li>
|
||||
{{#link-to "authenticated.prefs"}}
|
||||
<span>{{t "nav.userPreferences.link"}}</span>
|
||||
<i class="icon icon-gear icon-fw"/>{{/link-to}}
|
||||
<span>{{t "nav.userPreferences.link"}}</span>
|
||||
<i class="icon icon-gear icon-fw"/>
|
||||
{{/link-to}}
|
||||
</li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<li>
|
||||
{{#link-to "logout" class="user-logout"}}
|
||||
<span>{{t "nav.user.logout"}}</span>
|
||||
<i class="icon icon-logout icon-fw"/>{{/link-to}}
|
||||
<span>{{t "nav.user.logout"}}</span>
|
||||
<i class="icon icon-logout icon-fw"/>
|
||||
{{/link-to}}
|
||||
</li>
|
||||
{{/dd.content}}
|
||||
{{!-- </ul> --}}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ export default Component.extend(NewOrEdit, {
|
|||
errors: null,
|
||||
region: null,
|
||||
regionChoices: REGIONS,
|
||||
sinlgeCloudKeyChoice: null,
|
||||
|
||||
didReceiveAttrs() {
|
||||
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);
|
||||
|
||||
|
||||
next(() => {
|
||||
set(this, 'cloudKeyType', get(match, 'name'));
|
||||
setProperties(this, {
|
||||
cloudKeyType: get(match, 'name'),
|
||||
singleCloudKeyChoice: get(match, 'displayName'),
|
||||
});
|
||||
this.initCloudCredentialConfig();
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -18,24 +18,30 @@
|
|||
{{t "modalAddCloudKey.type"}}
|
||||
</label>
|
||||
|
||||
<select
|
||||
class="form-control"
|
||||
onchange={{action "selectConfig" value="target.value"}}
|
||||
>
|
||||
{{#if (not-eq cloudKeyType value)}}
|
||||
<option value="" selected=true >
|
||||
{{t "modalAddCloudKey.typeSelect.prompt"}}
|
||||
</option>
|
||||
{{/if}}
|
||||
{{#each configChoices as |choice|}}
|
||||
<option
|
||||
value="{{choice.name}}"
|
||||
selected={{eq choice.name cloudKeyType}}
|
||||
>
|
||||
{{choice.displayName}}
|
||||
</option>
|
||||
{{/each}}
|
||||
</select>
|
||||
{{#if singleCloudKeyChoice}}
|
||||
<div class="pt-10 pl-10">
|
||||
{{singleCloudKeyChoice}}
|
||||
</div>
|
||||
{{else}}
|
||||
<select
|
||||
class="form-control"
|
||||
onchange={{action "selectConfig" value="target.value"}}
|
||||
>
|
||||
{{#if (not-eq cloudKeyType value)}}
|
||||
<option value="" selected=true >
|
||||
{{t "modalAddCloudKey.typeSelect.prompt"}}
|
||||
</option>
|
||||
{{/if}}
|
||||
{{#each configChoices as |choice|}}
|
||||
<option
|
||||
value="{{choice.name}}"
|
||||
selected={{eq choice.name cloudKeyType}}
|
||||
>
|
||||
{{choice.displayName}}
|
||||
</option>
|
||||
{{/each}}
|
||||
</select>
|
||||
{{/if}}
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ import {
|
|||
import { alias } from '@ember/object/computed';
|
||||
import Component from '@ember/component';
|
||||
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 { inject as service } from '@ember/service';
|
||||
|
||||
|
|
@ -14,7 +12,6 @@ registerDisplayLocation(DRIVER, 'config.region');
|
|||
registerDisplaySize(DRIVER, 'config.size');
|
||||
|
||||
const DRIVER = 'digitalocean';
|
||||
const DIGITALOCEAN_API = 'api.digitalocean.com/v2';
|
||||
const VALID_IMAGES = [
|
||||
'rancheros',
|
||||
'centos-7-x64',
|
||||
|
|
@ -167,45 +164,4 @@ export default Component.extend(NodeDriver, {
|
|||
|
||||
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