diff --git a/backend/routes/PublicRouter.ts b/backend/routes/PublicRouter.ts index 59a1c274..c748a952 100644 --- a/backend/routes/PublicRouter.ts +++ b/backend/routes/PublicRouter.ts @@ -31,7 +31,7 @@ export class PublicRouter{ res.render(_path.resolve(__dirname, './../../frontend/index.ejs'),res.tpl); }; - this.app.get(['/','/login',"/gallery*"], renderIndex); + this.app.get(['/','/login',"/gallery*","/admin"], renderIndex); } diff --git a/frontend/app/admin/admin.component.css b/frontend/app/admin/admin.component.css new file mode 100644 index 00000000..cdadcf81 --- /dev/null +++ b/frontend/app/admin/admin.component.css @@ -0,0 +1,5 @@ +#login-card { +} +body { + background: #eee; +} \ No newline at end of file diff --git a/frontend/app/admin/admin.component.html b/frontend/app/admin/admin.component.html new file mode 100644 index 00000000..a355eb82 --- /dev/null +++ b/frontend/app/admin/admin.component.html @@ -0,0 +1,9 @@ + + + User management + + + + + + diff --git a/frontend/app/admin/admin.component.ts b/frontend/app/admin/admin.component.ts new file mode 100644 index 00000000..43758b16 --- /dev/null +++ b/frontend/app/admin/admin.component.ts @@ -0,0 +1,33 @@ +/// + +import {Component, OnInit} from 'angular2/core'; +import {LoginCredential} from '../../../common/entities/LoginCredential'; +import {AuthenticationService} from "../model/authentication.service"; +import {Router} from "angular2/router"; +import {MATERIAL_DIRECTIVES} from "ng2-material/all"; +import {FORM_DIRECTIVES} from "angular2/common"; +import {MATERIAL_BROWSER_PROVIDERS} from "ng2-material/all"; +import {ViewportHelper} from "ng2-material/all"; +import {FrameComponent} from "../frame/frame.component"; + +@Component({ + selector: 'admin', + templateUrl: 'app/admin/admin.component.html', + styleUrls:['app/admin/admin.component.css'], + directives:[MATERIAL_DIRECTIVES, FrameComponent], + providers:[MATERIAL_BROWSER_PROVIDERS] +}) +export class AdminComponent implements OnInit{ + constructor(private _authService: AuthenticationService, private _router: Router) { + } + + ngOnInit(){ + if (!this._authService.isAuthenticated()) { + this._router.navigate(['Login']); + return; + } + } + + +} + diff --git a/frontend/app/admin/admin.service.ts b/frontend/app/admin/admin.service.ts new file mode 100644 index 00000000..82f66f6b --- /dev/null +++ b/frontend/app/admin/admin.service.ts @@ -0,0 +1,25 @@ +/// + +import {Injectable} from 'angular2/core'; +import {NetworkService} from "../model/network.service"; +import {Http} from "angular2/http"; +import {Message} from "../../../common/entities/Message"; +import {Directory} from "../../../common/entities/Directory"; + +@Injectable() +export class GalleryService extends NetworkService{ + + + constructor(_http:Http){ + super(_http); + } + + public getDirectory(directoryName:string): Promise>{ + return this.getJson("/gallery/"+directoryName); + } + + + + + +} diff --git a/frontend/app/app.component.ts b/frontend/app/app.component.ts index 4d352d29..a18a06ac 100644 --- a/frontend/app/app.component.ts +++ b/frontend/app/app.component.ts @@ -12,7 +12,8 @@ import {HTTP_PROVIDERS} from "angular2/http"; import {UserService} from "./model/user.service"; import {GalleryService} from "./gallery/gallery.service"; import {MATERIAL_BROWSER_PROVIDERS} from "ng2-material/all"; -import {ViewportHelper} from "ng2-material/core/util/viewport"; +import {ViewportHelper} from "ng2-material/core/util/viewport"; +import {AdminComponent} from "./admin/admin.component"; @Component({ @@ -39,6 +40,11 @@ import {ViewportHelper} from "ng2-material/core/util/viewport"; component: LoginComponent, useAsDefault: true }, + { + path: '/admin', + name: 'Admin', + component: AdminComponent + }, { path: '/gallery', redirectTo: ["Gallery",{directory:""}] diff --git a/frontend/app/frame/frame.component.html b/frontend/app/frame/frame.component.html new file mode 100644 index 00000000..9115a22f --- /dev/null +++ b/frontend/app/frame/frame.component.html @@ -0,0 +1,35 @@ + + + + +

