Skip to content

Commit 86b43b1

Browse files
committed
add demo of basica violations; work on geneontology/minerva#212
1 parent 288ffb3 commit 86b43b1

File tree

4 files changed

+114
-12
lines changed

4 files changed

+114
-12
lines changed

css/NoctuaEditor.css

+43-6
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ a:active {
143143
}
144144

145145
.menu, #render, #explanation {
146-
background-color:#fff;
146+
background-color:#fff;
147147
}
148148

149149
.menu {
@@ -173,7 +173,7 @@ a:active {
173173
color:orange !important;
174174
}
175175

176-
.window, .demo-window, .label {
176+
.window, .demo-window, .label {
177177
text-align: center;
178178
z-index: 24;
179179
cursor: grab;
@@ -385,6 +385,43 @@ path, ._jsPlumb_endpoint { cursor: pointer; }
385385
box-shadow: 0px 0px 6px black;
386386
}
387387

388+
/* open violation button */
389+
.open-violation-dialog {
390+
position: absolute;
391+
bottom: 37%;
392+
top: 5px;
393+
left: 25px;
394+
width: 1em;
395+
height: 1em;
396+
background-color: #ee0000;
397+
cursor: zoom-in;
398+
box-shadow: 0px 0px 2px black;
399+
-webkit-transition:-webkit-box-shadow 0.25s ease-in;
400+
-moz-transition:-moz-box-shadow 0.25s ease-in;
401+
transition:box-shadow 0.25s ease-in;
402+
padding: 0 0; /* override bootstrap 3 padding for compaction */
403+
}
404+
.open-violation-dialog:hover {
405+
box-shadow: 0px 0px 6px black;
406+
}
407+
408+
/* open violation button, edge version (different mechanisms in jsplumb) */
409+
.open-violation-dialog-edge {
410+
width: 1em;
411+
height: 1em;
412+
background-color: #ee0000;
413+
cursor: zoom-in;
414+
box-shadow: 0px 0px 2px black;
415+
-webkit-transition:-webkit-box-shadow 0.25s ease-in;
416+
-moz-transition:-moz-box-shadow 0.25s ease-in;
417+
transition:box-shadow 0.25s ease-in;
418+
padding: 0 0; /* override bootstrap 3 padding for compaction */
419+
margin-bottom: 2px; /* looks a little better in FF */
420+
}
421+
.open-violation-dialog-edge:hover {
422+
box-shadow: 0px 0px 6px black;
423+
}
424+
388425
.mme-type-table {
389426
margin-bottom: 5px;
390427
}
@@ -436,7 +473,7 @@ path, ._jsPlumb_endpoint { cursor: pointer; }
436473
-moz-border-radius: 10px/10px;
437474
-webkit-border-radius: 10px 10px;
438475
border-radius: 10px/10px;;
439-
border:solid 3px #FF0000;
476+
border:solid 3px #FF0000;
440477
width:10px;
441478
height:10px;
442479
opacity: 0.5;
@@ -504,7 +541,7 @@ path, ._jsPlumb_endpoint { cursor: pointer; }
504541
.aLabel {
505542
background-color: white;
506543
opacity: 0.8;
507-
padding: 0.3em;
544+
padding: 0.3em;
508545
border-radius: 0.5em;
509546
border: 1px solid #346789;
510547
cursor: pointer;
@@ -556,8 +593,8 @@ path, ._jsPlumb_endpoint { cursor: pointer; }
556593
}
557594

558595
/*
559-
* BBOP MME
560-
*/
596+
* BBOP MME
597+
*/
561598
.bbop-mme-more-results-ul {
562599
border-bottom: 3px dotted;
563600
}

js/NoctuaEditor.js

+45-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ var notify_github = require('toastr'); // notifications
7272
// And the layouts!
7373
var layout_engine = require('bbop-layout');
7474

75+
// Some render support.
76+
var pretty = require('js-object-pretty-print').pretty;
77+
7578
// Aliases.
7679
var each = us.each;
7780
var noctua_graph = model.graph;
@@ -706,6 +709,42 @@ var MMEnvInit = function(model_json, in_relations, in_token){
706709
});
707710
}
708711

