buat history and notifikasi
This commit is contained in:
@@ -36,11 +36,15 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
|
||||
<script src="{{ asset('vendor/DataTables/datatables.min.js') }}"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>
|
||||
|
||||
|
||||
{{-- Pusher --}}
|
||||
<script src="https://js.pusher.com/7.0/pusher.min.js"></script>
|
||||
|
||||
{{-- jquery validation --}}
|
||||
<script src="{{ asset('js/jquery.validate.min.js') }}"></script>
|
||||
<script src="{{ asset('js/additional-methods.min.js') }}"></script>
|
||||
|
||||
|
||||
<!-- Styles -->
|
||||
<style>
|
||||
html, body {
|
||||
@@ -96,86 +100,37 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="flex-center position-ref full-height">
|
||||
@if (Route::has('login'))
|
||||
<div class="top-right links">
|
||||
@auth
|
||||
<a href="{{ url('/home') }}">Home</a>
|
||||
@else
|
||||
<a href="{{ route('login') }}">Login</a>
|
||||
<h1>Pusher Test</h1>
|
||||
<p>
|
||||
Try publishing an event to channel <code>my-channel</code>
|
||||
with event name <code>my-event</code>.
|
||||
</p>
|
||||
<button onclick="trigtest()">Click</button>
|
||||
</body>
|
||||
|
||||
|
||||
@if (Route::has('register'))
|
||||
<a href="{{ route('register') }}">Register</a>
|
||||
@endif
|
||||
@endauth
|
||||
</div>
|
||||
@endif
|
||||
<script>
|
||||
|
||||
<div class="content">
|
||||
<div class="title m-b-md">
|
||||
Laravel
|
||||
</div>
|
||||
// // Enable pusher logging - don't include this in production
|
||||
// Pusher.logToConsole = true;
|
||||
|
||||
// var pusher = new Pusher('26b0ec2f297f94b7aa9b', {
|
||||
// cluster: 'ap1',
|
||||
// encrypted: true
|
||||
// });
|
||||
|
||||
// var channel = pusher.subscribe('status-liked');
|
||||
// channel.bind('my-event', function(data) {
|
||||
// let message = JSON.stringify(data);
|
||||
|
||||
<div class="links">
|
||||
<button class="btn btn-primary" id="login_button">Login</button>
|
||||
<button class="btn btn-primary" id="logout_button">Logout</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
// alert(message);
|
||||
// });
|
||||
|
||||
function trigtest()
|
||||
{
|
||||
pusher.bind();
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</html>
|
||||
<script>
|
||||
var auth_token;
|
||||
$('#login_button').click(function(){
|
||||
$.ajax({
|
||||
method:'POST',
|
||||
url:'http://e-arrahn.test/api/mobile/login',
|
||||
data:{
|
||||
'email':'aziz@pkb.net',
|
||||
'password':'Abc123'
|
||||
},
|
||||
dataType:'json',
|
||||
success:function(data){
|
||||
auth_token = data['token']['token'];
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Berjaya!',
|
||||
text: 'Login Berjaya'
|
||||
});
|
||||
},
|
||||
error: function(xhRequest, ErrorText, thrownError){
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Amaran!',
|
||||
text: 'Login Tidak Berjaya'
|
||||
});
|
||||
console.log(xhRequest);
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#logout_button').click(function(){
|
||||
$.ajax({
|
||||
method:'GET',
|
||||
url:'http://e-arrahn.test/api/mobile/logout',
|
||||
headers:{
|
||||
'Authorization':'Bearer '+auth_token,
|
||||
'Accept':'*'
|
||||
},
|
||||
success:function(data){
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Berjaya!',
|
||||
text: 'Logout Berjaya'
|
||||
});
|
||||
},
|
||||
error: function(xhRequest, ErrorText, thrownError){
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Amaran!',
|
||||
text: 'Logout Tidak Berjaya'
|
||||
});
|
||||
console.log(xhRequest);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user