Skip to content

Commit

Permalink
feat: add work dir backup options (halo-dev/console#362)
Browse files Browse the repository at this point in the history
* feat: add work dir backup options

* feat: add layout to backup options

* refactor: modify variable naming

* refactor: rename variables
  • Loading branch information
guqing authored Oct 12, 2021
1 parent 9d3b2af commit 4682d88
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 9 deletions.
10 changes: 9 additions & 1 deletion src/api/backup.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,22 @@ backupApi.importMarkdown = (formData, uploadProgress, cancelToken) => {
})
}

backupApi.backupWorkDir = () => {
backupApi.backupWorkDir = options => {
return service({
url: `${baseUrl}/work-dir`,
method: 'post',
data: options,
timeout: 8640000 // 24 hours
})
}

backupApi.listWorkDirOptions = () => {
return service({
url: `${baseUrl}/work-dir/options`,
method: 'get'
})
}

backupApi.listWorkDirBackups = () => {
return service({
url: `${baseUrl}/work-dir`,
Expand Down
45 changes: 37 additions & 8 deletions src/views/system/components/BackupWorkDirDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,34 @@
<a-divider class="divider-transparent" />
<div class="bottom-control">
<a-space>
<a-button type="primary" icon="download" @click="handleBackupClick">备份</a-button>
<a-button type="dashed" icon="reload" :loading="loading" @click="handleListBackups">刷新</a-button>
</a-space>
</div>
<a-modal v-model="optionsModal.visible" title="备份选项">
<template slot="footer">
<a-button @click="() => (optionsModal.visible = false)">取消</a-button>
<ReactiveButton
type="primary"
icon="download"
@click="handleBackupClick"
@click="handleBackupConfirmed"
@callback="handleBackupedCallback"
:loading="backuping"
:errored="backupErrored"
text="备份"
text="确认"
loadedText="备份成功"
erroredText="备份失败"
></ReactiveButton>
<a-button type="dashed" icon="reload" :loading="loading" @click="handleListBackups">刷新</a-button>
</a-space>
</div>
</template>
<a-checkbox-group v-model="optionsModal.selected" style="width: 100%">
<a-row>
<a-col :span="8" v-for="item in optionsModal.options" :key="item">
<a-checkbox :value="item">
{{ item }}
</a-checkbox>
</a-col>
</a-row>
</a-checkbox-group>
</a-modal>
</a-drawer>
</template>
<script>
Expand All @@ -68,7 +82,12 @@ export default {
backuping: false,
loading: false,
backupErrored: false,
backups: []
backups: [],
optionsModal: {
options: [],
visible: false,
selected: []
}
}
},
model: {
Expand Down Expand Up @@ -102,9 +121,18 @@ export default {
})
},
handleBackupClick() {
backupApi.listWorkDirOptions().then(response => {
this.optionsModal = {
visible: true,
options: response.data.data,
selected: response.data.data
}
})
},
handleBackupConfirmed() {
this.backuping = true
backupApi
.backupWorkDir()
.backupWorkDir(this.optionsModal.selected)
.catch(() => {
this.backupErrored = true
})
Expand All @@ -118,6 +146,7 @@ export default {
if (this.backupErrored) {
this.backupErrored = false
} else {
this.optionsModal.visible = false
this.handleListBackups()
}
},
Expand Down

0 comments on commit 4682d88

Please sign in to comment.