@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,202 +1,181 @@
1
- <template>
2
- <div class="pubmed-container">
3
- <div v-loading="loading.response" class="block">
4
- <div class="attribute-title">Pubmed Resources</div>
5
- <br/>
6
- <el-carousel
7
- :autoplay="false"
8
- indicator-position="outside"
9
- height="250px" width="200px"
10
- >
11
- <el-carousel-item v-for="(pub, i) in pubmeds" :key="i">
12
- <div class="attribute-content">
13
- <div v-html="pub.html"/>
14
- <el-link :href="pub.url" :underline="false" class="el-link" target="_blank">{{pub.url}}</el-link>
15
- </div>
16
- </el-carousel-item>
17
- </el-carousel>
18
- </div>
19
- </div>
20
- </template>
21
-
22
-
23
- <script>
24
- /* eslint-disable no-alert, no-console */
25
- import Vue from "vue";
26
- import {
27
- Link,
28
- Carousel,
29
- CarouselItem,
30
- Button
31
- } from "element-ui";
32
- import lang from "element-ui/lib/locale/lang/en";
33
- import locale from "element-ui/lib/locale";
34
- locale.use(lang);
35
- Vue.use(Link);
36
- Vue.use(Carousel);
37
- Vue.use(CarouselItem);
38
- Vue.use(Button);
39
-
40
-
41
- export default {
42
- name: "Tooltip",
43
- props: {
44
- /**
45
- * Specify the endpoint of the flatmap server.
46
- */
47
- flatmapAPI: {
48
- type: String,
49
- default: 'https://mapcore-demo.org/current/flatmap/v2/'
50
- },
51
- entry: {
52
- type: Object,
53
- default: () => {}
54
- },
55
- },
56
- watch: {
57
- 'entry.featureId': function (val){
58
- this.flatmapQuery(val).then(pb => this.pubmeds = pb)
59
- },
60
- 'entry.featureIds': {
61
- handler: function(ids) {
62
- this.flatmapQuery(ids)
63
- }
64
- }
65
- },
66
- data: function() {
67
- return {
68
- data: {},
69
- pubmeds: [],
70
- pubmedIds: [],
71
- loading: {response: true, publications: true}
72
- };
73
- },
74
- mounted: function() {
75
- if (this.entry.featureIds)
76
- this.flatmapQuery(this.entry.featureIds)
77
- },
78
- methods: {
79
- stripPMIDPrefix: function (pubmedId){
80
- return pubmedId.split(':')[1]
81
- },
82
- titleFromPubmed: function (pubmedId){
83
- return new Promise((resolve) => {
84
- fetch(`https://api.ncbi.nlm.nih.gov/lit/ctxp/v1/pubmed/?format=citation&contenttype=json&id=${pubmedId}`)
85
- .then(response => response.json())
86
- .then(data => {
87
- resolve(data.apa.format)
88
- })
89
- .catch((error) => {
90
- console.error('Error:', error);
91
- });
92
- })
93
- },
94
- splitLink(bibliographyString){
95
- let split = bibliographyString.split('https')
96
- return [split[0], 'https' + split[1]]
97
- },
98
- buildPubmedSqlStatement: function(keastIds) {
99
- let sql = 'select distinct publication from publications where entity in ('
100
- if (keastIds.length === 1) {
101
- sql += `'${keastIds[0]}')`
102
- } else if (keastIds.length > 1) {
103
- for (let i in keastIds) {
104
- sql += `'${keastIds[i]}'${i >= keastIds.length - 1 ? ')' : ','} `
105
- }
106
- }
107
- return sql
108
- },
109
- flatmapQuery: function(keastIds){
110
- if(!keastIds || keastIds.length === 0) return
111
- this.pubmeds = []
112
- this.loading.response = true
113
-
114
- // fetch pubmed publications for the given ids
115
- const data = { sql: this.buildPubmedSqlStatement(keastIds)};
116
- console.log(data)
117
- fetch(`${this.flatmapAPI}knowledge/query/`, {
118
- method: 'POST',
119
- headers: {
120
- 'Content-Type': 'application/json',
121
- },
122
- body: JSON.stringify(data),
123
- })
124
- .then(response => response.json())
125
- .then(data => {
126
- this.responseData = data
127
- this.loading.response = false
128
-
129
- // create links for each pubmedId
130
- data.values.forEach(identifier => {
131
- let ids = this.stripPMIDPrefix(identifier[0])
132
- this.titleFromPubmed(ids).then( bib=>{
133
- let [html, link] = this.splitLink(bib)
134
- this.pubmeds.push({identifier: identifier[0] , html: html, url: link})
135
- })
136
- });
137
- this.$emit('pubmedSearchUrl', this.pubmedSearchUrl(data.values.map(id=>this.stripPMIDPrefix(id[0]))))
138
- })
139
- .catch((error) => {
140
- console.error('Error:', error);
141
- })
142
- },
143
- pubmedSearchUrl: function(ids) {
144
- let url = 'https://pubmed.ncbi.nlm.nih.gov/?'
145
- let params = new URLSearchParams()
146
- params.append('term', ids)
147
- return url + params.toString()
148
- }
149
- }
150
- };
151
- </script>
152
-
153
- <style scoped lang="scss">
154
- @import "~element-ui/packages/theme-chalk/src/link";
155
- @import "~element-ui/packages/theme-chalk/src/carousel";
156
- @import "~element-ui/packages/theme-chalk/src/carousel-item";
157
-
158
- .attribute-title{
159
- font-size: 16px;
160
- font-weight: 600;
161
- /* font-weight: bold; */
162
- text-transform: uppercase;
163
- }
164
-
165
- .attribute-content{
166
- font-size: 14px;
167
- font-weight: 400;
168
- }
169
-
170
- .el-link {
171
- color: $app-primary-color;
172
- text-decoration: none;
173
- word-wrap: break-word;
174
- &:hover, &:focus{
175
- color: $app-primary-color;
176
- text-decoration: underline;
177
- }
178
- }
179
-
180
- ::v-deep .el-carousel__button {
181
- background-color: $app-primary-color;
182
- }
183
-
184
- .button {
185
- margin-left: 0px !important;
186
- margin-top: 0px !important;
187
- font-size: 14px !important;
188
- background-color: $app-primary-color;
189
- color: #fff;
190
- &:hover{
191
- color: #fff !important;
192
- background: #ac76c5 !important;
193
- border: 1px solid #ac76c5 !important;
194
- }
195
- &+.button {
196
- margin-top: 10px !important;
197
- background-color: $app-primary-color;
198
- color: #fff;
199
- }
200
- }
201
-
1
+ <template>
2
+ <div class="pubmed-container">
3
+ <div v-loading="loading.response" class="block">
4
+ <div class="attribute-title">Pubmed Resources</div>
5
+ <br/>
6
+ <el-carousel
7
+ :autoplay="false"
8
+ indicator-position="outside"
9
+ height="250px" width="200px"
10
+ >
11
+ <el-carousel-item v-for="(pub, i) in pubmeds" :key="i">
12
+ <div class="attribute-content">
13
+ <div v-html="pub.html"/>
14
+ <el-link :href="pub.url" :underline="false" class="el-link" target="_blank">{{pub.url}}</el-link>
15
+ </div>
16
+ </el-carousel-item>
17
+ </el-carousel>
18
+ </div>
19
+ </div>
20
+ </template>
21
+
22
+
23
+ <script>
24
+ /* eslint-disable no-alert, no-console */
25
+ import Vue from "vue";
26
+ import {
27
+ Link,
28
+ Carousel,
29
+ CarouselItem
30
+ } from "element-ui";
31
+ import lang from "element-ui/lib/locale/lang/en";
32
+ import locale from "element-ui/lib/locale";
33
+ locale.use(lang);
34
+ Vue.use(Link);
35
+ Vue.use(Carousel);
36
+ Vue.use(CarouselItem);
37
+
38
+
39
+ export default {
40
+ name: "Tooltip",
41
+ props: {
42
+ featureId: {
43
+ type: String,
44
+ default: ''
45
+ },
46
+ /**
47
+ * Specify the endpoint of the flatmap server.
48
+ */
49
+ flatmapAPI: {
50
+ type: String,
51
+ default: "https://mapcore-demo.org/flatmaps/"
52
+ }
53
+ },
54
+ watch: {
55
+ 'featureId': function (val){
56
+ console.log('feature id watch triggered', val)
57
+ this.flatmapQuery(val)
58
+ }
59
+ },
60
+ computed: {
61
+ },
62
+ data: function() {
63
+ return {
64
+ pubmeds: [],
65
+ pubmedIds: [],
66
+ loading: {response: true, publications: true}
67
+ };
68
+ },
69
+ mounted: function() {
70
+ this.flatmapQuery(this.featureId)
71
+ },
72
+ methods: {
73
+ stripPMIDPrefix: function (pubmedId){
74
+ return pubmedId.split(':')[1]
75
+ },
76
+ titleFromPubmed: function (pubmedId){
77
+ return new Promise((resolve) => {
78
+ fetch(`https://api.ncbi.nlm.nih.gov/lit/ctxp/v1/pubmed/?format=citation&contenttype=json&id=${pubmedId}`)
79
+ .then(response => response.json())
80
+ .then(data => {
81
+ resolve(data.apa.format)
82
+ })
83
+ .catch((error) => {
84
+ console.error('Error:', error);
85
+ });
86
+ })
87
+ },
88
+ splitLink(bibliographyString){
89
+ let split = bibliographyString.split('https')
90
+ return [split[0], 'https' + split[1]]
91
+ },
92
+ flatmapQuery: function(identifier){
93
+ this.pubmeds = []
94
+ this.loading.response = true
95
+ let endpoint = this.flatmapAPI + 'knowledge/query/';
96
+ const data = { sql: 'select publication from publications where entity=?', "params": [identifier]};
97
+ fetch(endpoint, {
98
+ method: 'POST',
99
+ headers: {
100
+ 'Content-Type': 'application/json',
101
+ },
102
+ body: JSON.stringify(data),
103
+ })
104
+ .then(response => response.json())
105
+ .then(data => {
106
+ this.responseData = data
107
+ this.loading.response = false
108
+ data.values.forEach(identifier => {
109
+ let ids = this.stripPMIDPrefix(identifier[0])
110
+ this.titleFromPubmed(ids).then( bib=>{
111
+ let [html, link] = this.splitLink(bib)
112
+ this.pubmeds.push({identifier: identifier[0] , html: html, url: link})
113
+
114
+ })
115
+ });
116
+ this.$emit('pubmedSearchUrl', this.pubmedSearchUrl(data.values.map(id=>this.stripPMIDPrefix(id[0]))))
117
+ })
118
+ .catch((error) => {
119
+ console.error('Error:', error);
120
+ });
121
+ },
122
+ pubmedSearchUrl: function(ids) {
123
+ let url = 'https://pubmed.ncbi.nlm.nih.gov/?'
124
+ let params = new URLSearchParams()
125
+ params.append('term', ids)
126
+ return url + params.toString()
127
+ }
128
+ }
129
+ };
130
+ </script>
131
+
132
+ <style scoped lang="scss">
133
+ @import "~element-ui/packages/theme-chalk/src/link";
134
+ @import "~element-ui/packages/theme-chalk/src/carousel";
135
+ @import "~element-ui/packages/theme-chalk/src/carousel-item";
136
+
137
+ .attribute-title{
138
+ font-size: 16px;
139
+ font-weight: 600;
140
+ /* font-weight: bold; */
141
+ text-transform: uppercase;
142
+ }
143
+
144
+ .attribute-content{
145
+ font-size: 14px;
146
+ font-weight: 400;
147
+ }
148
+
149
+ .el-link {
150
+ color: $app-primary-color;
151
+ text-decoration: none;
152
+ word-wrap: break-word;
153
+ &:hover, &:focus{
154
+ color: $app-primary-color;
155
+ text-decoration: underline;
156
+ }
157
+ }
158
+
159
+ ::v-deep .el-carousel__button {
160
+ background-color: $app-primary-color;
161
+ }
162
+
163
+ .button {
164
+ margin-left: 0px !important;
165
+ margin-top: 0px !important;
166
+ font-size: 14px !important;
167
+ background-color: $app-primary-color;
168
+ color: #fff;
169
+ &:hover{
170
+ color: #fff !important;
171
+ background: #ac76c5 !important;
172
+ border: 1px solid #ac76c5 !important;
173
+ }
174
+ &+.button {
175
+ margin-top: 10px !important;
176
+ background-color: $app-primary-color;
177
+ color: #fff;
178
+ }
179
+ }
180
+
202
181
  </style>