@abi-software/flatmapvuer 0.2.5-upstream-downstream → 0.2.5

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