1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-14 11:23:17 +02:00
pigallery2/frontend/app/model/navigation.service.ts
2018-05-09 13:56:02 -04:00

37 lines
992 B
TypeScript

import {Injectable} from '@angular/core';
import {Router} from '@angular/router';
import {ShareService} from '../gallery/share.service';
@Injectable()
export class NavigationService {
constructor(private _router: Router,
private _shareService: ShareService) {
}
public isLoginPage() {
return this._router.isActive('login', true) || this._router.isActive('shareLogin', true);
}
public async toLogin() {
await this._shareService.wait();
if (this._shareService.isSharing()) {
return this._router.navigate(['shareLogin'], {queryParams: {sk: this._shareService.getSharingKey()}});
} else {
return this._router.navigate(['login']);
}
}
public async toGallery() {
await this._shareService.wait();
if (this._shareService.isSharing()) {
return this._router.navigate(['gallery', ''], {queryParams: {sk: this._shareService.getSharingKey()}});
} else {
return this._router.navigate(['gallery', '']);
}
}
}