Changed schema service.
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good Details

2022.01
Mark van der Wal 2020-06-24 11:52:05 +02:00
parent 6f52302875
commit 4527276254
1 changed files with 4 additions and 14 deletions

View File

@ -14,19 +14,9 @@ export class SchemaService {
return this.appConfig.getConfig('apiEndPoint');
}
public getSchemaIdFromSchemaUrl(schemaUrl): string {
const url = new URL(schemaUrl);
const pathSplit = url.pathname.split('/');
return pathSplit[pathSplit.length - 1].replace('.json', '');
}
public getSchemaWithUrl(schemaUrl): Observable<string> {
const id = this.getSchemaIdFromSchemaUrl(schemaUrl);
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/schema/${id}`);
}
public getSchemaWithId(schemaId): Observable<string> {
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/schema/${schemaId}`);
/** Takes decoded schema url id */
public getSchema(id): Observable<string> {
const encodedId = encodeURIComponent(id);
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/schema/${encodedId}`);
}
}