/** @file
 * @author Edouard DUPIN
 * @copyright 2018, Edouard DUPIN, all right reserved
 * @license PROPRIETARY (see license file)
 */

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router'; // CLI imports router

import { HelpScene, HomeScene, SeasonEditScene, SeasonScene, SeriesEditScene, SeriesScene, SettingsScene, TypeScene, VideoEditScene, VideoScene } from './scene';
import { UploadScene } from './scene/upload/upload';
import { ForbiddenScene, OnlyUsersGuardHome, HomeOutScene, OnlyUnregisteredGuardHome, SsoScene, OnlyAdminGuard, OnlyUsersGuard, NotFound404Scene } from '@kangaroo-and-rabbit/kar-cw';
// import { HelpComponent } from './help/help.component';

// see https://angular.io/guide/router


const routes: Routes = [
	{ path: '', redirectTo: '/home', pathMatch: 'full' },

	{ path: 'forbidden', component: ForbiddenScene },

	// ------------------------------------
	// -- home global interface
	// ------------------------------------
	{
		path: 'home',
		component: HomeScene,
		canActivate: [OnlyUsersGuardHome], // this route to unregistered path when not logged ==> permit to simplify display
	},
	{
		path: 'unregistered',
		component: HomeOutScene,
		canActivate: [OnlyUnregisteredGuardHome], // jump to the home when registered
	},
	// ------------------------------------
	// -- SSO Generic interface
	// ------------------------------------
	{ path: 'sso/:data/:keepConnected/:token', component: SsoScene },
	{ path: 'sso/:keepConnected/:token', component: SsoScene },
	{ path: 'sso', component: SsoScene },

	// ------------------------------------
	// -- Generic pages
	// ------------------------------------
	{ path: 'help/:page', component: HelpScene },
	{ path: 'help', component: HelpScene },

	// ------------------------------------
	// -- upload new data:
	// ------------------------------------
	{
		path: 'upload',
		component: UploadScene,
		canActivate: [OnlyAdminGuard],
	},
	{
		path: 'type/:typeId/:seriesId/:seasonId/:videoId',
		component: TypeScene,
		canActivate: [OnlyUsersGuard],
	},

	{
		path: 'series/:typeId/:seriesId/:seasonId/:videoId',
		component: SeriesScene,
		canActivate: [OnlyUsersGuard],
	},
	{
		path: 'series-edit/:typeId/:seriesId/:seasonId/:videoId',
		component: SeriesEditScene,
		canActivate: [OnlyAdminGuard],
	},

	{
		path: 'season/:typeId/:seriesId/:seasonId/:videoId',
		component: SeasonScene,
		canActivate: [OnlyUsersGuard],
	},
	{
		path: 'season-edit/:typeId/:seriesId/:seasonId/:videoId',
		component: SeasonEditScene,
		canActivate: [OnlyAdminGuard],
	},

	{
		path: 'video/:typeId/:seriesId/:seasonId/:videoId',
		component: VideoScene,
		canActivate: [OnlyUsersGuard],
	},
	{
		path: 'video-edit/:typeId/:seriesId/:seasonId/:videoId',
		component: VideoEditScene,
		canActivate: [OnlyAdminGuard],
	},
	{
		path: 'settings',
		component: SettingsScene,
		canActivate: [OnlyUsersGuard],
	},
	{
		path: '**',
		component: NotFound404Scene,
	},
];

@NgModule({
	imports: [
		RouterModule.forRoot(
			routes,
			{
				//enableTracing: true, // <-- debugging purposes only
			},
		),
	],
	exports: [
		RouterModule,
	]
})
export class AppRoutingModule { }
// export const routing: ModuleWithProviders = RouterModule.forRoot(routes);

