Renamed prefixes in angular.json
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good
This commit is contained in:
58
projects/common/src/fm/services/auth-guard.service.ts
Normal file
58
projects/common/src/fm/services/auth-guard.service.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
CanActivate, Router, CanLoad, Route, CanActivateChild ,
|
||||
ActivatedRouteSnapshot,
|
||||
RouterStateSnapshot
|
||||
} from '@angular/router';
|
||||
|
||||
import { Store } from '@ngrx/store';
|
||||
import { OAuthService } from 'angular-oauth2-oidc';
|
||||
|
||||
|
||||
import * as appCommonReducer from '../reducers/app-common.reducer'
|
||||
import * as appCommonActions from '../actions/app-common.actions';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class AuthGuard implements CanActivate, CanLoad, CanActivateChild {
|
||||
|
||||
private loginDispatched = false;
|
||||
private initialized = false;
|
||||
constructor(private oauthService: OAuthService, private router: Router, private store: Store<appCommonReducer.State> ) { }
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
|
||||
let url: string = state.url;
|
||||
|
||||
return this.checkLogin(url);
|
||||
}
|
||||
|
||||
canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
|
||||
let url: string = state.url;
|
||||
|
||||
return this.checkLogin(url);
|
||||
}
|
||||
|
||||
canLoad(route: Route): boolean {
|
||||
return this.checkLogin(route.path);
|
||||
}
|
||||
|
||||
checkLogin(url: string): boolean {
|
||||
if (!this.oauthService.hasValidAccessToken()) {
|
||||
if (!this.loginDispatched) {
|
||||
this.oauthService.silentRefresh().then(info => {
|
||||
this.router.navigateByUrl(url);
|
||||
}).catch(error => {
|
||||
this.loginDispatched = true;
|
||||
this.store.dispatch(new appCommonActions.Login(url));
|
||||
})
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
if (!this.initialized) {
|
||||
this.initialized = true;
|
||||
this.store.dispatch(new appCommonActions.InitUser());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
14
projects/common/src/fm/services/date-adapter.service.ts
Normal file
14
projects/common/src/fm/services/date-adapter.service.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Component, Injectable } from '@angular/core';
|
||||
import { NgbDateAdapter, NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';
|
||||
|
||||
@Injectable()
|
||||
export class NgbDateNativeAdapter extends NgbDateAdapter<Date> {
|
||||
|
||||
fromModel(date: Date): NgbDateStruct {
|
||||
return (date && date.getFullYear) ? {year: date.getFullYear(), month: date.getMonth() + 1, day: date.getDate()} : null;
|
||||
}
|
||||
|
||||
toModel(date: NgbDateStruct): Date {
|
||||
return date ? new Date(Date.UTC(date.year, date.month - 1, date.day)) : null;
|
||||
}
|
||||
}
|
29
projects/common/src/fm/services/event.service.ts
Normal file
29
projects/common/src/fm/services/event.service.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { IEventMessage } from '../models/event.message';
|
||||
import { Subject } from 'rxjs';
|
||||
import { OAuthService } from 'angular-oauth2-oidc';
|
||||
import { HubConnection, HubConnectionBuilder, LogLevel } from '@aspnet/signalr';
|
||||
import { AppConfig } from "../shared/app.config";
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class EventService {
|
||||
|
||||
public event:Subject <IEventMessage> = new Subject<IEventMessage>();
|
||||
private _connection: HubConnection = null;
|
||||
private _apiEndPoint: string;
|
||||
|
||||
constructor(private oauthService: OAuthService, private appConfig: AppConfig) {
|
||||
this._apiEndPoint = appConfig.getConfig("apiEndPoint");
|
||||
this._connection = new HubConnectionBuilder().withUrl(`${ this._apiEndPoint}/eventHub`).configureLogging(LogLevel.Information).build();
|
||||
this._connection.start().then(() => {
|
||||
var accessToken = oauthService.getAccessToken();
|
||||
if (accessToken) {
|
||||
this._connection.send('authenticate', oauthService.getAccessToken());
|
||||
}
|
||||
});
|
||||
this._connection.on('event', eventMessage => {
|
||||
this.event.next(eventMessage);
|
||||
});
|
||||
}
|
||||
}
|
54
projects/common/src/fm/services/folder.service.ts
Normal file
54
projects/common/src/fm/services/folder.service.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
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()
|
||||
export class FolderService {
|
||||
|
||||
constructor(public httpClient: HttpClient, public appConfig: AppConfig) {
|
||||
}
|
||||
|
||||
ApiEndpoint() {
|
||||
return this.appConfig.getConfig("apiEndPoint");
|
||||
}
|
||||
|
||||
parseDates(item: any): IListItem {
|
||||
item.created = new Date(Date.parse(item.created));
|
||||
item.updated = new Date(Date.parse(item.updated));
|
||||
item.dataDate = new Date(Date.parse(item.dataDate));
|
||||
return item;
|
||||
}
|
||||
|
||||
getFolder(code: string): Observable<IListItem> {
|
||||
return this.httpClient.get<IListItem>(`${this.ApiEndpoint()}/api/v1/folders/${code}`).pipe(map(i => this.parseDates(i)));
|
||||
}
|
||||
|
||||
getMyRoots(): Observable<IListItem[]> {
|
||||
return this.httpClient.get<IListItem[]>(`${this.ApiEndpoint()}/api/v1/folders/my_roots`).pipe(map(ia => ia.map(i => this.parseDates(i))));
|
||||
}
|
||||
|
||||
getFolderParents(code: string): Observable<IListItem[]> {
|
||||
return this.httpClient.get<IListItem[]>(`${this.ApiEndpoint()}/api/v1/folders/${code}/parents`).pipe(map(ia => ia.map(i => this.parseDates(i))));
|
||||
}
|
||||
|
||||
getChildFolders(code: string): Observable<IListItem[]> {
|
||||
return this.httpClient.get<IListItem[]>(`${this.ApiEndpoint()}/api/v1/folders/${code}/listfolders`).pipe(map(ia => ia.map(i => this.parseDates(i))));
|
||||
}
|
||||
|
||||
getItems(code: string,skip:number, take:number): Observable<IListItem[]> {
|
||||
return this.httpClient.get<IListItem[]>(`${this.ApiEndpoint()}/api/v1/folders/${code}/list?skip=${skip}&take=${take}`).pipe(map(ia => ia.map(i => this.parseDates(i))));
|
||||
}
|
||||
|
||||
moveItem(itemCode: string, newParentCode: string): Observable<IListItem> {
|
||||
const body = { itemCode: itemCode,newParentCode: newParentCode };
|
||||
return this.httpClient.post<IListItem>(`${this.ApiEndpoint()}/api/v1/items/move`, body).pipe(map(i => this.parseDates(i)));
|
||||
}
|
||||
|
||||
createFolder(folder: IItem): Observable<IListItem> {
|
||||
return this.httpClient.post<IListItem>(`${this.ApiEndpoint()}/api/v1/folders/`, folder).pipe(map(i => this.parseDates(i)));
|
||||
}
|
||||
}
|
20
projects/common/src/fm/services/full-screen-guard.service.ts
Normal file
20
projects/common/src/fm/services/full-screen-guard.service.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CanLoad, Route, CanActivate, CanDeactivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router';
|
||||
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
import * as appCommonReducer from '../reducers/app-common.reducer'
|
||||
import * as appCommonActions from '../actions/app-common.actions';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class FullScreenGuard implements CanActivate {
|
||||
|
||||
private loginDispatched = false;
|
||||
constructor(private store: Store<appCommonReducer.State> ) { }
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
|
||||
this.store.dispatch(new appCommonActions.FullScreen());
|
||||
return true;
|
||||
}
|
||||
}
|
124
projects/common/src/fm/services/item.service.ts
Normal file
124
projects/common/src/fm/services/item.service.ts
Normal file
@@ -0,0 +1,124 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { IItemType } from '../models/item.type';
|
||||
import { IItem } from '../models/item';
|
||||
import { IItemTask } from '../models/itemTask';
|
||||
import { HttpClient, HttpParams } from "@angular/common/http";
|
||||
import { AppConfig } from "../shared/app.config";
|
||||
|
||||
@Injectable()
|
||||
export class ItemService {
|
||||
constructor(public httpClient: HttpClient, public appConfig: AppConfig) {
|
||||
}
|
||||
|
||||
ApiEndpoint() {
|
||||
return this.appConfig.getConfig("apiEndPoint");
|
||||
}
|
||||
|
||||
parseDates(item: any): IItem {
|
||||
item.created = new Date(Date.parse(item.created));
|
||||
item.updated = new Date(Date.parse(item.updated));
|
||||
item.dataDate = new Date(Date.parse(item.dataDate));
|
||||
return item;
|
||||
}
|
||||
|
||||
getItemTypes(): Observable<{ [id: string]: IItemType }> {
|
||||
return this.httpClient.get<{ [id: string]: IItemType }>(`${this.ApiEndpoint()}/api/v1/itemtypes/`);
|
||||
}
|
||||
|
||||
getFeatures(extent: number[], crs: string, searchText?: string, searchTags?:string,startDate?:Date,endDate?:Date,itemType?:string,parentCode?:string,dataFilter?:string,level?:number): Observable<any> {
|
||||
var params = new HttpParams();
|
||||
params = params.append("bbox", extent.join(","));
|
||||
params = params.append("crs", crs);
|
||||
if (searchText) params = params.append("q", searchText);
|
||||
if (searchTags) params = params.append("t", searchTags);
|
||||
if (startDate) params = params.append("sd", startDate.toISOString());
|
||||
if (endDate) params = params.append("ed", endDate.toISOString());
|
||||
if (itemType) params = params.append("it", itemType);
|
||||
if (parentCode) params = params.append("pc", parentCode);
|
||||
if (dataFilter) params = params.append("df", dataFilter);
|
||||
if (level) params = params.append("lvl", dataFilter);
|
||||
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/features/`, {params:params});
|
||||
}
|
||||
|
||||
getFeature(code:string, crs: string): Observable<any> {
|
||||
var params = new HttpParams();
|
||||
params = params.append("crs", crs);
|
||||
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/${code}/feature/`, { params: params });
|
||||
}
|
||||
|
||||
getItem(code: string): Observable<IItem> {
|
||||
return this.httpClient.get<IItem>(`${this.ApiEndpoint()}/api/v1/items/${code}`).pipe(map(i => this.parseDates(i)));
|
||||
}
|
||||
|
||||
getItemByCodeAndType(code: string, itemType: string): Observable<IItem> {
|
||||
return this.httpClient.get<IItem>(`${this.ApiEndpoint()}/api/v1/items/${code}/${itemType}`);
|
||||
}
|
||||
|
||||
getItemList(itemType: string, dataFilter?: any, level: number = 1): Observable<IItem[]> {
|
||||
var params = new HttpParams();
|
||||
params = params.append("it", itemType);
|
||||
if(dataFilter != null){
|
||||
params = params.append("df", JSON.stringify(dataFilter));
|
||||
}
|
||||
params = params.append("lvl", itemType);
|
||||
return this.httpClient.get<IItem[]>(`${this.ApiEndpoint()}/api/v1/items/`, { params: params }).pipe(map(ia => ia.map(i => this.parseDates(i))));
|
||||
}
|
||||
|
||||
getChildItemList(parentcode: string, itemType: string, dataFilter?: any, level: number = 1): Observable<IItem[]> {
|
||||
var params = new HttpParams();
|
||||
params = params.append("it", itemType);
|
||||
if (dataFilter != null) {
|
||||
params = params.append("df", JSON.stringify(dataFilter));
|
||||
}
|
||||
params = params.append("lvl", level.toString());
|
||||
return this.httpClient.get<IItem[]>(`${this.ApiEndpoint()}/api/v1/items/${parentcode}/children`, { params: params });
|
||||
}
|
||||
|
||||
getChildItemListByExtent(parentcode: string, itemType: string, extent: number[], crs: string, dataFilter?: any, level: number = 1): Observable<IItem[]> {
|
||||
var params = new HttpParams();
|
||||
params = params.append("it", itemType);
|
||||
params = params.append("bbox", extent.join(","));
|
||||
params = params.append("crs", crs);
|
||||
if (dataFilter != null) {
|
||||
params = params.append("df", JSON.stringify(dataFilter));
|
||||
}
|
||||
params = params.append("lvl", level.toString());
|
||||
return this.httpClient.get<IItem[]>(`${this.ApiEndpoint()}/api/v1/items/${parentcode}/children`, { params: params });
|
||||
}
|
||||
|
||||
getItemFeatures(code: string, extent: number[], crs: string, layerIndex?:number): Observable<any> {
|
||||
var params = new HttpParams();
|
||||
params = params.append("bbox", extent.join(","));
|
||||
params = params.append("crs", crs);
|
||||
if(layerIndex!=null)
|
||||
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/${code}/features/layer/${layerIndex}`, { params: params });
|
||||
else
|
||||
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/${code}/features`, { params: params });
|
||||
}
|
||||
|
||||
putItem(item:IItem): Observable<IItem> {
|
||||
return this.httpClient.put<IItem>(`${this.ApiEndpoint()}/api/v1/items/${item.code}`,item);
|
||||
}
|
||||
|
||||
deleteItems(itemCodes:string[]): Observable<any> {
|
||||
return this.httpClient.post<any>(`${this.ApiEndpoint()}/api/v1/items/delete`, itemCodes);
|
||||
}
|
||||
|
||||
getTemporalLast(code: string): Observable<any> {
|
||||
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/${code}/temporal/last`);
|
||||
}
|
||||
|
||||
getTemporal(code: string, startDate?: Date, endDate?: Date): Observable<any> {
|
||||
var params = new HttpParams();
|
||||
if (startDate) params = params.append("sd", startDate.toISOString());
|
||||
if (endDate) params = params.append("ed", endDate.toISOString());
|
||||
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/${code}/temporal/`, { params: params });
|
||||
}
|
||||
|
||||
postItemTask(item: IItem, task: IItemTask): Observable<IItemTask> {
|
||||
return this.httpClient.post<IItemTask>(`${this.ApiEndpoint()}/api/v1/items/${item.code}/tasks`, task);
|
||||
}
|
||||
}
|
||||
|
39
projects/common/src/fm/services/itemtype.service.ts
Normal file
39
projects/common/src/fm/services/itemtype.service.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { Component, Injectable } from '@angular/core';
|
||||
import { Store } from '@ngrx/store';
|
||||
import * as appCommonReducer from '../reducers/app-common.reducer'
|
||||
import {IItemTypes} from '../models/item.types'
|
||||
import {IItem} from '../models/item'
|
||||
|
||||
@Injectable()
|
||||
export class ItemTypeService {
|
||||
public itemTypes: IItemTypes;
|
||||
|
||||
constructor(private store: Store<appCommonReducer.State> ) {
|
||||
this.store.select(appCommonReducer.selectGetItemTypes).subscribe((itemTypes) => {
|
||||
this.itemTypes = itemTypes;
|
||||
});
|
||||
}
|
||||
|
||||
getIcon(itemType: string) {
|
||||
var icon = "fa fa-file-o";
|
||||
if (this.itemTypes[itemType]) icon = this.itemTypes[itemType].icon;
|
||||
return icon;
|
||||
}
|
||||
|
||||
getColor(itemType: string) {
|
||||
var color = "#000000";
|
||||
if (this.itemTypes[itemType]) color = this.itemTypes[itemType].iconColor;
|
||||
return color;
|
||||
}
|
||||
|
||||
hasViewer(item: IItem) {
|
||||
let itemType: string = item.itemType;
|
||||
if (this.itemTypes[itemType]) return this.itemTypes[itemType].viewer !== undefined;
|
||||
return false;
|
||||
}
|
||||
|
||||
isLayer(item: IItem) {
|
||||
let itemType: string = item.itemType;
|
||||
return itemType == "vnd.farmmaps.itemtype.geotiff.processed" || itemType == "vnd.farmmaps.itemtype.layer" || itemType == "vnd.farmmaps.itemtype.shape.processed";
|
||||
}
|
||||
}
|
20
projects/common/src/fm/services/nav-bar-guard.service.ts
Normal file
20
projects/common/src/fm/services/nav-bar-guard.service.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CanLoad, Route, CanActivate, CanDeactivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
|
||||
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
import * as appCommonReducer from '../reducers/app-common.reducer'
|
||||
import * as appCommonActions from '../actions/app-common.actions';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class NavBarGuard implements CanActivate {
|
||||
|
||||
private loginDispatched = false;
|
||||
constructor(private store: Store<appCommonReducer.State>) { }
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
|
||||
this.store.dispatch(new appCommonActions.ShowNavBar());
|
||||
return true;
|
||||
}
|
||||
}
|
73
projects/common/src/fm/services/timespan.service.ts
Normal file
73
projects/common/src/fm/services/timespan.service.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { Observable , Observer } from 'rxjs';
|
||||
import { ITypeaheadItem } from '../models/typeahead.item';
|
||||
|
||||
@Injectable()
|
||||
export class TimespanService {
|
||||
constructor(private datePipe: DatePipe) {
|
||||
}
|
||||
unitScales: number[] = [1, 1000, 1000 * 60, 1000 * 60 * 60, 1000 * 60 * 60 * 24, 1000 * 60 * 60 * 24 * 7, 1000 * 60 * 60 * 24 * 31, 1000 * 60 * 60 * 24 * 31 * 3, 1000 * 60 * 60 * 24 * 365.25];
|
||||
units: string[] = ['millisecond', 'second', 'minute', 'hour', 'day', 'week', 'month', 'quarter', 'year'];
|
||||
quarters: string[] = ['KW1', 'KW2', 'KW3', 'KW4'];
|
||||
|
||||
getStartEndCaption(date: Date, otherDate: Date, unitScale: number, suffix: boolean = false, extended: boolean = true): string {
|
||||
let showSuffix = false;
|
||||
otherDate = new Date(otherDate.getTime() - 1); // fix year edge case
|
||||
if (unitScale == 3) {
|
||||
let format = "HH:00";
|
||||
if (extended) {
|
||||
if (suffix || date.getFullYear() != otherDate.getFullYear())
|
||||
format = "d MMM yyyy:HH:00";
|
||||
else if (date.getMonth() !== otherDate.getMonth())
|
||||
format = "d MMM HH:00";
|
||||
}
|
||||
return this.datePipe.transform(date, format);
|
||||
|
||||
}
|
||||
if (unitScale == 4) {
|
||||
let format = "d";
|
||||
if (extended) {
|
||||
if (suffix || date.getFullYear() != otherDate.getFullYear())
|
||||
format = "d MMM yyyy";
|
||||
else if (date.getMonth() !== otherDate.getMonth())
|
||||
format = "d MMM"
|
||||
}
|
||||
return this.datePipe.transform(date, format);
|
||||
|
||||
}
|
||||
if (unitScale == 6) {
|
||||
let format = "MMM";
|
||||
if (extended) {
|
||||
if (suffix || date.getFullYear() != otherDate.getFullYear())
|
||||
format = "MMM yyyy";
|
||||
}
|
||||
return this.datePipe.transform(date, format);
|
||||
}
|
||||
if (unitScale == 7) {
|
||||
let q = Math.trunc(date.getMonth() / 3);
|
||||
return this.quarters[q];
|
||||
}
|
||||
if (unitScale == 8) {
|
||||
return this.datePipe.transform(date, "yyyy");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
getStartCaption(startDate: Date, endDate: Date, unitScale: number, suffix: boolean = false, extended: boolean = true): string {
|
||||
return this.getStartEndCaption(new Date(startDate.getTime() + (this.unitScales[unitScale] / 2)), endDate, unitScale, suffix, extended);
|
||||
}
|
||||
|
||||
getEndCaption(startDate: Date,endDate: Date, unitScale: number, suffix: boolean = true): string {
|
||||
return this.getStartEndCaption(new Date(endDate.getTime() - (this.unitScales[unitScale] / 2)), startDate, unitScale, suffix);
|
||||
}
|
||||
|
||||
getCaption(startDate: Date, endDate: Date, unitScale: number): string {
|
||||
let startCaption = this.getStartCaption(startDate, endDate, unitScale);
|
||||
let endCaption = this.getEndCaption(startDate,endDate, unitScale);
|
||||
if ((endDate.getTime() - startDate.getTime()) < (1.5 * this.unitScales[unitScale]))
|
||||
return endCaption;
|
||||
return `${startCaption}-${endCaption}`;
|
||||
}
|
||||
|
||||
}
|
23
projects/common/src/fm/services/typeahead.service.ts
Normal file
23
projects/common/src/fm/services/typeahead.service.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable , Observer } from 'rxjs';
|
||||
import { ITypeaheadItem } from '../models/typeahead.item';
|
||||
import { HttpClient, HttpParams } from "@angular/common/http";
|
||||
import { AppConfig } from "../shared/app.config";
|
||||
|
||||
@Injectable()
|
||||
export class TypeaheadService {
|
||||
constructor(public httpClient: HttpClient, public appConfig: AppConfig) {
|
||||
}
|
||||
|
||||
ApiEndpoint() {
|
||||
return this.appConfig.getConfig("apiEndPoint");
|
||||
}
|
||||
|
||||
getSearchTypeaheadItems(searchText:string,skip:number = 0,take:number = 10): Observable<ITypeaheadItem[]> {
|
||||
return this.httpClient.get<ITypeaheadItem[]>(`${this.ApiEndpoint()}/api/v1/typeahead/search/?q=${searchText}&skip=${skip}&take=${take}`);
|
||||
}
|
||||
|
||||
getTagTypeaheadItems(searchText: string, skip: number = 0, take: number = 10): Observable<ITypeaheadItem[]> {
|
||||
return this.httpClient.get<ITypeaheadItem[]>(`${this.ApiEndpoint()}/api/v1/typeahead/tag/?q=${searchText}&skip=${skip}&take=${take}`);
|
||||
}
|
||||
}
|
19
projects/common/src/fm/services/user.service.ts
Normal file
19
projects/common/src/fm/services/user.service.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { IUser } from '../models/user';
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { AppConfig } from "../shared/app.config";
|
||||
|
||||
@Injectable()
|
||||
export class UserService {
|
||||
constructor(public httpClient: HttpClient, public appConfig: AppConfig) {
|
||||
}
|
||||
|
||||
ApiEndpoint() {
|
||||
return this.appConfig.getConfig("apiEndPoint");
|
||||
}
|
||||
|
||||
getCurrentUser(): Observable<IUser> {
|
||||
return this.httpClient.get<IUser>(`${this.ApiEndpoint()}/api/v1/currentuser`);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user