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
@@ -6,34 +6,37 @@ import Masthead from '@shell/components/ResourceList/Masthead';
import ResourceTable from '@shell/components/ResourceTable';
import { STATE, AGE, NAME, NAMESPACE } from '@shell/config/table-headers';
import FilterVMSchedule from '../components/FilterVMSchedule';
import { HCI } from '../types';
import { allSettled } from '../utils/promise';
import { BACKUP_TYPE } from '../config/types';
import { defaultTableSortGenerationFn } from '@shell/components/ResourceTable.vue';
export default {
name: 'HarvesterListBackup',
components: {
ResourceTable, Banner, Loading, Masthead, MessageLink
ResourceTable, Banner, Loading, Masthead, MessageLink, FilterVMSchedule
},
props: {
schema: {
type: Object,
required: true,
}
},
},
async fetch() {
const inStore = this.$store.getters['currentProduct'].inStore;
const hash = await allSettled({
vms: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.VM }),
settings: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.SETTING }),
rows: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.BACKUP }),
vms: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.VM }),
settings: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.SETTING }),
backups: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.BACKUP }),
scheduleList: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.SCHEDULE_VM_BACKUP }),
});
this.rows = hash.rows;
this.backups = hash.backups;
this.rows = hash.backups;
this.settings = hash.settings;
if (this.$store.getters[`${ inStore }/schemaFor`](HCI.SETTING)) {
const backupTargetResource = hash.settings.find( O => O.id === 'backup-target');
const isEmpty = this.getBackupTargetValueIsEmpty(backupTargetResource);
@@ -50,10 +53,12 @@ export default {
const resource = params.resource;
return {
rows: [],
settings: [],
rows: [],
backups: [],
settings: [],
resource,
to: `${ HCI.SETTING }/backup-target?mode=edit`,
to: `${ HCI.SETTING }/backup-target?mode=edit`,
searchSchedule: ''
};
},
@@ -85,7 +90,25 @@ export default {
}
return out;
}
},
getRow(row) {
return row.status && row.status.source;
},
changeRows(filteredRows, searchSchedule) {
this[searchSchedule] = searchSchedule;
this[backups] = filteredRows;
},
sortGenerationFn() {
let base = defaultTableSortGenerationFn(this.schema, this.$store);
base += this.searchSchedule;
return base;
},
},
computed: {
@@ -101,6 +124,12 @@ export default {
align: 'left',
formatter: 'AttachVMWithName'
},
{
name: 'backupCreatedFrom',
labelKey: 'harvester.tableHeaders.vmSchedule',
value: 'sourceSchedule',
formatter: 'BackupCreatedFrom',
},
{
name: 'backupTarget',
labelKey: 'tableHeaders.backupTarget',
@@ -112,7 +141,7 @@ export default {
name: 'readyToUse',
labelKey: 'tableHeaders.readyToUse',
value: 'status.readyToUse',
align: 'left',
align: 'center',
formatter: 'Checked',
},
];
@@ -124,25 +153,24 @@ export default {
value: 'backupProgress',
align: 'left',
formatter: 'HarvesterBackupProgressBar',
width: 200,
});
}
cols.push(AGE);
return cols;
},
hasBackupProgresses() {
return !!this.rows.find(R => R.status?.progress !== undefined);
return !!this.backups.find(r => r.status?.progress !== undefined);
},
filteredRows() {
return this.rows.filter(R => R.spec?.type !== BACKUP_TYPE.SNAPSHOT);
return this.backups.filter(r => r.spec?.type !== BACKUP_TYPE.SNAPSHOT);
},
getRawRows() {
return this.rows.filter(r => r.spec?.type === BACKUP_TYPE.BACKUP);
},
backupTargetResource() {
return this.settings.find( O => O.id === 'backup-target');
return this.settings.find(O => O.id === 'backup-target');
},
isEmptyValue() {
@@ -211,16 +239,22 @@ export default {
:headers="headers"
:groupable="true"
:rows="filteredRows"
:sort-generation-fn="sortGenerationFn"
:schema="schema"
key-field="_key"
default-sort-by="age"
>
<template #more-header-middle>
<FilterVMSchedule
:rows="getRawRows"
@change-rows="changeRows"
/>
</template>
<template #col:name="{row}">
<td>
<span>
<router-link
v-if="row.status && row.status.source"
v-if="getRow(row)"
:to="row.detailLocation"
>
{{ row.nameDisplay }}