2021-04-15 14:13:46 +00:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
|
|
|
|
import { forkJoin, Observable } from 'rxjs';
|
2021-06-08 14:29:45 +00:00
|
|
|
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';
|
2021-04-15 14:13:46 +00:00
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
})
|
|
|
|
export class InitialDataResolver implements Resolve<any>
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*/
|
2021-06-08 14:29:45 +00:00
|
|
|
constructor(
|
|
|
|
private _messagesService: MessagesService,
|
|
|
|
private _navigationService: NavigationService,
|
|
|
|
private _notificationsService: NotificationsService,
|
|
|
|
private _shortcutsService: ShortcutsService,
|
|
|
|
private _userService: UserService
|
|
|
|
)
|
2021-04-15 14:13:46 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------------------------------
|
|
|
|
// @ Public methods
|
|
|
|
// -----------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Use this resolver to resolve initial mock-api for the application
|
|
|
|
*
|
|
|
|
* @param route
|
|
|
|
* @param state
|
|
|
|
*/
|
2021-06-08 14:29:45 +00:00
|
|
|
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<any>
|
2021-04-15 14:13:46 +00:00
|
|
|
{
|
|
|
|
// Fork join multiple API endpoint calls to wait all of them to finish
|
|
|
|
return forkJoin([
|
2021-06-08 14:29:45 +00:00
|
|
|
this._navigationService.get(),
|
|
|
|
this._messagesService.getAll(),
|
|
|
|
this._notificationsService.getAll(),
|
|
|
|
this._shortcutsService.getAll(),
|
|
|
|
this._userService.get()
|
|
|
|
]);
|
2021-04-15 14:13:46 +00:00
|
|
|
}
|
|
|
|
}
|