1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-12 11:15:22 +02:00

Disabling searching with shared link #269

This commit is contained in:
Patrik J. Braun 2021-04-23 17:54:43 +02:00
parent 90a6c4b6b1
commit f0f47f96bb
6 changed files with 46 additions and 19 deletions

View File

@ -8,7 +8,7 @@ import {NetworkService} from './network.service';
import {ErrorCodes, ErrorDTO} from '../../../../common/entities/Error';
import {CookieNames} from '../../../../common/CookieNames';
import {ShareService} from '../../ui/gallery/share.service';
import { CookieService } from 'ngx-cookie-service';
import {CookieService} from 'ngx-cookie-service';
/* Injected config / user from server side */
// tslint:disable-next-line:no-internal-module no-namespace
@ -85,6 +85,10 @@ export class AuthenticationService {
return this.user.value && this.user.value.role >= role;
}
public canSearch(): boolean {
return this.isAuthorized(UserRoles.Guest);
}
public async logout(): Promise<void> {
await this.userService.logout();
this.user.next(null);

View File

@ -99,9 +99,9 @@ export class GalleryComponent implements OnInit, OnDestroy {
return this.navigation.toLogin();
}
this.showSearchBar = Config.Client.Search.enabled && this.authService.isAuthorized(UserRoles.Guest);
this.showSearchBar = Config.Client.Search.enabled && this.authService.canSearch();
this.showShare = Config.Client.Sharing.enabled && this.authService.isAuthorized(UserRoles.User);
this.showRandomPhotoBuilder = Config.Client.RandomPhoto.enabled && this.authService.isAuthorized(UserRoles.Guest);
this.showRandomPhotoBuilder = Config.Client.RandomPhoto.enabled && this.authService.isAuthorized(UserRoles.User);
this.subscription.content = this.galleryService.content.subscribe(this.onContentChange);
this.subscription.route = this.route.params.subscribe(this.onRoute);

View File

@ -7,6 +7,8 @@ import {Config} from '../../../../../../common/config/public/Config';
import {PageHelper} from '../../../../model/page.helper';
import {PhotoDTO, PhotoMetadata} from '../../../../../../common/entities/PhotoDTO';
import {SearchQueryTypes, TextSearch, TextSearchQueryMatchTypes} from '../../../../../../common/entities/SearchQueryDTO';
import {UserRoles} from '../../../../../../common/entities/UserDTO';
import {AuthenticationService} from '../../../../model/network/authentication.service';
@Component({
selector: 'app-gallery-grid-photo',
@ -29,8 +31,9 @@ export class GalleryPhotoComponent implements IRenderable, OnInit, OnDestroy {
wasInView: boolean = null;
constructor(private thumbnailService: ThumbnailManagerService) {
this.searchEnabled = Config.Client.Search.enabled;
constructor(private thumbnailService: ThumbnailManagerService,
private authService: AuthenticationService) {
this.searchEnabled = Config.Client.Search.enabled && this.authService.canSearch();
}
get ScrollListener(): boolean {

View File

@ -56,17 +56,31 @@
[style.width.px]="faceContainerDim.width* zoom"
[style.height.px]="faceContainerDim.height* zoom"
*ngIf="facesEnabled && activePhoto && activePhoto.gridMedia.Photo.metadata.faces && activePhoto.gridMedia.Photo.metadata.faces.length > 0">
<a
class="face"
[routerLink]="['/search', getPersonSearchQuery(face.name)]"
[style.top.%]="face.box.top / activePhoto.gridMedia.Photo.metadata.size.height*100"
[style.left.%]="face.box.left / activePhoto.gridMedia.Photo.metadata.size.width*100"
[style.height.%]="face.box.height / activePhoto.gridMedia.Photo.metadata.size.height*100"
[style.width.%]="face.box.width / activePhoto.gridMedia.Photo.metadata.size.width*100"
*ngFor="let face of activePhoto.gridMedia.Photo.metadata.faces">
<div class="face-box"></div>
<span class="face-name">{{face.name}}</span>
</a>
<ng-container *ngIf="searchEnabled">
<a
class="face"
[routerLink]="['/search', getPersonSearchQuery(face.name)]"
[style.top.%]="face.box.top / activePhoto.gridMedia.Photo.metadata.size.height*100"
[style.left.%]="face.box.left / activePhoto.gridMedia.Photo.metadata.size.width*100"
[style.height.%]="face.box.height / activePhoto.gridMedia.Photo.metadata.size.height*100"
[style.width.%]="face.box.width / activePhoto.gridMedia.Photo.metadata.size.width*100"
*ngFor="let face of activePhoto.gridMedia.Photo.metadata.faces">
<div class="face-box"></div>
<span class="face-name">{{face.name}}</span>
</a>
</ng-container>
<ng-container *ngIf="!searchEnabled">
<div
class="face"
[style.top.%]="face.box.top / activePhoto.gridMedia.Photo.metadata.size.height*100"
[style.left.%]="face.box.left / activePhoto.gridMedia.Photo.metadata.size.width*100"
[style.height.%]="face.box.height / activePhoto.gridMedia.Photo.metadata.size.height*100"
[style.width.%]="face.box.width / activePhoto.gridMedia.Photo.metadata.size.width*100"
*ngFor="let face of activePhoto.gridMedia.Photo.metadata.faces">
<div class="face-box"></div>
<span class="face-name">{{face.name}}</span>
</div>
</ng-container>
</div>

View File

@ -8,6 +8,7 @@ import {PhotoDTO} from '../../../../../../common/entities/PhotoDTO';
import {GalleryLightboxMediaComponent} from '../media/media.lightbox.gallery.component';
import {Config} from '../../../../../../common/config/public/Config';
import {SearchQueryTypes, TextSearch, TextSearchQueryMatchTypes} from '../../../../../../common/entities/SearchQueryDTO';
import {AuthenticationService} from '../../../../model/network/authentication.service';
export enum PlayBackStates {
Paused = 1,
@ -48,13 +49,16 @@ export class ControlsLightboxComponent implements OnDestroy, OnInit, OnChanges {
public drag = {x: 0, y: 0};
public SearchQueryTypes = SearchQueryTypes;
public faceContainerDim = {width: 0, height: 0};
public searchEnabled: boolean;
private visibilityTimer: number = null;
private timer: Observable<number>;
private timerSub: Subscription;
private prevDrag = {x: 0, y: 0};
private prevZoom = 1;
constructor(public fullScreenService: FullScreenService) {
constructor(public fullScreenService: FullScreenService,
private authService: AuthenticationService) {
this.searchEnabled = Config.Client.Search.enabled && this.authService.canSearch();
}
public get Zoom(): number {

View File

@ -7,6 +7,7 @@ import {Utils} from '../../../../../../common/Utils';
import {QueryService} from '../../../../model/query.service';
import {MapService} from '../../map/map.service';
import {SearchQueryTypes, TextSearch, TextSearchQueryMatchTypes} from '../../../../../../common/entities/SearchQueryDTO';
import {AuthenticationService} from '../../../../model/network/authentication.service';
@Component({
selector: 'app-info-panel',
@ -23,9 +24,10 @@ export class InfoPanelLightboxComponent implements OnInit {
readonly SearchQueryTypes: typeof SearchQueryTypes = SearchQueryTypes;
constructor(public queryService: QueryService,
public mapService: MapService) {
public mapService: MapService,
private authService: AuthenticationService) {
this.mapEnabled = Config.Client.Map.enabled;
this.searchEnabled = Config.Client.Search.enabled;
this.searchEnabled = Config.Client.Search.enabled && this.authService.canSearch();
}
get FullPath(): string {