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
2017-07-09 12:03:17 +02:00

39 lines
1.0 KiB
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() {
console.log("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() {
console.log("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", ""]);
}
}
}