From dac6f9259237d489a38e404b2f65ebf022f6813e Mon Sep 17 00:00:00 2001 From: paulr34 <64710345+paulr34@users.noreply.github.com> Date: Fri, 9 Dec 2022 13:33:08 -0500 Subject: [PATCH] =?UTF-8?q?Adding=20alert=20mechanism=20which=20changes=20?= =?UTF-8?q?the=20button=20color=20when=20there=20are=20=E2=80=A6=20(#839)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adding alert mechanism which changes the button color when there are notifications to check * removing debug code --- src-electron/db/query-notification.js | 9 +-------- src/layouts/ZclConfiguratorLayout.vue | 29 ++++++++++++++++++++++++++- src/pages/Notifications.vue | 26 +++++++++++++++--------- test/ui.test.js | 9 +++++++++ 4 files changed, 55 insertions(+), 18 deletions(-) diff --git a/src-electron/db/query-notification.js b/src-electron/db/query-notification.js index 97e444c81f..265a3effac 100644 --- a/src-electron/db/query-notification.js +++ b/src-electron/db/query-notification.js @@ -39,13 +39,7 @@ async function setNotification(db, type, status, sessionId, severity) { [sessionId, type, status, severity, 1] ) } -async function setAllNotificationDisplay(db, sessionId) { - return dbApi.dbUpdate( - db, - 'UPDATE SESSION_NOTICE SET DISPLAY = ? WHERE SESSION_REF = ?', - [0, sessionId] - ) -} + /** * Deletes a notification from the SESSION_NOTICE table * @@ -78,7 +72,6 @@ async function getNotification(db, sessionId) { } // exports exports.setNotification = setNotification -exports.setAllNotificationDisplay = setAllNotificationDisplay exports.deleteNotification = deleteNotification exports.getNotification = getNotification //# sourceMappingURL=query-notification.js.map diff --git a/src/layouts/ZclConfiguratorLayout.vue b/src/layouts/ZclConfiguratorLayout.vue index 3d1f4459bf..089594c6ca 100644 --- a/src/layouts/ZclConfiguratorLayout.vue +++ b/src/layouts/ZclConfiguratorLayout.vue @@ -78,7 +78,13 @@ limitations under the License. - +
Notifications @@ -135,6 +141,19 @@ export default { this.miniState = true } }, + getNotifications() { + this.$serverGet(restApi.uri.notification) + .then((resp) => { + if (resp.data[0] === undefined) { + this.notification = 'white' + } else { + this.notification = 'red' + } + }) + .catch((err) => { + console.log(err) + }) + }, setSelectedEndpoint(value) { this.$store.dispatch('zap/updateSelectedEndpointType', { endpointType: this.endpointType[value], @@ -251,8 +270,16 @@ export default { isExpanded: false, globalOptionsDialog: false, zclExtensionDialog: false, + notification: '', + } + }, + created() { + if (this.$serverGet != null) { + this.notification = '' + this.getNotifications() } }, + components: { ZclGeneralOptionsBar, ZclEndpointManager, diff --git a/src/pages/Notifications.vue b/src/pages/Notifications.vue index 8fb69997ef..dc20855cee 100644 --- a/src/pages/Notifications.vue +++ b/src/pages/Notifications.vue @@ -39,6 +39,19 @@ diff --git a/test/ui.test.js b/test/ui.test.js index 2ddff982b8..4d565255b3 100644 --- a/test/ui.test.js +++ b/test/ui.test.js @@ -80,6 +80,7 @@ import ZclClusterLayout from '../src/layouts/ZclClusterLayout.vue' import ZclConfiguratorLayout from '../src/layouts/ZclConfiguratorLayout.vue' import Error404 from '../src/pages/Error404.vue' import Preference from '../src/pages/Preference.vue' +import Notifications from '../src/pages/Notifications.vue' import PreferenceGeneration from '../src/pages/PreferenceGeneration.vue' import PreferenceUser from '../src/pages/PreferenceUser.vue' import PreferencePackage from '../src/pages/PreferencePackage.vue' @@ -256,6 +257,14 @@ describe('Component mounting test', () => { }, timeout.short() ) + test( + 'Notifications', + () => { + const wrapper = shallowMount(Notifications, { store: ZapStore() }) + expect(wrapper.html().length).toBeGreaterThan(100) + }, + timeout.short() + ) test( 'Error404', () => {