Skip to content

Commit

Permalink
"Generated by an API" label is displayed for both WFS and OGC API dow…
Browse files Browse the repository at this point in the history
…nloads
  • Loading branch information
ronitjadhav committed Jan 20, 2025
1 parent fbf7973 commit d19b770
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 26 deletions.
4 changes: 1 addition & 3 deletions apps/datahub-e2e/src/e2e/datasets.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ describe('datasets', () => {
cy.visit('/search')

// aliases
cy.get('gn-ui-results-list-item', { timeout: 10000 })
.find('a')
.as('results')
cy.get('gn-ui-results-list-item').find('a').as('results')
cy.get('@results').eq(2).as('sampleResult')
cy.get('@results')
.then(($results) => $results.length)
Expand Down
9 changes: 9 additions & 0 deletions libs/common/fixtures/src/lib/link.fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,15 @@ export const aSetOfLinksFixture = () => ({
),
accessServiceProtocol: 'wfs',
} as DatasetDownloadDistribution),
geodataOgcApiDownload: () =>
({
name: 'mylayer',
type: 'download',
url: new URL(
'https://my.ogc.server/data/ogcapi/collections/comptages_velo/items?'
),
accessServiceProtocol: 'ogcFeatures',
} as DatasetDownloadDistribution),
geodataWms2: () =>
({
name: 'myotherlayer',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
>
<span
class="pl-2 inline-flex items-center text-gray-800 text-sm"
*ngIf="isFromWfs"
*ngIf="isFromAPI"
translate=""
>datahub.search.filter.generatedByWfs</span
>datahub.search.filter.generatedByAPI</span
>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,19 @@ describe('DownloadsListItemComponent', () => {
expect(badgeElt.styles['background-color']).toEqual('red')
})

describe('when it is not Wfs', () => {
it('do not display wfs information', () => {
describe('when it is not WFS or OGC API', () => {
it('do not display wfs or OGC API information', () => {
const spans = fixture.debugElement.queryAll(By.css('span'))

expect(spans.length).toBe(1)
})
})
describe('when it is not Wfs', () => {
describe('when it is WFS or OGC API', () => {
beforeEach(() => {
component.isFromWfs = true
component.isFromAPI = true
fixture.detectChanges()
})
it('add wfs information', () => {
it('add WFS or OGC API information', () => {
const spans = fixture.debugElement.queryAll(By.css('span'))

expect(spans.length).toBe(2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class DownloadItemComponent {
@Input() link: DatasetOnlineResource
@Input() color: string
@Input() format: string
@Input() isFromWfs: boolean
@Input() isFromAPI: boolean
@Output() exportUrl = new EventEmitter<string>()

openUrl() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
[link]="link"
[color]="getLinkColor(link)"
[format]="getLinkFormat(link)"
[isFromWfs]="isFromWfs(link)"
[isFromAPI]="isFromAPI(link)"
></gn-ui-download-item>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe('DownloadsListComponent', () => {
fixture.detectChanges()
items = de.queryAll(By.directive(DownloadItemComponent))
})
it('contains color, isWfs & format', () => {
it('contains color, isAPI & format', () => {
expect(items.length).toBe(1)
expect(items[0].componentInstance.link).toEqual(
aSetOfLinksFixture().geodataShpWithMimeType()
Expand All @@ -125,7 +125,7 @@ describe('DownloadsListComponent', () => {
expect(items[0].componentInstance.color).toEqual(
expect.stringMatching(/#[0-9a-b]{2,6}/i)
)
expect(items[0].componentInstance.isFromWfs).toEqual(false)
expect(items[0].componentInstance.isFromAPI).toEqual(false)
})
})
describe('displaying download links from WFS', () => {
Expand All @@ -136,8 +136,20 @@ describe('DownloadsListComponent', () => {
fixture.detectChanges()
items = de.queryAll(By.directive(DownloadItemComponent))
})
it('sets isFromWfs to true', () => {
expect(items[0].componentInstance.isFromWfs).toEqual(true)
it('sets isFromAPI to true', () => {
expect(items[0].componentInstance.isFromAPI).toEqual(true)
})
})
describe('displaying download links from OGC Features', () => {
let items: DebugElement[]

beforeEach(() => {
component.links = [aSetOfLinksFixture().geodataOgcApiDownload()]
fixture.detectChanges()
items = de.queryAll(By.directive(DownloadItemComponent))
})
it('sets isFromAPI to true', () => {
expect(items[0].componentInstance.isFromAPI).toEqual(true)
})
})
describe('filtering links', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ export class DownloadsListComponent {
return getBadgeColor(getFileFormat(link))
}

isFromWfs(link: DatasetOnlineResource) {
return link.type === 'download' && link.accessServiceProtocol === 'wfs'
isFromAPI(link: DatasetOnlineResource) {
return (
link.type === 'download' &&
(link.accessServiceProtocol === 'wfs' ||
link.accessServiceProtocol === 'ogcFeatures')
)
}
}
2 changes: 1 addition & 1 deletion translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"datahub.record.addToFavorites": "Zu Favoriten hinzufügen",
"datahub.search.back": "Zurück",
"datahub.search.filter.all": "Alle",
"datahub.search.filter.generatedByWfs": "Generiert durch eine API",
"datahub.search.filter.generatedByAPI": "Generiert durch eine API",
"datahub.search.filter.others": "Andere",
"dataset.error.http": "Die Daten konnten aufgrund eines HTTP-Fehlers nicht geladen werden: \"{ info }\"",
"dataset.error.network": "Die Daten konnten aufgrund eines Netzwerkfehlers oder CORS-Beschränkungen nicht geladen werden: \"{ info }\"",
Expand Down
2 changes: 1 addition & 1 deletion translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"datahub.record.addToFavorites": "Add to favorites",
"datahub.search.back": "Back",
"datahub.search.filter.all": "All",
"datahub.search.filter.generatedByWfs": "Generated by an API",
"datahub.search.filter.generatedByAPI": "Generated by an API",
"datahub.search.filter.others": "Others",
"dataset.error.http": "The data could not be loaded because of an HTTP error: \"{ info }\"",
"dataset.error.network": "The data could not be loaded because of a network error or CORS limitations: \"{ info }\"",
Expand Down
2 changes: 1 addition & 1 deletion translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"datahub.record.addToFavorites": "",
"datahub.search.back": "",
"datahub.search.filter.all": "",
"datahub.search.filter.generatedByWfs": "",
"datahub.search.filter.generatedByAPI": "",
"datahub.search.filter.others": "",
"dataset.error.http": "",
"dataset.error.network": "",
Expand Down
2 changes: 1 addition & 1 deletion translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"datahub.record.addToFavorites": "Ajouter aux favoris",
"datahub.search.back": "Retour",
"datahub.search.filter.all": "Tous",
"datahub.search.filter.generatedByWfs": "généré par une API",
"datahub.search.filter.generatedByAPI": "généré par une API",
"datahub.search.filter.others": "Autres",
"dataset.error.http": "Le chargement des données a échoué en raison d'une erreur HTTP: \"{ info }\"",
"dataset.error.network": "Le chargement des données a échoué en raison d'une erreur réseau ou de limitations CORS: \"{ info }\"",
Expand Down
2 changes: 1 addition & 1 deletion translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"datahub.record.addToFavorites": "Aggiungere a miei preferiti",
"datahub.search.back": "Ritorna",
"datahub.search.filter.all": "Tutti",
"datahub.search.filter.generatedByWfs": "generato da un'API",
"datahub.search.filter.generatedByAPI": "generato da un'API",
"datahub.search.filter.others": "Altri",
"dataset.error.http": "Il caricamento dei dati non è riuscito a causa di un errore HTTP: \"{info}\"",
"dataset.error.network": "Il caricamento dei dati non è riuscito a causa di un errore di rete o di limitazioni CORS: \"{info}\"",
Expand Down
2 changes: 1 addition & 1 deletion translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"datahub.record.addToFavorites": "",
"datahub.search.back": "",
"datahub.search.filter.all": "",
"datahub.search.filter.generatedByWfs": "",
"datahub.search.filter.generatedByAPI": "",
"datahub.search.filter.others": "",
"dataset.error.http": "",
"dataset.error.network": "",
Expand Down
2 changes: 1 addition & 1 deletion translations/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"datahub.record.addToFavorites": "",
"datahub.search.back": "",
"datahub.search.filter.all": "",
"datahub.search.filter.generatedByWfs": "",
"datahub.search.filter.generatedByAPI": "",
"datahub.search.filter.others": "",
"dataset.error.http": "",
"dataset.error.network": "",
Expand Down
2 changes: 1 addition & 1 deletion translations/sk.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"datahub.record.addToFavorites": "Pridať do obľúbených",
"datahub.search.back": "Späť na výsledky",
"datahub.search.filter.all": "Všetky",
"datahub.search.filter.generatedByWfs": "vygenerované cez API",
"datahub.search.filter.generatedByAPI": "vygenerované cez API",
"datahub.search.filter.others": "Iné",
"dataset.error.http": "Dáta sa nedajú načítať kvôli chybe HTTP: \"{ info }\"",
"dataset.error.network": "Dáta sa nedajú načítať kvôli chybe v sieti alebo obmedzeniam CORS: \"{ info }\"",
Expand Down

0 comments on commit d19b770

Please sign in to comment.