@abi-software/map-utilities 1.1.3-beta.4 → 1.1.3-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -181,6 +181,15 @@ export default {
|
|
|
181
181
|
this.hideSpinner();
|
|
182
182
|
|
|
183
183
|
this.connectivityGraph.showConnectivity(graphCanvas);
|
|
184
|
+
|
|
185
|
+
this.connectivityGraph.on('tap-node', (event) => {
|
|
186
|
+
const { label } = event.detail;
|
|
187
|
+
const labels = label.split(`\n`);
|
|
188
|
+
/**
|
|
189
|
+
* This event is triggered after a node on the connectivity graph is clicked.
|
|
190
|
+
*/
|
|
191
|
+
this.$emit('tap-node', labels);
|
|
192
|
+
});
|
|
184
193
|
},
|
|
185
194
|
query: async function (sql, params) {
|
|
186
195
|
const url = `${this.mapServer}knowledge/query/`;
|
|
@@ -287,14 +296,20 @@ export default {
|
|
|
287
296
|
},
|
|
288
297
|
getCachedTermLabels: async function () {
|
|
289
298
|
if (this.labelledTerms.size) {
|
|
290
|
-
const data = await this.query(
|
|
291
|
-
select entity,
|
|
292
|
-
|
|
299
|
+
const data = await this.query(
|
|
300
|
+
`select entity, knowledge from knowledge
|
|
301
|
+
where entity in (?${', ?'.repeat(this.labelledTerms.size-1)})
|
|
302
|
+
order by source desc`,
|
|
293
303
|
[...this.labelledTerms.values()]
|
|
294
304
|
);
|
|
295
305
|
|
|
296
|
-
|
|
297
|
-
|
|
306
|
+
let last_entity = null;
|
|
307
|
+
for (const [key, jsonKnowledge] of data.values) {
|
|
308
|
+
if (key !== last_entity) {
|
|
309
|
+
const knowledge = JSON.parse(jsonKnowledge);
|
|
310
|
+
this.labelCache.set(key, knowledge['label'] || key);
|
|
311
|
+
last_entity = key;
|
|
312
|
+
}
|
|
298
313
|
}
|
|
299
314
|
|
|
300
315
|
const labelCacheObj = Object.fromEntries(this.labelCache);
|
|
@@ -25,7 +25,7 @@ import cytoscape from 'cytoscape'
|
|
|
25
25
|
|
|
26
26
|
//==============================================================================
|
|
27
27
|
|
|
28
|
-
export class ConnectivityGraph
|
|
28
|
+
export class ConnectivityGraph extends EventTarget
|
|
29
29
|
{
|
|
30
30
|
cyg = null
|
|
31
31
|
nodes = []
|
|
@@ -37,8 +37,9 @@ export class ConnectivityGraph
|
|
|
37
37
|
|
|
38
38
|
constructor(labelCache, graphCanvas)
|
|
39
39
|
{
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
super()
|
|
41
|
+
this.labelCache = labelCache;
|
|
42
|
+
this.graphCanvas = graphCanvas;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
async addConnectivity(knowledge)
|
|
@@ -70,6 +71,13 @@ export class ConnectivityGraph
|
|
|
70
71
|
//================
|
|
71
72
|
{
|
|
72
73
|
this.cyg = new CytoscapeGraph(this, graphCanvas)
|
|
74
|
+
|
|
75
|
+
this.cyg.on('tap-node', (event) => {
|
|
76
|
+
const tapEvent = new CustomEvent('tap-node', {
|
|
77
|
+
detail: event.detail
|
|
78
|
+
})
|
|
79
|
+
this.dispatchEvent(tapEvent);
|
|
80
|
+
});
|
|
73
81
|
}
|
|
74
82
|
|
|
75
83
|
clearConnectivity()
|
|
@@ -140,6 +148,12 @@ export class ConnectivityGraph
|
|
|
140
148
|
}
|
|
141
149
|
return result
|
|
142
150
|
}
|
|
151
|
+
|
|
152
|
+
on(eventName, callback)
|
|
153
|
+
//=====================
|
|
154
|
+
{
|
|
155
|
+
this.addEventListener(eventName, callback)
|
|
156
|
+
}
|
|
143
157
|
}
|
|
144
158
|
|
|
145
159
|
//==============================================================================
|
|
@@ -188,13 +202,14 @@ const GRAPH_STYLE = [
|
|
|
188
202
|
|
|
189
203
|
//==============================================================================
|
|
190
204
|
|
|
191
|
-
class CytoscapeGraph
|
|
205
|
+
class CytoscapeGraph extends EventTarget
|
|
192
206
|
{
|
|
193
207
|
cy
|
|
194
208
|
tooltip
|
|
195
209
|
|
|
196
210
|
constructor(connectivityGraph, graphCanvas)
|
|
197
211
|
{
|
|
212
|
+
super()
|
|
198
213
|
this.cy = cytoscape({
|
|
199
214
|
container: graphCanvas,
|
|
200
215
|
elements: connectivityGraph.elements,
|
|
@@ -211,6 +226,7 @@ class CytoscapeGraph
|
|
|
211
226
|
}).on('mouseover', 'node', this.overNode.bind(this))
|
|
212
227
|
.on('mouseout', 'node', this.exitNode.bind(this))
|
|
213
228
|
.on('position', 'node', this.moveNode.bind(this))
|
|
229
|
+
.on('tap', 'node', this.tapNode.bind(this))
|
|
214
230
|
|
|
215
231
|
this.tooltip = document.createElement('div')
|
|
216
232
|
this.tooltip.className = 'cy-graph-tooltip'
|
|
@@ -259,6 +275,23 @@ class CytoscapeGraph
|
|
|
259
275
|
{
|
|
260
276
|
this.tooltip.hidden = true
|
|
261
277
|
}
|
|
278
|
+
|
|
279
|
+
tapNode(event)
|
|
280
|
+
//============
|
|
281
|
+
{
|
|
282
|
+
const node = event.target
|
|
283
|
+
const data = node.data()
|
|
284
|
+
const tapEvent = new CustomEvent('tap-node', {
|
|
285
|
+
detail: data
|
|
286
|
+
})
|
|
287
|
+
this.dispatchEvent(tapEvent);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
on(eventName, callback)
|
|
291
|
+
//=====================
|
|
292
|
+
{
|
|
293
|
+
this.addEventListener(eventName, callback)
|
|
294
|
+
}
|
|
262
295
|
}
|
|
263
296
|
|
|
264
297
|
//==============================================================================
|