Add services

This commit is contained in:
Çetin
2025-01-03 12:05:07 +03:00
parent fc8f5eceee
commit d7bb01ce99
7 changed files with 46 additions and 3 deletions

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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;
}));
}
}

View 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[]);
}
}

View 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);
}
}

View 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);
}
}