/
App.vue
246 lines (232 loc) · 6.88 KB
/
App.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<template>
<div id="app">
<link rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Asap:400,400i,500,600,700&display=swap">
<div class="button-container">
<el-popover
placement="bottom"
trigger="click"
width=500
class="popover"
:teleported=false
>
<div class="options-container">
<el-row class="row" :gutter="20">
<el-button @click="saveSettings()" size="small">Save Settings</el-button>
<el-button @click="restoreSettings()" size="small">Restore Settings</el-button>
<el-button @click="getShareableURL()" size="small">Get Link</el-button>
</el-row>
<el-row class="row" :gutter="20">
<el-button @click="setMultiFlatmap()" size="small">Set MultiFlatmap</el-button>
<el-button @click="setLegacyMultiFlatmap()" size="small">Set Legacy MultiFlatmap</el-button>
<el-button @click="setScaffold()" size="small">Set To Scaffold</el-button>
<el-button @click="setFlatmap()" size="small">Set Flatmap</el-button>
<el-button @click="setSearch()" size="small">Set Search</el-button>
</el-row>
</div>
<template #reference>
<el-button class="options-button" :icon="ElIconSetting">Options</el-button>
</template>
</el-popover>
</div>
<div class="map-app">
<MapContent ref="map" :startingMap="startingMap" :options="options" :state="state" :shareLink="shareLink" @updateShareLinkRequested="updateUUID" @isReady="mapIsReady"/>
</div>
</div>
</template>
<script>
/* eslint-disable no-alert, no-console */
import { shallowRef } from 'vue';
import MapContent from './components/MapContent.vue';
import { Setting as ElIconSetting } from '@element-plus/icons-vue'
import {
ElButton as Button,
ElCol as Col,
ElPopover as Popover,
ElRow as Row,
} from 'element-plus';
export default {
name: 'app',
components: {
Button,
Col,
Popover,
Row,
MapContent,
},
data: function() {
return {
uuid: undefined,
state: undefined,
prefix: "/map",
api: import.meta.env.VITE_API_LOCATION,
mapSettings: [],
startingMap: "AC",
ElIconSetting: shallowRef(ElIconSetting)
}
},
computed: {
shareLink: function() {
if (this.uuid)
return this.prefix +"?id=" + this.uuid;
return this.prefix;
},
options: function() {
return {
sparcApi: import.meta.env.VITE_API_LOCATION,
algoliaIndex: import.meta.env.VITE_ALGOLIA_INDEX,
algoliaKey: import.meta.env.VITE_ALGOLIA_KEY,
algoliaId: import.meta.env.VITE_ALGOLIA_ID,
pennsieveApi: import.meta.env.VITE_PENNSIEVE_API_LOCATION,
flatmapAPI: import.meta.env.VITE_FLATMAPAPI_LOCATION,
nlLinkPrefix: import.meta.env.VITE_NL_LINK_PREFIX,
rootUrl: import.meta.env.VITE_ROOT_URL,
userToken: undefined,
}
}
},
methods: {
saveSettings: function() {
this.mapSettings.push(this.$refs.map.getState());
},
restoreSettings: function() {
if (this.mapSettings.length > 0)
this.$refs.map.setState(this.mapSettings.pop());
},
updateUUID: function() {
let xmlhttp = new XMLHttpRequest();
let url = this.api + 'map/getshareid';
let state = this.$refs.map.getState();
xmlhttp.open('POST', url, true);
//Send the proper header information along with the request
xmlhttp.setRequestHeader('Content-type', 'application/json');
xmlhttp.onreadystatechange = () => {//Call a function when the state changes.
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
let state = JSON.parse(xmlhttp.responseText);
this.uuid = state.uuid;
}
}
xmlhttp.send(JSON.stringify({"state": state}));
},
setFlatmap: function() {
this.$refs.map.setCurrentEntry(
{
type: "Flatmap",
resource: "FunctionalConnectivity",
label: "Functional"
}
);
},
setLegacyMultiFlatmap: function() {
this.$refs.map.setCurrentEntry(
{
type: "MultiFlatmap",
taxo: "NCBITaxon:10114",
uuid: "01fedbf9-d783-509c-a10c-827941ab13da",
}
);
},
setMultiFlatmap: function() {
this.$refs.map.setCurrentEntry(
{
type: "MultiFlatmap",
taxo: "NCBITaxon:9606",
biologicalSex: "PATO:0000384",
//organ: "heart"
organ: "UBERON:0018675"
}
);
},
setScaffold: function() {
this.$refs.map.setCurrentEntry(
{
type: "Scaffold",
label: "Colon",
url: "https://mapcore-demo.org/current/sparc-api-v2/s3-resource/221/3/files/derivative/Scaffolds/mouse_colon_metadata.json",
viewUrl: "M16_view.json"
}
);
},
setSearch: function() {
this.$refs.map.openSearch([], "10.26275/1uno-tynt");
},
mapIsReady: function() {
console.log("map is ready")
},
parseQuery: function () {
this.$router.isReady().then(() => {
this.uuid = this.$route.query.id;
if (window) {
this.prefix = window.location.origin + window.location.pathname;
}
if (this.uuid) {
let xmlhttp = new XMLHttpRequest();
let url = this.api + 'map/getstate';
xmlhttp.open('POST', url, true);
//Send the proper header information along with the request
xmlhttp.setRequestHeader('Content-type', 'application/json');
xmlhttp.onreadystatechange = () => {//Call a function when the state changes.
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
let state = JSON.parse(xmlhttp.responseText);
this.state = state.state;
}
}
xmlhttp.send(JSON.stringify({"uuid": this.uuid}));
}
})
},
},
mounted: function() {
this.parseQuery();
},
}
</script>
<style lang="scss">
#app {
height:100%;
width: 100%;
position:absolute;
font-family: "Asap",sans-serif;
--el-color-primary: #8300BF;
--el-color-primary-light-7: #dab3ec;
--el-color-primary-light-8: #e6ccf2;
--el-color-primary-light-9: #f3e6f9;
}
body {
margin: 0px;
}
.map-app {
position:absolute;
height: calc(100% - 104px);
width:calc(100% - 54px);
margin-top:20px;
margin-left:26px;
margin-right:26px;
border: solid 1px #dcdfe6;
box-shadow: 0 1px 8px 0 rgba(0, 0, 0, 0.06);
}
.popover{
top:10px;
right:50%;
position:absolute;
z-index:1000;
}
.row {
margin-bottom: 5px;
&:last-child {
margin-bottom: 0;
}
}
.button-container {
display: flex;
align-items: center;
justify-content: center;
height:50px;
}
.options-container{
text-align: center;
}
.map-icon {
color: $app-primary-color!important;
}
</style>