diff --git a/backend/middlewares/GalleryMWs.ts b/backend/middlewares/GalleryMWs.ts new file mode 100644 index 00000000..22596461 --- /dev/null +++ b/backend/middlewares/GalleryMWs.ts @@ -0,0 +1,39 @@ + +import {UserManager} from "../model/UserManager"; +import {NextFunction, Request, Response} from "express"; +import {BaseMWs} from "./BaseMWs"; +import {Error, ErrorCodes} from "../../common/entities/Error"; +import Util = jasmine.Util; + +export class GalleryMWs extends BaseMWs{ + + + public static listDirectory(req:Request, res:Response, next:NextFunction){ + //TODO: implement + return super.renderError(res,new Error(ErrorCodes.GENERAL_ERROR)); + } + + + public static renderImage(req:Request, res:Response, next:NextFunction){ + //TODO: implement + return super.renderError(res,new Error(ErrorCodes.GENERAL_ERROR)); + } + + public static renderThumbnail(req:Request, res:Response, next:NextFunction){ + //TODO: implement + return super.renderError(res,new Error(ErrorCodes.GENERAL_ERROR)); + } + + public static search(req:Request, res:Response, next:NextFunction){ + //TODO: implement + return super.renderError(res,new Error(ErrorCodes.GENERAL_ERROR)); + } + + public static autocomplete(req:Request, res:Response, next:NextFunction){ + //TODO: implement + return super.renderError(res,new Error(ErrorCodes.GENERAL_ERROR)); + } + + + +} \ No newline at end of file diff --git a/backend/model/GalleryManager.ts b/backend/model/GalleryManager.ts new file mode 100644 index 00000000..0ef077bd --- /dev/null +++ b/backend/model/GalleryManager.ts @@ -0,0 +1,31 @@ +import {User} from "../../common/entities/User"; +export class UserManager { + + private static users = [new User(1,"TestUser","test@test.hu","122345")]; + + public static findOne(filter,cb:(error: any,result:User) => void){ + return cb(null, UserManager.users[0]); + } + + public static find(filter,cb:(error: any,result:Array) => void){ + return cb(null, UserManager.users); + } + + public static createUser(user,cb:(error: any,result:User) => void){ + UserManager.users.push(user); + return cb(null, user); + } + + public static deleteUser(id:number,cb:(error: any,result:string) => void){ + UserManager.users = UserManager.users.filter(u => u.id != id); + return cb(null, "ok"); + } + + public static changeRole(request:any,cb:(error: any,result:string) => void){ + return cb(null,"ok"); + } + public static changePassword(request:any,cb:(error: any,result:string) => void){ + return cb(null,"ok"); + } + +} \ No newline at end of file diff --git a/backend/routes/AdminRouter.ts b/backend/routes/AdminRouter.ts index 7c20135f..64b812bd 100644 --- a/backend/routes/AdminRouter.ts +++ b/backend/routes/AdminRouter.ts @@ -7,7 +7,7 @@ export class AdminRouter{ constructor(private app) { this.addResetDB(); - this.addIndexGalery(); + this.addIndexGallery(); } private addResetDB() { @@ -18,7 +18,7 @@ export class AdminRouter{ ); }; - private addIndexGalery() { + private addIndexGallery() { this.app.post("/api/admin/gallery/index", AuthenticationMWs.authenticate, AuthenticationMWs.authorise(UserRoles.Admin) diff --git a/backend/routes/GalleryRouter.ts b/backend/routes/GalleryRouter.ts index bd0310d6..264926a9 100644 --- a/backend/routes/GalleryRouter.ts +++ b/backend/routes/GalleryRouter.ts @@ -1,6 +1,7 @@ /// import {AuthenticationMWs} from "../middlewares/AuthenticationMWs"; +import {GalleryMWs} from "../middlewares/GalleryMWs"; export class GalleryRouter{ constructor(private app){ @@ -15,37 +16,37 @@ export class GalleryRouter{ private addDirectoryList() { this.app.get("/api/gallery/:directory", - AuthenticationMWs.authenticate - //TODO: implement + AuthenticationMWs.authenticate, + GalleryMWs.listDirectory ); }; private addGetImage() { this.app.get("/api/gallery/:directory/:image", - AuthenticationMWs.authenticate - //TODO: implement + AuthenticationMWs.authenticate, + GalleryMWs.renderImage ); }; private addGetImageThumbnail() { this.app.get("/api/gallery/:directory/:image/thumbnail", - AuthenticationMWs.authenticate - //TODO: implement + AuthenticationMWs.authenticate, + GalleryMWs.renderThumbnail ); }; private addSearch() { this.app.get("/api/gallery/search", - AuthenticationMWs.authenticate - //TODO: implement + AuthenticationMWs.authenticate, + GalleryMWs.search ); }; private addAutoComplete() { this.app.get("/api/gallery/autocomplete", - AuthenticationMWs.authenticate - //TODO: implement + AuthenticationMWs.authenticate, + GalleryMWs.autocomplete ); }; diff --git a/frontend/app/model/network.service.ts b/frontend/app/model/network.service.ts index acd29bcf..f05300d2 100644 --- a/frontend/app/model/network.service.ts +++ b/frontend/app/model/network.service.ts @@ -16,7 +16,7 @@ export class NetworkService{ let headers = new Headers({ 'Content-Type': 'application/json' }); let options = new RequestOptions({ headers: headers }); console.log(this._http.post(this._baseUrl+url, body, options)); - return this._http['method'](this._baseUrl+url, body, options) + return this._http[method](this._baseUrl+url, body, options) .toPromise() .then(res => > res.json()) .catch(NetworkService.handleError);