source: frontend/js/AdminPanel.js@ 0a7426e

Last change on this file since 0a7426e was c164f8f, checked in by Kristijan <kristijanzafirovski26@…>, 6 days ago

pred-finalna

  • Property mode set to 100644
File size: 1.8 KB
Line 
1document.getElementById('startScraperButton').addEventListener('click', function() {
2
3 fetch('/admin/start-scraper', { method: 'POST' })
4 .then(response => response.json())
5 .then(data => alert(data.message))
6 .catch(error => console.error('Error:', error));
7
8 fetchLastUpdateTime();
9});
10function popupConfirm(){
11 const div = document.getElementById('warning').style.display = 'block';
12}
13function popupClose(){
14 const div = document.getElementById('warning').style.display = 'none';
15}
16document.getElementById('confirmDrop').addEventListener('click', function() {
17
18 fetch('/admin/drop-db', {method: 'GET'}).then(r => alert("Database dropped")).catch(err => console.error(err));
19 popupClose();
20});
21function fetchLastUpdateTime() {
22 fetch('/admin/last-update-time')
23 .then(response => response.json())
24 .then(data => {
25 document.getElementById('lastUpdateTime').textContent = new Date(data.lastUpdateTime).toLocaleString();
26 })
27 .catch(error => console.error('Error fetching last update time:', error));
28}
29function fetchCurrentOptionsCount() {
30 fetch('/admin/current-options-count')
31 .then(response => response.json())
32 .then(data => {
33 document.getElementById('currentOptionsCount').textContent = data.currentOptionsCount;
34 })
35 .catch(error => console.error('Error fetching current options count:', error));
36}
37
38// Fetch data when the page loads
39document.addEventListener('DOMContentLoaded', function() {
40 fetchLastUpdateTime();
41 fetchCurrentOptionsCount();
42});
43
44
45document.getElementById('logoutButton').addEventListener('click', function() {
46 sessionStorage.removeItem('loggedIn');
47 sessionStorage.removeItem('userEmail');
48 window.location.href = 'index.html'; // Redirect
49});
Note: See TracBrowser for help on using the repository browser.