(Config Service) Added ability to access to the default config and reset to it

This commit is contained in:
Sercan Yemen 2018-05-27 16:57:54 +03:00
parent 02f305be1f
commit 9635165316

View File

@ -59,6 +59,16 @@ export class FuseConfigService
return this._configSubject.asObservable(); return this._configSubject.asObservable();
} }
/**
* Get default config
*
* @returns {any}
*/
get defaultConfig(): any
{
return this._defaultConfig;
}
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------
// @ Private methods // @ Private methods
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------
@ -78,11 +88,11 @@ export class FuseConfigService
this._defaultConfig.customScrollbars = false; this._defaultConfig.customScrollbars = false;
} }
// Set the settings from the default settings // Set the config from the default config
this._configSubject = new BehaviorSubject(_.cloneDeep(this._defaultConfig)); this._configSubject = new BehaviorSubject(_.cloneDeep(this._defaultConfig));
// Reload the default settings on every navigation start if // Reload the default config on every navigation start if
// the current settings are different from defaults // the current config is different from the default one
this._router.events this._router.events
.pipe(filter(event => event instanceof NavigationStart)) .pipe(filter(event => event instanceof NavigationStart))
.subscribe(() => { .subscribe(() => {
@ -92,5 +102,18 @@ export class FuseConfigService
} }
}); });
} }
// -----------------------------------------------------------------------------------------------------
// @ Public methods
// -----------------------------------------------------------------------------------------------------
/**
* Reset to the default config
*/
resetToDefaults(): void
{
// Set the config from the default config
this._configSubject.next(_.cloneDeep(this._defaultConfig));
}
} }