1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

Fixing constantly updating navigator bar. This should fix the button not working problem for IOS #493

This commit is contained in:
Patrik J. Braun 2022-12-18 10:09:34 +01:00
parent f2504f60d2
commit 48a1900fc6
2 changed files with 68 additions and 66 deletions

View File

@ -1,20 +1,20 @@
<div class="container-fluid mb-2 pt-1 pb-1 pe-0 ps-0"> <div class="container-fluid mb-2 pt-1 pb-1 pe-0 ps-0">
<nav class="d-md-flex row" aria-label="breadcrumb"> <nav class="d-md-flex row" aria-label="breadcrumb">
<div class="col-12 col-md-auto"> <div class="col-12 col-md-auto">
<ol *ngIf="isDirectory" id="directory-path" class="mb-0 mt-1 breadcrumb"> <ol *ngIf="isDirectory" id="directory-path" class="mb-0 mt-1 breadcrumb">
<li *ngFor="let path of Routes" class="breadcrumb-item"> <li *ngFor="let path of routes | async" class="breadcrumb-item">
<a *ngIf="path.route" [routerLink]="['/gallery',path.route]" <a *ngIf="path.route" [routerLink]="['/gallery',path.route]"
[queryParams]="queryService.getParams()">{{path.name}}</a> [queryParams]="queryService.getParams()">{{path.name}}</a>
<ng-container *ngIf="!path.route">{{path.name}}</ng-container> <ng-container *ngIf="!path.route">{{path.name}}</ng-container>
</li> </li>
</ol> </ol>
<ol *ngIf="!isDirectory" class="mb-0 mt-1 breadcrumb"> <ol *ngIf="!isDirectory" class="mb-0 mt-1 breadcrumb">
<li class="active"> <li class="active">
<ng-container i18n>Searching for:</ng-container> <ng-container i18n>Searching for:</ng-container>
<strong> {{galleryService.content.value?.searchResult?.searchQuery | searchQuery}}</strong> <strong> {{galleryService.content.value?.searchResult?.searchQuery | searchQuery}}</strong>
</li> </li>
</ol> </ol>
</div> </div>
<div class="ms-auto text-end col-12 col-md-auto"> <div class="ms-auto text-end col-12 col-md-auto">
@ -77,4 +77,4 @@
</div> </div>
<app-gallery-filter *ngIf="showFilters && ItemCount> 0"></app-gallery-filter> <app-gallery-filter *ngIf="showFilters && ItemCount> 0"></app-gallery-filter>

View File

@ -34,6 +34,7 @@ export class GalleryNavigatorComponent {
public readonly SearchQueryTypes = SearchQueryTypes; public readonly SearchQueryTypes = SearchQueryTypes;
public wrappedContent: Observable<ContentWrapperWithError>; public wrappedContent: Observable<ContentWrapperWithError>;
public directoryContent: Observable<DirectoryContent>; public directoryContent: Observable<DirectoryContent>;
public routes: Observable<NavigatorPath[]>;
public showFilters = false; public showFilters = false;
private readonly RootFolderName: string; private readonly RootFolderName: string;
@ -49,6 +50,59 @@ export class GalleryNavigatorComponent {
this.directoryContent = this.wrappedContent.pipe( this.directoryContent = this.wrappedContent.pipe(
map((c) => (c.directory ? c.directory : c.searchResult)) map((c) => (c.directory ? c.directory : c.searchResult))
); );
this.routes = this.galleryService.content.pipe(
map((c) => {
if (!c.directory) {
return [];
}
const path = c.directory.path.replace(new RegExp('\\\\', 'g'), '/');
const dirs = path.split('/');
dirs.push(c.directory.name);
// removing empty strings
for (let i = 0; i < dirs.length; i++) {
if (!dirs[i] || 0 === dirs[i].length || '.' === dirs[i]) {
dirs.splice(i, 1);
i--;
}
}
const user = this.authService.user.value;
const arr: NavigatorPath[] = [];
// create root link
if (dirs.length === 0) {
arr.push({name: this.RootFolderName, route: null});
} else {
arr.push({
name: this.RootFolderName,
route: UserDTOUtils.isDirectoryPathAvailable('/', user.permissions)
? '/'
: null,
});
}
// create rest navigation
dirs.forEach((name, index) => {
const route = dirs.slice(0, dirs.indexOf(name) + 1).join('/');
if (dirs.length - 1 === index) {
arr.push({name, route: null});
} else {
arr.push({
name,
route: UserDTOUtils.isDirectoryPathAvailable(route, user.permissions)
? route
: null,
});
}
});
return arr;
})
);
} }
get isDirectory(): boolean { get isDirectory(): boolean {
@ -64,58 +118,6 @@ export class GalleryNavigatorComponent {
: 0; : 0;
} }
get Routes(): NavigatorPath[] {
const c = this.galleryService.content.value;
if (!c.directory) {
return [];
}
const path = c.directory.path.replace(new RegExp('\\\\', 'g'), '/');
const dirs = path.split('/');
dirs.push(c.directory.name);
// removing empty strings
for (let i = 0; i < dirs.length; i++) {
if (!dirs[i] || 0 === dirs[i].length || '.' === dirs[i]) {
dirs.splice(i, 1);
i--;
}
}
const user = this.authService.user.value;
const arr: NavigatorPath[] = [];
// create root link
if (dirs.length === 0) {
arr.push({name: this.RootFolderName, route: null});
} else {
arr.push({
name: this.RootFolderName,
route: UserDTOUtils.isDirectoryPathAvailable('/', user.permissions)
? '/'
: null,
});
}
// create rest navigation
dirs.forEach((name, index) => {
const route = dirs.slice(0, dirs.indexOf(name) + 1).join('/');
if (dirs.length - 1 === index) {
arr.push({name, route: null});
} else {
arr.push({
name,
route: UserDTOUtils.isDirectoryPathAvailable(route, user.permissions)
? route
: null,
});
}
});
return arr;
}
get DefaultSorting(): SortingMethods { get DefaultSorting(): SortingMethods {
return this.sortingService.getDefaultSorting( return this.sortingService.getDefaultSorting(
this.galleryService.content.value this.galleryService.content.value