PiGallery2

+
+ + + + +
+ + +
+ +
+ +

+ PiGallery2 +

+ +
+
+ + +
+
+ +
\ No newline at end of file diff --git a/frontend/app/frame/frame.component.ts b/frontend/app/frame/frame.component.ts new file mode 100644 index 00000000..c5158806 --- /dev/null +++ b/frontend/app/frame/frame.component.ts @@ -0,0 +1,25 @@ +/// + +import {Component, ViewEncapsulation} from 'angular2/core'; +import {Router, RouterLink} from "angular2/router"; +import {MATERIAL_DIRECTIVES} from "ng2-material/all"; +import {MATERIAL_BROWSER_PROVIDERS} from "ng2-material/all"; +import {ViewportHelper} from "ng2-material/all"; +import {SidenavService} from "ng2-material/all"; + +@Component({ + selector: 'app-frame', + templateUrl: 'app/frame/frame.component.html', + directives:[RouterLink,MATERIAL_DIRECTIVES], + providers: [SidenavService], + encapsulation: ViewEncapsulation.Emulated +}) +export class FrameComponent { + constructor( private _router: Router, public sidenav: SidenavService) { + } + + public showSideNav(){ + this.sidenav.show("menu"); + } +} + diff --git a/frontend/app/gallery/gallery.component.html b/frontend/app/gallery/gallery.component.html index 45fc9959..3a1e1f45 100644 --- a/frontend/app/gallery/gallery.component.html +++ b/frontend/app/gallery/gallery.component.html @@ -1,38 +1,9 @@ - - - - -

PiGallery2

-
- - - -
- - -
- -
- -

- PiGallery2 -

- -
-
- - -
- -
- - -
+ + +
+
-
+ - \ No newline at end of file + +
\ No newline at end of file diff --git a/frontend/app/gallery/gallery.component.ts b/frontend/app/gallery/gallery.component.ts index 3d887c3b..b835bd59 100644 --- a/frontend/app/gallery/gallery.component.ts +++ b/frontend/app/gallery/gallery.component.ts @@ -10,6 +10,7 @@ import {GalleryDirectoryComponent} from "./directory/directory.gallery.component import {GalleryGridComponent} from "./grid/grid.gallery.component"; import {MATERIAL_DIRECTIVES} from "ng2-material/all"; import {SidenavService} from "ng2-material/all"; +import {FrameComponent} from "../frame/frame.component"; @Component({ selector: 'gallery', @@ -17,8 +18,8 @@ import {SidenavService} from "ng2-material/all"; styleUrls: ['app/gallery/gallery.component.css'], directives:[GalleryGridComponent, GalleryDirectoryComponent, - MATERIAL_DIRECTIVES], - providers: [SidenavService] + FrameComponent, + MATERIAL_DIRECTIVES] }) export class GalleryComponent implements OnInit{ @@ -27,8 +28,7 @@ export class GalleryComponent implements OnInit{ constructor(private _galleryService:GalleryService, private _params: RouteParams, private _authService: AuthenticationService, - private _router: Router, - public sidenav: SidenavService) { + private _router: Router) { } ngOnInit(){ @@ -50,9 +50,7 @@ export class GalleryComponent implements OnInit{ this.currentDirectory = message.result; }); } - public showSideNav(){ - this.sidenav.show("menu"); - } + }