-
Notifications
You must be signed in to change notification settings - Fork 1
/
panelControl.php
341 lines (284 loc) · 12.9 KB
/
panelControl.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
<?php
session_start();
if(!$_SESSION['loggedin']){
header('location: login.php');
}else{
include 'model.php';
$users = model::getUsers();
$groups = model::getGroups();
$newUserId = model::getNewUserId();
$newLink = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]" . dirname($_SERVER['PHP_SELF']) . 'index.php?id=' . $newUserId ;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>DANTE - Administration</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/login.css" rel="stylesheet">
</head>
<body>
<div class="container">
<h2>DANTE - Administration</h2>
<h3>Sync database</h3>
<div id="doing-sync" class="alert alert-info" style="display: none">
<strong>Synchronization</strong> Please wait...
</div>
<div id="success-sync" class="alert alert-success alert-dismissible" role="alert" style="display: none">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden=true>×</span>
</button>
Synchronization done! <br>
</div>
<div id="error-sync" class="alert alert-danger alert-dismissible" role="alert" style="display: none">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden=true>×</span>
</button>
<strong>Error</strong> An error has occured during synchronization.
</div>
<p>
Annotators can be organized in annotation groups, where each group is allowed to annotate a specific subset of videos.<br>
Such functionality is realized by placing the videos in the following hierarchy <code>/video/xxx/</code>, where
<code>xxx</code> is the name of an annotation group.
<div class="alert alert-warning" role="alert">
<strong><i class="fa fa-warning" aria-hidden="true"></i></strong> Supported video formats are: Theora (Ogg), H.264 (MP4), HEVC (MP4), VP8 (WebM), VP9 (WebM), AV1 (WebM).<br> For a wider web browser compatibility we suggest to adopt H.264 (MP4) file format.
</div>
</p>
<p>
<strong>Example</strong><br>
To create two annotation groups, <em>alpha</em> and <em>beta</em>:
<ol>
<li>create the following directories <code>/video/alpha/</code> and <code>/video/beta/</code></li>
<li>place the videos to be annotated in the relative directories.</li>
<li>press <strong>Sync now</strong> button</li>
<li>reload the page and add a new annotator, assigning the corresponding group</li>
</ol>
</p>
<div id="sycngroup">
<button type="submit" id="btnSync" class="btn btn-default btn-primary">Sync now</button>
</div>
</div>
<hr>
<div class="container">
<h3>Annotators</h3>
<div id="doing-delete" class="alert alert-info" style="display: none">
<strong>Deletion</strong> Please wait...
</div>
<div id="success-delete" class="alert alert-success alert-dismissible" role="alert" style="display: none">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden=true>×</span>
</button>
Annotator correctly deleted! <br>
</div>
<div id="error-delete" class="alert alert-danger alert-dismissible" role="alert" style="display: none">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden=true>×</span>
</button>
<strong>Error</strong> An error has occured during deletion.
</div>
<p>List of current annotators. The deletion of an annotator does not delete relative annotations already done.</p>
<table class="table table-condensed">
<thead>
<tr>
<th>ID</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
<th>Group id</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
while($riga = mysqli_fetch_array($users)){
echo '<tr>';
echo '<td>' . $riga['id'] . '</td>';
echo '<td>' . $riga['name'] . '</td>';
echo '<td>' . $riga['surname'] . '</td>';
echo '<td>' . $riga['email'] . '</td>';
echo '<td>' . $riga['fk_idgroup'] . '</td>';
echo '<td><button data-id="' . $riga['id'] . '" class="btn btn-xs btn-danger deleteUser">Delete</button></td>';
echo '</tr>';
}
?>
</tbody>
</table>
</div>
<hr>
<div class="container">
<h3>Add new annotator</h3>
<div id="doing-add" class="alert alert-info" style="display: none">
<strong>Creating</strong> Please wait...
</div>
<div id="success-add" class="alert alert-success alert-dismissible" role="alert" style="display: none">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden=true>×</span>
</button>
New annotator added, please copy and send the following personal URL: <br>
<strong><?php echo $newLink ?></strong>
</div>
<div id="error-add" class="alert alert-danger alert-dismissible" role="alert" style="display: none">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden=true>×</span>
</button>
<strong>Error</strong> An error has occured, please contact the mantainer.
</div>
<p>Add a new annotator by inserting the required information.</p>
<form id="formNewUser" onsubmit="" action="" class="form-inline">
<div class="form-group">
<div for="name">Name</div>
<input type="text" class="form-control" name="name" placeholder="Jane" required="">
</div>
<div class="form-group">
<div for="surname">Surname</div>
<input type="text" class="form-control" name="surname" placeholder="Doe" required="">
</div>
<div class="form-group">
<div for="email">Email</div>
<input type="email" class="form-control" name="email" placeholder="[email protected]" required="">
</div>
<div class="form-group">
<div for="group">Group</div>
<select name="group" class="form-control">
<?php
while($riga = mysqli_fetch_array($groups)){
echo '<option value="'.$riga['name'].'">'.$riga['name'].'</option>';
}
?>
</select>
</div>
<div class="form-group">
<div for="idUser">Id</div>
<input name="idUser" class="form-control" value="<?php echo $newUserId ?>" size="4px" readonly></input>
</div>
<div class="form-group">
<div> </div>
<button type="submit" id="btnAdd" class="btn btn-default btn-primary">Add</button>
</div>
</form>
<button type="submit" id="btnNew" class="btn btn-default btn-primary" style="display:none">Add new</button>
</div>
<hr>
<div class="container">
<h3>Change admin password</h3>
<div id="doing-update" class="alert alert-info" style="display: none">
<strong>Updating</strong> Please wait...
</div>
<div id="success-update" class="alert alert-success alert-dismissible" role="alert" style="display: none">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden=true>×</span>
</button>
Administrator password updated correctly!
</div>
<div id="error-update" class="alert alert-danger alert-dismissible" role="alert" style="display: none">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden=true>×</span>
</button>
<strong>Error</strong> An error has occured, please contact the mantainer.
</div>
<p>For security reasons, please remember to update the default admin password as soon as possible.</p>
<form id="formNewPass" onsubmit="" action="" class="form-inline">
<div class="form-group">
<div for="pwd">New password</div>
<input id="adminPass" pattern=".{5,}" title="5 characters minimum" name="pwd" type="password" class="form-control" size="20px"></input>
</div>
<div class="form-group">
<div> </div>
<button type="submit" id="btnUpdate" class="btn btn-default btn-primary">Update</button>
</div>
</form>
</div>
<!-- jQuery -->
<script type="text/javascript" src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script>
$("#formNewUser").submit(function(e) {
e.preventDefault();
$('#doing-add').fadeIn();
var userData = objectifyForm($("#formNewUser").serializeArray());
$.ajax({
type: "POST",
url: "addUser.php",
data: {data : JSON.stringify(userData)},
cache: false,
success: function (response) {
$('#doing-add').fadeOut(function() {$('#success-add').fadeIn()});
$("#formNewUser").fadeOut();
$("#btnNew").fadeIn();
},
error: function (xhr, ajaxOptions, thrownError) {
$('#doing-add').fadeOut(function() {$('#error-add').fadeIn()});
console.log(xhr.responseText);
}
});
return false;
});
$('#btnNew').click(function(e) {
window.location.reload();
});
$('#btnSync').click(function(e) {
$('#doing-sync').fadeIn();
$.ajax({
type: "GET",
url: "syncgroup.php",
cache: false,
success: function (response) {
$('#doing-sync').fadeOut(function() {$('#success-sync').fadeIn()});
},
error: function (xhr, ajaxOptions, thrownError) {
$('#doing-sync').fadeOut(function() {$('#error-sync').fadeIn()});
console.log(xhr.responseText);
}
});
return false;
});
$("#formNewPass").submit(function(e) {
e.preventDefault();
$('#doing-update').fadeIn();
var userData = $("#adminPass").val();
$.ajax({
type: "POST",
url: "updateAdmin.php",
data: {password : JSON.stringify(userData)},
cache: false,
success: function (response) {
$('#doing-update').fadeOut(function() {$('#success-update').fadeIn()});
},
error: function (xhr, ajaxOptions, thrownError) {
$('#doing-update').fadeOut(function() {$('#error-update').fadeIn()});
console.log(xhr.responseText);
}
});
return false;
});
$('.deleteUser').click(function(e) {
$('#doing-delete').fadeIn();
var annoId = $(this).data('id');
$.ajax({
type: "POST",
url: "deleteUser.php",
data: {annoId: annoId},
cache: false,
success: function (response) {
$('#doing-delete').fadeOut(function() {$('#success-delete').fadeIn()});
window.location.reload();
},
error: function (xhr, ajaxOptions, thrownError) {
$('#doing-delete').fadeOut(function() {$('#error-delete').fadeIn()});
console.log(xhr.responseText);
}
});
return false;
});
function objectifyForm(formArray) {//serialize data function
var returnArray = {};
for (var i = 0; i < formArray.length; i++){
returnArray[formArray[i]['name']] = formArray[i]['value'];
}
return returnArray;
}
</script>
</body>
</html>