2021-04-22 17:44:23 +00:00
< template >
2021-04-28 23:45:01 +00:00
< div class = "notifications" >
2021-04-22 17:44:23 +00:00
< div class = "notifications-header" >
< h4 class = "notifications-title" > Notifications < / h4 >
< div class = "notifications-actions" >
< Icon
2021-05-08 22:23:10 +00:00
v - if = "unseenCount > 0"
2021-04-25 01:08:50 +00:00
v - tooltip = "'Mark all as seen'"
2021-04-22 17:44:23 +00:00
icon = "checkmark"
2021-04-25 01:08:50 +00:00
@ click = "checkNotifications"
2021-04-22 17:44:23 +00:00
/ >
< Icon
2021-05-08 22:23:10 +00:00
v - tooltip = "'Add alert'"
2021-04-22 17:44:23 +00:00
icon = "plus3"
@ click = "showAddAlert = true"
/ >
< / div >
< / div >
< AddAlert
v - if = "showAddAlert"
@ close = "showAddAlert = false"
> Alert < / AddAlert >
< div class = "notifications-body" >
2021-04-25 22:48:31 +00:00
< div
2021-04-22 17:44:23 +00:00
v - if = "notifications.length === 0"
2021-04-25 01:08:50 +00:00
class = "notifications-empty"
2021-04-25 22:48:31 +00:00
> No notifications < / div >
2021-04-22 17:44:23 +00:00
< ul
v - else
class = "nolist"
>
< li
v - for = "notification in notifications"
: key = "`notification-${notification.id}`"
2021-04-25 01:08:50 +00:00
: class = "{ unseen: !notification.seen }"
2021-04-22 17:44:23 +00:00
class = "notification"
2021-04-28 23:45:01 +00:00
@ click = "checkNotification(notification.id, true)"
2021-04-22 17:44:23 +00:00
>
< router -link
: to = "`/scene/${notification.scene.id}/${notification.scene.slug}`"
class = "notification-link"
>
< img
: src = "getPath(notification.scene.poster, 'thumbnail')"
class = "poster"
>
< div class = "notification-body" >
2021-04-25 01:08:50 +00:00
< div class = "notification-row notification-title" >
< img
v - if = "notification.scene.entity.type === 'network' || notification.scene.entity.independent"
2021-04-27 02:41:22 +00:00
v - tooltip = "notification.scene.entity.name"
2021-04-25 22:48:31 +00:00
: src = "`/img/logos/${notification.scene.entity.slug}/favicon_${theme === 'dark' ? 'light' : 'dark'}.png`"
2021-04-25 01:08:50 +00:00
class = "notification-favicon"
>
< img
v - else
2021-04-27 02:41:22 +00:00
v - tooltip = "notification.scene.entity.name"
2021-04-25 22:48:31 +00:00
: src = "`/img/logos/${notification.scene.entity.parent.slug}/favicon_${theme === 'dark' ? 'light' : 'dark'}.png`"
2021-04-25 01:08:50 +00:00
class = "notification-favicon"
>
New & nbsp ; < ul
2021-04-25 22:48:31 +00:00
v - if = "notification.alert?.tags.length > 0"
2021-04-25 01:08:50 +00:00
class = "nolist notification-tags"
>
< li
v - for = "tag in notification.alert.tags"
: key = "`notification-tag-${tag.slug}`"
class = "notification-tag"
> { { tag . name } } < / li > & nbsp ;
< / ul > scene
< / div >
2021-04-27 02:41:22 +00:00
< div class = "notification-row notification-details" >
< span class = "notification-date" > { { formatDate ( notification . scene . date , 'MMM D' ) } } < / span >
2021-04-25 01:08:50 +00:00
< ul
v - if = "notification.scene.actors.length > 0"
class = "nolist notification-actors"
>
< li
v - for = "actor in notification.scene.actors"
: key = "`notification-actor-${actor.slug}`"
class = "notification-actor"
> { { actor . name } } < / li >
< / ul >
< / div >
2021-04-22 17:44:23 +00:00
< / div >
2021-04-25 01:08:50 +00:00
< Icon
v - if = "!notification.seen"
v - tooltip = "'Mark as seen'"
icon = "checkmark"
class = "notification-check"
2021-04-28 23:45:01 +00:00
@ click . prevent . stop = "checkNotification(notification.id)"
2021-04-25 01:08:50 +00:00
/ >
2021-04-27 02:41:22 +00:00
< Icon
v - if = "notification.alert"
v - tooltip = "`You set an alert for <strong>${notification.alert.tags.map(tag => tag.name).join(', ') || 'all'}</strong> scenes with <strong>${notification.alert.actors.map(actor => actor.name).join(', ') || 'any actor'}</strong> for <strong>${notification.alert.entity?.name || 'any channel'}</strong>`"
icon = "question5"
2021-04-28 23:45:01 +00:00
@ click . prevent . stop
2021-04-27 02:41:22 +00:00
/ >
2021-04-22 17:44:23 +00:00
< / r o u t e r - l i n k >
< / li >
< / ul >
< / div >
2021-05-08 22:23:10 +00:00
< div @click ="$emit('blur')" >
< router -link
to = "/notifications"
class = "notification-link notification-more"
> See all < / r o u t e r - l i n k >
< / div >
2021-04-22 17:44:23 +00:00
< / div >
< / template >
< script >
import AddAlert from '../alerts/add.vue' ;
2021-04-25 01:08:50 +00:00
async function checkNotifications ( ) {
await this . $store . dispatch ( 'checkNotifications' ) ;
2021-05-08 22:23:10 +00:00
this . $emit ( 'check' ) ;
2021-04-25 01:08:50 +00:00
}
2021-04-22 17:44:23 +00:00
2021-04-28 23:45:01 +00:00
async function checkNotification ( notificationId , blur ) {
2021-04-25 01:08:50 +00:00
await this . $store . dispatch ( 'checkNotification' , notificationId ) ;
2021-05-08 22:23:10 +00:00
this . $emit ( 'check' ) ;
2021-04-28 23:45:01 +00:00
if ( blur ) {
this . events . emit ( 'blur' ) ;
}
2021-04-22 17:44:23 +00:00
}
export default {
components : {
AddAlert ,
} ,
2021-05-08 22:23:10 +00:00
props : {
notifications : {
type : Array ,
default : ( ) => [ ] ,
} ,
unseenCount : {
type : Number ,
default : 0 ,
} ,
} ,
2021-04-22 17:44:23 +00:00
data ( ) {
return {
showAddAlert : false ,
} ;
} ,
methods : {
2021-04-25 01:08:50 +00:00
checkNotifications ,
checkNotification ,
2021-04-22 17:44:23 +00:00
} ,
} ;
< / script >
< style lang = "scss" scoped >
. notifications {
width : 30 rem ;
2021-05-08 22:23:10 +00:00
max - height : calc ( 100 vh - 5 rem ) ;
display : flex ;
flex - direction : column ;
2021-04-22 17:44:23 +00:00
}
. notifications - header {
display : flex ;
justify - content : space - between ;
. icon {
padding : .5 rem ;
fill : var ( -- shadow ) ;
2021-05-08 22:23:10 +00:00
& : first - child {
padding : .5 rem .5 rem .5 rem 1.5 rem ;
}
2021-04-27 02:41:22 +00:00
& : last - child {
2021-05-08 22:23:10 +00:00
padding : .5 rem 1.5 rem .5 rem .5 rem ;
2021-04-27 02:41:22 +00:00
}
2021-05-08 22:23:10 +00:00
& : hover {
2021-04-22 17:44:23 +00:00
fill : var ( -- primary ) ;
cursor : pointer ;
}
}
}
. notifications - title {
display : inline - block ;
padding : .5 rem 1 rem ;
margin : 0 ;
color : var ( -- shadow ) ;
font - size : 1 rem ;
font - weight : bold ;
}
. notifications - body {
2021-05-08 22:23:10 +00:00
flex - grow : 1 ;
overflow - y : auto ;
2021-04-22 17:44:23 +00:00
box - shadow : 0 0 3 px var ( -- shadow - weak ) ;
}
2021-04-25 01:08:50 +00:00
. notifications - empty {
2021-04-25 22:48:31 +00:00
padding : .5 rem 1 rem ;
color : var ( -- shadow ) ;
2021-04-25 01:08:50 +00:00
}
2021-04-22 17:44:23 +00:00
. notification {
display : block ;
2021-04-27 02:41:22 +00:00
border - right : solid .5 rem var ( -- shadow - touch ) ;
2021-04-25 22:48:31 +00:00
color : var ( -- text ) ;
2021-04-25 01:08:50 +00:00
& . unseen {
border - right : solid .5 rem var ( -- primary ) ;
}
2021-04-22 17:44:23 +00:00
2021-04-27 01:56:38 +00:00
. icon {
2021-04-27 02:41:22 +00:00
padding : 1.3 rem .5 rem ;
2021-04-27 01:56:38 +00:00
fill : var ( -- shadow - weak ) ;
2021-05-08 22:23:10 +00:00
& . notification - check {
padding : 1.3 rem .5 rem 1.3 rem 1 rem ;
}
2021-04-27 02:41:22 +00:00
& : last - child {
padding : 1.3 rem 1 rem 1.3 rem .5 rem ;
}
2021-04-27 01:56:38 +00:00
& : hover {
fill : var ( -- primary ) ;
}
}
2021-04-22 17:44:23 +00:00
& : not ( : last - child ) {
2021-04-27 02:41:22 +00:00
border - bottom : solid 1 px var ( -- shadow - hint ) ;
2021-05-08 22:23:10 +00:00
margin : 0 0 - 1 px 0 ;
2021-04-22 17:44:23 +00:00
}
& : hover {
2021-04-27 02:41:22 +00:00
background : var ( -- shadow - touch ) ;
& : not ( . unseen ) {
border - right : solid .5 rem var ( -- shadow - weak ) ;
}
2021-04-22 17:44:23 +00:00
}
}
. notification - link {
display : flex ;
2021-04-25 01:08:50 +00:00
align - items : stretch ;
2021-04-22 17:44:23 +00:00
color : inherit ;
text - decoration : none ;
}
. notification - body {
2021-04-25 01:08:50 +00:00
flex - grow : 1 ;
2021-04-27 02:41:22 +00:00
padding : .4 rem 0 0 0 ;
2021-04-25 02:20:38 +00:00
overflow : hidden ;
2021-04-25 01:08:50 +00:00
}
. notification - row {
display : flex ;
2021-04-25 02:20:38 +00:00
overflow : hidden ;
2021-04-27 02:41:22 +00:00
}
2021-04-25 01:08:50 +00:00
2021-04-27 02:41:22 +00:00
. notification - title {
margin : .15 rem .5 rem .3 rem .5 rem ;
2021-04-22 17:44:23 +00:00
}
2021-04-25 01:08:50 +00:00
. notification - favicon {
width : 1 rem ;
height : 1 rem ;
margin : 0 .5 rem 0 0 ;
}
2021-04-27 02:41:22 +00:00
. notification - tags {
white - space : nowrap ;
}
2021-04-25 01:08:50 +00:00
. notification - actors {
2021-04-27 02:41:22 +00:00
padding : 0 .5 rem ;
height : 1.25 rem ;
2021-04-25 01:08:50 +00:00
display : inline - block ;
overflow : hidden ;
}
2021-04-27 02:41:22 +00:00
. notification - date {
width : 3 rem ;
flex - shrink : 0 ;
padding : .25 rem .25 rem .35 rem .25 rem ;
border - right : solid 1 px var ( -- shadow - hint ) ;
border - top : solid 1 px var ( -- shadow - hint ) ;
color : var ( -- shadow - strong ) ;
font - size : .8 rem ;
text - align : center ;
2021-04-25 02:20:38 +00:00
}
2021-04-25 01:08:50 +00:00
. notification - actor ,
. notification - tag {
2021-04-25 02:20:38 +00:00
white - space : nowrap ;
2021-04-25 01:08:50 +00:00
& : not ( : last - child ) : : after {
content : ',' ;
padding : 0 .1 rem 0 0 ;
}
}
. notification - actor {
2021-04-27 02:41:22 +00:00
padding : .25 rem .15 rem .35 rem 0 ;
2021-04-25 01:08:50 +00:00
color : var ( -- shadow - strong ) ;
font - size : .9 rem ;
}
. notification - tag {
font - weight : bold ;
}
2021-05-08 22:23:10 +00:00
. notification - more {
display : block ;
padding : .5 rem 1 rem ;
color : var ( -- shadow ) ;
text - align : center ;
font - size : .9 rem ;
font - weight : bold ;
& : hover {
color : var ( -- primary ) ;
}
}
2021-04-22 17:44:23 +00:00
. poster {
2021-04-27 02:41:22 +00:00
width : 6 rem ;
2021-04-28 23:45:01 +00:00
height : 3.6 rem ;
2021-04-22 17:44:23 +00:00
object - fit : cover ;
object - position : center ;
}
< / style >