import { Injectable } from '@angular/core' ; import { ActivatedRouteSnapshot , Resolve , RouterStateSnapshot } from '@angular/router' ; import { Group } from '../models/group' ; import { Observable } from 'rxjs' ; import { GroupService } from '../services/group.service' ; import { APIGetMultiResponse } from '../../services/models/api-response' ; import { CollectionParameters } from '../../services/models/api-parameter' ; import { map } from 'rxjs/operators' ; import { User } from '../models/user' ; import { AuthService } from '../../auth/services/auth.service' ; import { UserService } from '../services/user.service' ; @ Injectable ( { providedIn : 'root' } ) export class OwnGroupResolver implements Resolve < Group > { constructor ( private authService , private groupService ) { } public resolve ( route , state ) { const groupID = + this . authService . currentUserValue . group_id ; return this . groupService . getGroup ( groupID ) ; } } /**
 * Resolver for a single group
 */ @ Injectable ( { providedIn : 'root' } ) export class GroupResolver implements Resolve < Group > { constructor ( private groupService ) { } public resolve ( route , state ) { const groupID = + route . paramMap . get ( 'publicID' ) ; return this . groupService . getGroup ( groupID ) ; } } /**
 * Resolver for all groups
 */ @ Injectable ( { providedIn : 'root' } ) export class GroupsResolver implements Resolve < Array < Group > > { constructor ( private groupService ) { } public resolve ( route , state ) { const params = { filter : undefined , limit : 0 , sort : 'public_id' , order : 1 , page : 1 } ; return this . groupService . getGroups ( params ) . pipe ( map ( ( response ) => { return response . results as Array < Group > ; } ) ) ; } }