From aee28f604fd721060a3f7ce3bbc36ff309bd7919 Mon Sep 17 00:00:00 2001 From: Gaurav Kumar Date: Mon, 3 Nov 2025 10:48:55 +0530 Subject: [PATCH] Update chart-type.service.ts --- .../chart-type-manager/chart-type.service.ts | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/chart-type-manager/chart-type.service.ts b/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/chart-type-manager/chart-type.service.ts index 5885276..77fd94d 100644 --- a/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/chart-type-manager/chart-type.service.ts +++ b/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/chart-type-manager/chart-type.service.ts @@ -1,7 +1,6 @@ import { Injectable } from '@angular/core'; -import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; -import { environment } from 'src/environments/environment'; +import { ApiRequestService } from 'src/app/services/api/api-request.service'; export interface ChartType { id: number; @@ -17,33 +16,35 @@ export interface ChartType { providedIn: 'root' }) export class ChartTypeService { - private apiUrl = environment.apiUrl || 'http://localhost:8080/api'; - private chartTypesUrl = `${this.apiUrl}/chart-types`; + private chartTypesUrl = 'api/chart-types'; - constructor(private http: HttpClient) { } + constructor(private apiRequest: ApiRequestService) { } // Get all chart types getAllChartTypes(): Observable { - return this.http.get(this.chartTypesUrl); + return this.apiRequest.get(this.chartTypesUrl); } // Get chart type by ID getChartTypeById(id: number): Observable { - return this.http.get(`${this.chartTypesUrl}/${id}`); + const url = `${this.chartTypesUrl}/${id}`; + return this.apiRequest.get(url); } // Create new chart type createChartType(chartType: Partial): Observable { - return this.http.post(this.chartTypesUrl, chartType); + return this.apiRequest.post(this.chartTypesUrl, chartType); } // Update chart type updateChartType(id: number, chartType: ChartType): Observable { - return this.http.put(`${this.chartTypesUrl}/${id}`, chartType); + const url = `${this.chartTypesUrl}/${id}`; + return this.apiRequest.put(url, chartType); } // Delete chart type deleteChartType(id: number): Observable { - return this.http.delete(`${this.chartTypesUrl}/${id}`); + const url = `${this.chartTypesUrl}/${id}`; + return this.apiRequest.delete(url); } } \ No newline at end of file