Add services
This commit is contained in:
15
src/service/country.service.ts
Normal file
15
src/service/country.service.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
export class CountryService {
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
getCountries() {
|
||||
return this.http.get<any>('assets/demo/data/countries.json')
|
||||
.toPromise()
|
||||
.then(res => res.data as any[])
|
||||
.then(data => data);
|
||||
}
|
||||
}
|
||||
50
src/service/customer.service.ts
Normal file
50
src/service/customer.service.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
export interface Country {
|
||||
name?: string;
|
||||
code?: string;
|
||||
}
|
||||
|
||||
export interface Representative {
|
||||
name?: string;
|
||||
image?: string;
|
||||
}
|
||||
|
||||
export interface Customer {
|
||||
id?: number;
|
||||
name?: string;
|
||||
country?: Country;
|
||||
company?: string;
|
||||
date?: string;
|
||||
status?: string;
|
||||
activity?: number;
|
||||
representative?: Representative;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class CustomerService {
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
getCustomersSmall() {
|
||||
return this.http.get<any>('assets/demo/data/customers-small.json')
|
||||
.toPromise()
|
||||
.then(res => res.data as Customer[])
|
||||
.then(data => data);
|
||||
}
|
||||
|
||||
getCustomersMedium() {
|
||||
return this.http.get<any>('assets/demo/data/customers-medium.json')
|
||||
.toPromise()
|
||||
.then(res => res.data as Customer[])
|
||||
.then(data => data);
|
||||
}
|
||||
|
||||
getCustomersLarge() {
|
||||
return this.http.get<any>('assets/demo/data/customers-large.json')
|
||||
.toPromise()
|
||||
.then(res => res.data as Customer[])
|
||||
.then(data => data);
|
||||
}
|
||||
}
|
||||
15
src/service/event.service.ts
Normal file
15
src/service/event.service.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
export class EventService {
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
getEvents() {
|
||||
return this.http.get<any>('assets/demo/data/scheduleevents.json')
|
||||
.toPromise()
|
||||
.then(res => res.data as any[])
|
||||
.then(data => data);
|
||||
}
|
||||
}
|
||||
22
src/service/icon.service.ts
Normal file
22
src/service/icon.service.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class IconService {
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
icons!: any[];
|
||||
|
||||
selectedIcon: any;
|
||||
|
||||
apiUrl = 'assets/demo/data/icons.json';
|
||||
|
||||
getIcons() {
|
||||
return this.http.get(this.apiUrl).pipe(map((response: any) => {
|
||||
this.icons = response.icons;
|
||||
return this.icons;
|
||||
}));
|
||||
}
|
||||
}
|
||||
33
src/service/node.service.ts
Normal file
33
src/service/node.service.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { TreeNode } from 'primeng/api';
|
||||
|
||||
@Injectable()
|
||||
export class NodeService {
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
getFiles() {
|
||||
return this.http.get<any>('assets/demo/data/files.json')
|
||||
.toPromise()
|
||||
.then(res => res.data as TreeNode[]);
|
||||
}
|
||||
|
||||
getLazyFiles() {
|
||||
return this.http.get<any>('assets/demo/data/files-lazy.json')
|
||||
.toPromise()
|
||||
.then(res => res.data as TreeNode[]);
|
||||
}
|
||||
|
||||
getFilesystem() {
|
||||
return this.http.get<any>('assets/demo/data/filesystem.json')
|
||||
.toPromise()
|
||||
.then(res => res.data as TreeNode[]);
|
||||
}
|
||||
|
||||
getLazyFilesystem() {
|
||||
return this.http.get<any>('assets/demo/data/filesystem-lazy.json')
|
||||
.toPromise()
|
||||
.then(res => res.data as TreeNode[]);
|
||||
}
|
||||
}
|
||||
22
src/service/photo.service.ts
Normal file
22
src/service/photo.service.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
export interface Image {
|
||||
previewImageSrc?:any;
|
||||
thumbnailImageSrc?:any;
|
||||
alt?:any;
|
||||
title?:any;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class PhotoService {
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
getImages() {
|
||||
return this.http.get<any>('assets/demo/data/photos.json')
|
||||
.toPromise()
|
||||
.then(res => res.data as Image[])
|
||||
.then(data => data);
|
||||
}
|
||||
}
|
||||
54
src/service/product.service.ts
Normal file
54
src/service/product.service.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
interface InventoryStatus {
|
||||
label: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface Product {
|
||||
id?: string;
|
||||
code?: string;
|
||||
name?: string;
|
||||
description?: string;
|
||||
price?: number;
|
||||
quantity?: number;
|
||||
inventoryStatus?: InventoryStatus;
|
||||
category?: string;
|
||||
image?: string;
|
||||
rating?: number;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class ProductService {
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
getProductsSmall() {
|
||||
return this.http.get<any>('assets/demo/data/products-small.json')
|
||||
.toPromise()
|
||||
.then(res => res.data as Product[])
|
||||
.then(data => data);
|
||||
}
|
||||
|
||||
getProducts() {
|
||||
return this.http.get<any>('assets/demo/data/products.json')
|
||||
.toPromise()
|
||||
.then(res => res.data as Product[])
|
||||
.then(data => data);
|
||||
}
|
||||
|
||||
getProductsMixed() {
|
||||
return this.http.get<any>('assets/demo/data/products-mixed.json')
|
||||
.toPromise()
|
||||
.then(res => res.data as Product[])
|
||||
.then(data => data);
|
||||
}
|
||||
|
||||
getProductsWithOrdersSmall() {
|
||||
return this.http.get<any>('assets/demo/data/products-orders-small.json')
|
||||
.toPromise()
|
||||
.then(res => res.data as Product[])
|
||||
.then(data => data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user