mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-01-10 04:25:08 +00:00
9005f08ac7
(layouts) Common components of layouts now requests their data directly from their service rather than getting it from route data (core) New navigation service to request and store the navigation data
50 lines
1.8 KiB
TypeScript
50 lines
1.8 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
|
|
import { forkJoin, Observable } from 'rxjs';
|
|
import { MessagesService } from 'app/layout/common/messages/messages.service';
|
|
import { NavigationService } from 'app/core/navigation/navigation.service';
|
|
import { NotificationsService } from 'app/layout/common/notifications/notifications.service';
|
|
import { ShortcutsService } from 'app/layout/common/shortcuts/shortcuts.service';
|
|
import { UserService } from 'app/core/user/user.service';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class InitialDataResolver implements Resolve<any>
|
|
{
|
|
/**
|
|
* Constructor
|
|
*/
|
|
constructor(
|
|
private _messagesService: MessagesService,
|
|
private _navigationService: NavigationService,
|
|
private _notificationsService: NotificationsService,
|
|
private _shortcutsService: ShortcutsService,
|
|
private _userService: UserService
|
|
)
|
|
{
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------------------------------
|
|
// @ Public methods
|
|
// -----------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
* Use this resolver to resolve initial mock-api for the application
|
|
*
|
|
* @param route
|
|
* @param state
|
|
*/
|
|
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<any>
|
|
{
|
|
// Fork join multiple API endpoint calls to wait all of them to finish
|
|
return forkJoin([
|
|
this._navigationService.get(),
|
|
this._messagesService.getAll(),
|
|
this._notificationsService.getAll(),
|
|
this._shortcutsService.getAll(),
|
|
this._userService.get()
|
|
]);
|
|
}
|
|
}
|