mirror of https://github.com/rancher/ui.git
parent
2af8a5e489
commit
1e3b8ca24a
|
|
@ -10,22 +10,22 @@
|
||||||
{{#if item.submenu.length}}
|
{{#if item.submenu.length}}
|
||||||
{{! Has a submenu }}
|
{{! Has a submenu }}
|
||||||
{{#hover-dropdown
|
{{#hover-dropdown
|
||||||
tagName="li"
|
tagName="li"
|
||||||
class="nav-item"
|
class="nav-item"
|
||||||
as |dd|
|
as |dd|
|
||||||
}}
|
}}
|
||||||
{{#dd.trigger}}
|
{{#dd.trigger}}
|
||||||
{{#if (or (not item.resource) (rbac-allows resource=item.resource scope=item.resourceScope))}}
|
{{#if (or (not item.resource) (rbac-allows resource=item.resource scope=item.resourceScope))}}
|
||||||
{{#if item.route}}
|
{{#if item.route}}
|
||||||
{{#link-to-as-attrs
|
{{#link-to-as-attrs
|
||||||
ourRoute=item.route
|
ourRoute=item.route
|
||||||
ctx=item.ctx
|
ctx=item.ctx
|
||||||
qp=item.qp
|
qp=item.qp
|
||||||
currentWhen=item.currentWhen
|
currentWhen=item.currentWhen
|
||||||
activeParent="LI"
|
activeParent="LI"
|
||||||
role="button"
|
role="button"
|
||||||
aria-haspopup="true"
|
aria-haspopup="true"
|
||||||
aria-expanded="false"
|
aria-expanded="false"
|
||||||
}}
|
}}
|
||||||
{{maybe-t item.localizedLabel item.label}}
|
{{maybe-t item.localizedLabel item.label}}
|
||||||
<span class="icon icon-chevron-down"/>
|
<span class="icon icon-chevron-down"/>
|
||||||
|
|
@ -40,17 +40,17 @@
|
||||||
{{/dd.trigger}}
|
{{/dd.trigger}}
|
||||||
|
|
||||||
{{#dd.content
|
{{#dd.content
|
||||||
tagName="ul"
|
tagName="ul"
|
||||||
}}
|
}}
|
||||||
{{#each item.submenu as |subitem|}}
|
{{#each item.submenu as |subitem|}}
|
||||||
{{#if subitem.route}}
|
{{#if subitem.route}}
|
||||||
{{#if (or (not subitem.resource) (rbac-allows resource=subitem.resource scope=subitem.resourceScope))}}
|
{{#if (or (not subitem.resource) (rbac-allows resource=subitem.resource scope=subitem.resourceScope))}}
|
||||||
<li>
|
<li>
|
||||||
{{#link-to-as-attrs
|
{{#link-to-as-attrs
|
||||||
ourRoute=subitem.route
|
ourRoute=subitem.route
|
||||||
ctx=subitem.ctx
|
ctx=subitem.ctx
|
||||||
qp=subitem.qp
|
qp=subitem.qp
|
||||||
activeParent="LI"
|
activeParent="LI"
|
||||||
}}
|
}}
|
||||||
<span>
|
<span>
|
||||||
{{maybe-t subitem.localizedLabel subitem.label}}
|
{{maybe-t subitem.localizedLabel subitem.label}}
|
||||||
|
|
@ -80,12 +80,12 @@
|
||||||
{{! No submenu }}
|
{{! No submenu }}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
{{#link-to-as-attrs
|
{{#link-to-as-attrs
|
||||||
ourRoute=item.route
|
ourRoute=item.route
|
||||||
ctx=item.ctx
|
ctx=item.ctx
|
||||||
qp=item.qp
|
qp=item.qp
|
||||||
activeParent="LI"
|
activeParent="LI"
|
||||||
currentWhen=item.currentWhen
|
currentWhen=item.currentWhen
|
||||||
class="nav-link"
|
class="nav-link"
|
||||||
}}
|
}}
|
||||||
{{maybe-t item.localizedLabel item.label}}
|
{{maybe-t item.localizedLabel item.label}}
|
||||||
{{/link-to-as-attrs}}
|
{{/link-to-as-attrs}}
|
||||||
|
|
@ -134,8 +134,8 @@
|
||||||
{{/dd.trigger}}
|
{{/dd.trigger}}
|
||||||
|
|
||||||
{{#dd.content
|
{{#dd.content
|
||||||
class="text-right"
|
class="text-right"
|
||||||
tagName="ul"
|
tagName="ul"
|
||||||
}}
|
}}
|
||||||
{{#if accessEnabled}}
|
{{#if accessEnabled}}
|
||||||
<li role="presentation" class="user-auth">
|
<li role="presentation" class="user-auth">
|
||||||
|
|
@ -146,30 +146,34 @@
|
||||||
<li role="separator" class="divider"></li>
|
<li role="separator" class="divider"></li>
|
||||||
<li>
|
<li>
|
||||||
{{#link-to "authenticated.apikeys"}}
|
{{#link-to "authenticated.apikeys"}}
|
||||||
<span>{{t "nav.api.link"}}</span>
|
<span>{{t "nav.api.link"}}</span>
|
||||||
<i class="icon icon-key icon-fw"/>{{/link-to}}
|
<i class="icon icon-key icon-fw"/>{{/link-to}}
|
||||||
</li>
|
</li>
|
||||||
<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,24 +18,30 @@
|
||||||
{{t "modalAddCloudKey.type"}}
|
{{t "modalAddCloudKey.type"}}
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<select
|
{{#if singleCloudKeyChoice}}
|
||||||
class="form-control"
|
<div class="pt-10 pl-10">
|
||||||
onchange={{action "selectConfig" value="target.value"}}
|
{{singleCloudKeyChoice}}
|
||||||
>
|
</div>
|
||||||
{{#if (not-eq cloudKeyType value)}}
|
{{else}}
|
||||||
<option value="" selected=true >
|
<select
|
||||||
{{t "modalAddCloudKey.typeSelect.prompt"}}
|
class="form-control"
|
||||||
</option>
|
onchange={{action "selectConfig" value="target.value"}}
|
||||||
{{/if}}
|
>
|
||||||
{{#each configChoices as |choice|}}
|
{{#if (not-eq cloudKeyType value)}}
|
||||||
<option
|
<option value="" selected=true >
|
||||||
value="{{choice.name}}"
|
{{t "modalAddCloudKey.typeSelect.prompt"}}
|
||||||
selected={{eq choice.name cloudKeyType}}
|
</option>
|
||||||
>
|
{{/if}}
|
||||||
{{choice.displayName}}
|
{{#each configChoices as |choice|}}
|
||||||
</option>
|
<option
|
||||||
{{/each}}
|
value="{{choice.name}}"
|
||||||
</select>
|
selected={{eq choice.name cloudKeyType}}
|
||||||
|
>
|
||||||
|
{{choice.displayName}}
|
||||||
|
</option>
|
||||||
|
{{/each}}
|
||||||
|
</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