Commit 8ce38c6f authored by unknown's avatar unknown

Merge branch 'nicolas/feature' into maximilian/newGraph

parents 37594968 8689854f
......@@ -307,40 +307,46 @@
}
],
"fieldNames": {
"dateFields": ["isoStartDate", "isoEndDate"],
"geoLocalisation": "latLong"
},
"nodeTypes2": {
"date": {
"labelField": "startDate",
"color": "label",
"color": "#FF7F00",
"icon": ""
},
"regest": {
"labelField": "ident",
"color": "label",
"color": "#FF7F00",
"icon": ""
},
"event": {
"labelField": "label",
"color": "label",
"color": "#FF55FF",
"icon": ""
},
"person": {
"labelField": "label",
"color": "label",
"color": "#FF0000",
"icon": ""
},
"place": {
"labelField": "normalizedGerman",
"color": "label",
"color": "#BB7000",
"icon": ""
},
"indPlace": {
"labelField": "label",
"color": "label",
"color": "#BB7000",
"icon": ""
},
"lemma": {
"labelField": "lemma",
"color": "label",
"color": "#41C4F4",
"icon": ""
},
"literature": {
......@@ -355,12 +361,12 @@
},
"thing": {
"labelField": "label",
"color": "label",
"color": "#00A000",
"icon": ""
},
"entry": {
"labelField": "label",
"color": "label",
"color": "#789FFF",
"icon": ""
}
},
......@@ -407,7 +413,8 @@
],
"filterable": {
"date": ["regest"]
"date": ["regest"],
"keywords": ["regest"]
},
"source": {
......
import IdSet from "../../misc/customTypes/IdSet"
export class Node2d {
constructor(id, label, type, color=null, data=null, size=1, hide=false){
this.id = id
this.label = label
this.type = type
this.targets = new Set()
this.parents = new Set()
this.targets = new IdSet()
this.parents = new IdSet()
this.color = color ? color : "#DCDCDC"
this.data = data
this.size = size
......@@ -24,46 +26,60 @@ export class Node2d {
})
getEdgesId = () => {
const targets = [...this.targets].map(targetId => `${this.id} ${targetId}`)
const parents = [...this.parents].map(parentId => `${parentId} ${this.id}`)
const targets = this.targets.ids() .map(targetId => `${this.id} ${targetId}`)
const parents = this.parents.ids().map(parentId => `${parentId} ${this.id}`)
return targets.concat(parents)
}
getParents = () => [...this.parents]
getParents = (relationType="all") => this.parents.toArray(link => relationType === "all" || link.type === relationType)
getTargets = () => [...this.targets]
getTargets = (relationType="all") => this.targets.toArray(link => relationType === "all" || link.type === relationType)
getRelated= () => [...this.getParents(), ...this.getTargets()]
getRelated= (relationType="all") => [...this.getParents(relationType), ...this.getTargets(relationType)]
addTarget = targetId => {this.targets.add(targetId)}
addTarget = targetId => {this.targets.addOne(targetId)}
addParent = parentId => {this.parents.add(parentId)}
addParent = parentId => {this.parents.addOne(parentId)}
removeTarget = targetId => {this.targets.delete(targetId)}
removeTarget = targetId => {this.targets.removeOne(targetId)}
removeParent = parentId => {this.parents.delete(parentId)}
removeParent = parentId => {this.parents.removeOne(parentId)}
childrenSummary = (nodes, excludeHidden=false) => {
let valueCounts = {}
nodes.collectFromKeys([...this.targets]).forEach(n => {
let valueCounts = {nodes: {}, links: {}}
nodes.collectFromKeys(this.targets.ids()).forEach(n => {
if (!(n.excluded && excludeHidden)){
if (valueCounts[n.type] && !(n.excluded && excludeHidden))
valueCounts[n.type] += 1
if (valueCounts.nodes[n.type] && !(n.excluded && excludeHidden))
valueCounts.nodes[n.type] += 1
else
valueCounts[n.type] = 1
valueCounts.nodes[n.type] = 1
}})
this.targets.forEachEntry(link => {
if (valueCounts.links[link.type])
valueCounts.links[link.type] += 1
else
valueCounts.links[link.type] = 1
})
return valueCounts
}
parentSummary = (nodes, excludeHidden=false) => {
let valueCounts = {}
nodes.collectFromKeys([...this.parents]).forEach(n => {
let valueCounts = {nodes: {}, links: {}}
nodes.collectFromKeys(this.parents.ids()).forEach(n => {
if (!(n.excluded && excludeHidden)){
if (valueCounts[n.type])
valueCounts[n.type] += 1
if (valueCounts.nodes[n.type] && !(n.excluded && excludeHidden))
valueCounts.nodes[n.type] += 1
else
valueCounts[n.type] = 1
}})
valueCounts.nodes[n.type] = 1
}})
this.parents.forEachEntry(link => {
if (valueCounts.links[link.type])
valueCounts.links[link.type] += 1
else
valueCounts.links[link.type] = 1
})
return valueCounts
}
}
......
This diff is collapsed.
......@@ -91,8 +91,7 @@ function start(settings, login, password) {
let app = new App(dbConnector);
const graph2D = new Graph2D(dbConnector, [], []);
//testGraph2d(dbConnector)
testGraph2d(dbConnector)
// Setup interface
$('#db_name').html(settings.database.name);
//$('#keyword').focus();
......@@ -400,6 +399,11 @@ function start(settings, login, password) {
}
requestAnimationFrame(animate);
$("#filter-content").on("input", () => {
const keywords = $("#filter-content").val().split(" ")
graph2D.graph2d.filterByKeywords(keywords)
graph2D.applyFilterToGraph()
})
return app;
}
......
......@@ -74,7 +74,7 @@ module.exports = class Queries{
let types = this.settings.keywordSearch.selection.map((e) => e.layer);
let i = types.indexOf(type);
let query = this.settings.keywordSearch.selection[i].query;
keyword = keyword.replace("(", "\\\\(").replace(")", "\\\\)").replace(".", "\\\\.")
keyword = keyword.replace("(", "\\\\(").replace(")", "\\\\)").replace(".", "\\\\.").replace("]", "\\\\]").replace("[", "\\\\[")
query = query.replace(/%KEYWORD%/g, keyword);
query = query.replace(/%CULLS%/g, culls);
return query;
......
......@@ -11,6 +11,8 @@ export default class IdSet {
if (iterable)
iterable.forEach(obj => {this._entries[obj.id] = obj})
}
ids = () => Object.keys(this._entries)
addOne = obj => {
if (obj && !this._entries[obj.id])
......@@ -33,6 +35,9 @@ export default class IdSet {
collectFromKeys = idList => idList.map(id => this._entries[id])
/**
* if condFn is true, call f1 else call f2
*/
filterApply = (condFn, f1, f2) => {
for (let id in this._entries){
if (condFn(this._entries[id]))
......@@ -43,7 +48,7 @@ export default class IdSet {
}
forEachEntry = (f) => {
[...this._entries].forEach(e => f(e))
Object.values(this._entries).forEach(e => f(e))
}
remove = objs => objs.forEach(obj => this.removeOne(obj))
......
......@@ -32,7 +32,7 @@ export class EntrySearch {
getNodeName = (node, type) => node.properties[this._dbConnector.settings.nodeTypes2[type].labelField]
searchEntry = (searchString, type) => {
if (this._entries[type])
if (this._entries[type] && searchString.length > 2)
return this._entries[type].filter(x => x && x.toLowerCase().includes(searchString.toLowerCase()))
else
return []
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment