Skip to content

Commit

Permalink
fix asked by camp2camp
Browse files Browse the repository at this point in the history
  • Loading branch information
gkeimeHDF committed Jul 5, 2023
1 parent f13e429 commit 00e9c4b
Show file tree
Hide file tree
Showing 13 changed files with 143 additions and 44 deletions.
2 changes: 1 addition & 1 deletion apps/datahub/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ body {
}

.container-xs {
max-width: 500px;
max-width: calc(100% - 170px);
}
.container-sm {
max-width: 640px;
Expand Down
3 changes: 1 addition & 2 deletions apps/search/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
"results.sortBy.dateStamp": "Last updates",
"results.sortBy.popularity": "Popularity",
"results.sortBy.relevancy": "Relevancy",
"results.sortBy.qualityScore": "Quality score",
"search.field.any.placeholder": "Search datasets, services and maps ...",
"search.field.sortBy": "Sort by",
"search.loading": "Loading ..."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
getFirstValue,
LinkClassifierService,
LinkUsage,
mapContact,
MetadataLink,
MetadataLinkType,
MetadataRecord,
Expand Down Expand Up @@ -33,7 +34,7 @@ export class ElasticsearchFieldMapper {
constructor(
private metadataUrlService: MetadataUrlService,
private linkClassifier: LinkClassifierService
) {}
) { }

protected fields: Record<string, EsFieldMapperFn> = {
id: (output, source) => ({
Expand Down Expand Up @@ -153,7 +154,7 @@ export class ElasticsearchFieldMapper {
constraints
}
},
MD_LegalConstraintsOtherConstraintsObject: (output, source) =>
MD_LegalConstraintsOtherConstraintsObject: (output, source) =>
this.constraintField(
'MD_LegalConstraintsOtherConstraintsObject',
output,
Expand Down Expand Up @@ -189,14 +190,14 @@ export class ElasticsearchFieldMapper {
}

private calculateQualityScore = (source) => {
const qualityScore:number = selectField(source, 'qualityScore');
const qualityScore: number = selectField(source, 'qualityScore');
if (qualityScore != null) {
return qualityScore;
}
}
const metadataQualityConfig: MetadataQualityConfig = getMetadataQualityConfig();
let total = 0;
let success = 0;
const check = (name:string) => {
const check = (name: string) => {
const display = metadataQualityConfig[`DISPLAY_${name}`] !== false;
if (display) total++;
return display;
Expand Down Expand Up @@ -250,14 +251,16 @@ export class ElasticsearchFieldMapper {

private genericField = (output) => output

private constraintField = (fieldName: string, output, source) => ({
...output,
constraints: [
...(output.constraints || []),
...selectField<unknown[]>(source, fieldName).map(selectTranslatedValue),
],
})

private constraintField = (fieldName: string, output, source) => {
const constraints = Array.isArray(output.constraints) ? output.constraints : [];
const fieldValues = selectField<unknown[]>(source, fieldName);
const translatedValues = fieldValues.map(selectTranslatedValue);
const updatedConstraints = [...constraints, ...translatedValues];
return {
...output,
constraints: updatedConstraints,
};
}
getMappingFn(fieldName: string) {
return fieldName in this.fields ? this.fields[fieldName] : this.genericField
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ class OrganisationsServiceMock {
of(
'contact' in source
? {
...record,
contact: {
name: 'Main Contact',
...record,
contact: {
name: 'Main Contact',
email: '[email protected]',
organisation: source.contact[0].organisation,
},
resourceContacts: [
{
name: 'Resource Contact 1',
email: '[email protected]',
organisation: source.contact[0].organisation,
},
resourceContacts: [
{
name: 'Resource Contact 1',
email: '[email protected]',
},
{
name: 'Resource Contact 2',
email: '[email protected]',
},
],
}
{
name: 'Resource Contact 2',
email: '[email protected]',
},
],
}
: record
)
)
Expand Down Expand Up @@ -78,6 +78,7 @@ describe('ElasticsearchMapper', () => {
abstract: 'The grid is based on proposal ',
id: '12456',
metadataUrl: 'url',
qualityScore: 25,
thumbnailUrl: 'data:image/png;base64,',
title: 'EEA reference grid for Germany (10km), May 2013',
uuid: '20e9e1a1-83c1-4f13-89ef-c19767d6ee18f',
Expand All @@ -90,6 +91,7 @@ describe('ElasticsearchMapper', () => {
abstract: 'Reference layer of the rivers sensitive areas, ',
id: '12442',
metadataUrl: 'url',
qualityScore: 25,
thumbnailUrl: 'data:image/png;base64,',
title:
'Urban Waste Water Treatment Directive, Sensitive areas - rivers reported under UWWTD data call 2015, Nov. 2017',
Expand Down Expand Up @@ -428,9 +430,13 @@ describe('ElasticsearchMapper', () => {
],
metadataUrl: 'url',
ownerInfo: 'testadmin|ADMIN|Test|Administrator',
qualityScore: 100,
thumbnailUrl:
'https://sextant.ifremer.fr/geonetwork/srv/api/records/cf5048f6-5bbf-4e44-ba74-e6f429af51ea/attachments/parametres.gif',
title: 'Surval - Données par paramètre',
topic: [
'Océans',
],
uuid: 'cf5048f6-5bbf-4e44-ba74-e6f429af51ea',
contact: {
name: 'Main Contact',
Expand Down Expand Up @@ -512,11 +518,12 @@ describe('ElasticsearchMapper', () => {
'Sète',
'La Rochelle',
],
legalConstraints: [
"Restriction légale d'utilisation à préciser",
],
lineage:
'Les données sont bancarisées dans la base de données Quadrige.',
constraints: [
'Restriction lié à l’exercice du droit moral',
"Restriction légale d'utilisation à préciser",
'Pas de restriction d’accès public',
'Licence Ouverte version 2.0 https://www.etalab.gouv.fr/wp-content/uploads/2017/04/ETALAB-Licence-Ouverte-v2.0.pdf',
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ export class MetadataQualityInfoComponent {
@Input() value: boolean

get display() {
const name_snake_upper = this.name.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`).toUpperCase();
return this.metadataQualityConfig['DISPLAY_' + name_snake_upper] !== false;
if (this.name) {
const nameSnakeUpper = this.name.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`).toUpperCase();
return this.metadataQualityConfig['DISPLAY_' + nameSnakeUpper] !== false;
}
return false;
}

get icon() {
return this.value ? 'check' : 'warning_amber'
return this.value ? 'check' : 'warning_amber'
}

get labelKey() {
return 'record.metadata.quality.' + this.name + '.' + (this.value ? 'success' : 'failed')
return `record.metadata.quality.${this.name}.${(this.value ? 'success' : 'failed')}`
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
:host-context(.picto)>.metadata-quality {
margin-bottom: 0px;
}


:host-context(.picto) > .metadata-quality > .widget > p.text {
display: none;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { RECORDS_FULL_FIXTURE } from '@geonetwork-ui/util/shared/fixtures'
import { TranslateModule } from '@ngx-translate/core'
import { ContentGhostComponent } from '../content-ghost/content-ghost.component'
import { MetadataQualityComponent } from './metadata-quality.component'
import { By } from '@angular/platform-browser'

describe('MetadataQualityComponent', () => {
let component: MetadataQualityComponent
Expand All @@ -26,4 +27,28 @@ describe('MetadataQualityComponent', () => {
it('should create', () => {
expect(component).toBeTruthy()
})

it('focus should show menu / blur should hide', () => {
const progressBar = fixture.debugElement.query(By.css('gn-ui-progress-bar'))
progressBar.nativeElement.focus();
expect(component.isMenuShown).toBe(true)
progressBar.nativeElement.blur();
expect(component.isMenuShown).toBe(false)
})

it('mouseenter should show menu / mouseleave should hide', () => {
const metadataQuality = fixture.debugElement.query(By.css('.metadata-quality'))

const mouseEnterEvent = new Event('mouseenter');
metadataQuality.nativeElement.dispatchEvent(mouseEnterEvent);
expect(component.isMenuShown).toBe(true)

const mouseLeaveEvent = new Event('mouseleave');
metadataQuality.nativeElement.dispatchEvent(mouseLeaveEvent);
expect(component.isMenuShown).toBe(false)
})

it('content', () => {
expect(component.metadata?.contact?.organisation).toBe("Ifremer");
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {
TRANSLATE_DEFAULT_CONFIG,
UtilI18nModule,
} from '@geonetwork-ui/util/i18n'
import { TranslateModule } from '@ngx-translate/core'
import { Meta, moduleMetadata, Story } from '@storybook/angular'
import { MetadataQualityComponent } from './metadata-quality.component'
import { UiElementsModule } from '../ui-elements.module'
import { RECORDS_FULL_FIXTURE } from '@geonetwork-ui/util/shared/fixtures'

export default {
title: 'Elements/MetadataQualityComponent',
component: MetadataQualityComponent,
decorators: [
moduleMetadata({
imports: [
UiElementsModule,
UtilI18nModule,
TranslateModule.forRoot(TRANSLATE_DEFAULT_CONFIG),
],
}),
],
} as Meta<MetadataQualityComponent>

const Template: Story<MetadataQualityComponent> = (
args: MetadataQualityComponent
) => ({
component: MetadataQualityComponent,
props: args,
})

export const Primary = Template.bind({})
Primary.args = {
metadata: RECORDS_FULL_FIXTURE[1],
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'

import { ProgressBarComponent } from './progress-bar.component'

jest.mock('@geonetwork-ui/util/app-config', () => ({
getThemeConfig: () => ({
PROGRESS_BAR_TEXT_CLASS: '',
}),
isConfigLoaded: jest.fn(() => true),
}))

describe('ProgressBarComponent', () => {
let component: ProgressBarComponent
let fixture: ComponentFixture<ProgressBarComponent>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { moduleMetadata, Story, Meta } from '@storybook/angular'
import { ProgressBarComponent } from './progress-bar.component'


export default {
title: 'Widgets/ProgressBarComponent',
component: ProgressBarComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input } from '@angular/core'
import { getThemeConfig } from '@geonetwork-ui/util/app-config'
import { getThemeConfig, isConfigLoaded } from '@geonetwork-ui/util/app-config'

interface ColorScheme {
outerBar: string
Expand All @@ -15,7 +15,7 @@ interface ColorScheme {
export class ProgressBarComponent {
@Input() value = 0
@Input() type: 'primary' | 'secondary' | 'default' = 'default'
textClass = getThemeConfig().PROGRESS_BAR_TEXT_CLASS || 'font-bold'
textClass = isConfigLoaded() ? getThemeConfig().PROGRESS_BAR_TEXT_CLASS : 'font-bold'

get progress() {
return this.value > 0 ? (this.value < 100 ? this.value : 100) : 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,14 @@ describe('ElasticsearchService', () => {
'linkProtocol',
'contactForResource.organisation',
'contact.organisation',
'contact.email',
'userSavedCount',
"updateFrequency",
"cl_topic",
"cl_maintenanceAndUpdateFrequency",
"tag",
"MD_LegalConstraintsUseLimitationObject",
"qualityScore",
],
query: {
bool: {
Expand Down
17 changes: 17 additions & 0 deletions libs/util/shared/src/lib/fixtures/records.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,21 @@ export const RECORDS_FULL_FIXTURE: MetadataRecord[] = deepFreeze([
},
catalogUuid: '6731be1e-6533-44e0-9b8a-580b45e36e80',
},
{
id: '10421',
uuid: 'cf5048f6-5bbf-4e44-ba74-e6f429af51eb',
metadataUrl: 'url',
title: 'Test',
abstract: "La description du test",
updateFrequency: null,
keywords: [],
contact: {
name: 'Jean-Michel',
organisation: 'Ifremer',
email: '[email protected]',
},
topic: [],
legalConstraints: [],
qualityScore: 50
}
])

0 comments on commit 00e9c4b

Please sign in to comment.