@startinblox/components-ds4go 3.1.4 → 3.1.6
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/dist/{custom-getter-ZPFnoSjt-BCNOlbJZ-CHZXhUca.js → custom-getter-ZPFnoSjt-BCNOlbJZ-DYuXZ4Fr.js} +1 -1
- package/dist/{index-DQ-N8-vz.js → index-9p-uZ-aS.js} +22756 -22538
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/component.d.ts +131 -0
- package/src/components/cards/ds4go-card-catalog.ts +17 -0
- package/src/components/catalog/ds4go-dsif-explorer-poc-holder.ts +324 -0
- package/src/components/modal/ds4go-fact-bundle-modal.ts +31 -12
- package/src/components/solid-dsif-explorer-poc.ts +101 -160
- package/src/components/solid-fact-bundle-creation.ts +9 -9
- package/src/helpers/index.ts +2 -0
- package/src/helpers/ui/formatCase.ts +8 -0
- package/src/mocks/dsif/catalog.jsonld +372 -0
- package/src/mocks/dsif/root-authority.jsonld +26 -0
- package/src/mocks/dsif/sector-authority.jsonld +121 -0
|
@@ -1,68 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OrbitComponent, sort } from "@helpers";
|
|
2
2
|
import { msg, str } from "@lit/localize";
|
|
3
3
|
import { Task } from "@lit/task";
|
|
4
|
-
import type {
|
|
5
|
-
|
|
4
|
+
import type {
|
|
5
|
+
PropertiesPicker,
|
|
6
|
+
SearchObject,
|
|
7
|
+
DSIFRootAuthoritySector,
|
|
8
|
+
DSIFSectorAuthority,
|
|
9
|
+
DSIFCatalogEntry,
|
|
10
|
+
DSIFCatalogWithContext,
|
|
11
|
+
DSIFDatasetWithContext,
|
|
12
|
+
} from "@src/component";
|
|
13
|
+
import { html, nothing } from "lit";
|
|
6
14
|
import { customElement, property, state } from "lit/decorators.js";
|
|
7
15
|
|
|
8
|
-
// TODO: move to @src/component
|
|
9
|
-
//------------------------------------------------------------------------------
|
|
10
|
-
interface Sector {
|
|
11
|
-
sectorName: string;
|
|
12
|
-
description: string;
|
|
13
|
-
federatedCatalogEndpoint: string;
|
|
14
|
-
lastUpdated: string;
|
|
15
|
-
id: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface Catalog {
|
|
19
|
-
catalogId: string;
|
|
20
|
-
type: string;
|
|
21
|
-
description: string;
|
|
22
|
-
endpoints: {
|
|
23
|
-
catalog: string;
|
|
24
|
-
};
|
|
25
|
-
lastUpdated: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface Dataset extends Resource {
|
|
29
|
-
"dct:title": string;
|
|
30
|
-
"dct:description": string;
|
|
31
|
-
"dct:creator": string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
interface CatalogEntry extends Resource {
|
|
35
|
-
"dct:title": string;
|
|
36
|
-
"dct:description": string;
|
|
37
|
-
"dcat:dataset": Dataset[];
|
|
38
|
-
}
|
|
39
|
-
//------------------------------------------------------------------------------
|
|
40
|
-
|
|
41
16
|
@customElement("solid-dsif-explorer-poc")
|
|
42
17
|
export class SolidDsifExplorerPoc extends OrbitComponent {
|
|
43
|
-
static styles = css`
|
|
44
|
-
.card-grid {
|
|
45
|
-
margin: var(--scale-900) 0;
|
|
46
|
-
display: flex;
|
|
47
|
-
flex-direction: row;
|
|
48
|
-
flex-wrap: wrap;
|
|
49
|
-
gap: 20px;
|
|
50
|
-
}
|
|
51
|
-
.card-grid-vertical {
|
|
52
|
-
justify-content: stretch;
|
|
53
|
-
}
|
|
54
|
-
.card-grid-vertical ds4go-card-catalog {
|
|
55
|
-
width: 354px;
|
|
56
|
-
height: auto;
|
|
57
|
-
}
|
|
58
|
-
ds4go-card-catalog.cursor-pointer {
|
|
59
|
-
cursor: pointer;
|
|
60
|
-
}
|
|
61
|
-
tems-division {
|
|
62
|
-
margin-top: var(--scale-900);
|
|
63
|
-
}
|
|
64
|
-
`;
|
|
65
|
-
|
|
66
18
|
@property({ attribute: "sector-id", type: String })
|
|
67
19
|
sectorId?: string;
|
|
68
20
|
|
|
@@ -80,6 +32,11 @@ export class SolidDsifExplorerPoc extends OrbitComponent {
|
|
|
80
32
|
{ key: "dct:description", value: "description" },
|
|
81
33
|
{ key: "dcat:dataset", value: "dataset", expand: true },
|
|
82
34
|
{ key: "dct:creator", value: "creator" },
|
|
35
|
+
{ key: "dspace:assetId", value: "assetId" },
|
|
36
|
+
{ key: "dsif:pricing", value: "pricing" },
|
|
37
|
+
{ key: "dsif:previewLinks", value: "previewLinks" },
|
|
38
|
+
{ key: "dsif:negotiation", value: "negotiation" },
|
|
39
|
+
{ key: "dsif:originCatalogId", value: "originCatalogId" },
|
|
83
40
|
];
|
|
84
41
|
|
|
85
42
|
async _afterAttach() {
|
|
@@ -91,13 +48,13 @@ export class SolidDsifExplorerPoc extends OrbitComponent {
|
|
|
91
48
|
}
|
|
92
49
|
|
|
93
50
|
@state()
|
|
94
|
-
sectors:
|
|
51
|
+
sectors: DSIFRootAuthoritySector[] = [];
|
|
95
52
|
|
|
96
53
|
@state()
|
|
97
|
-
catalogs?:
|
|
54
|
+
catalogs?: DSIFCatalogWithContext[];
|
|
98
55
|
|
|
99
56
|
@state()
|
|
100
|
-
object?:
|
|
57
|
+
object?: DSIFCatalogEntry;
|
|
101
58
|
|
|
102
59
|
_getResource = new Task(this, {
|
|
103
60
|
task: async ([dataSrc, sectorId, catalogId]) => {
|
|
@@ -119,11 +76,17 @@ export class SolidDsifExplorerPoc extends OrbitComponent {
|
|
|
119
76
|
this.sectors = [];
|
|
120
77
|
try {
|
|
121
78
|
const rootAuthority = await fetch(dataSrc);
|
|
122
|
-
|
|
79
|
+
const rootData =
|
|
80
|
+
(await rootAuthority.json()) as DSIFRootAuthoritySector[];
|
|
81
|
+
|
|
82
|
+
this.sectors = rootData.map((sector) => ({
|
|
83
|
+
...sector,
|
|
84
|
+
rootAuthorityUrl: dataSrc,
|
|
85
|
+
})) as DSIFRootAuthoritySector[];
|
|
123
86
|
|
|
124
87
|
this.hasCachedDatas = true;
|
|
125
88
|
} catch (error) {
|
|
126
|
-
console.warn(`Failed to fetch
|
|
89
|
+
console.warn(`Failed to fetch root authority ${dataSrc}`, error);
|
|
127
90
|
return;
|
|
128
91
|
}
|
|
129
92
|
}
|
|
@@ -144,7 +107,16 @@ export class SolidDsifExplorerPoc extends OrbitComponent {
|
|
|
144
107
|
const response = await fetch(
|
|
145
108
|
`${sector.federatedCatalogEndpoint}/discovery`,
|
|
146
109
|
);
|
|
147
|
-
|
|
110
|
+
const sectorAuthority =
|
|
111
|
+
(await response.json()) as DSIFSectorAuthority;
|
|
112
|
+
|
|
113
|
+
return sectorAuthority.catalogs.map((catalog) => ({
|
|
114
|
+
...catalog,
|
|
115
|
+
sectorName: sector.sectorName,
|
|
116
|
+
sectorId: sector.id,
|
|
117
|
+
rootAuthorityUrl: sector.rootAuthorityUrl,
|
|
118
|
+
sectorAuthorityUrl: `${sector.federatedCatalogEndpoint}/discovery`,
|
|
119
|
+
})) as DSIFCatalogWithContext[];
|
|
148
120
|
} catch (error) {
|
|
149
121
|
console.warn(
|
|
150
122
|
`Failed to fetch sector authority ${sector.federatedCatalogEndpoint}/discovery`,
|
|
@@ -159,33 +131,45 @@ export class SolidDsifExplorerPoc extends OrbitComponent {
|
|
|
159
131
|
|
|
160
132
|
if (catalogId) {
|
|
161
133
|
if (catalogId === "*") {
|
|
134
|
+
const allDatasets = (
|
|
135
|
+
await Promise.all(
|
|
136
|
+
this.catalogs.map(async (catalog) => {
|
|
137
|
+
try {
|
|
138
|
+
const catalogEntry = (await (
|
|
139
|
+
await fetch(catalog.endpoints.catalog)
|
|
140
|
+
).json()) as DSIFCatalogEntry;
|
|
141
|
+
|
|
142
|
+
return catalogEntry["dcat:dataset"].map((dataset) => ({
|
|
143
|
+
...dataset,
|
|
144
|
+
catalogTitle: catalogEntry["dct:title"],
|
|
145
|
+
catalogId: catalog.catalogId,
|
|
146
|
+
sectorName: catalog.sectorName,
|
|
147
|
+
sectorId: catalog.sectorId,
|
|
148
|
+
rootAuthorityUrl: catalog.rootAuthorityUrl,
|
|
149
|
+
sectorAuthorityUrl: catalog.sectorAuthorityUrl,
|
|
150
|
+
})) as DSIFDatasetWithContext[];
|
|
151
|
+
} catch (error) {
|
|
152
|
+
console.warn(
|
|
153
|
+
`Failed to fetch catalog from ${catalog.endpoints.catalog}`,
|
|
154
|
+
error,
|
|
155
|
+
);
|
|
156
|
+
return [];
|
|
157
|
+
}
|
|
158
|
+
}),
|
|
159
|
+
)
|
|
160
|
+
).flat() as DSIFDatasetWithContext[];
|
|
161
|
+
|
|
162
162
|
this.object = {
|
|
163
163
|
"@id": "urn:uuid:all-catalogs",
|
|
164
|
+
"@type": "dcat:Catalog",
|
|
164
165
|
"dct:title": msg("All Catalogs"),
|
|
165
166
|
"dct:description": "",
|
|
166
|
-
"dcat:dataset":
|
|
167
|
-
await Promise.all(
|
|
168
|
-
this.catalogs.map(async (catalog) => {
|
|
169
|
-
try {
|
|
170
|
-
return (
|
|
171
|
-
(await (
|
|
172
|
-
await fetch(catalog.endpoints.catalog)
|
|
173
|
-
).json()) as CatalogEntry
|
|
174
|
-
)["dcat:dataset"];
|
|
175
|
-
} catch (error) {
|
|
176
|
-
console.warn(
|
|
177
|
-
`Failed to fetch catalog from ${catalog.endpoints.catalog}`,
|
|
178
|
-
error,
|
|
179
|
-
);
|
|
180
|
-
return [];
|
|
181
|
-
}
|
|
182
|
-
}),
|
|
183
|
-
)
|
|
184
|
-
).flat() as Dataset[],
|
|
167
|
+
"dcat:dataset": allDatasets,
|
|
185
168
|
};
|
|
186
169
|
|
|
187
170
|
return this.object;
|
|
188
171
|
}
|
|
172
|
+
|
|
189
173
|
// FIXME: What if both sbx and sa use the same catalogId?
|
|
190
174
|
const selectedCatalog = this.catalogs.find(
|
|
191
175
|
(catalog) => catalog.catalogId === catalogId,
|
|
@@ -193,9 +177,23 @@ export class SolidDsifExplorerPoc extends OrbitComponent {
|
|
|
193
177
|
|
|
194
178
|
if (selectedCatalog) {
|
|
195
179
|
try {
|
|
196
|
-
|
|
180
|
+
const catalogEntry = (await (
|
|
197
181
|
await fetch(selectedCatalog.endpoints.catalog)
|
|
198
|
-
).json()) as
|
|
182
|
+
).json()) as DSIFCatalogEntry;
|
|
183
|
+
|
|
184
|
+
catalogEntry["dcat:dataset"] = catalogEntry["dcat:dataset"].map(
|
|
185
|
+
(dataset) => ({
|
|
186
|
+
...dataset,
|
|
187
|
+
catalogTitle: catalogEntry["dct:title"],
|
|
188
|
+
catalogId: selectedCatalog.catalogId,
|
|
189
|
+
sectorName: selectedCatalog.sectorName,
|
|
190
|
+
sectorId: selectedCatalog.sectorId,
|
|
191
|
+
rootAuthorityUrl: selectedCatalog.rootAuthorityUrl,
|
|
192
|
+
sectorAuthorityUrl: selectedCatalog.sectorAuthorityUrl,
|
|
193
|
+
}),
|
|
194
|
+
) as DSIFDatasetWithContext[];
|
|
195
|
+
|
|
196
|
+
this.object = catalogEntry;
|
|
199
197
|
|
|
200
198
|
this.object["dcat:dataset"] = sort(
|
|
201
199
|
this.object["dcat:dataset"],
|
|
@@ -279,7 +277,7 @@ export class SolidDsifExplorerPoc extends OrbitComponent {
|
|
|
279
277
|
: this.catalogId === "*"
|
|
280
278
|
? `${msg("All Datasets")}`
|
|
281
279
|
: `${msg("Datasets from")}
|
|
282
|
-
${(datas as
|
|
280
|
+
${(datas as DSIFCatalogEntry)["dct:title"]} (From ${this.sectorId})`
|
|
283
281
|
: this.sectorId
|
|
284
282
|
? this.sectorId === "*"
|
|
285
283
|
? `${msg("All Sectors")}`
|
|
@@ -300,79 +298,22 @@ export class SolidDsifExplorerPoc extends OrbitComponent {
|
|
|
300
298
|
: nothing}</tems-header
|
|
301
299
|
>
|
|
302
300
|
<div slot="content">
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
: nothing}
|
|
320
|
-
type=${"bill-image"}
|
|
321
|
-
.header=${dataset["dct:title"] || nothing}
|
|
322
|
-
.content=${dataset["dct:description"] ||
|
|
323
|
-
nothing}
|
|
324
|
-
></ds4go-card-catalog>`,
|
|
325
|
-
)}`
|
|
326
|
-
: this.sectorId
|
|
327
|
-
? html`${datas.map(
|
|
328
|
-
(catalog: Catalog) =>
|
|
329
|
-
html`<ds4go-card-catalog
|
|
330
|
-
class="cursor-pointer"
|
|
331
|
-
.object=${import.meta.env.DEV
|
|
332
|
-
? catalog
|
|
333
|
-
: nothing}
|
|
334
|
-
type=${"bill-image"}
|
|
335
|
-
.header=${catalog.catalogId || nothing}
|
|
336
|
-
.content=${catalog.description || nothing}
|
|
337
|
-
date=${formatDate(catalog.lastUpdated) ||
|
|
338
|
-
nothing}
|
|
339
|
-
@click=${() =>
|
|
340
|
-
this._selectCatalog(catalog.catalogId)}
|
|
341
|
-
></ds4go-card-catalog>`,
|
|
342
|
-
)}`
|
|
343
|
-
: html`${datas.map(
|
|
344
|
-
(sector: Sector) =>
|
|
345
|
-
html`<ds4go-card-catalog
|
|
346
|
-
class="cursor-pointer"
|
|
347
|
-
.object=${import.meta.env.DEV
|
|
348
|
-
? sector
|
|
349
|
-
: nothing}
|
|
350
|
-
type=${"bill-image"}
|
|
351
|
-
.header=${sector.id || nothing}
|
|
352
|
-
.content=${sector.description || nothing}
|
|
353
|
-
date=${formatDate(sector.lastUpdated) ||
|
|
354
|
-
nothing}
|
|
355
|
-
@click=${() => this._selectSector(sector.id)}
|
|
356
|
-
></ds4go-card-catalog>`,
|
|
357
|
-
)}`}
|
|
358
|
-
</div>
|
|
359
|
-
</div>`
|
|
360
|
-
: html`<p>
|
|
361
|
-
${msg(
|
|
362
|
-
"No data available, data source may be temporarily unavailable.",
|
|
363
|
-
)}
|
|
364
|
-
</p>
|
|
365
|
-
${this.sectorId || this.catalogId
|
|
366
|
-
? html`<tems-button
|
|
367
|
-
type="primary"
|
|
368
|
-
label=${msg("Back")}
|
|
369
|
-
@click=${this._back}
|
|
370
|
-
></tems-button>`
|
|
371
|
-
: html`<tems-button
|
|
372
|
-
type="primary"
|
|
373
|
-
label=${msg("Retry")}
|
|
374
|
-
@click=${this.requestUpdate}
|
|
375
|
-
></tems-button>`}`}
|
|
301
|
+
<ds4go-catalog-filter-holder
|
|
302
|
+
.displayFiltering=${false}
|
|
303
|
+
@search=${this._search}
|
|
304
|
+
.search=${this.search}
|
|
305
|
+
.objects=${datas}
|
|
306
|
+
.resultCount=${this.resultCount}
|
|
307
|
+
.filterCount=${this.filterCount}
|
|
308
|
+
></ds4go-catalog-filter-holder>
|
|
309
|
+
<ds4go-dsif-explorer-poc-holder
|
|
310
|
+
.objects=${datas}
|
|
311
|
+
.search=${this.search}
|
|
312
|
+
@result-count=${this._resultCountUpdate}
|
|
313
|
+
.sectorId=${this.sectorId}
|
|
314
|
+
.catalogId=${this.catalogId}
|
|
315
|
+
.parent=${this}
|
|
316
|
+
></ds4go-dsif-explorer-poc-holder>
|
|
376
317
|
</div>
|
|
377
318
|
</tems-viewport>`;
|
|
378
319
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
filterObjectByValue,
|
|
3
|
+
formatCase,
|
|
3
4
|
formatDate,
|
|
4
5
|
OrbitComponent,
|
|
5
6
|
requestNavigation,
|
|
@@ -17,13 +18,6 @@ import ComponentStyles from "@styles/fact-bundle-creation.scss?inline";
|
|
|
17
18
|
import { html, nothing, unsafeCSS } from "lit";
|
|
18
19
|
import { customElement, property, state } from "lit/decorators.js";
|
|
19
20
|
|
|
20
|
-
const formatCase = (str: string) => {
|
|
21
|
-
return str
|
|
22
|
-
.replace(/([A-Z])/g, " $1")
|
|
23
|
-
.replace(/^./, (str) => str.toUpperCase())
|
|
24
|
-
.trim();
|
|
25
|
-
};
|
|
26
|
-
|
|
27
21
|
@customElement("solid-fact-bundle-creation")
|
|
28
22
|
export class SolidFactBundle extends OrbitComponent {
|
|
29
23
|
static styles = [unsafeCSS(ComponentStyles)];
|
|
@@ -153,6 +147,9 @@ export class SolidFactBundle extends OrbitComponent {
|
|
|
153
147
|
this.spliceLength =
|
|
154
148
|
Math.floor((window.innerWidth - 800) / 354) *
|
|
155
149
|
Math.floor((window.innerHeight - 255) / 500);
|
|
150
|
+
if (this.spliceLength < 5) {
|
|
151
|
+
this._showAllResults();
|
|
152
|
+
}
|
|
156
153
|
}
|
|
157
154
|
|
|
158
155
|
if (factsWithoutSelected.length > 0) {
|
|
@@ -254,7 +251,10 @@ export class SolidFactBundle extends OrbitComponent {
|
|
|
254
251
|
offeredAccess: "40",
|
|
255
252
|
pricingTier: "premium",
|
|
256
253
|
"dcat:endpointUrl": newFactBundleId,
|
|
257
|
-
previewLinks: this.selectedFacts
|
|
254
|
+
previewLinks: this.selectedFacts
|
|
255
|
+
.slice(0, 3)
|
|
256
|
+
.map((fact) => fact["@id"])
|
|
257
|
+
.join(", "),
|
|
258
258
|
"dsif:pricing": {
|
|
259
259
|
"dsif:costPerAPICall": 0.15,
|
|
260
260
|
"dsif:setupFee": 50,
|
|
@@ -424,7 +424,7 @@ export class SolidFactBundle extends OrbitComponent {
|
|
|
424
424
|
? html`<tems-button
|
|
425
425
|
type="primary"
|
|
426
426
|
disabled=${this.selectedFacts.length === 0 || nothing}
|
|
427
|
-
label=${msg("
|
|
427
|
+
label=${msg("Next")}
|
|
428
428
|
@click=${this._nextStep}
|
|
429
429
|
></tems-button>`
|
|
430
430
|
: html`<div class="flex">
|
package/src/helpers/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ import filterObjectByNamedValue from "@helpers/datas/filterObjectByNamedValue";
|
|
|
14
14
|
import filterObjectByType from "@helpers/datas/filterObjectByType";
|
|
15
15
|
import filterObjectByValue from "@helpers/datas/filterObjectByValue";
|
|
16
16
|
import sort from "@helpers/datas/sort";
|
|
17
|
+
import formatCase from "@helpers/ui/formatCase";
|
|
17
18
|
import formatDate from "@helpers/ui/formatDate";
|
|
18
19
|
import requestNavigation from "@helpers/utils/requestNavigation";
|
|
19
20
|
import uniq from "@helpers/utils/uniq";
|
|
@@ -29,6 +30,7 @@ export {
|
|
|
29
30
|
filterObjectByValue,
|
|
30
31
|
filterObjectByType,
|
|
31
32
|
filterObjectByDateInterval,
|
|
33
|
+
formatCase,
|
|
32
34
|
formatDate,
|
|
33
35
|
ComponentObjectHandler,
|
|
34
36
|
ComponentObjectsHandler,
|