From fd8197fc77c7656dc539e86b3ebbe57573c87849 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Thu, 16 Jun 2022 11:58:23 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20=E8=A7=86=E5=9B=BE=E9=87=8D?= =?UTF-8?q?=E7=BD=AE=E5=A2=9E=E5=8A=A0=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/lang/en.js | 2 ++ frontend/src/lang/tw.js | 2 ++ frontend/src/lang/zh.js | 2 ++ frontend/src/views/chart/view/ChartEdit.vue | 19 ++++++++++++++----- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/frontend/src/lang/en.js b/frontend/src/lang/en.js index 3a9106e4ec..03385ad3e6 100644 --- a/frontend/src/lang/en.js +++ b/frontend/src/lang/en.js @@ -660,6 +660,8 @@ export default { kettle_setting: 'Kettle Setting' }, chart: { + view_reset: 'View Reset', + view_reset_tips: 'Discard Changes To View?', export_img: 'Export Img', title_repeat: 'The Title Already Exist', save_snapshot: 'Save Snapshot', diff --git a/frontend/src/lang/tw.js b/frontend/src/lang/tw.js index 45b0364045..c2af66b461 100644 --- a/frontend/src/lang/tw.js +++ b/frontend/src/lang/tw.js @@ -662,6 +662,8 @@ export default { kettle_setting: 'Kettle 設置' }, chart: { + view_reset: '视图重置', + view_reset_tips: '放弃对视图的修改?', export_img: '导出图片', title_repeat: '當前標題已存在', save_snapshot: '保存縮略圖', diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index 01ddc5c753..66a0864a84 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -663,6 +663,8 @@ export default { kettle_setting: 'Kettle 设置' }, chart: { + view_reset: '视图重置', + view_reset_tips: '放弃对视图的修改?', export_img: '导出图片', title_repeat: '当前标题已存在', save_snapshot: '保存缩略图', diff --git a/frontend/src/views/chart/view/ChartEdit.vue b/frontend/src/views/chart/view/ChartEdit.vue index bf0418bafa..640351200c 100644 --- a/frontend/src/views/chart/view/ChartEdit.vue +++ b/frontend/src/views/chart/view/ChartEdit.vue @@ -1030,6 +1030,7 @@ import { pluginTypes } from '@/api/chart/chart' import ValueFormatterEdit from '@/views/chart/components/value-formatter/ValueFormatterEdit' import ChartStyle from '@/views/chart/view/ChartStyle' import CustomSortEdit from '@/views/chart/components/compare/CustomSortEdit' +import {delGroup} from "@/api/panel/panel"; export default { name: 'ChartEdit', components: { @@ -2398,11 +2399,19 @@ export default { reset() { const _this = this - resetViewCacheCallBack(_this.param.id, _this.panelInfo.id, function(rsp) { - _this.changeEditStatus(false) - _this.getChart(_this.param.id, 'panel') - // _this.getData(_this.param.id) - bus.$emit('view-in-cache', { type: 'propChange', viewId: _this.param.id }) + + this.$confirm(this.$t('chart.view_reset'), this.$t('chart.view_reset_tips'), { + confirmButtonText: this.$t('commons.confirm'), + cancelButtonText: this.$t('commons.cancel'), + type: 'warning' + }).then(() => { + resetViewCacheCallBack(_this.param.id, _this.panelInfo.id, function(rsp) { + _this.changeEditStatus(false) + _this.getChart(_this.param.id, 'panel') + bus.$emit('view-in-cache', { type: 'propChange', viewId: _this.param.id }) + }) + }).catch(() => { + // Do Nothing }) }, changeEditStatus(status) { From 2284cad01c024b1782e1aa8b342ee3fb35434918 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Thu, 16 Jun 2022 14:10:08 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E6=A0=A1=E9=AA=8C=E9=A9=B1=E5=8A=A8?= =?UTF-8?q?ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/dataease/service/datasource/DriverService.java | 8 +++++++- backend/src/main/resources/i18n/messages_en_US.properties | 3 ++- backend/src/main/resources/i18n/messages_zh_CN.properties | 1 + backend/src/main/resources/i18n/messages_zh_TW.properties | 3 ++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/io/dataease/service/datasource/DriverService.java b/backend/src/main/java/io/dataease/service/datasource/DriverService.java index df44a4fef3..eef7f8df4d 100644 --- a/backend/src/main/java/io/dataease/service/datasource/DriverService.java +++ b/backend/src/main/java/io/dataease/service/datasource/DriverService.java @@ -105,6 +105,9 @@ public class DriverService { public void deleteDriverFile(String driverFileId) throws Exception{ DeDriverDetails deDriverDetails = deDriverDetailsMapper.selectByPrimaryKey(driverFileId); DeDriver deDriver = deDriverMapper.selectByPrimaryKey(deDriverDetails.getDeDriverId()); + if(deDriver == null){ + throw new Exception(Translator.get("I18N_DRIVER_NOT_FOUND")); + } DeFileUtils.deleteFile(DRIVER_PATH + deDriverDetails.getDeDriverId() + "/" + deDriverDetails.getFileName()); SysLogDTO sysLogDTO = DeLogUtils.buildLog(SysLogConstants.OPERATE_TYPE.DELETE, SysLogConstants.SOURCE_TYPE.DRIVER_FILE, deDriverDetails.getId(), deDriverDetails.getDeDriverId(), null, null); DeLogUtils.save(sysLogDTO); @@ -114,6 +117,10 @@ public class DriverService { } public DeDriverDetails saveJar(MultipartFile file, String driverId) throws Exception { + DeDriver deDriver = deDriverMapper.selectByPrimaryKey(driverId); + if(deDriver == null){ + throw new Exception(Translator.get("I18N_DRIVER_NOT_FOUND")); + } String filename = file.getOriginalFilename(); String dirPath = DRIVER_PATH + driverId + "/"; String filePath = dirPath + filename; @@ -138,7 +145,6 @@ public class DriverService { deDriverDetailsMapper.insert(deDriverDetails); SysLogDTO sysLogDTO = DeLogUtils.buildLog(SysLogConstants.OPERATE_TYPE.UPLOADFILE, SysLogConstants.SOURCE_TYPE.DRIVER_FILE, deDriverDetails.getId(), driverId, null, null); DeLogUtils.save(sysLogDTO); - DeDriver deDriver = deDriverMapper.selectByPrimaryKey(driverId); DefaultJdbcProvider defaultJdbcProvider = (DefaultJdbcProvider)ProviderFactory.getProvider(deDriver.getType()); defaultJdbcProvider.reloadCustomJdbcClassLoader(deDriver); return deDriverDetails; diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 7c5fa0cfc6..27be07bb0c 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -155,4 +155,5 @@ SOURCE_TYPE_DRIVER_FILE=DRIVER FILE SOURCE_TYPE_MENU=MENU I18N_DRIVER_NOT_DELETE=Drivers in use cannot be deleted -I18N_DRIVER_REPEAT_NAME=Driver name cannot be same. \ No newline at end of file +I18N_DRIVER_REPEAT_NAME=Driver name cannot be same. +I18N_DRIVER_NOT_FOUND=Cannot find driver. \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index ab615dae2a..01258ce785 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -159,3 +159,4 @@ I18N_TIME=操作时间 I18N_DRIVER_NOT_DELETE=使用中的驱动不允许删除 I18N_DRIVER_REPEAT_NAME=名称重复 +I18N_DRIVER_NOT_FOUND=未找到驱动 diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 33343c94ec..607079419e 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -154,4 +154,5 @@ SOURCE_TYPE_DRIVER_FILE=驅動文件 SOURCE_TYPE_MENU=菜單 I18N_DRIVER_NOT_DELETE=使用中的驅動不允許删除 -I18N_DRIVER_REPEAT_NAME=名稱重複 \ No newline at end of file +I18N_DRIVER_REPEAT_NAME=名稱重複 +I18N_DRIVER_NOT_FOUND=未找到驅動 \ No newline at end of file From b4e917a6a666c8d51c8fd37eb2868e2aa84386ad Mon Sep 17 00:00:00 2001 From: junjun Date: Thu, 16 Jun 2022 14:18:10 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=E8=A7=86=E5=9B=BE=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E8=AE=A1=E7=AE=97=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/chart/view/CalcChartFieldEdit.vue | 55 ++++++++++++++++--- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/frontend/src/views/chart/view/CalcChartFieldEdit.vue b/frontend/src/views/chart/view/CalcChartFieldEdit.vue index 1407c17400..757a6598f9 100644 --- a/frontend/src/views/chart/view/CalcChartFieldEdit.vue +++ b/frontend/src/views/chart/view/CalcChartFieldEdit.vue @@ -95,7 +95,7 @@ :key="item.id" class="item-dimension" :title="item.name" - @click="insertFieldToCodeMirror('['+item.id+']')" + @click="insertFieldToCodeMirror('['+item.name+']')" > @@ -125,7 +125,7 @@ :key="item.id" class="item-quota" :title="item.name" - @click="insertFieldToCodeMirror('['+item.id+']')" + @click="insertFieldToCodeMirror('['+item.name+']')" > @@ -283,7 +283,8 @@ export default { dimensionData: [], quotaData: [], functionData: [], - tableFields: {} + tableFields: {}, + name2Auto: [] } }, computed: { @@ -332,7 +333,7 @@ export default { this.$refs.myCm.codemirror.showHint() }) this.initFunctions() - this.initField() + // this.initField() }, methods: { onCmReady(cm) { @@ -356,6 +357,7 @@ export default { pos2.line = pos1.line pos2.ch = pos1.ch this.$refs.myCm.codemirror.replaceRange(param, pos2) + this.$refs.myCm.codemirror.markText(pos2, { line: pos2.line, ch: param.length + pos2.ch }, { atomic: true, selectRight: true }) }, initFunctions() { @@ -370,28 +372,63 @@ export default { initField() { if (this.field.id || this.mode === 'copy') { this.fieldForm = JSON.parse(JSON.stringify(this.field)) + this.name2Auto = [] + this.fieldForm.originName = this.setNameIdTrans('id', 'name', this.fieldForm.originName, this.name2Auto) + setTimeout(() => { + this.matchToAuto() + }, 500) } else { this.fieldForm = JSON.parse(JSON.stringify(this.fieldForm)) } }, + matchToAuto() { + if (!this.name2Auto.length) return + this.name2Auto.forEach(ele => { + const search = this.$refs.myCm.codemirror.getSearchCursor(ele, { line: 0, ch: 0 }) + if (search.find()) { + const { from, to } = search.pos + this.$refs.myCm.codemirror.markText({ line: from.line, ch: from.ch - 1 }, { line: to.line, ch: to.ch + 1 }, { atomic: true, selectRight: true }) + } + }) + }, closeCalcField() { this.resetField() this.$emit('onEditClose', {}) }, + setNameIdTrans(from, to, originName, name2Auto) { + let name2Id = originName + const nameIdMap = [...this.dimensionData, ...this.quotaData].reduce((pre, next) => { + pre[next[from]] = next[to] + return pre + }, {}) + const on = originName.match(/(?<=\[).+?(?=\])/g) + if (on) { + on.forEach(ele => { + if (name2Auto) { + name2Auto.push(nameIdMap[ele]) + } + name2Id = name2Id.replace(ele, nameIdMap[ele]) + }) + } + return name2Id + }, + saveCalcField() { - if (this.fieldForm.name && this.fieldForm.name.length > 50) { + const { id, name = [], deType, originName } = this.fieldForm + if (name.length > 50) { this.$message.error(this.$t('dataset.field_name_less_50')) return } - if (!this.fieldForm.id) { - this.fieldForm.type = this.fieldForm.deType - this.fieldForm.deExtractType = this.fieldForm.deType + if (!id) { + this.fieldForm.type = deType + this.fieldForm.deExtractType = deType this.fieldForm.tableId = this.param.tableId this.fieldForm.columnIndex = 0 this.fieldForm.chartId = this.param.id } + this.fieldForm.originName = this.setNameIdTrans('name', 'id', originName) post('/chart/field/save/' + this.panelInfo.id, this.fieldForm).then(response => { this.closeCalcField() }) @@ -425,6 +462,8 @@ export default { this.dimensionData = JSON.parse(JSON.stringify(this.tableFields.dimensionList)).filter(ele => ele.extField === 0) this.quotaData = JSON.parse(JSON.stringify(this.tableFields.quotaList)).filter(ele => ele.extField === 0) + + this.initField() }) } }