summaryrefslogtreecommitdiffstats
path: root/webapp/src/store
diff options
context:
space:
mode:
authorUdo Walter2019-02-23 09:35:27 +0100
committerUdo Walter2019-02-23 09:35:27 +0100
commit461549c117c9760392debae54bb8c7a1ed66b807 (patch)
treea45beb1d249d364a83bf8d1685d9bc7fda7d5915 /webapp/src/store
parent[Account] Add password change functionality (diff)
downloadbas-461549c117c9760392debae54bb8c7a1ed66b807.tar.gz
bas-461549c117c9760392debae54bb8c7a1ed66b807.tar.xz
bas-461549c117c9760392debae54bb8c7a1ed66b807.zip
[groups] add iprange functionality to groups; add refresh button
Diffstat (limited to 'webapp/src/store')
-rw-r--r--webapp/src/store/groups.js34
1 files changed, 27 insertions, 7 deletions
diff --git a/webapp/src/store/groups.js b/webapp/src/store/groups.js
index 8f50978..8315dd0 100644
--- a/webapp/src/store/groups.js
+++ b/webapp/src/store/groups.js
@@ -55,7 +55,7 @@ export default {
context.commit('setClientList', res[1].data.map(x => ({ id: x.id, name: x.name || x.id })))
})
},
- loadGroup (context, { id, name, tabIndex, switchTab, reload, placeholderName }) {
+ loadGroup (context, { id, name, tabIndex, switchTab, reload, save, placeholderName }) {
if (!reload && context.state.tabChain.length > tabIndex && context.state.tabChain[tabIndex].id === id) {
if (switchTab) context.commit('setActiveTab', tabIndex)
} else {
@@ -65,7 +65,7 @@ export default {
if (context.state.tabChain.length <= tabIndex || context.state.tabChain[tabIndex].id !== id) {
context.commit('setTab', { index: tabIndex, item: { id, name, tabType: 'group', tabShowAll: showAll, subgroups: [], clients: [] } })
}
- context.commit('setTabLoading', tabIndex)
+ if (!save) context.commit('setTabLoading', tabIndex)
if (switchTab) context.commit('setActiveTab', tabIndex)
axios.get('/api/groups/' + id + (showAll ? '?all' : '')).then(res => {
res.data.tabType = 'group'
@@ -99,16 +99,27 @@ export default {
reload (context) {
context.dispatch('loadLists')
context.state.tabChain.forEach((item, index) => {
+ if (item.id === 'create') return
if (item.tabType === 'group') context.dispatch('loadGroup', { id: item.id, tabIndex: index, reload: true, tabShowAll: item.tabShowAll })
else if (item.tabType === 'client') context.dispatch('loadClient', { id: item.id, tabIndex: index, reload: true })
})
},
- saveGroup (context, { id, data, parentIds, tabIndex, callback }) {
+ saveGroup (context, { id, data, parents, ipranges, tabIndex, callback }) {
+ const parentIds = parents.map(x => x.id)
const url = id === 'create' ? '/api/groups' : '/api/groups/' + id
- axios.post(url, { data, parentIds }).then(res => {
+ axios.post(url, { data, parentIds, ipranges }).then(res => {
if (res.data.id) {
if (callback) callback(res.data.id)
- context.commit('setTab', { index: tabIndex, item: { id: res.data.id, name: data.name, tabType: 'group', subgroups: [], clients: [] } })
+ context.commit('setTab', {
+ index: tabIndex,
+ item: {
+ ...context.state.tabChain[tabIndex],
+ ...data,
+ id: res.data.id,
+ parents,
+ ipranges
+ }
+ })
if (parentIds && tabIndex > 1 && !parentIds.includes(context.state.tabChain[tabIndex - 1].id)) {
context.commit('deleteFromTabChain', { index: 1, count: tabIndex - 1 })
context.commit('setActiveTab', 1)
@@ -117,12 +128,21 @@ export default {
}
})
},
- saveClient (context, { id, data, groupIds, tabIndex, callback }) {
+ saveClient (context, { id, data, groups, tabIndex, callback }) {
+ const groupIds = groups.map(x => x.id)
const url = id === 'create' ? '/api/clients' : '/api/clients/' + id
axios.post(url, { data, groupIds }).then(res => {
if (res.data.id) {
if (callback) callback(res.data.id)
- context.commit('setTab', { index: tabIndex, item: { id: res.data.id, name: data.name, tabType: 'client' } })
+ context.commit('setTab', {
+ index: tabIndex,
+ item: {
+ ...context.state.tabChain[tabIndex],
+ ...data,
+ id: res.data.id,
+ groups
+ }
+ })
if (groupIds && tabIndex > 1 && !groupIds.includes(context.state.tabChain[tabIndex - 1].id)) {
context.commit('deleteFromTabChain', { index: 1, count: tabIndex - 1 })
context.commit('setActiveTab', 1)