This is an automated email from the ASF dual-hosted git repository. xxyu pushed a commit to branch kylin5 in repository https://gitbox.apache.org/repos/asf/kylin.git
commit 23aa4fd3c92f419cb8f88c1ef3b25d708194c38d Author: Qian Xia <lauraxiaq...@gmail.com> AuthorDate: Fri Jul 28 18:12:54 2023 +0800 KYLIN-5674 model detail issue --- kystudio/src/components/layout/layout_full.vue | 3 +- .../StudioModel/ModelList/AggregateModal/store.js | 2 + .../ModelList/ModelLayout/modelLayout.vue | 157 ++++++++++++--------- .../studio/StudioModel/ModelList/index.vue | 6 +- kystudio/src/store/model.js | 4 +- 5 files changed, 103 insertions(+), 69 deletions(-) diff --git a/kystudio/src/components/layout/layout_full.vue b/kystudio/src/components/layout/layout_full.vue index 33922c0fcd..cb7ba62274 100644 --- a/kystudio/src/components/layout/layout_full.vue +++ b/kystudio/src/components/layout/layout_full.vue @@ -49,6 +49,7 @@ import { filterInjectScript } from 'util' @Component({ computed: { ...mapGetters([ + 'isAdminRole', 'isProjectOperator', 'isAdvancedOperator' ]), @@ -60,7 +61,7 @@ import { filterInjectScript } from 'util' provide () { return { forceUpdateRoute: this.forceUpdateRoute, - isAdvancedOperatorUser: () => this.isProjectOperator && this.isAdvancedOperator // 高级运维人员,可以设计索引 + isAdvancedOperatorUser: () => (this.isProjectOperator || this.isAdminRole) && this.isAdvancedOperator // 高级运维人员,可以设计索引 } }, components: { diff --git a/kystudio/src/components/studio/StudioModel/ModelList/AggregateModal/store.js b/kystudio/src/components/studio/StudioModel/ModelList/AggregateModal/store.js index 844157863f..c56324c325 100644 --- a/kystudio/src/components/studio/StudioModel/ModelList/AggregateModal/store.js +++ b/kystudio/src/components/studio/StudioModel/ModelList/AggregateModal/store.js @@ -151,6 +151,8 @@ export default { initAggregate.measures = measuresList state.form.aggregateArray.push(initAggregate) } + } else { + state.originFormData = [] } } }, diff --git a/kystudio/src/components/studio/StudioModel/ModelList/ModelLayout/modelLayout.vue b/kystudio/src/components/studio/StudioModel/ModelList/ModelLayout/modelLayout.vue index cc8186aae3..033a915f9a 100644 --- a/kystudio/src/components/studio/StudioModel/ModelList/ModelLayout/modelLayout.vue +++ b/kystudio/src/components/studio/StudioModel/ModelList/ModelLayout/modelLayout.vue @@ -24,6 +24,7 @@ @rename="changeModelName" @loadModelsList="reloadModel" @loadModels="reloadModel" + :modelListFilters="modelListFilters" :currentModel="currentModelRow" :appendToBody="true" :editText="$t('modelEditAction')" @@ -133,7 +134,7 @@ import { Component } from 'vue-property-decorator' import { mapState, mapGetters, mapActions } from 'vuex' import { handleError, jumpToJobs } from 'util/business' import { transToServerGmtTime, handleSuccessAsync } from 'util' -import { pageRefTags, pageCount } from 'config' +import { pageCount } from 'config' import locales from './locales' import ModelOverview from '../ModelOverview/ModelOverview.vue' import ModelSegment from '../ModelSegment/index.vue' @@ -156,19 +157,18 @@ import ModelTitleDescription from '../Components/ModelTitleDescription' @Component({ beforeRouteEnter (to, from, next) { - if (!from.name || from.name !== 'ModelList') { - next((vm) => { - vm.initData = true - vm.modelPageOffest = to.query.modelPageOffest - vm.__init() - }) - } else { - next((vm) => { - vm.initData = true - vm.modelPageOffest = to.query.modelPageOffest - vm.initModelData() - }) - } + next(vm => { + // 从模型页面过来,用模型列表的过滤条件获取modelList + if (to.query.modelListFilters || getQueryString('modelListFilters')) { + vm.modelListFilters = JSON.parse(to.query.modelListFilters) || JSON.parse(getQueryString('modelListFilters')) + } + + if (from.name === 'ModelList') { + vm.filterData = vm.modelListFilters + } else if (to.query.filterData) { + vm.filterData = JSON.parse(to.query.filterData) + } + }) }, computed: { ...mapGetters([ @@ -227,7 +227,6 @@ import ModelTitleDescription from '../Components/ModelTitleDescription' locales }) export default class ModelLayout extends Vue { - pageRefTags = pageRefTags randomKey = Date.now().toString(32) initData = false currentModelRow = null @@ -237,28 +236,44 @@ export default class ModelLayout extends Vue { buildVisible = {} showModelList = false showSearchResult = false - modelPageOffest = 0 + modelListFilters = {} + filterData = { + page_offset: 0, + page_size: pageCount, + exact: false, + model_name: this.searchModelName, + sort_by: 'last_modify', + reverse: true, + status: [], + model_alias_or_owner: '', + last_modify: [], + owner: '', + project: this.currentSelectedProject + } created () { - // if (!this.initData) { - // this.initModelData() - // } + this.__init() document.addEventListener('click', this.handleClick) } async __init () { - await this.loadModelList() - this.initModelData() + try { + const { modelName } = this.$route.params + this.modelName = modelName + this.$nextTick(async () => { + await this.loadModelList() + this.initModelData() + }) + } catch (e) { + handleError(e) + } } async initModelData () { - const { modelName, searchModelName, tabTypes } = this.$route.params - this.modelName = modelName - this.searchModelName = searchModelName || '' - await this.refreshModelData() - this.currentModelRow = {...this.currentModelRow, tabTypes: typeof tabTypes !== 'undefined' ? tabTypes : 'overview'} - if (this.currentModelRow.tabTypes === 'second' && localStorage.getItem('isFirstSaveModel') === 'true') { - this.showGuide() + try { + await this.refreshModelData('init') + } catch (e) { + handleError(e) } } @@ -267,61 +282,73 @@ export default class ModelLayout extends Vue { } jumpBack () { - this.$router.push({name: 'ModelList'}) + this.$router.push({name: 'ModelList', query: { modelListFilters: JSON.stringify(this.modelListFilters) }}) } // 模型搜索 - searchModel (val) { + searchModel () { + this.resetFilters() this.loadModelList() } + resetFilters () { + this.filterData = { + page_offset: 0, + page_size: pageCount, + exact: false, + model_name: this.searchModelName, + sort_by: 'last_modify', + reverse: true, + status: [], + model_alias_or_owner: '', + last_modify: [], + owner: '', + project: this.currentSelectedProject + } + } + chooseOtherModel ({model, ...args}) { if (model.status && model.status === 'BROKEN') return this.$router.push({name: 'refresh'}) this.$nextTick(() => { - this.$router.replace({name: 'ModelDetails', params: {modelName: model.alias, searchModelName: this.searchModelName, ...args}, query: {modelPageOffest: this.modelPageOffest}}) + this.$router.replace({name: 'ModelDetails', params: {modelName: model.alias, ...args}, query: {modelListFilters: JSON.stringify(this.modelListFilters), filterData: JSON.stringify(this.filterData)}}) }) } - loadModelList (name = '') { - const { modelPageOffest } = this - return new Promise((resolve, reject) => { - const modelName = this.searchModelName || name + async loadModelList () { + try { this.showSearchResult = true - this.loadModels({ - page_offset: modelPageOffest || 0, - page_size: +localStorage.getItem(this.pageRefTags.modelListPager) || pageCount, - exact: false, - model_name: modelName || '', - sort_by: 'last_modify', - reverse: true, - status: [], - model_alias_or_owner: '', - last_modify: [], - owner: '', - project: this.currentSelectedProject - }).then(() => { - this.showSearchResult = false - resolve() - }).catch((res) => { - handleError(res) - reject() - }) - }) + this.filterData.project = this.currentSelectedProject + await this.loadModels(this.filterData) + this.showSearchResult = false + } catch (e) { + handleError(e) + } } // 仅刷新当前 model 数据 - async refreshModelData () { - const response = await this.getModelByModelName({model_name: this.modelName, project: this.currentSelectedProject}) - const { value } = await handleSuccessAsync(response) - if (value.length) { - this.currentModelRow = {...this.currentModelRow, ...value[0]} - if (!this.modelList.filter(it => it.alias === this.modelName).length) { - // 没有匹配到相应的 model + async refreshModelData (type) { + try { + const response = await this.getModelByModelName({model_name: this.modelName, project: this.currentSelectedProject}) + const { value } = await handleSuccessAsync(response) + // 能通过模型名称获取到模型数据,说明该模型存在 + if (value.length) { + if (type === 'init') { + const { tabTypes, createSecStorageIndex, indexTab } = this.$route.params + this.showCreateOrEditSecStorageIndex = createSecStorageIndex ?? false + this.currentIndexTab = indexTab ?? 'indexOverview' + this.currentModelRow = {tabTypes: typeof tabTypes !== 'undefined' ? tabTypes : 'overview', ...value[0]} + if (this.currentModelRow.tabTypes === 'second' && localStorage.getItem('isFirstSaveModel') === 'true') { + this.showGuide() + } + } else { + this.currentModelRow = {...this.currentModelRow, ...value[0]} + } + } else { this.jumpBack() } - } else { - this.$router.replace({ name: 'ModelList', params: {searchModelName: this.searchModelName} }) + } catch (e) { + handleError(e) } } @@ -618,7 +645,7 @@ export default class ModelLayout extends Vue { position: absolute; padding: 0 0 14px 0; box-sizing: border-box; - z-index: 11; + z-index: 9999; line-height: 56px; background: @ke-background-color-white; box-shadow: 0px 2px 8px rgba(50, 73, 107, 24%); diff --git a/kystudio/src/components/studio/StudioModel/ModelList/index.vue b/kystudio/src/components/studio/StudioModel/ModelList/index.vue index 7c34681e68..cbaea53e51 100644 --- a/kystudio/src/components/studio/StudioModel/ModelList/index.vue +++ b/kystudio/src/components/studio/StudioModel/ModelList/index.vue @@ -277,6 +277,10 @@ function getDefaultFilters (that) { vm.filterArgs.model_alias_or_owner = to.params.modelAlias vm.filterArgs.exact = true } + // 从ER图跳转回来的,模糊搜索模型 - KE + if (to.query.modelListFilters) { + vm.filterArgs = {...vm.filterArgs, ...JSON.parse(to.query.modelListFilters)} + } if (to.query.model_alias) { vm.currentEditModel = to.query.model_alias vm.filterArgs.model_alias_or_owner = to.query.model_alias @@ -830,7 +834,7 @@ export default class ModelList extends Vue { modelRowClickEvent (row, e) { if (row.status === 'BROKEN' || ('visible' in row && !row.visible)) return - this.$router.push({name: 'ModelDetails', params: {modelName: row.alias}, query: {modelPageOffest: this.filterArgs.page_offset}}) + this.$router.push({ name: 'ModelDetails', params: {modelName: row.alias}, query: {modelListFilters: JSON.stringify(this.filterArgs)} }) } // 展示 E-R 图 diff --git a/kystudio/src/store/model.js b/kystudio/src/store/model.js index b45235fb27..e08319e2e9 100644 --- a/kystudio/src/store/model.js +++ b/kystudio/src/store/model.js @@ -65,8 +65,8 @@ export default { return new Promise((resolve, reject) => { const newParams = { ...para, - last_modify_from: para.last_modify[0] && para.last_modify[0].getTime(), - last_modify_to: para.last_modify[1] && para.last_modify[1].getTime(), + last_modify_from: para.last_modify[0] && new Date(para.last_modify[0]).getTime(), + last_modify_to: para.last_modify[1] && new Date(para.last_modify[1]).getTime(), last_modify: undefined } api.model.getModelList(newParams).then((response) => {