mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
167 lines
5.4 KiB
167 lines
5.4 KiB
3 years ago
|
<template>
|
||
|
<v-menu offset-y :close-on-content-click="false" class="">
|
||
|
<!-- notification button -->
|
||
|
|
||
2 years ago
|
<template #activator="{ on }">
|
||
3 years ago
|
<div class="d-flex align-center ml-4 justify-center">
|
||
3 years ago
|
<v-badge v-if="GetHasErrors && !GetPendingStatus" color="red" overlap bottom>
|
||
|
<template #badge>
|
||
2 years ago
|
<v-icon v-ripple="{ class: 'nc-ripple' }" size="10" v-on="on"> mdi-exclamation </v-icon>
|
||
3 years ago
|
</template>
|
||
2 years ago
|
<v-icon v-ripple="{ class: 'nc-ripple' }" size="20" class="nc-menu-alert" v-on="on"> mdi-bell-ring </v-icon>
|
||
3 years ago
|
</v-badge>
|
||
2 years ago
|
<v-icon v-else v-ripple="{ class: 'nc-ripple' }" size="20" class="nc-menu-alert" v-on="on">
|
||
3 years ago
|
mdi-bell-ring
|
||
|
</v-icon>
|
||
3 years ago
|
<v-progress-circular
|
||
|
v-if="GetPendingStatus"
|
||
|
style="position: absolute"
|
||
|
:width="3"
|
||
3 years ago
|
size="30"
|
||
3 years ago
|
color="orange"
|
||
|
indeterminate
|
||
3 years ago
|
/>
|
||
3 years ago
|
</div>
|
||
|
</template>
|
||
|
|
||
2 years ago
|
<v-list v-if="notificationList.length" style="max-height: 250px; overflow-y: auto">
|
||
|
<div v-for="item in notificationList" :key="item.time">
|
||
3 years ago
|
<v-list-item>
|
||
|
<v-list-item-avatar size="30">
|
||
2 years ago
|
<v-progress-circular v-if="item.status === 'pending'" :width="3" size="30" color="orange" indeterminate />
|
||
|
<v-icon v-else v-ripple="{ class: 'nc-ripple' }" size="20" :class="notificationIcons[item.status].class">
|
||
3 years ago
|
{{ notificationIcons[item.status].icon }}
|
||
3 years ago
|
</v-icon>
|
||
|
</v-list-item-avatar>
|
||
|
|
||
|
<v-list-item-content>
|
||
3 years ago
|
<v-list-item-title>
|
||
|
{{ item.type }}
|
||
3 years ago
|
<b>"{{ item.module }}.{{ item.title }}"</b>{{ notificationIcons[item.status].message }}
|
||
|
</v-list-item-title>
|
||
|
<v-list-item-subtitle>{{ timeDifference(item.time) }}</v-list-item-subtitle>
|
||
|
</v-list-item-content>
|
||
|
</v-list-item>
|
||
3 years ago
|
<v-divider />
|
||
3 years ago
|
</div>
|
||
|
</v-list>
|
||
|
<v-list>
|
||
2 years ago
|
<v-list-item v-if="notificationList.length" style="min-height: 30px">
|
||
|
<a class="text-center mb-0" style="width: 100%; min-width: 200px" @click.prevent="clearNotification">{{
|
||
|
$t('msg.info.notifications.clear')
|
||
|
}}</a>
|
||
3 years ago
|
</v-list-item>
|
||
|
<v-list-item v-else>
|
||
|
<v-list-item-content>
|
||
3 years ago
|
<v-list-item-subtitle class="px-3">
|
||
3 years ago
|
{{ $t('msg.info.notifications.no_new') }}
|
||
3 years ago
|
</v-list-item-subtitle>
|
||
3 years ago
|
</v-list-item-content>
|
||
|
</v-list-item>
|
||
|
</v-list>
|
||
|
</v-menu>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
2 years ago
|
import { mapGetters } from 'vuex';
|
||
3 years ago
|
|
||
|
export default {
|
||
3 years ago
|
name: 'Notification',
|
||
3 years ago
|
computed: {
|
||
|
...mapGetters({
|
||
|
GetHasErrors: 'notification/GetHasErrors',
|
||
2 years ago
|
GetPendingStatus: 'notification/GetPendingStatus',
|
||
3 years ago
|
}),
|
||
3 years ago
|
notificationList() {
|
||
2 years ago
|
return this.$store.state.notification.list;
|
||
|
},
|
||
3 years ago
|
},
|
||
3 years ago
|
filters: {
|
||
3 years ago
|
capitalize(value) {
|
||
2 years ago
|
if (!value) {
|
||
|
return '';
|
||
|
}
|
||
|
value = value.toString();
|
||
|
return value.charAt(0).toUpperCase() + value.slice(1);
|
||
|
},
|
||
3 years ago
|
},
|
||
3 years ago
|
data() {
|
||
3 years ago
|
return {
|
||
|
notificationIcons: {
|
||
|
success: {
|
||
|
message: ' successful',
|
||
|
class: 'success',
|
||
2 years ago
|
icon: 'mdi-check-circle',
|
||
3 years ago
|
},
|
||
|
error: {
|
||
|
message: ' failed',
|
||
|
class: 'error',
|
||
2 years ago
|
icon: 'mdi-cloud-alert',
|
||
3 years ago
|
},
|
||
|
pending: {
|
||
|
message: ' pending',
|
||
|
class: 'success',
|
||
2 years ago
|
icon: 'mdi-check-circle',
|
||
|
},
|
||
|
},
|
||
|
};
|
||
3 years ago
|
},
|
||
|
methods: {
|
||
3 years ago
|
timeDifference(previous) {
|
||
2 years ago
|
const current = Date.now();
|
||
|
const msPerMinute = 60 * 1000;
|
||
|
const msPerHour = msPerMinute * 60;
|
||
|
const msPerDay = msPerHour * 24;
|
||
|
const msPerMonth = msPerDay * 30;
|
||
|
const msPerYear = msPerDay * 365;
|
||
3 years ago
|
|
||
2 years ago
|
const elapsed = current - previous;
|
||
3 years ago
|
|
||
|
if (elapsed < msPerMinute) {
|
||
2 years ago
|
return Math.round(elapsed / 1000) + ' seconds ago';
|
||
3 years ago
|
} else if (elapsed < msPerHour) {
|
||
2 years ago
|
return Math.round(elapsed / msPerMinute) + ' minutes ago';
|
||
3 years ago
|
} else if (elapsed < msPerDay) {
|
||
2 years ago
|
return Math.round(elapsed / msPerHour) + ' hours ago';
|
||
3 years ago
|
} else if (elapsed < msPerMonth) {
|
||
2 years ago
|
return 'approximately ' + Math.round(elapsed / msPerDay) + ' days ago';
|
||
3 years ago
|
} else if (elapsed < msPerYear) {
|
||
2 years ago
|
return 'approximately ' + Math.round(elapsed / msPerMonth) + ' months ago';
|
||
3 years ago
|
} else {
|
||
2 years ago
|
return 'approximately ' + Math.round(elapsed / msPerYear) + ' years ago';
|
||
3 years ago
|
}
|
||
|
},
|
||
3 years ago
|
clearNotification() {
|
||
2 years ago
|
this.$store.commit('notification/MutListClearFinished');
|
||
|
},
|
||
|
},
|
||
|
};
|
||
3 years ago
|
</script>
|
||
|
|
||
2 years ago
|
<style scoped></style>
|
||
3 years ago
|
<!--
|
||
|
/**
|
||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
|
||
|
*
|
||
|
* @author Naveen MR <oof1lab@gmail.com>
|
||
|
* @author Pranav C Balan <pranavxc@gmail.com>
|
||
3 years ago
|
* @author Alejandro Moreno <info@pixplix.com>
|
||
3 years ago
|
*
|
||
|
* @license GNU AGPL version 3 or any later version
|
||
|
*
|
||
|
* This program is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Affero General Public License as
|
||
|
* published by the Free Software Foundation, either version 3 of the
|
||
|
* License, or (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Affero General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Affero General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|