1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2025-11-29 22:48:28 +02:00

Implement search query based sharing on the backend #1015

This commit is contained in:
Patrik J. Braun
2025-08-17 11:43:29 +02:00
parent 41f57e29db
commit 31ef7e8470
30 changed files with 568 additions and 353 deletions

View File

@@ -183,7 +183,7 @@ export class GalleryComponent implements OnInit, OnDestroy {
qParams[QueryParams.gallery.sharingKey_query] =
this.shareService.getSharingKey();
this.router
.navigate(['/gallery', sharing.path], {queryParams: qParams})
.navigate(['/search', sharing.searchQuery], {queryParams: qParams})
.catch(console.error);
return;
}

View File

@@ -1,7 +1,7 @@
import {Component, ElementRef, HostListener, ViewChild} from '@angular/core';
import {Router, RouterLink} from '@angular/router';
import {DomSanitizer} from '@angular/platform-browser';
import {UserDTOUtils} from '../../../../../common/entities/UserDTO';
import {UserRoles} from '../../../../../common/entities/UserDTO';
import {AuthenticationService} from '../../../model/network/authentication.service';
import {QueryService} from '../../../model/query.service';
import {Utils} from '../../../../../common/Utils';
@@ -137,7 +137,7 @@ export class GalleryNavigatorComponent {
} else {
arr.push({
name: this.RootFolderName,
route: UserDTOUtils.isDirectoryPathAvailable('/', user.permissions)
route: user.role <= UserRoles.LimitedGuest // it's basically a sharing. they should not just navigate wherever
? '/'
: null,
});
@@ -151,7 +151,7 @@ export class GalleryNavigatorComponent {
} else {
arr.push({
name,
route: UserDTOUtils.isDirectoryPathAvailable(route, user.permissions)
route: user.role <= UserRoles.LimitedGuest // it's basically a sharing. they should not just navigate wherever
? route
: null,
});

View File

@@ -8,6 +8,7 @@ import {QueryParams} from '../../../../common/QueryParams';
import {UserDTO, UserRoles} from '../../../../common/entities/UserDTO';
import {Utils} from '../../../../common/Utils';
import {Config} from '../../../../common/config/public/Config';
import {SearchQueryTypes, TextSearch, TextSearchQueryMatchTypes} from '../../../../common/entities/SearchQueryDTO';
@Injectable()
@@ -80,8 +81,8 @@ export class ShareService {
this.sharingSubject.value == null
) {
this.sharingKey = user.usedSharingKey || this.getSharingKey();
if(!this.sharingKey){ //no key to fetch
return
if (!this.sharingKey) { //no key to fetch
return;
}
await this.getSharing();
}
@@ -102,13 +103,11 @@ export class ShareService {
public createSharing(
dir: string,
includeSubFolders: boolean,
password: string,
valid: number
): Promise<SharingDTO> {
return this.networkService.postJson('/share/' + dir, {
createSharing: {
includeSubfolders: includeSubFolders,
valid,
...(!!password && {password: password}) // only add password if present
} as CreateSharingDTO,
@@ -118,14 +117,12 @@ export class ShareService {
public updateSharing(
dir: string,
sharingId: number,
includeSubFolders: boolean,
password: string,
valid: number
): Promise<SharingDTO> {
return this.networkService.putJson('/share/' + dir, {
updateSharing: {
id: sharingId,
includeSubfolders: includeSubFolders,
valid,
password,
} as CreateSharingDTO,
@@ -169,7 +166,11 @@ export class ShareService {
public async getSharingListForDir(
dir: string
): Promise<SharingDTO[]> {
return this.networkService.getJson('/share/list/' + dir);
return this.networkService.getJson('/share/list/' + JSON.stringify({
type: SearchQueryTypes.directory,
text: dir,
matchType: TextSearchQueryMatchTypes.exact_match
} as TextSearch));
}

View File

@@ -37,7 +37,6 @@ export class GalleryShareComponent implements OnInit, OnDestroy {
showSharingList = false;
input = {
includeSubfolders: true,
valid: {
amount: 30,
type: ValidityTypes.Days as ValidityTypes,
@@ -139,7 +138,6 @@ export class GalleryShareComponent implements OnInit, OnDestroy {
this.sharing = await this.sharingService.updateSharing(
this.currentDir,
this.sharing.id,
this.input.includeSubfolders,
this.input.password,
this.calcValidity()
);
@@ -157,7 +155,6 @@ export class GalleryShareComponent implements OnInit, OnDestroy {
this.url = $localize`loading..`;
this.sharing = await this.sharingService.createSharing(
this.currentDir,
this.input.includeSubfolders,
this.input.password,
this.calcValidity()
);