@abi-software/map-utilities 1.1.3-beta.2 → 1.1.3-beta.3
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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="connectivity-graph">
|
|
2
|
+
<div class="connectivity-graph" v-loading="loading">
|
|
3
3
|
<div ref="graphCanvas" class="graph-canvas"></div>
|
|
4
4
|
<div class="control-panel">
|
|
5
5
|
<div class="node-key">
|
|
@@ -82,8 +82,11 @@ export default {
|
|
|
82
82
|
},
|
|
83
83
|
data: function () {
|
|
84
84
|
return {
|
|
85
|
-
|
|
85
|
+
loading: true,
|
|
86
86
|
connectivityGraph: null,
|
|
87
|
+
selectedSource: '',
|
|
88
|
+
pathList: [],
|
|
89
|
+
schemaVersion: '',
|
|
87
90
|
knowledgeByPath: new Map(),
|
|
88
91
|
labelledTerms: new Set(),
|
|
89
92
|
labelCache: new Map(),
|
|
@@ -94,20 +97,47 @@ export default {
|
|
|
94
97
|
};
|
|
95
98
|
},
|
|
96
99
|
mounted() {
|
|
100
|
+
this.loadCacheData();
|
|
97
101
|
this.run().then((res) => {
|
|
98
102
|
this.showGraph(this.entry);
|
|
99
103
|
});
|
|
100
104
|
},
|
|
101
105
|
methods: {
|
|
106
|
+
loadCacheData: function () {
|
|
107
|
+
const selectedSource = sessionStorage.getItem('connectivity-graph-source');
|
|
108
|
+
const labelCache = sessionStorage.getItem('connectivity-graph-labels');
|
|
109
|
+
const pathList = sessionStorage.getItem('connectivity-graph-pathlist');
|
|
110
|
+
const schemaVersion = sessionStorage.getItem('connectivity-graph-schema-version');
|
|
111
|
+
|
|
112
|
+
if (selectedSource) {
|
|
113
|
+
this.selectedSource = selectedSource;
|
|
114
|
+
}
|
|
115
|
+
if (pathList) {
|
|
116
|
+
this.pathList = JSON.parse(pathList);
|
|
117
|
+
}
|
|
118
|
+
if (labelCache) {
|
|
119
|
+
const labelCacheObj = JSON.parse(labelCache);
|
|
120
|
+
this.labelCache = new Map(Object.entries(labelCacheObj));
|
|
121
|
+
}
|
|
122
|
+
if (schemaVersion) {
|
|
123
|
+
this.schemaVersion = schemaVersion;
|
|
124
|
+
}
|
|
125
|
+
},
|
|
102
126
|
run: async function () {
|
|
103
|
-
|
|
104
|
-
|
|
127
|
+
if (!this.schemaVersion) {
|
|
128
|
+
this.schemaVersion = await this.getSchemaVersion();
|
|
129
|
+
sessionStorage.setItem('connectivity-graph-schema-version', this.schemaVersion);
|
|
130
|
+
}
|
|
131
|
+
if (this.schemaVersion < MIN_SCHEMA_VERSION) {
|
|
105
132
|
console.warn('No Server!');
|
|
106
133
|
return;
|
|
107
134
|
}
|
|
108
135
|
this.showSpinner();
|
|
109
|
-
|
|
110
|
-
|
|
136
|
+
if (!this.selectedSource) {
|
|
137
|
+
this.selectedSource = await this.setSourceList();
|
|
138
|
+
sessionStorage.setItem('connectivity-graph-source', this.selectedSource);
|
|
139
|
+
}
|
|
140
|
+
await this.setPathList(this.selectedSource)
|
|
111
141
|
this.hideSpinner();
|
|
112
142
|
},
|
|
113
143
|
showGraph: async function (neuronPath) {
|
|
@@ -159,28 +189,33 @@ export default {
|
|
|
159
189
|
}
|
|
160
190
|
return firstSource;
|
|
161
191
|
},
|
|
162
|
-
|
|
192
|
+
loadPathData: async function (source) {
|
|
163
193
|
const data = await this.query(
|
|
164
194
|
`select entity, knowledge from knowledge
|
|
165
195
|
where entity like 'ilxtr:%' and source=?
|
|
166
196
|
order by entity`,
|
|
167
197
|
[source]);
|
|
168
|
-
const pathList = [];
|
|
198
|
+
const pathList = data ? data.values : [];
|
|
199
|
+
return pathList;
|
|
200
|
+
},
|
|
201
|
+
setPathList: async function (source) {
|
|
202
|
+
if (!this.pathList.length) {
|
|
203
|
+
this.pathList = await this.loadPathData(source);
|
|
204
|
+
sessionStorage.setItem('connectivity-graph-pathlist', JSON.stringify(this.pathList));
|
|
205
|
+
}
|
|
169
206
|
this.knowledgeByPath.clear();
|
|
170
207
|
this.labelledTerms = new Set();
|
|
171
|
-
for (const [key, jsonKnowledge] of
|
|
208
|
+
for (const [key, jsonKnowledge] of this.pathList) {
|
|
172
209
|
const knowledge = JSON.parse(jsonKnowledge);
|
|
173
210
|
if ('connectivity' in knowledge) {
|
|
174
|
-
const label = knowledge.label || key;
|
|
175
|
-
const shortLabel = (label === key.slice(6).replace('-prime', "'").replaceAll('-', ' '))
|
|
176
|
-
? ''
|
|
177
|
-
: (label.length < 50) ? label : `${label.slice(0, 50)}...`;
|
|
178
|
-
pathList.push(key);
|
|
179
211
|
this.knowledgeByPath.set(key, knowledge);
|
|
180
212
|
this.cacheLabels(knowledge);
|
|
181
213
|
}
|
|
182
214
|
}
|
|
183
|
-
|
|
215
|
+
|
|
216
|
+
if (!this.labelCache.size) {
|
|
217
|
+
await this.getCachedTermLabels();
|
|
218
|
+
}
|
|
184
219
|
return '';
|
|
185
220
|
},
|
|
186
221
|
getSchemaVersion: async function () {
|
|
@@ -207,14 +242,16 @@ export default {
|
|
|
207
242
|
},
|
|
208
243
|
getCachedTermLabels: async function () {
|
|
209
244
|
if (this.labelledTerms.size) {
|
|
210
|
-
const
|
|
245
|
+
const data = await this.query(`
|
|
211
246
|
select entity, label from labels
|
|
212
247
|
where entity in (?${', ?'.repeat(this.labelledTerms.size-1)})`,
|
|
213
248
|
[...this.labelledTerms.values()]
|
|
214
249
|
);
|
|
215
|
-
for (const termLabel of
|
|
250
|
+
for (const termLabel of data.values) {
|
|
216
251
|
this.labelCache.set(termLabel[0], termLabel[1]);
|
|
217
252
|
}
|
|
253
|
+
const labelCacheObj = Object.fromEntries(this.labelCache);
|
|
254
|
+
sessionStorage.setItem('connectivity-graph-labels', JSON.stringify(labelCacheObj));
|
|
218
255
|
}
|
|
219
256
|
},
|
|
220
257
|
cacheNodeLabels: function (node) {
|
|
@@ -229,10 +266,10 @@ export default {
|
|
|
229
266
|
}
|
|
230
267
|
},
|
|
231
268
|
showSpinner: function () {
|
|
232
|
-
|
|
269
|
+
this.loading = true;
|
|
233
270
|
},
|
|
234
271
|
hideSpinner: function () {
|
|
235
|
-
|
|
272
|
+
this.loading = false;
|
|
236
273
|
},
|
|
237
274
|
reset: function () {
|
|
238
275
|
this.connectivityGraph.reset();
|
|
@@ -294,7 +331,7 @@ export default {
|
|
|
294
331
|
}
|
|
295
332
|
|
|
296
333
|
.tools {
|
|
297
|
-
margin-top:
|
|
334
|
+
margin-top: 0.5rem;
|
|
298
335
|
display: flex;
|
|
299
336
|
flex-direction: row;
|
|
300
337
|
gap: 0.5rem;
|
|
@@ -310,6 +347,10 @@ export default {
|
|
|
310
347
|
background: $app-primary-color !important;
|
|
311
348
|
transition: all 0.25s ease;
|
|
312
349
|
|
|
350
|
+
svg {
|
|
351
|
+
margin: 0;
|
|
352
|
+
}
|
|
353
|
+
|
|
313
354
|
&,
|
|
314
355
|
&:focus,
|
|
315
356
|
&:active {
|
|
@@ -27,7 +27,7 @@ import cytoscape from 'cytoscape'
|
|
|
27
27
|
|
|
28
28
|
export class ConnectivityGraph
|
|
29
29
|
{
|
|
30
|
-
|
|
30
|
+
cyg = null
|
|
31
31
|
nodes = []
|
|
32
32
|
edges = []
|
|
33
33
|
axons = []
|
|
@@ -69,31 +69,31 @@ export class ConnectivityGraph
|
|
|
69
69
|
showConnectivity(graphCanvas)
|
|
70
70
|
//================
|
|
71
71
|
{
|
|
72
|
-
this.
|
|
72
|
+
this.cyg = new CytoscapeGraph(this, graphCanvas)
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
clearConnectivity()
|
|
76
76
|
//=================
|
|
77
77
|
{
|
|
78
|
-
if (this.cy) {
|
|
79
|
-
this.cy.remove()
|
|
80
|
-
this.cy = null
|
|
78
|
+
if (this.cyg?.cy) {
|
|
79
|
+
this.cyg.cy.remove()
|
|
80
|
+
this.cyg.cy = null
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
reset()
|
|
85
85
|
//=================
|
|
86
86
|
{
|
|
87
|
-
if (this.
|
|
88
|
-
this.
|
|
87
|
+
if (this.cyg?.cy) {
|
|
88
|
+
this.cyg.cy.reset()
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
enableZoom(option)
|
|
93
93
|
//=================
|
|
94
94
|
{
|
|
95
|
-
if (this.
|
|
96
|
-
this.
|
|
95
|
+
if (this.cyg?.cy) {
|
|
96
|
+
this.cyg.cy.userZoomingEnabled(option)
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
@@ -195,7 +195,6 @@ class CytoscapeGraph
|
|
|
195
195
|
|
|
196
196
|
constructor(connectivityGraph, graphCanvas)
|
|
197
197
|
{
|
|
198
|
-
// const graphCanvas = document.getElementById('graph-canvas')
|
|
199
198
|
this.cy = cytoscape({
|
|
200
199
|
container: graphCanvas,
|
|
201
200
|
elements: connectivityGraph.elements,
|