Merge pull request #3341 from loganhz/workload-detail

Workload detail
This commit is contained in:
Vincent Fiduccia 2019-09-11 02:07:44 -07:00 committed by GitHub
commit 2ab9f42be3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 155 additions and 6 deletions

View File

@ -80,4 +80,12 @@
</div>
</div>
</div>
{{#accordion-list showExpandAll=false as | al expandFn |}}
{{form-related-workloads
workloads=model.workloads
expandAll=al.expandAll
expandFn=expandFn
}}
{{/accordion-list}}
</section>

View File

@ -45,7 +45,7 @@
</div>
</div>
<div class="box mt-10">
<div class="box mt-10 mb-20">
{{form-key-value
initialMap=primaryResource.data
allowEmptyValue=true
@ -58,6 +58,16 @@
}}
</div>
{{#accordion-list showExpandAll=false as | al expandFn |}}
{{#if isView}}
{{form-related-workloads
workloads=model.workloads
expandAll=al.expandAll
expandFn=expandFn
}}
{{/if}}
{{/accordion-list}}
{{#unless isView}}
{{top-errors errors=errors}}
{{save-cancel

View File

@ -167,6 +167,13 @@
<hr/>
{{#accordion-list showExpandAll=false as | al expandFn |}}
{{#if isView}}
{{form-related-workloads
workloads=model.workloads
expandAll=al.expandAll
expandFn=expandFn
}}
{{/if}}
{{#accordion-list-item
title=(t "cruPersistentVolume.customize.title")
detail=(t "cruPersistentVolume.customize.detail")

View File

@ -41,7 +41,7 @@
model=model
}}
<div class="box mt-10">
<div class="box mt-10 mb-20">
<label class="acc-label">
{{t "newSecret.values.label"}}
</label>
@ -57,6 +57,16 @@
}}
</div>
{{#accordion-list showExpandAll=false as | al expandFn |}}
{{#if isView}}
{{form-related-workloads
workloads=model.workloads
expandAll=al.expandAll
expandFn=expandFn
}}
{{/if}}
{{/accordion-list}}
{{#unless isView}}
{{top-errors errors=errors}}
{{save-cancel

View File

@ -0,0 +1,29 @@
import Component from '@ember/component';
import layout from './template';
import { headers } from 'ui/containers/index/controller'
import { set } from '@ember/object';
export default Component.extend({
layout,
classNames: ['accordion-wrapper'],
headers,
expandedInstances: null,
expandOnInit: false,
init() {
this._super(...arguments);
set(this, 'expandedInstances', []);
},
actions: {
toggleExpand(instId) {
let list = this.get('expandedInstances');
if ( list.includes(instId) ) {
list.removeObject(instId);
} else {
list.addObject(instId);
}
},
},
});

View File

@ -0,0 +1,41 @@
{{#accordion-list-item
title=(t "formRelatedWorkloads.title")
detail=(t "formRelatedWorkloads.detail")
expandAll=expandAll
expand=(action expandFn)
expandOnInit=expandOnInit
}}
{{#sortable-table
tableClassNames="double-rows"
classNames="grid sortable-table"
body=workloads
searchText=searchText
sortBy=sortBy
subRows=true
pagingLabel="pagination.workload"
headers=headers as |sortable kind inst dt|}}
{{#if (eq kind "row")}}
{{workload-row
model=inst
toggle=(action "toggleExpand")
expanded=(array-includes expandedInstances inst.id)
searchText=searchText
subMatches=sortable.subMatches
fullColspan=sortable.fullColspan
dt=dt
}}
{{else if (eq kind "nomatch")}}
<tr>
<td colspan="{{sortable.fullColspan}}" class="text-center text-muted lacsso pt-20 pb-20">
{{t "containersPage.table.noMatch"}}
</td>
</tr>
{{else if (eq kind "norows")}}
<tr>
<td colspan="{{sortable.fullColspan}}" class="text-center text-muted lacsso pt-20 pb-20">
{{t "formRelatedWorkloads.nodata"}}
</td>
</tr>
{{/if}}
{{/sortable-table}}
{{/accordion-list-item}}

View File

@ -6,9 +6,22 @@ import Resource from '@rancher/ember-api-store/models/resource';
export default Resource.extend({
router: service(),
intl: service(),
allWorkloads: service(),
state: 'active',
workloads: computed('allWorkloads.list.@each.volumes', 'allWorkloads.list.@each.containers', function() {
return (get(this, 'allWorkloads.list') || []).map((item) => item.obj).filter((workload) => {
if ( get(this, 'namespaceId') && get(workload, 'namespaceId') !== get(this, 'namespaceId')) {
return false;
}
const volume = (get(workload, 'volumes') || []).find((volume) => get(volume, 'secret.secretName') === get(this, 'name'));
const env = (get(workload, 'containers') || []).find((container) => (get(container, 'environmentFrom') || []).find((env) => get(env, 'source') === 'secret' && get(env, 'sourceName') === get(this, 'name')));
return volume || env;
});
}),
issuedDate: computed('issuedAt', function() {
return new Date(get(this, 'issuedAt'));
}),

View File

@ -14,6 +14,16 @@ export default Resource.extend({
namespace: reference('namespaceId', 'namespace', 'clusterStore'),
firstKey: alias('keys.firstObject'),
workloads: computed('namespace.workloads.@each.volumes', 'namespace.workloads.@each.containers', function() {
return (get(this, 'namespace.workloads') || []).filter((workload) => {
const volume = (get(workload, 'volumes') || []).find((volume) => get(volume, 'configMap.name') === get(this, 'name'));
const env = (get(workload, 'containers') || []).find((container) => (get(container, 'environmentFrom') || []).find((env) => get(env, 'source') === 'configMap' && get(env, 'sourceName') === get(this, 'name')));
return volume || env;
});
}),
keys: computed('data', function() {
return Object.keys(get(this, 'data') || {}).sort();
}),

View File

@ -13,6 +13,10 @@ var PersistentVolumeClaim = Resource.extend({
persistentVolume: reference('volumeId', 'persistentVolume', 'clusterStore'),
namespace: reference('namespaceId', 'namespace', 'clusterStore'),
workloads: computed('namespace.workloads.@each.volumes', function() {
return (get(this, 'namespace.workloads') || []).filter((workload) => (get(workload, 'volumes') || []).find((volume) => get(volume, 'persistentVolumeClaim.persistentVolumeClaimId') === get(this, 'id')));
}),
sizeBytes: computed('status.capacity.storage', function() {
const str = get(this, 'status.capacity.storage');

View File

@ -5,6 +5,7 @@ import Resource from '@rancher/ember-api-store/models/resource';
export default Resource.extend({
router: service(),
allWorkloads: service(),
state: 'active',
canClone: true,
@ -14,6 +15,18 @@ export default Resource.extend({
return Object.keys(get(this, 'data') || {}).sort();
}),
workloads: computed('allWorkloads.list.@each.volumes', 'allWorkloads.list.@each.containers', function() {
return (get(this, 'allWorkloads.list') || []).map((item) => item.obj).filter((workload) => {
if ( get(this, 'namespaceId') && get(workload, 'namespaceId') !== get(this, 'namespaceId')) {
return false;
}
const volume = (get(workload, 'volumes') || []).find((volume) => get(volume, 'secret.secretName') === get(this, 'name'));
const env = (get(workload, 'containers') || []).find((container) => (get(container, 'environmentFrom') || []).find((env) => get(env, 'source') === 'secret' && get(env, 'sourceName') === get(this, 'name')));
return volume || env;
});
}),
actions: {
edit() {
get(this, 'router').transitionTo('authenticated.project.secrets.detail.edit', get(this, 'id'));

View File

@ -5476,6 +5476,10 @@ formUserData:
formLabelsAnnotations:
title: Labels & Annotations
detail: Key/Value pairs that can be used to label/annotate containers and make scheduling decisions.
formRelatedWorkloads:
title: Related Workloads
detail: Workloads which are using it
nodata: No Related Workloads
formNodeTaints:
title: Taints
detail: Taints mark that the node should not accept any pods that do not tolerate the taints.