1
|
<%@page contentType="text/html" pageEncoding="UTF-8"%>
|
2
|
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
|
3
|
|
4
|
<c:set var="HOME_URL" value="${initParam.HOME_URL}"/>
|
5
|
<c:set var="isLoggedIn" value="${sessionScope.isLoggedIn}"/>
|
6
|
<c:set var="user" value="${sessionScope.user}"/>
|
7
|
|
8
|
<!DOCTYPE html>
|
9
|
<html>
|
10
|
<head>
|
11
|
<meta charset="utf-8">
|
12
|
|
13
|
<link rel="stylesheet" href="css/main.css">
|
14
|
|
15
|
<script src="js/libs/jquery-3.3.1.min.js"></script>
|
16
|
<script src="js/userMenu.js"></script>
|
17
|
|
18
|
<title>IMiGEr</title>
|
19
|
</head>
|
20
|
|
21
|
<body class="${isLoggedIn ? 'loggedIn' : 'loggedOut'}">
|
22
|
<header class="header" id="header">
|
23
|
<img src="images/logo.png" class="header-logo" alt="logo of University of West Bohemia" title="University of West Bohemia">
|
24
|
|
25
|
<h2 class="header-title">Interactive Multimodal Graph Explorer</h2>
|
26
|
|
27
|
<%@ include file="userMenu.jsp" %>
|
28
|
</header>
|
29
|
|
30
|
<main>
|
31
|
<div class="upload-form">
|
32
|
<h3>New diagram</h3>
|
33
|
|
34
|
<c:if test="${not empty errorMessage}">
|
35
|
<p class="alert">${errorMessage}</p>
|
36
|
</c:if>
|
37
|
|
38
|
<form method="post" enctype="multipart/form-data">
|
39
|
<div class="form-field">
|
40
|
<label for="file">Select JSON data file:</label><br>
|
41
|
<input type="file" name="file" id="file">
|
42
|
</div>
|
43
|
|
44
|
<div class="form-field">
|
45
|
Select type of data file:<br>
|
46
|
<label for="spade"><input type="radio" name="jsonFileFormat" value="spade" id="spade" checked> Spade JSON</label><br>
|
47
|
<label for="raw"><input type="radio" name="jsonFileFormat" value="raw" id="raw"> Raw JSON</label><br>
|
48
|
</div>
|
49
|
|
50
|
<button id="btnLoad" type="submit">Start visualization</button>
|
51
|
</form>
|
52
|
</div>
|
53
|
|
54
|
<div class="diagrams-menu loggedInOnly">
|
55
|
<h3>My diagrams</h3>
|
56
|
|
57
|
<ul id="privateDiagramList">
|
58
|
<c:forEach items="${diagramsPrivate}" var="diagram">
|
59
|
<li>
|
60
|
<a href="${HOME_URL}graph?diagramId=${diagram.id}">${diagram.name}</a>
|
61
|
<button class="removeDiagramButton" data-name="${diagram.name}" data-id="${diagram.id}"><img src="images/button_cancel.png" alt="odstranit"></button>
|
62
|
</li>
|
63
|
</c:forEach>
|
64
|
</ul>
|
65
|
</div>
|
66
|
|
67
|
<div class="diagrams-menu">
|
68
|
<h3>Public diagrams</h3>
|
69
|
|
70
|
<ul id="publicDiagramList">
|
71
|
<c:forEach items="${diagramsPublic}" var="diagram">
|
72
|
<li>
|
73
|
<a href="${HOME_URL}graph?diagramId=${diagram.id}">${diagram.name}</a>
|
74
|
</li>
|
75
|
</c:forEach>
|
76
|
</ul>
|
77
|
</div>
|
78
|
</main>
|
79
|
|
80
|
<script>
|
81
|
var privateDiagramList = document.getElementById('privateDiagramList');
|
82
|
|
83
|
$(privateDiagramList).on('click', '.removeDiagramButton', function(e) {
|
84
|
if (confirm('Do you really want to delete ' + $(this).data('name') + '?')) {
|
85
|
$.ajax({
|
86
|
'type': 'delete',
|
87
|
'url': 'api/remove-diagram?diagramId=' + $(this).data('id'),
|
88
|
'success': function () {
|
89
|
location.reload(true);
|
90
|
},
|
91
|
'error': function (xhr) {
|
92
|
switch (xhr.status) {
|
93
|
case 401:
|
94
|
alert('You are either not logged in or not an owner of this diagram.');
|
95
|
break;
|
96
|
default:
|
97
|
alert('Something went wrong.');
|
98
|
}
|
99
|
},
|
100
|
});
|
101
|
}
|
102
|
});
|
103
|
|
104
|
document.addEventListener('imiger.userLoggedIn', function() {
|
105
|
$.getJSON('api/get-private-diagrams').then(function(data) {
|
106
|
data.forEach(function(diagram) {
|
107
|
var openDiagramLink = document.createElement('a');
|
108
|
openDiagramLink.setAttribute('href', './graph?diagramId=' + diagram.id);
|
109
|
openDiagramLink.innerText = diagram.name;
|
110
|
|
111
|
var removeDiagramIcon = document.createElement('img');
|
112
|
removeDiagramIcon.setAttribute('src', 'images/button_cancel.png');
|
113
|
removeDiagramIcon.setAttribute('alt', 'odstranit');
|
114
|
|
115
|
var removeDiagramButton = document.createElement('button');
|
116
|
removeDiagramButton.setAttribute('class', 'removeDiagramButton');
|
117
|
removeDiagramButton.setAttribute('data-id', diagram.id);
|
118
|
removeDiagramButton.setAttribute('data-name', diagram.name);
|
119
|
removeDiagramButton.appendChild(removeDiagramIcon);
|
120
|
|
121
|
var diagramListItem = document.createElement('li');
|
122
|
diagramListItem.appendChild(openDiagramLink);
|
123
|
diagramListItem.appendChild(removeDiagramButton);
|
124
|
|
125
|
privateDiagramList.appendChild(diagramListItem);
|
126
|
});
|
127
|
});
|
128
|
});
|
129
|
|
130
|
document.addEventListener('imiger.userLoggedOut', function() {
|
131
|
privateDiagramList.innerHTML = '';
|
132
|
});
|
133
|
</script>
|
134
|
</body>
|
135
|
</html>
|