Skip to content

Commit 795af8a

Browse files
committed
Add notification feature to webapps and libs
1 parent 8229cab commit 795af8a

File tree

84 files changed

+3774
-1757
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+3774
-1757
lines changed

client/web/admin/src/app.js

+20
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ export default (options = {}) => {
9292
// Load effective permissions
9393
this.$store.dispatch('rbac/load', enabledApis)
9494

95+
// Initialize notifications
96+
this.$store.dispatch('notifications/fetchNotifications')
97+
9598
return this.loadBundle(bundleLoaderOpt)
9699
.then(() => this.$SystemAPI.automationList({ excludeInvalid: true }))
97100
.then(this.makeAutomationScriptsRegistrator(
@@ -147,6 +150,22 @@ export default (options = {}) => {
147150
this.$store.dispatch('wfPrompts/clear', msg['@value'])
148151
break
149152

153+
case 'notification':
154+
this.$store.dispatch('notifications/addNotification', msg['@value'])
155+
break
156+
157+
case 'notification.read':
158+
this.$store.dispatch('notifications/updateReadNotification', msg['@value'])
159+
break
160+
161+
case 'notification.read.all':
162+
this.$store.dispatch('notifications/updateAllReadNotifications', msg['@value'])
163+
break
164+
165+
case 'notification.delete':
166+
this.$store.dispatch('notifications/removeNotification', msg['@value'])
167+
break
168+
150169
case 'error':
151170
this.toastDanger('Websocket message with error', msg['@value'])
152171
}
@@ -163,6 +182,7 @@ export default (options = {}) => {
163182
'general',
164183
'navigation',
165184
'notification',
185+
'notifications',
166186
'general',
167187
'permissions',
168188
'system.stats',

client/web/admin/src/components/Settings/UI/CUITopbarSettings.vue

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
{{ $t('app-selector.hide') }}
2222
</b-form-checkbox>
2323

24+
<b-form-checkbox
25+
v-model="topbarSettings.hideNotifications"
26+
>
27+
{{ $t('notifications.hide') }}
28+
</b-form-checkbox>
29+
2430
<b-form-checkbox
2531
v-model="topbarSettings.hideHelp"
2632
>

client/web/admin/src/components/faIcons.js

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
faAngleDoubleRight,
1212
faPowerOff,
1313
faCheck,
14+
faCheckDouble,
1415
faTachometerAlt,
1516
faTimes,
1617
faFileCode,
@@ -53,6 +54,8 @@ import {
5354
faTrashRestore,
5455
faLocationArrow,
5556
faEyeSlash,
57+
faBellSlash,
58+
faBell as faBellSolid,
5659
} from '@fortawesome/free-solid-svg-icons'
5760

5861
import {
@@ -62,6 +65,7 @@ import {
6265
faUser,
6366
faTrashAlt,
6467
faEdit,
68+
faBell,
6569
} from '@fortawesome/free-regular-svg-icons'
6670

6771
library.add(
@@ -77,6 +81,7 @@ library.add(
7781
faAngleDoubleRight,
7882
faPowerOff,
7983
faCheck,
84+
faCheckDouble,
8085
faTachometerAlt,
8186
faTimes,
8287
faFileCode,
@@ -125,4 +130,7 @@ library.add(
125130
faAngleUp,
126131
faAngleDown,
127132
faEyeSlash,
133+
faBell,
134+
faBellSolid,
135+
faBellSlash,
128136
)

client/web/admin/src/store/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,11 @@ export default new Vuex.Store({
2727
webapp: 'admin',
2828
}),
2929
},
30+
notifications: {
31+
namespaced: true,
32+
...cvStore.notifications({
33+
api: Vue.prototype.$SystemAPI,
34+
}),
35+
},
3036
},
3137
})

client/web/admin/src/views/Layout.vue

+4-1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@
117117
warning: (countdownTime) => $t('general:extendSession.labels.warning', { countdownTime }),
118118
}"
119119
/>
120+
121+
<c-notification-sidebar v-if="!$Settings.get('ui.topbar', {}).hideNotifications" />
120122
</div>
121123
</template>
122124

@@ -125,7 +127,7 @@ import CTheMainNav from 'corteza-webapp-admin/src/components/CTheMainNav'
125127
import { components, mixins } from '@cortezaproject/corteza-vue'
126128
import { mapGetters } from 'vuex'
127129
128-
const { CExtendSession, CPermissionsModal, CPrompts, CTopbar, CSidebar } = components
130+
const { CExtendSession, CPermissionsModal, CPrompts, CTopbar, CSidebar, CNotificationSidebar } = components
129131
130132
export default {
131133
i18nOptions: {
@@ -139,6 +141,7 @@ export default {
139141
CSidebar,
140142
CTheMainNav,
141143
CExtendSession,
144+
CNotificationSidebar,
142145
},
143146
144147
mixins: [

client/web/compose/src/app.js

+20
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ export default (options = {}) => {
9292
// Initializes reminders subsystems, do prefetch of all pending reminders
9393
this.$Reminder.init(this, { filter: { assignedTo: user.userID } })
9494

95+
// Initialize notifications
96+
this.$store.dispatch('notifications/fetchNotifications')
97+
9598
this.loadBundle(bundleLoaderOpt)
9699
.then(() => this.$ComposeAPI.automationList({ excludeInvalid: true }))
97100
.then(this.makeAutomationScriptsRegistrator(
@@ -153,6 +156,22 @@ export default (options = {}) => {
153156
this.$Reminder.enqueueRaw(msg['@value'])
154157
break
155158

159+
case 'notification':
160+
this.$store.dispatch('notifications/addNotification', msg['@value'])
161+
break
162+
163+
case 'notification.read':
164+
this.$store.dispatch('notifications/updateReadNotification', msg['@value'])
165+
break
166+
167+
case 'notification.read.all':
168+
this.$store.dispatch('notifications/updateAllReadNotifications', msg['@value'])
169+
break
170+
171+
case 'notification.delete':
172+
this.$store.dispatch('notifications/removeNotification', msg['@value'])
173+
break
174+
156175
case 'error':
157176
this.toastDanger('Websocket message with error', msg['@value'])
158177
}
@@ -172,6 +191,7 @@ export default (options = {}) => {
172191
'namespace',
173192
'navigation',
174193
'notification',
194+
'notifications',
175195
'onboarding',
176196
'page',
177197
'permissions',

client/web/compose/src/components/faIcons.js

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
faCloudDownloadAlt,
1414
faTimes,
1515
faCheck,
16+
faCheckDouble,
1617
faBold,
1718
faItalic,
1819
faUnderline,
@@ -67,6 +68,8 @@ import {
6768
faTools,
6869
faTable,
6970
faCamera,
71+
faBellSlash,
72+
faBell as faBellSolid,
7073
} from '@fortawesome/free-solid-svg-icons'
7174

7275
import {
@@ -117,6 +120,7 @@ library.add(
117120
faCloudDownloadAlt,
118121
faTimes,
119122
faCheck,
123+
faCheckDouble,
120124
faBell,
121125
faClock,
122126
faSquare,
@@ -182,4 +186,7 @@ library.add(
182186
faExclamationCircle,
183187
faTable,
184188
faCamera,
189+
faBell,
190+
faBellSolid,
191+
faBellSlash,
185192
)

client/web/compose/src/store/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,11 @@ export default new Vuex.Store({
4242
webapp: 'compose',
4343
}),
4444
},
45+
notifications: {
46+
namespaced: true,
47+
...cvStore.notifications({
48+
api: Vue.prototype.$SystemAPI,
49+
}),
50+
},
4551
},
4652
})

client/web/compose/src/views/Layout.vue

+15-1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@
120120
warning: (countdownTime) => $t('general:extendSession.labels.warning', { countdownTime }),
121121
}"
122122
/>
123+
124+
<c-notification-sidebar v-if="!$Settings.get('ui.topbar', {}).hideNotifications" />
123125
</div>
124126
</template>
125127

@@ -129,7 +131,7 @@ import CTranslationModal from '../components/Translator/CTranslatorModal'
129131
import { mapGetters, mapActions } from 'vuex'
130132
import { debounce } from 'lodash'
131133
import { components } from '@cortezaproject/corteza-vue'
132-
const { CToaster, CPrompts, CPermissionsModal, CTopbar, CSidebar, CExtendSession } = components
134+
const { CToaster, CPrompts, CPermissionsModal, CTopbar, CSidebar, CExtendSession, CNotificationSidebar } = components
133135
134136
export default {
135137
i18nOptions: {
@@ -144,6 +146,7 @@ export default {
144146
CSidebar,
145147
CToaster, // Only used for reminders
146148
CExtendSession,
149+
CNotificationSidebar,
147150
},
148151
149152
data () {
@@ -369,3 +372,14 @@ export default {
369372
},
370373
}
371374
</script>
375+
376+
<style lang="scss" scoped>
377+
.sidebar-spacer {
378+
width: 0;
379+
transition: width 0.2s ease-in-out;
380+
381+
&.expanded {
382+
width: 240px;
383+
}
384+
}
385+
</style>

client/web/discovery/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"lodash": "^4.17.21",
3535
"portal-vue": "^2.1.7",
3636
"vue": "2.7.16",
37+
"vue-native-websocket": "^2.0.15",
3738
"vue-router": "^3.4.9",
3839
"vue-text-highlight": "^2.0.10",
3940
"vuex": "^3.6.2"

client/web/discovery/src/App.vue

-63
This file was deleted.

0 commit comments

Comments
 (0)