Skip to content

Commit 2bd0d06

Browse files
committed
l
1 parent 860cc8a commit 2bd0d06

31 files changed

Lines changed: 2088 additions & 867 deletions

app/Config/Routes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
$routes->add('form', 'BuildResponse::show/45');
4444
$routes->add('login', 'BuildResponse::loginForm');
4545
});
46+
$routes->add('home', 'Admin::home');
4647
$routes->add('dashboard', 'Admin::dashboard');
4748
});
4849

app/Controllers/Admin.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
class Admin extends BaseController
44
{
55
public function dashboard()
6+
{
7+
return view('admin/dashboard');
8+
}
9+
10+
public function home()
611
{
712
return view('admin/index');
813
}

app/Views/admin/dashboard.php

Lines changed: 687 additions & 0 deletions
Large diffs are not rendered by default.

app/Views/admin/footer.php

Lines changed: 60 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,53 +14,75 @@
1414
<!-- Page level custom scripts -->
1515
<script src="<?= base_url('js/demo/chart-area-demo.js') ?>"></script>
1616
<script src="<?= base_url('js/demo/chart-pie-demo.js') ?>"></script>
17-
18-
<!-- The core Firebase JS SDK is always required and must be listed first -->
1917
<script src="https://www.gstatic.com/firebasejs/8.2.2/firebase-app.js"></script>
20-
21-
<!-- TODO: Add SDKs for Firebase products that you want to use
22-
https://firebase.google.com/docs/web/setup#available-libraries -->
2318
<script src="https://www.gstatic.com/firebasejs/8.2.2/firebase-messaging.js"></script>
2419

20+
2521
<script>
26-
// Your web app's Firebase configuration
27-
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
28-
var firebaseConfig = {
29-
apiKey: "AIzaSyDwryXt3F82bEwZW00MtJlfUcSSxMWDv0M",
30-
authDomain: "admin-dashboard-b0cbd.firebaseapp.com",
31-
projectId: "admin-dashboard-b0cbd",
32-
storageBucket: "admin-dashboard-b0cbd.appspot.com",
33-
messagingSenderId: "779440569317",
34-
appId: "1:779440569317:web:ff6fed27c72157fd850d0c",
35-
measurementId: "G-TRPWWWNMNF"
36-
};
37-
// Initialize Firebase
38-
firebase.initializeApp(firebaseConfig);
22+
// Your web app's Firebase configuration
23+
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
24+
var firebaseConfig = {
25+
apiKey: "AIzaSyCITZQ354SOOSmElp5WEYOkvnuT9B7Tp-s",
26+
authDomain: "ci4-firebase-7eb2d.firebaseapp.com",
27+
projectId: "ci4-firebase-7eb2d",
28+
storageBucket: "ci4-firebase-7eb2d.appspot.com",
29+
messagingSenderId: "551568081824",
30+
appId: "1:551568081824:web:7d5b2baddb344657081ac5",
31+
measurementId: "G-G7FB02J0DX"
32+
};
33+
// Initialize Firebase
34+
firebase.initializeApp(firebaseConfig);
3935

36+
const fcm = firebase.messaging()
37+
fcm.getToken({
38+
vapidKey: 'BNq7dY7XYEZBETPjHGVyFQ_TlNfjQhyeFl5cghu8ru4SB_Xj2k-W1kwo_tO3UkTOeCRns8qhnTtzoMagkv5LqgE'
39+
}).then((token) => {
40+
console.log('getToken: ', token)
41+
});
4042

41-
// Retrieve Firebase Messaging object.
42-
const messaging = firebase.messaging();
4343

44-
// Get registration token. Initially this makes a network call, once retrieved
45-
// subsequent calls to getToken will return from cache.
46-
messaging.getToken({
47-
vapidKey: 'BDRZzzVm6iZaZctzyehpyRX0auU-WfVjn9tF6LSfOSLhPxDHptnewOEutxdINidFYCcXSHf-3kYK9MTOU2gdkio'
48-
}).then((currentToken) => {
49-
if (currentToken) {
50-
console.log('registration token available', currentToken)
51-
} else {
52-
// Show permission request.
53-
console.log('No registration token available. Request permission to generate one.');
54-
}
55-
}).catch((err) => {
56-
console.error('An error occurred while retrieving token. ', err);
57-
});
5844

59-
messaging.onMessage((payload) => {
60-
console.log('Message received. ', payload);
61-
});
62-
</script>
45+
fcm.onMessage((data) => {
46+
console.log('onMessage: ', data)
47+
let title = data['data']['title']
48+
let body = data['data']['body']
49+
//.badge-counter
50+
let count = localStorage.getItem("notification-count");
51+
if (count) {
52+
localStorage.setItem("notification-count", parseInt(count) + 1);
53+
} else {
54+
localStorage.setItem("notification-count", 1);
55+
}
6356

57+
$('.badge-counter').text(localStorage.getItem("notification-count"))
58+
59+
$('#dropdown-container').append(
60+
`<a class="dropdown-item d-flex align-items-center" href="#">
61+
<div class="mr-3">
62+
<div class="icon-circle bg-primary">
63+
<i class="fas fa-file-alt text-white"></i>
64+
</div>
65+
</div>
66+
<div>
67+
<div class="small text-gray-500">${new Date().toLocaleString('en-US', { hour: 'numeric', minute: 'numeric', hour12: true })}</div>
68+
<span class="font-weight-bold">${title}</span>
69+
</div>
70+
</a>`
71+
)
72+
73+
//const pattern = /^\(\d+\)/
74+
75+
Notification.requestPermission((status) => {
76+
console.log('requestPermission', status)
77+
if (status === 'granted') {
78+
79+
new Notification(title, {
80+
body: body
81+
})
82+
}
83+
})
84+
})
85+
</script>
6486
</body>
6587

6688
</html>

0 commit comments

Comments
 (0)