@abi-software/flatmapvuer 0.5.5-beta.0 → 0.5.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.
@@ -0,0 +1,231 @@
1
+ <template>
2
+ <div class="container">
3
+ <el-row>
4
+ <el-col :span="12">
5
+ <div class="title-text">
6
+ Systems
7
+ </div>
8
+ </el-col>
9
+ </el-row>
10
+ <div class="tree-container">
11
+ <el-tree
12
+ ref="tree"
13
+ node-key="key"
14
+ show-checkbox
15
+ :check-strictly="false"
16
+ :data="treeData"
17
+ :render-after-expand="false"
18
+ :default-expanded-keys="defaultExpandedKeys"
19
+ @check="checkChanged"
20
+ >
21
+ <span
22
+ slot-scope="{ node, data }"
23
+ class="region-tree-node"
24
+ :class="{
25
+ activeItem: nodeIsActive(data),
26
+ hoverItem: nodeIsHover(data),
27
+ }"
28
+ @click="changeActiveByNode(data)"
29
+ @mouseover="changeHoverByNode(data)"
30
+ >
31
+ <div :style="getBackgroundStyles(data)">
32
+ {{ node.label }}
33
+ </div>
34
+ </span>
35
+ </el-tree>
36
+ </div>
37
+ </div>
38
+ </template>
39
+
40
+ <script>
41
+ /* eslint-disable no-alert, no-console */
42
+ import Vue from "vue";
43
+ import { Checkbox, CheckboxGroup, ColorPicker, Row, Tree } from "element-ui";
44
+ import lang from "element-ui/lib/locale/lang/en";
45
+ import locale from "element-ui/lib/locale";
46
+ locale.use(lang);
47
+ Vue.use(Checkbox);
48
+ Vue.use(CheckboxGroup);
49
+ Vue.use(ColorPicker);
50
+ Vue.use(Row);
51
+ Vue.use(Tree);
52
+
53
+ /**
54
+ * A vue component for toggling visibility of various regions.
55
+ */
56
+ export default {
57
+ name: "TreeControls",
58
+ props: {
59
+ treeData: {
60
+ type: Array,
61
+ default: function () {
62
+ return [];
63
+ }
64
+ },
65
+ active: {
66
+ type: String,
67
+ default: ""
68
+ },
69
+ hover: {
70
+ type: String,
71
+ default: ""
72
+ }
73
+ },
74
+ data: function () {
75
+ return {
76
+ defaultExpandedKeys: ["All"],
77
+ };
78
+ },
79
+ destroyed: function () {
80
+ this.sortedPrimitiveGroups = undefined;
81
+ },
82
+ methods: {
83
+ nodeIsActive: function(data) {
84
+ return this.active === data.models;
85
+ },
86
+ nodeIsHover: function(data) {
87
+ return this.hover === data.models;
88
+ },
89
+ changeActiveByNode: function(data) {
90
+ if (data.models) {
91
+ this.$emit("change-active", data.models);
92
+ }
93
+ },
94
+ changeHoverByNode: function() {
95
+ //if (data.models) {
96
+ // this.$emit("change-active", data.models);
97
+ //}
98
+ },
99
+ checkChanged: function (node, data) {
100
+ const isChecked = data.checkedKeys.includes(node.key);
101
+ if (node.key === "All") {
102
+ this.$emit("checkAll", isChecked);
103
+ } else {
104
+ this.$emit("changed", {key: node.key, value: isChecked});
105
+ }
106
+ },
107
+ getBackgroundStyles: function(node) {
108
+ if ('colour' in node) {
109
+ return { background: node.colour };
110
+ }
111
+ return {};
112
+ },
113
+ },
114
+ };
115
+ </script>
116
+
117
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
118
+ <style scoped lang="scss">
119
+ @import "~element-ui/packages/theme-chalk/src/checkbox";
120
+ @import "~element-ui/packages/theme-chalk/src/row";
121
+ @import "~element-ui/packages/theme-chalk/src/tree";
122
+
123
+ .checkbox-container {
124
+ display: flex;
125
+ cursor: pointer;
126
+ }
127
+
128
+ .tree-controls {
129
+ position: absolute;
130
+ bottom: 0px;
131
+ transition: all 1s ease;
132
+
133
+ &:focus {
134
+ outline: none;
135
+ }
136
+ }
137
+
138
+ .container {
139
+ text-align: left;
140
+ overflow: none;
141
+ padding-top: 7px;
142
+ padding-bottom: 16px;
143
+ background: #ffffff;
144
+ }
145
+
146
+ .title-text {
147
+ width: 59px;
148
+ height: 20px;
149
+ color: rgb(48, 49, 51);
150
+ font-size: 14px;
151
+ font-weight: normal;
152
+ line-height: 20px;
153
+ margin-left: 8px;
154
+ }
155
+
156
+ .all-checkbox {
157
+ float: right;
158
+ }
159
+
160
+ .tree-container {
161
+ width: 260px;
162
+ border: 1px solid rgb(144, 147, 153);
163
+ border-radius: 4px;
164
+ background: #ffffff;
165
+ margin-top: 6px;
166
+ scrollbar-width: thin;
167
+
168
+ ::v-deep .el-tree {
169
+ max-height: 240px;
170
+ min-height: 130px;
171
+ overflow: auto;
172
+ &::-webkit-scrollbar {
173
+ width: 4px;
174
+ }
175
+
176
+ &::-webkit-scrollbar-thumb {
177
+ border-radius: 10px;
178
+ box-shadow: inset 0 0 6px #c0c4cc;
179
+ }
180
+ }
181
+
182
+ ::v-deep .el-tree-node__content {
183
+ height: 22px;
184
+ }
185
+ }
186
+
187
+ ::v-deep .el-checkbox__input {
188
+ &.is-indeterminate,
189
+ &.is-checked {
190
+ .el-checkbox__inner {
191
+ background-color: $app-primary-color;
192
+ border-color: $app-primary-color;
193
+ }
194
+ }
195
+ }
196
+
197
+ ::v-deep .el-tree-node__children .el-tree-node__children .el-tree-node__content > label.el-checkbox {
198
+ display: none;
199
+ }
200
+
201
+ ::v-deep .el-checkbox__label {
202
+ padding-left: 5px;
203
+ color: $app-primary-color !important;
204
+ font-size: 12px;
205
+ font-weight: 500;
206
+ letter-spacing: 0px;
207
+ line-height: 14px;
208
+ }
209
+
210
+ .activeItem {
211
+ background-color: #bbb !important;
212
+ }
213
+
214
+ .region-tree-node {
215
+ flex: 1;
216
+ color: $app-primary-color !important;
217
+ display: flex;
218
+ font-size: 12px;
219
+ line-height: 14px;
220
+ padding-left: 0px;
221
+ background-color: #fff;
222
+ width: 100%;
223
+
224
+ }
225
+
226
+ .hoverItem {
227
+ background-color: #eee !important;
228
+ }
229
+
230
+ </style>
231
+
@@ -15,7 +15,7 @@
15
15
  <text transform="matrix(0.9908 0 0 1 117.5474 171.7975)" class="st3 st4 st5" style="white-space: pre;">Specific anatomical structure</text>
