-
Notifications
You must be signed in to change notification settings - Fork 3
/
invention.html
319 lines (293 loc) · 13 KB
/
invention.html
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="Create processing jobs for this machine">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Invention</title>
<!-- Add to homescreen for Chrome on Android -->
<meta name="mobile-web-app-capable" content="yes">
<link rel="icon" sizes="192x192" href="images/touch/chrome-touch-icon-192x192.png">
<!-- Add to homescreen for Safari on iOS -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="Material Design Lite">
<link rel="apple-touch-icon-precomposed" href="apple-touch-icon-precomposed.png">
<!-- Tile icon for Win8 (144x144 + tile color) -->
<meta name="msapplication-TileImage" content="images/touch/ms-touch-icon-144x144-precomposed.png">
<meta name="msapplication-TileColor" content="#3372DF">
<!-- SEO: If your mobile URL is different from the desktop URL, add a canonical link to the desktop page https://developers.google.com/webmasters/smartphone-sites/feature-phones -->
<!--
<link rel="canonical" href="http://www.example.com/">
-->
<link href="https://fonts.googleapis.com/css?family=Roboto:regular,bold,italic,thin,light,bolditalic,black,medium&lang=en" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="css/materialize.min.css">
<!-- <link rel="stylesheet" href="css/ghpages-materialize.css"> -->
<link rel="stylesheet" href="css/styles.css">
<style>
#view-source {
position: fixed;
display: block;
right: 0;
bottom: 0;
margin-right: 40px;
margin-bottom: 40px;
z-index: 900;
}
iframe {
width: 100%;
height: 500px;
border-radius: 5px;
}
iframe:hover {
animation-duration: 1s;
box-shadow: 0px 0px 10px #888;
}
.console {
background-color: rgba(200,200,200,0.5);
color: #000;
width: 100%;
height: 400px;
position: absolute;
bottom: 0;
padding: 5px;
}
.console textarea {
height: 400px;
padding: 10px;
}
</style>
<!-- <link rel="stylesheet" href="css/dialog-polyfill.min.css"> -->
</head>
<body>
<div class="navbar-fixed">
<nav>
<div class="nav-wrapper">
<a href="#" class="brand-logo"> Invention</a>
<ul class="right hide-on-med-and-down">
<li><a href="#modal-about" class="modal-trigger" id="dialog-about-button">About</a></li>
</ul>
</div>
</nav>
</div>
<main class="container">
<div class="row"> </div>
<div class="row">
<div class="section col s12">
<div id="list-of-machines"></div>
</div>
</div>
<div class="fixed-action-btn" style="bottom: 40px; right: 30px;">
<a class="btn-floating btn-large waves-effect waves-light red" id="add-machine"><i class="material-icons">add</i></a>
</div>
</main>
</div>
<dialog class="mdl-dialog modal" id="modal-about">
<div class="mdl-dialog__content modal-content">
<div style="font-size: 22pt; margin-bottom: 20px;">
Invention
</div>
<div>
<p>
Create processing pipelines that can be shared across instances of this platform. In order to see what goes on behind the scenes open the <span id="console-start">console</span>.
</p>
Note: The docker interface components depend on a particular port range (4200-4220) to be open on your network. If these ports are not open no connection to the consoles can be established. You can still run a local browser on the machine to see the interface.
<p>
</p>
<p>
Learn more about this project by visiting <a href="https://abcd-workspace.ucsd.edu">abcd-workspace.ucsd.edu</a>.
</p>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn mdl-button close-dialog modal-action modal-close btn-flat">OK</button>
</div>
</dialog>
<dialog class="mdl-dialog modal" id="modal-start-container">
<div class="mdl-dialog__content modal-content">
<div style="font-size: 22pt; margin-bottom: 20px;">
Start
</div>
<div>
<p>
Specify what data this container should see on your system
</p>
<p>
<form>
<div class="row">
<div class="input-field col s6">
<select id="start-container-start-option">
<option value="">What data should be made available?</option>
<option value="all_data" selected>All Data</option>
<option value="random_study">A random study</option>
<option value="random_series">A random series</option>
<option value="random_t1">A random T1 series</option>
<option value="random_phantom">A random phantom scan</option>
<option value="random_diffusion">A random diffusion series</option>
<option value="random_resting">A random resting state series</option>
<option value="random_functional">A random functional image series</option>
</select>
<label>Input provided to this container</label>
</div>
</div>
</form>
</p>
</div>
</div>
<div class="mdl-dialog__actions modal-footer">
<button type="button" class="btn mdl-button modal-action modal-close close-dialog">Close</button>
<button type="button" class="btn mdl-button modal-action modal-close" id="start-container-start">Start</button>
</div>
</dialog>
<script src="js/jquery-2.1.4.min.js"></script>
<!-- <script src="js/dialog-polyfill.min.js"></script> -->
<script src="js/materialize.min.js"></script>
<script>
runUpdate = false;
function checkShell( id ) {
jQuery.getJSON('php/machines.php', {}, function(data) {
for (var i = 0; i < data.length; i++) {
if (id == data[i].id && typeof data[i].port != 'undefined' && data[i].port != "") {
// found the right entry, add to page using its id
setTimeout(function() { jQuery('#'+id).append("<iframe str='//localhost:" + data[i].port + "'></iframe>"); }, 4000);
return;
}
}
if (runUpdate == false) {
setTimeout(checkShell(id), 2000); // check again later
runUpdate=true;
}
});
}
// get all machines that exist already and add to user interface
function getListOfMachines() {
jQuery.getJSON('php/machines.php', function(data) {
for (var i = 0; i < data.length; i++) {
jQuery('#list-of-machines').append("<div id=\"" + data[i].id + "\" style=\"position: relative; min-height: 70px;\"></div>");
jQuery('#'+data[i].id).append(
"<div class=\"fixed-action-btn horizontal click-to-toggle\" style=\"position: absolute; right: 24px; top: -20px;\">" +
" <a class=\"btn-floating btn-large red\">" +
" <i class=\"large material-icons\">mode_edit</i>" +
" </a>" +
" <ul>" +
// <li><a class=\"btn-floating green publish-container\" title=\"publish this container\" container=\""+data[i].id+"\"><i class=\"material-icons\">publish</i></a></li>" +
" <li><a class=\"btn-floating red remove-container\" title=\"delete this container\" container=\""+data[i].id+"\"><i class=\"material-icons\">delete_forever</i></a></li>" +
" <li><a class=\"btn-floating blue save-container\" title=\"Save this container\" container=\""+data[i].id+"\"><i class=\"material-icons\">save</i></a></li>" +
" <li><a class=\"btn-floating yellow stop-container\" title=\"Stop this container\" container=\""+data[i].id+"\"><i class=\"material-icons\">pan_tool</i></a></li>" +
" <li><a class=\"btn-floating green start-container\" title=\"Start this container\" container=\""+data[i].id+"\"><i class=\"material-icons\">autorenew</i></a></li>" +
" </ul>" +
"</div>");
str = "";
str = str + '<div><span>' + data[i].id + '</span>';
if (typeof data[i].port !== 'undefined' && data[i].port !== "") {
str = str + ' (:' + data[i].port + ')';
}
if (typeof data[i].info !== 'undefined') {
alt = "empty description";
if (typeof data[i].info['description'] !== 'undefined') {
alt = data[i].info['description'];
}
if (typeof data[i].info['name'] !== 'undefined') {
str = str + ' <span style=\"text-transform: uppercase;\" title=\"' + alt + '\">"' + data[i].info['name'] + '"</span>';
}
if (typeof data[i].info['version'] !== 'undefined') {
str = str + ' v:' + data[i].info['version'];
}
}
str = str + '</div>';
jQuery('#'+data[i].id).append(str);
if (typeof data[i].port != 'undefined' && data[i].port != "") {
jQuery('#'+data[i].id).append("<iframe src=\"http://localhost:" + data[i].port + "\"></iframe>");
}
}
});
}
// add new machine (use default settings)
function addNewMachine() {
var options = {
name: "test",
action: "create"
};
jQuery.getJSON('php/machines.php', options, function(data) {
// we should get back how to access the new system (id)
setTimeout( checkShell(data.id) , 2000);
});
}
function displayConsole() {
// if the console exists already delete it
if (jQuery('#console').length == 0) {
jQuery('body').append('<div id=\"console\" class=\"console\"><textarea rows=\"200\" cols=\"80\">loading ...</textarea></div>');
setInterval(function() {
// get the log file from /server/logs/machines.log
jQuery.get('server/logs/machines.log', function(data) {
jQuery('.console textarea').text( data );
});
}, 2000);
return;
}
jQuery('#console').remove();
}
jQuery(document).ready(function() {
jQuery('#console-start').on('click', function() {
displayConsole();
});
jQuery('select').material_select();
getListOfMachines();
jQuery('#add-machine').click(function() {
addNewMachine();
});
jQuery('#list-of-machines').on('click', '.stop-container', function() {
var id = jQuery(this).attr('container');
var options = { action: "stop", id: id };
jQuery.getJSON('php/machines.php', options, function(data) {});
jQuery('.fixed-action-btn').closeFAB();
});
jQuery('#list-of-machines').on('click', '.start-container', function() {
var id = jQuery(this).attr('container');
//var dialog = document.querySelector('#modal-start-container');
//if (!dialog.showModal) {
// dialogPolyfill.registerDialog(dialog);
//}
jQuery('#modal-start-container').attr('container', id);
jQuery('#modal-start-container').openModal();
jQuery('.fixed-action-btn').closeFAB();
});
jQuery('#start-container-start').click(function() {
var opt = jQuery('#start-container-start-option').val();
var id = jQuery('#modal-start-container').attr('container');
var options = { action: "start", id: id, opt: opt };
jQuery.getJSON('php/machines.php', options, function(data) {
checkShell( id );
});
//jQuery(this).parent().parent().closeModal();
jQuery('.fixed-action-btn').closeFAB();
});
jQuery('#list-of-machines').on('click', '.save-container', function() {
var id = jQuery(this).attr('container');
var options = { action: "save", id: id };
jQuery.getJSON('php/machines.php', options, function(data) {});
jQuery('.fixed-action-btn').closeFAB();
});
jQuery('#list-of-machines').on('click', '.remove-container', function() {
var id = jQuery(this).attr('container');
var options = { action: "delete", id: id };
jQuery.getJSON('php/machines.php', options, function(data) {});
});
jQuery('#dialog-about-button').click(function() {
//var dialog = document.querySelector('#modal-about');
//if (!dialog.openModal) {
// dialogPolyfill.registerDialog(dialog);
//}
//dialog.openModal();
jQuery('#modal-about').openModal();
});
//jQuery('.close-dialog').click(function() {
// jQuery(this).parent().parent().closeModal();
// jQuery('._dialog_overlay').remove();
//});
});
</script>
</body>
</html>