From cc13bc70cc22589209996018eb5e5cda773e8e97 Mon Sep 17 00:00:00 2001 From: CoderSerio Date: Tue, 5 Sep 2023 16:10:35 +0800 Subject: [PATCH 01/21] feat: init the layout of new web page of controller --- linkis-web/.env | 2 +- linkis-web/package.json | 160 ++-- .../apps/linkis/module/codeQuery/index.vue | 242 +++--- .../module/globalHistoryManagement/index.vue | 173 +++-- .../module/resourceManagement/index.vue | 709 +++++++++++------- linkis-web/vue.config.js | 158 ++-- 6 files changed, 894 insertions(+), 550 deletions(-) diff --git a/linkis-web/.env b/linkis-web/.env index d9f101acc3..5983420f56 100644 --- a/linkis-web/.env +++ b/linkis-web/.env @@ -1,5 +1,5 @@ VUE_APP_HOST= -BACKEND_URL=http://127.0.0.1:9001 +BACKEND_URL=http://106.52.77.156:19888 VUE_APP_MN_CONFIG_PREFIX= VUE_APP_MN_CONFIG_SOCKET=/ws/api/entrance/connect VUE_APP_VERSION=1.3.2 diff --git a/linkis-web/package.json b/linkis-web/package.json index 064566871d..7e722ec39f 100644 --- a/linkis-web/package.json +++ b/linkis-web/package.json @@ -1,83 +1,83 @@ { - "name": "linkis", - "version": "1.3.2", - "private": true, - "scripts": { - "serve": "vue-cli-service serve", - "build": "vue-cli-service build", - "lint": "vue-cli-service lint --no-fix", - "fix": "eslint --ext .js,.vue src --fix", - "precommit": "lint-staged", - "preinstall": "npm install --package-lock-only --ignore-scripts && npx npm-force-resolutions" - }, - "husky": { - "hooks": { - "postcommit": "git update-index --again", - "pre-commit": "lint-staged" - } - }, - "lint-staged": { - "src/**/*.{js,vue}": [ - "vue-cli-service lint --no-fix" - ] - }, - "dependencies": { - "@form-create/iview": "2.5.27", - "axios": "0.21.4", - "babel-polyfill": "6.26.0", - "core-js": "3.27.2", - "dexie": "3.2.3", - "dt-sql-parser": "3.0.5", - "eslint": "7.21.0", - "eslint-plugin-vue": "9.6.0", - "highlight.js": "10.7.0", - "iview": "3.5.4", - "jsencrypt": "3.2.1", - "lodash": "4.17.21", - "md5": "2.3.0", - "mitt": "1.2.0", - "moment": "2.29.4", - "monaco-editor": "0.30.1", - "object-to-formdata": "4.2.2", - "path-browserify": "1.0.1", - "postcss": "8.4.21", - "qs": "6.11.0", - "reconnecting-websocket": "4.4.0", - "sql-formatter": "2.3.3", - "svgo": "3.0.2", - "v-jsoneditor": "1.4.5", - "vue": "2.6.12", - "vue-i18n": "8.22.1", - "vue-router": "3.4.8", - "vuedraggable": "2.24.3", - "vuescroll": "4.16.1", - "worker-loader": "3.0.8" - }, - "devDependencies": { - "@intlify/vue-i18n-loader": "1.0.0", - "@vue/cli-plugin-babel": "5.0.8", - "@vue/cli-plugin-eslint": "5.0.8", - "@vue/cli-service": "5.0.8", - "@vue/eslint-config-standard": "4.0.0", - "archiver": "3.1.1", - "autoprefixer": "10.4.14", - "babel-eslint": "10.1.0", - "copy-webpack-plugin": "9.1.0", - "csp-html-webpack-plugin": "5.1.0", - "filemanager-webpack-plugin": "7.0.0", - "husky": "1.3.1", - "lint-staged": "13.1.1", - "material-design-icons": "3.0.1", - "monaco-editor-webpack-plugin": "6.0.0", - "node-sass": "8.0.0", - "npm-force-resolutions": "0.0.10", - "sass-loader": "10.4.1", - "svg-sprite-loader": "6.0.0", - "vue-cli-plugin-mockjs": "0.1.3", - "vue-template-compiler": "2.6.12", - "webpack-virtual-modules": "0.3.2" - }, - "resolutions": { - "postcss": "8.4.21" + "name": "linkis", + "version": "1.3.2", + "private": true, + "scripts": { + "serve": "vue-cli-service serve", + "build": "vue-cli-service build", + "lint": "vue-cli-service lint --no-fix", + "fix": "eslint --ext .js,.vue src --fix", + "precommit": "lint-staged", + "preinstall": "npm install --package-lock-only --ignore-scripts && npx npm-force-resolutions" + }, + "husky": { + "hooks": { + "postcommit": "git update-index --again", + "pre-commit": "lint-staged" } + }, + "lint-staged": { + "src/**/*.{js,vue}": [ + "vue-cli-service lint --no-fix" + ] + }, + "dependencies": { + "@form-create/iview": "2.5.27", + "axios": "0.21.4", + "babel-polyfill": "6.26.0", + "core-js": "^3.31.0", + "dexie": "3.2.3", + "dt-sql-parser": "3.0.5", + "eslint": "7.21.0", + "eslint-plugin-vue": "9.6.0", + "highlight.js": "10.7.0", + "iview": "3.5.4", + "jsencrypt": "3.2.1", + "lodash": "4.17.21", + "md5": "2.3.0", + "mitt": "1.2.0", + "moment": "2.29.4", + "monaco-editor": "0.30.1", + "object-to-formdata": "4.2.2", + "path-browserify": "1.0.1", + "postcss": "8.4.21", + "qs": "6.11.0", + "reconnecting-websocket": "4.4.0", + "sql-formatter": "2.3.3", + "svgo": "3.0.2", + "v-jsoneditor": "1.4.5", + "vue": "2.6.12", + "vue-i18n": "8.22.1", + "vue-router": "3.4.8", + "vuedraggable": "2.24.3", + "vuescroll": "4.16.1", + "worker-loader": "3.0.8" + }, + "devDependencies": { + "@intlify/vue-i18n-loader": "1.0.0", + "@vue/cli-plugin-babel": "5.0.8", + "@vue/cli-plugin-eslint": "5.0.8", + "@vue/cli-service": "5.0.8", + "@vue/eslint-config-standard": "4.0.0", + "archiver": "3.1.1", + "autoprefixer": "10.4.14", + "babel-eslint": "10.1.0", + "copy-webpack-plugin": "9.1.0", + "csp-html-webpack-plugin": "5.1.0", + "filemanager-webpack-plugin": "7.0.0", + "husky": "1.3.1", + "lint-staged": "13.1.1", + "material-design-icons": "3.0.1", + "monaco-editor-webpack-plugin": "6.0.0", + "node-sass": "8.0.0", + "npm-force-resolutions": "0.0.10", + "sass-loader": "10.4.1", + "svg-sprite-loader": "6.0.0", + "vue-cli-plugin-mockjs": "0.1.3", + "vue-template-compiler": "2.6.12", + "webpack-virtual-modules": "0.3.2" + }, + "resolutions": { + "postcss": "8.4.21" + } } diff --git a/linkis-web/src/apps/linkis/module/codeQuery/index.vue b/linkis-web/src/apps/linkis/module/codeQuery/index.vue index 1afef71a20..a1ddaa3920 100644 --- a/linkis-web/src/apps/linkis/module/codeQuery/index.vue +++ b/linkis-web/src/apps/linkis/module/codeQuery/index.vue @@ -17,23 +17,48 @@ @@ -108,14 +142,14 @@ export default { tableData: [], beforeSearch: true, searchBar: { - executionCode: "", + executionCode: '', shortcut: [], - status: "", + status: '' }, searchParams: { - executionCode: "", + executionCode: '', shortcut: [], - status: "", + status: '' }, tableLoading: false, isLogAdmin: false, @@ -199,28 +233,32 @@ export default { align: 'center', render: (h, params) => { return h('div', [ - h('Button', { - // props: { - // type: 'default', - // size: 'small' - // }, - class: { - 'render-btn': true, - }, - on: { - click: () => { - this.check(params.row.id) + h( + 'Button', + { + // props: { + // type: 'default', + // size: 'small' + // }, + class: { + 'render-btn': true + }, + on: { + click: () => { + this.check(params.row.id) + } } - } - }, this.$t('message.linkis.codeQuery.check')) - ]); + }, + this.$t('message.linkis.codeQuery.check') + ) + ]) } }, { title: this.$t('message.linkis.codeQuery.id'), key: 'id', width: 200, - align: 'center', + align: 'center' }, { title: this.$t('message.linkis.codeQuery.code'), @@ -248,33 +286,39 @@ export default { tooltip: true, align: 'center', render: (h, params) => { - return h('Tag', { - props: { - color: this.colorGetter(params.row.status) - } - }, this.$t(`message.linkis.statusType.${params.row.status.toLowerCase()}`)) + return h( + 'Tag', + { + props: { + color: this.colorGetter(params.row.status) + } + }, + this.$t( + `message.linkis.statusType.${params.row.status.toLowerCase()}` + ) + ) } - }, + } ], page: { pageSize: 10, pageNow: 1, - totalPage: 0, + totalPage: 0 }, - userName: '', + userName: '' } }, computed: { noDataText() { - if(this.beforeSearch) { + if (this.beforeSearch) { return this.$t('message.linkis.noDataTextBeforeSearch') } return this.$t('message.linkis.noDataTextAfterSearch') - }, + } }, methods: { confirmSearch() { - if(this.tableLoading) return; + if (this.tableLoading) return this.searchParams = cloneDeep(this.searchBar) this.page.pageNow = 1 this.search() @@ -289,33 +333,33 @@ export default { }, async reset() { this.searchBar = { - executionCode: "", + executionCode: '', shortcut: [], - status: "", - }; + status: '' + } this.searchParams = { - executionCode: "", + executionCode: '', shortcut: [], - status: "", - }; - this.beforeSearch = true; - this.tableData = []; + status: '' + } + this.beforeSearch = true + this.tableData = [] }, async changePage(val) { - this.page.pageNow = val; - await this.search(); + this.page.pageNow = val + await this.search() }, async search() { try { this.tableLoading = true - if(!this.searchParams.executionCode) { + if (!this.searchParams.executionCode) { this.$Message.warning(this.$t('message.linkis.codeQuery.inputCode')) - this.beforeSearch = true; - throw Error(this.$t('message.linkis.codeQuery.inputCode')); + this.beforeSearch = true + throw Error(this.$t('message.linkis.codeQuery.inputCode')) } - this.beforeSearch = false; - const { executionCode, shortcut, status } = this.searchParams; - const { pageNow, pageSize } = this.page; + this.beforeSearch = false + const { executionCode, shortcut, status } = this.searchParams + const { pageNow, pageSize } = this.page const params = { executionCode, startDate: Date.parse(shortcut[0]), @@ -332,12 +376,12 @@ export default { if (!status || status === 'all') { delete params.status } - const res = await api.fetch(`/jobhistory/es/search`, params, 'get'); + const res = await api.fetch(`/jobhistory/es/search`, params, 'get') this.tableData = res.tasks.content this.page.totalPage = res.tasks.totalElements this.tableLoading = false } catch (err) { - window.console.warn(err); + window.console.warn(err) this.tableLoading = false } }, @@ -346,10 +390,10 @@ export default { id } // set storage - sessionStorage.setItem('code-search', JSON.stringify(this.searchParams)); - sessionStorage.setItem('code-use-cache', true); - sessionStorage.setItem('code-search-page', JSON.stringify(this.page)); - sessionStorage.setItem('code-search-admin', this.isAdminModel); + sessionStorage.setItem('code-search', JSON.stringify(this.searchParams)) + sessionStorage.setItem('code-use-cache', true) + sessionStorage.setItem('code-search-page', JSON.stringify(this.page)) + sessionStorage.setItem('code-search-admin', this.isAdminModel) this.$router.push({ path: '/console/codeDetail', @@ -359,44 +403,46 @@ export default { colorGetter(status) { switch (status) { case 'Running': - return 'yellow'; + return 'yellow' case 'Succeed': - return 'green'; + return 'green' case 'Failed': - return 'red'; + return 'red' default: - break; + break } - }, + } }, created() { // 获取是否是历史管理员权限 - api.fetch('/jobhistory/governanceStationAdmin', 'get').then(res => { + api.fetch('/jobhistory/governanceStationAdmin', 'get').then((res) => { this.isLogAdmin = res.admin }) }, beforeRouteEnter(to, from, next) { - if(from.name !== 'codeDetail') { - sessionStorage.removeItem('code-search'); - sessionStorage.removeItem('code-search-page'); - sessionStorage.removeItem('code-search-admin'); - sessionStorage.setItem('code-use-cache', false); + if (from.name !== 'codeDetail') { + sessionStorage.removeItem('code-search') + sessionStorage.removeItem('code-search-page') + sessionStorage.removeItem('code-search-admin') + sessionStorage.setItem('code-use-cache', false) } - next(); + next() }, mounted() { - if(sessionStorage.getItem('code-use-cache') === 'true') { - this.searchParams = JSON.parse(sessionStorage.getItem('code-search')); - this.searchBar = JSON.parse(sessionStorage.getItem('code-search')); - this.page = JSON.parse(sessionStorage.getItem('code-search-page')); - this.isAdminModel = JSON.parse(sessionStorage.getItem('code-search-admin')); - if(sessionStorage.getItem('isLogAdmin') !== 'true') { - this.isAdminModel = false; + if (sessionStorage.getItem('code-use-cache') === 'true') { + this.searchParams = JSON.parse(sessionStorage.getItem('code-search')) + this.searchBar = JSON.parse(sessionStorage.getItem('code-search')) + this.page = JSON.parse(sessionStorage.getItem('code-search-page')) + this.isAdminModel = JSON.parse( + sessionStorage.getItem('code-search-admin') + ) + if (sessionStorage.getItem('isLogAdmin') !== 'true') { + this.isAdminModel = false } - this.search(); + this.search() } } -}; +} diff --git a/linkis-web/src/apps/linkis/module/globalHistoryManagement/index.vue b/linkis-web/src/apps/linkis/module/globalHistoryManagement/index.vue index 8a35fa8695..43955f7573 100644 --- a/linkis-web/src/apps/linkis/module/globalHistoryManagement/index.vue +++ b/linkis-web/src/apps/linkis/module/globalHistoryManagement/index.vue @@ -22,19 +22,26 @@ - + - + - + - + - + - + + 123 - - - + + + + >{{ + isAdminModel + ? $t('message.linkis.generalView') + : $t('message.linkis.manageView') + }} -
-
- +
+
+
@@ -267,11 +306,11 @@ export default { }, created() { // Get whether it is a historical administrator(获取是否是历史管理员权限) - api.fetch('/jobhistory/governanceStationAdmin', 'get').then(res => { + api.fetch('/jobhistory/governanceStationAdmin', 'get').then((res) => { this.isLogAdmin = res.admin this.isHistoryAdmin = res.historyAdmin }) - api.fetch('/configuration/engineType', 'get').then(res => { + api.fetch('/configuration/engineType', 'get').then((res) => { this.getEngineTypes = ['all', ...res.engineType] }) }, @@ -288,12 +327,12 @@ export default { window.removeEventListener('resize', this.getHeight) }, beforeRouteEnter(to, from, next) { - if(from.name !== 'viewHistory') { - sessionStorage.removeItem('last-admin-model'); - sessionStorage.removeItem('last-searchbar-status'); - sessionStorage.removeItem('last-pageSetting-status'); + if (from.name !== 'viewHistory') { + sessionStorage.removeItem('last-admin-model') + sessionStorage.removeItem('last-searchbar-status') + sessionStorage.removeItem('last-pageSetting-status') } - next(); + next() }, activated() { this.init() @@ -308,7 +347,10 @@ export default { const lastPage = storage.get('last-pageSetting-status') if (lastSearch) { if (lastSearch.shortcut[0] && lastSearch.shortcut[1]) { - lastSearch.shortcut = [new Date(lastSearch.shortcut[0]), new Date(lastSearch.shortcut[1])] + lastSearch.shortcut = [ + new Date(lastSearch.shortcut[0]), + new Date(lastSearch.shortcut[1]) + ] } else { const today = new Date(new Date().toLocaleDateString()) lastSearch.shortcut = [today, today] @@ -361,7 +403,7 @@ export default { if (sourceJson && sourceJson.nodeName) { fileName = sourceJson.nodeName } - const query = { + const query = { taskID: params.row.taskID, execID: params.row.strongerExecId, status: params.row.status, @@ -380,8 +422,12 @@ export default { }, getParams(page) { - const startDate = this.searchBar.shortcut[0] ? new Date(this.searchBar.shortcut[0].setHours(0, 0, 0, 0)) : this.searchBar.shortcut[0] - const endDate = this.searchBar.shortcut[1] ? new Date(this.searchBar.shortcut[1].setHours(23, 59, 59, 0)): this.searchBar.shortcut[1] + const startDate = this.searchBar.shortcut[0] + ? new Date(this.searchBar.shortcut[0].setHours(0, 0, 0, 0)) + : this.searchBar.shortcut[0] + const endDate = this.searchBar.shortcut[1] + ? new Date(this.searchBar.shortcut[1].setHours(23, 59, 59, 0)) + : this.searchBar.shortcut[1] const params = { taskID: this.searchBar.id, creator: this.searchBar.creator, @@ -430,7 +476,7 @@ export default { this.column = this.getColumns() api .fetch('/jobhistory/list', params, 'get') - .then(rst => { + .then((rst) => { this.isLoading = false this.list = this.getList(rst.tasks) this.pageSetting.current = page @@ -447,7 +493,7 @@ export default { this.column = this.getColumns() api .fetch('/jobhistory/list', params, 'get') - .then(rst => { + .then((rst) => { this.pageSetting.total = rst.totalPage this.isLoading = false this.list = this.getList(rst.tasks) @@ -458,15 +504,18 @@ export default { }) }, getList(list) { - const getFailedReason = item => { + const getFailedReason = (item) => { return item.errCode && item.errDesc ? item.errCode + item.errDesc : item.errCode || item.errDesc || '' } if (!this.isAdminModel) { - return list.map(item => { + return list.map((item) => { return { - disabled: ['Submitted', 'Inited', 'Scheduled', 'Running'].indexOf(item.status) === -1, + disabled: + ['Submitted', 'Inited', 'Scheduled', 'Running'].indexOf( + item.status + ) === -1, taskID: item.taskID, strongerExecId: item.strongerExecId, source: item.sourceTailor, @@ -483,17 +532,19 @@ export default { } }) } - return list.map(item => { + return list.map((item) => { return Object.assign(item, { disabled: - ['Submitted', 'Inited', 'Scheduled', 'Running'].indexOf(item.status) === -1, + ['Submitted', 'Inited', 'Scheduled', 'Running'].indexOf( + item.status + ) === -1, failedReason: getFailedReason(item), source: item.sourceTailor }) }) }, checkChange(v) { - this.list = this.list.map(it => { + this.list = this.list.map((it) => { it.checked = !it.disabled && v return it }) @@ -602,7 +653,7 @@ export default { } ] if (!this.isAdminModel) { - const index = column.findIndex(item => item.key === 'umUser') + const index = column.findIndex((item) => item.key === 'umUser') column.splice(index, 1) } return column @@ -658,17 +709,17 @@ export default { } }, stop() { - const selected = this.list.filter(it => it.checked) + const selected = this.list.filter((it) => it.checked) if (!selected.length) { this.$Message.warning(this.$t('message.linkis.unselect')) - return; + return } this.$Modal.confirm({ title: this.$t('message.linkis.modal.modalTitle'), content: this.$t('message.linkis.modal.modalDeleteTask'), - onOk: ()=>{ + onOk: () => { const inst = {} - selected.forEach(it => { + selected.forEach((it) => { if (inst[it.instance]) { inst[it.instance].taskIDList.push(it.taskID) inst[it.instance].idList.push(it.strongerExecId) @@ -680,12 +731,22 @@ export default { } }) const p = [] - Object.keys(inst).forEach(instkey => { - if (instkey) p.push(api.fetch(`/entrance/${inst[instkey].idList[0]}/killJobs`, { idList: inst[instkey].idList, taskIDList: inst[instkey].taskIDList }, 'post')) + Object.keys(inst).forEach((instkey) => { + if (instkey) + p.push( + api.fetch( + `/entrance/${inst[instkey].idList[0]}/killJobs`, + { + idList: inst[instkey].idList, + taskIDList: inst[instkey].taskIDList + }, + 'post' + ) + ) }) - Promise.all(p).then(()=> { - this.$Message.success(this.$t('message.linkis.udf.success')); + Promise.all(p).then(() => { + this.$Message.success(this.$t('message.linkis.udf.success')) this.search() }) } diff --git a/linkis-web/src/apps/linkis/module/resourceManagement/index.vue b/linkis-web/src/apps/linkis/module/resourceManagement/index.vue index 12f438b5ac..323710f2d7 100644 --- a/linkis-web/src/apps/linkis/module/resourceManagement/index.vue +++ b/linkis-web/src/apps/linkis/module/resourceManagement/index.vue @@ -17,38 +17,66 @@