forked from rancher/dashboard
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1103 from a110605/issue-6058
Add VM schedules pages
- Loading branch information
Showing
33 changed files
with
1,470 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<script> | ||
import { RadioGroup } from '@components/Form/Radio'; | ||
export default { | ||
name: 'HarvesterFilterVMSchedule', | ||
components: { RadioGroup }, | ||
props: { | ||
rows: { | ||
type: Array, | ||
required: true, | ||
}, | ||
}, | ||
data() { | ||
return { selected: '' }; | ||
}, | ||
computed: { | ||
scheduleOptions() { | ||
const options = this.rows.map(r => r.sourceSchedule).filter(r => r); | ||
return Array.from(new Set(options)); | ||
}, | ||
}, | ||
methods: { | ||
onSelect(selected) { | ||
this.selected = selected; | ||
this.filterRows(); | ||
}, | ||
remove() { | ||
this.selected = ''; | ||
this.filterRows(); | ||
}, | ||
filterRows() { | ||
if (!this.selected) { | ||
this.$emit('change-rows', this.rows); | ||
return; | ||
} | ||
const filteredRows = this.rows.filter(row => row.sourceSchedule === this.selected); | ||
this.$emit('change-rows', filteredRows, this.selected); | ||
} | ||
}, | ||
watch: { | ||
rows: { | ||
deep: true, | ||
immediate: false, | ||
handler() { | ||
this.filterRows(); | ||
} | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<template> | ||
<div class="vm-schedule-filter"> | ||
<template> | ||
<span v-if="selected" class="banner-item bg-warning"> | ||
{{ t('harvester.tableHeaders.vmSchedule') }}{{ selected ? ` = ${selected}`: '' }}<i class="icon icon-close ml-5" @click="remove" /> | ||
</span> | ||
</template> | ||
|
||
<v-popover | ||
:trigger="scheduleOptions.length ? 'click' : 'manual'" | ||
placement="bottom-end" | ||
> | ||
<slot name="header"> | ||
<button ref="actionDropDown" class="btn bg-primary mr-10"> | ||
<slot name="title"> | ||
{{ t('harvester.fields.filterSchedule') }} | ||
</slot> | ||
</button> | ||
</slot> | ||
<template slot="popover"> | ||
<div class="filter-popup"> | ||
<RadioGroup | ||
v-model="selected" | ||
class="mr-10 ml-10" | ||
name="model" | ||
:options="scheduleOptions" | ||
:labels="scheduleOptions" | ||
@input="onSelect" | ||
/> | ||
</div> | ||
</template> | ||
</v-popover> | ||
</div> | ||
</template> | ||
|
||
<style lang="scss" scoped> | ||
.vm-schedule-filter { | ||
display: inline-block; | ||
.banner-item { | ||
display: inline-block; | ||
font-size: 16px; | ||
margin-right: 10px; | ||
padding: 6px; | ||
border-radius: 2px; | ||
i { | ||
cursor: pointer; | ||
vertical-align: middle; | ||
} | ||
} | ||
} | ||
.filter-popup { | ||
width: max-content; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
pkg/harvester/detail/harvesterhci.io.schedulevmbackup/BackupList.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<script> | ||
import ResourceTable from '@shell/components/ResourceTable'; | ||
import { STATE, NAME, AGE } from '@shell/config/table-headers'; | ||
import { allSettled } from '../../utils/promise'; | ||
import { BACKUP_TYPE } from '../../config/types'; | ||
import { HCI } from '../../types'; | ||
import { HCI as HCI_ANNOTATIONS } from '@pkg/harvester/config/labels-annotations'; | ||
export default { | ||
name: 'BackupList', | ||
components: { ResourceTable }, | ||
props: { | ||
id: { | ||
type: String, | ||
required: true, | ||
}, | ||
}, | ||
async fetch() { | ||
const inStore = this.$store.getters['currentProduct'].inStore; | ||
const hash = await allSettled({ backups: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.BACKUP }) }); | ||
this.rows = hash.backups; | ||
}, | ||
data() { | ||
const inStore = this.$store.getters['currentProduct'].inStore; | ||
const schema = this.$store.getters[`${ inStore }/schemaFor`](HCI.BACKUP); | ||
return { | ||
rows: [], | ||
schema | ||
}; | ||
}, | ||
computed: { | ||
headers() { | ||
const cols = [ | ||
STATE, | ||
{ | ||
...NAME, | ||
width: 400 | ||
}, | ||
{ | ||
name: 'targetVM', | ||
labelKey: 'tableHeaders.targetVm', | ||
value: 'attachVM', | ||
align: 'left', | ||
sort: 'attachVM', | ||
formatter: 'AttachVMWithName' | ||
}, | ||
{ | ||
name: 'backupTarget', | ||
labelKey: 'tableHeaders.backupTarget', | ||
value: 'backupTarget', | ||
sort: 'backupTarget', | ||
align: 'left', | ||
formatter: 'HarvesterBackupTargetValidation' | ||
}, | ||
{ | ||
name: 'readyToUse', | ||
labelKey: 'tableHeaders.readyToUse', | ||
value: 'status.readyToUse', | ||
sort: 'status.readyToUse', | ||
align: 'center', | ||
formatter: 'Checked', | ||
}, | ||
]; | ||
if (this.hasBackupProgresses) { | ||
cols.push({ | ||
name: 'backupProgress', | ||
labelKey: 'tableHeaders.progress', | ||
value: 'backupProgress', | ||
sort: 'backupProgress', | ||
align: 'left', | ||
formatter: 'HarvesterBackupProgressBar', | ||
}); | ||
} | ||
cols.push(AGE); | ||
return cols; | ||
}, | ||
hasBackupProgresses() { | ||
return !!this.rows.find(R => R.status?.progress !== undefined); | ||
}, | ||
filteredRows() { | ||
let r = this.rows.filter(row => row.spec?.type === BACKUP_TYPE.BACKUP); | ||
if (this.id) { | ||
r = r.filter(backup => backup.metadata.annotations?.[HCI_ANNOTATIONS.SVM_BACKUP_ID] === this.id); | ||
} | ||
return r; | ||
}, | ||
}, | ||
}; | ||
</script> | ||
<template> | ||
<ResourceTable | ||
v-bind="$attrs" | ||
:headers="headers" | ||
:groupable="false" | ||
:rows="filteredRows" | ||
:schema="schema" | ||
key-field="_key" | ||
default-sort-by="age" | ||
v-on="$listeners" | ||
> | ||
<template #col:name="{row}"> | ||
<td> | ||
<span> | ||
<n-link | ||
v-if="row?.status?.source" | ||
:to="row.detailLocation" | ||
> | ||
{{ row.nameDisplay }} | ||
</n-link> | ||
<span v-else> | ||
{{ row.nameDisplay }} | ||
</span> | ||
</span> | ||
</td> | ||
</template> | ||
</ResourceTable> | ||
</template> |
Oops, something went wrong.