summaryrefslogtreecommitdiffstats
path: root/webapp/src/store
diff options
context:
space:
mode:
authorUdo Walter2018-11-26 20:12:31 +0100
committerUdo Walter2018-11-26 20:12:31 +0100
commit82648439b945cc5d049886f7e79c2f0dd9d14ff9 (patch)
treeebeb33ba47bef73306d004b230726ddad5d16bfa /webapp/src/store
parent[webapp] small bugfix (diff)
downloadbas-82648439b945cc5d049886f7e79c2f0dd9d14ff9.tar.gz
bas-82648439b945cc5d049886f7e79c2f0dd9d14ff9.tar.xz
bas-82648439b945cc5d049886f7e79c2f0dd9d14ff9.zip
[webapp+server] Add first implementation of a websocket to alert webclients of events
and to synchronize notification across multiple webapp instances of the same user
Diffstat (limited to 'webapp/src/store')
-rw-r--r--webapp/src/store/groups.js18
-rw-r--r--webapp/src/store/notifications.js7
2 files changed, 17 insertions, 8 deletions
diff --git a/webapp/src/store/groups.js b/webapp/src/store/groups.js
index 1bbded9..adc78f8 100644
--- a/webapp/src/store/groups.js
+++ b/webapp/src/store/groups.js
@@ -130,7 +130,7 @@ export default {
}
})
},
- deleteGroups (context, { selected }) {
+ deleteGroups (context, { selected, callback }) {
const ids = selected.map(x => x.id)
axios.post('/api/groups/delete', { ids }).then(() => {
var i = 1
@@ -142,18 +142,20 @@ export default {
i++
}
context.dispatch('reload')
+ if (callback) callback()
})
},
- deleteClients (context, { selected }) {
+ deleteClients (context, { selected, callback }) {
const ids = selected.map(x => x.id)
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 })
context.dispatch('reload')
+ if (callback) callback()
})
},
- removeSubroups (context, { tabIndex, selected }) {
+ 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(() => {
@@ -163,9 +165,10 @@ export default {
context.commit('deleteFromTabChain', { index: tabIndex + 1, count: context.state.tabChain.length - (tabIndex + 1) })
}
context.dispatch('reload')
+ if (callback) callback()
})
},
- removeClients (context, { tabIndex, selected }) {
+ 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(() => {
@@ -175,20 +178,23 @@ export default {
context.commit('deleteFromTabChain', { index: tabIndex + 1, count: 1 })
}
context.dispatch('reload')
+ if (callback) callback()
})
},
- addSubgroups (context, { tabIndex, selected }) {
+ 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(() => {
context.dispatch('reload')
+ if (callback) callback()
})
},
- addClients (context, { tabIndex, selected }) {
+ 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(() => {
context.dispatch('reload')
+ if (callback) callback()
})
}
}
diff --git a/webapp/src/store/notifications.js b/webapp/src/store/notifications.js
index 9f41d07..4687b78 100644
--- a/webapp/src/store/notifications.js
+++ b/webapp/src/store/notifications.js
@@ -23,10 +23,13 @@ export default {
state.newAlertCount++
state.alerts.unshift(data)
},
- removeAlert (state, a) {
+ removeAlert (state, id) {
+ const a = state.alerts.find(el => el.id === id)
a.show = false
setTimeout(function () {
- state.alerts.splice(state.alerts.indexOf(a), 1)
+ var index = state.alerts.indexOf(a)
+ state.alerts.splice(index, 1)
+ if (index < state.newAlertCount && index >= 0) state.newAlertCount--
}, 200)
},
resetNewAlertCount (state) {