diff --git a/src/app/app-provider.module.ts b/src/app/app-provider.module.ts index d4db7d8..4b97d17 100644 --- a/src/app/app-provider.module.ts +++ b/src/app/app-provider.module.ts @@ -3,15 +3,13 @@ import { HTTP_INTERCEPTORS } from '@angular/common/http'; import { UserModule } from './pages/users/user/user.module'; import { AppService } from './service/app.service'; - +import { API_BASE_URL } from 'src/shared/common/type/injection-token.type'; export function initApp(appService: AppService) { return () => appService.initApp(); } @NgModule({ - imports: [ - UserModule.forRoot(), - ], + imports: [UserModule.forRoot()], exports: [], providers: [ AppService, @@ -24,6 +22,11 @@ export function initApp(appService: AppService) { deps: [AppService], multi: true }, + { + provide: API_BASE_URL, + useValue: 'http://localhost:8088/api', + multi: true + }, // { provide: HTTP_INTERCEPTORS, useClass: AuthHttpInterceptor, multi: true }, { provide: 'virtualScroller.scrollThrottlingTime', useValue: 0 }, { provide: 'virtualScroller.scrollDebounceTime', useValue: 0 }, @@ -34,4 +37,4 @@ export function initApp(appService: AppService) { { provide: 'virtualScroller.resizeBypassRefreshThreshold', useValue: 5 } ] }) -export class AppProviderModule { } +export class AppProviderModule {} diff --git a/src/app/pages/accounts/accounts.module.ts b/src/app/pages/accounts/accounts.module.ts index a108993..b04e49b 100755 --- a/src/app/pages/accounts/accounts.module.ts +++ b/src/app/pages/accounts/accounts.module.ts @@ -2,8 +2,6 @@ import { NgModule, ModuleWithProviders } from '@angular/core'; import { CommonModule } from '@angular/common'; import { TranslateModule } from '@ngx-translate/core'; -import { COMPONENTS } from './component'; -import { AccountsService } from './service/accounts.service'; import { AccountsStoreModule } from './accounts-store.module'; import { MatButtonModule } from '@angular/material/button'; import { MatCheckboxModule } from '@angular/material/checkbox'; @@ -14,7 +12,14 @@ import { MatInputModule } from '@angular/material/input'; import { FuseSharedModule } from 'src/@fuse/shared.module'; import { AccountsRoutingPageModule } from './accounts-routing.page.module'; -// import { SharedModule } from '../../../common/shared/shared.module'; +import { COMPONENTS } from './component'; +import { SERVICES } from './service'; + +@NgModule({ + imports: [AccountsStoreModule], + exports: [] +}) +export class AccountsRootModule {} @NgModule({ imports: [ @@ -31,32 +36,15 @@ import { AccountsRoutingPageModule } from './accounts-routing.page.module'; FuseSharedModule // SharedModule, - - ], - declarations: [ - ...COMPONENTS, - ], - exports: [ - ...COMPONENTS, ], + declarations: [...COMPONENTS], + exports: [...COMPONENTS] }) export class AccountsModule { public static forRoot(): ModuleWithProviders { return { ngModule: AccountsRootModule, - providers: [ - AccountsService, - ], + providers: [...SERVICES] }; } } - -@NgModule({ - imports: [ - AccountsStoreModule, - ], - exports: [ - ] -}) -export class AccountsRootModule { -} diff --git a/src/app/pages/accounts/service/accounts.service.ts b/src/app/pages/accounts/service/accounts.service.ts index 1bf40a6..2ba809d 100644 --- a/src/app/pages/accounts/service/accounts.service.ts +++ b/src/app/pages/accounts/service/accounts.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core'; +import { Injectable, Inject } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; @@ -7,14 +7,15 @@ import { map } from 'rxjs/operators'; import { CookieService } from 'ngx-cookie-service'; import { environment } from '../../../../environments/environment'; import { User } from '../../../../shared/user/model/user.model'; +import { API_BASE_URL } from 'src/shared/common/type/injection-token.type'; @Injectable() export class AccountsService { public constructor( private httpClient: HttpClient, private cookieService: CookieService, - ) { - } + @Inject(API_BASE_URL) private apiBaseUrl: string + ) {} // public authenticate(oauthType: string, params?: Map) { // const query = this.getQueryParams(params); @@ -40,7 +41,6 @@ export class AccountsService { let query = ''; if (!params || 0 === params.size) { - model return query; } @@ -60,9 +60,6 @@ export class AccountsService { password }; - return this.httpClient.post( - `${this.apiEntryPoint}/auth/signin`, - model - ); + return this.httpClient.post(`${this.apiBaseUrl}/auth/signin`, model); } } diff --git a/src/app/pages/accounts/service/index.ts b/src/app/pages/accounts/service/index.ts new file mode 100644 index 0000000..06f4d72 --- /dev/null +++ b/src/app/pages/accounts/service/index.ts @@ -0,0 +1,3 @@ +import { AccountsService } from './accounts.service'; + +export const SERVICES = [AccountsService]; diff --git a/src/shared/common/type/injection-token.type.ts b/src/shared/common/type/injection-token.type.ts new file mode 100644 index 0000000..cdc816a --- /dev/null +++ b/src/shared/common/type/injection-token.type.ts @@ -0,0 +1,3 @@ +import { InjectionToken } from '@angular/core'; + +export const API_BASE_URL = new InjectionToken('API_BASE_URL');