2018-03-31 03:30:30 +08:00
|
|
|
import {ModuleWithProviders} from '@angular/core';
|
2018-12-10 05:33:52 +08:00
|
|
|
import {RouterModule, Routes, UrlMatchResult, UrlSegment} from '@angular/router';
|
2019-03-03 17:30:12 +08:00
|
|
|
import {LoginComponent} from './ui/login/login.component';
|
|
|
|
import {GalleryComponent} from './ui/gallery/gallery.component';
|
|
|
|
import {AdminComponent} from './ui/admin/admin.component';
|
|
|
|
import {ShareLoginComponent} from './ui/sharelogin/share-login.component';
|
2018-11-30 22:36:42 +08:00
|
|
|
import {QueryParams} from '../../common/QueryParams';
|
2019-03-03 17:30:12 +08:00
|
|
|
import {DuplicateComponent} from './ui/duplicates/duplicates.component';
|
|
|
|
import {FacesComponent} from './ui/faces/faces.component';
|
2016-12-27 06:36:38 +08:00
|
|
|
|
2018-12-10 05:33:52 +08:00
|
|
|
export function galleryMatcherFunction(
|
|
|
|
segments: UrlSegment[]): UrlMatchResult | null {
|
|
|
|
|
|
|
|
|
|
|
|
if (segments.length === 0) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
const path = segments[0].path;
|
|
|
|
|
|
|
|
const posParams: { [key: string]: UrlSegment } = {};
|
|
|
|
if (path === 'gallery') {
|
|
|
|
if (segments.length > 1) {
|
|
|
|
posParams[QueryParams.gallery.directory] = segments[1];
|
|
|
|
}
|
|
|
|
return {consumed: segments.slice(0, Math.min(segments.length, 2)), posParams};
|
|
|
|
}
|
|
|
|
if (path === 'search') {
|
|
|
|
if (segments.length > 1) {
|
|
|
|
posParams[QueryParams.gallery.searchText] = segments[1];
|
|
|
|
}
|
|
|
|
return {consumed: segments.slice(0, Math.min(segments.length, 2)), posParams};
|
|
|
|
}
|
|
|
|
if (path === 'share') {
|
|
|
|
if (segments.length > 1) {
|
|
|
|
posParams[QueryParams.gallery.sharingKey_long] = segments[1];
|
|
|
|
}
|
|
|
|
return {consumed: segments.slice(0, Math.min(segments.length, 2)), posParams};
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2016-12-27 06:36:38 +08:00
|
|
|
const ROUTES: Routes = [
|
2017-06-11 04:32:56 +08:00
|
|
|
{
|
|
|
|
path: 'login',
|
|
|
|
component: LoginComponent
|
|
|
|
},
|
2017-07-04 01:17:49 +08:00
|
|
|
{
|
|
|
|
path: 'shareLogin',
|
|
|
|
component: ShareLoginComponent
|
|
|
|
},
|
2017-06-11 04:32:56 +08:00
|
|
|
{
|
|
|
|
path: 'admin',
|
|
|
|
component: AdminComponent
|
|
|
|
},
|
2019-01-18 07:26:20 +08:00
|
|
|
{
|
|
|
|
path: 'duplicates',
|
|
|
|
component: DuplicateComponent
|
|
|
|
},
|
2019-02-15 07:25:55 +08:00
|
|
|
{
|
|
|
|
path: 'faces',
|
|
|
|
component: FacesComponent
|
|
|
|
},
|
2017-06-11 04:32:56 +08:00
|
|
|
{
|
2018-12-10 05:33:52 +08:00
|
|
|
matcher: galleryMatcherFunction,
|
2017-07-04 01:17:49 +08:00
|
|
|
component: GalleryComponent
|
|
|
|
},
|
2017-07-21 03:06:48 +08:00
|
|
|
{path: '', redirectTo: '/login', pathMatch: 'full'},
|
|
|
|
{path: '**', redirectTo: '/login', pathMatch: 'full'}
|
2016-12-27 06:36:38 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
export const appRoutes: ModuleWithProviders = RouterModule.forRoot(ROUTES);
|
|
|
|
|