summaryrefslogtreecommitdiffstats
path: root/webapp/src/store
diff options
context:
space:
mode:
authorUdo Walter2018-11-24 20:00:29 +0100
committerUdo Walter2018-11-24 20:00:29 +0100
commit8a15b67a06fb3cdd7ba5f644475f07f5cf5ef96e (patch)
tree1d3e31971b57af585efa08b72dc606be2a2cf197 /webapp/src/store
parentmerge (diff)
downloadbas-8a15b67a06fb3cdd7ba5f644475f07f5cf5ef96e.tar.gz
bas-8a15b67a06fb3cdd7ba5f644475f07f5cf5ef96e.tar.xz
bas-8a15b67a06fb3cdd7ba5f644475f07f5cf5ef96e.zip
[webapp] Add notification system
Components can call this. and this. to display notifications
Diffstat (limited to 'webapp/src/store')
-rw-r--r--webapp/src/store/global.js15
-rw-r--r--webapp/src/store/notifications.js36
2 files changed, 38 insertions, 13 deletions
diff --git a/webapp/src/store/global.js b/webapp/src/store/global.js
index bf31ce9..3277cea 100644
--- a/webapp/src/store/global.js
+++ b/webapp/src/store/global.js
@@ -19,26 +19,15 @@ export default {
clipped: loadSetting('clipped', true),
mini: loadSetting('mini', true)
},
- snackbars: [],
loginRedirect: null
},
getters: {
tabsDark: state => state.settings.dark || state.settings.coloredTabs,
tabsColor: state => state.settings.coloredTabs ? 'primary' : '',
- tabsSliderColor: state => state.settings.coloredTabs ? 'white' : 'primary',
- nextSnackbar (state) {
- if (state.snackbars) return state.snackbars[0]
- else return ''
- }
+ tabsSliderColor: state => state.settings.coloredTabs ? 'white' : 'primary'
},
mutations: {
setLoginRedirect: (state, value) => { state.loginRedirect = value },
- saveSetting (state, { name, value }) { if (name in state.settings) state.settings[name] = value; localStorage.setItem('settings.' + name, value) },
- shiftSnackbars (state) {
- state.snackbars.shift()
- },
- newSnackbar (state, text) {
- state.snackbars.push(text)
- }
+ saveSetting (state, { name, value }) { if (name in state.settings) state.settings[name] = value; localStorage.setItem('settings.' + name, value) }
}
}
diff --git a/webapp/src/store/notifications.js b/webapp/src/store/notifications.js
new file mode 100644
index 0000000..9f41d07
--- /dev/null
+++ b/webapp/src/store/notifications.js
@@ -0,0 +1,36 @@
+export default {
+ namespaced: true,
+ state: {
+ alerts: [],
+ snackbars: [],
+ newAlertCount: 0
+ },
+ getters: {
+ nextSnackbar (state) {
+ if (state.snackbars) return state.snackbars[0]
+ else return null
+ }
+ },
+ mutations: {
+ shiftSnackbars (state) {
+ state.snackbars.shift()
+ },
+ newSnackbar (state, data) {
+ state.snackbars.push(data)
+ },
+ newAlert (state, data) {
+ data.show = true
+ state.newAlertCount++
+ state.alerts.unshift(data)
+ },
+ removeAlert (state, a) {
+ a.show = false
+ setTimeout(function () {
+ state.alerts.splice(state.alerts.indexOf(a), 1)
+ }, 200)
+ },
+ resetNewAlertCount (state) {
+ state.newAlertCount = 0
+ }
+ }
+}