-
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
WIP : Advanced filters #702
Closed
Closed
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
912f2cb
feat: adds ThesaurusTranslationSearchField request to fields
f-necas 6302fe0
Add contact filter from OrgForResource
Angi-Kinas c7d0f9a
feat(DH) :Add translation for contact filter
Angi-Kinas b91f0fa
feat: retrieve values for orgs
f-necas ff26b82
chore: add semver dependency
fgravin d4ac088
refactor(platform): remove isApiCompatible
fgravin 5c5aae1
refactor(org): use semver for version comparison
fgravin d56f845
feat(platform): throw an error is the version is not compatible
fgravin f909efc
WIP: Add new ContactField that differs between gn version
Angi-Kinas ed85f75
feat: update dump, remove log and fix filter
f-necas 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
135 changes: 135 additions & 0 deletions
135
libs/data-access/gn4/src/custom-api/thesaurus.api.service.ts
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. The content of the commit has nothing to do with the commit message. |
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,135 @@ | ||
import { Inject, Injectable, Optional } from '@angular/core' | ||
import { | ||
HttpClient, | ||
HttpHeaders, | ||
HttpParameterCodec, | ||
} from '@angular/common/http' | ||
import { Observable } from 'rxjs' | ||
import { CustomHttpParameterCodec } from '../openapi/encoder' | ||
import { Configuration } from '../openapi/configuration' | ||
|
||
import { BASE_PATH } from '../openapi/variables' | ||
|
||
export interface thesaurusResponse { | ||
values: { [key: string]: string } | ||
definitions: { [key: string]: string } | ||
coordEast?: string | ||
coordWest?: string | ||
coordSouth?: string | ||
coordNorth?: string | ||
thesaurusKey: string | ||
value: string | ||
uri: string | ||
definition?: string | ||
} | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class ThesaurusApiService { | ||
protected basePath = 'https://apps.titellus.net/geonetwork/srv/api' | ||
public defaultHeaders = new HttpHeaders() | ||
public configuration = new Configuration() | ||
public encoder: HttpParameterCodec | ||
|
||
constructor( | ||
protected httpClient: HttpClient, | ||
@Optional() @Inject(BASE_PATH) basePath: string, | ||
@Optional() configuration: Configuration | ||
) { | ||
if (configuration) { | ||
this.configuration = configuration | ||
} | ||
if (typeof this.configuration.basePath !== 'string') { | ||
if (typeof basePath !== 'string') { | ||
basePath = this.basePath | ||
} | ||
this.configuration.basePath = basePath | ||
} | ||
this.encoder = this.configuration.encoder || new CustomHttpParameterCodec() | ||
} | ||
|
||
/** | ||
* List database translations (used to overrides client application translations). | ||
* @param esFieldName set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | ||
* @param iso3 set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | ||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | ||
* @param reportProgress flag to report request and response progress. | ||
*/ | ||
public getTranslationsFromThesaurus( | ||
thesaurusName: string, | ||
langIso3: string, | ||
observe?: 'body', | ||
reportProgress?: boolean, | ||
options?: { httpHeaderAccept?: 'application/json' } | ||
): Observable<any> | ||
public getTranslationsFromThesaurus( | ||
thesaurusName: string, | ||
langIso3: string, | ||
observe?: 'response', | ||
reportProgress?: boolean, | ||
options?: { httpHeaderAccept?: 'application/json' } | ||
): Observable<thesaurusResponse[]> | ||
public getTranslationsFromThesaurus( | ||
thesaurusName: string, | ||
langIso3: string, | ||
observe?: 'events', | ||
reportProgress?: boolean, | ||
options?: { httpHeaderAccept?: 'application/json' } | ||
): Observable<thesaurusResponse[]> | ||
public getTranslationsFromThesaurus( | ||
thesaurusName: string, | ||
langIso3: string, | ||
observe: any = 'body', | ||
reportProgress: boolean = false, | ||
options?: { httpHeaderAccept?: 'application/json' } | ||
): Observable<any> { | ||
if ( | ||
thesaurusName === null || | ||
thesaurusName === undefined || | ||
langIso3 === null || | ||
langIso3 === undefined | ||
) { | ||
throw new Error( | ||
'Required parameter pack was null or undefined when calling getTranslationsFromThesaurus.' | ||
) | ||
} | ||
|
||
let headers = this.defaultHeaders | ||
|
||
let httpHeaderAcceptSelected: string | undefined = | ||
options && options.httpHeaderAccept | ||
if (httpHeaderAcceptSelected === undefined) { | ||
// to determine the Accept header | ||
const httpHeaderAccepts: string[] = ['application/json'] | ||
httpHeaderAcceptSelected = | ||
this.configuration.selectHeaderAccept(httpHeaderAccepts) | ||
} | ||
if (httpHeaderAcceptSelected !== undefined) { | ||
headers = headers.set('Accept', httpHeaderAcceptSelected) | ||
} | ||
|
||
let responseType_: 'text' | 'json' = 'json' | ||
if ( | ||
httpHeaderAcceptSelected && | ||
httpHeaderAcceptSelected.startsWith('text') | ||
) { | ||
responseType_ = 'text' | ||
} | ||
|
||
return this.httpClient.get<thesaurusResponse[]>( | ||
`${ | ||
this.configuration.basePath | ||
}/registries/vocabularies/search?rows=1000&type=CONTAINS&sort=DESC&thesaurus=${encodeURIComponent( | ||
String(thesaurusName) | ||
)}&lang=${encodeURIComponent(langIso3)}`, | ||
{ | ||
responseType: <any>responseType_, | ||
withCredentials: this.configuration.withCredentials, | ||
headers: headers, | ||
observe: observe, | ||
reportProgress: reportProgress, | ||
} | ||
) | ||
} | ||
} |
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
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.
This is useless as the
gn-ui-figure
already does a translation.