Skip to content

Commit dac6f92

Browse files
authored
Adding alert mechanism which changes the button color when there are … (#839)
* Adding alert mechanism which changes the button color when there are notifications to check * removing debug code
1 parent c3ee722 commit dac6f92

File tree

4 files changed

+55
-18
lines changed

4 files changed

+55
-18
lines changed

src-electron/db/query-notification.js

Lines changed: 1 addition & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/layouts/ZclConfiguratorLayout.vue

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,13 @@ limitations under the License.
7878
</div></Transition
7979
>
8080
</q-btn>
81-
<q-btn flat icon="warning" to="/notifications" id="Notifications">
81+
<q-btn
82+
flat
83+
icon="warning"
84+
to="/notifications"
85+
id="Notifications"
86+
:color="notification"
87+
>
8288
<Transition name="bounce">
8389
<div v-if="displayButton" class="text-align q-ml-xs">
8490
Notifications
@@ -135,6 +141,19 @@ export default {
135141
this.miniState = true
136142
}
137143
},
144+
getNotifications() {
145+
this.$serverGet(restApi.uri.notification)
146+
.then((resp) => {
147+
if (resp.data[0] === undefined) {
148+
this.notification = 'white'
149+
} else {
150+
this.notification = 'red'
151+
}
152+
})
153+
.catch((err) => {
154+
console.log(err)
155+
})
156+
},
138157
setSelectedEndpoint(value) {
139158
this.$store.dispatch('zap/updateSelectedEndpointType', {
140159
endpointType: this.endpointType[value],
@@ -251,8 +270,16 @@ export default {
251270
isExpanded: false,
252271
globalOptionsDialog: false,
253272
zclExtensionDialog: false,
273+
notification: '',
274+
}
275+
},
276+
created() {
277+
if (this.$serverGet != null) {
278+
this.notification = ''
279+
this.getNotifications()
254280
}
255281
},
282+
256283
components: {
257284
ZclGeneralOptionsBar,
258285
ZclEndpointManager,

src/pages/Notifications.vue

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@
3939
<script>
4040
import restApi from '../../src-shared/rest-api.js'
4141
export default {
42+
methods: {
43+
getNotifications() {
44+
this.$serverGet(restApi.uri.notification)
45+
.then((resp) => {
46+
for (let i = 0; i < resp.data.length; i++) {
47+
this.notis.push(resp.data[i])
48+
}
49+
})
50+
.catch((err) => {
51+
console.log(err)
52+
})
53+
},
54+
},
4255
data() {
4356
return {
4457
columns: [
@@ -66,15 +79,10 @@ export default {
6679
}
6780
},
6881
created() {
69-
this.$serverGet(restApi.uri.notification)
70-
.then((resp) => {
71-
for (let i = 0; i < resp.data.length; i++) {
72-
this.notis.push(resp.data[i])
73-
}
74-
})
75-
.catch((err) => {
76-
console.log(err)
77-
})
82+
if (this.$serverGet != null) {
83+
this.notis = []
84+
this.getNotifications()
85+
}
7886
},
7987
}
8088
</script>

test/ui.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ import ZclClusterLayout from '../src/layouts/ZclClusterLayout.vue'
8080
import ZclConfiguratorLayout from '../src/layouts/ZclConfiguratorLayout.vue'
8181
import Error404 from '../src/pages/Error404.vue'
8282
import Preference from '../src/pages/Preference.vue'
83+
import Notifications from '../src/pages/Notifications.vue'
8384
import PreferenceGeneration from '../src/pages/PreferenceGeneration.vue'
8485
import PreferenceUser from '../src/pages/PreferenceUser.vue'
8586
import PreferencePackage from '../src/pages/PreferencePackage.vue'
@@ -256,6 +257,14 @@ describe('Component mounting test', () => {
256257
},
257258
timeout.short()
258259
)
260+
test(
261+
'Notifications',
262+
() => {
263+
const wrapper = shallowMount(Notifications, { store: ZapStore() })
264+
expect(wrapper.html().length).toBeGreaterThan(100)
265+
},
266+
timeout.short()
267+
)
259268
test(
260269
'Error404',
261270
() => {

0 commit comments

Comments
 (0)