mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2025-12-13 21:21:44 +00:00
add lock icon in VM list page
This commit is contained in:
parent
d06f0ec989
commit
6ce99fad1f
@ -63,10 +63,7 @@ export default {
|
|||||||
|
|
||||||
imageName() {
|
imageName() {
|
||||||
const imageList = this.$store.getters['harvester/all'](HCI.IMAGE) || [];
|
const imageList = this.$store.getters['harvester/all'](HCI.IMAGE) || [];
|
||||||
|
const image = imageList.find( I => this.value.rootImageId === I.id);
|
||||||
const image = imageList.find( (I) => {
|
|
||||||
return this.value.rootImageId === I.id;
|
|
||||||
});
|
|
||||||
|
|
||||||
return image?.spec?.displayName || 'N/A';
|
return image?.spec?.displayName || 'N/A';
|
||||||
},
|
},
|
||||||
|
|||||||
@ -640,6 +640,10 @@ harvester:
|
|||||||
userTips: The user to be added must already exist; otherwise, the credentials will not take effect.
|
userTips: The user to be added must already exist; otherwise, the credentials will not take effect.
|
||||||
duplicatedUser: User already exists.
|
duplicatedUser: User already exists.
|
||||||
invalidUser: Invalid Username.
|
invalidUser: Invalid Username.
|
||||||
|
lockIconTooltip:
|
||||||
|
image: Image encrypted
|
||||||
|
volume: Volume encrypted
|
||||||
|
both: Image encrypted and volume encrypted
|
||||||
input:
|
input:
|
||||||
name: Name
|
name: Name
|
||||||
memory: Memory
|
memory: Memory
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import ResourceTable from '@shell/components/ResourceTable';
|
import ResourceTable from '@shell/components/ResourceTable';
|
||||||
import LinkDetail from '@shell/components/formatter/LinkDetail';
|
|
||||||
|
|
||||||
import { STATE, AGE, NAME, NAMESPACE } from '@shell/config/table-headers';
|
import { STATE, AGE, NAME, NAMESPACE } from '@shell/config/table-headers';
|
||||||
import { NODE, POD } from '@shell/config/types';
|
import { PVC, PV, NODE, POD } from '@shell/config/types';
|
||||||
|
|
||||||
import { allHash } from '@shell/utils/promise';
|
import { allHash } from '@shell/utils/promise';
|
||||||
import Loading from '@shell/components/Loading';
|
import Loading from '@shell/components/Loading';
|
||||||
@ -60,7 +58,6 @@ export default {
|
|||||||
components: {
|
components: {
|
||||||
Loading,
|
Loading,
|
||||||
HarvesterVmState,
|
HarvesterVmState,
|
||||||
LinkDetail,
|
|
||||||
ConsoleBar,
|
ConsoleBar,
|
||||||
ResourceTable
|
ResourceTable
|
||||||
},
|
},
|
||||||
@ -77,6 +74,9 @@ export default {
|
|||||||
const _hash = {
|
const _hash = {
|
||||||
vms: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.VM }),
|
vms: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.VM }),
|
||||||
pod: this.$store.dispatch(`${ inStore }/findAll`, { type: POD }),
|
pod: this.$store.dispatch(`${ inStore }/findAll`, { type: POD }),
|
||||||
|
pvcs: this.$store.dispatch(`${ inStore }/findAll`, { type: PVC }),
|
||||||
|
pvs: this.$store.dispatch(`${ inStore }/findAll`, { type: PV }),
|
||||||
|
images: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.IMAGE }),
|
||||||
restore: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.RESTORE }),
|
restore: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.RESTORE }),
|
||||||
backups: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.BACKUP }),
|
backups: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.BACKUP }),
|
||||||
};
|
};
|
||||||
@ -169,6 +169,20 @@ export default {
|
|||||||
await this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.VMIM });
|
await this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.VMIM });
|
||||||
|
|
||||||
this['allVMIs'] = vmis;
|
this['allVMIs'] = vmis;
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
lockIconTooltipMessage(row) {
|
||||||
|
if (row.isVMImageEncrypted && row.isVolumeEncrypted) {
|
||||||
|
return this.t('harvester.virtualMachine.lockIconTooltip.both');
|
||||||
|
} else if (row.isVMImageEncrypted) {
|
||||||
|
return this.t('harvester.virtualMachine.lockIconTooltip.image');
|
||||||
|
} else if (row.isVolumeEncrypted) {
|
||||||
|
return this.t('harvester.virtualMachine.lockIconTooltip.volume');
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@ -194,11 +208,16 @@ export default {
|
|||||||
|
|
||||||
<template cell:name="scope">
|
<template cell:name="scope">
|
||||||
<div class="name-console">
|
<div class="name-console">
|
||||||
<LinkDetail v-if="scope.row.type !== HCI.VMI" v-model:value="scope.row.metadata.name" :row="scope.row" />
|
<router-link
|
||||||
|
v-if="scope.row.type !== HCI.VMI"
|
||||||
|
:to="scope.row.detailLocation"
|
||||||
|
>
|
||||||
|
{{ scope.row.metadata.name }}
|
||||||
|
<i v-if="lockIconTooltipMessage(scope.row)" v-tooltip="lockIconTooltipMessage(scope.row)" class="icon icon-lock" />
|
||||||
|
</router-link>
|
||||||
<span v-else>
|
<span v-else>
|
||||||
{{ scope.row.metadata.name }}
|
{{ scope.row.metadata.name }}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<ConsoleBar :resource="scope.row" class="console mr-10 ml-10" />
|
<ConsoleBar :resource="scope.row" class="console mr-10 ml-10" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -214,11 +214,7 @@ export default class HciPv extends HarvesterResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get isEncrypted() {
|
get isEncrypted() {
|
||||||
const inStore = this.$rootGetters['currentProduct'].inStore;
|
return this.relatedPV?.spec.csi.volumeAttributes.encrypted || false;
|
||||||
|
|
||||||
const longhornVolume = this.$rootGetters[`${ inStore }/all`](LONGHORN.VOLUMES).find(v => v.metadata?.name === this.spec?.volumeName);
|
|
||||||
|
|
||||||
return longhornVolume?.spec.encrypted || false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get longhornVolume() {
|
get longhornVolume() {
|
||||||
|
|||||||
@ -574,6 +574,29 @@ export default class VirtVm extends HarvesterResource {
|
|||||||
return vmis.find(VMI => VMI.id === this.id);
|
return vmis.find(VMI => VMI.id === this.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isVMImageEncrypted() {
|
||||||
|
const inStore = this.productInStore;
|
||||||
|
const imageList = this.$rootGetters[`${ inStore }/all`](HCI.IMAGE);
|
||||||
|
const rootImage = imageList.find(image => this.rootImageId === image.id);
|
||||||
|
|
||||||
|
return rootImage?.isEncrypted || false;
|
||||||
|
}
|
||||||
|
|
||||||
|
get isVolumeEncrypted() {
|
||||||
|
const inStore = this.productInStore;
|
||||||
|
const pvcs = this.$rootGetters[`${ inStore }/all`](PVC);
|
||||||
|
|
||||||
|
// filter out the root image PVC
|
||||||
|
const nonRootImagePVCs = pvcs.filter(pvc => !pvc.metadata.annotations[HCI_ANNOTATIONS.IMAGE_ID]);
|
||||||
|
|
||||||
|
const volumeClaimNames = this.spec.template.spec.volumes?.map(v => v.persistentVolumeClaim?.claimName).map(v => v) || [];
|
||||||
|
|
||||||
|
const pvcVolumes = nonRootImagePVCs.filter(pvc => volumeClaimNames.includes(pvc.metadata.name));
|
||||||
|
|
||||||
|
// if any non-rootImage PCV volume is encrypted, return true, otherwise return false
|
||||||
|
return pvcVolumes.some(pvcVol => pvcVol.isEncrypted) ;
|
||||||
|
}
|
||||||
|
|
||||||
get isError() {
|
get isError() {
|
||||||
const conditions = get(this.vmi, 'status.conditions');
|
const conditions = get(this.vmi, 'status.conditions');
|
||||||
const vmiFailureCond = findBy(conditions, 'type', 'Failure');
|
const vmiFailureCond = findBy(conditions, 'type', 'Failure');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user