This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nezha-nezha-fronted/nezha-fronted/src/components/page/config/backups.vue

195 lines
5.0 KiB
Vue
Raw Normal View History

<template>
2022-05-26 16:32:20 +08:00
<div class="system backup">
2022-04-08 18:02:57 +08:00
<div class="system-config-form system-config-backup">
<div class="system-title">{{ $t("backup.configurations") }}</div>
<nz-data-list
ref="dataList"
id="modelTable"
:data="tableData"
border
from="backups"
>
<template v-slot="slotProps">
<backups-table
ref="backupsTable1"
:custom-table-title="customTableTitle"
:is-configurations="true"
:table-data="tableData"
@edit="edit"
>
</backups-table>
</template>
</nz-data-list>
</div>
2022-04-08 18:02:57 +08:00
<div class="system-config-form system-config-backup">
<div class="system-title">{{ $t("backup.recent") }}</div>
<nz-data-list
ref="dataList"
id="modelTable"
:data="tableData2"
border
from="backups"
>
<template v-slot="slotProps">
<backups-table
ref="backupsTable2"
:custom-table-title="customTableTitle2"
:is-configurations="false"
key="backups2"
:table-data2="tableData2"
@getTableData="getTableData"
>
</backups-table>
</template>
</nz-data-list>
</div>
<transition name="right-box">
<backups-box
v-if="rightBoxshow"
:obj="object"
@close="closeRightBox"
class="backup_box"
></backups-box>
</transition>
</div>
</template>
<script>
2022-04-08 15:05:10 +08:00
import nzDataList from '@/components/common/table/nzDataList'
import backupsTable from '@/components/common/table/settings/backupsTable'
import backupsBox from '@/components/common/rightBox/administration/backupsBox'
2022-06-10 10:48:48 +08:00
import bus from '@/libs/bus'
export default {
2022-04-08 15:05:10 +08:00
name: 'backups',
mixins: [],
2022-04-08 15:05:10 +08:00
props: [''],
data () {
return {
2022-04-08 15:05:10 +08:00
url: '/sys/backup',
customTableTitle: [
2022-06-21 18:14:21 +08:00
{ label: this.$t('alert.config.schedEnable'), prop: 'schedule' },
2022-05-30 09:18:13 +08:00
{ label: this.$t('backup.backupRetention'), prop: 'retention' },
2022-06-21 18:14:21 +08:00
{ label: this.$t('overall.enable'), prop: 'state' }
],
customTableTitle2: [
{ label: this.$t('config.assetLabel.date'), prop: 'time', minwidth: 228 },
2022-05-30 09:18:13 +08:00
{ label: this.$t('backup.File'), prop: 'fileName', minwidth: 363 },
{ label: this.$t('backup.size'), prop: 'size', minwidth: 306 },
{ label: this.$t('overall.remark'), prop: 'Description', minwidth: 569 }
],
tableData: [
{
2022-04-08 15:05:10 +08:00
retention: '',
state: '',
schedule: {}
}
],
tableData2: [
// {
// list: {
// }
// }
],
2022-04-08 15:05:10 +08:00
rightBoxshow: false,
isRefresh: ''
}
},
2022-04-08 15:05:10 +08:00
components: { nzDataList, backupsTable, backupsBox },
computed: {},
2022-04-08 15:05:10 +08:00
created () {},
mounted () {
2022-04-11 17:24:10 +08:00
this.getTableData()
2022-06-10 10:48:48 +08:00
bus.$on('backupNow', () => {
this.getTableData()
})
},
methods: {
2022-04-11 17:24:10 +08:00
getTableData (item) {
if (!item) {
this.$get('/sys/backup').then((res) => {
if (res.code === 200) {
if (res.data) {
this.tableData[0].retention = res.data.retention
this.tableData[0].state = res.data.state == 1
for (const i in res.data.schedule) {
this.tableData[0].schedule[i] = res.data.schedule[i]
}
2022-04-11 17:24:10 +08:00
}
}
})
2022-06-10 10:48:48 +08:00
this.$get('/sys/backup/list').then((res) => {
2022-04-11 17:24:10 +08:00
if (res.code === 200) {
if (res.data) {
this.tableData2 = res.data
}
}
})
} else if (item == 'backup') {
this.$get('/sys/backup').then((res) => {
if (res.code === 200) {
if (res.data) {
this.tableData[0].retention = res.data.retention
this.tableData[0].state = res.data.state == 1
for (const i in res.data.schedule) {
this.tableData[0].schedule[i] = res.data.schedule[i]
}
2022-04-11 17:24:10 +08:00
}
}
})
2022-06-10 10:48:48 +08:00
this.$get('/sys/backup/list').then((res) => {
if (res.code === 200) {
if (res.data) {
this.tableData2 = res.data
}
}
})
2022-04-11 17:24:10 +08:00
} else if (item == 'recent') {
2022-06-10 10:48:48 +08:00
this.$get('/sys/backup/list').then((res) => {
2022-04-11 17:24:10 +08:00
if (res.code === 200) {
if (res.data) {
this.tableData2 = res.data
} else {
this.tableData2 = []
2022-04-11 17:24:10 +08:00
}
}
})
}
},
2022-04-08 15:05:10 +08:00
edit (row) {
2022-04-11 17:24:10 +08:00
this.object = {
...row,
checkDay: '',
checkDays: '',
datepicker: ''
2022-04-08 18:51:13 +08:00
}
2022-04-08 18:02:57 +08:00
this.object.name = this.$t('backup.edit')
2022-04-08 15:05:10 +08:00
if (this.object.schedule) {
for (const i in this.object.schedule) {
this.object[i] = this.object.schedule[i]
}
}
this.rightBoxshow = true
},
closeRightBox (refresh) {
if (refresh) {
this.getTableData('backup')
}
2022-04-08 15:05:10 +08:00
this.rightBoxshow = false
2022-04-11 17:24:10 +08:00
}
},
2022-04-08 15:05:10 +08:00
watch: {}
}
</script>