@abi-software/map-side-bar 2.7.3-beta.0 → 2.7.3-beta.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/map-side-bar",
3
- "version": "2.7.3-beta.0",
3
+ "version": "2.7.3-beta.1",
4
4
  "files": [
5
5
  "dist/*",
6
6
  "src/*",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@abi-software/gallery": "^1.1.2",
42
- "@abi-software/map-utilities": "^1.4.3-beta.3",
42
+ "@abi-software/map-utilities": "^1.5.0-beta.1",
43
43
  "@abi-software/svg-sprite": "^1.0.1",
44
44
  "@element-plus/icons-vue": "^2.3.1",
45
45
  "algoliasearch": "^4.10.5",
package/src/App.vue CHANGED
@@ -16,22 +16,22 @@
16
16
  <el-button @click="keywordSearch">keyword search</el-button>
17
17
  <el-button @click="getFacets">Get facets</el-button>
18
18
  <el-button @click="toggleCreateData">Create Data/Annotation</el-button>
19
+ <el-button @click="openConnectivitySearch()">Connectivity Search</el-button>
19
20
  </div>
20
21
  <SideBar
21
22
  :envVars="envVars"
22
23
  class="side-bar"
23
24
  ref="sideBar"
24
25
  :visible="sideBarVisibility"
25
- :tabs="tabs"
26
- :activeTabId="activeId"
27
26
  :annotationEntry="annotationEntry"
28
27
  :createData="createData"
29
- :connectivityInfo="connectivityInput"
30
- @tabClicked="tabClicked"
28
+ :connectivityEntry="connectivityEntry"
29
+ :connectivityKnowledge="connectivityKnowledge"
31
30
  @search-changed="searchChanged($event)"
32
31
  @hover-changed="hoverChanged($event)"
33
- @connectivity-component-click="onConnectivityComponentClick"
32
+ @connectivity-hovered="onConnectivityHovered"
34
33
  @actionClick="action"
34
+ @connectivity-explorer-clicked="onConnectivityExplorerClicked"
35
35
  />
36
36
  </div>
37
37
  </template>
@@ -43,8 +43,24 @@ import SideBar from './components/SideBar.vue'
43
43
  import EventBus from './components/EventBus.js'
44
44
  import exampleConnectivityInput from './exampleConnectivityInput.js'
45
45
 
46
+
46
47
  const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
47
48
 
49
+ const flatmapQuery = (flatmapApi, sql) => {
50
+ const data = { sql: sql };
51
+ return fetch(`${flatmapApi}knowledge/query/`, {
52
+ method: "POST",
53
+ headers: {
54
+ "Content-Type": "application/json",
55
+ },
56
+ body: JSON.stringify(data),
57
+ })
58
+ .then((response) => response.json())
59
+ .catch((error) => {
60
+ console.error("Error:", error);
61
+ });
62
+ };
63
+
48
64
  // let testContext = {
49
65
  // "description": "3D digital tracings of the enteric plexus obtained from seven subjects (M11, M16, M162, M163, M164, M168) are mapped randomly on mouse proximal colon. The data depicts individual neural wiring patterns in enteric microcircuits, and revealed both neuron and fiber units wired in a complex organization.",
50
66
  // "heading": "Digital tracings of enteric plexus",
@@ -94,27 +110,19 @@ export default {
94
110
  components: {
95
111
  SideBar,
96
112
  },
97
- computed: {
98
- tabs: function () {
99
- let temp = [...this.tabArray]
100
- for (let i in this.tabArray) {
101
- temp[i].contextCard = this.contextArray[i]
102
- }
103
- return temp
104
- },
113
+ provide() {
114
+ return {
115
+ $annotator: undefined,
116
+ userApiKey: undefined,
117
+ }
105
118
  },
106
119
  data: function () {
107
120
  return {
108
- annotationEntry: {
109
- featureId :"epicardium",
110
- resourceId: "https://mapcore-bucket1.s3-us-west-2.amazonaws.com/others/29_Jan_2020/heartICN_metadata.json","resource":"https://mapcore-bucket1.s3-us-west-2.amazonaws.com/others/29_Jan_2020/heartICN_metadata.json"
111
- },
112
- contextArray: [null, null],
113
- tabArray: [
114
- { title: 'Flatmap', id: 1, type: 'search'},
115
- { title: 'Connectivity', id: 2, type: 'connectivity' },
116
- { title: 'Annotation', id: 3, type: 'annotation' },
117
- ],
121
+ annotationEntry: [{
122
+ featureId: "epicardium",
123
+ resourceId: "https://mapcore-bucket1.s3-us-west-2.amazonaws.com/others/29_Jan_2020/heartICN_metadata.json",
124
+ "resource": "https://mapcore-bucket1.s3-us-west-2.amazonaws.com/others/29_Jan_2020/heartICN_metadata.json"
125
+ }],
118
126
  sideBarVisibility: true,
119
127
  envVars: {
120
128
  API_LOCATION: import.meta.env.VITE_APP_API_LOCATION,
@@ -127,8 +135,7 @@ export default {
127
135
  ROOT_URL: import.meta.env.VITE_APP_ROOT_URL,
128
136
  FLATMAPAPI_LOCATION: import.meta.env.VITE_FLATMAPAPI_LOCATION,
129
137
  },
130
- connectivityInput: exampleConnectivityInput,
131
- activeId: 1,
138
+ connectivityEntry: [],
132
139
  createData: {
133
140
  toBeConfirmed: false,
134
141
  points: [],
@@ -137,17 +144,66 @@ export default {
137
144
  y: 0,
138
145
  },
139
146
  createDataSet: false,
147
+ sckanVersion: 'sckan-2024-09-21-npo',
148
+ flatmapKnowledge: [],
149
+ connectivityKnowledge: [],
150
+ query: '',
151
+ filter: [],
152
+ target: [],
140
153
  }
141
154
  },
142
155
  methods: {
156
+ loadConnectivityKnowledge: async function () {
157
+ const sql = `select knowledge from knowledge
158
+ where source="${this.sckanVersion}"
159
+ order by source desc`;
160
+ const response = await flatmapQuery(this.envVars.FLATMAPAPI_LOCATION, sql);
161
+ const mappedData = response.values.map(x => x[0]);
162
+ const knowledge = mappedData.map(x => JSON.parse(x));
163
+ this.flatmapKnowledge = knowledge.filter((item) => {
164
+ if (item.source === this.sckanVersion && item.connectivity?.length) return true;
165
+ return false;
166
+ });
167
+ this.connectivityKnowledge = this.flatmapKnowledge;
168
+ },
169
+ connectivityQueryFilter: async function (payload) {
170
+ let results = this.flatmapKnowledge;
171
+ if (payload.type === "query-update") {
172
+ if (this.query !== payload.value) this.target = [];
173
+ this.query = payload.value;
174
+ } else if (payload.type === "filter-update") {
175
+ this.filter = payload.value;
176
+ this.target = [];
177
+ } else if (payload.type === "query-filter-update") {
178
+ this.query = payload.query;
179
+ this.filter = payload.filter;
180
+ this.target = payload.data;
181
+ }
182
+ if (this.query) {
183
+ let flag = "", order = [], paths = [];
184
+ const labels = ['neuron type aacar 11'];
185
+ flag = 'label';
186
+ order = labels;
187
+ if (labels.length === 1) {
188
+ paths =['ilxtr:neuron-type-aacar-11', 'ilxtr:neuron-type-bolew-unbranched-11'];
189
+ flag = 'id';
190
+ order = [this.query, ...paths.filter(item => item !== this.query)];
191
+ }
192
+ results = results.filter(item => paths.includes(item.id) || labels.includes(item.label));
193
+ results.sort((a, b) => order.indexOf(a[flag]) - order.indexOf(b[flag]));
194
+ }
195
+ this.connectivityKnowledge = results;
196
+ },
143
197
  hoverChanged: function (data) {
144
198
  console.log('hoverChanged', data)
145
199
  },
146
200
  searchChanged: function (data) {
147
- console.log(data)
148
- },
149
- tabClicked: function (tab) {
150
- this.activeId = tab.id
201
+ if (!this.flatmapKnowledge.length) {
202
+ this.loadConnectivityKnowledge();
203
+ }
204
+ if (data.id === 2) {
205
+ this.connectivityQueryFilter(data)
206
+ }
151
207
  },
152
208
  // For connectivity input actions
153
209
  action: function (action) {
@@ -280,11 +336,19 @@ export default {
280
336
  this.createDataSet = false
281
337
  }
282
338
  },
283
- onConnectivityComponentClick: function(data) {
284
- console.log("onConnectivityComponentClick" , data)
339
+ onConnectivityHovered: function(data) {
340
+ console.log("onConnectivityHovered" , data)
341
+ },
342
+ openConnectivitySearch: function (entry) {
343
+ const query = entry ? entry.query : 'ilxtr:neuron-type-aacar-5'
344
+ const filter = entry ? entry.filter : []
345
+ this.$refs.sideBar.openConnectivitySearch(filter, query)
346
+ },
347
+ onConnectivityExplorerClicked: function () {
348
+ this.connectivityEntry = [...exampleConnectivityInput]
285
349
  }
286
350
  },
287
- mounted: function () {
351
+ mounted: async function () {
288
352
  console.log('mounted app')
289
353
  EventBus.on('contextUpdate', (payLoad) => {
290
354
  console.log('contextUpdate', payLoad)
@@ -0,0 +1,21 @@
1
+ @import '_variables';
2
+
3
+ .pagination {
4
+ padding-bottom: 16px;
5
+ background-color: white;
6
+ font-weight: bold;
7
+ display: flex;
8
+ flex-direction: row;
9
+ align-items: center;
10
+ justify-content: center;
11
+ }
12
+
13
+ .pagination :deep(button) {
14
+ background-color: white !important;
15
+ }
16
+ .pagination :deep(li) {
17
+ background-color: white !important;
18
+ }
19
+ .pagination :deep(li.is-active) {
20
+ color: $app-primary-color;
21
+ }
@@ -65,7 +65,7 @@ export default {
65
65
  },
66
66
  props: {
67
67
  annotationEntry: {
68
- type: Object,
68
+ type: Array,
69
69
  },
70
70
  createData: {
71
71
  type: Object,
@@ -0,0 +1,93 @@
1
+ <template>
2
+ <div class="connectivity-card-container" ref="container">
3
+ <div class="connectivity-card" ref="card">
4
+ <div class="seperator-path"></div>
5
+ <div v-loading="loading" class="card" @click="cardClicked(entry)">
6
+ <div class="title">{{ capitalise(entry.label) }}</div>
7
+ <template v-for="field in displayFields" :key="field">
8
+ <div class="details" v-if="entry[field]">
9
+ <strong>{{ field }}:</strong> {{ entry[field] }}
10
+ </div>
11
+ </template>
12
+ </div>
13
+ </div>
14
+ </div>
15
+ </template>
16
+
17
+ <script>
18
+ export default {
19
+ name: "ConnectivityCard",
20
+ data() {
21
+ return {
22
+ displayFields: ["id"],
23
+ };
24
+ },
25
+ props: {
26
+ /**
27
+ * Object containing information for
28
+ * the required viewing.
29
+ */
30
+ entry: {
31
+ type: Object,
32
+ default: () => {},
33
+ },
34
+ },
35
+ computed: {
36
+ loading: function () {
37
+ // Only when click on overlay paths
38
+ if ("detailsReady" in this.entry) {
39
+ return !this.entry.detailsReady;
40
+ }
41
+ return false;
42
+ },
43
+ },
44
+ methods: {
45
+ capitalise: function (text) {
46
+ if (text) return text.charAt(0).toUpperCase() + text.slice(1);
47
+ return "";
48
+ },
49
+ cardClicked: function (data) {
50
+ if (!this.loading) {
51
+ this.$emit("connectivity-explorer-clicked", data);
52
+ }
53
+ },
54
+ },
55
+ };
56
+ </script>
57
+
58
+ <style lang="scss" scoped>
59
+ .connectivity-card {
60
+ padding-left: 5px;
61
+ position: relative;
62
+ min-height: 5rem;
63
+ }
64
+
65
+ .card {
66
+ padding-top: 18px;
67
+ padding-left: 6px;
68
+ cursor: pointer;
69
+ }
70
+
71
+ .title {
72
+ padding-bottom: 0.75rem;
73
+ font-weight: bold;
74
+ line-height: 1.5;
75
+ letter-spacing: 1.05px;
76
+ }
77
+
78
+ .details {
79
+ line-height: 1.5;
80
+ letter-spacing: 1.05px;
81
+ }
82
+
83
+ .button {
84
+ margin-right: 3.5rem;
85
+ font-family: Asap;
86
+ font-size: 14px;
87
+ font-weight: normal;
88
+ background-color: $app-primary-color;
89
+ border: $app-primary-color;
90
+ color: white;
91
+ margin-top: 8px;
92
+ }
93
+ </style>