diff --git a/backend/config/ConfigLoader.ts b/backend/config/ConfigLoader.ts index 30287b74..a7823424 100644 --- a/backend/config/ConfigLoader.ts +++ b/backend/config/ConfigLoader.ts @@ -25,7 +25,6 @@ export class ConfigLoader { let argv = optimist.argv; delete(argv._); delete(argv.$0); - console.log(argv); this.processHierarchyVar(configObject, argv); }; diff --git a/backend/middlewares/user/UserMWs.ts b/backend/middlewares/user/UserMWs.ts index 7e7a2568..0047351a 100644 --- a/backend/middlewares/user/UserMWs.ts +++ b/backend/middlewares/user/UserMWs.ts @@ -3,6 +3,7 @@ import {Error, ErrorCodes} from "../../../common/entities/Error"; import {ObjectManagerRepository} from "../../model/ObjectManagerRepository"; import {User} from "../../../common/entities/User"; import {Config} from "../../config/Config"; +import {Utils} from "../../../common/Utils"; export class UserMWs { @@ -91,6 +92,7 @@ export class UserMWs { if ((err) || (!result)) { return next(new Error(ErrorCodes.GENERAL_ERROR)); } + result = Utils.clone(result); for (let i = 0; i < result.length; i++) { result[i].password = ""; } diff --git a/frontend/app/admin/admin.component.html b/frontend/app/admin/admin.component.html index d2e69ba6..2e4ee117 100644 --- a/frontend/app/admin/admin.component.html +++ b/frontend/app/admin/admin.component.html @@ -1,77 +1,5 @@ - - - User management - - - - - - - Name - Role - - - - - {{user.name}} - - - - {{repository.value}} - - - - - {{user.role | stringifyRole}} - - - - - - - - - - + Add - user - - - - - - - - - - - × - Modal title - - - - - - - {{repository.value}} - - - - - - - + diff --git a/frontend/app/admin/admin.component.ts b/frontend/app/admin/admin.component.ts index 07a98f2d..8612b937 100644 --- a/frontend/app/admin/admin.component.ts +++ b/frontend/app/admin/admin.component.ts @@ -4,31 +4,23 @@ import {Component, OnInit} from "@angular/core"; import {AuthenticationService} from "../model/network/authentication.service.ts"; import {Router} from "@angular/router-deprecated"; import {FrameComponent} from "../frame/frame.component"; -import {User, UserRoles} from "../../../common/entities/User"; +import {UserRoles} from "../../../common/entities/User"; import {FORM_DIRECTIVES} from "@angular/common"; -import {Utils} from "../../../common/Utils"; -import {AdminService} from "./admin.service"; -import {Message} from "../../../common/entities/Message"; import {StringifyRole} from "./../pipes/StringifyRolePipe"; import {Config} from "../config/Config"; +import {UserMangerSettingsComponent} from "../settings/usermanager/usermanager.settings.component"; @Component({ selector: 'admin', templateUrl: 'app/admin/admin.component.html', styleUrls: ['app/admin/admin.component.css'], - directives: [FrameComponent, FORM_DIRECTIVES], - providers: [AdminService], + directives: [FrameComponent, FORM_DIRECTIVES, UserMangerSettingsComponent], pipes: [StringifyRole] }) export class AdminComponent implements OnInit { - - private newUser = new User(); - private userRoles:Array = []; - private users:Array = []; userManagementEnable:boolean = false; - constructor(private _authService:AuthenticationService, private _router:Router, private _adminService:AdminService) { - + constructor(private _authService:AuthenticationService, private _router:Router) { this.userManagementEnable = Config.Client.authenticationRequired; } @@ -37,50 +29,8 @@ export class AdminComponent implements OnInit { this._router.navigate(['Login']); return; } - if (Config.Client.authenticationRequired === true) { - this.userRoles = Utils.enumToArray(UserRoles).filter(r => r.key <= this._authService.getUser().role); - this.getUsersList(); - } } - private getUsersList() { - this._adminService.getUsers().then((result:Message>) => { - this.users = result.result; - }); - } - - - canModifyUser(user:User):boolean { - let currentUser = this._authService.getUser(); - if (!currentUser) { - return false; - } - - return currentUser.name != user.name && currentUser.role >= user.role; - } - - initNewUser() { - this.newUser = new User(); - this.newUser.role = UserRoles.User; - } - - addNewUser() { - this._adminService.createUser(this.newUser).then(() => { - this.getUsersList(); - }); - } - - updateRole(user:User) { - this._adminService.updateRole(user).then(() => { - this.getUsersList(); - }); - } - - deleteUser(user:User) { - this._adminService.deleteUser(user).then(() => { - this.getUsersList(); - }); - } } diff --git a/frontend/app/gallery/grid/grid.gallery.component.ts b/frontend/app/gallery/grid/grid.gallery.component.ts index 553386ca..7eef5bc6 100644 --- a/frontend/app/gallery/grid/grid.gallery.component.ts +++ b/frontend/app/gallery/grid/grid.gallery.component.ts @@ -49,6 +49,7 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit { if (this.isAfterViewInit === false) { return; } + this.updateContainerWidth(); this.sortPhotos(); this.mergeNewPhotos(); setImmediate(() => { diff --git a/frontend/app/gallery/grid/photo/photo.grid.gallery.component.ts b/frontend/app/gallery/grid/photo/photo.grid.gallery.component.ts index a843a494..4ea62386 100644 --- a/frontend/app/gallery/grid/photo/photo.grid.gallery.component.ts +++ b/frontend/app/gallery/grid/photo/photo.grid.gallery.component.ts @@ -57,21 +57,16 @@ export class GalleryPhotoComponent implements IRenderable, OnInit, AfterViewInit } ngOnInit() { + this.loading.show = true; //set up befoar adding task to thumbnail generator if (this.gridPhoto.isThumbnailAvailable()) { this.image.src = this.gridPhoto.getThumbnailPath(); this.image.show = true; - // this.loading.show = false; - - } else { - if (this.gridPhoto.isReplacementThumbnailAvailable()) { - this.image.src = this.gridPhoto.getReplacementThumbnailPath(); - this.image.show = true; - this.loading.show = false; - } else { - this.loading.show = true; - } + } else if (this.gridPhoto.isReplacementThumbnailAvailable()) { + this.image.src = this.gridPhoto.getReplacementThumbnailPath(); + this.image.show = true; } + } ngAfterViewInit() { diff --git a/frontend/app/login/login.component.html b/frontend/app/login/login.component.html index ba7fddcb..4ce1e4f8 100644 --- a/frontend/app/login/login.component.html +++ b/frontend/app/login/login.component.html @@ -2,6 +2,9 @@ Please sign in + + {{loginError}} + ) => { + if (message.error) { + if (message.error.code === ErrorCodes.CREDENTIAL_NOT_FOUND) { + this.loginError = "Wrong username or password"; + } + } + }); } } diff --git a/frontend/app/model/network/authentication.service.ts b/frontend/app/model/network/authentication.service.ts index 95377875..7caf1e71 100644 --- a/frontend/app/model/network/authentication.service.ts +++ b/frontend/app/model/network/authentication.service.ts @@ -26,7 +26,6 @@ export class AuthenticationService { //picking up session.. if (this.isAuthenticated() == false && Cookie.get('pigallery2-session') != null) { if (typeof ServerInject !== "undefined" && typeof ServerInject.user !== "undefined") { - console.log("user found"); this.setUser(ServerInject.user); } this.getSessionUser(); @@ -51,12 +50,13 @@ export class AuthenticationService { } public login(credential:LoginCredential) { - this._userService.login(credential).then((message:Message) => { + return this._userService.login(credential).then((message:Message) => { if (message.error) { console.log(ErrorCodes[message.error.code] + ", message: " + message.error.message); } else { this.setUser(message.result); } + return message; }); } diff --git a/frontend/app/notification.service.ts b/frontend/app/notification.service.ts new file mode 100644 index 00000000..0a6dbc24 --- /dev/null +++ b/frontend/app/notification.service.ts @@ -0,0 +1,29 @@ +/// + +import {Injectable} from "@angular/core"; + +@Injectable() +export class NotificationService { + + + constructor() { + + } + + public showException(message:string) { + + } + + public showError(message:string) { + + } + + public showWarn(message:string) { + + } + + public showInfo(message:string) { + + } + +} diff --git a/frontend/app/settings/usermanager/usermanager.settings.component.css b/frontend/app/settings/usermanager/usermanager.settings.component.css new file mode 100644 index 00000000..e69de29b diff --git a/frontend/app/settings/usermanager/usermanager.settings.component.html b/frontend/app/settings/usermanager/usermanager.settings.component.html new file mode 100644 index 00000000..39fc4b77 --- /dev/null +++ b/frontend/app/settings/usermanager/usermanager.settings.component.html @@ -0,0 +1,73 @@ + + + User management + + + + + + + Name + Role + + + + + {{user.name}} + + + + {{repository.value}} + + + + + {{user.role | stringifyRole}} + + + + + + + + + + + Add + user + + + + + + + + + + × + Modal title + + + + + + + {{repository.value}} + + + + + + + + diff --git a/frontend/app/settings/usermanager/usermanager.settings.component.ts b/frontend/app/settings/usermanager/usermanager.settings.component.ts new file mode 100644 index 00000000..6b4b7da6 --- /dev/null +++ b/frontend/app/settings/usermanager/usermanager.settings.component.ts @@ -0,0 +1,81 @@ +/// + +import {Component, OnInit} from "@angular/core"; +import {AuthenticationService} from "../../model/network/authentication.service.ts"; +import {Router} from "@angular/router-deprecated"; +import {FrameComponent} from "../../frame/frame.component"; +import {User, UserRoles} from "../../../../common/entities/User"; +import {FORM_DIRECTIVES} from "@angular/common"; +import {Utils} from "../../../../common/Utils"; +import {Message} from "../../../../common/entities/Message"; +import {StringifyRole} from "./../../pipes/StringifyRolePipe"; +import {UserManagerSettingsService} from "./usermanager.settings.service"; + +@Component({ + selector: 'settings-usermanager', + templateUrl: 'app/settings/usermanager/usermanager.settings.component.html', + styleUrls: ['app/settings/usermanager/usermanager.settings.component.css'], + directives: [FrameComponent, FORM_DIRECTIVES], + providers: [UserManagerSettingsService], + pipes: [StringifyRole] +}) +export class UserMangerSettingsComponent implements OnInit { + + private newUser = new User(); + private userRoles:Array = []; + private users:Array = []; + + constructor(private _authService:AuthenticationService, private _router:Router, private _userSettings:UserManagerSettingsService) { + } + + ngOnInit() { + if (!this._authService.isAuthenticated() || this._authService.getUser().role < UserRoles.Admin) { + this._router.navigate(['Login']); + return; + } + this.userRoles = Utils.enumToArray(UserRoles).filter(r => r.key <= this._authService.getUser().role); + this.getUsersList(); + } + + private getUsersList() { + this._userSettings.getUsers().then((result:Message>) => { + this.users = result.result; + }); + } + + + canModifyUser(user:User):boolean { + let currentUser = this._authService.getUser(); + if (!currentUser) { + return false; + } + + return currentUser.name != user.name && currentUser.role >= user.role; + } + + initNewUser() { + this.newUser = new User(); + this.newUser.role = UserRoles.User; + } + + addNewUser() { + this._userSettings.createUser(this.newUser).then(() => { + this.getUsersList(); + }); + } + + updateRole(user:User) { + this._userSettings.updateRole(user).then(() => { + this.getUsersList(); + }); + } + + deleteUser(user:User) { + this._userSettings.deleteUser(user).then(() => { + this.getUsersList(); + }); + } +} + + + diff --git a/frontend/app/admin/admin.service.spec.ts b/frontend/app/settings/usermanager/usermanager.settings.service.spec.ts similarity index 79% rename from frontend/app/admin/admin.service.spec.ts rename to frontend/app/settings/usermanager/usermanager.settings.service.spec.ts index b1f7e34e..13fe0d26 100644 --- a/frontend/app/admin/admin.service.spec.ts +++ b/frontend/app/settings/usermanager/usermanager.settings.service.spec.ts @@ -3,8 +3,8 @@ import {BaseRequestOptions, Http} from "@angular/http"; import {MockBackend} from "@angular/http/testing"; import {provide} from "@angular/core"; import "rxjs/Rx"; -import {NetworkService} from "../model/network/network.service"; -import {AdminService} from "./admin.service"; +import {NetworkService} from "../../model/network/network.service"; +import {UserManagerSettingsService} from "./usermanager.settings.service"; describe('AdminService', () => { @@ -19,7 +19,7 @@ describe('AdminService', () => { }, deps: [MockBackend, BaseRequestOptions] }), NetworkService, - AdminService + UserManagerSettingsService ]); diff --git a/frontend/app/admin/admin.service.ts b/frontend/app/settings/usermanager/usermanager.settings.service.ts similarity index 70% rename from frontend/app/admin/admin.service.ts rename to frontend/app/settings/usermanager/usermanager.settings.service.ts index 5a4af839..be7332e7 100644 --- a/frontend/app/admin/admin.service.ts +++ b/frontend/app/settings/usermanager/usermanager.settings.service.ts @@ -1,12 +1,12 @@ -/// +/// import {Injectable} from "@angular/core"; -import {NetworkService} from "../model/network/network.service.ts"; -import {Message} from "../../../common/entities/Message"; -import {User} from "../../../common/entities/User"; +import {User} from "../../../../common/entities/User"; +import {NetworkService} from "../../model/network/network.service"; +import {Message} from "../../../../common/entities/Message"; @Injectable() -export class AdminService { +export class UserManagerSettingsService { constructor(private _networkService:NetworkService) {