Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Angi-Kinas authored and f-necas committed Nov 22, 2023
1 parent 6653144 commit 36efb2b
Show file tree
Hide file tree
Showing 11 changed files with 158 additions and 53 deletions.
62 changes: 62 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# TODO :

- [ ] contact: organisation ou individualname

Contact filter :

- Organisation (translated)
- Individual name

Add filter along others :
Map with ES (elastic search)
Add individualName to retrieve in the request to index

Json retrieved from index

```json
"contactForResource": [
{
"individual": "Beat Tschumi",
"organisationObject": {
"default": "Office fédéral de l'agriculture",
"langger": "Bundesamt für Landwirtschaft",
"langeng": "Federal Office for Agriculture",
"langroh": "Bundesamt für Landwirtschaft",
"langita": "Ufficio federale dell'agricoltura",
"langfre": "Office fédéral de l'agriculture"
},
"email": "[email protected]"
}
],
```

## Questions for Florent:

- contact or contact for resource?
- where is the codelist ? Do we import it with geonetwork API ?

```ts
export const RoleValues = [
'unspecified',
'other',
'author', // Party who authored the resource
'collaborator', // party who assists with the generation of the resource other than the principal investigator
'contributor', // party contributing to the resource
'custodian', // Party that accepts accountability and responsibility for the data and ensures appropriate care and maintenance of the resource
'distributor', // Party who distributes the resource
'editor', // party who reviewed or modified the resource to improve the content
'funder', // party providing monetary support for the resource
'mediator', // a class of entity that mediates access to the resource and for whom the resource is intended or useful
'originator', // Party who created the resource
'owner', // Party that owns the resource
'point_of_contact', // Party who can be contacted for acquiring knowledge about or acquisition of the resource
'principal_investigator', // Key party responsible for gathering information and conducting research
'processor', // Party who has processed the data in a manner such that the resource has been modified
'publisher', // Party who published the resource
'resource_provider', // Party that supplies the resource
'rights_holder', // party owning or managing rights over the resource
'sponsor', // party that sponsors the resource
'stakeholder', // party who has an interest in the resource or the use of the resource
'user', // Party who uses the resource
]
```
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jest.mock('@geonetwork-ui/util/app-config', () => ({
'license',
'topic',
'publicationYear',
'contact',
],
}),
}))
Expand Down Expand Up @@ -99,6 +100,7 @@ class FieldsServiceMock {
'license',
'topic',
'publicationYear',
'contact',
]
}
}
Expand Down Expand Up @@ -300,6 +302,7 @@ describe('SearchFiltersComponent', () => {
filter_license: {},
filter_documentStandard: {},
filter_inspireKeyword: {},
filter_contact: {},
})
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class SearchFiltersComponent implements OnInit {
'topic',
'isSpatial',
'license',
'inspireKeyword',
]
)
.filter((adv_filter) => {
Expand Down
Binary file added apps/datahub/src/assets/img/geocat-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 44 additions & 41 deletions conf/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ datahub_url = "/datahub"
proxy_path = ""
# This optional parameter defines, in which language metadata should be queried in elasticsearch.
# Use ISO 639-2/B (https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format to indicate the language of the metadata.
# Setting to "current" will use the current language of the User Interface.
# If not indicated, a wildcard is used and no language preference is applied for the search.
# metadata_language = "current"
metadata_language = "current"
# This optional URL should point to the login page that allows authentication to the datahub.
# If not indicated, the default geonetwork login page is used.
# The following three placeholders can be part of this URL:
Expand All @@ -32,7 +31,7 @@ proxy_path = ""
# This optional parameter defines the languages that will be provided in a dropdown for the user to translate the UI.
# Available languages are listed here: (https://github.com/geonetwork/geonetwork-ui/blob/main/libs/util/i18n/src/lib/i18n.constants.ts).
# More information about the translation can be found in the docs (https://geonetwork.github.io/geonetwork-ui/main/docs/reference/i18n.html)
# languages = ['en', 'fr', 'de']
languages = ['en', 'fr', 'de', 'it']

### VISUAL THEME

Expand All @@ -41,16 +40,16 @@ proxy_path = ""
# - for font families: https://developer.mozilla.org/en-US/docs/Web/CSS/font-family
# - for background: https://developer.mozilla.org/en-US/docs/Web/CSS/background
[theme]
primary_color = "#c82850"
secondary_color = "#001638"
main_color = "#555" # All-purpose text color
primary_color = "#f19330"
secondary_color = "#0071ae"
main_color = "#212029" # All-purpose text color
background_color = "#fdfbff"

# These optional parameters indicate which background should be used for the main header and the text color used
# on top of the background. The color should be chosen to contrast well with the background (defaults to white).
# Note: The search header does not use the header_foreground_color as it allows futher customisation via HTML.
# header_background = "center /cover url('assets/img/header_bg.webp')" or "var(--color-gray-500)"
# header_foreground_color = 'white'
header_background = "linear-gradient(to bottom, #fff 0%, 37%, #fff 37%, 70%, var(--color-secondary) 100%)"
header_foreground_color = 'inherit'

# This optional parameter allows to override the fallback image that should be used for thumbnails,
# if the metadata record has no thumbnail image url or it is broken.
Expand All @@ -65,7 +64,6 @@ background_color = "#fdfbff"

# This section contains settings used for fine-tuning the search experience
[search]

# Optional; specify a GeoJSON object to be used as filter: all records contained inside the geometry will be boosted on top,
# all records which do not intersect with the geometry will be shown with lower priority; can be specified as URL or inline
# Note: if the GeoJSON object contains multiple features, only the geometry of the first one will be kept!
Expand All @@ -75,11 +73,11 @@ background_color = "#fdfbff"
# The advanced search filters available to the user can be customized with this setting.
# The following fields can be used for filtering: 'publisher', 'format', 'publicationYear', 'standard', 'inspireKeyword', 'topic', 'isSpatial', 'license'
# any other field will be ignored
# advanced_filters = ['publisher', 'format', 'publicationYear', 'topic', 'isSpatial', 'license']
advanced_filters = ['topic', 'publisher', 'contact', 'inspireKeyword', 'resourceType', 'representationType', 'format']

# One or several search presets can be defined here; every search preset is composed of:
# - a name (which can be a translation key)
# - a sort criteria: either `createDate`, `userSavedCount` or `_score` (prepend with `-` for descending sort) (optionnal)
# - a sort criteria: either `createDate`, `userSavedCount` or `_score` (prepend with `-` for descending sort)
# - filters which can be expressed like so:
# [[search_preset]]
# name = 'filterByName'
Expand All @@ -92,43 +90,20 @@ background_color = "#fdfbff"
# filters.publicationYear = ['2023', '2022']
# filters.isSpatial = ['yes']
# filters.license = ['unknown']
# sort = 'createDate'
# [[search_preset]]
# name = 'otherFilterName'
# filters.q = 'Other Full text search'
# ...

# Search presets will be advertised to the user along the main search field.


### METADATA QUALITY SETTINGS

# This section contains settings used for fine-tuning the metadata quality experience
[metadata-quality]
# By default the widget is not activated to enable it, just add this parameter.
# enabled = true
# If u want to use metadata quality widget this configuration is required

# if you add an indexed field to calculate the qualityScore, the datahub search allow you to sort on this field with this parameter
# sortable = true

# by default the widget appears in 2 locations in the search list and in the detail page
# allow you to hide the widget in detail
# display_widget_in_detail = false
# allow you to hide the widget in search list
# display_widget_in_search = false
# If you want see the widget in the two locations, don't fill theses configurations

# By default the window popup all fields to view if they are filled or not but you can hide some
# display_title = false
# display_description = false
# display_topic = false
# display_keywords = false
# display_legal_constraints = false
# display_contact = false
# display_update_frequency = false
# display_organisation = false
# If you want see all fields, don't fill theses configurations
# [[search_preset]]
# sort = "-createDate"
# name = 'filterByOrgs'
# filters.publisher = ['DREAL', 'atmo Hauts-de-France', 'blargz']
# [[search_preset]]
# name = 'Wind turbines'
# filters.q = 'wind'

### MAP SETTINGS

Expand Down Expand Up @@ -201,3 +176,31 @@ background_color = "#fdfbff"
# Welcome to <span class="text-primary">Organization</span>'s<br>
# wonderful <span style="font-size: 1.2em;">data catalogue</span>
# """
[translations.fr]
datahub.header.title.html = '<div><img src="assets/img/geocat-logo.png" class="h-36"/></div>'
search.field.location.placeholder = 'ex: Berne'
datahub.header.organisations = 'Catalogues'
search.filters.publisher = 'Catalogues'
datahub.header.documentation = 'Documentation'
datahub.header.admin = 'Admin'
[translations.en]
datahub.header.title.html = '<div><img src="assets/img/geocat-logo.png" class="h-36"/></div>'
search.field.location.placeholder = 'ex: Berne'
datahub.header.organisations = 'Catalogues'
search.filters.publisher = 'Catalogues'
datahub.header.documentation = 'Documentation'
datahub.header.admin = 'Admin'
[translations.de]
datahub.header.title.html = '<div><img src="assets/img/geocat-logo.png" class="h-36"/></div>'
search.field.location.placeholder = 'ex: Berne'
datahub.header.organisations = 'Katalogen'
search.filters.publisher = 'Katalogen'
datahub.header.documentation = 'Dokumentation'
datahub.header.admin = 'Admin'
[translations.it]
datahub.header.title.html = '<div><img src="assets/img/geocat-logo.png" class="h-36"/></div>'
search.field.location.placeholder = 'ex: Berne'
datahub.header.organisations = 'Cataloghi'
search.filters.publisher = 'Cataloghi'
datahub.header.documentation = "Documentazione"
datahub.header.admin = 'Admin'
1 change: 1 addition & 0 deletions libs/feature/search/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const FIELDS_SUMMARY: FieldName[] = [
'codelist_status_text',
'linkProtocol',
'contactForResource*.organisation*',
'contactForResource*.individual*',
'contact*.organisation*',
'contact*.email',
'userSavedCount',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ describe('FieldsService', () => {
'q',
'license',
'owner',
'contact',
])
})
})
Expand Down Expand Up @@ -158,6 +159,7 @@ describe('FieldsService', () => {
resourceType: [],
topic: [],
owner: [],
contact: [],
})
})
})
Expand Down
12 changes: 10 additions & 2 deletions libs/feature/search/src/lib/utils/service/fields.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
OrganizationSearchField,
OwnerSearchField,
SimpleSearchField,
ContactSearchField,
//GnUiTranslationSearchFieldArray,
} from './fields'
import { forkJoin, Observable, of } from 'rxjs'
import { map } from 'rxjs/operators'
Expand Down Expand Up @@ -52,11 +54,16 @@ export class FieldsService {
this.injector
),
topic: new GnUiTranslationSearchField('cl_topic.key', 'asc', this.injector),
inspireKeyword: new SimpleSearchField(
'th_httpinspireeceuropaeutheme-theme_tree.default',
inspireKeyword: new GnUiTranslationSearchField(
'th_httpinspireeceuropaeutheme-theme.link',
'asc',
this.injector
),
/*inspireKeyword: new SimpleSearchField(
'th_httpinspireeceuropaeutheme-theme_tree.key', //todo remove default
'asc',
this.injector
),*/
documentStandard: new SimpleSearchField(
'documentStandard',
'asc',
Expand All @@ -66,6 +73,7 @@ export class FieldsService {
q: new FullTextSearchField(),
license: new LicenseSearchField(this.injector),
owner: new OwnerSearchField(this.injector),
contact: new ContactSearchField(this.injector), // || organization
} as Record<string, AbstractSearchField>

get supportedFields() {
Expand Down
42 changes: 33 additions & 9 deletions libs/feature/search/src/lib/utils/service/fields.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { firstValueFrom, Observable, of, switchMap } from 'rxjs'
import { ToolsApiService } from '@geonetwork-ui/data-access/gn4'
import { catchError, map, shareReplay } from 'rxjs/operators'
import { catchError, map, shareReplay, tap } from 'rxjs/operators'
import { Injector } from '@angular/core'
import { TranslateService } from '@ngx-translate/core'
import { marker } from '@biesbjerg/ngx-translate-extract-marker'
Expand Down Expand Up @@ -107,7 +107,10 @@ export class GnUiTranslationSearchField extends SimpleSearchField {

private async getTranslation(topicKey: string) {
return firstValueFrom(
this.allTranslations.pipe(map((translations) => translations[topicKey]))
this.allTranslations.pipe(
tap((val) => console.log(topicKey, val)),
map((translations) => translations[topicKey])
)
)
}

Expand All @@ -117,13 +120,13 @@ export class GnUiTranslationSearchField extends SimpleSearchField {

getAvailableValues(): Observable<FieldAvailableValue[]> {
// sort values by alphabetical order
return super
.getAvailableValues()
.pipe(
map((values) =>
values.sort((a, b) => new Intl.Collator().compare(a.label, b.label))
)
)
return super.getAvailableValues().pipe(
tap((val) => console.log(val)),
map((values) =>
values.sort((a, b) => new Intl.Collator().compare(a.label, b.label))
),
tap((val) => console.log('after', val))
)
}
}

Expand Down Expand Up @@ -272,6 +275,27 @@ if(unknown) emit('unknown');`
}
}

export class ContactSearchField implements AbstractSearchField {
private orgsService = this.injector.get(OrganizationsServiceInterface)

constructor(private injector: Injector) {}

getFiltersForValues(values: FieldValue[]): Observable<FieldFilters> {
//todo
return of()
}

getValuesForFilter(filters: FieldFilters): Observable<FieldValue[]> {
//todo
return of()
}

getAvailableValues(): Observable<FieldAvailableValue[]> {
//todo
return of()
}
}

// This will use the OrganizationsServiceInterface
// Field values are the organization names
export class OrganizationSearchField implements AbstractSearchField {
Expand Down
1 change: 1 addition & 0 deletions libs/util/app-config/src/lib/app-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ describe('app config utils', () => {
'inspireKeyword',
'topic',
'license',
'contact',
],
})
})
Expand Down
2 changes: 1 addition & 1 deletion libs/util/app-config/src/lib/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fonts_stylesheet_url = "https://fonts.googleapis.com/css2?family=Open+Sans"
[search]
filter_geometry_url = 'https://my.domain.org/geom.json'
advanced_filters = ['publicationYear', 'documentStandard', 'inspireKeyword', 'topic', 'license']
advanced_filters = ['publicationYear', 'documentStandard', 'inspireKeyword', 'topic', 'license', 'contact']
[[search_preset]]
sort = "-createDate"
Expand Down

0 comments on commit 36efb2b

Please sign in to comment.