mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-01-09 12:05:08 +00:00
(core) Separated the "auth" and "icon registry" to their own modules to keep the CoreModule simple
This commit is contained in:
parent
9edc62f703
commit
e00dda98bc
21
src/app/core/auth/auth.module.ts
Normal file
21
src/app/core/auth/auth.module.ts
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
|
||||||
|
import { AuthService } from 'app/core/auth/auth.service';
|
||||||
|
import { AuthInterceptor } from 'app/core/auth/auth.interceptor';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports : [
|
||||||
|
HttpClientModule
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
AuthService,
|
||||||
|
{
|
||||||
|
provide : HTTP_INTERCEPTORS,
|
||||||
|
useClass: AuthInterceptor,
|
||||||
|
multi : true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class AuthModule
|
||||||
|
{
|
||||||
|
}
|
|
@ -1,21 +1,11 @@
|
||||||
import { NgModule, Optional, SkipSelf } from '@angular/core';
|
import { NgModule, Optional, SkipSelf } from '@angular/core';
|
||||||
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
|
import { AuthModule } from 'app/core/auth/auth.module';
|
||||||
import { DomSanitizer } from '@angular/platform-browser';
|
import { IconsModule } from 'app/core/icons/icons.module';
|
||||||
import { MatIconRegistry } from '@angular/material/icon';
|
|
||||||
import { AuthService } from 'app/core/auth/auth.service';
|
|
||||||
import { AuthInterceptor } from 'app/core/auth/auth.interceptor';
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports : [
|
imports: [
|
||||||
HttpClientModule
|
AuthModule,
|
||||||
],
|
IconsModule
|
||||||
providers: [
|
|
||||||
AuthService,
|
|
||||||
{
|
|
||||||
provide : HTTP_INTERCEPTORS,
|
|
||||||
useClass: AuthInterceptor,
|
|
||||||
multi : true
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class CoreModule
|
export class CoreModule
|
||||||
|
@ -24,8 +14,6 @@ export class CoreModule
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
private _domSanitizer: DomSanitizer,
|
|
||||||
private _matIconRegistry: MatIconRegistry,
|
|
||||||
@Optional() @SkipSelf() parentModule?: CoreModule
|
@Optional() @SkipSelf() parentModule?: CoreModule
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -34,14 +22,5 @@ export class CoreModule
|
||||||
{
|
{
|
||||||
throw new Error('CoreModule has already been loaded. Import this module in the AppModule only.');
|
throw new Error('CoreModule has already been loaded. Import this module in the AppModule only.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register icon sets
|
|
||||||
this._matIconRegistry.addSvgIconSet(this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/material-twotone.svg'));
|
|
||||||
this._matIconRegistry.addSvgIconSetInNamespace('mat_outline', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/material-outline.svg'));
|
|
||||||
this._matIconRegistry.addSvgIconSetInNamespace('mat_solid', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/material-solid.svg'));
|
|
||||||
this._matIconRegistry.addSvgIconSetInNamespace('iconsmind', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/iconsmind.svg'));
|
|
||||||
this._matIconRegistry.addSvgIconSetInNamespace('feather', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/feather.svg'));
|
|
||||||
this._matIconRegistry.addSvgIconSetInNamespace('heroicons_outline', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/heroicons-outline.svg'));
|
|
||||||
this._matIconRegistry.addSvgIconSetInNamespace('heroicons_solid', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/heroicons-solid.svg'));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
25
src/app/core/icons/icons.module.ts
Normal file
25
src/app/core/icons/icons.module.ts
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { DomSanitizer } from '@angular/platform-browser';
|
||||||
|
import { MatIconRegistry } from '@angular/material/icon';
|
||||||
|
|
||||||
|
@NgModule()
|
||||||
|
export class IconsModule
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
constructor(
|
||||||
|
private _domSanitizer: DomSanitizer,
|
||||||
|
private _matIconRegistry: MatIconRegistry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Register icon sets
|
||||||
|
this._matIconRegistry.addSvgIconSet(this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/material-twotone.svg'));
|
||||||
|
this._matIconRegistry.addSvgIconSetInNamespace('mat_outline', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/material-outline.svg'));
|
||||||
|
this._matIconRegistry.addSvgIconSetInNamespace('mat_solid', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/material-solid.svg'));
|
||||||
|
this._matIconRegistry.addSvgIconSetInNamespace('iconsmind', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/iconsmind.svg'));
|
||||||
|
this._matIconRegistry.addSvgIconSetInNamespace('feather', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/feather.svg'));
|
||||||
|
this._matIconRegistry.addSvgIconSetInNamespace('heroicons_outline', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/heroicons-outline.svg'));
|
||||||
|
this._matIconRegistry.addSvgIconSetInNamespace('heroicons_solid', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/heroicons-solid.svg'));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user