2021-10-12 06:27:36 +00:00
|
|
|
<template>
|
|
|
|
<transition name="network-notification-fade" tag="div">
|
|
|
|
<div v-show="showNotification" class="ui-notification-container">
|
|
|
|
<div class="ui-notification">
|
2021-12-07 18:15:36 +00:00
|
|
|
<fluent-icon icon="wifi-off" />
|
2021-10-12 06:27:36 +00:00
|
|
|
<p class="ui-notification-text">
|
2022-02-01 06:55:51 +00:00
|
|
|
{{
|
|
|
|
useInstallationName(
|
|
|
|
$t('NETWORK.NOTIFICATION.TEXT'),
|
|
|
|
globalConfig.installationName
|
|
|
|
)
|
|
|
|
}}
|
2021-10-12 06:27:36 +00:00
|
|
|
</p>
|
2021-12-07 18:15:36 +00:00
|
|
|
<woot-button variant="clear" size="small" @click="refreshPage">
|
2021-10-12 06:27:36 +00:00
|
|
|
{{ $t('NETWORK.BUTTON.REFRESH') }}
|
2021-12-07 18:15:36 +00:00
|
|
|
</woot-button>
|
|
|
|
<woot-button
|
|
|
|
variant="clear"
|
|
|
|
size="small"
|
|
|
|
color-scheme="secondary"
|
|
|
|
icon="dismiss-circle"
|
|
|
|
@click="closeNotification"
|
|
|
|
>
|
|
|
|
</woot-button>
|
2021-10-12 06:27:36 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</transition>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-02-01 06:55:51 +00:00
|
|
|
import globalConfigMixin from 'shared/mixins/globalConfigMixin';
|
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
|
2021-10-12 06:27:36 +00:00
|
|
|
export default {
|
2022-02-01 06:55:51 +00:00
|
|
|
mixins: [globalConfigMixin],
|
|
|
|
|
2021-10-12 06:27:36 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
showNotification: !navigator.onLine,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2022-02-01 06:55:51 +00:00
|
|
|
computed: {
|
|
|
|
...mapGetters({ globalConfig: 'globalConfig/get' }),
|
|
|
|
},
|
|
|
|
|
2021-10-12 06:27:36 +00:00
|
|
|
mounted() {
|
|
|
|
window.addEventListener('offline', this.updateOnlineStatus);
|
|
|
|
},
|
|
|
|
|
|
|
|
beforeDestroy() {
|
|
|
|
window.removeEventListener('offline', this.updateOnlineStatus);
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
refreshPage() {
|
|
|
|
window.location.reload();
|
|
|
|
},
|
|
|
|
|
|
|
|
closeNotification() {
|
|
|
|
this.showNotification = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
updateOnlineStatus(event) {
|
|
|
|
if (event.type === 'offline') {
|
|
|
|
this.showNotification = true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
@import '~dashboard/assets/scss/mixins';
|
|
|
|
|
|
|
|
.ui-notification-container {
|
|
|
|
max-width: 40rem;
|
|
|
|
position: absolute;
|
|
|
|
right: var(--space-normal);
|
|
|
|
top: var(--space-normal);
|
2021-12-07 18:15:36 +00:00
|
|
|
z-index: var(--z-index-very-high);
|
2021-10-12 06:27:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.ui-notification {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
2021-12-07 18:15:36 +00:00
|
|
|
align-items: center;
|
|
|
|
width: 100%;
|
2021-10-12 06:27:36 +00:00
|
|
|
|
2021-12-07 18:15:36 +00:00
|
|
|
background-color: var(--y-100);
|
|
|
|
border-radius: var(--border-radius-medium);
|
|
|
|
box-shadow: var(--shadow-large);
|
2021-10-12 06:27:36 +00:00
|
|
|
|
2021-12-07 18:15:36 +00:00
|
|
|
min-width: 24rem;
|
|
|
|
padding: var(--space-normal);
|
2021-10-12 06:27:36 +00:00
|
|
|
}
|
|
|
|
|
2021-12-07 18:15:36 +00:00
|
|
|
.ui-notification-text {
|
|
|
|
margin: 0 var(--space-small);
|
2021-10-12 06:27:36 +00:00
|
|
|
}
|
|
|
|
</style>
|