-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Datahub: support thesaurus based advanced fields #719
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f867b59
refactor(fields): rename GnU1Translated to KeySearchField
fgravin 8f7caff
refactor(fields): remove gn4 ToolsApi dependency
fgravin 1162845
feat(platform): add getThesaurusByLang method
fgravin fb7712c
feat(fields): add a thesaurus field for inspire
fgravin 4174c0b
fix(quality): handle i18n in quality widget items
fgravin 54398b4
fix(figures): handle i18n for titles
fgravin a121dd1
fix(i18n): regenerate translations, from fixes
fgravin d041fe5
feat(filters): translate contact filter
fgravin a65b3bb
feat(thesaurus): add model
fgravin 7d3e1e1
fix(sources): use back /sources request
fgravin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,36 @@ | ||
import { Injectable } from '@angular/core' | ||
import { Observable, of, switchMap } from 'rxjs' | ||
import { map, shareReplay, tap } from 'rxjs/operators' | ||
import { catchError, map, shareReplay, tap } from 'rxjs/operators' | ||
import { | ||
MeApiService, | ||
RegistriesApiService, | ||
SiteApiService, | ||
ToolsApiService, | ||
UsersApiService, | ||
} from '@geonetwork-ui/data-access/gn4' | ||
import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' | ||
import { UserModel } from '@geonetwork-ui/common/domain/model/user/user.model' | ||
import { Organization } from '@geonetwork-ui/common/domain/model/record' | ||
import { Gn4PlatformMapper } from './gn4-platform.mapper' | ||
import { ThesaurusModel } from '@geonetwork-ui/common/domain/model/thesaurus/thesaurus.model' | ||
|
||
const minApiVersion = '4.2.0' | ||
@Injectable() | ||
export class Gn4PlatformService implements PlatformServiceInterface { | ||
private readonly type = 'GeoNetwork' | ||
private me$: Observable<UserModel> | ||
private users$: Observable<UserModel[]> | ||
isAnonymous$: Observable<boolean> | ||
private isAnonymous$: Observable<boolean> | ||
|
||
private keyTranslations$ = this.toolsApiService | ||
.getTranslationsPackage1('gnui') | ||
.pipe( | ||
catchError(() => { | ||
console.warn('Error while loading gnui language package') | ||
return of({}) | ||
}), | ||
shareReplay(1) | ||
) | ||
|
||
private settings$ = of(true).pipe( | ||
switchMap(() => this.siteApiService.getSiteOrPortalDescription()), | ||
|
@@ -42,7 +55,9 @@ export class Gn4PlatformService implements PlatformServiceInterface { | |
private siteApiService: SiteApiService, | ||
private meApi: MeApiService, | ||
private usersApi: UsersApiService, | ||
private mapper: Gn4PlatformMapper | ||
private mapper: Gn4PlatformMapper, | ||
private toolsApiService: ToolsApiService, | ||
private registriesApiService: RegistriesApiService | ||
) { | ||
this.me$ = this.meApi.getMe().pipe( | ||
switchMap((apiUser) => this.mapper.userFromMeApi(apiUser)), | ||
|
@@ -85,4 +100,19 @@ export class Gn4PlatformService implements PlatformServiceInterface { | |
getUsers(): Observable<UserModel[]> { | ||
return this.users$ | ||
} | ||
|
||
translateKey(key: string): Observable<string> { | ||
return this.keyTranslations$.pipe(map((translations) => translations[key])) | ||
} | ||
Comment on lines
+104
to
+106
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
getThesaurusByLang( | ||
thesaurusName: string, | ||
lang: string | ||
): Observable<ThesaurusModel> { | ||
return this.registriesApiService | ||
.searchKeywords(null, lang, 1000, 0, null, [thesaurusName]) | ||
.pipe( | ||
map((thesaurus) => this.mapper.thesaurusFromApi(thesaurus as any[])) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './thesaurus.model' |
6 changes: 6 additions & 0 deletions
6
libs/common/domain/src/lib/model/thesaurus/thesaurus.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export interface ThesaurusItemModel { | ||
key: string | ||
label: string | ||
} | ||
|
||
export type ThesaurusModel = ThesaurusItemModel[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use the
translate
pipe here, instead ofmarker
? I know it's translated too in the gn-ui-figure component but amaybe that's the thing that doesn't make sense (translating inputs in presentation components mean the translation keys will not be discoverable)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I just saw the approval from Angie.
I've merged it.
I also found it weird that the translation is done in the children, I understood that it's because in the children component, the translations use params.
But yes, translations should be done from the parent IMO.