Latest changes from Harvester master - a537c1ae38eb7030542ac371f24ae3336cd9d422

Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
This commit is contained in:
Francesco Torchia
2024-10-23 17:01:40 +02:00
parent 2ca86930ad
commit 118aaf16b7
35 changed files with 1484 additions and 93 deletions
@@ -2,14 +2,15 @@
import Loading from '@shell/components/Loading';
import Masthead from '@shell/components/ResourceList/Masthead';
import ResourceTable from '@shell/components/ResourceTable';
import { SCHEMA } from '@shell/config/types';
import { allHash } from '@shell/utils/promise';
import FilterVMSchedule from '../components/FilterVMSchedule';
import { STATE, AGE, NAME, NAMESPACE } from '@shell/config/table-headers';
import { HCI } from '../types';
import { BACKUP_TYPE } from '../config/types';
import { defaultTableSortGenerationFn } from '@shell/components/ResourceTable.vue';
const schema = {
export const schema = {
id: HCI.VM_SNAPSHOT,
type: SCHEMA,
attributes: {
@@ -22,7 +23,7 @@ const schema = {
export default {
name: 'HarvesterListVMSnapshot',
components: {
ResourceTable, Loading, Masthead
ResourceTable, Loading, Masthead, FilterVMSchedule
},
async fetch() {
@@ -39,6 +40,7 @@ export default {
}
this.rows = hash.rows;
this.snapshots = hash.rows;
},
data() {
@@ -47,7 +49,9 @@ export default {
const resource = params.resource;
return {
rows: [],
rows: [],
snapshots: [],
searchSchedule: '',
resource,
};
},
@@ -63,19 +67,32 @@ export default {
labelKey: 'tableHeaders.targetVm',
value: 'attachVM',
align: 'left',
sort: 'attachVM',
formatter: 'AttachVMWithName'
},
{
name: 'backupCreatedFrom',
labelKey: 'harvester.tableHeaders.vmSchedule',
value: 'sourceSchedule',
sort: 'sourceSchedule',
formatter: 'BackupCreatedFrom',
},
{
name: 'readyToUse',
labelKey: 'tableHeaders.readyToUse',
value: 'status.readyToUse',
align: 'left',
align: 'center',
sort: 'status.readyToUse',
formatter: 'Checked',
},
AGE
];
},
getRawRows() {
return this.rows.filter(r => r.spec?.type === BACKUP_TYPE.SNAPSHOT);
},
schema() {
return schema;
},
@@ -85,9 +102,24 @@ export default {
},
filteredRows() {
return this.rows.filter(R => R.spec?.type !== BACKUP_TYPE.BACKUP);
return this.snapshots.filter(r => r.spec?.type !== BACKUP_TYPE.BACKUP);
},
},
methods: {
changeRows(filteredRows, searchSchedule) {
this['searchSchedule'] = searchSchedule;
this['snapshots'] = filteredRows;
},
sortGenerationFn() {
let base = defaultTableSortGenerationFn(this.schema, this.$store);
base += this.searchSchedule;
return base;
},
}
};
</script>
@@ -100,17 +132,23 @@ export default {
:type-display="typeDisplay"
:create-button-label="t('harvester.vmSnapshot.createText')"
/>
<ResourceTable
v-bind="$attrs"
:headers="headers"
:groupable="true"
:rows="filteredRows"
:schema="schema"
:sort-generation-fn="sortGenerationFn"
key-field="_key"
default-sort-by="age"
>
<template #more-header-middle>
<FilterVMSchedule
:rows="getRawRows"
@change-rows="changeRows"
/>
</template>
<template #col:name="{row}">
<td>
<span>
@@ -126,6 +164,6 @@ export default {
</span>
</td>
</template>
</resourcetable>
</ResourceTable>
</div>
</template>