finished notification

This commit is contained in:
hafifierahman
2024-11-08 22:00:17 +08:00
parent 4c113cb052
commit c4388321aa
9 changed files with 688 additions and 36 deletions
+6 -2
View File
@@ -3,14 +3,18 @@ class SubscribePusher {
this.subscribe = subscribe;
this.event = event;
this.apikey = apikey;
this.pusher = new Pusher(this.apikey, {
cluster: 'ap1', // Replace 'your_cluster' with the actual cluster of your Pusher app
});
}
channel_subscribe() {
let channel = pusher.subscribe(this.subscribe);
channel_subscribe(callback) {
let channel = this.pusher.subscribe(this.subscribe);
channel.bind(this.event, function(data){
callback(data);
});
}
}
export default SubscribePusher;
+2 -2
View File
@@ -436,7 +436,7 @@ async function openuptambahdanserah(e)
{
$.ajax({
method: "GET",
url: "{{ route('event.tellercash') }}",
url: event_tellercash,
success:function(data){
console.log('successfull trigger');
},
@@ -602,7 +602,7 @@ function tambahdanserahanfunc(e)
$.ajax({
method: "GET",
url: "{{ route('event.tellercash') }}",
url: event_tellercash,
success:function(data){
console.log('successfull trigger');
}
+59 -26
View File
@@ -1,10 +1,40 @@
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 apikey = window.apikey;
const Toast = Swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 5000,
timerProgressBar: true,
didOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer)
toast.addEventListener('mouseleave', Swal.resumeTimer)
}
})
const notify = new NotifyKhazanah(channel,event,apikey);
notify.channel_subscribe((data) => {
console.log(data);
Toast.fire({
icon: 'info',
title: 'Permohonan Kelulusan Wang Tunai Teller!'
});
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 requestApi = (url, method, datarequest, callback) => {
$.ajax({
@@ -20,25 +50,6 @@ let requestApi = (url, method, datarequest, callback) => {
});
};
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");
@@ -52,7 +63,7 @@ let notify_main = () =>{
}
let notify_khazanah_main = () =>{
requestApi(api + '/api/requestTeller/get/' + kodcaw,"GET",{}, (response) =>{
requestApi(window.api + '/api/requestTeller/get/' + window.kodcaw,"GET",{}, (response) =>{
let countModal = 0;
let countSerahan = 0;
@@ -63,13 +74,35 @@ let notify_khazanah_main = () =>{
countSerahan++;
}
});
let btn_serahan = document.getElementById('btn-ser');
let btn_pendahuluan = document.getElementById('btn-pend');
let span_element_ser = btn_serahan.querySelector('span');
let span_element_pend = btn_pendahuluan.querySelector('span');
if(!btn_serahan.classList.contains('btn-danger') && countSerahan > 0){
btn_serahan.classList.add('btn-danger');
span_element_ser.innerText = countSerahan;
}
if(!btn_pendahuluan.classList.contains('btn-danger') && countModal > 0){
btn_pendahuluan.classList.add('btn-danger');
span_element_pend.innerText = countModal;
}
});
}
let notify_pendahuluan = () =>{
timer_reload();
}
let notify_serahan = () =>{
timer_reload();
}
let timer_reload = () =>{
setTimeout(() => {
window.location.reload();
}, 3000);
}