addded notification

This commit is contained in:
hafifierahman
2024-11-04 01:18:29 +08:00
parent 8ec68e8913
commit f3020b33c5
11 changed files with 204 additions and 136 deletions
+19
View File
@@ -94,3 +94,22 @@ span#basic-hargaemas {
padding: 5px 10px;
text-align: center;
}
@keyframes heartbeat {
0% {
transform: scale(1);
}
30% {
transform: scale(1.2);
}
60% {
transform: scale(1);
}
100% {
transform: scale(1);
}
}
.heartbeat {
animation: heartbeat 1s infinite;
}
+16
View File
@@ -0,0 +1,16 @@
class SubscribePusher {
constructor(subscribe, event, apikey) {
this.subscribe = subscribe;
this.event = event;
this.apikey = apikey;
}
channel_subscribe() {
let channel = pusher.subscribe(this.subscribe);
channel.bind(this.event, function(data){
callback(data);
});
}
}
export default SubscribePusher;
+19
View File
@@ -434,6 +434,17 @@ async function openuptambahdanserah(e)
}
else
{
$.ajax({
method: "GET",
url: "{{ route('event.tellercash') }}",
success:function(data){
console.log('successfull trigger');
},
error: function(xhRequest, ajaxOptions, thrownError){
console.log(xhRequest,thrownError);
}
})
$.ajax({
method:"POST",
url: api_url + '/api/requestTeller/' + kodcaw,
@@ -589,6 +600,14 @@ function tambahdanserahanfunc(e)
if(id == "serahanmodal")
{
$.ajax({
method: "GET",
url: "{{ route('event.tellercash') }}",
success:function(data){
console.log('successfull trigger');
}
})
$.ajax({
method:"POST",
url: api_url + '/api/requestTeller/' + kodcaw,
+75
View File
@@ -0,0 +1,75 @@
import NotifyKhazanah from './Class/SubscribePusher.js';
let channel = 'notify-deposit';
let event = 'deposit-event';
let apikey = "{{ env('PUSHER_APP_KEY') }}";
let api = "{{ config('api.url') }}";
let kodcaw = "{{ Auth::user()->kodcaw }}";
let requestApi = (url, method, datarequest, callback) => {
$.ajax({
method: method,
url: url,
data: datarequest,
success: function(data) {
callback(data);
},
error: function(xhRequest, ajaxOptions, thrownError) {
console.error("Request failed:", xhRequest, thrownError);
}
});
};
let triggerPage = () =>{
const notify = new NotifyKhazanah(channel,event,apikey);
notify.channel_subscribe((data) => {
console.log(data);
const currentPath = window.location.pathname;
if (currentPath === "/home") {
notify_main();
} else if (currentPath === "/menu") {
notify_khazanah_main();
}else if(currentPath === '/pendahuluan'){
notify_pendahuluan();
}else if(currentPath === '/serahan'){
notify_serahan();
}
});
}
let notify_main = () =>{
const button = document.getElementById("btn-khazanah");
if(!button){
return;
}
button.classList.add('btn-danger');
button.classList.add('heartbeat');
}
let notify_khazanah_main = () =>{
requestApi(api + '/api/requestTeller/get/' + kodcaw,"GET",{}, (response) =>{
let countModal = 0;
let countSerahan = 0;
response.forEach((req) => {
if (req.modal !== 0) {
countModal++;
} else if (req.serahan !== 0) {
countSerahan++;
}
});
});
}
let notify_pendahuluan = () =>{
}
let notify_serahan = () =>{
}