diff --git a/src/backend/middlewares/RenderingMWs.ts b/src/backend/middlewares/RenderingMWs.ts index 44b280c4..6d5da82d 100644 --- a/src/backend/middlewares/RenderingMWs.ts +++ b/src/backend/middlewares/RenderingMWs.ts @@ -6,6 +6,7 @@ import {UserDTO, UserRoles} from '../../common/entities/UserDTO'; import {NotificationManager} from '../model/NotifocationManager'; import {Logger} from '../Logger'; import {SharingDTO} from '../../common/entities/SharingDTO'; +import {Utils} from '../../common/Utils'; export class RenderingMWs { @@ -54,8 +55,12 @@ export class RenderingMWs { return next(); } - req.resultPipe.forEach((s: SharingDTO) => delete s.password); - return RenderingMWs.renderMessage(res, req.resultPipe); + const shares: SharingDTO[] = Utils.clone(req.resultPipe); + shares.forEach(s => { + delete s.password; + delete s.creator.password; + }); + return RenderingMWs.renderMessage(res, shares); } public static renderFile(req: Request, res: Response, next: NextFunction) { diff --git a/src/backend/middlewares/SharingMWs.ts b/src/backend/middlewares/SharingMWs.ts index 01c2ece4..9ef50858 100644 --- a/src/backend/middlewares/SharingMWs.ts +++ b/src/backend/middlewares/SharingMWs.ts @@ -125,7 +125,7 @@ export class SharingMWs { return next(); } try { - req.resultPipe = await ObjectManagers.getInstance().SharingManager.find({}); + req.resultPipe = await ObjectManagers.getInstance().SharingManager.listAll(); return next(); } catch (err) { return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, 'Error during listing shares', err)); diff --git a/src/backend/model/database/interfaces/ISharingManager.ts b/src/backend/model/database/interfaces/ISharingManager.ts index b5e38ed1..85823bc6 100644 --- a/src/backend/model/database/interfaces/ISharingManager.ts +++ b/src/backend/model/database/interfaces/ISharingManager.ts @@ -7,7 +7,7 @@ export interface ISharingManager { updateSharing(sharing: SharingDTO, forceUpdate: boolean): Promise; - find(filter: any): Promise; + listAll(): Promise; deleteSharing(sharingKey: string): Promise; } diff --git a/src/backend/model/database/memory/SharingManager.ts b/src/backend/model/database/memory/SharingManager.ts index 96d9bf6b..d0f1c6a1 100644 --- a/src/backend/model/database/memory/SharingManager.ts +++ b/src/backend/model/database/memory/SharingManager.ts @@ -7,7 +7,7 @@ export class SharingManager implements ISharingManager { throw new Error('not implemented'); } - find(filter: any): Promise { + listAll(): Promise { throw new Error('not implemented'); } diff --git a/src/backend/model/database/sql/SharingManager.ts b/src/backend/model/database/sql/SharingManager.ts index e4b7b031..fc9cb144 100644 --- a/src/backend/model/database/sql/SharingManager.ts +++ b/src/backend/model/database/sql/SharingManager.ts @@ -5,7 +5,6 @@ import {SharingEntity} from './enitites/SharingEntity'; import {Config} from '../../../../common/config/private/Config'; import {PasswordHelper} from '../../PasswordHelper'; import {DeleteResult} from 'typeorm'; -import {UserEntity} from './enitites/UserEntity'; export class SharingManager implements ISharingManager { @@ -25,10 +24,12 @@ export class SharingManager implements ISharingManager { await connection.getRepository(SharingEntity).remove(sharing); } - async find(filter: any): Promise { + async listAll(): Promise { await SharingManager.removeExpiredLink(); const connection = await SQLConnection.getConnection(); - return await connection.getRepository(SharingEntity).find(filter); + return await connection.getRepository(SharingEntity) + .createQueryBuilder('share') + .leftJoinAndSelect('share.creator', 'creator').getMany(); } async findOne(filter: any): Promise { diff --git a/src/backend/routes/SharingRouter.ts b/src/backend/routes/SharingRouter.ts index b8e49b61..79965ee8 100644 --- a/src/backend/routes/SharingRouter.ts +++ b/src/backend/routes/SharingRouter.ts @@ -13,6 +13,7 @@ export class SharingRouter { this.addCreateSharing(app); this.addUpdateSharing(app); this.addListSharing(app); + this.addDeleteSharing(app); } private static addShareLogin(app: express.Express) { @@ -55,7 +56,7 @@ export class SharingRouter { app.delete(['/api/share/:sharingKey'], AuthenticationMWs.authenticate, AuthenticationMWs.authorise(UserRoles.Admin), - SharingMWs.updateSharing, + SharingMWs.deleteSharing, RenderingMWs.renderOK ); } diff --git a/src/frontend/app/ui/settings/share/share.settings.component.css b/src/frontend/app/ui/settings/share/share.settings.component.css index a5800fa2..604cf37a 100644 --- a/src/frontend/app/ui/settings/share/share.settings.component.css +++ b/src/frontend/app/ui/settings/share/share.settings.component.css @@ -1,3 +1,7 @@ .panel-info { text-align: center; } + +.share-settings-save-buttons .btn{ + margin-bottom: 10px; +} diff --git a/src/frontend/app/ui/settings/share/share.settings.component.html b/src/frontend/app/ui/settings/share/share.settings.component.html index 548462f1..4c334729 100644 --- a/src/frontend/app/ui/settings/share/share.settings.component.html +++ b/src/frontend/app/ui/settings/share/share.settings.component.html @@ -38,14 +38,53 @@
Sharing is not supported with these settings
- - + + + +
+
+
+

Shared links:

+ + + + + + + + + + + + + + + + + + + +
KeyFolderCreatorExpires
{{share.sharingKey}}{{share.path}}{{share.creator.name}}{{share.expires | date}} + +
+
+ + +
+ No sharing was created. +
+
diff --git a/src/frontend/app/ui/settings/share/share.settings.component.ts b/src/frontend/app/ui/settings/share/share.settings.component.ts index 73a521a3..f2f4e5bc 100644 --- a/src/frontend/app/ui/settings/share/share.settings.component.ts +++ b/src/frontend/app/ui/settings/share/share.settings.component.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import {SettingsComponent} from '../_abstract/abstract.settings.component'; import {AuthenticationService} from '../../../model/network/authentication.service'; import {NavigationService} from '../../../model/navigation.service'; @@ -6,6 +6,7 @@ import {NotificationService} from '../../../model/notification.service'; import {ShareSettingsService} from './share.settings.service'; import {I18n} from '@ngx-translate/i18n-polyfill'; import {ClientConfig} from '../../../../../common/config/public/ClientConfig'; +import {SharingDTO} from '../../../../../common/entities/SharingDTO'; @Component({ selector: 'app-settings-share', @@ -14,7 +15,10 @@ import {ClientConfig} from '../../../../../common/config/public/ClientConfig'; '../_abstract/abstract.settings.component.css'], providers: [ShareSettingsService], }) -export class ShareSettingsComponent extends SettingsComponent { +export class ShareSettingsComponent extends SettingsComponent implements OnInit { + + + public shares: SharingDTO[] = []; constructor(_authService: AuthenticationService, _navigation: NavigationService, @@ -25,6 +29,25 @@ export class ShareSettingsComponent extends SettingsComponent { @@ -23,4 +24,14 @@ export class ShareSettingsService extends AbstractSettingsService { + return this._networkService.getJson('/share/list'); + } + + + public deleteSharing(sharing: SharingDTO): Promise { + return this._networkService.deleteJson('/share/' + sharing.sharingKey); + } + } diff --git a/src/frontend/translate/messages.en.xlf b/src/frontend/translate/messages.en.xlf index 070cda1d..11eb06bf 100644 --- a/src/frontend/translate/messages.en.xlf +++ b/src/frontend/translate/messages.en.xlf @@ -842,10 +842,6 @@ app/ui/settings/search/search.settings.component.html 53 - - app/ui/settings/share/share.settings.component.html - 43 - app/ui/settings/random-photo/random-photo.settings.component.html 40 @@ -899,10 +895,6 @@ app/ui/settings/search/search.settings.component.html 57 - - app/ui/settings/share/share.settings.component.html - 47 - app/ui/settings/random-photo/random-photo.settings.component.html 44 @@ -1376,6 +1368,84 @@ Sharing is not supported with these settings + + Save + + + app/ui/settings/share/share.settings.component.html + 45 + + + app/ui/settings/indexing/indexing.settings.component.html + 72 + + Save + + + Reset + + + app/ui/settings/share/share.settings.component.html + 49 + + + app/ui/settings/indexing/indexing.settings.component.html + 76 + + Reset + + + Shared links: + + app/ui/settings/share/share.settings.component.html + 56 + + Shared links: + + + Key + + app/ui/settings/share/share.settings.component.html + 62 + + Key + + + Folder + + app/ui/settings/share/share.settings.component.html + 63 + + Folder + + + Creator + + app/ui/settings/share/share.settings.component.html + 64 + + Creator + + + Expires + + app/ui/settings/share/share.settings.component.html + 65 + + Expires + + + + No sharing was created. + + + app/ui/settings/share/share.settings.component.html + 84 + + + No sharing was created. + + This feature enables you to generate 'random photo' urls. @@ -1796,24 +1866,6 @@ Exclude File List - - Save - - - app/ui/settings/indexing/indexing.settings.component.html - 72 - - Save - - - Reset - - - app/ui/settings/indexing/indexing.settings.component.html - 76 - - Reset - If you add a new folder to your gallery, the site indexes it automatically. diff --git a/src/frontend/translate/messages.fr.xlf b/src/frontend/translate/messages.fr.xlf index c9a85d9b..9c873197 100644 --- a/src/frontend/translate/messages.fr.xlf +++ b/src/frontend/translate/messages.fr.xlf @@ -842,10 +842,6 @@ app/ui/settings/search/search.settings.component.html 53 - - app/ui/settings/share/share.settings.component.html - 43 - app/ui/settings/random-photo/random-photo.settings.component.html 40 @@ -899,10 +895,6 @@ app/ui/settings/search/search.settings.component.html 57 - - app/ui/settings/share/share.settings.component.html - 47 - app/ui/settings/random-photo/random-photo.settings.component.html 44 @@ -1376,6 +1368,84 @@ Le partage n'est pas supporté avec ces paramètres + + Save + + + app/ui/settings/share/share.settings.component.html + 45 + + + app/ui/settings/indexing/indexing.settings.component.html + 72 + + Enregistrer + + + Reset + + + app/ui/settings/share/share.settings.component.html + 49 + + + app/ui/settings/indexing/indexing.settings.component.html + 76 + + Réinitialiser + + + Shared links: + + app/ui/settings/share/share.settings.component.html + 56 + + Shared links: + + + Key + + app/ui/settings/share/share.settings.component.html + 62 + + Key + + + Folder + + app/ui/settings/share/share.settings.component.html + 63 + + Folder + + + Creator + + app/ui/settings/share/share.settings.component.html + 64 + + Creator + + + Expires + + app/ui/settings/share/share.settings.component.html + 65 + + Expires + + + + No sharing was created. + + + app/ui/settings/share/share.settings.component.html + 84 + + + No sharing was created. + + This feature enables you to generate 'random photo' urls. @@ -1796,24 +1866,6 @@ Exclude File List - - Save - - - app/ui/settings/indexing/indexing.settings.component.html - 72 - - Enregistrer - - - Reset - - - app/ui/settings/indexing/indexing.settings.component.html - 76 - - Réinitialiser - If you add a new folder to your gallery, the site indexes it automatically. diff --git a/src/frontend/translate/messages.hu.xlf b/src/frontend/translate/messages.hu.xlf index 4a00b32f..4d943c1f 100644 --- a/src/frontend/translate/messages.hu.xlf +++ b/src/frontend/translate/messages.hu.xlf @@ -842,10 +842,6 @@ app/ui/settings/search/search.settings.component.html 53 - - app/ui/settings/share/share.settings.component.html - 43 - app/ui/settings/random-photo/random-photo.settings.component.html 40 @@ -899,10 +895,6 @@ app/ui/settings/search/search.settings.component.html 57 - - app/ui/settings/share/share.settings.component.html - 47 - app/ui/settings/random-photo/random-photo.settings.component.html 44 @@ -1376,6 +1368,84 @@ A megosztás nem támogatott ezekkel a beállításokkal + + Save + + + app/ui/settings/share/share.settings.component.html + 45 + + + app/ui/settings/indexing/indexing.settings.component.html + 72 + + Mentés + + + Reset + + + app/ui/settings/share/share.settings.component.html + 49 + + + app/ui/settings/indexing/indexing.settings.component.html + 76 + + Visszaállítás + + + Shared links: + + app/ui/settings/share/share.settings.component.html + 56 + + Megosztások: + + + Key + + app/ui/settings/share/share.settings.component.html + 62 + + Kulcs + + + Folder + + app/ui/settings/share/share.settings.component.html + 63 + + Mappa + + + Creator + + app/ui/settings/share/share.settings.component.html + 64 + + Létre hozta + + + Expires + + app/ui/settings/share/share.settings.component.html + 65 + + Lejár + + + + No sharing was created. + + + app/ui/settings/share/share.settings.component.html + 84 + + + Még nem hoztak létre megosztást. + + This feature enables you to generate 'random photo' urls. @@ -1796,24 +1866,6 @@ Mappa kihagyó fájlok - - Save - - - app/ui/settings/indexing/indexing.settings.component.html - 72 - - Mentés - - - Reset - - - app/ui/settings/indexing/indexing.settings.component.html - 76 - - Visszaállítás - If you add a new folder to your gallery, the site indexes it automatically. @@ -2776,4 +2828,4 @@ - \ No newline at end of file + diff --git a/src/frontend/translate/messages.ro.xlf b/src/frontend/translate/messages.ro.xlf index 9540a73f..a23517d7 100644 --- a/src/frontend/translate/messages.ro.xlf +++ b/src/frontend/translate/messages.ro.xlf @@ -842,10 +842,6 @@ app/ui/settings/search/search.settings.component.html 53 - - app/ui/settings/share/share.settings.component.html - 43 - app/ui/settings/random-photo/random-photo.settings.component.html 40 @@ -899,10 +895,6 @@ app/ui/settings/search/search.settings.component.html 57 - - app/ui/settings/share/share.settings.component.html - 47 - app/ui/settings/random-photo/random-photo.settings.component.html 44 @@ -1376,6 +1368,84 @@ Partajarea nu este suportată cu aceste setări + + Save + + + app/ui/settings/share/share.settings.component.html + 45 + + + app/ui/settings/indexing/indexing.settings.component.html + 72 + + Salvare + + + Reset + + + app/ui/settings/share/share.settings.component.html + 49 + + + app/ui/settings/indexing/indexing.settings.component.html + 76 + + Restabilire + + + Shared links: + + app/ui/settings/share/share.settings.component.html + 56 + + Shared links: + + + Key + + app/ui/settings/share/share.settings.component.html + 62 + + Key + + + Folder + + app/ui/settings/share/share.settings.component.html + 63 + + Folder + + + Creator + + app/ui/settings/share/share.settings.component.html + 64 + + Creator + + + Expires + + app/ui/settings/share/share.settings.component.html + 65 + + Expires + + + + No sharing was created. + + + app/ui/settings/share/share.settings.component.html + 84 + + + No sharing was created. + + This feature enables you to generate 'random photo' urls. @@ -1796,24 +1866,6 @@ Exclude File List - - Save - - - app/ui/settings/indexing/indexing.settings.component.html - 72 - - Salvare - - - Reset - - - app/ui/settings/indexing/indexing.settings.component.html - 76 - - Restabilire - If you add a new folder to your gallery, the site indexes it automatically. diff --git a/src/frontend/translate/messages.ru.xlf b/src/frontend/translate/messages.ru.xlf index a4bc28ac..f0ed8972 100644 --- a/src/frontend/translate/messages.ru.xlf +++ b/src/frontend/translate/messages.ru.xlf @@ -842,10 +842,6 @@ app/ui/settings/search/search.settings.component.html 53 - - app/ui/settings/share/share.settings.component.html - 43 - app/ui/settings/random-photo/random-photo.settings.component.html 40 @@ -899,10 +895,6 @@ app/ui/settings/search/search.settings.component.html 57 - - app/ui/settings/share/share.settings.component.html - 47 - app/ui/settings/random-photo/random-photo.settings.component.html 44 @@ -1376,6 +1368,84 @@ Совместное использование не поддерживается с указанными настройками + + Save + + + app/ui/settings/share/share.settings.component.html + 45 + + + app/ui/settings/indexing/indexing.settings.component.html + 72 + + Сохранить + + + Reset + + + app/ui/settings/share/share.settings.component.html + 49 + + + app/ui/settings/indexing/indexing.settings.component.html + 76 + + Сбросить + + + Shared links: + + app/ui/settings/share/share.settings.component.html + 56 + + Shared links: + + + Key + + app/ui/settings/share/share.settings.component.html + 62 + + Key + + + Folder + + app/ui/settings/share/share.settings.component.html + 63 + + Folder + + + Creator + + app/ui/settings/share/share.settings.component.html + 64 + + Creator + + + Expires + + app/ui/settings/share/share.settings.component.html + 65 + + Expires + + + + No sharing was created. + + + app/ui/settings/share/share.settings.component.html + 84 + + + No sharing was created. + + This feature enables you to generate 'random photo' urls. @@ -1796,24 +1866,6 @@ Exclude File List - - Save - - - app/ui/settings/indexing/indexing.settings.component.html - 72 - - Сохранить - - - Reset - - - app/ui/settings/indexing/indexing.settings.component.html - 76 - - Сбросить - If you add a new folder to your gallery, the site indexes it automatically.