@abi-software/map-side-bar 2.4.0-alpha-1 → 2.4.0-isan-0

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.
Files changed (43) hide show
  1. package/.eslintrc.js +12 -12
  2. package/.postcssrc.json +5 -5
  3. package/LICENSE +201 -201
  4. package/README.md +168 -168
  5. package/cypress.config.js +23 -23
  6. package/dist/map-side-bar.js +9362 -15112
  7. package/dist/map-side-bar.umd.cjs +103 -50
  8. package/dist/style.css +1 -1
  9. package/package.json +77 -77
  10. package/reporter-config.json +9 -9
  11. package/src/App.vue +268 -266
  12. package/src/algolia/algolia.js +256 -255
  13. package/src/algolia/utils.js +105 -100
  14. package/src/assets/_variables.scss +43 -43
  15. package/src/assets/styles.scss +6 -6
  16. package/src/components/BadgesGroup.vue +124 -124
  17. package/src/components/ConnectivityInfo.vue +619 -619
  18. package/src/components/DatasetCard.vue +367 -367
  19. package/src/components/EventBus.js +3 -3
  20. package/src/components/ExternalResourceCard.vue +113 -113
  21. package/src/components/ImageGallery.vue +542 -542
  22. package/src/components/PMRDatasetCard.vue +303 -237
  23. package/src/components/SearchFilters.vue +1023 -1023
  24. package/src/components/SearchHistory.vue +175 -175
  25. package/src/components/SideBar.vue +456 -436
  26. package/src/components/SidebarContent.vue +710 -730
  27. package/src/components/Tabs.vue +145 -145
  28. package/src/components/index.js +8 -8
  29. package/src/components/species-map.js +8 -8
  30. package/src/components.d.ts +0 -1
  31. package/src/exampleConnectivityInput.js +291 -291
  32. package/src/flatmapQueries/flatmapQueries.js +220 -168
  33. package/src/main.js +9 -9
  34. package/src/mixins/S3Bucket.vue +37 -37
  35. package/src/mixins/mixedPageCalculation.vue +102 -78
  36. package/static.json +6 -6
  37. package/vite.config.js +55 -55
  38. package/vuese-generator.js +65 -65
  39. package/dist/data/pmr-sample.json +0 -3181
  40. package/public/data/pmr-sample.json +0 -3181
  41. package/src/components/FlatmapDatasetCard.vue +0 -171
  42. package/src/components/allPaths.js +0 -5928
  43. package/src/components/pmrTest.js +0 -4
@@ -1,78 +1,102 @@
1
- <script>
2
- const RatioOfPMRResults = 0.2; // Ratio of PMR results to Sparc results
3
-
4
- // The functions below are needed because the number of results shown on the page is dependent what is available from each index.
5
- // We fix this by calcuting how many results we have shown before the requested page and then calculating the offset based on that.
6
-
7
- export default {
8
- methods: {
9
-
10
- // Calculate Variable Ratio is used as a number to determine how the ratio of PMR results to SPARC results
11
- // will be shown on the page. 1 means only PMR results, 0 means only SPARC results.
12
- calculateVariableRatio: function () {
13
- if (this.page === 1) {
14
- this.variableRatio = RatioOfPMRResults
15
- } else if( this.npp_SPARC * (this.page -1) >= this.sparcNumberOfHits) {
16
- this.variableRatio = 1
17
- // calculate offset
18
- let mixedOffest = this.page*RatioOfPMRResults
19
- } else if(this.npp_PMR * (this.page - 1) >= this.pmrNumberOfHits) {
20
- this.variableRatio = 0
21
- } else {
22
- this.variableRatio = RatioOfPMRResults
23
- }
24
- },
25
- calculatePMROffest: function() {
26
- if (this.variableRatio === RatioOfPMRResults) {
27
- return (this.page-1)*this.npp_PMR
28
- } else if (this.variableRatio === 1) {
29
-
30
- // calculate how many results we showed before the requested page
31
- let pageWhereSPARCResultsRanOut = Math.ceil(this.sparcNumberOfHits / this.npp_SPARC)
32
- let numberOfPMRResultsShownInMixed = this.npp_PMR * pageWhereSPARCResultsRanOut
33
- let numberOfPMRResultsShownInPMROnly = (this.page - 1 - pageWhereSPARCResultsRanOut) * this.numberPerPage
34
- return numberOfPMRResultsShownInMixed + numberOfPMRResultsShownInPMROnly
35
- }
36
- },
37
- calculateSPARCOffest: function() {
38
- if(this.variableRatio === RatioOfPMRResults) {
39
- return (this.page-1)*this.npp_SPARC
40
- } else if (this.variableRatio === 0) {
41
-
42
- // calculate how many results we showed before the requested page
43
- let pageWherePMRResultsRanOut = Math.ceil(this.pmrNumberOfHits / this.npp_PMR)
44
- let numberOfSPARCResultsShownInMixed = this.npp_SPARC * pageWherePMRResultsRanOut
45
- let numberOfSPARCResultsShownInSPARCOnly = (this.page - 1 - pageWherePMRResultsRanOut) * this.numberPerPage
46
- let offset = numberOfSPARCResultsShownInMixed + numberOfSPARCResultsShownInSPARCOnly
47
- return offset
48
- }
49
- },
50
- PMRLimit: function(pmrResultsOnlyFlag=false) {
51
- if (pmrResultsOnlyFlag) {
52
- return this.numberPerPage
53
- }
54
- if (this.variableRatio === RatioOfPMRResults) {
55
- return this.npp_PMR
56
- } else if (this.variableRatio === 1) {
57
- return this.numberPerPage
58
- } else if (this.variableRatio === 0) {
59
- return 0
60
- }
61
- },
62
- SPARCLimit: function(pmrResultsOnlyFlag=false) {
63
- if(pmrResultsOnlyFlag) {
64
- return 0
65
- }
66
- if (this.variableRatio === RatioOfPMRResults) {
67
- return this.npp_SPARC
68
- } else if (this.variableRatio === 0) {
69
- return this.numberPerPage
70
- } else if (this.variableRatio === 1) {
71
- return 0
72
- }
73
- },
74
- }
75
- };
76
- </script>
77
-
78
-
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
+ methods: {
10
+
11
+ // Calculate Variable Ratio is used as a number to determine how the ratio of PMR results to SPARC results
12
+ // will be shown on the page. 1 means only PMR results, 0 means only SPARC results.
13
+ calculateVariableRatio: function () {
14
+ if (this.page === 1) {
15
+ this.variableRatio = this.RatioOfPMRResults
16
+
17
+ // Check if we have run out of Sparc results
18
+ } else if( this.npp_SPARC * (this.page -1) >= this.sparcNumberOfHits) {
19
+ this.variableRatio = 1
20
+
21
+ // Check if we have run out of PMR results
22
+ } else if(this.npp_PMR * (this.page - 1) >= this.pmrNumberOfHits) {
23
+ this.variableRatio = 0
24
+ } else {
25
+
26
+ // Set the ratio to the same as the previous page if both indeces have results
27
+ this.variableRatio = this.RatioOfPMRResults
28
+ }
29
+ },
30
+
31
+ // calculatePMROffest is used to calculate how many PMR results we have shown before the requested page
32
+ calculatePMROffest: function() {
33
+
34
+ // If variable ratio has not changed, we have not run out of results.
35
+ // we can use the the number per page PMR to calculate the offset
36
+ if (this.variableRatio === this.RatioOfPMRResults) {
37
+ return (this.page-1)*this.npp_PMR
38
+
39
+ // If we have run out of SPARC results, we need to calculate how many PMR results we have shown before the requested page
40
+ } else if (this.variableRatio === 1) {
41
+
42
+ // calculate how many results we showed before the requested page
43
+ // We want our offset to be the number of PMR results shown before the requested page
44
+ // This can be though of as numberOfPMRResultsShownInMixed + numberOfPMRResultsShownInPMROnly = offset
45
+ let pageWhereSPARCResultsRanOut = Math.ceil(this.sparcNumberOfHits / this.npp_SPARC)
46
+ let numberOfPMRResultsShownInMixed = this.npp_PMR * pageWhereSPARCResultsRanOut
47
+ let numberOfPMRResultsShownInPMROnly = (this.page - 1 - pageWhereSPARCResultsRanOut) * this.numberPerPage
48
+ return numberOfPMRResultsShownInMixed + numberOfPMRResultsShownInPMROnly
49
+ }
50
+ },
51
+
52
+ // calculateSPARCOffest is used to calculate how many SPARC results we have shown before the requested page. See above for details
53
+ calculateSPARCOffest: function() {
54
+ if(this.variableRatio === this.RatioOfPMRResults) {
55
+ return (this.page-1)*this.npp_SPARC
56
+ } else if (this.variableRatio === 0) {
57
+
58
+ // calculate how many results we showed before the requested page
59
+ let pageWherePMRResultsRanOut = Math.ceil(this.pmrNumberOfHits / this.npp_PMR)
60
+ let numberOfSPARCResultsShownInMixed = this.npp_SPARC * pageWherePMRResultsRanOut
61
+ let numberOfSPARCResultsShownInSPARCOnly = (this.page - 1 - pageWherePMRResultsRanOut) * this.numberPerPage
62
+ let offset = numberOfSPARCResultsShownInMixed + numberOfSPARCResultsShownInSPARCOnly
63
+ return offset
64
+ }
65
+ },
66
+
67
+ // PMRLimit is used to calculate how many PMR results we can show on the page.
68
+ PMRLimit: function(pmrResultsOnlyFlag=false) {
69
+ // If we only want PMR results, return the number per page
70
+ if (pmrResultsOnlyFlag) {
71
+ return this.numberPerPage
72
+ }
73
+ // If the variable ratio is the same as the ratio of PMR results, return the number per page set for PMR
74
+ if (this.variableRatio === this.RatioOfPMRResults) {
75
+ return this.npp_PMR
76
+
77
+ // if we have run out of sparc results, we want to show pmr results equal to the total number of results per page
78
+ } else if (this.variableRatio === 1) {
79
+ return this.numberPerPage
80
+
81
+ // if we have run out of pmr results, we want to show 0 pmr results
82
+ } else if (this.variableRatio === 0) {
83
+ return 0
84
+ }
85
+ },
86
+ SPARCLimit: function(pmrResultsOnlyFlag=false) {
87
+ if(pmrResultsOnlyFlag) {
88
+ return 0
89
+ }
90
+ if (this.variableRatio === this.RatioOfPMRResults) {
91
+ return this.npp_SPARC
92
+ } else if (this.variableRatio === 0) {
93
+ return this.numberPerPage
94
+ } else if (this.variableRatio === 1) {
95
+ return 0
96
+ }
97
+ },
98
+ }
99
+ };
100
+ </script>
101
+
102
+
package/static.json CHANGED
@@ -1,7 +1,7 @@
1
- {
2
- "root": "dist",
3
- "clean_urls": true,
4
- "routes": {
5
- "/**": "index.html"
6
- }
1
+ {
2
+ "root": "dist",
3
+ "clean_urls": true,
4
+ "routes": {
5
+ "/**": "index.html"
6
+ }
7
7
  }
package/vite.config.js CHANGED
@@ -1,56 +1,56 @@
1
- import { resolve } from "node:path"
2
-
3
- import { defineConfig } from 'vite'
4
- import vue from '@vitejs/plugin-vue'
5
-
6
- import Components from 'unplugin-vue-components/vite'
7
- import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
8
-
9
- // https://vitejs.dev/config/
10
- export default defineConfig({
11
- server: {
12
- port: 8081,
13
- },
14
- plugins: [
15
- vue(),
16
- Components({
17
- // allow auto load markdown components under `./src/components/`
18
- extensions: ['vue', 'md'],
19
- // allow auto import and register components used in markdown
20
- include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
21
- resolvers: [
22
- ElementPlusResolver({
23
- importStyle: 'sass',
24
- }),
25
- ],
26
- dts: './src/components.d.ts',
27
- }),
28
- ],
29
- resolve: {
30
- alias: {
31
- '@': resolve(__dirname, './src'),
32
- }
33
- },
34
- build: {
35
- lib: {
36
- entry: resolve(__dirname, "./src/components/index.js"),
37
- name: "MapSideBar",
38
- fileName: 'map-side-bar',
39
- },
40
- rollupOptions: {
41
- external: ["vue"],
42
- output: {
43
- globals: {
44
- vue: "Vue",
45
- },
46
- },
47
- },
48
- },
49
- css: {
50
- preprocessorOptions: {
51
- scss: {
52
- additionalData: `@use './src/assets/styles' as *;`
53
- }
54
- }
55
- }
1
+ import { resolve } from "node:path"
2
+
3
+ import { defineConfig } from 'vite'
4
+ import vue from '@vitejs/plugin-vue'
5
+
6
+ import Components from 'unplugin-vue-components/vite'
7
+ import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
8
+
9
+ // https://vitejs.dev/config/
10
+ export default defineConfig({
11
+ server: {
12
+ port: 8081,
13
+ },
14
+ plugins: [
15
+ vue(),
16
+ Components({
17
+ // allow auto load markdown components under `./src/components/`
18
+ extensions: ['vue', 'md'],
19
+ // allow auto import and register components used in markdown
20
+ include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
21
+ resolvers: [
22
+ ElementPlusResolver({
23
+ importStyle: 'sass',
24
+ }),
25
+ ],
26
+ dts: './src/components.d.ts',
27
+ }),
28
+ ],
29
+ resolve: {
30
+ alias: {
31
+ '@': resolve(__dirname, './src'),
32
+ }
33
+ },
34
+ build: {
35
+ lib: {
36
+ entry: resolve(__dirname, "./src/components/index.js"),
37
+ name: "MapSideBar",
38
+ fileName: 'map-side-bar',
39
+ },
40
+ rollupOptions: {
41
+ external: ["vue"],
42
+ output: {
43
+ globals: {
44
+ vue: "Vue",
45
+ },
46
+ },
47
+ },
48
+ },
49
+ css: {
50
+ preprocessorOptions: {
51
+ scss: {
52
+ additionalData: `@use './src/assets/styles' as *;`
53
+ }
54
+ }
55
+ }
56
56
  })
@@ -1,65 +1,65 @@
1
- /**
2
- * Vuese Generator
3
- *
4
- * To generate markdown files from Vue components
5
- * To watch components changes for Vitepress on Dev Mode
6
- */
7
-
8
- import fs from 'fs'
9
- import path from 'path'
10
- import chokidar from 'chokidar'
11
- import { parser } from '@vuese/parser'
12
- import { Render } from '@vuese/markdown-render'
13
-
14
- const watchMode = process.argv.find((argv) => argv === 'watch')
15
-
16
- const componentsDir = 'src/components'
17
- const components = ['SideBar.vue']
18
- const outputDir = 'docs/components'
19
-
20
- function generateMarkdown(file) {
21
- const fileWithPath = `${componentsDir}/${file}`
22
- const fileContent = fs.readFileSync(fileWithPath, 'utf-8')
23
-
24
- try {
25
- const parserResult = parser(fileContent)
26
- const r = new Render(parserResult)
27
- const renderResult = r.render()
28
- const markdownResult = r.renderMarkdown()
29
- const markdownContent = markdownResult.content
30
- const componentName = path.basename(fileWithPath, '.vue')
31
-
32
- if (!fs.existsSync(outputDir)) {
33
- fs.mkdirSync(outputDir)
34
- }
35
-
36
- fs.writeFile(`${outputDir}/${componentName}.md`, markdownContent, (err) => {
37
- if (err) {
38
- console.error(`Error writing markdown file for ${componentName}`, err)
39
- } else {
40
- console.log(`Markdown file for ${componentName} is generated!`)
41
- }
42
- })
43
- } catch(e) {
44
- console.error(e)
45
- }
46
- }
47
-
48
- // To generate markdown files - one time
49
- components.forEach((component) => {
50
- console.log(`Write markdown file for ${component} on first load.`)
51
- generateMarkdown(component)
52
- })
53
-
54
- // To watch component changes and generate markdown files
55
- if (watchMode) {
56
- const watcher = chokidar.watch(components, {
57
- cwd: componentsDir,
58
- ignoreInitial: true,
59
- })
60
-
61
- watcher.on('change', (file) => {
62
- console.log(`The component ${file} has changed!`)
63
- generateMarkdown(file)
64
- })
65
- }
1
+ /**
2
+ * Vuese Generator
3
+ *
4
+ * To generate markdown files from Vue components
5
+ * To watch components changes for Vitepress on Dev Mode
6
+ */
7
+
8
+ import fs from 'fs'
9
+ import path from 'path'
10
+ import chokidar from 'chokidar'
11
+ import { parser } from '@vuese/parser'
12
+ import { Render } from '@vuese/markdown-render'
13
+
14
+ const watchMode = process.argv.find((argv) => argv === 'watch')
15
+
16
+ const componentsDir = 'src/components'
17
+ const components = ['SideBar.vue']
18
+ const outputDir = 'docs/components'
19
+
20
+ function generateMarkdown(file) {
21
+ const fileWithPath = `${componentsDir}/${file}`
22
+ const fileContent = fs.readFileSync(fileWithPath, 'utf-8')
23
+
24
+ try {
25
+ const parserResult = parser(fileContent)
26
+ const r = new Render(parserResult)
27
+ const renderResult = r.render()
28
+ const markdownResult = r.renderMarkdown()
29
+ const markdownContent = markdownResult.content
30
+ const componentName = path.basename(fileWithPath, '.vue')
31
+
32
+ if (!fs.existsSync(outputDir)) {
33
+ fs.mkdirSync(outputDir)
34
+ }
35
+
36
+ fs.writeFile(`${outputDir}/${componentName}.md`, markdownContent, (err) => {
37
+ if (err) {
38
+ console.error(`Error writing markdown file for ${componentName}`, err)
39
+ } else {
40
+ console.log(`Markdown file for ${componentName} is generated!`)
41
+ }
42
+ })
43
+ } catch(e) {
44
+ console.error(e)
45
+ }
46
+ }
47
+
48
+ // To generate markdown files - one time
49
+ components.forEach((component) => {
50
+ console.log(`Write markdown file for ${component} on first load.`)
51
+ generateMarkdown(component)
52
+ })
53
+
54
+ // To watch component changes and generate markdown files
55
+ if (watchMode) {
56
+ const watcher = chokidar.watch(components, {
57
+ cwd: componentsDir,
58
+ ignoreInitial: true,
59
+ })
60
+
61
+ watcher.on('change', (file) => {
62
+ console.log(`The component ${file} has changed!`)
63
+ generateMarkdown(file)
64
+ })
65
+ }