Browse Source

fix: 调整快照页面备份路径样式 (#3696)

pull/3702/head
ssongliu 10 months ago committed by GitHub
parent
commit
df2a705713
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 17
      backend/app/dto/setting.go
  2. 3
      backend/app/service/cronjob_backup.go
  3. 2
      backend/init/migration/migrations/v_1_9.go
  4. 10
      frontend/src/views/cronjob/index.vue
  5. 27
      frontend/src/views/setting/snapshot/index.vue

17
backend/app/dto/setting.go

@ -115,14 +115,15 @@ type SnapshotImport struct {
Description string `json:"description" validate:"max=256"`
}
type SnapshotInfo struct {
ID uint `json:"id"`
Name string `json:"name"`
Description string `json:"description" validate:"max=256"`
From string `json:"from"`
Status string `json:"status"`
Message string `json:"message"`
CreatedAt time.Time `json:"createdAt"`
Version string `json:"version"`
ID uint `json:"id"`
Name string `json:"name"`
Description string `json:"description" validate:"max=256"`
From string `json:"from"`
DefaultDownload string `json:"defaultDownload"`
Status string `json:"status"`
Message string `json:"message"`
CreatedAt time.Time `json:"createdAt"`
Version string `json:"version"`
InterruptStep string `json:"interruptStep"`
RecoverStatus string `json:"recoverStatus"`

3
backend/app/service/cronjob_backup.go

@ -208,7 +208,8 @@ func (u *CronjobService) handleSnapshot(cronjob model.Cronjob, startTime time.Ti
record.FileDir = "system_snapshot"
req := dto.SnapshotCreate{
From: record.BackupType,
From: record.BackupType,
DefaultDownload: cronjob.DefaultDownload,
}
name, err := NewISnapshotService().HandleSnapshot(true, logPath, req, startTime.Format("20060102150405"))
if err != nil {

2
backend/init/migration/migrations/v_1_9.go

@ -281,7 +281,7 @@ var UpdateCronjobSpec = &gormigrate.Migration{
mapAccount[item.ID] = item.Type
}
for _, job := range jobs {
if job.KeepLocal {
if job.KeepLocal && mapAccount[uint(job.TargetDirID)] != constant.Local {
if err := tx.Model(&model.Cronjob{}).
Where("id = ?", job.ID).
Updates(map[string]interface{}{

10
frontend/src/views/cronjob/index.vue

@ -83,7 +83,7 @@
<template #default="{ row }">
<div v-for="(item, index) of row.spec.split(',')" :key="index" class="mt-1">
<div v-if="row.expand || (!row.expand && index < 3)">
<el-tag>
<el-tag type="info">
{{ transSpecToStr(item) }}
</el-tag>
</div>
@ -115,9 +115,9 @@
</el-table-column>
<el-table-column :min-width="80" :label="$t('cronjob.target')" prop="defaultDownload">
<template #default="{ row }">
<div v-for="(item, index) of row.backupAccounts.split(',')" :key="index" class="mt-1">
<div v-for="(item, index) of row.backupAccounts?.split(',')" :key="index" class="mt-1">
<div v-if="row.accountExpand || (!row.accountExpand && index < 3)">
<el-tag v-if="row.backupAccounts">
<el-tag type="info" v-if="row.backupAccounts">
<span v-if="item === row.defaultDownload">
<el-icon><Star /></el-icon>
{{ $t('setting.' + item) }}
@ -129,12 +129,12 @@
<span v-else>-</span>
</div>
</div>
<div v-if="!row.accountExpand && row.backupAccounts.split(',').length > 3">
<div v-if="!row.accountExpand && row.backupAccounts?.split(',').length > 3">
<el-button type="primary" link @click="row.accountExpand = true">
{{ $t('commons.button.expand') }}...
</el-button>
</div>
<div v-if="row.accountExpand && row.backupAccounts.split(',').length > 3">
<div v-if="row.accountExpand && row.backupAccounts?.split(',').length > 3">
<el-button type="primary" link @click="row.accountExpand = false">
{{ $t('commons.button.collapse') }}
</el-button>

27
frontend/src/views/setting/snapshot/index.vue

@ -49,9 +49,30 @@
<el-table-column prop="version" :label="$t('app.version')" />
<el-table-column :label="$t('setting.backupAccount')" min-width="80" prop="from">
<template #default="{ row }">
<span v-if="row.from">
{{ $t('setting.' + row.from) }}
</span>
<div v-for="(item, index) of row.from.split(',')" :key="index" class="mt-1">
<div v-if="row.expand || (!row.expand && index < 3)">
<el-tag v-if="row.from" type="info">
<span v-if="item === row.defaultDownload">
<el-icon><Star /></el-icon>
{{ $t('setting.' + item) }}
</span>
<span v-else>
{{ $t('setting.' + item) }}
</span>
</el-tag>
<span v-else>-</span>
</div>
</div>
<div v-if="!row.expand && row.from.split(',').length > 3">
<el-button type="primary" link @click="row.expand = true">
{{ $t('commons.button.expand') }}...
</el-button>
</div>
<div v-if="row.expand && row.from.split(',').length > 3">
<el-button type="primary" link @click="row.expand = false">
{{ $t('commons.button.collapse') }}
</el-button>
</div>
</template>
</el-table-column>
<el-table-column :label="$t('commons.table.status')" min-width="80" prop="status">

Loading…
Cancel
Save