This repository has been archived by the owner on May 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Live Notification on all the page of the dashboard!
Live notification with Mercure!
- Loading branch information
Showing
15 changed files
with
158 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
import '../scss/dashboard.scss'; | ||
import '../scss/dashboard.scss'; | ||
import Vue from "vue"; | ||
import Toasted from "vue-toasted"; | ||
import Notification from "../vue/Notification"; | ||
|
||
Vue.use(Toasted, { | ||
iconPack: 'fontawesome' | ||
}); | ||
|
||
new Vue({ | ||
components: { Notification }, | ||
template: "<Notification/>", | ||
// router | ||
}).$mount("#notification"); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
@import "variables"; | ||
|
||
.center-icon { | ||
line-height: 50px; | ||
} | ||
|
||
.grey-navbar { | ||
background-color: $navbar-grey; | ||
} | ||
|
||
.passive-bell { | ||
position: relative; | ||
cursor: pointer; | ||
} | ||
|
||
.new-notification { | ||
position: absolute; | ||
content: ""; | ||
height: 5px; | ||
width: 5px; | ||
border-radius: 50%; | ||
top: 18px; | ||
right: 4px; | ||
background-color: red; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
@import "variables"; | ||
@import "menu"; | ||
|
||
// Usefull class to center your content in the <main> tag | ||
.main-full-height { | ||
height: calc(100vh - 82px); | ||
height: calc(100vh - 83px); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<template> | ||
<li class="nav-item text-light center-icon passive-bell"> | ||
<img :src="bell" width="30" alt="Icone cloche"> | ||
<span id="new-icon"></span> | ||
</li> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: "Notification", | ||
data: function() { | ||
return { | ||
'bell': '/build/bell-icon.svg' | ||
} | ||
}, | ||
mounted() { | ||
// Port hardcodé, réfléchir à mieux | ||
const url = new URL(document.location.origin + ":1337/.well-known/mercure"); | ||
url.searchParams.append('topic', `${document.location.origin}/api/notifications/{id}`); | ||
const eventSource = new EventSource(url); | ||
eventSource.onmessage = () => { | ||
document.getElementById('new-icon').classList.add('new-notification') | ||
let toast = this.$toasted.show("Vous avez reçu une nouvelle notification!", { | ||
theme: "toasted-primary", | ||
icon: "bell", | ||
position: "top-right", | ||
duration : 3000 | ||
}); | ||
}; | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace App\Repository; | ||
|
||
use App\Entity\Notification; | ||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | ||
use Doctrine\Persistence\ManagerRegistry; | ||
|
||
/** | ||
* @method Notification|null find($id, $lockMode = null, $lockVersion = null) | ||
* @method Notification|null findOneBy(array $criteria, array $orderBy = null) | ||
* @method Notification[] findAll() | ||
* @method Notification[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | ||
*/ | ||
class NotificationRepository extends ServiceEntityRepository | ||
{ | ||
public function __construct(ManagerRegistry $registry) | ||
{ | ||
parent::__construct($registry, Notification::class); | ||
} | ||
|
||
// /** | ||
// * @return Notification[] Returns an array of Notification objects | ||
// */ | ||
/* | ||
public function findByExampleField($value) | ||
{ | ||
return $this->createQueryBuilder('c') | ||
->andWhere('c.exampleField = :val') | ||
->setParameter('val', $value) | ||
->orderBy('c.id', 'ASC') | ||
->setMaxResults(10) | ||
->getQuery() | ||
->getResult() | ||
; | ||
} | ||
*/ | ||
|
||
/* | ||
public function findOneBySomeField($value): ?Notification | ||
{ | ||
return $this->createQueryBuilder('c') | ||
->andWhere('c.exampleField = :val') | ||
->setParameter('val', $value) | ||
->getQuery() | ||
->getOneOrNullResult() | ||
; | ||
} | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,3 +195,7 @@ | |
</div> | ||
|
||
{% endblock %} | ||
|
||
{% block javascripts %} | ||
{{ encore_entry_script_tags('dashboard') }} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,4 +33,6 @@ | |
|
||
{% endblock %} | ||
|
||
|
||
{% block javascripts %} | ||
{{ encore_entry_script_tags('dashboard') }} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,8 @@ | |
|
||
</div> | ||
|
||
{% endblock %} | ||
|
||
{% block javascripts %} | ||
{{ encore_entry_script_tags('dashboard') }} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters