geonetwork-ui 2.4.3 → 2.4.4-dev.9094d472a

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 (78) hide show
  1. package/esm2022/libs/feature/dataviz/src/lib/chart-view/chart-view.component.mjs +7 -4
  2. package/esm2022/libs/feature/dataviz/src/lib/service/data.service.mjs +8 -8
  3. package/esm2022/libs/feature/dataviz/src/lib/table-view/table-view.component.mjs +7 -4
  4. package/esm2022/libs/feature/record/src/lib/data-view/data-view.component.mjs +4 -3
  5. package/esm2022/libs/feature/record/src/lib/map-view/map-view.component.mjs +3 -2
  6. package/esm2022/libs/feature/record/src/lib/state/mdview.facade.mjs +8 -1
  7. package/esm2022/libs/ui/elements/src/lib/markdown-parser/markdown-parser.component.mjs +3 -3
  8. package/esm2022/libs/util/data-fetcher/src/lib/data-fetcher.mjs +5 -4
  9. package/esm2022/libs/util/data-fetcher/src/lib/readers/base-cache.mjs +12 -0
  10. package/esm2022/libs/util/data-fetcher/src/lib/readers/base-file.mjs +3 -3
  11. package/esm2022/libs/util/data-fetcher/src/lib/readers/base.mjs +1 -1
  12. package/esm2022/libs/util/data-fetcher/src/lib/readers/csv.mjs +2 -2
  13. package/esm2022/libs/util/data-fetcher/src/lib/readers/excel.mjs +2 -2
  14. package/esm2022/libs/util/data-fetcher/src/lib/readers/geojson.mjs +2 -2
  15. package/esm2022/libs/util/data-fetcher/src/lib/readers/gml.mjs +5 -3
  16. package/esm2022/libs/util/data-fetcher/src/lib/readers/json.mjs +2 -2
  17. package/esm2022/libs/util/data-fetcher/src/lib/readers/wfs.mjs +19 -11
  18. package/esm2022/libs/util/data-fetcher/src/lib/utils.mjs +13 -9
  19. package/esm2022/translations/de.json +0 -1
  20. package/esm2022/translations/en.json +0 -1
  21. package/esm2022/translations/es.json +0 -1
  22. package/esm2022/translations/fr.json +0 -1
  23. package/esm2022/translations/nl.json +0 -1
  24. package/esm2022/translations/pt.json +0 -1
  25. package/fesm2022/geonetwork-ui.mjs +145 -111
  26. package/fesm2022/geonetwork-ui.mjs.map +1 -1
  27. package/libs/feature/dataviz/src/lib/chart-view/chart-view.component.d.ts +2 -1
  28. package/libs/feature/dataviz/src/lib/chart-view/chart-view.component.d.ts.map +1 -1
  29. package/libs/feature/dataviz/src/lib/service/data.service.d.ts +2 -2
  30. package/libs/feature/dataviz/src/lib/service/data.service.d.ts.map +1 -1
  31. package/libs/feature/dataviz/src/lib/table-view/table-view.component.d.ts +2 -1
  32. package/libs/feature/dataviz/src/lib/table-view/table-view.component.d.ts.map +1 -1
  33. package/libs/feature/record/src/lib/data-view/data-view.component.d.ts +1 -0
  34. package/libs/feature/record/src/lib/data-view/data-view.component.d.ts.map +1 -1
  35. package/libs/feature/record/src/lib/map-view/map-view.component.d.ts.map +1 -1
  36. package/libs/feature/record/src/lib/state/mdview.facade.d.ts +1 -0
  37. package/libs/feature/record/src/lib/state/mdview.facade.d.ts.map +1 -1
  38. package/libs/util/data-fetcher/src/lib/data-fetcher.d.ts +2 -2
  39. package/libs/util/data-fetcher/src/lib/data-fetcher.d.ts.map +1 -1
  40. package/libs/util/data-fetcher/src/lib/readers/base-cache.d.ts +8 -0
  41. package/libs/util/data-fetcher/src/lib/readers/base-cache.d.ts.map +1 -0
  42. package/libs/util/data-fetcher/src/lib/readers/base-file.d.ts +2 -2
  43. package/libs/util/data-fetcher/src/lib/readers/base-file.d.ts.map +1 -1
  44. package/libs/util/data-fetcher/src/lib/readers/base.d.ts +2 -2
  45. package/libs/util/data-fetcher/src/lib/readers/base.d.ts.map +1 -1
  46. package/libs/util/data-fetcher/src/lib/readers/gml.d.ts +5 -3
  47. package/libs/util/data-fetcher/src/lib/readers/gml.d.ts.map +1 -1
  48. package/libs/util/data-fetcher/src/lib/readers/wfs.d.ts +7 -4
  49. package/libs/util/data-fetcher/src/lib/readers/wfs.d.ts.map +1 -1
  50. package/libs/util/data-fetcher/src/lib/utils.d.ts +2 -2
  51. package/libs/util/data-fetcher/src/lib/utils.d.ts.map +1 -1
  52. package/package.json +1 -1
  53. package/src/libs/feature/dataviz/src/lib/chart-view/chart-view.component.ts +4 -1
  54. package/src/libs/feature/dataviz/src/lib/service/data.service.ts +22 -9
  55. package/src/libs/feature/dataviz/src/lib/table-view/table-view.component.ts +2 -1
  56. package/src/libs/feature/record/src/lib/data-view/data-view.component.html +2 -0
  57. package/src/libs/feature/record/src/lib/data-view/data-view.component.ts +3 -0
  58. package/src/libs/feature/record/src/lib/map-view/map-view.component.ts +2 -1
  59. package/src/libs/feature/record/src/lib/state/mdview.facade.ts +13 -0
  60. package/src/libs/ui/elements/src/lib/markdown-parser/markdown-parser.component.ts +2 -2
  61. package/src/libs/util/data-fetcher/src/lib/data-fetcher.ts +13 -4
  62. package/src/libs/util/data-fetcher/src/lib/readers/base-cache.ts +14 -0
  63. package/src/libs/util/data-fetcher/src/lib/readers/base-file.ts +2 -1
  64. package/src/libs/util/data-fetcher/src/lib/readers/base.ts +2 -2
  65. package/src/libs/util/data-fetcher/src/lib/readers/csv.ts +1 -1
  66. package/src/libs/util/data-fetcher/src/lib/readers/excel.ts +1 -1
  67. package/src/libs/util/data-fetcher/src/lib/readers/geojson.ts +1 -1
  68. package/src/libs/util/data-fetcher/src/lib/readers/gml.ts +7 -7
  69. package/src/libs/util/data-fetcher/src/lib/readers/json.ts +1 -1
  70. package/src/libs/util/data-fetcher/src/lib/readers/wfs.ts +34 -11
  71. package/src/libs/util/data-fetcher/src/lib/utils.ts +38 -32
  72. package/translations/de.json +0 -1
  73. package/translations/en.json +0 -1
  74. package/translations/es.json +0 -1
  75. package/translations/fr.json +0 -1
  76. package/translations/nl.json +0 -1
  77. package/translations/pt.json +0 -1
  78. package/translations/sk.json +0 -1
@@ -23,6 +23,6 @@ export function parseJson(text: string): {
23
23
 
24
24
  export class JsonReader extends BaseFileReader {
25
25
  getData() {
26
- return fetchDataAsText(this.url).then(parseJson)
26
+ return fetchDataAsText(this.url, this.cacheActive).then(parseJson)
27
27
  }
28
28
  }
@@ -1,18 +1,24 @@
1
1
  import { WfsEndpoint, WfsVersion } from '@camptocamp/ogc-client'
2
2
  import { DataItem, DatasetInfo, PropertyInfo } from '../model'
3
3
  import { fetchDataAsText } from '../utils'
4
- import { BaseReader } from './base'
5
4
  import { GmlReader, parseGml } from './gml'
6
5
  import { GeojsonReader, parseGeojson } from './geojson'
7
- import { marker } from '@biesbjerg/ngx-translate-extract-marker'
6
+ import { BaseCacheReader } from './base-cache'
7
+ import { getJsonDataItemsProxy, jsonToGeojsonFeature } from '../utils'
8
+ import { generateSqlQuery } from '../sql-utils'
8
9
 
9
- export class WfsReader extends BaseReader {
10
+ export class WfsReader extends BaseCacheReader {
10
11
  endpoint: WfsEndpoint
11
12
  featureTypeName: string
12
13
  version: WfsVersion
13
14
 
14
- constructor(url: string, wfsEndpoint: WfsEndpoint, featureTypeName: string) {
15
- super(url)
15
+ constructor(
16
+ url: string,
17
+ wfsEndpoint: WfsEndpoint,
18
+ featureTypeName: string,
19
+ cacheActive?: boolean
20
+ ) {
21
+ super(url, cacheActive)
16
22
  this.endpoint = wfsEndpoint
17
23
  this.featureTypeName = featureTypeName
18
24
  this.version = this.endpoint.getVersion()
@@ -90,11 +96,10 @@ export class WfsReader extends BaseReader {
90
96
  }
91
97
  }
92
98
 
93
- protected getData() {
94
- if (this.aggregations || this.groupedBy) {
95
- throw new Error(marker('wfs.aggregations.notsupported'))
99
+ public async getData(aggregation?, groupedBy?) {
100
+ if (aggregation || groupedBy) {
101
+ return { items: await this.getQueryData() }
96
102
  }
97
-
98
103
  const asJson = this.endpoint.supportsJson(this.featureTypeName)
99
104
  const attributes = this.selected ?? undefined
100
105
  let url = this.endpoint.getFeatureUrl(this.featureTypeName, {
@@ -117,18 +122,36 @@ export class WfsReader extends BaseReader {
117
122
  url = `${url}${finalUrl.search ? '&' : ''}SORTBY=${sorts}`
118
123
  }
119
124
 
120
- return fetchDataAsText(url).then((text) =>
125
+ return fetchDataAsText(url, this.cacheActive).then((text) =>
121
126
  asJson
122
127
  ? parseGeojson(text)
123
128
  : parseGml(text, this.featureTypeName, this.version)
124
129
  )
125
130
  }
126
131
 
132
+ public async getQueryData() {
133
+ const items = (await this.getData()).items
134
+ const jsonItems = getJsonDataItemsProxy(items)
135
+ const query = generateSqlQuery(
136
+ this.selected,
137
+ this.filter,
138
+ this.sort,
139
+ this.startIndex,
140
+ this.count,
141
+ this.groupedBy,
142
+ this.aggregations
143
+ )
144
+ const result = await import('alasql').then((module) =>
145
+ module.default(query, [jsonItems])
146
+ )
147
+ return result.map(jsonToGeojsonFeature)
148
+ }
149
+
127
150
  load() {
128
151
  // Nothing to load for Wfs
129
152
  }
130
153
 
131
154
  async read(): Promise<DataItem[]> {
132
- return (await this.getData()).items
155
+ return (await this.getData(this.aggregations, this.groupedBy)).items
133
156
  }
134
157
  }
@@ -51,39 +51,45 @@ export function fetchHeaders(url: string): Promise<DatasetHeaders> {
51
51
  })
52
52
  }
53
53
 
54
- export function fetchDataAsText(url: string): Promise<string> {
55
- return useCache(
56
- () =>
57
- sharedFetch(url)
58
- .catch((error) => {
59
- throw FetchError.corsOrNetwork(error.message)
60
- })
61
- .then(async (response) => {
62
- if (!response.ok) {
63
- throw FetchError.http(response.status, await response.text())
64
- }
65
- return response.text()
66
- }),
67
- url,
68
- 'asText'
69
- )
54
+ export function fetchDataAsText(
55
+ url: string,
56
+ cacheActive: boolean
57
+ ): Promise<string> {
58
+ const fetchFactory = () =>
59
+ sharedFetch(url)
60
+ .catch((error) => {
61
+ throw FetchError.corsOrNetwork(error.message)
62
+ })
63
+ .then(async (response) => {
64
+ if (!response.ok) {
65
+ const clonedResponse = response.clone()
66
+ throw FetchError.http(response.status, await clonedResponse.text())
67
+ }
68
+ const clonedResponse = response.clone()
69
+ return clonedResponse.text()
70
+ })
71
+
72
+ return cacheActive ? useCache(fetchFactory, url, 'asText') : fetchFactory()
70
73
  }
71
- export function fetchDataAsArrayBuffer(url: string): Promise<ArrayBuffer> {
72
- return useCache(
73
- () =>
74
- sharedFetch(url)
75
- .catch((error) => {
76
- throw FetchError.corsOrNetwork(error.message)
77
- })
78
- .then(async (response) => {
79
- if (!response.ok) {
80
- throw FetchError.http(response.status, await response.text())
81
- }
82
- // convert to a numeric array so that we can store the response in cache
83
- return Array.from(new Uint8Array(await response.arrayBuffer()))
84
- }),
85
- url,
86
- 'asArrayBuffer'
74
+ export function fetchDataAsArrayBuffer(
75
+ url: string,
76
+ cacheActive: boolean
77
+ ): Promise<ArrayBuffer> {
78
+ const fetchFactory = () =>
79
+ sharedFetch(url)
80
+ .catch((error) => {
81
+ throw FetchError.corsOrNetwork(error.message)
82
+ })
83
+ .then(async (response) => {
84
+ if (!response.ok) {
85
+ throw FetchError.http(response.status, await response.text())
86
+ }
87
+ // convert to a numeric array so that we can store the response in cache
88
+ return Array.from(new Uint8Array(await response.arrayBuffer()))
89
+ })
90
+
91
+ return (
92
+ cacheActive ? useCache(fetchFactory, url, 'asArrayBuffer') : fetchFactory()
87
93
  ).then((array) => {
88
94
  return new Uint8Array(array).buffer
89
95
  })
@@ -602,7 +602,6 @@
602
602
  "tooltip.url.open": "URL öffnen",
603
603
  "ui.readLess": "Weniger lesen",
604
604
  "ui.readMore": "Weiterlesen",
605
- "wfs.aggregations.notsupported": "",
606
605
  "wfs.feature.limit": "Zu viele Features, um den WFS-Layer anzuzeigen!",
607
606
  "wfs.featuretype.notfound": "Kein passender Feature-Typ wurde im Dienst gefunden",
608
607
  "wfs.geojsongml.notsupported": "Dieser Dienst unterstützt das GeoJSON- oder GML-Format nicht",
@@ -602,7 +602,6 @@
602
602
  "tooltip.url.open": "Open URL",
603
603
  "ui.readLess": "Read less",
604
604
  "ui.readMore": "Read more",
605
- "wfs.aggregations.notsupported": "Aggregations are currently not supported for WFS services",
606
605
  "wfs.feature.limit": "Too many features to display the WFS layer!",
607
606
  "wfs.featuretype.notfound": "No matching feature type was found in the service",
608
607
  "wfs.geojsongml.notsupported": "This service does not support the GeoJSON or GML format",
@@ -602,7 +602,6 @@
602
602
  "tooltip.url.open": "",
603
603
  "ui.readLess": "",
604
604
  "ui.readMore": "",
605
- "wfs.aggregations.notsupported": "",
606
605
  "wfs.feature.limit": "",
607
606
  "wfs.featuretype.notfound": "",
608
607
  "wfs.geojsongml.notsupported": "",
@@ -602,7 +602,6 @@
602
602
  "tooltip.url.open": "Ouvrir l'URL",
603
603
  "ui.readLess": "Réduire",
604
604
  "ui.readMore": "Lire la suite",
605
- "wfs.aggregations.notsupported": "Agrégations non supportées pour les services WFS",
606
605
  "wfs.feature.limit": "Trop d'objets pour afficher la couche WFS !",
607
606
  "wfs.featuretype.notfound": "La classe d'objets n'a pas été trouvée dans le service",
608
607
  "wfs.geojsongml.notsupported": "Le service ne supporte pas le format GeoJSON ou GML",
@@ -602,7 +602,6 @@
602
602
  "tooltip.url.open": "",
603
603
  "ui.readLess": "",
604
604
  "ui.readMore": "",
605
- "wfs.aggregations.notsupported": "",
606
605
  "wfs.feature.limit": "",
607
606
  "wfs.featuretype.notfound": "",
608
607
  "wfs.geojsongml.notsupported": "",
@@ -602,7 +602,6 @@
602
602
  "tooltip.url.open": "",
603
603
  "ui.readLess": "",
604
604
  "ui.readMore": "",
605
- "wfs.aggregations.notsupported": "",
606
605
  "wfs.feature.limit": "",
607
606
  "wfs.featuretype.notfound": "",
608
607
  "wfs.geojsongml.notsupported": "",
@@ -602,7 +602,6 @@
602
602
  "tooltip.url.open": "Otvoriť URL",
603
603
  "ui.readLess": "Čítať menej",
604
604
  "ui.readMore": "Čítať viac",
605
- "wfs.aggregations.notsupported": "",
606
605
  "wfs.feature.limit": "",
607
606
  "wfs.featuretype.notfound": "V službe nebol nájdený žiadny zodpovedajúci typ funkcie",
608
607
  "wfs.geojsongml.notsupported": "Táto služba nepodporuje formát GeoJSON alebo GML",