Browse Source

(*)备份恢复修改

master
peng.peng 1 year ago
parent
commit
b9ca312d91
  1. 3
      api/app/lib/controllers/backups/index.js
  2. 2
      api/app/lib/controllers/metadataSearch/index.js
  3. 27
      api/app/lib/models/backups.js
  4. 38
      web/client/src/sections/backups/containers/backupTask.js

3
api/app/lib/controllers/backups/index.js

@ -141,7 +141,8 @@ function restore(opts) {
const { code, message } = res.body const { code, message } = res.body
models.Backups.update({ models.Backups.update({
state: code == 200 ? '恢复成功' : '恢复失败', state: code == 200 ? '恢复成功' : '恢复失败',
log: code == 200 ? '' : message log: code == 200 ? '' : message,
restoreDatabases: ctx.request.body.databases
}, { where: { id: id } }) }, { where: { id: id } })
if (code != 200) ctx.fs.logger.error(`path: ${ctx.path}, error: ${message}`); if (code != 200) ctx.fs.logger.error(`path: ${ctx.path}, error: ${message}`);
}) })

2
api/app/lib/controllers/metadataSearch/index.js

@ -67,7 +67,7 @@ function searchMeta(opts) {
} }
} }
// 新增模型 // 下载表数据
function getTableData(opts) { function getTableData(opts) {
return async function (ctx, next) { return async function (ctx, next) {

27
api/app/lib/models/backups.js

@ -88,6 +88,33 @@ module.exports = dc => {
field: "log", field: "log",
autoIncrement: false autoIncrement: false
}, },
restoreDatabases: {
type: DataTypes.JSONB,
allowNull: true,
defaultValue: null,
comment: null,
primaryKey: false,
field: "restore_databases",
autoIncrement: false
},
restoreStart: {
type: DataTypes.DATE,
allowNull: true,
defaultValue: null,
comment: "恢复开始时间",
primaryKey: false,
field: "restore_start",
autoIncrement: false
},
restoreEnd: {
type: DataTypes.DATE,
allowNull: true,
defaultValue: null,
comment: "恢复结束时间",
primaryKey: false,
field: "restore_end",
autoIncrement: false
},
}, { }, {
tableName: "backups", tableName: "backups",

38
web/client/src/sections/backups/containers/backupTask.js

@ -49,46 +49,77 @@ function Member(props) {
{ {
title: '序号', title: '序号',
dataIndex: 'index', dataIndex: 'index',
fixed: 'left',
width: '7%',
render: (text, record, index) => { return index + 1 } render: (text, record, index) => { return index + 1 }
}, },
{ {
title: '备份数据源', title: '备份数据源',
dataIndex: 'database', dataIndex: 'database',
fixed: 'left',
width: '7%',
render: (text, record) => record?.databases?.database render: (text, record) => record?.databases?.database
}, },
{ {
title: '备份信息', title: '备份信息',
dataIndex: 'note', dataIndex: 'note',
fixed: 'left',
width: '7%',
}, },
{ {
title: '备份大小', title: '备份大小',
dataIndex: 'size', dataIndex: 'size',
fixed: 'left',
width: '7%',
}, },
{ {
title: '备份时间', title: '备份时间',
dataIndex: 'createTime', dataIndex: 'createTime',
fixed: 'left',
width: '7%',
render: (text, record) => { return moment(record?.createTime).format('YYYY-MM-DD HH:mm:ss') } render: (text, record) => { return moment(record?.createTime).format('YYYY-MM-DD HH:mm:ss') }
}, },
{ {
title: '备份完成时间', title: '备份完成时间',
dataIndex: 'completeTime', dataIndex: 'completeTime',
fixed: 'left',
width: '7%',
render: (text, record) => { return record?.completeTime ? moment(record?.completeTime).format('YYYY-MM-DD HH:mm:ss') : '-' } render: (text, record) => { return record?.completeTime ? moment(record?.completeTime).format('YYYY-MM-DD HH:mm:ss') : '-' }
}, },
{ {
title: '状态', title: '状态',
dataIndex: 'state', dataIndex: 'state',
fixed: 'left',
width: '7%',
},
{
title: '恢复数据源',
dataIndex: 'restoreDatabases',
width: '8%',
render: (text, record) => record?.restoreDatabases?.database
},
{
title: '恢复开始时间',
width: '7%',
dataIndex: 'restoreStart',
},
{
title: '恢复结束时间',
width: '7%',
dataIndex: 'restoreEnd',
}, },
{ {
title: '异常日志', title: '异常日志',
dataIndex: 'log', dataIndex: 'log',
width: '7%',
ellipsis: true, ellipsis: true,
}, },
{ {
title: '操作', title: '操作',
width: 160, width: '8%',
key: 'option', key: 'option',
valueType: 'option', valueType: 'option',
fixed: 'right',
render: (text, record) => { render: (text, record) => {
const options = []; const options = [];
options.push( options.push(
@ -208,7 +239,8 @@ function Member(props) {
scroll={ scroll={
{ {
scrollToFirstRowOnChange: true, scrollToFirstRowOnChange: true,
y: clientHeight - 260 y: clientHeight - 260,
x: 1800
} }
} }
pagination={{ pagination={{

Loading…
Cancel
Save