Skip to content

Commit

Permalink
Merge pull request #19 from camptocamp/dataset-information-block
Browse files Browse the repository at this point in the history
[Dataset page] Information block
  • Loading branch information
cmoinier authored Feb 26, 2024
2 parents d74f764 + 1b9601d commit 7dad1cc
Show file tree
Hide file tree
Showing 13 changed files with 322 additions and 51 deletions.
104 changes: 88 additions & 16 deletions apps/datahub-e2e/src/e2e/dataset.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,78 @@ describe('datasets', () => {
.should('have.css', 'max-height', '72px')
})

describe('Information block', () => {
beforeEach(() =>
cy
.get('mel-datahub-dataset-information')
.children('div')
.first()
.children('div')
.eq(1)
.as('mainInfo')
)
it('should display the information block', () => {
cy.get('mel-datahub-dataset-information').should('be.visible')
})

it('should display the update date', () => {
cy.get('@mainInfo')
.first()
.find('div')
.first()
.find('span')
.should('have.text', 'Mise à jour le')
})

it('should display the categories btns', () => {
cy.get('@mainInfo')
.children('div')
.eq(1)
.find('div')
.children('button')
.should('have.length.gt', 0)
})

it('should display the territories', () => {
cy.get('@mainInfo')
.children('div')
.eq(2)
.find('div')
.children('button')
.should('have.length.gt', 0)
})

it('should display the licenses', () => {
cy.get('@mainInfo')
.children('div')
.eq(3)
.children('span')
.eq(1)
.should('have.length.gt', 0)
})

it('should display the producer', () => {
cy.get('@mainInfo')
.children('div')
.eq(4)
.find('span')
.eq(1)
.should('have.text', 'Bundesamt für Raumentwicklung')
})

it('should display the social media share btns', () => {
cy.get('mel-datahub-dataset-information')
.children('div')
.first()
.children('div')
.eq(2)
.children('div')
.first()
.find('a')
.should('have.length', 4)
})
})

it('should display the abstract in expanded mode without gradient', () => {
cy.get('mel-datahub-text-expand').should('be.visible')
cy.get('mel-datahub-text-expand').find('mel-datahub-button').click()
Expand All @@ -76,21 +148,21 @@ describe('datasets', () => {
cy.get('mel-datahub-footer').should('be.visible')
})
})
describe('when logged in', () => {
beforeEach(() => {
cy.login()
cy.clearFavorites()
cy.visit('/dataset/8698bf0b-fceb-4f0f-989b-111e7c4af0a4')
})
it('should toggle the favorite button', () => {
cy.get('mel-datahub-button').eq(0).as('favoriteButton')
cy.get('@favoriteButton')
.find('img')
.should('have.attr', 'src', 'assets/icons/heart.svg')
cy.get('@favoriteButton').click()
cy.get('@favoriteButton')
.find('img')
.should('have.attr', 'src', 'assets/icons/heart-filled.svg')
})
})
describe('when logged in', () => {
beforeEach(() => {
cy.login()
cy.clearFavorites()
cy.visit('/dataset/8698bf0b-fceb-4f0f-989b-111e7c4af0a4')
})
it('should toggle the favorite button', () => {
cy.get('mel-datahub-button').eq(0).as('favoriteButton')
cy.get('@favoriteButton')
.find('img')
.should('have.attr', 'src', 'assets/icons/heart.svg')
cy.get('@favoriteButton').click()
cy.get('@favoriteButton')
.find('img')
.should('have.attr', 'src', 'assets/icons/heart-filled.svg')
})
})
2 changes: 2 additions & 0 deletions apps/datahub/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import { HeartToggleComponent } from './common/favorites/heart-toggle/heart-togg
import { TextExpandComponent } from './common/text-expand/text-expand.component'
import { MelDatahubFooterComponent } from './common/footer/mel-datahub-footer.component'
import { CustomCarouselComponent } from './common/custom-carousel/custom-carousel.component'
import { DatasetInformationComponent } from './dataset/dataset-information/dataset-information.component'

