@abi-software/map-utilities 1.1.3-beta.3 → 1.1.3-beta.4
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
package/src/App.vue
CHANGED
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
import { ConnectivityGraph } from './graph';
|
|
61
61
|
|
|
62
62
|
const MIN_SCHEMA_VERSION = 1.3;
|
|
63
|
+
const CACHE_LIFETIME = 24 * 60 * 60 * 1000; // One day
|
|
63
64
|
const RESET_LABEL = 'Reset position';
|
|
64
65
|
const ZOOM_LOCK_LABEL = 'Lock zoom (to scroll)';
|
|
65
66
|
const ZOOM_UNLOCK_LABEL = 'Unlock zoom';
|
|
@@ -97,6 +98,7 @@ export default {
|
|
|
97
98
|
};
|
|
98
99
|
},
|
|
99
100
|
mounted() {
|
|
101
|
+
this.refreshCache();
|
|
100
102
|
this.loadCacheData();
|
|
101
103
|
this.run().then((res) => {
|
|
102
104
|
this.showGraph(this.entry);
|
|
@@ -123,10 +125,37 @@ export default {
|
|
|
123
125
|
this.schemaVersion = schemaVersion;
|
|
124
126
|
}
|
|
125
127
|
},
|
|
128
|
+
removeAllCacheData: function () {
|
|
129
|
+
const keys = [
|
|
130
|
+
'connectivity-graph-expiry',
|
|
131
|
+
'connectivity-graph-source',
|
|
132
|
+
'connectivity-graph-labels',
|
|
133
|
+
'connectivity-graph-pathlist',
|
|
134
|
+
'connectivity-graph-schema-version',
|
|
135
|
+
];
|
|
136
|
+
keys.forEach((key) => {
|
|
137
|
+
sessionStorage.removeItem(key);
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
refreshCache: function () {
|
|
141
|
+
const expiry = sessionStorage.getItem('connectivity-graph-expiry');
|
|
142
|
+
const now = new Date();
|
|
143
|
+
|
|
144
|
+
if (now.getTime() > expiry) {
|
|
145
|
+
this.removeAllCacheData();
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
updateCacheExpiry: function () {
|
|
149
|
+
const now = new Date();
|
|
150
|
+
const expiry = now.getTime() + CACHE_LIFETIME;
|
|
151
|
+
|
|
152
|
+
sessionStorage.setItem('connectivity-graph-expiry', expiry);
|
|
153
|
+
},
|
|
126
154
|
run: async function () {
|
|
127
155
|
if (!this.schemaVersion) {
|
|
128
156
|
this.schemaVersion = await this.getSchemaVersion();
|
|
129
157
|
sessionStorage.setItem('connectivity-graph-schema-version', this.schemaVersion);
|
|
158
|
+
this.updateCacheExpiry();
|
|
130
159
|
}
|
|
131
160
|
if (this.schemaVersion < MIN_SCHEMA_VERSION) {
|
|
132
161
|
console.warn('No Server!');
|
|
@@ -136,22 +165,27 @@ export default {
|
|
|
136
165
|
if (!this.selectedSource) {
|
|
137
166
|
this.selectedSource = await this.setSourceList();
|
|
138
167
|
sessionStorage.setItem('connectivity-graph-source', this.selectedSource);
|
|
168
|
+
this.updateCacheExpiry();
|
|
139
169
|
}
|
|
140
|
-
await this.setPathList(this.selectedSource)
|
|
170
|
+
await this.setPathList(this.selectedSource);
|
|
141
171
|
this.hideSpinner();
|
|
142
172
|
},
|
|
143
173
|
showGraph: async function (neuronPath) {
|
|
144
174
|
const graphCanvas = this.$refs.graphCanvas;
|
|
175
|
+
|
|
145
176
|
this.showSpinner();
|
|
177
|
+
|
|
146
178
|
this.connectivityGraph = new ConnectivityGraph(this.labelCache, graphCanvas);
|
|
147
179
|
await this.connectivityGraph.addConnectivity(this.knowledgeByPath.get(neuronPath));
|
|
180
|
+
|
|
148
181
|
this.hideSpinner();
|
|
182
|
+
|
|
149
183
|
this.connectivityGraph.showConnectivity(graphCanvas);
|
|
150
|
-
this.currentPath = neuronPath
|
|
151
184
|
},
|
|
152
185
|
query: async function (sql, params) {
|
|
153
186
|
const url = `${this.mapServer}knowledge/query/`;
|
|
154
|
-
const query = { sql, params }
|
|
187
|
+
const query = { sql, params };
|
|
188
|
+
|
|
155
189
|
try {
|
|
156
190
|
const response = await fetch(url, {
|
|
157
191
|
method: 'POST',
|
|
@@ -162,9 +196,11 @@ export default {
|
|
|
162
196
|
},
|
|
163
197
|
body: JSON.stringify(query)
|
|
164
198
|
});
|
|
199
|
+
|
|
165
200
|
if (!response.ok) {
|
|
166
201
|
throw new Error(`Cannot access ${url}`);
|
|
167
202
|
}
|
|
203
|
+
|
|
168
204
|
return await response.json();
|
|
169
205
|
} catch {
|
|
170
206
|
return {
|
|
@@ -179,14 +215,17 @@ export default {
|
|
|
179
215
|
// Order with most recent first...
|
|
180
216
|
let firstSource = '';
|
|
181
217
|
const sourceList = [];
|
|
218
|
+
|
|
182
219
|
for (const source of sources) {
|
|
183
220
|
if (source) {
|
|
184
221
|
sourceList.push(source);
|
|
222
|
+
|
|
185
223
|
if (firstSource === '') {
|
|
186
224
|
firstSource = source;
|
|
187
225
|
}
|
|
188
226
|
}
|
|
189
227
|
}
|
|
228
|
+
|
|
190
229
|
return firstSource;
|
|
191
230
|
},
|
|
192
231
|
loadPathData: async function (source) {
|
|
@@ -202,9 +241,12 @@ export default {
|
|
|
202
241
|
if (!this.pathList.length) {
|
|
203
242
|
this.pathList = await this.loadPathData(source);
|
|
204
243
|
sessionStorage.setItem('connectivity-graph-pathlist', JSON.stringify(this.pathList));
|
|
244
|
+
this.updateCacheExpiry();
|
|
205
245
|
}
|
|
246
|
+
|
|
206
247
|
this.knowledgeByPath.clear();
|
|
207
248
|
this.labelledTerms = new Set();
|
|
249
|
+
|
|
208
250
|
for (const [key, jsonKnowledge] of this.pathList) {
|
|
209
251
|
const knowledge = JSON.parse(jsonKnowledge);
|
|
210
252
|
if ('connectivity' in knowledge) {
|
|
@@ -216,6 +258,7 @@ export default {
|
|
|
216
258
|
if (!this.labelCache.size) {
|
|
217
259
|
await this.getCachedTermLabels();
|
|
218
260
|
}
|
|
261
|
+
|
|
219
262
|
return '';
|
|
220
263
|
},
|
|
221
264
|
getSchemaVersion: async function () {
|
|
@@ -232,9 +275,11 @@ export default {
|
|
|
232
275
|
"Content-Type": "application/json"
|
|
233
276
|
}
|
|
234
277
|
});
|
|
278
|
+
|
|
235
279
|
if (!response.ok) {
|
|
236
280
|
console.error(`Cannot access ${url}`);
|
|
237
281
|
}
|
|
282
|
+
|
|
238
283
|
return await response.json();
|
|
239
284
|
} catch {
|
|
240
285
|
return null;
|
|
@@ -247,11 +292,14 @@ export default {
|
|
|
247
292
|
where entity in (?${', ?'.repeat(this.labelledTerms.size-1)})`,
|
|
248
293
|
[...this.labelledTerms.values()]
|
|
249
294
|
);
|
|
295
|
+
|
|
250
296
|
for (const termLabel of data.values) {
|
|
251
297
|
this.labelCache.set(termLabel[0], termLabel[1]);
|
|
252
298
|
}
|
|
299
|
+
|
|
253
300
|
const labelCacheObj = Object.fromEntries(this.labelCache);
|
|
254
301
|
sessionStorage.setItem('connectivity-graph-labels', JSON.stringify(labelCacheObj));
|
|
302
|
+
this.updateCacheExpiry();
|
|
255
303
|
}
|
|
256
304
|
},
|
|
257
305
|
cacheNodeLabels: function (node) {
|
|
@@ -309,7 +357,7 @@ export default {
|
|
|
309
357
|
.node-key {
|
|
310
358
|
border: 1px solid $app-primary-color;
|
|
311
359
|
padding: 4px;
|
|
312
|
-
background-color: rgba(
|
|
360
|
+
background-color: rgba(#f7faff, 0.85);
|
|
313
361
|
|
|
314
362
|
div div {
|
|
315
363
|
width: 90px;
|
|
@@ -362,6 +410,20 @@ export default {
|
|
|
362
410
|
}
|
|
363
411
|
}
|
|
364
412
|
|
|
413
|
+
:deep(.cy-graph-tooltip) {
|
|
414
|
+
padding: 4px 10px;
|
|
415
|
+
font-family: Asap;
|
|
416
|
+
font-size: 12px;
|
|
417
|
+
background: #f3ecf6 !important;
|
|
418
|
+
border: 1px solid $app-primary-color;
|
|
419
|
+
border-radius: var(--el-border-radius-base);
|
|
420
|
+
position: relative;
|
|
421
|
+
top: 0;
|
|
422
|
+
left: 0;
|
|
423
|
+
width: fit-content;
|
|
424
|
+
z-index: 1;
|
|
425
|
+
}
|
|
426
|
+
|
|
365
427
|
.visually-hidden {
|
|
366
428
|
clip: rect(0 0 0 0);
|
|
367
429
|
clip-path: inset(50%);
|
|
@@ -213,9 +213,9 @@ class CytoscapeGraph
|
|
|
213
213
|
.on('position', 'node', this.moveNode.bind(this))
|
|
214
214
|
|
|
215
215
|
this.tooltip = document.createElement('div')
|
|
216
|
-
this.tooltip.
|
|
216
|
+
this.tooltip.className = 'cy-graph-tooltip'
|
|
217
217
|
this.tooltip.hidden = true
|
|
218
|
-
|
|
218
|
+
graphCanvas?.lastChild?.appendChild(this.tooltip)
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
remove()
|