mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-02-03 13:22:05 +02:00
implementing galleryRoute
This commit is contained in:
parent
8f5fcff2dc
commit
b0f4d878ff
39
backend/middlewares/GalleryMWs.ts
Normal file
39
backend/middlewares/GalleryMWs.ts
Normal file
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
31
backend/model/GalleryManager.ts
Normal file
31
backend/model/GalleryManager.ts
Normal file
@ -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<User>) => 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");
|
||||
}
|
||||
|
||||
}
|
@ -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)
|
||||
|
@ -1,6 +1,7 @@
|
||||
///<reference path="../../typings/main.d.ts"/>
|
||||
|
||||
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
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -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 => <Message<any>> res.json())
|
||||
.catch(NetworkService.handleError);
|
||||
|
Loading…
x
Reference in New Issue
Block a user