diff --git a/backend/middlewares/AuthenticationMWs.ts b/backend/middlewares/AuthenticationMWs.ts
index 326c0b3c..656bfb41 100644
--- a/backend/middlewares/AuthenticationMWs.ts
+++ b/backend/middlewares/AuthenticationMWs.ts
@@ -10,10 +10,10 @@ import {UserRoles} from "../../common/entities/User";
export class AuthenticationMWs {
- public static authenticate(req:Request, res:Response, next:NextFunction){
- if (typeof req.session.user === 'undefined') {
+ public static authenticate(req:Request, res:Response, next:NextFunction){
+ /* if (typeof req.session.user === 'undefined') {
return next(new Error(ErrorCodes.NOT_AUTHENTICATED));
- }
+ }*/
return next();
}
diff --git a/backend/middlewares/GalleryMWs.ts b/backend/middlewares/GalleryMWs.ts
index e568e216..2e8f357d 100644
--- a/backend/middlewares/GalleryMWs.ts
+++ b/backend/middlewares/GalleryMWs.ts
@@ -9,7 +9,9 @@ import {Directory} from "../../common/entities/Directory";
export class GalleryMWs {
- public static listDirectory(req:Request, res:Response, next:NextFunction){
+ public static listDirectory(req:Request, res:Response, next:NextFunction){
+ console.log("listDirectory");
+ console.log(req.params);
let directoryName = "/";
if(req.params.directory){
directoryName = req.params.directory;
@@ -30,16 +32,14 @@ export class GalleryMWs {
}
- public static loadImage(req:Request, res:Response, next:NextFunction){
- let directoryName = "/";
- if(req.params.directory){
- directoryName = req.params.directory;
- }
- if(!(req.params.image)){
+ public static loadImage(req:Request, res:Response, next:NextFunction){
+ console.log("loadImage");
+ console.log(req.params);
+ if(!(req.params.imagePath)){
return next();
}
- let fullImagePath = path.join(__dirname,"/../../demo/images", directoryName,req.params.image);
+ let fullImagePath = path.join(__dirname,"/../../demo/images", req.params.imagePath);
if(fs.statSync(fullImagePath).isDirectory()){
return next();
}
diff --git a/backend/routes/GalleryRouter.ts b/backend/routes/GalleryRouter.ts
index 096f6d85..e4e5ca08 100644
--- a/backend/routes/GalleryRouter.ts
+++ b/backend/routes/GalleryRouter.ts
@@ -7,16 +7,16 @@ import {RenderingMWs} from "../middlewares/RenderingMWs";
export class GalleryRouter{
constructor(private app){
- this.addDirectoryList();
this.addGetImageThumbnail();
this.addGetImage();
+ this.addDirectoryList();
this.addSearch();
this.addAutoComplete();
}
private addDirectoryList() {
- this.app.get(["/api/gallery/:directory","/api/gallery/","/api/gallery//"],
+ this.app.get(["/api/gallery/:directory(*)","/api/gallery/","/api/gallery//"],
AuthenticationMWs.authenticate,
GalleryMWs.listDirectory,
RenderingMWs.renderResult
@@ -25,7 +25,7 @@ export class GalleryRouter{
private addGetImage() {
- this.app.get(["/api/gallery/:directory/:image","/api/gallery/:image"],
+ this.app.get(["/api/gallery/:imagePath(*\.(jpg|bmp|png|gif|jpeg))"],
AuthenticationMWs.authenticate,
GalleryMWs.loadImage,
RenderingMWs.renderFile
diff --git a/backend/routes/PublicRouter.ts b/backend/routes/PublicRouter.ts
index cb53a1a4..d01625c4 100644
--- a/backend/routes/PublicRouter.ts
+++ b/backend/routes/PublicRouter.ts
@@ -12,7 +12,7 @@ export class PublicRouter{
var renderIndex = (req: _express.Request, res: _express.Response) => {
res.sendFile(_path.resolve(__dirname, './../../frontend/index.html'));
};
- this.app.get(['/login',"/gallery"], renderIndex);
+ this.app.get(['/login',"/gallery*"], renderIndex);
}
diff --git a/backend/server.ts b/backend/server.ts
index b2932631..cf3afb8c 100644
--- a/backend/server.ts
+++ b/backend/server.ts
@@ -51,7 +51,20 @@ export class Server {
*/
// for parsing application/json
this.app.use(_bodyParser.json());
-
+
+ this.app.use("/testDir/:img(*\.(jpg|bmp))",(req,res,next)=>{
+ console.log(req.params);
+ res.send(req.params);
+ });
+ this.app.use("/testDir/:dir(*)",(req,res,next)=>{
+ console.log(req.params);
+ res.send(req.params);
+ });
+
+ this.app.use("/testDir/*",(req,res,next)=>{
+ console.log(req.params);
+ res.send(req.params);
+ });
new PublicRouter(this.app);
diff --git a/frontend/app/app.component.ts b/frontend/app/app.component.ts
index 2eb6d4ca..94337045 100644
--- a/frontend/app/app.component.ts
+++ b/frontend/app/app.component.ts
@@ -11,6 +11,7 @@ import {Router, Location} from "angular2/router";
import {HTTP_PROVIDERS} from "angular2/http";
import {UserService} from "./model/user.service";
import {GalleryService} from "./gallery/gallery.service";
+import {GeneratedUrl} from "angular2/src/router/rules/route_paths/route_path";
@@ -32,10 +33,13 @@ import {GalleryService} from "./gallery/gallery.service";
name: 'Login',
component: LoginComponent,
useAsDefault: true
- },
+ },
{
- path: '/gallery/:directory',
+ regex: '/gallery(/([\S]*))?',
name: 'Gallery',
+ serializer: (params): GeneratedUrl => {
+ return new GeneratedUrl(`/gallery/${params['directory']}`, {})
+ },
component: GalleryComponent
}
])
diff --git a/frontend/app/gallery/directory/directory.gallery.component.html b/frontend/app/gallery/directory/directory.gallery.component.html
index afc5310b..69fa3efa 100644
--- a/frontend/app/gallery/directory/directory.gallery.component.html
+++ b/frontend/app/gallery/directory/directory.gallery.component.html
@@ -1 +1 @@
-{{directory.name}}
\ No newline at end of file
+{{directory.name}}
\ No newline at end of file
diff --git a/frontend/app/gallery/directory/directory.gallery.component.ts b/frontend/app/gallery/directory/directory.gallery.component.ts
index a24220af..6e2e0a34 100644
--- a/frontend/app/gallery/directory/directory.gallery.component.ts
+++ b/frontend/app/gallery/directory/directory.gallery.component.ts
@@ -3,6 +3,7 @@
import {Component, Input, OnInit} from 'angular2/core';
import {Directory} from "../../../../common/entities/Directory";
import {RouterLink} from "angular2/router";
+import {Utils} from "../../../../common/Utils";
@Component({
selector: 'gallery-directory',
@@ -15,6 +16,10 @@ export class GalleryDirectoryComponent{
constructor() {
}
+ getDirectoryPath(){
+ return Utils.concatUrls(this.directory.path,this.directory.name);
+ }
+
}
diff --git a/frontend/app/gallery/gallery.component.ts b/frontend/app/gallery/gallery.component.ts
index 213c3606..df71a461 100644
--- a/frontend/app/gallery/gallery.component.ts
+++ b/frontend/app/gallery/gallery.component.ts
@@ -33,6 +33,7 @@ export class GalleryComponent implements OnInit{
this._router.navigate(['Login']);
return;
}
+ console.log(this._params.get('directory'));
let directoryName = this._params.get('directory');
directoryName = directoryName ? directoryName : "";
this._galleryService.getDirectory(directoryName).then(( message:Message) => {
diff --git a/frontend/app/gallery/photo/photo.gallery.component.ts b/frontend/app/gallery/photo/photo.gallery.component.ts
index 7bbe1b8c..64625387 100644
--- a/frontend/app/gallery/photo/photo.gallery.component.ts
+++ b/frontend/app/gallery/photo/photo.gallery.component.ts
@@ -1,6 +1,6 @@
///
-import {Component, Input, OnInit} from 'angular2/core';
+import {Component, Input} from 'angular2/core';
import {Photo} from "../../../../common/entities/Photo";
import {Directory} from "../../../../common/entities/Directory";
import {Utils} from "../../../../common/Utils";
@@ -17,7 +17,6 @@ export class GalleryPhotoComponent{
}
getPhotoPath(){
- console.log(Utils.concatUrls("/api/gallery",this.directory.path,this.directory.name,this.photo.name));
return Utils.concatUrls("/api/gallery",this.directory.path,this.directory.name,this.photo.name);
}