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 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/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() }) } } diff --git a/frontend/src/views/chart/view/ChartEdit.vue b/frontend/src/views/chart/view/ChartEdit.vue index 933ace7366..765eed7c51 100644 --- a/frontend/src/views/chart/view/ChartEdit.vue +++ b/frontend/src/views/chart/view/ChartEdit.vue @@ -1098,6 +1098,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"; import ChartFieldEdit from '@/views/chart/view/ChartFieldEdit' import CalcChartFieldEdit from '@/views/chart/view/CalcChartFieldEdit' @@ -2504,11 +2505,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) {