api url is added
This commit is contained in:
parent
cd76913035
commit
94efeb43fd
|
@ -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 },
|
||||
|
|
|
@ -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<AccountsRootModule> {
|
||||
return {
|
||||
ngModule: AccountsRootModule,
|
||||
providers: [
|
||||
AccountsService,
|
||||
],
|
||||
providers: [...SERVICES]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
AccountsStoreModule,
|
||||
],
|
||||
exports: [
|
||||
]
|
||||
})
|
||||
export class AccountsRootModule {
|
||||
}
|
||||
|
|
|
@ -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<string, string>) {
|
||||
// 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<User>(
|
||||
`${this.apiEntryPoint}/auth/signin`,
|
||||
model
|
||||
);
|
||||
return this.httpClient.post<User>(`${this.apiBaseUrl}/auth/signin`, model);
|
||||
}
|
||||
}
|
||||
|
|
3
src/app/pages/accounts/service/index.ts
Normal file
3
src/app/pages/accounts/service/index.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
import { AccountsService } from './accounts.service';
|
||||
|
||||
export const SERVICES = [AccountsService];
|
3
src/shared/common/type/injection-token.type.ts
Normal file
3
src/shared/common/type/injection-token.type.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
import { InjectionToken } from '@angular/core';
|
||||
|
||||
export const API_BASE_URL = new InjectionToken<string>('API_BASE_URL');
|
Loading…
Reference in New Issue
Block a user