Skip to content

Commit bf640c0

Browse files
authored
Merge pull request #326 from TextDB/jimmy-ui-resultbox
[Issue #246] GUI: Show returned JSON results using third-party pretty-json javascript library
2 parents 2996344 + fce94bd commit bf640c0

10 files changed

Lines changed: 218 additions & 20 deletions

File tree

‎textdb/textdb-gui/css/style.css‎

Lines changed: 69 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ body {
2525
overflow: auto;
2626
}
2727

28-
/* Each Operator Selector */
28+
/* Each Operator Selector */
2929
.menu li {
3030
border-bottom: 1px solid #636366;
3131
border-left: 3px solid transparent;
@@ -46,13 +46,14 @@ body {
4646
cursor: default;
4747
}
4848

49-
/* The X that closes the menu */
49+
/* The X that closes the menu */
5050
.icon-close {
5151
cursor: pointer;
5252
padding: 10px;
5353
padding-bottom: 14px;
5454
}
55-
/* The Dropdown Panel after selecting an operator from menu */
55+
56+
/* The Dropdown Panel after selecting an operator from menu */
5657
.panel{
5758
color: #fff;
5859
font-size: 16px;
@@ -105,7 +106,8 @@ button{
105106
color: white;
106107
font-weight: bold;
107108
}
108-
/* menu, delete, and process operators (grouped) */
109+
110+
/* menu, delete, and process operators (grouped) */
109111
.nav div {
110112
border: 1px solid #636366;
111113
cursor: pointer;
@@ -148,8 +150,8 @@ button{
148150
border: 1px solid black;
149151
}
150152

151-
/* Closes the Attributes Box when clicked */
152-
.band{
153+
/* Closes the Attributes Box when clicked */
154+
.attributes-band{
153155
height: 20px;
154156
border-bottom: 1px solid black;
155157
padding: 11px;
@@ -167,8 +169,68 @@ button{
167169
white-space: pre-wrap;
168170
line-height: 1.5;
169171
}
170-
/* The edit/confirm/cancel buttons */
172+
173+
/* The edit/confirm/cancel buttons */
171174
#attributes button{
172175
margin: 5px;
173176
border: 1px solid black;
174177
}
178+
179+
/* Result Frame and Result Box after processing query */
180+
.result-frame{
181+
top: 0;
182+
left: 0;
183+
height: 100%;
184+
width: 100%;
185+
background-color: black;
186+
position: fixed;
187+
}
188+
189+
.result-box{
190+
top: 2%;
191+
left: 1%;
192+
bottom: 2%;
193+
right: 30px;
194+
height: 96%;
195+
font-family: 'Open Sans', sans-serif;
196+
font-size: 16px;
197+
line-height: 1.5;
198+
background-color: white;
199+
position: fixed;
200+
}
201+
202+
/* .result-box div{
203+
display: block;
204+
} */
205+
206+
.result-box-band{
207+
padding: 11px;
208+
height: 50px;
209+
font-size: 22px;
210+
border-bottom: 1px solid black;
211+
background: #202024 url('../img/black-thread.png') repeat left top;
212+
color: #fff;
213+
cursor: pointer;
214+
}
215+
216+
.result-frame-close {
217+
padding: 0px;
218+
cursor: pointer;
219+
float: right;
220+
/* padding: 10px;
221+
padding-bottom: 14px; */
222+
}
223+
224+
.return-result{
225+
padding: 11px;
226+
top: 73px;
227+
left: 0px;
228+
bottom: 11px;
229+
width: 100%;
230+
font-family: 'Open Sans', sans-serif;
231+
font-size: 16px;
232+
line-height: 1.5;
233+
position: absolute;
234+
white-space: preline;
235+
overflow: auto;
236+
}

‎textdb/textdb-gui/index.html‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@
55

66
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
77
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
8-
<script type="text/javascript" src="thirdparty/textdb.flowchart.js"></script>
8+
<script type="text/javascript" src="thirdparty/pretty-json/underscore-min.js" ></script>
9+
<script type="text/javascript" src="thirdparty/pretty-json/backbone-min.js" ></script>
10+
11+
<script type="text/javascript" src="thirdparty/pretty-json/pretty-json-min.js"></script>
12+
<script type="text/javascript" src="thirdparty/flowchart-js/textdb.flowchart.js"></script>
913
<script type="text/javascript" src="js/app.js"></script>
1014

11-
<link href='thirdparty/flowchart.css' rel='stylesheet'>
15+
<link href='thirdparty/pretty-json/pretty-json.css' rel='stylesheet'>
16+
<link href='thirdparty/flowchart-js/flowchart.css' rel='stylesheet'>
1217
<link href='css/style.css' rel='stylesheet'>
1318

1419

@@ -200,7 +205,7 @@
200205
</div>
201206

202207
<div class="popup">
203-
<div class="band">Attributes</div>
208+
<div class="attributes-band">Attributes</div>
204209
<div id="attributes" class="popup-panel"></div>
205210
</div>
206211

‎textdb/textdb-gui/js/app.js‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ var closeMenu = function(){
3131
}, 200);
3232
};
3333

34+
var closeResultFrame = function(closeButton){
35+
$(closeButton).parent().parent().parent().remove();
36+
};
37+
3438
var closeBand = function(){
3539
$('.popup').animate({
3640
'bottom': '-570px'
@@ -56,8 +60,12 @@ var main = function(){
5660

5761
$('.icon-close').click(closeMenu);
5862

59-
$('.band').on('click', closeBand);
60-
63+
$('body').on('click', '.result-frame .result-box .result-box-band .result-frame-close', function() {
64+
closeResultFrame(this);
65+
});
66+
67+
$('.attributes-band').on('click', closeBand);
68+
6169
$('.menu ul li').on('click', function(){
6270
selectPanel(this);
6371
});

‎textdb/textdb-gui/js/onstart.js‎

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ var setup = function(){
3636
/*
3737
Helper Functions
3838
*/
39+
//Helper Function for Process Queries that displays the results after hitting "Process Query"
40+
function createResultFrame(message){
41+
var resultFrame = $('<div class="result-frame"><div class="result-box"><div class="result-box-band">Return Result<div class="result-frame-close"><img src="img/close-icon.png"></div></div><div class="return-result"></div></div></div>');
42+
$('body').append(resultFrame);
43+
44+
var node = new PrettyJSON.view.Node({
45+
el:$('.return-result'),
46+
data:message
47+
});
48+
}
3949

4050
//Create Operator Helper Function
4151
function getExtraOperators(userInput, panel){
@@ -53,7 +63,6 @@ var setup = function(){
5363
}
5464
extraOperators['keyword'] = userInput;
5565
extraOperators['matching_type'] = $('#' + panel + ' .matching-type').val();
56-
5766
}
5867
else if (panel == 'dictionary-panel'){
5968
if (userInput == null || userInput == ''){
@@ -233,6 +242,49 @@ var setup = function(){
233242
var operators = [];
234243
var links = [];
235244

245+
var DUMMYJSON = {
246+
glossary: {
247+
title: 'example glossary',
248+
GlossDiv: {
249+
title: 'S',
250+
GlossList: {
251+
GlossEntry: {
252+
ID: 'SGML',
253+
SortAs: 'SGML',
254+
GlossTerm: 'Standard Generalized Markup Language',
255+
Acronym: 'SGML',
256+
Abbrev: 'ISO 8879:1986',
257+
GlossDef: {
258+
para: 'A meta-markup language, used to create markup languages such as DocBook.',
259+
GlossSeeAlso: ['GML', 'XML']
260+
},
261+
GlossSee: 'markup'
262+
}
263+
}
264+
}
265+
},
266+
glossary2: {
267+
title: 'example glossary',
268+
GlossDiv: {
269+
title: 'S',
270+
GlossList: {
271+
GlossEntry: {
272+
ID: 'SGML',
273+
SortAs: 'SGML',
274+
GlossTerm: 'Standard Generalized Markup Language',
275+
Acronym: 'SGML',
276+
Abbrev: 'ISO 8879:1986',
277+
GlossDef: {
278+
para: 'A meta-markup language, used to create markup languages such as DocBook.',
279+
GlossSeeAlso: ['GML', 'XML']
280+
},
281+
GlossSee: 'markup'
282+
}
283+
}
284+
}
285+
}
286+
}
287+
236288
for(var operatorIndex in GUIJSON.operators){
237289
var currentOperator = GUIJSON['operators']
238290
if (currentOperator.hasOwnProperty(operatorIndex)){
@@ -257,9 +309,6 @@ var setup = function(){
257309
}
258310
TEXTDBJSON.operators = operators;
259311
TEXTDBJSON.links = links;
260-
261-
// console.log(JSON.stringify(TEXTDBJSON));
262-
// console.log(JSON.stringify(GUIJSON));
263312

264313
$.ajax({
265314
url: "http://localhost:8080/queryplan/execute",
@@ -270,9 +319,12 @@ var setup = function(){
270319
success: function(returnedData){
271320
console.log("SUCCESS\n");
272321
console.log(JSON.stringify(returnedData));
322+
createResultFrame(returnedData);
273323
},
274324
error: function(xhr, status, err){
275-
console.log("ERROR");
325+
console.log(JSON.stringify(xhr));
326+
console.log(JSON.stringify(err));
327+
createResultFrame(DUMMYJSON);
276328
}
277329
});
278330
};
@@ -300,7 +352,7 @@ var setup = function(){
300352
var deleteButton = $('<button class="delete-operator">Delete</button>');
301353
$('#attributes').append(deleteButton);
302354

303-
$('.band').html('Attributes for <em>' + title + '</em>');
355+
$('.attributes-band').html('Attributes for <em>' + title + '</em>');
304356
};
305357

306358
//Create Operator to send to flowchart.js and display on flowchart
@@ -418,7 +470,7 @@ var setup = function(){
418470
output = data['operators'][selectedOperator]['properties']['attributes'];
419471

420472
var title = data['operators'][selectedOperator]['properties']['title'];
421-
$('.band').html('Attributes for <em>' + title + '</em>');
473+
$('.attributes-band').html('Attributes for <em>' + title + '</em>');
422474

423475
$('#attributes').text(getPopupText(output));
424476
$('#attributes').html($('#attributes').text());
@@ -437,7 +489,7 @@ var setup = function(){
437489
'visibility': 'hidden'
438490
});
439491

440-
$('.band').text('Attributes');
492+
$('.attributes-band').text('Attributes');
441493

442494
$('#the-flowchart').flowchart('deleteSelected');
443495
data = $('#the-flowchart').flowchart('getData');
File renamed without changes.

textdb/textdb-gui/thirdparty/textdb.flowchart.js renamed to textdb/textdb-gui/thirdparty/flowchart-js/textdb.flowchart.js

File renamed without changes.

‎textdb/textdb-gui/thirdparty/pretty-json/backbone-min.js‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎textdb/textdb-gui/thirdparty/pretty-json/pretty-json-min.js‎

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/* common */
2+
.mark-water{
3+
color:#bbb;
4+
}
5+
/* eof common */
6+
7+
/* node */
8+
.node-content-wrapper{
9+
font-family: 'Quicksand', sans-serif;
10+
background-color:#fff;
11+
}
12+
.node-content-wrapper ul{
13+
border-left:1px dotted #ccc;
14+
list-style:none;
15+
padding-left:25px;
16+
margin:0px;
17+
}
18+
.node-content-wrapper ul li{
19+
list-style:none;
20+
border-bottom:0;
21+
padding-bottom:0
22+
}
23+
.node-hgl-path{
24+
background-color:#fefbdf;
25+
}
26+
.node-bracket{
27+
font-weight:bold;
28+
display:inline-block;
29+
cursor:pointer;
30+
}
31+
.node-bracket:hover{
32+
color:#999;
33+
}
34+
/* eof node */
35+
36+
/* leaf */
37+
.leaft-container{
38+
width:100%;
39+
max-width:300px;
40+
height:100%;
41+
}
42+
43+
.title{ color:#ccc;}
44+
.string{ color:#080;}
45+
.number{ color:#ccaa00;}
46+
.boolean{ color:#1979d3;}
47+
.date{ color:#aa6655;}
48+
.null{ color:#ff5050;}
49+
/* eof leaf */

0 commit comments

Comments
 (0)