Skip to content

Commit

Permalink
Add desktop notification filters (#106)
Browse files Browse the repository at this point in the history
* adds desktop notification filtering

* changes some styling in notify component and changes default notification filter
  • Loading branch information
steefmin authored and rick-nu committed Jan 18, 2019
1 parent 1ef9000 commit e9ee2d9
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 1 deletion.
28 changes: 27 additions & 1 deletion front-end/components/SettingsPanel/panels/Notify/notify.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,23 @@
<button class="option" @click="enableNotifications" :class="{ current: pushNotifications }">
Enable desktop notifications
</button>
<ul id="statusSelector" v-if="pushNotifications">
<li v-for="(enabled, status) in notificationStatuses" :key="status">
<button class="sub-option" @click="toggleNotificationStatus(status);" :class="{ current: enabled }">
Show {{ status }}
</button>
</li>
</ul>
</div>
</template>

<script>
import CIMonitorLogo from '../../../EmptyBoard/logo.png';
import { SETTINGS_SET_NOTIFICATIONS_ON, SETTINGS_SET_NOTIFICATIONS_OFF } from '../../../../store/StaticMutations';
import {
SETTINGS_SET_NOTIFICATIONS_ON,
SETTINGS_SET_NOTIFICATIONS_OFF,
SETTINGS_SET_NOTIFICATION_STATUSES,
} from '../../../../store/StaticMutations';
export default {
methods: {
Expand All @@ -35,11 +46,19 @@ export default {
disableNotifications() {
this.$store.commit(SETTINGS_SET_NOTIFICATIONS_OFF);
},
toggleNotificationStatus(status) {
let statuses = this.$store.state.settings.notificationStatuses;
statuses[status] = !statuses[status];
this.$store.commit(SETTINGS_SET_NOTIFICATION_STATUSES, statuses);
},
},
computed: {
pushNotifications() {
return this.$store.state.settings.pushNotifications;
},
notificationStatuses() {
return this.$store.state.settings.notificationStatuses;
},
},
};
</script>
Expand All @@ -48,6 +67,13 @@ export default {
.option
@extend %radio-option
.sub-option
@extend %check-box
hr
@extend %line-break
li
list-style-type: none
padding-left: 35px
</style>
4 changes: 4 additions & 0 deletions front-end/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ new Vue({
return;
}

if (!this.$store.state.settings.notificationStatuses[status.state]) {
return;
}

try {
new Notification(`CIMonitor • ${status.state}`, {
body: `${status.title}${status.subTitle ? ` • ${status.subTitle}` : ''}: ${status.state}`,
Expand Down
28 changes: 28 additions & 0 deletions front-end/sass/placeholders/_form.sass
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,34 @@
border-radius: 50%
background: $color-info

%check-box
position: relative
display: block
border: 0
background: transparent
padding: 10px 10px 10px 36px
font-size: 16px

&::before
content: ' '
position: absolute
left: 0
top: 50%
margin-top: -12px
width: 20px
height: 20px
border: 2px solid $color-gray-lighter

&.current::after
content: ' '
position: absolute
left: 6px
top: 50%
margin-top: -6px
width: 12px
height: 12px
background: $color-info

%line-break
height: 2px
background: $color-gray-lighter
Expand Down
1 change: 1 addition & 0 deletions front-end/store/StaticMutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export const SETTINGS_SET_PANEL_CLOSED = 'settingsPanelSetClosed';
export const SETTINGS_SET_THEME = 'settingsSetTheme';
export const SETTINGS_SET_NOTIFICATIONS_ON = 'settingsSetNotificationsOn';
export const SETTINGS_SET_NOTIFICATIONS_OFF = 'settingsSetNotificationsOff';
export const SETTINGS_SET_NOTIFICATION_STATUSES = 'settingsSetNotificationStatuses';

export const STATUS_SET_STATUSES = 'statusSetStatuses';

Expand Down
11 changes: 11 additions & 0 deletions front-end/store/modules/SettingStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@ import {
SETTINGS_SET_THEME,
SETTINGS_SET_NOTIFICATIONS_ON,
SETTINGS_SET_NOTIFICATIONS_OFF,
SETTINGS_SET_NOTIFICATION_STATUSES,
} from '../StaticMutations';

const state = {
settingsPanelOpen: false,
theme: 'basic-dark',
pushNotifications: false,
notificationStatuses: {
info: true,
warning: true,
error: true,
success: true,
},
};

const getters = {};
Expand Down Expand Up @@ -45,6 +52,10 @@ const mutations = {
[SETTINGS_SET_THEME](state, theme) {
state.theme = theme;
},

[SETTINGS_SET_NOTIFICATION_STATUSES](state, statuses) {
state.notificationStatuses = statuses;
},
};

export default {
Expand Down

0 comments on commit e9ee2d9

Please sign in to comment.