@abi-software/map-side-bar 2.7.0 → 2.7.1-isan.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.
@@ -0,0 +1,108 @@
1
+ <script>
2
+ // The functions below are needed because the number of results shown on the page is dependent what is available from each index.
3
+ // We fix this by calcuting how many results we have shown before the requested page and then calculating the offset based on that.
4
+
5
+ // Note that this.RatioOfPMRResults is a number that determines how many PMR results are shown compared to SPARC results. It is grabbed from a constant in
6
+ // SidebarContent.vue.
7
+
8
+ export default {
9
+ data: function () {
10
+ return {
11
+ variableRatio: 0.2
12
+ }
13
+ },
14
+ methods: {
15
+
16
+ // Calculate Variable Ratio is used as a number to determine how the ratio of PMR results to SPARC results
17
+ // will be shown on the page. 1 means only PMR results, 0 means only SPARC results.
18
+ calculateVariableRatio: function () {
19
+ if (this.page === 1) {
20
+ this.variableRatio = this.RatioOfPMRResults
21
+
22
+ // Check if we have run out of Sparc results
23
+ } else if( this.npp_SPARC * (this.page -1) >= this.sparcNumberOfHits) {
24
+ this.variableRatio = 1
25
+
26
+ // Check if we have run out of PMR results
27
+ } else if(this.npp_PMR * (this.page - 1) >= this.pmrNumberOfHits) {
28
+ this.variableRatio = 0
29
+ } else {
30
+
31
+ // Set the ratio to the same as the previous page if both indeces have results
32
+ this.variableRatio = this.RatioOfPMRResults
33
+ }
34
+ },
35
+
36
+ // calculatePMROffest is used to calculate how many PMR results we have shown before the requested page
37
+ calculatePMROffest: function() {
38
+
39
+ console.log(this.variableRatio, this.RatioOfPMRResults)
40
+ // If variable ratio has not changed, we have not run out of results.
41
+ // we can use the the number per page PMR to calculate the offset
42
+ if (this.variableRatio === this.RatioOfPMRResults) {
43
+ return (this.page-1)*this.npp_PMR
44
+
45
+ // If we have run out of SPARC results, we need to calculate how many PMR results we have shown before the requested page
46
+ } else if (this.variableRatio === 1) {
47
+
48
+ // calculate how many results we showed before the requested page
49
+ // We want our offset to be the number of PMR results shown before the requested page
50
+ // This can be though of as numberOfPMRResultsShownInMixed + numberOfPMRResultsShownInPMROnly = offset
51
+ let pageWhereSPARCResultsRanOut = Math.ceil(this.sparcNumberOfHits / this.npp_SPARC)
52
+ let numberOfPMRResultsShownInMixed = this.npp_PMR * pageWhereSPARCResultsRanOut
53
+ let numberOfPMRResultsShownInPMROnly = (this.page - 1 - pageWhereSPARCResultsRanOut) * this.numberPerPage
54
+ return numberOfPMRResultsShownInMixed + numberOfPMRResultsShownInPMROnly
55
+ }
56
+ },
57
+
58
+ // calculateSPARCOffest is used to calculate how many SPARC results we have shown before the requested page. See above for details
59
+ calculateSPARCOffest: function() {
60
+ if(this.variableRatio === this.RatioOfPMRResults) {
61
+ return (this.page-1)*this.npp_SPARC
62
+ } else if (this.variableRatio === 0) {
63
+
64
+ // calculate how many results we showed before the requested page
65
+ let pageWherePMRResultsRanOut = Math.ceil(this.pmrNumberOfHits / this.npp_PMR)
66
+ let numberOfSPARCResultsShownInMixed = this.npp_SPARC * pageWherePMRResultsRanOut
67
+ let numberOfSPARCResultsShownInSPARCOnly = (this.page - 1 - pageWherePMRResultsRanOut) * this.numberPerPage
68
+ let offset = numberOfSPARCResultsShownInMixed + numberOfSPARCResultsShownInSPARCOnly
69
+ return offset
70
+ }
71
+ },
72
+
73
+ // PMRLimit is used to calculate how many PMR results we can show on the page.
74
+ PMRLimit: function(pmrResultsOnlyFlag=false) {
75
+ // If we only want PMR results, return the number per page
76
+ if (pmrResultsOnlyFlag) {
77
+ return this.numberPerPage
78
+ }
79
+ // If the variable ratio is the same as the ratio of PMR results, return the number per page set for PMR
80
+ if (this.variableRatio === this.RatioOfPMRResults) {
81
+ return this.npp_PMR
82
+
83
+ // if we have run out of sparc results, we want to show pmr results equal to the total number of results per page
84
+ } else if (this.variableRatio === 1) {
85
+ return this.numberPerPage
86
+
87
+ // if we have run out of pmr results, we want to show 0 pmr results
88
+ } else if (this.variableRatio === 0) {
89
+ return 0
90
+ }
91
+ },
92
+ SPARCLimit: function(pmrResultsOnlyFlag=false) {
93
+ if(pmrResultsOnlyFlag) {
94
+ return 0
95
+ }
96
+ if (this.variableRatio === this.RatioOfPMRResults) {
97
+ return this.npp_SPARC
98
+ } else if (this.variableRatio === 0) {
99
+ return this.numberPerPage
100
+ } else if (this.variableRatio === 1) {
101
+ return 0
102
+ }
103
+ },
104
+ }
105
+ };
106
+ </script>
107
+
108
+
@@ -1,163 +0,0 @@
1
- <template>
2
- <div class="dataset-card-container" ref="container">
3
- <div class="dataset-card" ref="card">
4
- <div class="seperator-path"></div>
5
- <div class="card"
6
- @click="cardClicked(entry)"
7
- @mouseover="cardHovered(entry)"
8
- @mouseleave="cardHovered(undefined)"
9
- >
10
- <div class="card-right">
11
- <div class="title">{{ entry.label }}</div>
12
- <template v-for="field in displayFields" :key="field">
13
- <div class="details" v-if="entry[field]">
14
- <strong>{{ field }}:</strong> {{ entry[field] }}
15
- </div>
16
- </template>
17
- </div>
18
- </div>
19
- </div>
20
- </div>
21
- </template>
22
-
23
- <script>
24
- import EventBus from './EventBus.js'
25
- /* eslint-disable no-alert, no-console */
26
-
27
- export default {
28
- data() {
29
- return {
30
- displayFields: [
31
- "label",
32
- "id",
33
- ]
34
- }
35
- },
36
- name: 'ConnectivityCard',
37
- props: {
38
- /**
39
- * Object containing information for
40
- * the required viewing.
41
- */
42
- entry: {
43
- type: Object,
44
- default: () => {},
45
- },
46
- },
47
- methods: {
48
- cardClicked: function (data) {
49
- EventBus.emit('connectivity-clicked', data);
50
- },
51
- cardHovered: function (data) {
52
- EventBus.emit('connectivity-hovered', data);
53
- },
54
- }
55
- }
56
- </script>
57
-
58
- <style lang="scss" scoped>
59
- .dataset-card {
60
- padding-left: 5px;
61
- padding-right: 5px;
62
- position: relative;
63
- min-height: 17rem;
64
- }
65
-
66
- .title {
67
- padding-bottom: 0.75rem;
68
- font-family: Asap;
69
- font-size: 14px;
70
- font-weight: bold;
71
- font-stretch: normal;
72
- font-style: normal;
73
- line-height: 1.5;
74
- letter-spacing: 1.05px;
75
- color: #484848;
76
- cursor: pointer;
77
- }
78
- .card {
79
- padding-top: 18px;
80
- position: relative;
81
- display: flex;
82
- }
83
-
84
- .card-left {
85
- flex: 1;
86
- }
87
-
88
- .card-right {
89
- flex: 1.3;
90
- padding-left: 6px;
91
- }
92
-
93
- .button {
94
- z-index: 10;
95
- font-family: Asap;
96
- font-size: 14px;
97
- font-weight: normal;
98
- font-stretch: normal;
99
- font-style: normal;
100
- line-height: normal;
101
- letter-spacing: normal;
102
- background-color: $app-primary-color;
103
- border: $app-primary-color;
104
- color: white;
105
- cursor: pointer;
106
- margin-top: 8px;
107
- }
108
-
109
- .button:hover {
110
- background-color: $app-primary-color;
111
- color: white;
112
- }
113
-
114
- .banner-img {
115
- width: 128px;
116
- height: 128px;
117
- box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.25);
118
- background-color: #ffffff;
119
- cursor: pointer;
120
- }
121
- .details {
122
- font-family: Asap;
123
- font-size: 14px;
124
- font-weight: normal;
125
- font-stretch: normal;
126
- font-style: normal;
127
- line-height: 1.5;
128
- letter-spacing: 1.05px;
129
- color: #484848;
130
- }
131
-
132
- .badges-container {
133
- margin-top: 0.75rem;
134
- }
135
-
136
- .loading-icon {
137
- z-index: 20;
138
- width: 40px;
139
- height: 40px;
140
- left: 80px;
141
- }
142
-
143
- .loading-icon :deep(.el-loading-mask) {
144
- background-color: rgba(117, 190, 218, 0) !important;
145
- }
146
-
147
- .loading-icon :deep(.el-loading-spinner .path) {
148
- stroke: $app-primary-color;
149
- }
150
-
151
- .float-button-container {
152
- position: absolute;
153
- bottom: 8px;
154
- right: 16px;
155
- opacity: 0;
156
- visibility: hidden;
157
-
158
- .card:hover & {
159
- opacity: 1;
160
- visibility: visible;
161
- }
162
- }
163
- </style>
@@ -1,352 +0,0 @@
1
- <template>
2
- <div v-if="flatmapKnowledge" class="main">
3
- <div class="header">
4
- <el-input
5
- class="search-input"
6
- placeholder="Search"
7
- v-model="searchInput"
8
- @keyup="search(searchInput)"
9
- clearable
10
- @clear="clearSearchClicked"
11
- ></el-input>
12
- <el-button
13
- v-show="false"
14
- type="primary"
15
- class="button"
16
- @click="search(searchInput)"
17
- size="large"
18
- >
19
- Search
20
- </el-button>
21
- </div>
22
- <div class="content scrollbar" ref="content">
23
- <div v-for="result in paginatedResults" :key="result.id" class="step-item">
24
- <connectivity-card
25
- class="dataset-card"
26
- :entry="result"
27
- @mouseenter="hoverChanged(result)"
28
- @mouseleave="hoverChanged(undefined)"
29
- />
30
- </div>
31
- <el-pagination
32
- class="pagination"
33
- v-model:current-page="page"
34
- hide-on-single-page
35
- large
36
- layout="prev, pager, next"
37
- :page-size="numberPerPage"
38
- :total="numberOfHits"
39
- @current-change="pageChange"
40
- ></el-pagination>
41
- </div>
42
- </div>
43
- </template>
44
-
45
-
46
-
47
- <script>
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
-
64
- const filterKnowledge = (knowledge, sckanVersion) => {
65
- const result = knowledge.filter((item) => {
66
- if (item?.source && item.source === sckanVersion) {
67
- if ("connectivity" in item) {
68
- return true
69
- }
70
- }
71
- return false
72
- })
73
- return result
74
- }
75
-
76
-
77
- /* eslint-disable no-alert, no-console */
78
- import {
79
- ElButton as Button,
80
- ElCard as Card,
81
- ElDrawer as Drawer,
82
- ElIcon as Icon,
83
- ElInput as Input,
84
- ElPagination as Pagination,
85
- } from 'element-plus'
86
- import ConnectivityCard from './ConnectivityCard.vue'
87
-
88
- export default {
89
- components: {
90
- ConnectivityCard,
91
- Button,
92
- Card,
93
- Drawer,
94
- Icon,
95
- Input,
96
- Pagination
97
- },
98
- name: 'ConnectivityExplorer',
99
- props: {
100
- sckanVersion: {
101
- type: String,
102
- default: "sckan-2024-09-21-npo",
103
- },
104
- envVars: {
105
- type: Object,
106
- default: () => {},
107
- },
108
- },
109
- data: function () {
110
- return {
111
- mapServer: "",
112
- flatmapKnowledge: [],
113
- results: [],
114
- paginatedResults: [],
115
- searchInput: "",
116
- lastSearch: "",
117
- numberOfHits: 0,
118
- numberPerPage: 10,
119
- page: 1,
120
- previousSearch: undefined
121
- }
122
- },
123
- methods: {
124
- hoverChanged: function (data) {
125
- this.$emit('hover-changed', data)
126
- },
127
- resetSearch: function () {
128
- this.numberOfHits = 0
129
- this.search(this.searchInput)
130
- },
131
- clearSearchClicked: function () {
132
- this.searchInput = '';
133
- this.search("");
134
- },
135
- search: function(input) {
136
- this.results = []
137
- if (input !== this.previousSearch) {
138
- if (input === "") {
139
- this.results = this.flatmapKnowledge
140
- } else {
141
- for (const value of this.flatmapKnowledge) {
142
- const lowerCase = input.toLowerCase()
143
- const myJSON = JSON.stringify(value).toLowerCase()
144
- if (myJSON.includes(lowerCase)) {
145
- this.results.push(value)
146
- }
147
- }
148
- }
149
- }
150
- console.log(this.flatmapKnowledge, this.results)
151
- const start = this.numberPerPage * (this.page - 1)
152
- this.paginatedResults = this.results.slice(start, start + this.numberPerPage)
153
- this.numberOfHits = this.results.length
154
- this.searchInput = input
155
- this.lastSearch = input
156
- console.log(this.numberOfHits)
157
- },
158
- numberPerPageUpdate: function (val) {
159
- this.numberPerPage = val
160
- this.pageChange(1)
161
- },
162
- pageChange: function (page) {
163
- this.page = page
164
- this.search( this.searchInput)
165
- },
166
- scrollToTop: function () {
167
- if (this.$refs.content) {
168
- this.$refs.content.scroll({ top: 0, behavior: 'smooth' })
169
- }
170
- },
171
- resetPageNavigation: function () {
172
- this.page = 1
173
- },
174
- },
175
- mounted: function () {
176
- this.mapServer = this.envVars.FLATMAPAPI_LOCATION
177
- console.log(this.mapServer)
178
- if (this.mapServer) {
179
- const sql = `select knowledge from knowledge
180
- where source="${this.sckanVersion}"
181
- order by source desc`;
182
- flatmapQuery(this.mapServer, sql).then((response) => {
183
- const mappedData = response.values.map(x => x[0])
184
- const parsedData = mappedData.map(x => JSON.parse(x))
185
- this.flatmapKnowledge = filterKnowledge(parsedData, this.sckanVersion)
186
- this.search("");
187
- });
188
- }
189
- },
190
- }
191
- </script>
192
-
193
- <style lang="scss" scoped>
194
- .dataset-card {
195
- position: relative;
196
-
197
- &::before {
198
- content: "";
199
- display: block;
200
- width: calc(100% - 15px);
201
- height: 100%;
202
- position: absolute;
203
- top: 7px;
204
- left: 7px;
205
- border-style: solid;
206
- border-radius: 5px;
207
- border-color: transparent;
208
- }
209
-
210
- &:hover {
211
- &::before {
212
- border-color: var(--el-color-primary);
213
- }
214
- }
215
- }
216
-
217
- .main {
218
- font-size: 14px;
219
- text-align: left;
220
- line-height: 1.5em;
221
- font-family: Asap, sans-serif, Helvetica;
222
- font-weight: 400;
223
- /* outline: thin red solid; */
224
- overflow-y: auto;
225
- scrollbar-width: thin;
226
- min-width: 16rem;
227
- background-color: #f7faff;
228
- height: 100%;
229
- border-left: 1px solid var(--el-border-color);
230
- border-top: 1px solid var(--el-border-color);
231
- display: flex;
232
- flex-direction: column;
233
- gap: 1.75rem;
234
- padding: 1rem;
235
- }
236
-
237
- .step-item {
238
- font-size: 14px;
239
- margin-bottom: 18px;
240
- text-align: left;
241
- }
242
-
243
- .search-input {
244
- width: 298px !important;
245
- height: 40px;
246
- padding-right: 14px;
247
-
248
- :deep(.el-input__inner) {
249
- font-family: inherit;
250
- }
251
- }
252
-
253
- .header {
254
- .el-button {
255
- font-family: inherit;
256
-
257
- &:hover,
258
- &:focus {
259
- background: $app-primary-color;
260
- box-shadow: -3px 2px 4px #00000040;
261
- color: #fff;
262
- }
263
- }
264
- }
265
-
266
- .pagination {
267
- padding-bottom: 16px;
268
- background-color: white;
269
- padding-left: 95px;
270
- font-weight: bold;
271
- }
272
-
273
- .pagination :deep(button) {
274
- background-color: white !important;
275
- }
276
- .pagination :deep(li) {
277
- background-color: white !important;
278
- }
279
- .pagination :deep(li.is-active) {
280
- color: $app-primary-color;
281
- }
282
-
283
- .error-feedback {
284
- font-family: Asap;
285
- font-size: 14px;
286
- font-style: italic;
287
- padding-top: 15px;
288
- }
289
-
290
- .content-card :deep(.el-card__header) {
291
- background-color: #292b66;
292
- padding: 1rem;
293
- }
294
-
295
- .content-card :deep(.el-card__body) {
296
- background-color: #f7faff;
297
- overflow-y: hidden;
298
- padding: 1rem;
299
- }
300
-
301
- .content {
302
- // width: 515px;
303
- flex: 1 1 auto;
304
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
305
- border: solid 1px #e4e7ed;
306
- background-color: #ffffff;
307
- overflow-y: scroll;
308
- scrollbar-width: thin;
309
- border-radius: var(--el-border-radius-base);
310
- }
311
-
312
- .content :deep(.el-loading-spinner .path) {
313
- stroke: $app-primary-color;
314
- }
315
-
316
- .content :deep(.step-item:first-child .seperator-path) {
317
- display: none;
318
- }
319
-
320
- .content :deep(.step-item:not(:first-child) .seperator-path) {
321
- width: 455px;
322
- height: 0px;
323
- border: solid 1px #e4e7ed;
324
- background-color: #e4e7ed;
325
- }
326
-
327
- .scrollbar::-webkit-scrollbar-track {
328
- border-radius: 10px;
329
- background-color: #f5f5f5;
330
- }
331
-
332
- .scrollbar::-webkit-scrollbar {
333
- width: 12px;
334
- right: -12px;
335
- background-color: #f5f5f5;
336
- }
337
-
338
- .scrollbar::-webkit-scrollbar-thumb {
339
- border-radius: 4px;
340
- box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.06);
341
- background-color: #979797;
342
- }
343
-
344
- :deep(.el-input__suffix) {
345
- padding-right: 0px;
346
- }
347
-
348
- :deep(.my-drawer) {
349
- background: rgba(0, 0, 0, 0);
350
- box-shadow: none;
351
- }
352
- </style>