Added schema service
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
parent
aa3707aa56
commit
75015f6d22
@ -9,6 +9,7 @@ import { OAuthModule, OAuthService, OAuthStorage } from 'angular-oauth2-oidc';
|
|||||||
|
|
||||||
//components
|
//components
|
||||||
import { ItemTypeService } from './services/itemtype.service';
|
import { ItemTypeService } from './services/itemtype.service';
|
||||||
|
import { SchemaService } from './services/schema.service';
|
||||||
import { FolderService } from './services/folder.service';
|
import { FolderService } from './services/folder.service';
|
||||||
import { TimespanService } from './services/timespan.service';
|
import { TimespanService } from './services/timespan.service';
|
||||||
import { ItemService } from './services/item.service';
|
import { ItemService } from './services/item.service';
|
||||||
@ -47,7 +48,8 @@ export {
|
|||||||
AuthCallbackGuard,
|
AuthCallbackGuard,
|
||||||
ResumableFileUploadService,
|
ResumableFileUploadService,
|
||||||
NgbDateNativeAdapter,
|
NgbDateNativeAdapter,
|
||||||
StateSerializerService
|
StateSerializerService,
|
||||||
|
SchemaService
|
||||||
};
|
};
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
30
projects/common/src/fm/services/schema.service.ts
Normal file
30
projects/common/src/fm/services/schema.service.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import {HttpClient} from '@angular/common/http';
|
||||||
|
import {AppConfig} from '../shared/app.config';
|
||||||
|
import {Observable} from 'rxjs';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class SchemaService {
|
||||||
|
constructor(private httpClient: HttpClient, private appConfig: AppConfig) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ApiEndpoint() {
|
||||||
|
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}`);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user