-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
399 lines (367 loc) · 16.4 KB
/
index.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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Snactor UI</title>
<link rel="stylesheet" href="css/patternfly.min.css" />
<link rel="stylesheet" href="css/patternfly-additions.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/css/bootstrap-select.min.css">
<script src="https://code.jquery.com/jquery-3.2.1.min.js" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" crossorigin="anonymous"></script>
<script src="js/patternfly.min.js"></script>
<script src="js/patternfly-functions-navigation.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/bootstrap-select.min.js"></script>
</head>
<body>
<header>
<nav class="navbar navbar-default navbar-pf" role="navigation">
<div class="navbar-header">
<a class="navbar-brand" href="#" style="margin: 0">
<img src="img/brand.svg" alt="Snactor UI" />
</a>
</div>
<div class="collapse navbar-collapse navbar-collapse-1">
<ul class="nav navbar-nav navbar-utility">
<li class="dropdown">
<a class="nav-item-iconic" id="horizontalDropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span title="Help" class="fa pficon-help"></span>
<span class="caret"></span>
</a>
<ul class="dropdown-menu" aria-labelledby="horizontalDropdownMenu1">
<li><a href="#">Help</a></li>
<li><a href="#">About</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-primary">
<li class="active">
<a href="#actors">Actors</a>
</li>
<li>
<a href="#">Schemas</a>
</li>
</ul>
</div>
</nav>
</header>
<div class="container-fluid" id="toolbox">
<div class="row toolbar-pf">
<div class="col-sm-12">
<form class="toolbar-pf-actions">
<div class="form-group toolbar-pf-filter">
<label class="sr-only" for="filter">Name</label>
<div class="input-group">
<div class="input-group-btn">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Name <span class="caret"></span></button>
<ul class="dropdown-menu">
<li class="selected"><a href="#">Name</a></li>
<li><a href="#">Inputs</a></li>
<li><a href="#">Outputs</a></li>
<li><a href="#">Description</a></li>
</ul>
</div>
<!-- /btn-group -->
<input type="text" class="form-control" id="filter" placeholder="Filter By Name...">
</div>
<!-- /input-group -->
</div>
<div class="toolbar-pf-action-right">
<div class="form-group toolbar-pf-find">
<button class="btn btn-link btn-find" type="button">
<span class="fa fa-search"></span>
</button>
<div class="find-pf-dropdown-container">
<input type="text" class="form-control" id="find" placeholder="Find By Keyword...">
<div class="find-pf-buttons">
<span class="find-pf-nums">1 of 3</span>
<button class="btn btn-link" type="button">
<span class="fa fa-angle-up"></span>
</button>
<button class="btn btn-link" type="button">
<span class="fa fa-angle-down"></span>
</button>
<button class="btn btn-link btn-find-close" type="button">
<span class="pficon pficon-close"></span>
</button>
</div>
</div>
</div>
<div class="form-group toolbar-pf-view-selector">
<button class="btn btn-link "><i class="fa fa-th"></i></button>
<button class="btn btn-link "><i class="fa fa-th-large"></i></button>
<button class="btn btn-link "><i class="fa fa-th-list"></i></button>
</div>
</div>
</form>
<div class="row toolbar-pf-results">
<div class="col-sm-12">
<h5><span id="page-title">Actors</span>: <span id="page-extents" class="text-muted">1-10 / 35</span></h5>
</div>
<!-- /col -->
</div>
<!-- /row -->
</div>
<!-- /col -->
</div>
<!-- /row -->
</div>
<!-- /container -->
<div class="container-fluid">
<div class="list-group list-view-pf" id="main-list">
</div>
<form class="content-view-pf-pagination clearfix" id="pagination1">
<div class="form-group">
<select class="selectpicker pagination-pf-pagesize" disabled>
<option value="10" selected>10</option>
<option value="25">25</option>
<option value="50">50</option>
</select>
<span>per page</span>
</div>
<div class="form-group" style="align-items:center">
<span><span class="pagination-pf-items-current"></span> of <span class="pagination-pf-items-total"></span></span>
<ul class="pagination pagination-pf-back">
<li class="disabled"><a href="#" id="pagination-first" title="First Page"><span class="i fa fa-angle-double-left"></span></a></li>
<li class="disabled"><a href="#" id="pagination-prev" title="Previous Page"><span class="i fa fa-angle-left"></span></a></li>
</ul>
<label for="pagination1-page" class="sr-only">Current Page</label>
<input class="pagination-pf-page" type="text" value="1" id="pagination1-page"/>
<span>of <span class="pagination-pf-pages">5</span></span>
<ul class="pagination pagination-pf-forward">
<li><a href="#" id="pagination-next" title="Next Page"><span class="i fa fa-angle-right"></span></a></li>
<li><a href="#" id="pagination-last" title="Last Page"><span class="i fa fa-angle-double-right"></span></a></li>
</ul>
</div>
</form>
</div>
<script src="data.json"></script>
<script>
if (!String.prototype.format) {
String.prototype.format = function() {
var args = arguments;
return this.replace(/{(\d+)}/g, function(match, number) {
return typeof args[number] != 'undefined'
? args[number]
: match;
});
};
}
let item_data = `
<div class="list-group-item list-view-pf-stacked list-view-pf-top-align">
<div class="list-view-pf-checkbox">
<input type="checkbox">
</div>
<div class="list-view-pf-main-info" style="cursor:pointer" onclick="document.location.hash='#actor_{0}'">
<div class="list-view-pf-body">
<div class="list-view-pf-description">
<div class="list-group-item-heading">
{0}
</div>
<div class="list-group-item-text">
{1}
</div>
</div>
<div class="list-view-pf-additional-info">
<div class="list-view-pf-additional-info-item">
<span class="fa fa-angle-down"></span>
<a href="#"><strong>{2}</strong> inputs</a>
</div>
<div class="list-view-pf-additional-info-item">
<span class="fa fa-angle-up"></span>
<a href="#"><strong>{3}</strong> output</a>
</div>
</div>
</div>
</div>
</div>`
let show_actor = `
<div class="list-group-item container-fluid">
<div class="row">
<div class="col-md-3">
INPUTS:
<ul>
{0}
</ul>
</div>
<div class="col-md-3">
OUTPUTS:
<ul>
{1}
</ul>
</div>
<div class="col-md-6">
<dl class="dl-horizontal">
<dt>Actor Name</dt>
<dd>{2}</dd>
<dt>Tags</dt>
<dd>{3}</dd>
</dl>
<p>
{4}
</p>
</div>
</div>
<div class="list-view-pf-actions">
<button class="btn btn-default" onclick="history.go(-1);">Back</button>
</div>
</div>
`
let sane_split = function(str, sep, num) {
const separated = str.split(sep);
let base = separated.slice(0, num);
base.push(separated.slice(num, separated.length).join(sep));
return base;
};
let url_router = function() {
const route = sane_split(document.location.hash.substring(1), "_", 1);
switch (route[0]) {
case "actors":
const per_page = 10;
const num_actors = snactor_data.actors.length;
const num_pages = Math.max(1, Math.ceil(num_actors / per_page));
let index = 0;
$("#main-list > .list-group-item, iframe").remove();
$("#toolbox, #pagination1").show();
if (route.length > 1) {
index = (parseInt(route[1]) - 1) || 0;
}
const start = (index * per_page) + 1;
const end = Math.min((index + 1) * per_page - 1, num_actors - 1);
$('#page-extents').text('{0}-{1} / {2}'.format(start, end + 1, num_actors))
$('#pagination1-page').val((index + 1)+"");
$('.pagination-pf-items-current').text('{0}-{1}'.format(start, end + 1));
$('.pagination-pf-items-total').text(num_actors+"");
$('.pagination-pf-pages').text(num_pages+"");
if (index < 1) {
$('.pagination-pf-back > li').addClass('disabled');
$('.pagination-pf-back > li > a').attr('href', document.location.hash);
} else {
$('.pagination-pf-back > li').removeClass('disabled');
$('#pagination-prev').attr('href', "#actors_{0}".format(index));
}
if (index >= (num_pages - 1)) {
$('.pagination-pf-forward > li').addClass('disabled');
$('.pagination-pf-forward > li > a').attr('href', document.location.hash);
} else {
$('.pagination-pf-forward > li').removeClass('disabled');
$('#pagination-next').attr('href', "#actors_{0}".format(index + 2));
}
$(snactor_data.actors.slice(start - 1, end + 1)).each(
function() {
let inputs = this.inputs === undefined ? 0 : this.inputs.length;
let outputs = this.outputs === undefined ? 0 : this.outputs.length;
let description = this.description.split('\n')[0];
$('#main-list').append(
item_data.format(this.name, description, inputs, outputs)
);
}
);
break;
case "actor":
$("#main-list > .list-group-item, iframe").remove();
let actor = snactor_data.actors.find((f) => f.name == route[1]);
let inputs = "";
let outputs = "";
for (input of (actor.inputs || [])) {
inputs += '<li><a href="#schema_{1}">{0} -> {1}</a></li>'.format(input.name, input.type)
}
for (output of (actor.outputs || [])) {
outputs += '<li><a href="#schema_{1}">{0} -> {1}</a></li>'.format(output.name, output.type)
}
$("#main-list").append(show_actor.format(inputs, outputs, actor.name || "<unnamed>", actor.tags || "no tags", actor.description.split('\n')[0]));
$("#toolbox, #pagination1").hide()
break
case "schema":
$("#main-list > .list-group-item, iframe").remove();
$("#toolbox, #pagination1").hide();
let schema = snactor_data.schemas.find((f) => f.name == route[1]);
let props = schema.schema.properties;
$("#main-list").append(
`<div class="row"><div class="col-sm-4"><div class="h3" align="center">Schema Layout</div><iframe id='` + route[1] +`' style='padding: 0; border: 1px dashed; width: 600px; height: 600px; background: transparent' class='col-sm-4' src='https://lbovet.github.io/docson/index.html#data:text/json;base64,` + btoa(JSON.stringify(schema.schema)) + `'></iframe></div><div class="col-sm-6"><div class="h3">References</div></div></div>`
);
/*
for (prop of Object.keys(props)) {
console.log(prop, props[prop].type)
}
console.log(schema.name, schema.schema);
//console.log(route[1]);
*/
}
}
$(document).ready(function () {
window.addEventListener('hashchange', url_router);
url_router();
$('.selectpicker').selectpicker({
size: 5
});
// Row Checkbox Selection
$("input[type='checkbox']").change(function (e) {
if ($(this).is(":checked")) {
$(this).closest('.list-group-item').addClass("active");
} else {
$(this).closest('.list-group-item').removeClass("active");
}
});
// toggle dropdown menu
$('.list-view-pf-actions').on('show.bs.dropdown', function () {
var $this = $(this);
var $dropdown = $this.find('.dropdown');
var space = $(window).height() - $dropdown[0].getBoundingClientRect().top - $this.find('.dropdown-menu')
.outerHeight(true);
$dropdown.toggleClass('dropup', space < 10);
});
// allow users to select multiple list items with shift key
$('.list-group').on('click', '.list-view-pf-checkbox>input', function (event) {
var $list = $('.list-group');
var prevIndex = $list.data('preIndex');
var $listItems = $list.children('.list-group-item');
var $currentItem = $(this).closest('.list-group-item');
if (event.shiftKey && prevIndex > -1 && this.checked) {
var currentIndex = $listItems.index($currentItem);
var $selectScope = currentIndex - prevIndex > 0 ?
$currentItem.prevAll().not($listItems.eq(prevIndex).prevAll().addBack()) :
$listItems.eq(prevIndex).prevAll().not($currentItem.prevAll().addBack());
$selectScope.addClass('active').find('.list-view-pf-checkbox').children('input').prop('checked', true);
}
$list.data('preIndex', this.checked ? $listItems.index($currentItem) : -1);
});
$(".list-view-pf-expand").on("click", function () {
var $this = $(this);
var $heading = $(this).parents(".list-group-item");
//var $row = $heading.parent();
var $subPanels = $heading.find(".list-group-item-container");
var index = $heading.find(".list-view-pf-expand").index(this);
//Remove all active status
$heading.find(".list-view-pf-expand.active").find(".fa-angle-right").removeClass("fa-angle-down")
.end().removeClass("active")
.end().removeClass("list-view-pf-expand-active");
// Add active to the clicked item
$(this).addClass("active")
.parents(".list-group-item").addClass("list-view-pf-expand-active")
.end().find(".fa-angle-right").addClass("fa-angle-down");
// check if it needs to hide
if ($subPanels.eq(index).hasClass("hidden")) {
$heading.find(".list-group-item-container:visible").addClass("hidden");
$subPanels.eq(index).removeClass("hidden");
} else {
$subPanels.eq(index).addClass("hidden");
$heading.find(".list-view-pf-expand.active").find(".fa-angle-right").removeClass("fa-angle-down")
.end().removeClass("active")
.end().removeClass("list-view-pf-expand-active");
}
});
// click close button to close the panel
$(".list-group-item-container .close").on("click", function () {
var $this = $(this);
var $panel = $this.parent();
// close the container and remove the active status
$panel.addClass("hidden")
.parent().removeClass("list-view-pf-expand-active")
.find(".list-view-pf-expand.active").removeClass("active")
.find(".fa-angle-right").removeClass("fa-angle-down")
});
});
</script>
</body>
</html>