Revize 65c37e8b
Přidáno uživatelem Pavel Fidranský před více než 6 roky(ů)
sources/src/main/webapp/js/uploadFilesApp.js | ||
---|---|---|
9 | 9 |
run() { |
10 | 10 |
console.log('running...'); |
11 | 11 |
|
12 |
// auth popup |
|
13 |
const header = document.getElementById('header'); |
|
14 |
|
|
15 |
const loginPopup = new LoginPopup; |
|
16 |
header.appendChild(loginPopup.render()); |
|
17 |
|
|
18 |
const registerPopup = new RegisterPopup; |
|
19 |
header.appendChild(registerPopup.render()); |
|
20 |
|
|
21 |
document.getElementById('toggleLoginPopupButton').addEventListener('click', () => { |
|
22 |
registerPopup.close(); |
|
23 |
loginPopup.toggle(); |
|
24 |
}); |
|
25 |
|
|
26 |
document.getElementById('toggleRegisterPopupButton').addEventListener('click', () => { |
|
27 |
loginPopup.close(); |
|
28 |
registerPopup.toggle(); |
|
29 |
}); |
|
30 |
|
|
31 |
document.getElementById('logoutButton').addEventListener('click', e => { |
|
32 |
e.preventDefault(); |
|
33 |
this._logOut(); |
|
34 |
}); |
|
35 |
|
|
36 |
// private diagrams list |
|
12 | 37 |
const privateDiagramList = document.getElementById('privateDiagramList'); |
13 | 38 |
privateDiagramList.querySelectorAll('.remove-diagram-button').forEach(button => { |
14 | 39 |
button.addEventListener('click', this._removeDiagram); |
... | ... | |
27 | 52 |
}); |
28 | 53 |
} |
29 | 54 |
|
55 |
/** |
|
56 |
* Logs user out. |
|
57 |
*/ |
|
58 |
async _logOut() { |
|
59 |
try { |
|
60 |
await AJAX.get(Constants.API.logOut); |
|
61 |
|
|
62 |
document.dispatchEvent(new CustomEvent('imiger.userLoggedOut')); |
|
63 |
|
|
64 |
document.body.classList.remove('loggedIn'); |
|
65 |
document.body.classList.add('loggedOut'); |
|
66 |
|
|
67 |
} catch (error) { |
|
68 |
if (error instanceof HttpError) { |
|
69 |
alert('Something went wrong.'); |
|
70 |
} else { |
|
71 |
alert('Server has probably gone away.'); |
|
72 |
} |
|
73 |
} |
|
74 |
} |
|
75 |
|
|
30 | 76 |
/** |
31 | 77 |
* Loads private diagrams of the logged in user and adds them to a list. |
32 | 78 |
*/ |
sources/src/main/webapp/uploadFiles.jsp | ||
---|---|---|
31 | 31 |
<script src="js/app.js"></script> |
32 | 32 |
<script src="js/uploadFilesApp.js"></script> |
33 | 33 |
|
34 |
<script src="js/userMenu.js"></script> |
|
35 |
|
|
36 | 34 |
<title>${APP_NAME}</title> |
37 | 35 |
</head> |
38 | 36 |
|
... | ... | |
42 | 40 |
|
43 | 41 |
<h2 class="header-title">Interactive Multimodal Graph Explorer</h2> |
44 | 42 |
|
45 |
<%@ include file="userMenu.jsp" %> |
|
43 |
<div class="user-menu loggedInOnly"> |
|
44 |
<span id="usernameLabel">${user.username}</span> |
|
45 |
<button class="button" id="logoutButton">Log out</button> |
|
46 |
</div> |
|
47 |
|
|
48 |
<div class="user-menu loggedOutOnly"> |
|
49 |
<button class="button" id="toggleLoginPopupButton">Log in</button> |
|
50 |
<button class="button" id="toggleRegisterPopupButton">Register</button> |
|
51 |
</div> |
|
46 | 52 |
</header> |
47 | 53 |
|
48 | 54 |
<main> |
Také k dispozici: Unified diff
added userMenu functionality to UploadFilesApp