@abi-software/flatmapvuer 0.3.0-beta-2-upstream-downstream-4 → 0.3.0

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.
@@ -1,494 +1,494 @@
1
- <template>
2
- <div class="tooltip-container">
3
- <el-main v-if="content" class="main" v-loading="loading">
4
- <div class="block" v-if="content.title">
5
- <span class="title">{{capitalise(content.title)}}</span>
6
- </div>
7
- <div class="block" v-else>
8
- <span class="title">{{content.featureId}}</span>
9
- </div>
10
- <!-- Currently we don't show the pubmed viewer, will remove once we are certain it won't be used -->
11
- <pubmed-viewer v-if="content.featureIds" v-show="false" class="block" :entry="content" @pubmedSearchUrl="pubmedSearchUrlUpdate"/>
12
- {{content.paths}}
13
- <div v-if="this.origins" class="block">
14
- <div>
15
- <span class="attribute-title">Origin</span>
16
- <el-popover
17
- width="250"
18
- trigger="hover"
19
- :append-to-body=false
20
- popper-class="popover-origin-help"
21
- >
22
- <i slot="reference" class="el-icon-warning-outline info"/>
23
- <span style="word-break: keep-all;">
24
- <i>Origin</i> {{originDescription}}
25
- </span>
26
- </el-popover>
27
- </div>
28
- <div v-for="origin in origins" class="attribute-content" :key="origin">
29
- {{ capitalise(origin) }}
30
- </div>
31
- <el-button v-show="originsWithDatasets.length > 0" class="button" @click="openDendrites">
32
- Explore origin data
33
- </el-button>
34
- </div>
35
- <div v-if="this.components" class="block">
36
- <div class="attribute-title">Components</div>
37
- <div v-for="component in components" class="attribute-content" :key="component">
38
- {{ capitalise(component) }}
39
- </div>
40
- </div>
41
- <div v-if="this.destinations" class="block">
42
- <div>
43
- <span class="attribute-title">Destination</span>
44
- <el-popover
45
- width="250"
46
- trigger="hover"
47
- :append-to-body=false
48
- popper-class="popover-origin-help"
49
- >
50
- <i slot="reference" class="el-icon-warning-outline info"/>
51
- <span style="word-break: keep-all;">
52
- <i>Destination</i> is where the axons terminate (& in the cases of some psuedoinunipolar neurons, where their dendritic "terminals" are)
53
- </span>
54
- </el-popover>
55
- </div>
56
- <div v-for="destination in destinations" class="attribute-content" :key="destination">
57
- {{ capitalise(destination) }}
58
- </div>
59
- <el-button v-show="destinationsWithDatasets.length > 0" class="button" @click="openAxons">
60
- Explore destination data
61
- </el-button>
62
- </div>
63
-
64
- <!-- We will serach on components until we can search on neurons -->
65
- <el-button v-show="components.length > 0" class="button" @click="openAll">
66
- Search for data on components
67
- </el-button>
68
-
69
- <!-- Disable neuron search until it is ready -->
70
- <!-- <el-button v-for="action in content.actions" round :key="action.title"
71
- class="button" @click="resourceSelected(action)">
72
- <i v-if="action.title === 'Search for datasets' || action.title === 'View Dataset' " class="el-icon-coin"></i>
73
- {{action.title}}
74
- </el-button> -->
75
- <el-button v-if="pubmedSearchUrl" class="button" icon="el-icon-notebook-2" @click="openUrl(pubmedSearchUrl)">
76
- Open publications in pubmed
77
- </el-button>
78
- </el-main>
79
- </div>
80
- </template>
81
-
82
-
83
- <script>
84
- /* eslint-disable no-alert, no-console */
85
- import Vue from "vue";
86
- import {
87
- Button,
88
- Container,
89
- Header,
90
- Icon,
91
- Main
92
- } from "element-ui";
93
- import lang from "element-ui/lib/locale/lang/en";
94
- import locale from "element-ui/lib/locale";
95
- locale.use(lang);
96
- Vue.use(Button);
97
- Vue.use(Container);
98
- Vue.use(Header);
99
- Vue.use(Icon);
100
- Vue.use(Main);
101
-
102
- // pubmedviewer is currently not in use, but still under review so not ready to delete yet
103
- import PubmedViewer from './PubmedViewer.vue'
104
- import EventBus from './EventBus'
105
-
106
- const titleCase = (str) => {
107
- return str.replace(/\w\S*/g, (t) => { return t.charAt(0).toUpperCase() + t.substr(1).toLowerCase() });
108
- }
109
-
110
- const capitalise = function(str){
111
- if (str)
112
- return str.charAt(0).toUpperCase() + str.slice(1)
113
- return ""
114
- }
115
-
116
- export default {
117
- components: { PubmedViewer },
118
- name: "Tooltip",
119
- props: {
120
- visible: {
121
- type: Boolean,
122
- default: false
123
- },
124
- content: {
125
- type: Object,
126
- default: undefined
127
- },
128
- },
129
- data: function() {
130
- return {
131
- activeSpecies: undefined,
132
- appendToBody: false,
133
- pubmedSearchUrl: '',
134
- loading: false,
135
- destinations: [],
136
- origins: [],
137
- components: [],
138
- destinationsWithDatasets: [],
139
- originsWithDatasets: [],
140
- originDescriptions: {
141
- 'motor': 'is the location of the initial cell body of the circuit',
142
- 'sensory': 'is the location of the initial cell body in the PNS circuit'
143
- },
144
- componentsWithDatasets: [],
145
- uberons: [{id: undefined, name: undefined}]
146
- };
147
- },
148
- inject: ['sparcAPI', 'flatmapAPI'],
149
- watch: {
150
- 'content.featureIds': {
151
- handler: function(){
152
- this.pathwayQuery(this.content.featureIds)
153
- }
154
- }
155
- },
156
- mounted: function(){
157
- this.getOrganCuries()
158
- },
159
- computed: {
160
- originDescription: function(){
161
- if(this.content && this.content.title && this.content.title.toLowerCase().includes('motor')){
162
- return this.originDescriptions.motor
163
- } else {
164
- return this.originDescriptions.sensory
165
- }
166
- }
167
- },
168
- methods: {
169
- resourceSelected: function(action) {
170
- this.$emit("resource-selected", action);
171
- },
172
- titleCase: function(title){
173
- return titleCase(title)
174
- },
175
- capitalise: function(text){
176
- return capitalise(text)
177
- },
178
- onClose: function() {
179
- this.$emit("onClose")
180
- },
181
- openUrl: function(url){
182
- window.open(url, '_blank')
183
- },
184
- openAll: function(){
185
- EventBus.$emit('onActionClick', {type:'Facets', labels: this.components})
186
- },
187
- openAxons: function(){
188
- EventBus.$emit('onActionClick', {type:'Facets', labels: this.destinationsWithDatasets.map(a=>a.name)})
189
- },
190
- openDendrites: function(){
191
- EventBus.$emit('onActionClick', {type:'Facets', labels: this.originsWithDatasets.map(a=>a.name)})
192
- },
193
- pubmedSearchUrlUpdate: function (val){
194
- this.pubmedSearchUrl = val
195
- },
196
- findComponents: function(connectivity){
197
- let dnodes = connectivity.connectivity.flat() // get nodes from edgelist
198
- let nodes = [...new Set(dnodes)] // remove duplicates
199
-
200
- let found = []
201
- let terminal = false
202
- nodes.forEach(node=>{
203
- let n = node.flat() // Find all terms on the node
204
- terminal = false
205
-
206
- // Check if the node is an destination or origin (note that they are labelled dendrite and axon as opposed to origin and destination)
207
- n.forEach(s=>{
208
- if(connectivity.axons.includes(s)){
209
- terminal = true
210
- }
211
- if(connectivity.dendrites.includes(s)){
212
- terminal = true
213
- }
214
- })
215
- if (!terminal){
216
- found.push(node)
217
- }
218
- })
219
-
220
- // remove duplicates
221
- let foundUnique = [...new Set(found.map(n=>n[0]))]
222
- return foundUnique
223
- },
224
- getOrganCuries: function(){
225
- fetch(`${this.sparcAPI}get-organ-curies/`)
226
- .then(response=>response.json())
227
- .then(data=>{
228
- this.uberons = data.uberon.array
229
- })
230
- },
231
- buildConnectivitySqlStatement: function(keastIds) {
232
- let sql = 'select knowledge from knowledge where entity in ('
233
- if (keastIds.length === 1) {
234
- sql += `'${keastIds[0]}')`
235
- } else if (keastIds.length > 1) {
236
- for (let i in keastIds) {
237
- sql += `'${keastIds[i]}'${i >= keastIds.length - 1 ? ')' : ','} `
238
- }
239
- }
240
- return sql
241
- },
242
- buildLabelSqlStatement: function(uberons) {
243
- let sql = 'select entity, label from labels where entity in ('
244
- if (uberons.length === 1) {
245
- sql += `'${uberons[0]}')`
246
- } else if (uberons.length > 1) {
247
- for (let i in uberons) {
248
- sql += `'${uberons[i]}'${i >= uberons.length - 1 ? ')' : ','} `
249
- }
250
- }
251
- return sql
252
- },
253
- createLabelLookup: function(uberons) {
254
- return new Promise(resolve=> {
255
- let uberonMap = {}
256
- const data = { sql: this.buildLabelSqlStatement(uberons)}
257
- fetch(`${this.flatmapAPI}knowledge/query/`, {
258
- method: 'POST',
259
- headers: {
260
- 'Content-Type': 'application/json',
261
- },
262
- body: JSON.stringify(data),
263
- })
264
- .then(response => response.json())
265
- .then(payload => {
266
- const entity = payload.keys.indexOf("entity");
267
- const label = payload.keys.indexOf("label");
268
- if (entity > -1 && label > -1) {
269
- payload.values.forEach(pair => {
270
- uberonMap[pair[entity]] = pair[label];
271
- });
272
- }
273
- resolve(uberonMap)
274
- })
275
- })
276
- },
277
- pathwayQuery: function(keastIds){
278
- this.destinations = []
279
- this.origins = []
280
- this.components = []
281
- this.loading = true
282
- if (!keastIds || keastIds.length == 0) return
283
- const data = { sql: this.buildConnectivitySqlStatement(keastIds)};
284
- fetch(`${this.flatmapAPI}knowledge/query/`, {
285
- method: 'POST',
286
- headers: {
287
- 'Content-Type': 'application/json',
288
- },
289
- body: JSON.stringify(data),
290
- })
291
- .then(response => response.json())
292
- .then(data => {
293
- let connectivity = JSON.parse(data.values[0][0])
294
- let components = this.findComponents(connectivity)
295
-
296
- // Create list of ids to get labels for
297
- let conIds = connectivity.axons.concat(connectivity.dendrites.concat(components))
298
- this.createLabelLookup(conIds).then(lookUp=>{
299
- this.destinations = connectivity.axons.map(a=>lookUp[a])
300
- this.origins = connectivity.dendrites.map(d=>lookUp[d])
301
- this.components = components.map(c=>lookUp[c])
302
- })
303
-
304
- // Filter for the anatomy which is annotated on datasets
305
- this.destinationsWithDatasets = this.uberons.filter(ub => connectivity.axons.indexOf(ub.id) !== -1)
306
- this.originsWithDatasets = this.uberons.filter(ub => connectivity.dendrites.indexOf(ub.id) !== -1)
307
- this.componentsWithDatasets = this.uberons.filter(ub => connectivity.dendrites.indexOf(ub.id) !== -1)
308
- this.loading = false
309
- })
310
- .catch((error) => {
311
- console.error('Error:', error);
312
- })
313
- }
314
- }
315
- };
316
- </script>
317
-
318
- <style scoped lang="scss">
319
- @import "~element-ui/packages/theme-chalk/src/button";
320
- @import "~element-ui/packages/theme-chalk/src/container";
321
- @import "~element-ui/packages/theme-chalk/src/header";
322
- @import "~element-ui/packages/theme-chalk/src/main";
323
-
324
- .tooltip-container {
325
- text-align:justify;
326
- border-radius: 4px;
327
- box-shadow: 0 1px 2px rgba(0,0,0,.1);
328
- pointer-events: auto;
329
- background: #fff;
330
- border: 1px solid $app-primary-color;
331
- display: flex;
332
- justify-content: center;
333
- align-items: center;
334
- }
335
-
336
- .display {
337
- width: 44px;
338
- word-break: normal;
339
- }
340
-
341
- .title {
342
- text-align: left;
343
- width: 16em;
344
- line-height: 1.5em !important;
345
- font-size: 1em;
346
- font-family: Helvetica;
347
- font-weight: 500;
348
- /* font-weight: bold; */
349
- padding-bottom: 8px;
350
- }
351
-
352
- .block {
353
- margin-bottom: 1.5em;
354
- }
355
-
356
- .pub {
357
- width: 16rem;
358
- }
359
-
360
- .icon {
361
- right: 0px;
362
- position: absolute;
363
- top: 10px;
364
- }
365
-
366
- .icon:hover {
367
- cursor: pointer;
368
- }
369
-
370
- .popover-origin-help {
371
- text-transform: none !important; // need to overide the tooltip text transform
372
- }
373
-
374
- .info{
375
- transform: rotate(180deg);
376
- color: #8300bf;
377
- margin-left: 8px;
378
- }
379
-
380
- .main {
381
- font-size: 14px;
382
- text-align: left;
383
- line-height: 1.5em;
384
- font-family: Helvetica;
385
- font-weight: 400;
386
- /* outline: thin red solid; */
387
- padding: 1em !important;
388
- overflow: hidden;
389
- min-width: 16rem;
390
- }
391
-
392
- .title{
393
- font-size: 18px;
394
- font-weight: 500;
395
- font-weight: bold;
396
- padding-bottom: 8px;
397
- color: rgb(131, 0, 191);
398
-
399
- }
400
-
401
- .attribute-title{
402
- font-size: 16px;
403
- font-weight: 600;
404
- /* font-weight: bold; */
405
- text-transform: uppercase;
406
- }
407
-
408
- .attribute-content{
409
- font-size: 14px;
410
- font-weight: 500;
411
- }
412
-
413
- .popover-container {
414
- height: 100%;
415
- width: 100%;
416
- }
417
-
418
- .main {
419
- .el-button.is-round{
420
- border-radius: 4px;
421
- padding: 9px 20px 10px 20px;
422
- display: flex;
423
- height: 36px;
424
- }
425
- }
426
-
427
- .button {
428
- margin-left: 0px !important;
429
- margin-top: 0px !important;
430
- font-size: 14px !important;
431
- background-color: $app-primary-color;
432
- color: #fff;
433
- &+.button {
434
- margin-top: 10px !important;
435
- }
436
- &:hover {
437
- color: #fff !important;
438
- background: #ac76c5 !important;
439
- border: 1px solid #ac76c5 !important;
440
- }
441
- }
442
-
443
- .tooltip-container{
444
- &::after, &::before {
445
- content: '';
446
- display: block;
447
- position: absolute;
448
- width: 0;
449
- height: 0;
450
- border-style: solid;
451
- flex-shrink: 0;
452
- }
453
- }
454
-
455
- .mapboxgl-popup-anchor-bottom {
456
- .tooltip-container {
457
- &::after, &::before {
458
- top: 100%;
459
- border-width: 12px;
460
- }
461
- &::after {
462
- margin-top:-1px;
463
- border-color: rgb(255, 255, 255) transparent transparent transparent ;
464
- }
465
- &::before {
466
- margin: 0 auto;
467
- border-color: $app-primary-color transparent transparent transparent ;
468
- }
469
- }
470
- }
471
-
472
- .mapboxgl-popup-anchor-top {
473
- .tooltip-container {
474
- &::after, &::before {
475
- top: -24px;
476
- border-width: 12px;
477
- }
478
- &::after {
479
- margin-top: 1px;
480
- border-color: transparent transparent rgb(255, 255, 255) transparent ;
481
- }
482
- &::before {
483
- margin: 0 auto;
484
- border-color: transparent transparent $app-primary-color transparent ;
485
- }
486
- }
487
- }
488
-
489
-
490
- /* Fix for chrome bug where under triangle pops up above one on top of it */
491
- .selector:not(*:root), .tooltip-container::after{
492
- top: 99.4%;
493
- }
494
- </style>
1
+ <template>
2
+ <div class="tooltip-container">
3
+ <el-main v-if="content" class="main" v-loading="loading">
4
+ <div class="block" v-if="content.title">
5
+ <span class="title">{{capitalise(content.title)}}</span>
6
+ </div>
7
+ <div class="block" v-else>
8
+ <span class="title">{{content.featureId}}</span>
9
+ </div>
10
+ <!-- Currently we don't show the pubmed viewer, will remove once we are certain it won't be used -->
11
+ <pubmed-viewer v-if="content.featureIds" v-show="false" class="block" :entry="content" @pubmedSearchUrl="pubmedSearchUrlUpdate"/>
12
+ {{content.paths}}
13
+ <div v-if="this.origins" class="block">
14
+ <div>
15
+ <span class="attribute-title">Origin</span>
16
+ <el-popover
17
+ width="250"
18
+ trigger="hover"
19
+ :append-to-body=false
20
+ popper-class="popover-origin-help"
21
+ >
22
+ <i slot="reference" class="el-icon-warning-outline info"/>
23
+ <span style="word-break: keep-all;">
24
+ <i>Origin</i> {{originDescription}}
25
+ </span>
26
+ </el-popover>
27
+ </div>
28
+ <div v-for="origin in origins" class="attribute-content" :key="origin">
29
+ {{ capitalise(origin) }}
30
+ </div>
31
+ <el-button v-show="originsWithDatasets.length > 0" class="button" @click="openDendrites">
32
+ Explore origin data
33
+ </el-button>
34
+ </div>
35
+ <div v-if="this.components" class="block">
36
+ <div class="attribute-title">Components</div>
37
+ <div v-for="component in components" class="attribute-content" :key="component">
38
+ {{ capitalise(component) }}
39
+ </div>
40
+ </div>
41
+ <div v-if="this.destinations" class="block">
42
+ <div>
43
+ <span class="attribute-title">Destination</span>
44
+ <el-popover
45
+ width="250"
46
+ trigger="hover"
47
+ :append-to-body=false
48
+ popper-class="popover-origin-help"
49
+ >
50
+ <i slot="reference" class="el-icon-warning-outline info"/>
51
+ <span style="word-break: keep-all;">
52
+ <i>Destination</i> is where the axons terminate
53
+ </span>
54
+ </el-popover>
55
+ </div>
56
+ <div v-for="destination in destinations" class="attribute-content" :key="destination">
57
+ {{ capitalise(destination) }}
58
+ </div>
59
+ <el-button v-show="destinationsWithDatasets.length > 0" class="button" @click="openAxons">
60
+ Explore destination data
61
+ </el-button>
62
+ </div>
63
+
64
+ <!-- We will serach on components until we can search on neurons -->
65
+ <el-button v-show="components.length > 0" class="button" @click="openAll">
66
+ Search for data on components
67
+ </el-button>
68
+
69
+ <!-- Disable neuron search until it is ready -->
70
+ <!-- <el-button v-for="action in content.actions" round :key="action.title"
71
+ class="button" @click="resourceSelected(action)">
72
+ <i v-if="action.title === 'Search for datasets' || action.title === 'View Dataset' " class="el-icon-coin"></i>
73
+ {{action.title}}
74
+ </el-button> -->
75
+ <el-button v-if="pubmedSearchUrl" class="button" icon="el-icon-notebook-2" @click="openUrl(pubmedSearchUrl)">
76
+ Open publications in pubmed
77
+ </el-button>
78
+ </el-main>
79
+ </div>
80
+ </template>
81
+
82
+
83
+ <script>
84
+ /* eslint-disable no-alert, no-console */
85
+ import Vue from "vue";
86
+ import {
87
+ Button,
88
+ Container,
89
+ Header,
90
+ Icon,
91
+ Main
92
+ } from "element-ui";
93
+ import lang from "element-ui/lib/locale/lang/en";
94
+ import locale from "element-ui/lib/locale";
95
+ locale.use(lang);
96
+ Vue.use(Button);
97
+ Vue.use(Container);
98
+ Vue.use(Header);
99
+ Vue.use(Icon);
100
+ Vue.use(Main);
101
+
102
+ // pubmedviewer is currently not in use, but still under review so not ready to delete yet
103
+ import PubmedViewer from './PubmedViewer.vue'
104
+ import EventBus from './EventBus'
105
+
106
+ const titleCase = (str) => {
107
+ return str.replace(/\w\S*/g, (t) => { return t.charAt(0).toUpperCase() + t.substr(1).toLowerCase() });
108
+ }
109
+
110
+ const capitalise = function(str){
111
+ if (str)
112
+ return str.charAt(0).toUpperCase() + str.slice(1)
113
+ return ""
114
+ }
115
+
116
+ export default {
117
+ components: { PubmedViewer },
118
+ name: "Tooltip",
119
+ props: {
120
+ visible: {
121
+ type: Boolean,
122
+ default: false
123
+ },
124
+ content: {
125
+ type: Object,
126
+ default: undefined
127
+ },
128
+ },
129
+ data: function() {
130
+ return {
131
+ activeSpecies: undefined,
132
+ appendToBody: false,
133
+ pubmedSearchUrl: '',
134
+ loading: false,
135
+ destinations: [],
136
+ origins: [],
137
+ components: [],
138
+ destinationsWithDatasets: [],
139
+ originsWithDatasets: [],
140
+ originDescriptions: {
141
+ 'motor': 'is the location of the initial cell body of the circuit',
142
+ 'sensory': 'is the location of the initial cell body in the PNS circuit'
143
+ },
144
+ componentsWithDatasets: [],
145
+ uberons: [{id: undefined, name: undefined}]
146
+ };
147
+ },
148
+ inject: ['sparcAPI', 'flatmapAPI'],
149
+ watch: {
150
+ 'content.featureIds': {
151
+ handler: function(){
152
+ this.pathwayQuery(this.content.featureIds)
153
+ }
154
+ }
155
+ },
156
+ mounted: function(){
157
+ this.getOrganCuries()
158
+ },
159
+ computed: {
160
+ originDescription: function(){
161
+ if(this.content && this.content.title && this.content.title.toLowerCase().includes('motor')){
162
+ return this.originDescriptions.motor
163
+ } else {
164
+ return this.originDescriptions.sensory
165
+ }
166
+ }
167
+ },
168
+ methods: {
169
+ resourceSelected: function(action) {
170
+ this.$emit("resource-selected", action);
171
+ },
172
+ titleCase: function(title){
173
+ return titleCase(title)
174
+ },
175
+ capitalise: function(text){
176
+ return capitalise(text)
177
+ },
178
+ onClose: function() {
179
+ this.$emit("onClose")
180
+ },
181
+ openUrl: function(url){
182
+ window.open(url, '_blank')
183
+ },
184
+ openAll: function(){
185
+ EventBus.$emit('onActionClick', {type:'Facets', labels: this.components})
186
+ },
187
+ openAxons: function(){
188
+ EventBus.$emit('onActionClick', {type:'Facets', labels: this.destinationsWithDatasets.map(a=>a.name)})
189
+ },
190
+ openDendrites: function(){
191
+ EventBus.$emit('onActionClick', {type:'Facets', labels: this.originsWithDatasets.map(a=>a.name)})
192
+ },
193
+ pubmedSearchUrlUpdate: function (val){
194
+ this.pubmedSearchUrl = val
195
+ },
196
+ findComponents: function(connectivity){
197
+ let dnodes = connectivity.connectivity.flat() // get nodes from edgelist
198
+ let nodes = [...new Set(dnodes)] // remove duplicates
199
+
200
+ let found = []
201
+ let terminal = false
202
+ nodes.forEach(node=>{
203
+ let n = node.flat() // Find all terms on the node
204
+ terminal = false
205
+
206
+ // Check if the node is an destination or origin (note that they are labelled dendrite and axon as opposed to origin and destination)
207
+ n.forEach(s=>{
208
+ if(connectivity.axons.includes(s)){
209
+ terminal = true
210
+ }
211
+ if(connectivity.dendrites.includes(s)){
212
+ terminal = true
213
+ }
214
+ })
215
+ if (!terminal){
216
+ found.push(node)
217
+ }
218
+ })
219
+
220
+ // remove duplicates
221
+ let foundUnique = [...new Set(found.map(n=>n[0]))]
222
+ return foundUnique
223
+ },
224
+ getOrganCuries: function(){
225
+ fetch(`${this.sparcAPI}get-organ-curies/`)
226
+ .then(response=>response.json())
227
+ .then(data=>{
228
+ this.uberons = data.uberon.array
229
+ })
230
+ },
231
+ buildConnectivitySqlStatement: function(keastIds) {
232
+ let sql = 'select knowledge from knowledge where entity in ('
233
+ if (keastIds.length === 1) {
234
+ sql += `'${keastIds[0]}')`
235
+ } else if (keastIds.length > 1) {
236
+ for (let i in keastIds) {
237
+ sql += `'${keastIds[i]}'${i >= keastIds.length - 1 ? ')' : ','} `
238
+ }
239
+ }
240
+ return sql
241
+ },
242
+ buildLabelSqlStatement: function(uberons) {
243
+ let sql = 'select entity, label from labels where entity in ('
244
+ if (uberons.length === 1) {
245
+ sql += `'${uberons[0]}')`
246
+ } else if (uberons.length > 1) {
247
+ for (let i in uberons) {
248
+ sql += `'${uberons[i]}'${i >= uberons.length - 1 ? ')' : ','} `
249
+ }
250
+ }
251
+ return sql
252
+ },
253
+ createLabelLookup: function(uberons) {
254
+ return new Promise(resolve=> {
255
+ let uberonMap = {}
256
+ const data = { sql: this.buildLabelSqlStatement(uberons)}
257
+ fetch(`${this.flatmapAPI}knowledge/query/`, {
258
+ method: 'POST',
259
+ headers: {
260
+ 'Content-Type': 'application/json',
261
+ },
262
+ body: JSON.stringify(data),
263
+ })
264
+ .then(response => response.json())
265
+ .then(payload => {
266
+ const entity = payload.keys.indexOf("entity");
267
+ const label = payload.keys.indexOf("label");
268
+ if (entity > -1 && label > -1) {
269
+ payload.values.forEach(pair => {
270
+ uberonMap[pair[entity]] = pair[label];
271
+ });
272
+ }
273
+ resolve(uberonMap)
274
+ })
275
+ })
276
+ },
277
+ pathwayQuery: function(keastIds){
278
+ this.destinations = []
279
+ this.origins = []
280
+ this.components = []
281
+ this.loading = true
282
+ if (!keastIds || keastIds.length == 0) return
283
+ const data = { sql: this.buildConnectivitySqlStatement(keastIds)};
284
+ fetch(`${this.flatmapAPI}knowledge/query/`, {
285
+ method: 'POST',
286
+ headers: {
287
+ 'Content-Type': 'application/json',
288
+ },
289
+ body: JSON.stringify(data),
290
+ })
291
+ .then(response => response.json())
292
+ .then(data => {
293
+ let connectivity = JSON.parse(data.values[0][0])
294
+ let components = this.findComponents(connectivity)
295
+
296
+ // Create list of ids to get labels for
297
+ let conIds = connectivity.axons.concat(connectivity.dendrites.concat(components))
298
+ this.createLabelLookup(conIds).then(lookUp=>{
299
+ this.destinations = connectivity.axons.map(a=>lookUp[a])
300
+ this.origins = connectivity.dendrites.map(d=>lookUp[d])
301
+ this.components = components.map(c=>lookUp[c])
302
+ })
303
+
304
+ // Filter for the anatomy which is annotated on datasets
305
+ this.destinationsWithDatasets = this.uberons.filter(ub => connectivity.axons.indexOf(ub.id) !== -1)
306
+ this.originsWithDatasets = this.uberons.filter(ub => connectivity.dendrites.indexOf(ub.id) !== -1)
307
+ this.componentsWithDatasets = this.uberons.filter(ub => connectivity.dendrites.indexOf(ub.id) !== -1)
308
+ this.loading = false
309
+ })
310
+ .catch((error) => {
311
+ console.error('Error:', error);
312
+ })
313
+ }
314
+ }
315
+ };
316
+ </script>
317
+
318
+ <style scoped lang="scss">
319
+ @import "~element-ui/packages/theme-chalk/src/button";
320
+ @import "~element-ui/packages/theme-chalk/src/container";
321
+ @import "~element-ui/packages/theme-chalk/src/header";
322
+ @import "~element-ui/packages/theme-chalk/src/main";
323
+
324
+ .tooltip-container {
325
+ text-align:justify;
326
+ border-radius: 4px;
327
+ box-shadow: 0 1px 2px rgba(0,0,0,.1);
328
+ pointer-events: auto;
329
+ background: #fff;
330
+ border: 1px solid $app-primary-color;
331
+ display: flex;
332
+ justify-content: center;
333
+ align-items: center;
334
+ }
335
+
336
+ .display {
337
+ width: 44px;
338
+ word-break: normal;
339
+ }
340
+
341
+ .title {
342
+ text-align: left;
343
+ width: 16em;
344
+ line-height: 1.5em !important;
345
+ font-size: 1em;
346
+ font-family: Helvetica;
347
+ font-weight: 500;
348
+ /* font-weight: bold; */
349
+ padding-bottom: 8px;
350
+ }
351
+
352
+ .block {
353
+ margin-bottom: 1.5em;
354
+ }
355
+
356
+ .pub {
357
+ width: 16rem;
358
+ }
359
+
360
+ .icon {
361
+ right: 0px;
362
+ position: absolute;
363
+ top: 10px;
364
+ }
365
+
366
+ .icon:hover {
367
+ cursor: pointer;
368
+ }
369
+
370
+ .popover-origin-help {
371
+ text-transform: none !important; // need to overide the tooltip text transform
372
+ }
373
+
374
+ .info{
375
+ transform: rotate(180deg);
376
+ color: #8300bf;
377
+ margin-left: 8px;
378
+ }
379
+
380
+ .main {
381
+ font-size: 14px;
382
+ text-align: left;
383
+ line-height: 1.5em;
384
+ font-family: Helvetica;
385
+ font-weight: 400;
386
+ /* outline: thin red solid; */
387
+ padding: 1em !important;
388
+ overflow: hidden;
389
+ min-width: 16rem;
390
+ }
391
+
392
+ .title{
393
+ font-size: 18px;
394
+ font-weight: 500;
395
+ font-weight: bold;
396
+ padding-bottom: 8px;
397
+ color: rgb(131, 0, 191);
398
+
399
+ }
400
+
401
+ .attribute-title{
402
+ font-size: 16px;
403
+ font-weight: 600;
404
+ /* font-weight: bold; */
405
+ text-transform: uppercase;
406
+ }
407
+
408
+ .attribute-content{
409
+ font-size: 14px;
410
+ font-weight: 500;
411
+ }
412
+
413
+ .popover-container {
414
+ height: 100%;
415
+ width: 100%;
416
+ }
417
+
418
+ .main {
419
+ .el-button.is-round{
420
+ border-radius: 4px;
421
+ padding: 9px 20px 10px 20px;
422
+ display: flex;
423
+ height: 36px;
424
+ }
425
+ }
426
+
427
+ .button {
428
+ margin-left: 0px !important;
429
+ margin-top: 0px !important;
430
+ font-size: 14px !important;
431
+ background-color: $app-primary-color;
432
+ color: #fff;
433
+ &+.button {
434
+ margin-top: 10px !important;
435
+ }
436
+ &:hover {
437
+ color: #fff !important;
438
+ background: #ac76c5 !important;
439
+ border: 1px solid #ac76c5 !important;
440
+ }
441
+ }
442
+
443
+ .tooltip-container{
444
+ &::after, &::before {
445
+ content: '';
446
+ display: block;
447
+ position: absolute;
448
+ width: 0;
449
+ height: 0;
450
+ border-style: solid;
451
+ flex-shrink: 0;
452
+ }
453
+ }
454
+
455
+ .mapboxgl-popup-anchor-bottom {
456
+ .tooltip-container {
457
+ &::after, &::before {
458
+ top: 100%;
459
+ border-width: 12px;
460
+ }
461
+ &::after {
462
+ margin-top:-1px;
463
+ border-color: rgb(255, 255, 255) transparent transparent transparent ;
464
+ }
465
+ &::before {
466
+ margin: 0 auto;
467
+ border-color: $app-primary-color transparent transparent transparent ;
468
+ }
469
+ }
470
+ }
471
+
472
+ .mapboxgl-popup-anchor-top {
473
+ .tooltip-container {
474
+ &::after, &::before {
475
+ top: -24px;
476
+ border-width: 12px;
477
+ }
478
+ &::after {
479
+ margin-top: 1px;
480
+ border-color: transparent transparent rgb(255, 255, 255) transparent ;
481
+ }
482
+ &::before {
483
+ margin: 0 auto;
484
+ border-color: transparent transparent $app-primary-color transparent ;
485
+ }
486
+ }
487
+ }
488
+
489
+
490
+ /* Fix for chrome bug where under triangle pops up above one on top of it */
491
+ .selector:not(*:root), .tooltip-container::after{
492
+ top: 99.4%;
493
+ }
494
+ </style>