1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00
pigallery2/src/frontend/app/model/navigation.service.ts

41 lines
1.1 KiB
TypeScript
Raw Normal View History

2018-03-30 15:30:30 -04:00
import {Injectable} from '@angular/core';
2017-07-09 12:03:17 +02:00
2018-03-30 15:30:30 -04:00
import {Router} from '@angular/router';
import {ShareService} from '../ui/gallery/share.service';
2017-07-09 12:03:17 +02:00
@Injectable()
export class NavigationService {
constructor(private router: Router,
private shareService: ShareService) {
2017-07-09 12:03:17 +02:00
}
public isLoginPage(): boolean {
return this.router.isActive('login', true) || this.router.isActive('shareLogin', true);
2017-07-09 12:03:17 +02:00
}
public async toLogin(): Promise<boolean> {
await this.shareService.wait();
if (this.shareService.isSharing()) {
return this.router.navigate(['shareLogin'], {queryParams: {sk: this.shareService.getSharingKey()}});
2017-07-09 12:03:17 +02:00
} else {
return this.router.navigate(['login']);
2017-07-09 12:03:17 +02:00
}
}
public async toGallery(): Promise<boolean> {
await this.shareService.wait();
if (this.shareService.isSharing()) {
return this.router.navigate(['share', this.shareService.getSharingKey()]);
2017-07-09 12:03:17 +02:00
} else {
return this.router.navigate(['gallery', '']);
2017-07-09 12:03:17 +02:00
}
}
public async search(searchText: string): Promise<boolean> {
return this.router.navigate(['search', searchText]);
}
2017-07-09 12:03:17 +02:00
}