Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 53 additions & 2 deletions 55 ui/src/components/view/TreeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
:loadData="onLoadData"
:expandAction="false"
:showIcon="true"
:defaultSelectedKeys="defaultSelected"
:selectedKeys="defaultSelected"
:checkStrictly="true"
@select="onSelect"
@expand="onExpand"
:defaultExpandedKeys="arrExpand">
:expandedKeys="arrExpand">
<a-icon slot="parent" type="folder" />
<a-icon slot="leaf" type="block" />
</a-tree>
Expand Down Expand Up @@ -122,6 +122,12 @@ export default {
default () {
return []
}
},
treeStore: {
type: Object,
default () {
return {}
}
}
},
data () {
Expand Down Expand Up @@ -213,6 +219,39 @@ export default {
}

this.reloadTreeData(newData)
},
treeVerticalData () {
if (!this.treeStore.isExpand) {
return
}
if (this.treeStore.expands && this.treeStore.expands.length > 0) {
for (const expandKey of this.treeStore.expands) {
if (this.arrExpand.includes(expandKey)) {
continue
}
const keyVisible = this.treeVerticalData.findIndex(item => item.key === expandKey)
if (keyVisible > -1) this.arrExpand.push(expandKey)
}
}

if (this.treeStore.selected) {
this.selectedTreeKey = this.treeStore.selected
this.defaultSelected = [this.selectedTreeKey]

const resource = this.treeVerticalData.filter(item => item.id === this.selectedTreeKey)
if (resource.length > 0) {
this.resource = resource[0]
this.$emit('change-resource', this.resource)
} else {
const rootResource = this.treeVerticalData[0]
if (rootResource) {
this.resource = rootResource
this.selectedTreeKey = this.resource.key
this.defaultSelected = [this.selectedTreeKey]
this.$emit('change-resource', this.resource)
}
}
}
}
},
methods: {
Expand Down Expand Up @@ -273,10 +312,21 @@ export default {
this.selectedTreeKey = selectedKeys[0]
}

this.defaultSelected = []
this.defaultSelected.push(this.selectedTreeKey)

this.treeStore.expands = this.arrExpand
this.treeStore.selected = this.selectedTreeKey
this.$emit('change-tree-store', this.treeStore)

this.getDetailResource(this.selectedTreeKey)
},
onExpand (treeExpand) {
this.arrExpand = treeExpand
this.treeStore.isExpand = true
this.treeStore.expands = this.arrExpand
this.treeStore.selected = this.selectedTreeKey
this.$emit('change-tree-store', this.treeStore)
},
onSearch (value) {
if (this.searchQuery === '' && this.oldSearchQuery === '') {
Expand All @@ -303,6 +353,7 @@ export default {
this.arrExpand = []
this.treeViewData = []
this.loadingSearch = true
this.$emit('change-tree-store', {})

api(this.apiList, params).then(json => {
const listDomains = this.getResponseJsonData(json)
Expand Down
3 changes: 2 additions & 1 deletion 3 ui/src/store/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ const getters = {
cloudian: state => state.user.cloudian,
zones: state => state.user.zones,
timezoneoffset: state => state.user.timezoneoffset,
usebrowsertimezone: state => state.user.usebrowsertimezone
usebrowsertimezone: state => state.user.usebrowsertimezone,
domainStore: state => state.user.domainStore
}

export default getters
28 changes: 26 additions & 2 deletions 28 ui/src/store/modules/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@ import router from '@/router'
import store from '@/store'
import { login, logout, api } from '@/api'
import { i18n } from '@/locales'
import { ACCESS_TOKEN, CURRENT_PROJECT, DEFAULT_THEME, APIS, ASYNC_JOB_IDS, ZONES, TIMEZONE_OFFSET, USE_BROWSER_TIMEZONE } from '@/store/mutation-types'
import {
ACCESS_TOKEN,
CURRENT_PROJECT,
DEFAULT_THEME,
APIS,
ZONES,
TIMEZONE_OFFSET,
USE_BROWSER_TIMEZONE,
ASYNC_JOB_IDS,
DOMAIN_STORE
} from '@/store/mutation-types'

const user = {
state: {
Expand All @@ -40,7 +50,8 @@ const user = {
cloudian: {},
zones: {},
timezoneoffset: 0.0,
usebrowsertimezone: false
usebrowsertimezone: false,
domainStore: {}
},

mutations: {
Expand Down Expand Up @@ -91,6 +102,10 @@ const user = {
SET_ZONES: (state, zones) => {
state.zones = zones
Vue.ls.set(ZONES, zones)
},
SET_DOMAIN_STORE (state, domainStore) {
state.domainStore = domainStore
Vue.ls.set(DOMAIN_STORE, domainStore)
}
},

Expand Down Expand Up @@ -126,6 +141,7 @@ const user = {
commit('SET_FEATURES', {})
commit('SET_LDAP', {})
commit('SET_CLOUDIAN', {})
commit('SET_DOMAIN_STORE', {})

notification.destroy()

Expand All @@ -142,7 +158,10 @@ const user = {
const cachedZones = Vue.ls.get(ZONES, [])
const cachedTimezoneOffset = Vue.ls.get(TIMEZONE_OFFSET, 0.0)
const cachedUseBrowserTimezone = Vue.ls.get(USE_BROWSER_TIMEZONE, false)
const domainStore = Vue.ls.get(DOMAIN_STORE, {})
const hasAuth = Object.keys(cachedApis).length > 0

commit('SET_DOMAIN_STORE', domainStore)
if (hasAuth) {
console.log('Login detected, using cached APIs')
commit('SET_ZONES', cachedZones)
Expand Down Expand Up @@ -250,6 +269,7 @@ const user = {
commit('SET_LDAP', {})
commit('SET_CLOUDIAN', {})
commit('RESET_THEME')
commit('SET_DOMAIN_STORE', {})
Vue.ls.remove(CURRENT_PROJECT)
Vue.ls.remove(ACCESS_TOKEN)
Vue.ls.remove(ASYNC_JOB_IDS)
Expand Down Expand Up @@ -304,6 +324,10 @@ const user = {
reject(error)
})
})
},

SetDomainStore ({ commit }, domainStore) {
commit('SET_DOMAIN_STORE', domainStore)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions 1 ui/src/store/mutation-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const ZONES = 'ZONES'
export const ASYNC_JOB_IDS = 'ASYNC_JOB_IDS'
export const TIMEZONE_OFFSET = 'TIMEZONE_OFFSET'
export const USE_BROWSER_TIMEZONE = 'USE_BROWSER_TIMEZONE'
export const DOMAIN_STORE = 'DOMAIN_STORE'

export const CONTENT_WIDTH_TYPE = {
Fluid: 'Fluid',
Expand Down
11 changes: 10 additions & 1 deletion 11 ui/src/views/iam/DomainView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@
v-else
:treeData="treeData"
:treeSelected="treeSelected"
:treeStore="domainStore"
:loading="loading"
:tabs="$route.meta.tabs"
@change-resource="changeResource"
@change-tree-store="changeDomainStore"
:actionData="actionData"/>
</div>

Expand Down Expand Up @@ -108,7 +110,8 @@ export default {
treeSelected: {},
showAction: false,
action: {},
dataView: false
dataView: false,
domainStore: {}
}
},
computed: {
Expand All @@ -129,9 +132,11 @@ export default {
next()
},
beforeRouteLeave (to, from, next) {
this.changeDomainStore({})
next()
},
created () {
this.domainStore = store.getters.domainStore
this.fetchData()
},
watch: {
Expand Down Expand Up @@ -306,6 +311,10 @@ export default {
this.treeSelected = resource
this.resource = this.treeSelected
},
changeDomainStore (domainStore) {
this.domainStore = domainStore
store.dispatch('SetDomainStore', domainStore)
},
closeAction () {
this.showAction = false
},
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.