import { Injectable } from '@angular/core'; import { Observable , Observer } from 'rxjs'; import {map} from 'rxjs/operators'; import { IListItem } from '../models/list.item'; import { IItem } from '../models/item'; import { HttpClient } from "@angular/common/http"; import { AppConfig } from "../shared/app.config"; @Injectable({ providedIn: 'root', }) export class FolderService { constructor(public httpClient: HttpClient, public appConfig: AppConfig) { } ApiEndpoint() { return this.appConfig.getConfig("apiEndPoint"); } getFolder(code: string): Observable { return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/folders/${code}`); } getMyRoots(): Observable { return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/folders/my_roots`); } getFolderParents(code: string): Observable { return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/folders/${code}/parents`); } getChildFolders(code: string): Observable { return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/folders/${code}/listfolders`); } getItems(code: string,skip:number, take:number): Observable { return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/folders/${code}/list?skip=${skip}&take=${take}`); } moveItem(itemCode: string, newParentCode: string): Observable { const body = { itemCode: itemCode,newParentCode: newParentCode }; return this.httpClient.post(`${this.ApiEndpoint()}/api/v1/items/move`, body); } createFolder(folder: IItem): Observable { return this.httpClient.post(`${this.ApiEndpoint()}/api/v1/folders/`, folder); } }