addded notification
This commit is contained in:
Vendored
+16
@@ -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;
|
||||
Vendored
+19
@@ -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,
|
||||
|
||||
Vendored
+75
@@ -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 = () =>{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user