712+
function _attach_node_click_violation_view(sel){
713+
714+
// Add this event to whatever we got called in.
715+
jQuery(sel).unbind('click');
716+
jQuery(sel).click(
717+
function(evnt){
718+
evnt.stopPropagation();
719+
720+
// Resolve the event into the edit core node.
721+
var target_elt = jQuery(evnt.target);
722+
var parent_elt = target_elt.parent();
723+
var parent_id = parent_elt.attr('id');
724+
var enode = ecore.get_node_by_elt_id(parent_id);
725+
if( ! enode ){
726+
alert('Could not find related violation element.');
727+
}else{
728+
729+
var violation_renderings = [];
730+
var violations = ecore.get_violations_by_id(enode.id());
731+
each(violations, function(v){
732+
if( v.explanations().length === 0 ){
733+
violation_renderings.push(
734+
'[No explanation available.]');
735+
}else{
736+
violation_renderings.push(
737+
pretty(v.explanations(), '3', 'HTML'));
738+
}
739+
});
740+
var vvm = new widgetry.contained_modal(
741+
null, 'Violations',
742+
violation_renderings.join(' <hr /> '));
743+
vvm.show();
744+
}
745+
});
746+
}
747+
709748
// Delete all UI connections associated with node. This also
710749
// triggers the "connectionDetached" event, so the edges are being
711750
// removed from the model at the same time.
@@ -1061,9 +1100,12 @@ var MMEnvInit = function(model_json, in_relations, in_token){
10611100
// Make nodes able to use edit dialog.
10621101
_attach_node_click_edit('.open-dialog');
10631102

1064-
// // Make nodes able to clone themselves.
1103+
// Make nodes able to clone themselves.
10651104
_attach_node_click_annotation_edit('.open-annotation-dialog');
10661105

1106+
// Make nodes able to clone themselves.
1107+
_attach_node_click_violation_view('.open-violation-dialog');
1108+
10671109
// Make normal nodes availables as edge targets.
10681110
_make_selector_target('.demo-window');
10691111

@@ -1094,6 +1136,7 @@ var MMEnvInit = function(model_json, in_relations, in_token){
10941136
//
10951137
each(['.open-dialog',
10961138
'.open-annotation-dialog',
1139+
'.open-violations-dialog',
10971140
'.open-annotation-dialog-edge'], function(cls){
10981141
jQuery(cls).addClass('hidden');
10991142
});
@@ -1108,6 +1151,7 @@ var MMEnvInit = function(model_json, in_relations, in_token){
11081151
//
11091152
each(['.open-dialog',
11101153
'.open-annotation-dialog',
1154+
'.open-violations-dialog',
11111155
'.open-annotation-dialog-edge'], function(cls){
11121156
jQuery(cls).removeClass('hidden');
11131157
});

js/lib/noctua-widgetry/widgetry.js

+23-3
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,10 @@ function enode_types_to_ordered_stack(enode_types, aid){
306306
*
307307
* This whole bit will change a lot with new evidence coming down the
308308
* pipe.
309+
*
310+
* ecore is used to detect graph violations.
309311
*/
310-
function node_stack_object(enode, aid){
312+
function node_stack_object(enode, aid, ecore){
311313

312314
var hook_list = [];
313315

@@ -503,7 +505,7 @@ function add_enode(annotation_config, ecore, manager, enode, aid, graph_div, lef
503505
'class': 'demo-window',
504506
'style': style_str});
505507

506-
var enode_stack_table = new node_stack_object(enode, aid);
508+
var enode_stack_table = new node_stack_object(enode, aid, ecore);
507509
w.add_to(enode_stack_table.to_string());
508510

509511
// Box to drag new connections from.
@@ -523,6 +525,15 @@ function add_enode(annotation_config, ecore, manager, enode, aid, graph_div, lef
523525
'title': 'Open annotation dialog'});
524526
w.add_to(openann);
525527

528+
// Box to open violation dialog, if exist.
529+
if( ecore.get_violations_by_id(enode.id()).length > 0 ){
530+
var openvio = new bbop.html.tag('button',
531+
{'class':
532+
'open-violation-dialog btn btn-default',
533+
'title': 'Open violation dialog'});
534+
w.add_to(openvio);
535+
}
536+
526537
// Add to display.
527538
jQuery(graph_div).append(w.to_string());
528539

@@ -549,7 +560,7 @@ function update_enode(ecore, enode, aid){
549560
var uelt = ecore.get_node_elt_id(enode.id());
550561
jQuery('#' + uelt).empty();
551562

552-
var enode_stack_table = new node_stack_object(enode, aid);
563+
var enode_stack_table = new node_stack_object(enode, aid, ecore);
553564
jQuery('#' + uelt).append(enode_stack_table.to_string());
554565

555566
// Box to drag new connections from.
@@ -568,6 +579,15 @@ function update_enode(ecore, enode, aid){
568579
'open-annotation-dialog btn btn-default',
569580
'title': 'Open annotation dialog'});
570581
jQuery('#' + uelt).append(openann.to_string());
582+
583+
// Box to open violation dialog, if exist.
584+
if( ecore.get_violations_by_id(enode.id()).length > 0 ){
585+
var openvio = new bbop.html.tag('button',
586+
{'class':
587+
'open-violation-dialog btn btn-default',
588+
'title': 'Open violation dialog'});
589+
jQuery('#' + uelt).append(openvio.to_string());
590+
}
571591
}
572592

573593
/**

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@
4343
"bbop-client-barista": "0.0.7",
4444
"bbop-core": "0.0.5",
4545
"bbop-graph": "0.0.19",
46-
"bbop-graph-noctua": "0.0.32",
46+
"bbop-graph-noctua": "0.0.33",
4747
"bbop-layout": "0.0.4",
4848
"bbop-manager-golr": "0.0.11",
4949
"bbop-manager-minerva": "0.0.15",
5050
"bbop-manager-sparql": "0.0.5",
51-
"bbop-response-barista": "0.0.10",
51+
"bbop-response-barista": "0.0.11",
5252
"bbop-response-golr": "0.0.6",
5353
"bbop-rest-manager": "0.0.16",
5454
"bbop-rest-response": "0.0.4",
@@ -71,6 +71,7 @@
7171
"gulp-shell": "0.5.2",
7272
"http-proxy": "1.14.0",
7373
"jquery": "^2.2.4",
74+
"js-object-pretty-print": "0.3.0",
7475
"markdown": "0.5.0",
7576
"mime": "1.3.4",
7677
"minerva-requests": "0.0.17",

0 commit comments

Comments
 (0)