summaryrefslogtreecommitdiffstats
path: root/webapp/src/store
diff options
context:
space:
mode:
authorUdo Walter2018-12-04 17:41:15 +0100
committerUdo Walter2018-12-04 17:41:15 +0100
commit6bc320dddf45a88976ceb5fb17cf149d8b1e9e1b (patch)
tree5edcf1f2608624dd61d677fef8a2017edca01241 /webapp/src/store
parenteslint fix :) (diff)
downloadbas-6bc320dddf45a88976ceb5fb17cf149d8b1e9e1b.tar.gz
bas-6bc320dddf45a88976ceb5fb17cf149d8b1e9e1b.tar.xz
bas-6bc320dddf45a88976ceb5fb17cf149d8b1e9e1b.zip
[groups,clients,configurator] api rework to the new format
Diffstat (limited to 'webapp/src/store')
-rw-r--r--webapp/src/store/groups.js33
-rw-r--r--webapp/src/store/registration.js2
2 files changed, 18 insertions, 17 deletions
diff --git a/webapp/src/store/groups.js b/webapp/src/store/groups.js
index 7905fe4..8f50978 100644
--- a/webapp/src/store/groups.js
+++ b/webapp/src/store/groups.js
@@ -50,7 +50,7 @@ export default {
})
},
loadLists (context) {
- Promise.all([axios.get('/api/groups/getList'), axios.get('/api/clients/getList')]).then(res => {
+ Promise.all([axios.get('/api/groups'), axios.get('/api/clients')]).then(res => {
context.commit('setGroupList', res[0].data.map(x => ({ id: x.id, name: x.name || x.id })))
context.commit('setClientList', res[1].data.map(x => ({ id: x.id, name: x.name || x.id })))
})
@@ -67,7 +67,7 @@ export default {
}
context.commit('setTabLoading', tabIndex)
if (switchTab) context.commit('setActiveTab', tabIndex)
- axios.get('/api/groups/getGroup?id=' + id + (showAll ? '&all=true' : '')).then(res => {
+ axios.get('/api/groups/' + id + (showAll ? '?all' : '')).then(res => {
res.data.tabType = 'group'
res.data.tabShowAll = showAll
context.commit('setTab', { index: tabIndex, item: res.data })
@@ -86,7 +86,7 @@ export default {
context.commit('setTab', { index: tabIndex, item: { id, name, tabType: 'client' } })
}
if (switchTab) context.commit('setActiveTab', tabIndex)
- axios.get('/api/clients/getClient?id=' + id).then(res => {
+ axios.get('/api/clients/' + id).then(res => {
res.data.tabType = 'client'
context.commit('setTab', { index: tabIndex, item: res.data })
}).catch(err => {
@@ -103,12 +103,12 @@ export default {
else if (item.tabType === 'client') context.dispatch('loadClient', { id: item.id, tabIndex: index, reload: true })
})
},
- saveGroup (context, { id, info, parentIds, tabIndex, callback }) {
- axios.post('/api/groups/save', { id, info, parentIds }).then(res => {
+ saveGroup (context, { id, data, parentIds, tabIndex, callback }) {
+ const url = id === 'create' ? '/api/groups' : '/api/groups/' + id
+ axios.post(url, { data, parentIds }).then(res => {
if (res.data.id) {
- console.log(res.data.id)
if (callback) callback(res.data.id)
- context.commit('setTab', { index: tabIndex, item: { id: res.data.id, name: info.name, tabType: 'group' } })
+ context.commit('setTab', { index: tabIndex, item: { id: res.data.id, name: data.name, tabType: 'group', subgroups: [], clients: [] } })
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,11 +117,12 @@ export default {
}
})
},
- saveClient (context, { id, info, groupIds, tabIndex, callback }) {
- axios.post('/api/clients/save', { id, info, groupIds }).then(res => {
+ saveClient (context, { id, data, groupIds, tabIndex, callback }) {
+ 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: info.name, tabType: 'client' } })
+ context.commit('setTab', { index: tabIndex, item: { id: res.data.id, name: data.name, tabType: 'client' } })
if (groupIds && tabIndex > 1 && !groupIds.includes(context.state.tabChain[tabIndex - 1].id)) {
context.commit('deleteFromTabChain', { index: 1, count: tabIndex - 1 })
context.commit('setActiveTab', 1)
@@ -132,7 +133,7 @@ export default {
},
deleteGroups (context, { selected, callback }) {
const ids = selected.map(x => x.id)
- axios.post('/api/groups/delete', { ids }).then(() => {
+ axios.post('/api/groups/?delete', { ids }).then(() => {
var i = 1
while (i < context.state.tabChain.length) {
if (context.state.tabChain[i].tabType === 'group' && ids.includes(context.state.tabChain[i].id)) {
@@ -147,7 +148,7 @@ export default {
},
deleteClients (context, { selected, callback }) {
const ids = selected.map(x => x.id)
- axios.post('/api/clients/delete', { ids }).then(() => {
+ axios.post('/api/clients/?delete', { ids }).then(() => {
const index = context.state.tabChain.length - 1
const item = context.state.tabChain[index]
if (item.tabType === 'client' && ids.includes(item.id)) context.commit('deleteFromTabChain', { index, count: 1 })
@@ -158,7 +159,7 @@ export default {
removeSubroups (context, { tabIndex, selected, callback }) {
const id = context.state.tabChain[tabIndex].id
const ids = selected.map(x => x.id)
- axios.post('/api/groups/removeSubgroups', { id, ids }).then(() => {
+ axios.post('/api/groups/' + id + '/subgroups/?delete', { ids }).then(() => {
if (context.state.tabChain.length > tabIndex + 1 &&
context.state.tabChain[tabIndex + 1].tabType === 'group' &&
ids.includes(context.state.tabChain[tabIndex + 1].id)) {
@@ -171,7 +172,7 @@ export default {
removeClients (context, { tabIndex, selected, callback }) {
const id = context.state.tabChain[tabIndex].id
const ids = selected.map(x => x.id)
- axios.post('/api/groups/removeClients', { id, ids }).then(() => {
+ axios.post('/api/groups/' + id + '/clients/?delete', { ids }).then(() => {
if (context.state.tabChain.length > tabIndex + 1 &&
context.state.tabChain[tabIndex + 1].tabType === 'client' &&
ids.includes(context.state.tabChain[tabIndex + 1].id)) {
@@ -184,7 +185,7 @@ export default {
addSubgroups (context, { tabIndex, selected, callback }) {
const id = context.state.tabChain[tabIndex].id
const ids = selected.map(x => x.id)
- axios.post('/api/groups/addSubgroups', { id, ids }).then(() => {
+ axios.post('/api/groups/' + id + '/subgroups', { ids }).then(() => {
context.dispatch('reload')
if (callback) callback()
})
@@ -192,7 +193,7 @@ export default {
addClients (context, { tabIndex, selected, callback }) {
const id = context.state.tabChain[tabIndex].id
const ids = selected.map(x => x.id)
- axios.post('/api/groups/addClients', { id, ids }).then(() => {
+ axios.post('/api/groups/' + id + '/clients', { ids }).then(() => {
context.dispatch('reload')
if (callback) callback()
})
diff --git a/webapp/src/store/registration.js b/webapp/src/store/registration.js
index 388558d..8d1882f 100644
--- a/webapp/src/store/registration.js
+++ b/webapp/src/store/registration.js
@@ -27,7 +27,7 @@ export default {
})
},
loadGroupList (context) {
- axios.get('/api/groups/getList').then(result => {
+ axios.get('/api/groups').then(result => {
context.commit('setGroupList', result.data)
})
},