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.
189 lines
5.6 KiB
189 lines
5.6 KiB
4 years ago
|
<template>
|
||
|
<v-menu offset-y :close-on-content-click="false" class="">
|
||
|
<!-- notification button -->
|
||
|
|
||
3 years ago
|
<template #activator="{on}">
|
||
4 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>
|
||
|
<v-icon v-ripple="{class : 'nc-ripple'}" size="10" v-on="on">
|
||
|
mdi-exclamation
|
||
|
</v-icon>
|
||
4 years ago
|
</template>
|
||
3 years ago
|
<v-icon v-ripple="{class : 'nc-ripple'}" size="20" class="nc-menu-alert" v-on="on">
|
||
3 years ago
|
mdi-bell-ring
|
||
|
</v-icon>
|
||
4 years ago
|
</v-badge>
|
||
3 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>
|
||
4 years ago
|
<v-progress-circular
|
||
|
v-if="GetPendingStatus"
|
||
|
style="position: absolute"
|
||
|
:width="3"
|
||
4 years ago
|
size="30"
|
||
4 years ago
|
color="orange"
|
||
|
indeterminate
|
||
3 years ago
|
/>
|
||
4 years ago
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<v-list v-if="notificationList.length" style="max-height: 250px;overflow-y: auto">
|
||
3 years ago
|
<div
|
||
|
v-for="item in notificationList"
|
||
|
:key="item.time"
|
||
|
>
|
||
4 years ago
|
<v-list-item>
|
||
|
<v-list-item-avatar size="30">
|
||
|
<v-progress-circular
|
||
|
v-if="item.status === 'pending'"
|
||
|
:width="3"
|
||
|
size="30"
|
||
|
color="orange"
|
||
|
indeterminate
|
||
3 years ago
|
/>
|
||
4 years ago
|
<v-icon
|
||
|
v-else
|
||
3 years ago
|
v-ripple="{class : 'nc-ripple'}"
|
||
4 years ago
|
size="20"
|
||
|
:class="notificationIcons[item.status].class"
|
||
3 years ago
|
>
|
||
|
{{ notificationIcons[item.status].icon }}
|
||
4 years ago
|
</v-icon>
|
||
|
</v-list-item-avatar>
|
||
|
|
||
|
<v-list-item-content>
|
||
3 years ago
|
<v-list-item-title>
|
||
|
{{ item.type }}
|
||
4 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 />
|
||
4 years ago
|
</div>
|
||
|
</v-list>
|
||
|
<v-list>
|
||
3 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"
|
||
3 years ago
|
>{{ $t('msg.info.notifications.clear') }}</a>
|
||
4 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>
|
||
4 years ago
|
</v-list-item-content>
|
||
|
</v-list-item>
|
||
|
</v-list>
|
||
|
</v-menu>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
3 years ago
|
import { mapGetters } from 'vuex'
|
||
4 years ago
|
|
||
|
export default {
|
||
3 years ago
|
name: 'Notification',
|
||
4 years ago
|
computed: {
|
||
|
|
||
|
...mapGetters({
|
||
|
GetHasErrors: 'notification/GetHasErrors',
|
||
3 years ago
|
GetPendingStatus: 'notification/GetPendingStatus'
|
||
4 years ago
|
}),
|
||
3 years ago
|
notificationList() {
|
||
4 years ago
|
return this.$store.state.notification.list
|
||
|
}
|
||
|
},
|
||
3 years ago
|
filters: {
|
||
3 years ago
|
capitalize(value) {
|
||
3 years ago
|
if (!value) { return '' }
|
||
|
value = value.toString()
|
||
|
return value.charAt(0).toUpperCase() + value.slice(1)
|
||
|
}
|
||
|
},
|
||
3 years ago
|
data() {
|
||
4 years ago
|
return {
|
||
|
notificationIcons: {
|
||
|
success: {
|
||
|
message: ' successful',
|
||
|
class: 'success',
|
||
|
icon: 'mdi-check-circle'
|
||
|
},
|
||
|
error: {
|
||
|
message: ' failed',
|
||
|
class: 'error',
|
||
|
icon: 'mdi-cloud-alert'
|
||
|
},
|
||
|
pending: {
|
||
|
message: ' pending',
|
||
|
class: 'success',
|
||
|
icon: 'mdi-check-circle'
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
methods: {
|
||
3 years ago
|
timeDifference(previous) {
|
||
3 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
|
||
4 years ago
|
|
||
3 years ago
|
const elapsed = current - previous
|
||
4 years ago
|
|
||
|
if (elapsed < msPerMinute) {
|
||
3 years ago
|
return Math.round(elapsed / 1000) + ' seconds ago'
|
||
4 years ago
|
} else if (elapsed < msPerHour) {
|
||
3 years ago
|
return Math.round(elapsed / msPerMinute) + ' minutes ago'
|
||
4 years ago
|
} else if (elapsed < msPerDay) {
|
||
3 years ago
|
return Math.round(elapsed / msPerHour) + ' hours ago'
|
||
4 years ago
|
} else if (elapsed < msPerMonth) {
|
||
3 years ago
|
return 'approximately ' + Math.round(elapsed / msPerDay) + ' days ago'
|
||
4 years ago
|
} else if (elapsed < msPerYear) {
|
||
3 years ago
|
return 'approximately ' + Math.round(elapsed / msPerMonth) + ' months ago'
|
||
4 years ago
|
} else {
|
||
3 years ago
|
return 'approximately ' + Math.round(elapsed / msPerYear) + ' years ago'
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
clearNotification() {
|
||
3 years ago
|
this.$store.commit('notification/MutListClearFinished')
|
||
4 years ago
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
|
||
|
</style>
|
||
|
<!--
|
||
|
/**
|
||
|
* @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>
|
||
4 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/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|