or
model: {
id: "SID",
fields: {
//kuiRecordKey: { type: "number", editable: false, nullable: true },
SID: { type: "number", editable: true, nullable: false },
Name: { validation: { required: true, maxlength: 50 }, type: "string" },
Second: { type: "number", validation: { required: false, min: 0, max: 1 } },
Third: { type: "number", validation: { required: false, min: 0, max: 1 } }
}
(kuiRecordKey
- commented in the code above) and POST it so my processing logic would pick it up and use it accordingly.
$(document).ready(
function
() {
// Populate arrays for the menu items
var
Qdata = [{
"title"
:
"query 3"
,
"description"
:
"Return a graph of source and destination IPs limited to 5000"
},{
"title"
:
"query 4"
,
"description"
:
"Show list of all predicates and counts of each"
},{
"title"
:
"query 5"
,
"description"
:
"Show ontology"
},{
"title"
:
"query 1"
,
"description"
:
"DNS relationships 1000"
},{
"title"
:
"query 6"
,
"description"
:
"return first 500"
},{
"title"
:
"query 6"
,
"description"
:
"return first 500"
}];
var
Edata = [{
"ep"
:
"discover"
,
"title"
:
"discover"
},{
"ep"
:
"sc1"
,
"title"
:
"sc1"
},{
"ep"
:
"marple"
,
"title"
:
"marple"
}];
var
JSO;
// Dropdown menu for the queries
$(
"#query-picker"
).kendoDropDownList({
optionLabel:
"Queries"
,
dataTextField:
"description"
,
dataValueField:
"title"
,
dataSource: Qdata,
index: 0,
enable:
false
,
change: onChangeQ
});
// Dropdown menu for the endpoints
$(
"#endpoint-picker"
).kendoDropDownList({
optionLabel:
"Endpoints"
,
dataTextField:
"title"
,
dataValueField:
"ep"
,
dataSource: Edata,
index: 0,
change: onChangeE
});
// OnChange event for endpoint dropdown
var
epval;
function
onChangeE() {
ddlist=$(
"#query-picker"
).data(
"kendoDropDownList"
);
ddlist.enable(
true
);
epval=$(
"#endpoint-picker"
).data(
"kendoDropDownList"
);
};
// OnChange event for query dropdown
function
onChangeQ() {
var
qval=$(
"#query-picker"
).data(
"kendoDropDownList"
);
$.getJSON(
'./query?ep='
+ epval.value() +
'&qry='
+ qval.value(),
function
(JSO) {
$(
"#graph-container"
).empty();
var
sigInst = sigma.init(document.getElementById(
'graph-container'
)).drawingProperties({
defaultLabelColor:
'#fff'
,
defaultLabelSize: 14,
defaultLabelBGColor:
'#fff'
,
defaultLabelHoverColor:
'#000'
,
labelThreshold: 6,
defaultEdgeType:
'curve'
}).graphProperties({
minNodeSize: 1,
maxNodeSize: 10,
minEdgeSize: 1,
maxEdgeSize: 1
}).mouseProperties({
maxRatio: 32
});
$.each(JSO.data.results.graph.nodes,
function
(idx,obj) {
sigInst.addNode(obj.index,{
'color'
:
'#E68A00'
,
'x'
:Math.random(),
'y'
:Math.random(),
'size'
: obj.degree,
'shape'
:
'circle'
,
'label'
: obj.label,
'degree'
: obj.degree});
});
$.each(JSO.data.results.graph.edges,
function
(idx,obj) {
sigInst.addEdge(obj.index, obj.source, obj.target, {
'label'
: obj.label});
});
sigInst.draw();
var
kdata=JSON.stringify(JSO.data.results.triples);
alert(kdata);
$(
"#main-body-TR"
).kendoGrid({
dataSource: {
data: JSO.data.results.triples,
schema: {
model: {
fields: {
s: { type:
"string"
},
p: { type:
"string"
},
o: { type:
"string"
}
}
}
}
},
scrollable:
true
,
sortable:
true
,
filterable:
true
,
pageable: {
input:
true
,
numeric:
false
},
columns: [
{
field:
"s"
,
title:
"Subject"
},
{
field:
"p"
,
title:
"Predicte"
},
{
field:
"o"
,
title:
"Object"
}
]
});
var
isRunning =
false
;
document.getElementById(
'stop-layout'
).addEventListener(
'click'
,
function
(){
if
(isRunning){
isRunning =
false
;
sigInst.stopForceAtlas2();
document.getElementById(
'stop-layout'
).childNodes[0].nodeValue =
'Start Layout'
;
}
else
{
isRunning =
true
;
sigInst.startForceAtlas2();
document.getElementById(
'stop-layout'
).childNodes[0].nodeValue =
'Stop Layout'
;
}
},
true
);
document.getElementById(
'rescale-graph'
).addEventListener(
'click'
,
function
(){
sigInst.position(0,0,1).draw();
},
true
);
var
greyColor =
'rgba(180,180,180,0.3)'
;
sigInst.bind(
'overnodes'
,
function
(event){
var
nodes = event.content;
var
neighbors = {};
sigInst.iterEdges(
function
(e){
if
(nodes.indexOf(e.source)<0 && nodes.indexOf(e.target)<0){
if
(!e.attr[
'grey'
]){
e.attr[
'true_color'
] = e.color;
e.color = greyColor;
e.attr[
'grey'
] = 1;
}
}
else
{
e.color = e.attr[
'grey'
] ? e.attr[
'true_color'
] : e.color;
e.attr[
'grey'
] = 0;
neighbors[e.source] = 1;
neighbors[e.target] = 1;
}
}).iterNodes(
function
(n){
if
(!neighbors[n.id]){
if
(!n.attr[
'grey'
]){
n.attr[
'true_color'
] = n.color;
n.color = greyColor;
n.attr[
'grey'
] = 1;
}
}
else
{
n.color = n.attr[
'grey'
] ? n.attr[
'true_color'
] : n.color;
n.attr[
'grey'
] = 0;
}
}).draw(2,2,2);
}).bind(
'outnodes'
,
function
(){
sigInst.iterEdges(
function
(e){
e.color = e.attr[
'grey'
] ? e.attr[
'true_color'
] : e.color;
e.attr[
'grey'
] = 0;
}).iterNodes(
function
(n){
n.color = n.attr[
'grey'
] ? n.attr[
'true_color'
] : n.color;
n.attr[
'grey'
] = 0;
}).draw(2,2,2);
});
});
};
$(
"body"
).on({
ajaxStart:
function
() {
$(
"#loading-query"
).removeAttr(
'style'
);
},
ajaxStop:
function
() {
$(
"#loading-query"
).css(
'display'
,
'none'
);
}
});
});