@@ -71,7 +71,7 @@
import mTaskCtatusCount from './_source/taskCtatusCount'
import mProcessStateCount from './_source/processStateCount'
import mQueueCount from './_source/queueCount'
- import localStore from '@/module/util/localStorage'
+ import switchProject from '@/module/mixin/switchProject'
import mSecondaryMenu from '@/module/components/secondaryMenu/secondaryMenu'
import mListConstruction from '@/module/components/listConstruction/listConstruction'
@@ -89,14 +89,18 @@
props: {
id: Number
},
+ mixins: [switchProject],
methods: {
_datepicker (val) {
this.searchParams.startDate = val[0]
this.searchParams.endDate = val[1]
+ },
+ _updateProject () {
+ this.searchParams.projectId = this.id === 0 ? 0 : this.projectId
}
},
created () {
- this.searchParams.projectId = this.id === 0 ? 0 : localStore.getItem('projectId')
+ this.searchParams.projectId = this.id === 0 ? 0 : this.projectId
this.searchParams.startDate = dayjs().format('YYYY-MM-DD 00:00:00')
this.searchParams.endDate = dayjs().format('YYYY-MM-DD HH:mm:ss')
},
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/instance/pages/gantt/index.vue b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/instance/pages/gantt/index.vue
index e2e7d9b000..a18a3ab190 100644
--- a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/instance/pages/gantt/index.vue
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/instance/pages/gantt/index.vue
@@ -50,6 +50,7 @@
import mConditions from '@/module/components/conditions/conditions'
import mSecondaryMenu from '@/module/components/secondaryMenu/secondaryMenu'
import mListConstruction from '@/module/components/listConstruction/listConstruction'
+ import switchProject from '@/module/mixin/switchProject'
export default {
name: 'instance-gantt-index',
@@ -68,6 +69,7 @@
}
},
props: {},
+ mixins: [switchProject],
methods: {
...mapActions('dag', ['getViewGantt']),
/**
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/instance/pages/list/_source/list.vue b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/instance/pages/list/_source/list.vue
index 3dab95e476..87ee5cbe75 100644
--- a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/instance/pages/list/_source/list.vue
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/instance/pages/list/_source/list.vue
@@ -68,7 +68,7 @@
{{parseInt(pageNo === 1 ? ($index + 1) : (($index + 1) + (pageSize * (pageNo - 1))))}}
- {{item.name}}
+ {{item.name}}
|
@@ -302,6 +302,7 @@
import _ from 'lodash'
import { mapActions } from 'vuex'
import { tasksState, runningType } from '@/conf/home/pages/dag/_source/config'
+ import switchProject from '@/module/mixin/switchProject'
export default {
name: 'list',
@@ -320,6 +321,7 @@
pageNo: Number,
pageSize: Number
},
+ mixins: [switchProject],
methods: {
...mapActions('dag', ['editExecutorsState', 'deleteInstance', 'batchDeleteInstance']),
/**
@@ -372,7 +374,7 @@
* edit
*/
_reEdit (item) {
- this.$router.push({ path: `/projects/instance/list/${item.id}` })
+ this.$router.push({ path: `/projects/${this.projectId}/instance/list/${item.id}` })
},
/**
* Rerun
@@ -513,7 +515,7 @@
}
},
_gantt (item) {
- this.$router.push({ path: `/projects/instance/gantt/${item.id}` })
+ this.$router.push({ path: `/projects/${this.projectId}/instance/gantt/${item.id}` })
},
_topCheckBoxClick (is) {
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/instance/pages/list/index.vue b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/instance/pages/list/index.vue
index be80c3b002..0c9b028073 100644
--- a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/instance/pages/list/index.vue
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/instance/pages/list/index.vue
@@ -43,6 +43,7 @@
import mSpin from '@/module/components/spin/spin'
import localStore from '@/module/util/localStorage'
import { setUrlParams } from '@/module/util/routerUtil'
+ import switchProject from '@/module/mixin/switchProject'
import mNoData from '@/module/components/noData/noData'
import mSecondaryMenu from '@/module/components/secondaryMenu/secondaryMenu'
import mListConstruction from '@/module/components/listConstruction/listConstruction'
@@ -81,6 +82,7 @@
}
},
props: {},
+ mixins: [switchProject],
methods: {
...mapActions('dag', ['getProcessInstance']),
/**
@@ -129,6 +131,9 @@
_onUpdate () {
this._debounceGET()
},
+ _updateProject () {
+ this._debounceGET()
+ },
/**
* Routing changes
*/
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/list/_source/list.vue b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/list/_source/list.vue
index 8acee8e453..5947eb7319 100644
--- a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/list/_source/list.vue
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/list/_source/list.vue
@@ -132,12 +132,13 @@
},
methods: {
...mapActions('projects', ['deleteProjects']),
- ...mapMutations('dag', ['setProjectName']),
+ ...mapMutations('dag', ['setProjectId', 'setProjectName']),
_switchProjects (item) {
+ this.setProjectId(item.id)
this.setProjectName(item.name)
- localStore.setItem('projectName', `${item.name}`)
- localStore.setItem('projectId', `${item.id}`)
- this.$router.push({ path: `/projects/index` })
+ localStore.setItem('projectId', item.id)
+ localStore.setItem('projectName', item.name)
+ this.$router.push({ path: `/projects/${item.id}/index` })
},
_closeDelete (i) {
this.$refs[`poptip-${i}`][0].doClose()
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskInstance/_source/list.vue b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskInstance/_source/list.vue
index 60dd068ad9..86416df257 100644
--- a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskInstance/_source/list.vue
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskInstance/_source/list.vue
@@ -111,6 +111,7 @@
import Permissions from '@/module/permissions'
import mLog from '@/conf/home/pages/dag/_source/formModel/log'
import { tasksState } from '@/conf/home/pages/dag/_source/config'
+ import switchProject from '@/module/mixin/switchProject'
export default {
name: 'list',
@@ -126,6 +127,7 @@
pageNo: Number,
pageSize: Number
},
+ mixins: [switchProject],
methods: {
_rtState (code) {
let o = tasksState[code]
@@ -158,7 +160,7 @@
})
},
_go (item) {
- this.$router.push({ path: `/projects/instance/list/${item.processInstanceId}` })
+ this.$router.push({ path: `/projects/${this.projectId}/instance/list/${item.processInstanceId}` })
},
},
watch: {
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskInstance/index.vue b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskInstance/index.vue
index 2c07918d4d..f3a88c8cf9 100644
--- a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskInstance/index.vue
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskInstance/index.vue
@@ -43,6 +43,7 @@
import mSpin from '@/module/components/spin/spin'
import mNoData from '@/module/components/noData/noData'
import listUrlParamHandle from '@/module/mixin/listUrlParamHandle'
+ import switchProject from '@/module/mixin/switchProject'
import mSecondaryMenu from '@/module/components/secondaryMenu/secondaryMenu'
import mListConstruction from '@/module/components/listConstruction/listConstruction'
import mInstanceConditions from '@/conf/home/pages/projects/pages/_source/instanceConditions'
@@ -77,7 +78,7 @@
isLeft: true
}
},
- mixins: [listUrlParamHandle],
+ mixins: [listUrlParamHandle, switchProject],
props: {},
methods: {
...mapActions('dag', ['getTaskInstanceList']),
@@ -104,7 +105,7 @@
_getList (flag) {
this.isLoading = !flag
if(this.searchParams.pageNo == undefined) {
- this.$router.push({ path: `/projects/index` })
+ this.$router.push({ path: `/projects/${this.projectId}/index` })
return false
}
this.getTaskInstanceList(this.searchParams).then(res => {
@@ -130,7 +131,10 @@
}, 100, {
'leading': false,
'trailing': true
- })
+ }),
+ _updateProject () {
+ this._debounceGET()
+ }
},
watch: {
// router
diff --git a/dolphinscheduler-ui/src/js/conf/home/router/index.js b/dolphinscheduler-ui/src/js/conf/home/router/index.js
index b4236f3685..e7196fd505 100644
--- a/dolphinscheduler-ui/src/js/conf/home/router/index.js
+++ b/dolphinscheduler-ui/src/js/conf/home/router/index.js
@@ -17,6 +17,7 @@
import Vue from 'vue'
import i18n from '@/module/i18n/index.js'
+import { beforeProjectRoute } from '@/module/project/router'
import Router from 'vue-router'
Vue.use(Router)
@@ -48,15 +49,10 @@ const router = new Router({
redirect: {
name: 'projects-list'
},
+ beforeEnter: (to, from, next) => {
+ beforeProjectRoute(to, from, next)
+ },
children: [
- {
- path: '/projects/index',
- name: 'projects-index',
- component: resolve => require(['../pages/projects/pages/index/index'], resolve),
- meta: {
- title: `${i18n.$t('Project Home')}`
- }
- },
{
path: '/projects/list',
name: 'projects-list',
@@ -66,7 +62,15 @@ const router = new Router({
}
},
{
- path: '/projects/definition',
+ path: '/projects/:projectId/index',
+ name: 'projects-index',
+ component: resolve => require(['../pages/projects/pages/index/index'], resolve),
+ meta: {
+ title: `${i18n.$t('Project Home')}`
+ }
+ },
+ {
+ path: '/projects/:projectId/definition',
name: 'definition',
component: resolve => require(['../pages/projects/pages/definition/index'], resolve),
meta: {
@@ -77,7 +81,7 @@ const router = new Router({
},
children: [
{
- path: '/projects/definition/list',
+ path: '/projects/:projectId/definition/list',
name: 'projects-definition-list',
component: resolve => require(['../pages/projects/pages/definition/pages/list/index'], resolve),
meta: {
@@ -85,7 +89,7 @@ const router = new Router({
}
},
{
- path: '/projects/definition/list/:id',
+ path: '/projects/:projectId/definition/list/:id',
name: 'projects-definition-details',
component: resolve => require(['../pages/projects/pages/definition/pages/details/index'], resolve),
meta: {
@@ -93,7 +97,7 @@ const router = new Router({
}
},
{
- path: '/projects/definition/create',
+ path: '/projects/:projectId/definition/create',
name: 'definition-create',
component: resolve => require(['../pages/projects/pages/definition/pages/create/index'], resolve),
meta: {
@@ -101,7 +105,7 @@ const router = new Router({
}
},
{
- path: '/projects/definition/tree/:id',
+ path: '/projects/:projectId/definition/tree/:id',
name: 'definition-tree-view-index',
component: resolve => require(['../pages/projects/pages/definition/pages/tree/index'], resolve),
meta: {
@@ -109,7 +113,7 @@ const router = new Router({
}
},
{
- path: '/projects/definition/list/timing/:id',
+ path: '/projects/:projectId/definition/list/timing/:id',
name: 'definition-timing-details',
component: resolve => require(['../pages/projects/pages/definition/timing/index'], resolve),
meta: {
@@ -119,7 +123,7 @@ const router = new Router({
]
},
{
- path: '/projects/instance',
+ path: '/projects/:projectId/instance',
name: 'instance',
component: resolve => require(['../pages/projects/pages/instance/index'], resolve),
meta: {
@@ -130,7 +134,7 @@ const router = new Router({
},
children: [
{
- path: '/projects/instance/list',
+ path: '/projects/:projectId/instance/list',
name: 'projects-instance-list',
component: resolve => require(['../pages/projects/pages/instance/pages/list/index'], resolve),
meta: {
@@ -138,7 +142,7 @@ const router = new Router({
}
},
{
- path: '/projects/instance/list/:id',
+ path: '/projects/:projectId/instance/list/:id',
name: 'projects-instance-details',
component: resolve => require(['../pages/projects/pages/instance/pages/details/index'], resolve),
meta: {
@@ -146,7 +150,7 @@ const router = new Router({
}
},
{
- path: '/projects/instance/gantt/:id',
+ path: '/projects/:projectId/instance/gantt/:id',
name: 'instance-gantt-index',
component: resolve => require(['../pages/projects/pages/instance/pages/gantt/index'], resolve),
meta: {
@@ -156,7 +160,7 @@ const router = new Router({
]
},
{
- path: '/projects/task-instance',
+ path: '/projects/:projectId/task-instance',
name: 'task-instance',
component: resolve => require(['../pages/projects/pages/taskInstance'], resolve),
meta: {
@@ -165,7 +169,7 @@ const router = new Router({
},
{
- path: '/projects/task-record',
+ path: '/projects/:projectId/task-record',
name: 'task-record',
component: resolve => require(['../pages/projects/pages/taskRecord'], resolve),
meta: {
@@ -173,7 +177,7 @@ const router = new Router({
}
},
{
- path: '/projects/history-task-record',
+ path: '/projects/:projectId/history-task-record',
name: 'history-task-record',
component: resolve => require(['../pages/projects/pages/historyTaskRecord'], resolve),
meta: {
diff --git a/dolphinscheduler-ui/src/js/conf/home/store/dag/mutations.js b/dolphinscheduler-ui/src/js/conf/home/store/dag/mutations.js
index 02d466870a..2fda618e47 100755
--- a/dolphinscheduler-ui/src/js/conf/home/store/dag/mutations.js
+++ b/dolphinscheduler-ui/src/js/conf/home/store/dag/mutations.js
@@ -18,6 +18,9 @@
import _ from 'lodash'
export default {
+ setProjectId (state, payload) {
+ state.projectId = payload
+ },
setProjectName (state, payload) {
state.projectName = payload
},
diff --git a/dolphinscheduler-ui/src/js/conf/home/store/dag/state.js b/dolphinscheduler-ui/src/js/conf/home/store/dag/state.js
index b2aad5ec3a..04599531ce 100644
--- a/dolphinscheduler-ui/src/js/conf/home/store/dag/state.js
+++ b/dolphinscheduler-ui/src/js/conf/home/store/dag/state.js
@@ -17,7 +17,8 @@
import localStore from '@/module/util/localStorage'
-// Get the name of the item currently clicked
+// Get the project currently clicked
+const projectId = localStore.getItem('projectId')
const projectName = localStore.getItem('projectName')
export default {
@@ -43,7 +44,9 @@ export default {
runFlag: '',
// Whether to edit
isEditDag: false,
- // Current project
+ // Current project id
+ projectId: projectId,
+ // Current project name
projectName: projectName || '',
// Whether to update the process definition
syncDefine: true,
diff --git a/dolphinscheduler-ui/src/js/conf/home/store/projects/actions.js b/dolphinscheduler-ui/src/js/conf/home/store/projects/actions.js
index 43273de9e2..659506878a 100644
--- a/dolphinscheduler-ui/src/js/conf/home/store/projects/actions.js
+++ b/dolphinscheduler-ui/src/js/conf/home/store/projects/actions.js
@@ -30,6 +30,18 @@ export default {
})
})
},
+ /**
+ * Get project by id
+ */
+ getProjectById ({ state }, payload) {
+ return new Promise((resolve, reject) => {
+ io.get('projects/query-by-id', payload, res => {
+ resolve(res.data)
+ }).catch(e => {
+ reject(e)
+ })
+ })
+ },
/**
* Create project
*/
diff --git a/dolphinscheduler-ui/src/js/module/components/secondaryMenu/secondaryMenu.vue b/dolphinscheduler-ui/src/js/module/components/secondaryMenu/secondaryMenu.vue
index 36050bb79d..b75019e350 100644
--- a/dolphinscheduler-ui/src/js/module/components/secondaryMenu/secondaryMenu.vue
+++ b/dolphinscheduler-ui/src/js/module/components/secondaryMenu/secondaryMenu.vue
@@ -27,7 +27,7 @@
@@ -54,6 +54,7 @@
@@ -142,6 +146,9 @@
display: block;
position: relative;
padding-left: 10px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
>.icon {
vertical-align: middle;
font-size: 15px;
diff --git a/dolphinscheduler-ui/src/js/module/mixin/switchProject.js b/dolphinscheduler-ui/src/js/module/mixin/switchProject.js
new file mode 100644
index 0000000000..9e476af2aa
--- /dev/null
+++ b/dolphinscheduler-ui/src/js/module/mixin/switchProject.js
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { mapState } from 'vuex'
+import { beforeProjectRoute } from '@/module/project/router'
+
+export default {
+ computed: {
+ ...mapState('dag', ['projectId', 'projectName'])
+ },
+ watch: {
+ projectId () {
+ typeof this._updateProject === 'function' && this._updateProject()
+ }
+ },
+ beforeRouteUpdate (to, from, next) {
+ beforeProjectRoute(to, from, next)
+ }
+}
diff --git a/dolphinscheduler-ui/src/js/module/project/router.js b/dolphinscheduler-ui/src/js/module/project/router.js
new file mode 100644
index 0000000000..333d386cf6
--- /dev/null
+++ b/dolphinscheduler-ui/src/js/module/project/router.js
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import store from '@/conf/home/store'
+import localStore from '@/module/util/localStorage'
+
+export function beforeProjectRoute (to, from, next) {
+ const blacklist = ['projects', 'projects-list']
+ if (!blacklist.includes(to.name) && to.params.projectId && to.params.projectId !== localStore.getItem('projectId')) {
+ store.dispatch('projects/getProjectById', {
+ projectId: to.params.projectId
+ }).then(res => {
+ store.commit('dag/setProjectId', res.id)
+ store.commit('dag/setProjectName', res.name)
+ localStore.setItem('projectId', res.id)
+ localStore.setItem('projectName', res.name)
+ next()
+ }).catch(e => {
+ next({ name: 'projects-list' })
+ })
+ } else {
+ next()
+ }
+}
|