From d18bc398b7ba1763be1dbd477f95b890d07d5253 Mon Sep 17 00:00:00 2001 From: Sukhrob Ilyosbekov Date: Sun, 6 Oct 2024 03:56:38 -0400 Subject: [PATCH] removed core.module file --- README.md | 4 +- .../Logistics.OfficeApp/src/app/app.config.ts | 20 ++++++++++ .../layout/sidebar/sidebar.component.ts | 4 +- .../src/app/configs/app.config.ts | 12 ------ .../src/app/configs/auth.config.ts | 6 +-- .../src/app/configs/global.config.ts | 2 +- .../src/app/configs/index.ts | 4 +- .../src/app/core/core.module.ts | 40 ------------------- .../src/app/core/guards/auth.guard.ts | 2 +- .../src/app/core/guards/index.ts | 2 +- .../src/app/core/interceptors/index.ts | 4 +- .../core/interceptors/tenant.interceptor.ts | 26 +++++------- .../core/interceptors/token.interceptor.ts | 33 +++++++-------- .../src/app/core/services/api.service.ts | 6 +-- .../app/core/services/base-hub-connection.ts | 4 +- .../src/app/core/services/cookie.service.ts | 2 +- .../app/core/services/notification.service.ts | 6 +-- .../src/app/core/services/storage.service.ts | 2 +- .../src/app/core/services/toast.service.ts | 2 +- .../pages/dashboard/dashboard.component.ts | 4 +- .../src/app/pages/home/home.component.ts | 4 +- .../pages/load/add-load/add-load.component.ts | 4 +- .../load/edit-load/edit-load.component.ts | 4 +- .../truck-details/truck-details.component.ts | 20 ++++------ src/Client/Logistics.OfficeApp/src/main.ts | 26 +++--------- 25 files changed, 90 insertions(+), 153 deletions(-) delete mode 100644 src/Client/Logistics.OfficeApp/src/app/configs/app.config.ts delete mode 100644 src/Client/Logistics.OfficeApp/src/app/core/core.module.ts diff --git a/README.md b/README.md index b83c68508..d256fa762 100644 --- a/README.md +++ b/README.md @@ -37,10 +37,10 @@ Follow these steps to get the project up and running: $ cd logistics-app ``` -3. Install Angular app NPM packages: +3. Install Angular app dependencies: ``` cd src\Client\Logistics.OfficeApp - npm install + bun install ``` 4. Update database connection strings: diff --git a/src/Client/Logistics.OfficeApp/src/app/app.config.ts b/src/Client/Logistics.OfficeApp/src/app/app.config.ts index e69de29bb..f34764131 100644 --- a/src/Client/Logistics.OfficeApp/src/app/app.config.ts +++ b/src/Client/Logistics.OfficeApp/src/app/app.config.ts @@ -0,0 +1,20 @@ +import { provideHttpClient, withInterceptors } from '@angular/common/http'; +import { ApplicationConfig, importProvidersFrom } from "@angular/core"; +import { BrowserModule } from '@angular/platform-browser'; +import { provideAnimations } from '@angular/platform-browser/animations'; +import { provideRouter } from '@angular/router'; +import { provideAuth } from 'angular-auth-oidc-client'; +import { ToastModule } from 'primeng/toast'; +import { APP_ROUTES } from './app.routes'; +import { AUTH_CONFIG } from './configs'; +import { tenantInterceptor, tokenInterceptor } from './core/interceptors'; + +export const appConfig: ApplicationConfig = { + providers: [ + provideAuth({config: AUTH_CONFIG}), + provideRouter(APP_ROUTES), + importProvidersFrom(BrowserModule, ToastModule), + provideAnimations(), + provideHttpClient(withInterceptors([tenantInterceptor, tokenInterceptor])), + ], +}; diff --git a/src/Client/Logistics.OfficeApp/src/app/components/layout/sidebar/sidebar.component.ts b/src/Client/Logistics.OfficeApp/src/app/components/layout/sidebar/sidebar.component.ts index f99f541df..129f90b6c 100644 --- a/src/Client/Logistics.OfficeApp/src/app/components/layout/sidebar/sidebar.component.ts +++ b/src/Client/Logistics.OfficeApp/src/app/components/layout/sidebar/sidebar.component.ts @@ -6,7 +6,7 @@ import {SplitButtonModule} from "primeng/splitbutton"; import {PanelMenuModule} from "primeng/panelmenu"; import {OverlayPanelModule} from "primeng/overlaypanel"; import {MenuItem} from "primeng/api"; -import {AppConfig} from "@/configs"; +import {GLOBAL_CONFIG} from "@/configs"; import {AuthService} from "@/core/auth"; import {ApiService, TenantService} from "@/core/services"; @@ -107,6 +107,6 @@ export class SidebarComponent implements OnInit { } openAccountUrl() { - window.open(`${AppConfig.idHost}/account/manage/profile`, "_blank"); + window.open(`${GLOBAL_CONFIG.idHost}/account/manage/profile`, "_blank"); } } diff --git a/src/Client/Logistics.OfficeApp/src/app/configs/app.config.ts b/src/Client/Logistics.OfficeApp/src/app/configs/app.config.ts deleted file mode 100644 index ba96bc627..000000000 --- a/src/Client/Logistics.OfficeApp/src/app/configs/app.config.ts +++ /dev/null @@ -1,12 +0,0 @@ -import {environment} from "src/environments/environment"; - -export const AppConfig = { - apiHost: environment.apiHost, - idHost: environment.idHost, - mapboxToken: environment.mapboxToken, - storage: { - keys: { - user: "User", - }, - }, -}; diff --git a/src/Client/Logistics.OfficeApp/src/app/configs/auth.config.ts b/src/Client/Logistics.OfficeApp/src/app/configs/auth.config.ts index 58c18a7ed..7d9cb4e82 100644 --- a/src/Client/Logistics.OfficeApp/src/app/configs/auth.config.ts +++ b/src/Client/Logistics.OfficeApp/src/app/configs/auth.config.ts @@ -1,8 +1,8 @@ import {OpenIdConfiguration} from "angular-auth-oidc-client"; -import {AppConfig} from "./app.config"; +import {GLOBAL_CONFIG} from "./global.config"; -export const AuthConfig: OpenIdConfiguration = { - authority: AppConfig.idHost, +export const AUTH_CONFIG: OpenIdConfiguration = { + authority: GLOBAL_CONFIG.idHost, postLoginRoute: "/", // forbiddenRoute: '/forbidden', unauthorizedRoute: "/unauthorized", diff --git a/src/Client/Logistics.OfficeApp/src/app/configs/global.config.ts b/src/Client/Logistics.OfficeApp/src/app/configs/global.config.ts index 010d8e569..5a455a4e5 100644 --- a/src/Client/Logistics.OfficeApp/src/app/configs/global.config.ts +++ b/src/Client/Logistics.OfficeApp/src/app/configs/global.config.ts @@ -1,6 +1,6 @@ import {environment} from "src/environments/environment"; -export const APP_CONFIG = { +export const GLOBAL_CONFIG = { apiHost: environment.apiHost, idHost: environment.idHost, mapboxToken: environment.mapboxToken, diff --git a/src/Client/Logistics.OfficeApp/src/app/configs/index.ts b/src/Client/Logistics.OfficeApp/src/app/configs/index.ts index b504e4b71..0b64101fc 100644 --- a/src/Client/Logistics.OfficeApp/src/app/configs/index.ts +++ b/src/Client/Logistics.OfficeApp/src/app/configs/index.ts @@ -1,2 +1,2 @@ -export {AuthConfig} from "./auth.config"; -export {AppConfig} from "./app.config"; +export * from "./auth.config"; +export * from "./global.config"; diff --git a/src/Client/Logistics.OfficeApp/src/app/core/core.module.ts b/src/Client/Logistics.OfficeApp/src/app/core/core.module.ts deleted file mode 100644 index c67530ca4..000000000 --- a/src/Client/Logistics.OfficeApp/src/app/core/core.module.ts +++ /dev/null @@ -1,40 +0,0 @@ -import {AuthModule} from "angular-auth-oidc-client"; -import {NgModule} from "@angular/core"; -import {CommonModule} from "@angular/common"; -import {HTTP_INTERCEPTORS} from "@angular/common/http"; -import {AuthConfig} from "@/configs"; -import {TenantInterceptor} from "./interceptors/tenant.interceptor"; -import {TokenInterceptor} from "./interceptors/token.interceptor"; -import {AuthGuard} from "./guards/auth.guard"; -import { - ApiService, - CookieService, - LiveTrackingService, - NotificationService, - StorageService, - ToastService, -} from "./services"; -import {MessageService} from "primeng/api"; - -@NgModule({ - declarations: [], - imports: [ - AuthModule.forRoot({ - config: AuthConfig, - }), - CommonModule, - ], - providers: [ - {provide: HTTP_INTERCEPTORS, useClass: TenantInterceptor, multi: true}, - {provide: HTTP_INTERCEPTORS, useClass: TokenInterceptor, multi: true}, - AuthGuard, - ApiService, - CookieService, - StorageService, - LiveTrackingService, - NotificationService, - MessageService, - ToastService, - ], -}) -export class CoreModule {} diff --git a/src/Client/Logistics.OfficeApp/src/app/core/guards/auth.guard.ts b/src/Client/Logistics.OfficeApp/src/app/core/guards/auth.guard.ts index 20ada2ca9..e5f8f9c3a 100644 --- a/src/Client/Logistics.OfficeApp/src/app/core/guards/auth.guard.ts +++ b/src/Client/Logistics.OfficeApp/src/app/core/guards/auth.guard.ts @@ -3,7 +3,7 @@ import {ActivatedRouteSnapshot, Router, UrlTree} from "@angular/router"; import {map, Observable} from "rxjs"; import {AuthService, UserData} from "@/core/auth"; -@Injectable() +@Injectable({providedIn: "root"}) export class AuthGuard { constructor( private authService: AuthService, diff --git a/src/Client/Logistics.OfficeApp/src/app/core/guards/index.ts b/src/Client/Logistics.OfficeApp/src/app/core/guards/index.ts index b2d56accb..557cb6f1f 100644 --- a/src/Client/Logistics.OfficeApp/src/app/core/guards/index.ts +++ b/src/Client/Logistics.OfficeApp/src/app/core/guards/index.ts @@ -1 +1 @@ -export {AuthGuard} from "./auth.guard"; +export * from "./auth.guard"; diff --git a/src/Client/Logistics.OfficeApp/src/app/core/interceptors/index.ts b/src/Client/Logistics.OfficeApp/src/app/core/interceptors/index.ts index cdcaa207c..63a2c41ed 100644 --- a/src/Client/Logistics.OfficeApp/src/app/core/interceptors/index.ts +++ b/src/Client/Logistics.OfficeApp/src/app/core/interceptors/index.ts @@ -1,2 +1,2 @@ -export {TenantInterceptor} from "./tenant.interceptor"; -export {TokenInterceptor} from "./token.interceptor"; +export * from "./tenant.interceptor"; +export * from "./token.interceptor"; diff --git a/src/Client/Logistics.OfficeApp/src/app/core/interceptors/tenant.interceptor.ts b/src/Client/Logistics.OfficeApp/src/app/core/interceptors/tenant.interceptor.ts index de397d34c..a38c1dcd0 100644 --- a/src/Client/Logistics.OfficeApp/src/app/core/interceptors/tenant.interceptor.ts +++ b/src/Client/Logistics.OfficeApp/src/app/core/interceptors/tenant.interceptor.ts @@ -1,20 +1,16 @@ -import {Injectable} from "@angular/core"; -import {HttpRequest, HttpHandler, HttpEvent, HttpInterceptor} from "@angular/common/http"; +import {inject} from "@angular/core"; +import {HttpRequest, HttpEvent, HttpHandlerFn} from "@angular/common/http"; import {Observable} from "rxjs"; import {TenantService} from "../services/tenant.service"; -@Injectable() -export class TenantInterceptor implements HttpInterceptor { - constructor(private tenantService: TenantService) {} +export function tenantInterceptor(request: HttpRequest, next: HttpHandlerFn): Observable> { + const tenantService = inject(TenantService); + const tenantId = tenantService.getTenantName(); + const headers = tenantService.createTenantHeaders(request.headers, tenantId); + tenantService.setTenantCookie(tenantId); - intercept(request: HttpRequest, next: HttpHandler): Observable> { - const tenantId = this.tenantService.getTenantName(); - const headers = this.tenantService.createTenantHeaders(request.headers, tenantId); - this.tenantService.setTenantCookie(tenantId); - - request = request.clone({ - headers: headers, - }); - return next.handle(request); - } + request = request.clone({ + headers: headers, + }); + return next(request); } diff --git a/src/Client/Logistics.OfficeApp/src/app/core/interceptors/token.interceptor.ts b/src/Client/Logistics.OfficeApp/src/app/core/interceptors/token.interceptor.ts index d6a8b5166..b6b566bed 100644 --- a/src/Client/Logistics.OfficeApp/src/app/core/interceptors/token.interceptor.ts +++ b/src/Client/Logistics.OfficeApp/src/app/core/interceptors/token.interceptor.ts @@ -1,25 +1,20 @@ -import {Injectable} from "@angular/core"; -import {HttpRequest, HttpHandler, HttpEvent, HttpInterceptor} from "@angular/common/http"; +import {inject} from "@angular/core"; +import {HttpRequest, HttpEvent, HttpHandlerFn} from "@angular/common/http"; import {Observable} from "rxjs"; import {AuthService} from "@/core/auth"; -@Injectable() -export class TokenInterceptor implements HttpInterceptor { - constructor(private authService: AuthService) {} +export function tokenInterceptor(request: HttpRequest, next: HttpHandlerFn): Observable> { + const authService = inject(AuthService); + let token = ""; + authService.getAccessToken().subscribe((i) => (token = i)); + const headers = {Authorization: ""}; - intercept(request: HttpRequest, next: HttpHandler): Observable> { - let token = ""; - this.authService.getAccessToken().subscribe((i) => (token = i)); - const headers = {Authorization: ""}; - - if (!request.headers.get("bypassAuthorization")) { - headers["Authorization"] = `Bearer ${token}`; - } - - const newRequest = request.clone({ - setHeaders: headers, - }); - - return next.handle(newRequest); + if (!request.headers.get("bypassAuthorization")) { + headers["Authorization"] = `Bearer ${token}`; } + + const newRequest = request.clone({ + setHeaders: headers, + }); + return next(newRequest); } diff --git a/src/Client/Logistics.OfficeApp/src/app/core/services/api.service.ts b/src/Client/Logistics.OfficeApp/src/app/core/services/api.service.ts index 8670b431b..1747dd830 100644 --- a/src/Client/Logistics.OfficeApp/src/app/core/services/api.service.ts +++ b/src/Client/Logistics.OfficeApp/src/app/core/services/api.service.ts @@ -3,7 +3,7 @@ import {Injectable} from "@angular/core"; import {MessageService} from "primeng/api"; import {catchError, Observable, of} from "rxjs"; import {TenantService} from "@/core/services"; -import {AppConfig} from "@/configs"; +import {GLOBAL_CONFIG} from "@/configs"; import { Result, EmployeeDto, @@ -45,7 +45,7 @@ import { GetPayrollsQuery, } from "../models"; -@Injectable() +@Injectable({providedIn: "root"}) export class ApiService { private host: string; private headers: Record; @@ -55,7 +55,7 @@ export class ApiService { private readonly tenantService: TenantService, private readonly messageService: MessageService ) { - this.host = AppConfig.apiHost; + this.host = GLOBAL_CONFIG.apiHost; this.headers = {"content-type": "application/json"}; } diff --git a/src/Client/Logistics.OfficeApp/src/app/core/services/base-hub-connection.ts b/src/Client/Logistics.OfficeApp/src/app/core/services/base-hub-connection.ts index 1f062b04e..739763632 100644 --- a/src/Client/Logistics.OfficeApp/src/app/core/services/base-hub-connection.ts +++ b/src/Client/Logistics.OfficeApp/src/app/core/services/base-hub-connection.ts @@ -1,4 +1,4 @@ -import {AppConfig} from "@/configs"; +import {GLOBAL_CONFIG} from "@/configs"; import {HubConnection, HubConnectionBuilder, HttpTransportType} from "@microsoft/signalr"; import {TenantService} from "./tenant.service"; @@ -12,7 +12,7 @@ export abstract class BaseHubConnection { ) { this.isConnected = false; this.hubConnection = new HubConnectionBuilder() - .withUrl(`${AppConfig.apiHost}/hubs/${hubName}`, { + .withUrl(`${GLOBAL_CONFIG.apiHost}/hubs/${hubName}`, { skipNegotiation: true, transport: HttpTransportType.WebSockets, }) diff --git a/src/Client/Logistics.OfficeApp/src/app/core/services/cookie.service.ts b/src/Client/Logistics.OfficeApp/src/app/core/services/cookie.service.ts index 054ae63b0..e45568c69 100644 --- a/src/Client/Logistics.OfficeApp/src/app/core/services/cookie.service.ts +++ b/src/Client/Logistics.OfficeApp/src/app/core/services/cookie.service.ts @@ -1,6 +1,6 @@ import {Injectable} from "@angular/core"; -@Injectable() +@Injectable({providedIn: "root"}) export class CookieService { getCookie(name: string): string { const cookies = document.cookie.split(";"); diff --git a/src/Client/Logistics.OfficeApp/src/app/core/services/notification.service.ts b/src/Client/Logistics.OfficeApp/src/app/core/services/notification.service.ts index 8bc93c541..96bec969b 100644 --- a/src/Client/Logistics.OfficeApp/src/app/core/services/notification.service.ts +++ b/src/Client/Logistics.OfficeApp/src/app/core/services/notification.service.ts @@ -6,7 +6,7 @@ import {TenantService} from "./tenant.service"; import {BaseHubConnection} from "./base-hub-connection"; import {ApiService} from "./api.service"; -@Injectable() +@Injectable({providedIn: "root"}) export class NotificationService extends BaseHubConnection { constructor( private apiService: ApiService, @@ -15,7 +15,7 @@ export class NotificationService extends BaseHubConnection { super("notification", tenantService); } - set onReceiveNotification(callback: OnReceiveNotifictionCallback) { + set onReceiveNotification(callback: OnReceiveNotifictionFn) { this.hubConnection.on("ReceiveNotification", callback); } @@ -32,4 +32,4 @@ export class NotificationService extends BaseHubConnection { } } -type OnReceiveNotifictionCallback = (notification: NotificationDto) => void; +type OnReceiveNotifictionFn = (notification: NotificationDto) => void; diff --git a/src/Client/Logistics.OfficeApp/src/app/core/services/storage.service.ts b/src/Client/Logistics.OfficeApp/src/app/core/services/storage.service.ts index adb38e853..44891ca00 100644 --- a/src/Client/Logistics.OfficeApp/src/app/core/services/storage.service.ts +++ b/src/Client/Logistics.OfficeApp/src/app/core/services/storage.service.ts @@ -1,6 +1,6 @@ import {Injectable} from "@angular/core"; -@Injectable() +@Injectable({providedIn: "root"}) export class StorageService { get(name: string): T | null { try { diff --git a/src/Client/Logistics.OfficeApp/src/app/core/services/toast.service.ts b/src/Client/Logistics.OfficeApp/src/app/core/services/toast.service.ts index 0b573232d..86039c7a2 100644 --- a/src/Client/Logistics.OfficeApp/src/app/core/services/toast.service.ts +++ b/src/Client/Logistics.OfficeApp/src/app/core/services/toast.service.ts @@ -1,7 +1,7 @@ import {Injectable} from "@angular/core"; import {MessageService} from "primeng/api"; -@Injectable() +@Injectable({providedIn: "root"}) export class ToastService { constructor(private messageService: MessageService) {} diff --git a/src/Client/Logistics.OfficeApp/src/app/pages/dashboard/dashboard.component.ts b/src/Client/Logistics.OfficeApp/src/app/pages/dashboard/dashboard.component.ts index dbd17d101..a2c22f9a0 100644 --- a/src/Client/Logistics.OfficeApp/src/app/pages/dashboard/dashboard.component.ts +++ b/src/Client/Logistics.OfficeApp/src/app/pages/dashboard/dashboard.component.ts @@ -1,6 +1,6 @@ import {Component} from "@angular/core"; import {CommonModule} from "@angular/common"; -import {AppConfig} from "@/configs"; +import {GLOBAL_CONFIG} from "@/configs"; import {GrossesBarchartComponent, TrucksMapComponent} from "@/components"; import {CompanyStatsComponent, TruckStatsTableComponent} from "./components"; @@ -21,6 +21,6 @@ export class DashboardComponent { public readonly accessToken: string; constructor() { - this.accessToken = AppConfig.mapboxToken; + this.accessToken = GLOBAL_CONFIG.mapboxToken; } } diff --git a/src/Client/Logistics.OfficeApp/src/app/pages/home/home.component.ts b/src/Client/Logistics.OfficeApp/src/app/pages/home/home.component.ts index 73e1d731d..b023660bb 100644 --- a/src/Client/Logistics.OfficeApp/src/app/pages/home/home.component.ts +++ b/src/Client/Logistics.OfficeApp/src/app/pages/home/home.component.ts @@ -8,7 +8,7 @@ import {TooltipModule} from "primeng/tooltip"; import {TableModule} from "primeng/table"; import {SharedModule} from "primeng/api"; import {CardModule} from "primeng/card"; -import {AppConfig} from "@/configs"; +import {GLOBAL_CONFIG} from "@/configs"; import {DailyGrossesDto, LoadDto} from "@/core/models"; import {ApiService} from "@/core/services"; import {TrucksMapComponent} from "@/components"; @@ -39,7 +39,7 @@ import {NotificationsPanelComponent} from "./components"; ], }) export class HomeComponent implements OnInit { - public readonly accessToken = AppConfig.mapboxToken; + public readonly accessToken = GLOBAL_CONFIG.mapboxToken; public todayGross = 0; public weeklyGross = 0; public weeklyDistance = 0; diff --git a/src/Client/Logistics.OfficeApp/src/app/pages/load/add-load/add-load.component.ts b/src/Client/Logistics.OfficeApp/src/app/pages/load/add-load/add-load.component.ts index 17f55570a..21ca9f80c 100644 --- a/src/Client/Logistics.OfficeApp/src/app/pages/load/add-load/add-load.component.ts +++ b/src/Client/Logistics.OfficeApp/src/app/pages/load/add-load/add-load.component.ts @@ -8,7 +8,7 @@ import {ButtonModule} from "primeng/button"; import {DropdownModule} from "primeng/dropdown"; import {AutoCompleteModule} from "primeng/autocomplete"; import {ProgressSpinnerModule} from "primeng/progressspinner"; -import {AppConfig} from "@/configs"; +import {GLOBAL_CONFIG} from "@/configs"; import {AuthService} from "@/core/auth"; import {AddressDto, CreateLoadCommand, CustomerDto} from "@/core/models"; import {ApiService, ToastService} from "@/core/services"; @@ -47,7 +47,7 @@ import {TruckData} from "../shared"; ], }) export class AddLoadComponent implements OnInit { - public readonly accessToken = AppConfig.mapboxToken; + public readonly accessToken = GLOBAL_CONFIG.mapboxToken; private distanceMeters = 0; public isLoading = false; public form: FormGroup; diff --git a/src/Client/Logistics.OfficeApp/src/app/pages/load/edit-load/edit-load.component.ts b/src/Client/Logistics.OfficeApp/src/app/pages/load/edit-load/edit-load.component.ts index b62bc3786..1ec656e28 100644 --- a/src/Client/Logistics.OfficeApp/src/app/pages/load/edit-load/edit-load.component.ts +++ b/src/Client/Logistics.OfficeApp/src/app/pages/load/edit-load/edit-load.component.ts @@ -10,7 +10,7 @@ import {ButtonModule} from "primeng/button"; import {DropdownModule} from "primeng/dropdown"; import {AutoCompleteModule} from "primeng/autocomplete"; import {ProgressSpinnerModule} from "primeng/progressspinner"; -import {AppConfig} from "@/configs"; +import {GLOBAL_CONFIG} from "@/configs"; import {EnumType, LoadStatus, LoadStatusEnum} from "@/core/enums"; import {AddressDto, CustomerDto, UpdateLoadCommand} from "@/core/models"; import {ApiService, ToastService} from "@/core/services"; @@ -51,7 +51,7 @@ import {SearchCustomerComponent, SearchTruckComponent} from "../components"; providers: [ConfirmationService], }) export class EditLoadComponent implements OnInit { - public readonly accessToken = AppConfig.mapboxToken; + public readonly accessToken = GLOBAL_CONFIG.mapboxToken; private distanceMeters = 0; public id!: string; public loadRefId!: number; diff --git a/src/Client/Logistics.OfficeApp/src/app/pages/truck/truck-details/truck-details.component.ts b/src/Client/Logistics.OfficeApp/src/app/pages/truck/truck-details/truck-details.component.ts index f9e9eac72..0633809de 100644 --- a/src/Client/Logistics.OfficeApp/src/app/pages/truck/truck-details/truck-details.component.ts +++ b/src/Client/Logistics.OfficeApp/src/app/pages/truck/truck-details/truck-details.component.ts @@ -7,7 +7,7 @@ import {DailyGrossesDto, MonthlyGrossesDto, TruckDto, TruckGeolocationDto} from import {DistanceUnitPipe} from "@/core/pipes"; import {ApiService} from "@/core/services"; import {GeolocationMapComponent, GrossesBarchartComponent, BarChartDrawnEvent} from "@/components"; -import {AppConfig} from "@/configs"; +import {GLOBAL_CONFIG} from "@/configs"; import {LineChartDrawnEvent, TruckGrossesLinechartComponent} from "../components"; @Component({ @@ -28,26 +28,20 @@ import {LineChartDrawnEvent, TruckGrossesLinechartComponent} from "../components ], }) export class TruckDetailsComponent implements OnInit { - public readonly accessToken: string; + public readonly accessToken = GLOBAL_CONFIG.mapboxToken; public id!: string; - public isLoading: boolean; + public isLoading = false; public truck?: TruckDto; public dailyGrosses?: DailyGrossesDto; public monthlyGrosses?: MonthlyGrossesDto; - public rpmCurrent: number; - public rpmAllTime: number; - public truckLocations: TruckGeolocationDto[]; + public rpmCurrent = 0; + public rpmAllTime = 0; + public truckLocations: TruckGeolocationDto[] = []; constructor( private apiService: ApiService, private route: ActivatedRoute - ) { - this.accessToken = AppConfig.mapboxToken; - this.truckLocations = []; - this.isLoading = false; - this.rpmCurrent = 0; - this.rpmAllTime = 0; - } + ) {} ngOnInit(): void { this.route.params.subscribe((params) => { diff --git a/src/Client/Logistics.OfficeApp/src/main.ts b/src/Client/Logistics.OfficeApp/src/main.ts index 73dddbb41..5b7686934 100644 --- a/src/Client/Logistics.OfficeApp/src/main.ts +++ b/src/Client/Logistics.OfficeApp/src/main.ts @@ -1,22 +1,6 @@ -import {enableProdMode, importProvidersFrom} from "@angular/core"; -import {provideRouter} from "@angular/router"; -import {withInterceptorsFromDi, provideHttpClient} from "@angular/common/http"; -import {provideAnimations} from "@angular/platform-browser/animations"; -import {BrowserModule, bootstrapApplication} from "@angular/platform-browser"; -import {CoreModule} from "@/core/core.module"; -import {APP_ROUTES} from "./app/app.routes"; -import {AppComponent} from "./app/app.component"; -import {environment} from "./environments/environment"; +import {bootstrapApplication} from "@angular/platform-browser"; +import {AppComponent} from "@/app.component"; +import {appConfig} from "@/app.config"; -if (environment.production) { - enableProdMode(); -} - -bootstrapApplication(AppComponent, { - providers: [ - provideRouter(APP_ROUTES), - importProvidersFrom(BrowserModule, CoreModule), - provideAnimations(), - provideHttpClient(withInterceptorsFromDi()), - ], -}).catch((err) => console.error(err)); +bootstrapApplication(AppComponent, appConfig) + .catch((err) => console.error(err));