16
16
  -->
17
17
  <text transform="matrix(0.9908 0 0 1 118.0903 345.5266)" class="st3 st4 st5" style="white-space: pre;">Ganglia</text>
18
- <text transform="matrix(0.9908 0 0 1 118.0903 433.1613)" class="st3 st4 st5" style="white-space: pre;">Nerve plexus</text>
18
+ <text transform="matrix(0.9908 0 0 1 118.0903 433.1613)" class="st3 st4 st5" style="white-space: pre;">Ganglionated nerve plexus</text>
19
19
  </svg>
20
20
  </div>
21
21
  </template>
@@ -4,6 +4,34 @@ const removeDuplicates = function(arrayOfAnything){
4
4
  return [...new Set(arrayOfAnything.map(e => JSON.stringify(e)))].map(e => JSON.parse(e))
5
5
  }
6
6
 
7
+ const cachedLabels = {};
8
+
9
+ const findTaxonomyLabel = async function(flatmapAPI, taxonomy){
10
+ if (cachedLabels && cachedLabels.hasOwnProperty(taxonomy)) {
11
+ return cachedLabels[taxonomy];
12
+ }
13
+
14
+ return new Promise(resolve=>{
15
+ fetch(`${flatmapAPI}knowledge/label/${taxonomy}`, {
16
+ method: 'GET',
17
+ })
18
+ .then(response => response.json())
19
+ .then(data => {
20
+ let label = data.label;
21
+ if (label === "Mammalia") {
22
+ label = "Mammalia not otherwise specified";
23
+ }
24
+ cachedLabels[taxonomy] = label;
25
+ resolve(label);
26
+ })
27
+ .catch((error) => {
28
+ console.error('Error:', error);
29
+ cachedLabels[taxonomy] = taxonomy;
30
+ resolve(taxonomy);
31
+ })
32
+ });
33
+ }
34
+
7
35
  const inArray = function(ar1, ar2){
8
36
  let as1 = JSON.stringify(ar1)
9
37
  let as2 = JSON.stringify(ar2)
@@ -24,13 +52,21 @@ let FlatmapQueries = function(){
24
52
  this.lookUp = []
25
53
  }
26
54
 
27
- this.createTooltipData = function (eventData) {
55
+ this.createTooltipData = async function (eventData) {
28
56
  let hyperlinks = []
29
57
  if (eventData.feature.hyperlinks && eventData.feature.hyperlinks.length > 0) {
30
58
  hyperlinks = eventData.feature.hyperlinks
31
59
  } else {
32
60
  hyperlinks = this.urls.map(url=>({url: url, id: "pubmed"}))
33
61
  }
62
+ let taxonomyLabel = undefined;
63
+ if (eventData.provenanceTaxonomy) {
64
+ taxonomyLabel = [];
65
+ for (let i = 0; eventData.provenanceTaxonomy.length > i; i++) {
66
+ taxonomyLabel.push(await findTaxonomyLabel(this.flatmapAPI, eventData.provenanceTaxonomy[i]))
67
+ }
68
+ }
69
+
34
70
  let tooltipData = {
35
71
  destinations: this.destinations,
36
72
  origins: this.origins,
@@ -41,6 +77,8 @@ let FlatmapQueries = function(){
41
77
  title: eventData.label,
42
78
  featureId: eventData.resource,
43
79
  hyperlinks: hyperlinks,
80
+ provenanceTaxonomy: eventData.provenanceTaxonomy,
81
+ provenanceTaxonomyLabel: taxonomyLabel
44
82
  }
45
83
  return tooltipData
46
84
  }
@@ -371,4 +409,4 @@ let FlatmapQueries = function(){
371
409
  }
372
410
  }
373
411
 
374
- export {FlatmapQueries}
412
+ export {FlatmapQueries, findTaxonomyLabel}