From b9ca312d913c2babcd1b78ad694c6e623319a0bc Mon Sep 17 00:00:00 2001 From: "peng.peng" Date: Wed, 28 Jun 2023 14:11:14 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=EF=BC=88*=EF=BC=89=E5=A4=87=E4=BB=BD?= =?UTF-8?q?=E6=81=A2=E5=A4=8D=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/backups/index.js | 3 +- .../lib/controllers/metadataSearch/index.js | 2 +- api/app/lib/models/backups.js | 29 +++++++++++++- .../sections/backups/containers/backupTask.js | 38 +++++++++++++++++-- 4 files changed, 66 insertions(+), 6 deletions(-) diff --git a/api/app/lib/controllers/backups/index.js b/api/app/lib/controllers/backups/index.js index a545f1a..e7ce69f 100644 --- a/api/app/lib/controllers/backups/index.js +++ b/api/app/lib/controllers/backups/index.js @@ -141,7 +141,8 @@ function restore(opts) { const { code, message } = res.body models.Backups.update({ state: code == 200 ? '恢复成功' : '恢复失败', - log: code == 200 ? '' : message + log: code == 200 ? '' : message, + restoreDatabases: ctx.request.body.databases }, { where: { id: id } }) if (code != 200) ctx.fs.logger.error(`path: ${ctx.path}, error: ${message}`); }) diff --git a/api/app/lib/controllers/metadataSearch/index.js b/api/app/lib/controllers/metadataSearch/index.js index a8b5a74..6b69440 100644 --- a/api/app/lib/controllers/metadataSearch/index.js +++ b/api/app/lib/controllers/metadataSearch/index.js @@ -67,7 +67,7 @@ function searchMeta(opts) { } } -// 新增模型 +// 下载表数据 function getTableData(opts) { return async function (ctx, next) { diff --git a/api/app/lib/models/backups.js b/api/app/lib/models/backups.js index f205c39..78bb7db 100644 --- a/api/app/lib/models/backups.js +++ b/api/app/lib/models/backups.js @@ -88,7 +88,34 @@ module.exports = dc => { field: "log", 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", comment: "", diff --git a/web/client/src/sections/backups/containers/backupTask.js b/web/client/src/sections/backups/containers/backupTask.js index 51c06cc..2af76f3 100644 --- a/web/client/src/sections/backups/containers/backupTask.js +++ b/web/client/src/sections/backups/containers/backupTask.js @@ -49,46 +49,77 @@ function Member(props) { { title: '序号', dataIndex: 'index', + fixed: 'left', + width: '7%', render: (text, record, index) => { return index + 1 } }, { title: '备份数据源', dataIndex: 'database', + fixed: 'left', + width: '7%', render: (text, record) => record?.databases?.database - }, { title: '备份信息', dataIndex: 'note', + fixed: 'left', + width: '7%', }, { title: '备份大小', dataIndex: 'size', + fixed: 'left', + width: '7%', }, { title: '备份时间', dataIndex: 'createTime', + fixed: 'left', + width: '7%', render: (text, record) => { return moment(record?.createTime).format('YYYY-MM-DD HH:mm:ss') } }, { title: '备份完成时间', dataIndex: 'completeTime', + fixed: 'left', + width: '7%', render: (text, record) => { return record?.completeTime ? moment(record?.completeTime).format('YYYY-MM-DD HH:mm:ss') : '-' } }, { title: '状态', 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: '异常日志', dataIndex: 'log', + width: '7%', ellipsis: true, }, { title: '操作', - width: 160, + width: '8%', key: 'option', valueType: 'option', + fixed: 'right', render: (text, record) => { const options = []; options.push( @@ -208,7 +239,8 @@ function Member(props) { scroll={ { scrollToFirstRowOnChange: true, - y: clientHeight - 260 + y: clientHeight - 260, + x: 1800 } } pagination={{ From c95cc49a573a9a26ff5d0945813d42631659f380 Mon Sep 17 00:00:00 2001 From: "peng.peng" Date: Wed, 28 Jun 2023 15:01:52 +0800 Subject: [PATCH 2/4] =?UTF-8?q?(*)=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E5=AD=98=E5=82=A8=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/client/src/components/UploadLocal/index.js | 5 +++-- .../src/sections/metadataManagement/containers/filesTable.js | 2 +- web/routes/attachment/index.js | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/web/client/src/components/UploadLocal/index.js b/web/client/src/components/UploadLocal/index.js index 0af35e2..abd1dfa 100644 --- a/web/client/src/components/UploadLocal/index.js +++ b/web/client/src/components/UploadLocal/index.js @@ -214,7 +214,7 @@ class Uploads extends Component { }); } if (status === 'done') { - let { filename } = info.file.response; + let { filename, realName } = info.file.response; let size = info.file.size; let nextFileList = fileList; nextFileList[nextFileList.length - 1] = { @@ -223,7 +223,8 @@ class Uploads extends Component { status: 'done', storageUrl: filename, url: filename, - size: size + size: size, + realName: realName }; onChange(nextFileList); that.setState({ diff --git a/web/client/src/sections/metadataManagement/containers/filesTable.js b/web/client/src/sections/metadataManagement/containers/filesTable.js index a7ae2d6..96a24e8 100644 --- a/web/client/src/sections/metadataManagement/containers/filesTable.js +++ b/web/client/src/sections/metadataManagement/containers/filesTable.js @@ -279,7 +279,7 @@ const FilesTable = (props) => { if (values.files && values.files.length) { obj.type = values.files[0].name.split('.').pop(); obj.size = values.files[0].size; - obj.fileName = values.files[0].url.split('\\').pop(); + obj.fileName = values.files[0].realName; } dispatch(metadataManagement.postMetadataFiles(obj)).then(res => { if (res.success) { diff --git a/web/routes/attachment/index.js b/web/routes/attachment/index.js index 14df35b..bfcf516 100644 --- a/web/routes/attachment/index.js +++ b/web/routes/attachment/index.js @@ -104,7 +104,7 @@ module.exports = { app.fs.logger.log('error', '[Upload Heatmap]', err); }); ctx.status = 200; - ctx.body = { filename: path.join(`/assets/files/${fileFolder}`, fileName), name: 'UploadSuccess', message: '上传成功' }; + ctx.body = { realName: fileName, filename: path.join(`/assets/files/${fileFolder}`, fileName), name: 'UploadSuccess', message: '上传成功' }; } catch (err) { ctx.status = 500; ctx.fs.logger.error(err); From b07791aa728a8f4bdba7293d23dd11ddadcd8310 Mon Sep 17 00:00:00 2001 From: "peng.peng" Date: Wed, 28 Jun 2023 15:18:31 +0800 Subject: [PATCH 3/4] =?UTF-8?q?(*)=E8=B5=84=E6=BA=90=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/latestMetadata/index.js | 2 +- .../sections/metadataManagement/containers/databasesTable.js | 2 +- .../src/sections/metadataManagement/containers/filesTable.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/app/lib/controllers/latestMetadata/index.js b/api/app/lib/controllers/latestMetadata/index.js index 90f88ed..e6b3ef0 100644 --- a/api/app/lib/controllers/latestMetadata/index.js +++ b/api/app/lib/controllers/latestMetadata/index.js @@ -534,7 +534,7 @@ async function postMetadataResourceApplications(ctx) { } else { const models = ctx.fs.dc.models; const postOne = await models.ResourceConsumption.findOne({ - where: { applyBy: applyBy, resourceName: resourceName, resourceId, resourceType } + where: { applyBy: applyBy, resourceName: resourceName, resourceId, resourceType, approve_remarks: null } }); if (postOne) { ctx.status = 400; diff --git a/web/client/src/sections/metadataManagement/containers/databasesTable.js b/web/client/src/sections/metadataManagement/containers/databasesTable.js index 800672f..1e274da 100644 --- a/web/client/src/sections/metadataManagement/containers/databasesTable.js +++ b/web/client/src/sections/metadataManagement/containers/databasesTable.js @@ -170,7 +170,7 @@ const DatabaseTable = (props) => { width: '8%', render: (text, record) => { let resourceApplicationsRecords = metadataResourceApplications.filter(ra => - ra.applyBy == user.id && ra.resourceName === record.name && ra.resourceId == record.id); + ra.applyBy == user.id && ra.resourceName === record.name && ra.resourceId == record.id && !!record.token); return onView(record)}>查看 {user.role == '数据消费者' ? null : diff --git a/web/client/src/sections/metadataManagement/containers/filesTable.js b/web/client/src/sections/metadataManagement/containers/filesTable.js index 96a24e8..72e925b 100644 --- a/web/client/src/sections/metadataManagement/containers/filesTable.js +++ b/web/client/src/sections/metadataManagement/containers/filesTable.js @@ -293,7 +293,7 @@ const FilesTable = (props) => { if (values.files[0].size) { obj.size = values.files[0].size; } - obj.fileName = values.files[0].url.split('\\').pop(); + obj.fileName = values.files[0].realName; } dispatch(metadataManagement.putMetadataFiles(editData.record.id, obj)).then(res => { if (res.success) { From 6ef9ab108fba6ac228f264cc33c05c9c30b22a4d Mon Sep 17 00:00:00 2001 From: "peng.peng" Date: Wed, 28 Jun 2023 17:23:28 +0800 Subject: [PATCH 4/4] =?UTF-8?q?(*)=E8=84=9A=E6=9C=AC=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/metadataAcquisition/adapter.js | 2 +- scripts/0.0.7/05_alter_backups.sql | 18 ++++++++++++++++++ .../backups/components/backupsModal.js | 3 ++- .../sections/backups/containers/backupTask.js | 2 +- 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 scripts/0.0.7/05_alter_backups.sql diff --git a/api/app/lib/controllers/metadataAcquisition/adapter.js b/api/app/lib/controllers/metadataAcquisition/adapter.js index b25ef50..5fad233 100644 --- a/api/app/lib/controllers/metadataAcquisition/adapter.js +++ b/api/app/lib/controllers/metadataAcquisition/adapter.js @@ -1,6 +1,6 @@ 'use strict'; const { Pool } = require('pg'); -// 新增模型 +// 测试数据库连接 function checkConnect(opts) { return async function (ctx, next) { diff --git a/scripts/0.0.7/05_alter_backups.sql b/scripts/0.0.7/05_alter_backups.sql new file mode 100644 index 0000000..5a40fba --- /dev/null +++ b/scripts/0.0.7/05_alter_backups.sql @@ -0,0 +1,18 @@ + +comment on column backups.databases is '备份数据源地址'; + + +alter table backups + add restore_databases jsonb; + + +alter table backups + add restore_start timestamp with time zone; + +comment on column backups.restore_start is '备份开始时间'; + +alter table backups + add restore_end timestamp with time zone; + +comment on column backups.restore_end is '备份结束时间'; + diff --git a/web/client/src/sections/backups/components/backupsModal.js b/web/client/src/sections/backups/components/backupsModal.js index 2da7418..67bddf3 100644 --- a/web/client/src/sections/backups/components/backupsModal.js +++ b/web/client/src/sections/backups/components/backupsModal.js @@ -33,7 +33,8 @@ export default (props) => { onCancel: () => { }, }} onFinish={async (values) => { - values.databases = dataSources?.rows?.find(s => s.id == values?.databases?.value)?.config; + let database = dataSources?.rows?.find(s => s.id == values?.databases?.value) + values.databases = { displayName: database?.name, ...database?.config }; values.createTime = moment(); values.state = '备份中'; values.title = title; diff --git a/web/client/src/sections/backups/containers/backupTask.js b/web/client/src/sections/backups/containers/backupTask.js index 2af76f3..adf2242 100644 --- a/web/client/src/sections/backups/containers/backupTask.js +++ b/web/client/src/sections/backups/containers/backupTask.js @@ -58,7 +58,7 @@ function Member(props) { dataIndex: 'database', fixed: 'left', width: '7%', - render: (text, record) => record?.databases?.database + render: (text, record) => record?.databases?.displayName }, { title: '备份信息',