2020-12-03 00:32:33 +01:00
|
|
|
<template>
|
2020-12-05 00:45:48 +01:00
|
|
|
<div v-if="showNotification" class="uw-ultrawidify-container flex flex-column overflow-hidden">
|
2020-12-03 00:32:33 +01:00
|
|
|
<div class="notification-popup flex flex-row">
|
|
|
|
<div v-if="notificationIcon" class="flex-nogrow flex-noshrink notification-icon">
|
|
|
|
<Icon
|
|
|
|
class="flex-nogrow flex-noshrink"
|
|
|
|
:icon="notificationIcon"
|
|
|
|
>
|
|
|
|
</Icon>
|
|
|
|
</div>
|
2020-12-05 03:30:43 +01:00
|
|
|
<div class="notification-content flex-grow flex-shrink flex flex-column flex-cross-center">
|
2020-12-03 00:32:33 +01:00
|
|
|
<div
|
|
|
|
class="notification-text"
|
|
|
|
v-html="notificationText"
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
v-if="notificationActions"
|
|
|
|
class="action-buttons flex flex-row"
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
v-for="action of notificationActions"
|
2020-12-05 03:30:43 +01:00
|
|
|
class="action-button"
|
2020-12-03 00:32:33 +01:00
|
|
|
:key="action"
|
|
|
|
@click="action.command"
|
|
|
|
>
|
|
|
|
<Icon v-if="action.icon" :icon="action.icon"></Icon>{{action.label}}
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-12-05 03:30:43 +01:00
|
|
|
<div
|
|
|
|
v-if="hideActions"
|
|
|
|
class="hide-actions"
|
|
|
|
>
|
|
|
|
Never show again:<wbr>
|
|
|
|
<template
|
|
|
|
v-for="action of hideActions"
|
|
|
|
:key="action"
|
|
|
|
>
|
|
|
|
<i @click="closeNotification">
|
|
|
|
<a
|
|
|
|
class="hide-action-button"
|
|
|
|
@click="action.command"
|
|
|
|
>
|
|
|
|
{{action.label}}
|
|
|
|
</a>
|
|
|
|
<wbr>
|
|
|
|
</i>
|
|
|
|
</template>
|
|
|
|
</div>
|
2020-12-03 00:32:33 +01:00
|
|
|
</div>
|
2020-12-05 03:30:43 +01:00
|
|
|
<div
|
|
|
|
class="notification-icon action-button"
|
|
|
|
@click="closeNotification()"
|
|
|
|
>
|
2020-12-03 00:32:33 +01:00
|
|
|
<Icon
|
|
|
|
class="flex-nogrow flex-noshrink"
|
|
|
|
icon="x"
|
|
|
|
>
|
|
|
|
</Icon>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-12-03 01:35:22 +01:00
|
|
|
import { mapState } from 'vuex';
|
2020-12-03 00:32:33 +01:00
|
|
|
import Icon from '../common/components/Icon';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
Icon,
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
notificationTimeout: null,
|
|
|
|
notificationIcon: "exclamation-triangle",
|
2020-12-05 03:30:43 +01:00
|
|
|
notificationText: "<b>Sample text.</b> This will be replaced with real notification later.",
|
2020-12-03 00:32:33 +01:00
|
|
|
notificationActions: null,
|
2020-12-05 03:30:43 +01:00
|
|
|
hideActions: null,
|
|
|
|
showNotification: false,
|
2020-12-03 01:35:34 +01:00
|
|
|
};
|
2020-12-03 00:32:33 +01:00
|
|
|
},
|
2020-12-05 03:30:43 +01:00
|
|
|
computed: {
|
|
|
|
...mapState([
|
|
|
|
'notificationConfig'
|
|
|
|
]),
|
|
|
|
},
|
2020-12-03 00:32:33 +01:00
|
|
|
watch: {
|
|
|
|
/**
|
|
|
|
* Sets new notification config. Currently, we can only show one notification at a time.
|
|
|
|
*
|
|
|
|
* We expect a config object like this:
|
|
|
|
* {
|
|
|
|
* timeout: number — how long we'll be displaying the notification. If empty, 10s. -1: until user dismisses it
|
|
|
|
* icon: string — what icon we're gonna show. We're using bootstrap icons. Can be empty.
|
|
|
|
* text: — notification text. Supports HTML.
|
|
|
|
* notificationActions: [
|
|
|
|
* {
|
|
|
|
* command: function that gets executed upon clicking the button.
|
|
|
|
* label: label of the button
|
|
|
|
* icon: icon of the button
|
|
|
|
* }
|
2020-12-05 03:30:43 +01:00
|
|
|
* ],
|
|
|
|
* hideOptions: [
|
|
|
|
* // more of notificationActions except it's a special case
|
2020-12-03 00:32:33 +01:00
|
|
|
* ]
|
|
|
|
* }
|
|
|
|
*/
|
|
|
|
notificationConfig(newConfig) {
|
2020-12-05 03:30:43 +01:00
|
|
|
console.log('notificationConfig?');
|
2020-12-03 00:32:33 +01:00
|
|
|
if (newConfig) {
|
|
|
|
this.notificationText = newConfig.text;
|
|
|
|
this.notificationActions = newConfig.notificationActions;
|
|
|
|
this.notificationIcon = newConfig.icon;
|
2020-12-05 03:30:43 +01:00
|
|
|
this.hideActions = newConfig.hideActions;
|
2020-12-03 00:32:33 +01:00
|
|
|
|
|
|
|
this.showNotification = true;
|
|
|
|
|
|
|
|
if (newConfig.timeout !== -1) {
|
2020-12-05 03:30:43 +01:00
|
|
|
this.notificationTimeout = setTimeout(() => this.closeNotification(), newConfig.timeout ?? 5000);
|
2020-12-03 00:32:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
closeNotification() {
|
2020-12-05 03:30:43 +01:00
|
|
|
console.log("close notification!")
|
|
|
|
|
2020-12-03 00:32:33 +01:00
|
|
|
clearTimeout(this.notificationTimeout);
|
|
|
|
|
|
|
|
this.showNotification = false;
|
|
|
|
this.notificationIcon = null;
|
|
|
|
this.notificationText = null;
|
|
|
|
this.notificationActions = null;
|
2020-12-05 03:30:43 +01:00
|
|
|
this.hideActions = null;
|
2020-12-03 00:32:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-12-03 01:35:34 +01:00
|
|
|
|
2020-12-03 00:32:33 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2020-12-03 01:35:34 +01:00
|
|
|
@import '../res/css/colors.scss';
|
|
|
|
@import '../res/css/font/overpass.css';
|
|
|
|
@import '../res/css/font/overpass-mono.css';
|
|
|
|
@import '../res/css/common.scss';
|
|
|
|
|
2020-12-12 00:38:51 +01:00
|
|
|
.uw-ultrawidify-container-root {
|
2020-12-03 00:32:33 +01:00
|
|
|
position: relative;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
2020-12-05 03:30:43 +01:00
|
|
|
pointer-events: none;
|
|
|
|
|
|
|
|
font-size: 16px;
|
2020-12-03 00:32:33 +01:00
|
|
|
|
2020-12-05 00:45:48 +01:00
|
|
|
.notification-popup {
|
2020-12-05 03:30:43 +01:00
|
|
|
pointer-events: auto !important;
|
2020-12-05 00:45:48 +01:00
|
|
|
position: absolute;
|
|
|
|
z-index: 99999999;
|
2020-12-05 03:30:43 +01:00
|
|
|
top: 2em;
|
|
|
|
right: 2em;
|
|
|
|
width: 32em;
|
|
|
|
|
|
|
|
padding: 0.7em 0.5em;
|
|
|
|
|
|
|
|
font-family: 'Overpass';
|
|
|
|
|
2020-12-05 00:45:48 +01:00
|
|
|
background-color: rgba(108, 55, 12, 0.779);
|
|
|
|
color: #fff;
|
2020-12-05 03:30:43 +01:00
|
|
|
|
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.notifcation-content {
|
|
|
|
margin-left: 0.5em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.notification-text {
|
|
|
|
text-align: justify;
|
2020-12-05 00:45:48 +01:00
|
|
|
}
|
2020-12-05 03:30:43 +01:00
|
|
|
|
2020-12-05 00:45:48 +01:00
|
|
|
.notification-icon {
|
2020-12-05 03:30:43 +01:00
|
|
|
font-size: 3em;
|
|
|
|
line-height: 0.5;
|
|
|
|
}
|
|
|
|
.action-button {
|
|
|
|
pointer-events: auto;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
.hide-actions {
|
|
|
|
color: #ccc;
|
|
|
|
font-size: 0.8em;
|
|
|
|
justify-self: flex-end;
|
|
|
|
align-self: flex-end;
|
|
|
|
margin-top: 1em;
|
|
|
|
margin-bottom: -1em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.hide-action-button {
|
|
|
|
color: #eee;
|
|
|
|
font-size: 0.9em;
|
|
|
|
text-decoration: underline;
|
|
|
|
text-decoration-color: rgba(255,255,255,0.5);
|
|
|
|
|
|
|
|
pointer-events: auto;
|
|
|
|
cursor: pointer;
|
2020-12-05 00:45:48 +01:00
|
|
|
}
|
2020-12-03 00:32:33 +01:00
|
|
|
}
|
|
|
|
</style>
|