AW-3441 add valid packages selector
All checks were successful
FarmMaps/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
@@ -1,37 +1,37 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Store} from '@ngrx/store';
|
||||
import * as appCommonReducer from '../reducers/app-common.reducer'
|
||||
import { IPackages } from '../models/package';
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Store} from '@ngrx/store';
|
||||
import * as appCommonReducer from '../reducers/app-common.reducer';
|
||||
import {IPackage} from '../models/package';
|
||||
|
||||
import { IItem } from '../models/item';
|
||||
import { IItemTask } from '../models/itemTask';
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { AppConfig } from "../shared/app.config";
|
||||
import { Observable } from 'rxjs';
|
||||
import {IItem} from '../models/item';
|
||||
import {IItemTask} from '../models/itemTask';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {AppConfig} from '../shared/app.config';
|
||||
import {Observable} from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
|
||||
export class PackageService {
|
||||
private packages$:IPackages = {};
|
||||
private packages: {[key: string]: IPackage} = {};
|
||||
|
||||
constructor(private store$: Store<appCommonReducer.State>, public httpClient: HttpClient, public appConfig: AppConfig) {
|
||||
store$.select(appCommonReducer.SelectGetUserPackages).subscribe((packages) => {
|
||||
this.packages$ = packages;
|
||||
})
|
||||
store$.select(appCommonReducer.SelectGetValidUserPackages).subscribe((packages) => {
|
||||
this.packages = packages;
|
||||
});
|
||||
}
|
||||
|
||||
ApiEndpoint() {
|
||||
return this.appConfig.getConfig("apiEndPoint");
|
||||
}
|
||||
|
||||
|
||||
hasPackage(id:string):boolean {
|
||||
if(!this.packages$[id]) return false;
|
||||
return this.packages$[id].enabled ? this.packages$[id].enabled == true : true;
|
||||
if(!this.packages[id]) return false;
|
||||
return this.packages[id].enabled ? this.packages[id].enabled === true : true;
|
||||
}
|
||||
|
||||
postItemPackageTask(item: IItem, task: IItemTask): Observable<IItemTask> {
|
||||
return this.httpClient.post<IItemTask>(`${this.ApiEndpoint()}/api/v1/items/${item.code}/packagetasks`, task);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user