From e5c815b335a5dd762e0255f63cc2c1f713868c87 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=9D=92=E7=BE=BD?=
Date: Fri, 16 Aug 2019 16:12:06 +0800
Subject: [PATCH 1/7] fix the memory leak in clickoutside
---
src/js/helper/clickoutside.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/js/helper/clickoutside.js b/src/js/helper/clickoutside.js
index bd7bd5f..5452c97 100644
--- a/src/js/helper/clickoutside.js
+++ b/src/js/helper/clickoutside.js
@@ -1,4 +1,4 @@
-const cache = {};
+let cache = {};
let key = 1;
export default {
inserted(el, binding) {
@@ -19,5 +19,6 @@ export default {
unbind(el) {
const self = cache[el.outsideKey];
document.removeEventListener('click', self.documentHandler);
+ delete cache[el.outsideKey];
},
};
From ab201c8c9a52bd343fdba1d355b305ffd66b1e01 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=9D=92=E7=BE=BD?=
Date: Fri, 16 Aug 2019 16:31:41 +0800
Subject: [PATCH 2/7] =?UTF-8?q?1.remove=20auto-save=20of=20temp=20scripts?=
=?UTF-8?q?=EF=BC=9B=202.fix=20the=20problem=20of=20wrong=20result=20set?=
=?UTF-8?q?=20selection;=203.optimizing=20log=20input;=204.optimize=20pane?=
=?UTF-8?q?l=20menu.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/js/component/panel/panelItem.vue | 4 +-
src/js/module/workbench/container.vue | 14 ++-
.../module/workbench/script/historyScript.vue | 17 ++--
src/js/module/workbench/script/script.vue | 88 ++++++++++++++-----
4 files changed, 88 insertions(+), 35 deletions(-)
diff --git a/src/js/component/panel/panelItem.vue b/src/js/component/panel/panelItem.vue
index 6d3302d..29ab7b9 100644
--- a/src/js/component/panel/panelItem.vue
+++ b/src/js/component/panel/panelItem.vue
@@ -103,7 +103,7 @@ export default {
} else if (this.isDiy) {
styleAttr = Object.assign({
'position': 'fixed',
- 'z-index': 1100,
+ 'z-index': 100,
}, this.diyStyle);
} else {
styleAttr = {
@@ -112,7 +112,7 @@ export default {
'right': 0,
'top': 0,
'bottom': 0,
- 'z-index': 1100,
+ 'z-index': 100,
};
}
return styleAttr;
diff --git a/src/js/module/workbench/container.vue b/src/js/module/workbench/container.vue
index b3bec3d..5542d68 100644
--- a/src/js/module/workbench/container.vue
+++ b/src/js/module/workbench/container.vue
@@ -41,8 +41,11 @@
关闭右边
全屏
- 取消全屏
+ divided
+ v-if="!isTopPanelFull">全屏
+ 取消全屏
@@ -84,7 +87,7 @@
关闭提示
-
{{ closeModal.text }}
+
{{ closeModal.text }}
@@ -183,7 +187,9 @@ export default {
},
configLogPanel(name) {
if (name == 'fullScreen' || name == 'releaseFullScreen') {
- this.$refs.bottomPanel[name]();
+ this.$refs.bottomPanel[name]({
+ isDiy: false,
+ });
}
if (name == 'min') {
this.scriptViewState.bottomPanelHeight = 32;
@@ -199,9 +205,8 @@ export default {
},
changeResultSet(data, cb) {
const resultSet = _.isUndefined(data.currentSet) ? this.script.resultSet : data.currentSet;
- this.$set(this.script.resultList[data.lastSet], 'result', data.lastResult);
- // 拿到index对应的result
- const resultPath = this.script.resultList[resultSet].path;
+ const findResult = this.script.resultList.find((item) => item.name === `_${resultSet}.dolphin`);
+ const resultPath = findResult && findResult.path;
const hasResult = this.script.resultList[resultSet].hasOwnProperty('result');
if (!hasResult) {
const pageSize = 5000;
diff --git a/src/js/module/workbench/script/script.vue b/src/js/module/workbench/script/script.vue
index 47f22cf..1ce076f 100644
--- a/src/js/module/workbench/script/script.vue
+++ b/src/js/module/workbench/script/script.vue
@@ -65,10 +65,18 @@
@on-click="configLogPanel">
- 全屏
- 取消全屏
- 最小化
- 取消最小化
+ 全屏
+ 取消全屏
+ 最小化
+ 取消最小化
@@ -153,6 +161,7 @@ export default {
saveLoading: false,
isLogShow: false,
autoSaveTimer: null,
+ isBottomPanelFull: false,
};
},
computed: {
@@ -235,11 +244,13 @@ export default {
if (resultList) {
this.script.result = resultList[resultList.resultSet].result;
this.script.resultList = _.dropRight(_.toArray(resultList), 3);
- this.$nextTick(() => {
- this.$refs.result.resultSet = resultList.resultSet;
- this.$refs.result.initPage();
- });
this.showPanelTab(resultList.showPanel);
+ if (this.$refs.result) {
+ this.$nextTick(() => {
+ this.$refs.result.resultSet = resultList.resultSet;
+ this.$refs.result.initPage();
+ });
+ }
}
} });
this.dispatch('IndexedDB:getLog', { tabId: this.script.id,
@@ -403,6 +414,10 @@ export default {
// 执行
this.execute = new Execute(data);
this.isLogShow = false;
+ this.localLog = {
+ log: { all: '', error: '', warning: '', info: '' },
+ logLine: 1,
+ };
if (option && option.isRestore) {
this.execute.restore(option);
} else {
@@ -456,16 +471,16 @@ export default {
Object.keys(convertLogs).forEach((key) => {
const convertLog = convertLogs[key];
if (convertLog) {
- this.script.log[key] += convertLog + '\n';
+ this.localLog.log[key] += convertLog + '\n';
}
if (key === 'all') {
- this.script.logLine += convertLog.split('\n').length;
+ this.localLog.logLine += convertLog.split('\n').length;
}
});
- this.dispatch('IndexedDB:appendLog', {
- tabId: this.script.id,
- rst: this.script.log,
- });
+
+ if (this.scriptViewState.showPanel === 'log') {
+ this.localLogShow();
+ }
});
this.execute.on('history', (ret) => {
@@ -526,7 +541,6 @@ export default {
}
});
this.execute.on('result', (ret) => {
- this.script.running = false;
this.showPanelTab('result');
const storeResult = {
'headRows': ret.metadata,
@@ -650,10 +664,18 @@ export default {
this.showPanelTab('history');
this.isLogShow = true;
}
+ this.dispatch('IndexedDB:appendLog', {
+ tabId: this.script.id,
+ rst: this.script.log,
+ });
});
this.execute.on('stateEnd', () => {
// 执行成功的时候resolve,用于改变modal框中的loading状态
cb && cb('end');
+ this.dispatch('IndexedDB:appendLog', {
+ tabId: this.script.id,
+ rst: this.localLog.log,
+ });
});
this.execute.on('querySuccess', ({ type, task }) => {
const costTime = util.convertTimestamp(task.costTime);
@@ -747,9 +769,11 @@ export default {
},
autoSave() {
clearTimeout(this.autoSaveTimer);
- this.autoSaveTimer = setTimeout(() => {
- this.save();
- }, 1000 * 60 * 3);
+ if (!this.work.saveAs) {
+ this.autoSaveTimer = setTimeout(() => {
+ this.save();
+ }, 1000 * 60 * 5);
+ }
},
save() {
const params = {
@@ -804,10 +828,28 @@ export default {
},
showPanelTab(type) {
this.scriptViewState.showPanel = type;
+ if (type === 'log') {
+ this.localLogShow();
+ }
+ },
+ localLogShow() {
+ if (this.localLog) {
+ this.script.log = this.localLog.log;
+ this.script.logLine = this.localLog.logLine;
+ }
},
configLogPanel(name) {
- if (name == 'fullScreen' || name == 'releaseFullScreen') {
- this.$refs.bottomPanel[name]();
+ if (name == 'fullScreen') {
+ this.isBottomPanelFull = true;
+ this.$refs.bottomPanel[name]({
+ isDiy: false,
+ });
+ }
+ if (name == 'releaseFullScreen') {
+ this.isBottomPanelFull = false;
+ this.$refs.bottomPanel[name]({
+ isDiy: false,
+ });
}
if (name == 'min') {
this.scriptViewState.bottomPanelHeight = 32;
@@ -823,9 +865,8 @@ export default {
},
changeResultSet(data, cb) {
const resultSet = _.isUndefined(data.currentSet) ? this.script.resultSet : data.currentSet;
- // this.$set(this.script.resultList[resultSet], 'result', data.lastResult);
- // 拿到index对应的result
- const resultPath = this.script.resultList[resultSet].path;
+ const findResult = this.script.resultList.find((item) => item.name === `_${resultSet}.dolphin`);
+ const resultPath = findResult && findResult.path;
const hasResult = this.script.resultList[resultSet].hasOwnProperty('result');
if (!hasResult) {
const pageSize = 5000;
@@ -861,7 +902,6 @@ export default {
});
cb();
}).catch((err) => {
- this.$refs.result.resultSet = data.lastSet;
cb();
});
} else {
From 0afe31407f012215d2509f7727396a2280accb55 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=9D=92=E7=BE=BD?=
Date: Fri, 16 Aug 2019 16:36:28 +0800
Subject: [PATCH 3/7] optimizing the acquisition of python's keyword
---
src/js/component/editor/keyword/python.js | 54 +++++++++--------------
1 file changed, 20 insertions(+), 34 deletions(-)
diff --git a/src/js/component/editor/keyword/python.js b/src/js/component/editor/keyword/python.js
index a24d570..eeb944d 100644
--- a/src/js/component/editor/keyword/python.js
+++ b/src/js/component/editor/keyword/python.js
@@ -1,5 +1,5 @@
-import _ from 'lodash';
-import globalcache from '@js/service/db/globalcache.js';
+import { map, isEmpty } from 'lodash';
+import util from '../util';
import storage from '@/js/helper/storage';
const pyKeywordInfoProposals = [
@@ -215,35 +215,13 @@ const pyKeywordInfoProposals = [
},
];
-/**
- * 对拿到的数据格式化成completionList格式
- * @param {*} monaco 编辑器
- * @param {*} list 格式化列表
- * @return {*} 格式化后的列表
- */
-function completionListFormatter(monaco, list) {
- const formatList = [];
- list.forEach((item) => {
- if (item.udfType === 1 || item.udfType === 3) {
- formatList.push({
- label: item.udfName,
- kind: monaco.languages.CompletionItemKind.Function,
- insertText: item.udfName,
- detail: item.udfType > 2 ? '方法函数' : 'UDF函数',
- documentation: item.description,
- });
- }
- });
- return formatList;
-}
+let functionProposals = [];
export default {
async register(monaco) {
- const userInfo = storage.get('userInfo');
- const userName = userInfo.basic.userName;
- const globalCache = await globalcache.getCache(userName);
+ const lang = 'python';
- const pyProposals = _.map(pyKeywordInfoProposals, (item) => ({
+ const pyProposals = map(pyKeywordInfoProposals, (item) => ({
label: item.label.toLowerCase(),
kind: monaco.languages.CompletionItemKind.Keyword,
insertText: item.insertText.toLowerCase(),
@@ -251,18 +229,25 @@ export default {
documentation: item.documentation,
}));
- let functionProposals = completionListFormatter(monaco, globalCache.fnList);
+ util.getHiveList(monaco, lang).then((list) => {
+ functionProposals = list.udfProposals;
+ });
monaco.languages.registerCompletionItemProvider('python', {
triggerCharacters: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789._'.split(''),
async provideCompletionItems(model, position) {
+ if (isEmpty(functionProposals)) {
+ util.getHiveList(monaco, lang).then((list) => {
+ functionProposals = list.udfProposals;
+ });
+ }
+
const textUntilPosition = model.getValueInRange({
startLineNumber: position.lineNumber,
startColumn: 1,
endLineNumber: position.lineNumber,
endColumn: position.column,
});
- let completionList = null;
const keywordMatch = textUntilPosition.match(/([^"]*)?$/i);
const functionMatch = textUntilPosition.match(/\s+/i);
if (functionMatch) {
@@ -270,14 +255,15 @@ export default {
// 如果函数发生load状态变化,则重新从indexdb中获取fnlist
if (isFunctionChange) {
storage.set('isFunctionChange_python', false);
- const globalCache = await globalcache.getCache(userName);
- functionProposals = completionListFormatter(monaco, globalCache.fnList);
+ await util.getHiveList(monaco, lang).then((list) => {
+ return list.udfProposals;
+ });
}
- completionList = functionProposals;
+ return functionProposals;
} else if (keywordMatch) {
- completionList = pyProposals;
+ return pyProposals;
}
- return completionList;
+ return [];
},
});
},
From 889aad41f8e8c2d28f19daf6675d2df9f256672e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=9D=92=E7=BE=BD?=
Date: Fri, 16 Aug 2019 16:52:45 +0800
Subject: [PATCH 4/7] 1.add admin model to global history; 2.tables in global
history use handwritten plugins; 3.tables in workbench history use
handwritten plugins;
---
src/js/component/editor/index.scss | 18 +-
.../table/historyTable.vue} | 65 ++++-
src/js/module/globalHistory/expand.js | 21 --
src/js/module/globalHistory/index.scss | 128 ++++-----
src/js/module/globalHistory/index.vue | 255 +++++++++++++-----
src/js/module/globalHistory/log.vue | 157 +++++++++++
src/js/module/logView/index.js | 4 +
src/js/module/logView/index.scss | 57 ++++
src/js/module/logView/index.vue | 203 ++++++++++++++
src/js/module/workbench/index.scss | 19 +-
src/js/module/workbench/script/history.vue | 169 ++++--------
src/js/service/mixin.js | 12 +-
src/js/service/router.js | 50 +++-
src/js/view/console/index.vue | 91 +++----
14 files changed, 885 insertions(+), 364 deletions(-)
rename src/js/{module/globalHistory/table.vue => component/table/historyTable.vue} (78%)
delete mode 100644 src/js/module/globalHistory/expand.js
create mode 100644 src/js/module/globalHistory/log.vue
create mode 100755 src/js/module/logView/index.js
create mode 100755 src/js/module/logView/index.scss
create mode 100755 src/js/module/logView/index.vue
diff --git a/src/js/component/editor/index.scss b/src/js/component/editor/index.scss
index f1baf72..70a1304 100644
--- a/src/js/component/editor/index.scss
+++ b/src/js/component/editor/index.scss
@@ -4,10 +4,24 @@
height: 100%;
width: 100%;
- .monaco-editor {
+ .monaco-editor.vs {
.overflow-guard {
.monaco-scrollable-element {
- left: 82px !important;
+ .token {
+ &.log-error {
+ color: red;
+ font-weight: bold;
+ }
+ &.log-warn {
+ color: yellow;
+ }
+ &.log-info {
+ color: blue;
+ }
+ &.log-date {
+ color: green;
+ }
+ }
}
}
}
diff --git a/src/js/module/globalHistory/table.vue b/src/js/component/table/historyTable.vue
similarity index 78%
rename from src/js/module/globalHistory/table.vue
rename to src/js/component/table/historyTable.vue
index 72953b7..f5ae138 100644
--- a/src/js/module/globalHistory/table.vue
+++ b/src/js/component/table/historyTable.vue
@@ -16,7 +16,7 @@
:key="th.key"
:style="{'min-width': th.width + 'px', 'text-align': th.align}"
class="we-table-thead-cell">
- {{ th.title }}
+ {{ th.title || '#' }}
@@ -26,21 +26,24 @@
:key="index"
class="we-table-row">
+ :style="{'width': th.width ? th.width + 'px' : getComputedWidth(th)}"
+ :class="{'ellipsis': th.ellipsis}"
+ :title="th.ellipsis ? td[th.key] : ''">
- {{ td[th.key] }}
+ {{ td[th.key] }}
|
@@ -52,6 +55,7 @@
import moment from 'moment';
import util from '@/js/util';
import TableExpand from './expand';
+import elementResizeEvent from '@js/helper/elementResizeEvent';
export default {
components: {
TableExpand,
@@ -69,9 +73,15 @@ export default {
},
data() {
return {
-
+ offsetWidth: 0,
};
},
+ mounted() {
+ elementResizeEvent.bind(this.$el, this.resize);
+ },
+ beforeDestroy: function() {
+ elementResizeEvent.unbind(this.$el);
+ },
methods: {
renderComponent({ type, cell, key, params }) {
const value = cell[key];
@@ -88,6 +98,10 @@ export default {
return this.renderFormatTime(value);
case 'convertTime':
return this.renderConvertTime(value);
+ case 'index':
+ return this.renderIndex(cell);
+ case 'a':
+ return this.renderA(value, cell, params);
default:
return null;
}
@@ -244,7 +258,44 @@ export default {
return h('span', {}, util.convertTimestamp(value));
};
},
+ renderIndex(cell) {
+ const index = this.data.findIndex((item) => item.taskID === cell.taskID);
+ return (h) => {
+ return h('span', {}, index + 1);
+ };
+ },
+ renderA(value, cell, params) {
+ return (h) => {
+ return h('div', {
+ style: {
+ cursor: 'pointer',
+ color: '#ed4014',
+ },
+ on: {
+ click: (ev) => {
+ params.action({ row: cell });
+ },
+ },
+ }, value);
+ };
+ },
+ getComputedWidth(current) {
+ this.offsetWidth = this.$el && this.$el.offsetWidth;
+ let usedWidth = 0;
+ const unHasWidthList = [];
+ this.columns.forEach((item) => {
+ const width = item.width || 0;
+ usedWidth += width;
+ if (!item.width) {
+ unHasWidthList.push(item);
+ }
+ });
+ return (this.offsetWidth - 30 - usedWidth) / unHasWidthList.length + 'px';
+ },
+ resize() {
+ this.offsetWidth = this.$el && this.$el.offsetWidth;
+ },
},
};
-
+
diff --git a/src/js/module/globalHistory/expand.js b/src/js/module/globalHistory/expand.js
deleted file mode 100644
index 945a279..0000000
--- a/src/js/module/globalHistory/expand.js
+++ /dev/null
@@ -1,21 +0,0 @@
-export default {
- name: 'TableExpand',
- functional: true,
- props: {
- row: Object,
- render: Function,
- index: Number,
- column: {
- type: Object,
- default: null,
- },
- },
- render: (h, ctx) => {
- const params = {
- row: ctx.props.row,
- index: ctx.props.index,
- };
- if (ctx.props.column) params.column = ctx.props.column;
- return ctx.props.render(h, params);
- },
-};
diff --git a/src/js/module/globalHistory/index.scss b/src/js/module/globalHistory/index.scss
index 18088c9..08d2e9b 100644
--- a/src/js/module/globalHistory/index.scss
+++ b/src/js/module/globalHistory/index.scss
@@ -1,28 +1,4 @@
@import '../../../assets/styles/variables.scss';
-.render-btn {
- color: #515a6e;
- background-color: transparent;
- border-color: transparent;
- padding: 1px 7px 2px;
- font-size: 12px;
- border-radius: 3px;
- display: inline-block;
- margin-bottom: 0;
- font-weight: 400;
- text-align: center;
- cursor: pointer;
- background-image: none;
- border: 1px solid transparent;
- white-space: nowrap;
- border-radius: 4px;
- transition: color .2s linear,background-color .2s linear,border .2s linear,box-shadow .2s linear;
- &:hover {
- color: #57a3f3;
- background-color: #fff;
- border-color: transparent;
- text-decoration: none;
- }
-}
.progress-wrap {
position: $relative;
height: 20px;
@@ -45,6 +21,7 @@
}
.global-history {
position: $relative;
+ height: 100%;
.ivu-form {
display: flex;
.ivu-form-item {
@@ -58,69 +35,11 @@
display: flex;
justify-content: center;
align-items: center;
+ margin-top: 16px;
.ivu-table th {
background-color: $table-thead-blue-bg;
color: $body-background;
}
- .we-table-wrap {
- overflow: auto;
- display: block;
- .we-table {
- border: $border-width-base $border-style-base $border-color-base;
- table-layout: fixed;
- .we-table-thead {
- background-color: $table-thead-blue-bg;
- color: $body-background;
- .we-table-thead-cell {
- border-right: 1px solid $border-color-base;
- border-bottom: 1px solid $border-color-base;
- min-width: 0;
- height: 48px;
- box-sizing: border-box;
- text-align: left;
- text-overflow: ellipsis;
- vertical-align: middle;
- }
- }
- .we-table-row {
- height: 40px;
- &:nth-child(2n) {
- background-color: #f8f8f9;
- }
- &:hover {
- background-color: #ebf7ff;
- }
- .we-table-row-cell {
- border-right: 1px solid $border-color-base;
- border-bottom: 1px solid $border-color-base;
- min-width: 0;
- height: 48px;
- box-sizing: border-box;
- text-align: left;
- text-overflow: ellipsis;
- vertical-align: middle;
- .we-table-row-label {
- line-height: 20px;
- padding-left: 18px;
- padding-right: 18px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: normal;
- word-break: break-all;
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
- &.ellipsis {
- text-align: left;
- word-break: keep-all;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- }
- }
- }
- }
- }
}
.global-history-loading {
width: 100%;
@@ -140,4 +59,47 @@
width: 100%;
text-align: center;
}
+
+ .log-editor-wrap {
+ border: $border-width-base $border-style-base $border-color-base;
+ box-shadow: $shadow-card;
+ position: $absolute;
+ left: 0;
+ right: 0;
+ top: 40px;
+ bottom: 10px;
+
+ .log-tools {
+ height: 36px;
+ line-height: 36px;
+ padding-left: 10px;
+ background: $background-color-base;
+ position: $relative;
+ border-bottom: 2px solid $border-color-base;
+ overflow: hidden;
+ margin-bottom: -2px;
+ .log-tools-control {
+ display: inline-block;
+ position: $absolute;
+ top: 2px;
+ .log-tabs {
+ display: inline-block;
+ position: $absolute;
+ }
+ .log-search {
+ width: 100px;
+ position: $absolute;
+ left: 350px;
+ top: 5px;
+ font-size: $font-size-small;
+ }
+ .err-badge {
+ background: $error-color !important;
+ }
+ .warn-badge {
+ background: $yellow-color !important;
+ }
+ }
+ }
+ }
}
diff --git a/src/js/module/globalHistory/index.vue b/src/js/module/globalHistory/index.vue
index b0ca508..04e5ac2 100644
--- a/src/js/module/globalHistory/index.vue
+++ b/src/js/module/globalHistory/index.vue
@@ -8,30 +8,52 @@
-
+ placeholder="请输入ID搜索"
+ style="width:100px;"
+ :min="1"
+ :readonly="isLogModuleShow">
+ prop="proxyUser"
+ label="用户名"
+ v-if="isAdminModel">
+
+
+
+
+ style="width: 200px"
+ :editable="false"/>
+ class="divider"
+ v-if="!isLogModuleShow"/>
+ label="引擎"
+ v-if="!isLogModuleShow">