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

improve sharing UI #1015

This commit is contained in:
Patrik J. Braun
2025-08-17 18:37:26 +02:00
parent 578ea68da8
commit 07df03e38b
2 changed files with 26 additions and 6 deletions

View File

@@ -64,12 +64,22 @@
</div>
</div>
<div class="row mt-2">
<div class="col-12">
<small class="text-muted">
<span i18n>Sharing</span>&nbsp;<ng-container *ngIf="currentMediaCountIsLowerBound"><span
i18n>at least</span>&nbsp;
</ng-container>
<span class="fw-bold">{{ currentMediaCount }}</span>&nbsp;<span i18n>photos and videos.</span>&nbsp;<span i18n>Folders are not shared.</span>
</small>
</div>
</div>
<div class="row">
<div class="col-4">
<label class="control-label" for="share-password">
<ng-container i18n>Password</ng-container>
<ng-container *ngIf="passwordRequired">*</ng-container>
<ng-container *ngIf="passwordRequired">*</ng-container>
</label>
</div>
<div class="col-8">
@@ -114,7 +124,7 @@
<a *ngIf="!showSharingList"
(click)="showSharingList = true"
class="list-shares-button m-0">
<span class="badge text-bg-secondary me-1">{{activeShares.length}}</span>
<span class="badge text-bg-secondary me-1">{{ activeShares.length }}</span>
<ng-container i18n>active share(s) for this folder.
</ng-container>
<ng-icon name="ionChevronForwardOutline" class="ms-1"></ng-icon>
@@ -130,9 +140,9 @@
</thead>
<tbody>
<tr *ngFor="let share of activeShares">
<td><a [href]="sharingService.getUrl(share)">{{share.sharingKey}}</a></td>
<td *ngIf="IsAdmin">{{share.creator.name}}</td>
<td>{{share.expires | date}}</td>
<td><a [href]="sharingService.getUrl(share)">{{ share.sharingKey }}</a></td>
<td *ngIf="IsAdmin">{{ share.creator.name }}</td>
<td>{{ share.expires | date }}</td>
<td>
<button (click)="deleteSharing(share)"
[disabled]="share.sharingKey == sharing?.sharingKey"

View File

@@ -49,6 +49,8 @@ export class GalleryShareComponent implements OnInit, OnDestroy {
currentDir = '';
currentQuery: SearchQueryDTO = null;
sharingTarget = '';
currentMediaCount = 0;
currentMediaCountIsLowerBound = false;
sharing: SharingDTO = null;
contentSubscription: Subscription = null;
readonly passwordRequired = Config.Sharing.passwordRequired;
@@ -88,10 +90,15 @@ export class GalleryShareComponent implements OnInit, OnDestroy {
this.currentDir = '';
this.currentQuery = null;
this.sharingTarget = '';
this.currentMediaCount = 0;
this.currentMediaCountIsLowerBound = false;
if ((content as any).searchResult) {
this.currentQuery = (content as any).searchResult.searchQuery as SearchQueryDTO;
const sr = (content as any).searchResult;
this.currentQuery = sr.searchQuery as SearchQueryDTO;
this.sharingTarget = $localize`Search query`;
this.currentMediaCount = (sr.media ? sr.media.length : 0);
this.currentMediaCountIsLowerBound = !!sr.resultOverflow;
} else if (content.directory) {
this.currentDir = Utils.concatUrls(
content.directory.path,
@@ -103,6 +110,9 @@ export class GalleryShareComponent implements OnInit, OnDestroy {
matchType: TextSearchQueryMatchTypes.exact_match
} as TextSearch;
this.sharingTarget = this.currentDir;
// Prefer mediaCount, fallback to media length if needed
this.currentMediaCount = (typeof content.directory.mediaCount === 'number' ? content.directory.mediaCount : (content.directory.media ? content.directory.media.length : 0));
this.currentMediaCountIsLowerBound = false;
}
if (!this.enabled || !this.currentQuery) {