diff --git a/projects/common/src/fm/common-service.module.ts b/projects/common/src/fm/common-service.module.ts index 982c4dd..ce5a272 100644 --- a/projects/common/src/fm/common-service.module.ts +++ b/projects/common/src/fm/common-service.module.ts @@ -13,6 +13,7 @@ import { SchemaService } from './services/schema.service'; import { FolderService } from './services/folder.service'; import { TimespanService } from './services/timespan.service'; import { ItemService } from './services/item.service'; +import { AdminService } from './services/admin.service'; import { EventService } from './services/event.service'; import { TypeaheadService } from './services/typeahead.service'; import { UserService } from './services/user.service'; @@ -42,6 +43,7 @@ export { ItemTypeService, TimespanService, ItemService, + AdminService, EventService, TypeaheadService, UserService, diff --git a/projects/common/src/fm/services/admin.service.ts b/projects/common/src/fm/services/admin.service.ts new file mode 100644 index 0000000..de4ecf5 --- /dev/null +++ b/projects/common/src/fm/services/admin.service.ts @@ -0,0 +1,41 @@ +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; +import { IItem } from '../models/item'; +import { HttpClient, HttpParams } from "@angular/common/http"; +import { AppConfig } from "../shared/app.config"; +import {ItemTypeService} from './itemtype.service'; + +@Injectable({ + providedIn: 'root', +}) +export class AdminService { + constructor(public httpClient: HttpClient, public appConfig: AppConfig,private itemTypeService:ItemTypeService) { + } + + ApiEndpoint() { + return this.appConfig.getConfig("apiEndPoint"); + } + + getItemList(itemType?: string, dataFilter?: any, level?: number, atItemLocationItemCode?: string, indexed?: boolean, validToday?: boolean): Observable { + var params = new HttpParams(); + if(itemType) params = params.append("it", itemType); + if(dataFilter) params = params.append("df", JSON.stringify(dataFilter)); + if(atItemLocationItemCode) params = params.append("ail",atItemLocationItemCode); + if(indexed) params = params.append("ind",indexed?"true":"false"); + if (level) params = params.append("lvl", level.toFixed()); + if (validToday) params = params.append("vt", validToday ? "true" : "false"); + return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/admin/`, { params: params }); + } + + postItem(item:IItem): Observable { + return this.httpClient.post(`${this.ApiEndpoint()}/api/v1/admin`,item); + } + + putItem(item:IItem): Observable { + return this.httpClient.put(`${this.ApiEndpoint()}/api/v1/admin/${item.code}`,item); + } + + deleteItem(code: string): Observable { + return this.httpClient.delete(`${this.ApiEndpoint()}/api/v1/admin/${code}`); + } +}