@NgModule({
declarations: [
Expand Down Expand Up @@ -83,6 +84,7 @@ import { CustomCarouselComponent } from './common/custom-carousel/custom-carouse
TextExpandComponent,
MelDatahubFooterComponent,
CustomCarouselComponent,
DatasetInformationComponent,
],
imports: [
BrowserModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="mel-grid-container-dataset py-16">
<div class="md:col-start-2 lg:col-start-2 md:col-span-6 lg:col-span-8">
<div class="mel-grid-container-dataset">
<div class="md:col-start-2 lg:col-start-2 md:col-span-6 lg:col-span-8 py-16">
<div class="flex justify-end gap-2">
<mel-datahub-favorite-heart
[record]="record"
Expand Down Expand Up @@ -38,13 +38,10 @@ <h2 class="text-2xl font-title mb-6" translate>mel.dataset.abstract</h2>
</gn-ui-content-ghost>
}
</div>
<!-- TODO: create corresponding UI component -->
<div class="md:col-span-5 lg:col-span-3 overflow-hidden">
<div translate="">mel.dataset.informations</div>
<div>{{ record.recordUpdated }}</div>
<div>{{ record.keywords }}</div>
<div>{{ record.themes }}</div>
<div>{{ record.licenses }}</div>
<div>{{ record.ownerOrganization?.name }}</div>
<mel-datahub-dataset-information
[record]="record"
(keyword)="onInfoKeywordClick($event)"
></mel-datahub-dataset-information>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core'
import { RouterFacade } from 'geonetwork-ui'
import {
CatalogRecord,
DatasetRecord,
Expand All @@ -19,6 +20,8 @@ export class DatasetHeaderComponent {

@Input() incomplete: boolean

constructor(protected routerFacade: RouterFacade) {}

fieldReady(propName: string) {
return !this.incomplete || propName in this.metadata
}
Expand All @@ -30,4 +33,8 @@ export class DatasetHeaderComponent {
scrollTo(id: string) {
document.getElementById(id).scrollIntoView({ behavior: 'smooth' })
}

onInfoKeywordClick(keyword: string) {
this.routerFacade.updateSearch({ q: keyword })
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<div class="flex flex-col border-l-[1px] border-gray-5 pt-12 pb-8 pl-8 pr-20">
<div class="pb-6 gap-1">
<div class="inline-flex bg-primary h-1 w-16"></div>
<div class="text-2xl font-title" translate="">mel.dataset.informations</div>
</div>
<div class="flex flex-col gap-8 border-b-[1px] border-gray-3 pb-6">
@if(lastUpdate){
<div class="flex flex-row gap-2">
<span class="font-semibold" translate="">mel.dataset.updatedOn</span>
<div class="text-primary font-semibold">{{ lastUpdate }}</div>
</div>
} @if(record.keywords?.length) {
<div class="flex flex-col gap-2">
<span class="font-semibold" translate="">mel.dataset.categories</span>
<div class="flex gap-1 gap-x-2 flex-row flex-wrap">
@for(keyword of record.keywords; track record.uniqueIdentifier) {
<button
type="button"
[attr.aria-label]="keyword"
[title]="keyword"
(click)="onKeywordClick(keyword, $event)"
class="mel-badge-button-primary truncate"
>
{{ keyword }}
</button>
}
</div>
</div>
}
<!-- TODO: add an if condition when the territories field will be available -->
<div class="flex flex-col gap-2">
<span class="font-semibold" translate="">mel.dataset.territories</span>
<div class="flex gap-1 gap-x-2 flex-row flex-wrap">
<button
type="button"
aria-label="Lille"
title="Lille"
class="mel-badge-button-secondary truncate"
>
Lille
</button>
<button
type="button"
aria-label="Hauts-de-France"
title="Hauts-de-France"
class="mel-badge-button-secondary truncate"
>
Hauts-de-France
</button>
</div>
</div>
@if(record.licenses?.length) {
<div class="inline-block break-normal font-semibold">
<span class="mr-1" translate="">mel.dataset.licenses</span>
<span>
{{ record.licenses[0].text }}
</span>
</div>
} @if(record.ownerOrganization) {
<div class="inline-block break-normal font-semibold">
<span class="mr-1" translate="">mel.dataset.owner</span>
<span>{{ record.ownerOrganization?.name }}</span>
</div>
}
</div>
<div class="flex flex-col gap-2 pt-4">
<span class="font-semibold" translate="">mel.dataset.share</span>
<div class="flex flex-row gap-4 flex-wrap">
<a
class="mel-social-media-button"
href="https://twitter.com/MetropoleLille/"
target="_blank"
>
<img
class="h-6"
src="{{ iconsUrl }}twitter.svg"
[alt]="'mel.dataset.logo.twitter' | translate"
/></a>
<a
class="mel-social-media-button"
href="https://www.facebook.com/metropoledelille/"
target="_blank"
>
<img
class="h-6 mr-0.5"
src="{{ iconsUrl }}facebook.svg"
[alt]="'mel.dataset.logo.facebook' | translate"
/></a>
<a
class="mel-social-media-button"
href="https://fr.linkedin.com/company/metropoledelille/"
target="_blank"
>
<img
class="h-4"
src="{{ iconsUrl }}linkedin.svg"
[alt]="'mel.dataset.logo.linkedin' | translate"
/></a>
<a
class="mel-social-media-button"
href="mailto: [email protected]"
target="_blank"
>
<img
class="h-6"
src="{{ iconsUrl }}email.svg"
[alt]="'mel.dataset.logo.email' | translate"
/></a>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {
ChangeDetectionStrategy,
Component,
EventEmitter,
Input,
Output,
} from '@angular/core'
import { TranslateService } from '@ngx-translate/core'
import { CatalogRecord } from 'geonetwork-ui/libs/common/domain/src/lib/model/record'

@Component({
selector: 'mel-datahub-dataset-information',
templateUrl: './dataset-information.component.html',
styles: ``,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DatasetInformationComponent {
@Input() record: CatalogRecord
iconsUrl = 'assets/icons/'
@Output() keyword = new EventEmitter<string>()

constructor(public translateService: TranslateService) {}

get lastUpdate() {
return this.record?.recordUpdated?.toLocaleDateString(
this.translateService.currentLang
)
}

onKeywordClick(keyword: string, event: Event) {
event.stopPropagation()
this.keyword.emit(keyword)
}
}
58 changes: 34 additions & 24 deletions apps/datahub/src/assets/i18n/en_MEL.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,44 @@
"mel.common.footer.contact": "Contact us",
"mel.common.footer.follow": "Follow us !",
"mel.common.footer.legal": "Legal mentions",
"mel.common.footer.logo.financeUE": "",
"mel.common.footer.logo.franceRelance": "",
"mel.common.footer.logo.financeUE": "Financed by the European Union",
"mel.common.footer.logo.franceRelance": "France Relance",
"mel.common.footer.newletter.signup": "Sign up to the newsletter",
"mel.common.footer.news": "Last news",
"mel.common.footer.newsletter.inform": "Subscribe to the newsletter and stay informed of MEL's last news !",
"mel.common.footer.plan": "Sitemap",
"mel.common.footer.recruitment": "Recruitment",
"mel.common.footer.social": "Social medias",
"mel.common.header.title": "",
"mel.datahub.home.title": "",
"mel.datahub.search.title": "",
"mel.dataset.abstract": "",
"mel.dataset.api": "",
"mel.dataset.download": "",
"mel.dataset.favorite": "",
"mel.dataset.informations": "",
"mel.dataset.less": "",
"mel.dataset.more": "",
"mel.record.metadata.api": "",
"mel.record.metadata.api.form.closeButton": "",
"mel.record.metadata.api.form.title": "",
"mel.record.metadata.localisation": "",
"mel.record.metadata.preview": "",
"mel.record.metadata.producteur": "",
"mel.record.metadata.quality": "",
"mel.record.metadata.quality.details": "",
"mel.record.metadata.related": "",
"mel.record.tab.chart": "",
"mel.record.tab.data": "",
"mel.record.tab.map": ""
"mel.common.header.title": "Data platform",
"mel.datahub.home.title": "Métropole Européenne de Lille",
"mel.datahub.search.title": "dataset catalog",
"mel.dataset.abstract": "Abstract",
"mel.dataset.api": "API",
"mel.dataset.categories": "Categories :",
"mel.dataset.download": "Download",
"mel.dataset.favorite": "Favorites",
"mel.dataset.informations": "Information",
"mel.dataset.less": "Less",
"mel.dataset.licenses": "License :",
"mel.dataset.logo.email": "Email",
"mel.dataset.logo.facebook": "Facebook",
"mel.dataset.logo.linkedin": "Linkedin",
"mel.dataset.logo.twitter": "Twitter",
"mel.dataset.more": "More",
"mel.dataset.owner": "Producer :",
"mel.dataset.share": "Share this content :",
"mel.dataset.territories": "Territories :",
"mel.dataset.updatedOn": "Updated on",
"mel.record.metadata.api": "API",
"mel.record.metadata.api.form.closeButton": "Close",
"mel.record.metadata.api.form.title": "Generate a custom URL",
"mel.record.metadata.localisation": "Location",
"mel.record.metadata.preview": "Preview",
"mel.record.metadata.producteur": "Producer",
"mel.record.metadata.quality": "Metadata quality",
"mel.record.metadata.quality.details": "Details",
"mel.record.metadata.related": "Similar records",
"mel.record.tab.chart": "Analysis",
"mel.record.tab.data": "Table",
"mel.record.tab.map": "Map"
}
Loading

0 comments on commit 7dad1cc

Please sign in to comment.