Skip to content

Commit 29127ff

Browse files
committed
5. laboratorijska vjezba
Dodana autentifikacija i autorizacija Dodana JSON-LD semantika
1 parent 9d2c5f5 commit 29127ff

File tree

2 files changed

+421
-42
lines changed

2 files changed

+421
-42
lines changed

public/home.html

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<meta name="description" content="Skup podataka o punionicama električnih vozila na području Osijeka i Zagreba. Punionice su organzirane tako da imaju vezo roditelj-dijete između punionice i stanica za punjenje. Podaci ovog skupa dostupni su za preuzimanje u JSON i CSV formatu.">
77
<meta name="author" content="Borna Krušlin">
8-
<meta name="license" content="Creative Commons Zero v1.0 Universal"
9-
<meta name="contact information" content="[email protected]"
8+
<meta name="license" content="Creative Commons Zero v1.0 Universal">
9+
<meta name="contact information" content="[email protected]">
1010
<title>HomePage</title>
1111
<style>
1212
body {
@@ -62,6 +62,10 @@ <h1>Podaci o punionicama električnih vozila na području Osijeka i Zagreba</h1>
6262
<button onclick="downloadJSON()">Preuzmi JSON</button>
6363
<button onclick="downloadCSV()">Preuzmi CSV</button>
6464
<a href="/dataset">Pretraga baze</a>
65+
<a id="login" href="/login">Prijava</a>
66+
<a id="profile" href="/profile" style="display:none;">Korisnički profil</a>
67+
<a id="refresh" href="/refresh" style="display:none;">Osvježi preslike</a>
68+
<a id="logout" href="/logout" style="display:none;">Odjava</a>
6569
</body>
6670
<script>
6771
function downloadJSON(){
@@ -70,5 +74,32 @@ <h1>Podaci o punionicama električnih vozila na području Osijeka i Zagreba</h1>
7074
function downloadCSV(){
7175
window.location.href = '/punionice.csv';
7276
}
77+
78+
// Function to check if the user is authenticated
79+
function checkAuth() {
80+
fetch('/profile', {
81+
method: 'GET',
82+
headers: {
83+
'Accept': 'application/json'
84+
}
85+
}).then(response => {
86+
if (response.ok) {
87+
document.getElementById('login').style.display = 'none';
88+
document.getElementById('profile').style.display = 'inline-block';
89+
document.getElementById('refresh').style.display = 'inline-block';
90+
document.getElementById('logout').style.display = 'inline-block';
91+
} else {
92+
document.getElementById('login').style.display = 'inline-block';
93+
document.getElementById('profile').style.display = 'none';
94+
document.getElementById('refresh').style.display = 'none';
95+
document.getElementById('logout').style.display = 'none';
96+
}
97+
}).catch(error => {
98+
console.error('Error:', error);
99+
});
100+
}
101+
102+
// Check authentication status on page load
103+
window.onload = checkAuth;
73104
</script>
74105
</html>

0 commit comments

Comments
 (0)