2016-03-14 14:20:29 +02:00
|
|
|
///<reference path="../browser.d.ts"/>
|
2016-03-12 19:11:19 +02:00
|
|
|
|
2016-05-09 17:04:56 +02:00
|
|
|
import {Component, OnInit} from "@angular/core";
|
2016-03-12 15:57:22 +02:00
|
|
|
import {LoginComponent} from "./login/login.component";
|
2016-04-30 18:01:54 +02:00
|
|
|
import {AuthenticationService} from "./model/network/authentication.service.ts";
|
2016-05-09 17:04:56 +02:00
|
|
|
import {GalleryComponent} from "./gallery/gallery.component";
|
2016-03-13 12:28:29 +02:00
|
|
|
import {User} from "../../common/entities/User";
|
2016-05-09 17:04:56 +02:00
|
|
|
import {Router, RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS} from "@angular/router-deprecated";
|
2016-05-04 17:20:21 +02:00
|
|
|
import {HTTP_PROVIDERS} from "@angular/http";
|
2016-04-30 18:01:54 +02:00
|
|
|
import {UserService} from "./model/network/user.service.ts";
|
2016-05-09 17:04:56 +02:00
|
|
|
import {GalleryService} from "./gallery/gallery.service";
|
2016-05-04 22:44:26 +02:00
|
|
|
import {AdminComponent} from "./admin/admin.component";
|
2016-05-09 17:04:56 +02:00
|
|
|
import {NetworkService} from "./model/network/network.service";
|
2016-06-17 00:05:31 +02:00
|
|
|
import {ThumbnailLoaderService} from "./gallery/grid/thumnailLoader.service";
|
2016-06-26 11:08:05 +02:00
|
|
|
import {GalleryCacheService} from "./gallery/cache.gallery.service";
|
2016-07-06 12:53:49 +02:00
|
|
|
import {FullScreenService} from "./gallery/fullscreen.service";
|
2016-05-09 17:04:56 +02:00
|
|
|
|
2016-03-12 15:57:22 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'pi-gallery2-app',
|
|
|
|
template: `<router-outlet></router-outlet>`,
|
2016-05-04 17:20:21 +02:00
|
|
|
directives: [ROUTER_DIRECTIVES],
|
2016-03-12 15:57:22 +02:00
|
|
|
providers: [
|
2016-03-19 10:58:27 +02:00
|
|
|
HTTP_PROVIDERS,
|
2016-03-12 23:19:24 +02:00
|
|
|
ROUTER_PROVIDERS,
|
2016-05-04 22:44:26 +02:00
|
|
|
NetworkService,
|
2016-03-19 10:58:27 +02:00
|
|
|
UserService,
|
2016-06-26 11:08:05 +02:00
|
|
|
GalleryCacheService,
|
2016-03-20 17:54:30 +02:00
|
|
|
GalleryService,
|
2016-06-17 00:05:31 +02:00
|
|
|
AuthenticationService,
|
2016-07-06 12:53:49 +02:00
|
|
|
ThumbnailLoaderService,
|
|
|
|
FullScreenService]
|
2016-03-12 15:57:22 +02:00
|
|
|
})
|
|
|
|
@RouteConfig([
|
2016-04-09 18:06:29 +02:00
|
|
|
{
|
|
|
|
path: '/',
|
|
|
|
redirectTo: ["Login"]
|
|
|
|
},
|
2016-03-12 15:57:22 +02:00
|
|
|
{
|
|
|
|
path: '/login',
|
|
|
|
name: 'Login',
|
|
|
|
component: LoginComponent,
|
|
|
|
useAsDefault: true
|
2016-03-27 21:21:47 +02:00
|
|
|
},
|
2016-04-26 15:10:05 +02:00
|
|
|
{
|
|
|
|
path: '/admin',
|
|
|
|
name: 'Admin',
|
|
|
|
component: AdminComponent
|
|
|
|
},
|
2016-03-13 12:28:29 +02:00
|
|
|
{
|
2016-03-27 21:21:47 +02:00
|
|
|
path: '/gallery',
|
2016-05-09 17:04:56 +02:00
|
|
|
redirectTo: ["Gallery", {directory: ""}]
|
|
|
|
},
|
|
|
|
{
|
2016-04-09 18:06:29 +02:00
|
|
|
path: '/gallery/:directory',
|
2016-03-13 12:28:29 +02:00
|
|
|
name: 'Gallery',
|
|
|
|
component: GalleryComponent
|
2016-04-09 18:06:29 +02:00
|
|
|
},
|
2016-05-16 11:03:11 +02:00
|
|
|
{
|
|
|
|
path: '/search/:searchText',
|
|
|
|
name: 'Search',
|
|
|
|
component: GalleryComponent
|
|
|
|
},
|
2016-03-12 15:57:22 +02:00
|
|
|
])
|
2016-05-09 17:04:56 +02:00
|
|
|
export class AppComponent implements OnInit {
|
2016-03-13 12:28:29 +02:00
|
|
|
|
2016-05-09 17:04:56 +02:00
|
|
|
constructor(private _router:Router, private _authenticationService:AuthenticationService) {
|
2016-03-13 12:28:29 +02:00
|
|
|
}
|
2016-03-12 19:11:19 +02:00
|
|
|
|
2016-03-13 12:28:29 +02:00
|
|
|
ngOnInit() {
|
2016-05-16 23:15:03 +02:00
|
|
|
this._authenticationService.OnUserChanged.on((user:User) => {
|
|
|
|
if (user != null) {
|
|
|
|
if (this._router.isRouteActive(this._router.generate(['Login']))) {
|
|
|
|
console.log("routing");
|
|
|
|
this._router.navigate(["Gallery", {directory: ""}]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!this._router.isRouteActive(this._router.generate(['Login']))) {
|
|
|
|
console.log("routing");
|
|
|
|
this._router.navigate(["Login"]);
|
|
|
|
}
|
2016-04-09 18:06:29 +02:00
|
|
|
}
|
2016-05-16 23:15:03 +02:00
|
|
|
|
2016-03-13 12:28:29 +02:00
|
|
|
});
|
2016-05-09 17:04:56 +02:00
|
|
|
|
2016-03-19 10:58:27 +02:00
|
|
|
|
2016-03-12 19:11:19 +02:00
|
|
|
}
|
2016-03-12 15:57:22 +02:00
|
|
|
}
|