1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-04 10:34:45 +02:00

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/frontend/app/ui/gallery/gallery.component.ts
This commit is contained in:
Patrik J. Braun 2021-03-14 16:54:10 +01:00
commit 007962cc8d
9 changed files with 5744 additions and 44 deletions

5
package-lock.json generated
View File

@ -13509,6 +13509,11 @@
"resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz",
"integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg=="
},
"natural-orderby": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/natural-orderby/-/natural-orderby-2.0.3.tgz",
"integrity": "sha512-p7KTHxU0CUrcOXe62Zfrb5Z13nLvPhSWR/so3kFulUQU0sgUll2Z0LwpsLN351eOOD+hRGu/F1g+6xDfPeD++Q=="
},
"needle": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/needle/-/needle-2.5.2.tgz",

View File

@ -30,13 +30,12 @@
"url": "https://github.com/bpatrik/PiGallery2/issues"
},
"dependencies": {
"bcrypt": "5.0.0",
"body-parser": "1.19.0",
"cookie-parser": "1.4.5",
"cookie-session": "2.0.0-rc.1",
"csurf": "1.11.0",
"ejs": "3.1.5",
"bcrypt": "5.0.0",
"sharp": "0.23.4",
"exifreader": "3.13.0",
"express": "4.17.1",
"express-unless": "0.5.0",
@ -44,7 +43,9 @@
"image-size": "0.9.3",
"jimp": "0.16.1",
"locale": "0.1.0",
"natural-orderby": "^2.0.3",
"reflect-metadata": "0.1.13",
"sharp": "0.23.4",
"sqlite3": "5.0.0",
"ts-exif-parser": "0.2.1",
"ts-node-iptc": "1.0.11",

View File

@ -240,18 +240,27 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager {
}
if (dir.directories) {
for (let i = 0; i < dir.directories.length; i++) {
const dirName = GalleryManager.getAbsoluteDirName(dir.directories[i]);
dir.directories[i].media = await connection
.getRepository(MediaEntity)
.createQueryBuilder('media')
.innerJoinAndSelect('media.directory', 'directory')
.where('media.directory = :dir', {
dir: dir.directories[i].id
})
.orderBy('media.metadata.creationDate', 'ASC')
.orWhere("directory.path like :parentPath||'%'", {
parentPath: dirName
})
.orderBy('media.metadata.creationDate', 'DESC')
.limit(Config.Server.Indexing.folderPreviewSize)
.getMany();
dir.directories[i].isPartial = true;
for (let j = 0; j < dir.directories[i].media.length; j++) {
const dirs = dir.directories[i]
for (let j = 0; j < dirs.media.length; j++) {
const mediaDirName = GalleryManager.getAbsoluteDirName(dirs.media[j].directory);
const name = mediaDirName.substring(dirName.length);
dir.directories[i].media[j].name = name + dir.directories[i].media[j].name
dir.directories[i].media[j].directory = dir.directories[i];
dir.directories[i].media[j].readyThumbnails = [];
dir.directories[i].media[j].readyIcon = false;
@ -260,4 +269,9 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager {
}
}
public static getAbsoluteDirName(dir: DirectoryEntity) {
const path = dir.path;
const currentRoot = (path === "./" ? "" : path) ;
return currentRoot + dir.name + "/";
}
}

View File

@ -29,7 +29,7 @@ export class ConfigDiagnostics {
if (databaseConfig.type !== ServerConfig.DatabaseType.memory) {
await SQLConnection.tryConnection(databaseConfig);
}
if (databaseConfig.type !== ServerConfig.DatabaseType.sqlite) {
if (databaseConfig.type === ServerConfig.DatabaseType.sqlite) {
try {
await this.checkReadWritePermission(SQLConnection.getSQLiteDB(databaseConfig));
} catch (e) {

View File

@ -105,7 +105,7 @@ export class PublicRouter {
],
display: 'standalone',
orientation: 'any',
start_url: Config.Client.publicUrl,
start_url: Config.Client.publicUrl === '' ? '.' : Config.Client.publicUrl,
background_color: '#000000',
theme_color: '#000000'
});

View File

@ -3,6 +3,7 @@ import {AuthenticationService} from '../../model/network/authentication.service'
import {ActivatedRoute, Params, Router} from '@angular/router';
import {GalleryService} from './gallery.service';
import {GalleryGridComponent} from './grid/grid.gallery.component';
import {SearchTypes} from '../../../../common/entities/AutoCompleteItem';
import {Config} from '../../../../common/config/public/Config';
import {DirectoryDTO} from '../../../../common/entities/DirectoryDTO';
import {SearchResultDTO} from '../../../../common/entities/SearchResultDTO';
@ -18,6 +19,7 @@ import {QueryParams} from '../../../../common/QueryParams';
import {SeededRandomService} from '../../model/seededRandom.service';
import {take} from 'rxjs/operators';
import {SearchQueryTypes} from '../../../../common/entities/SearchQueryDTO';
import { compare } from 'natural-orderby';
@Component({
selector: 'app-gallery',
@ -36,7 +38,7 @@ export class GalleryComponent implements OnInit, OnDestroy {
public isPhotoWithLocation = false;
public countDown: { day: number, hour: number, minute: number, second: number } = null;
public readonly mapEnabled: boolean;
readonly SearchTypes: typeof SearchQueryTypes;
readonly SearchTypes: typeof SearchTypes;
private $counter: Observable<number>;
private subscription: { [key: string]: Subscription } = {
content: null,
@ -53,7 +55,7 @@ export class GalleryComponent implements OnInit, OnDestroy {
private _navigation: NavigationService,
private rndService: SeededRandomService) {
this.mapEnabled = Config.Client.Map.enabled;
this.SearchTypes = SearchQueryTypes;
this.SearchTypes = SearchTypes;
PageHelper.showScrollY();
}
@ -165,28 +167,16 @@ export class GalleryComponent implements OnInit, OnDestroy {
}
switch (this._galleryService.sorting.value) {
case SortingMethods.ascName:
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare()(a.name, b.name));
break;
case SortingMethods.ascDate:
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => {
if (a.name.toLowerCase() < b.name.toLowerCase()) {
return -1;
}
if (a.name.toLowerCase() > b.name.toLowerCase()) {
return 1;
}
return 0;
});
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare()(a.lastModified, b.lastModified));
break;
case SortingMethods.descName:
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare({ order: 'desc' })(a.name, b.name));
break;
case SortingMethods.descDate:
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => {
if (a.name.toLowerCase() < b.name.toLowerCase()) {
return 1;
}
if (a.name.toLowerCase() > b.name.toLowerCase()) {
return -1;
}
return 0;
});
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare({ order: 'desc' })(a.lastModified, b.lastModified));
break;
case SortingMethods.random:
this.rndService.setSeed(this.directories.length);

View File

@ -28,6 +28,7 @@ import {SortingMethods} from '../../../../../common/entities/SortingMethods';
import {MediaDTO} from '../../../../../common/entities/MediaDTO';
import {QueryParams} from '../../../../../common/QueryParams';
import {SeededRandomService} from '../../../model/seededRandom.service';
import { compare } from 'natural-orderby';
@Component({
selector: 'app-gallery-grid',
@ -230,26 +231,10 @@ export class GalleryGridComponent implements OnChanges, OnInit, AfterViewInit, O
private sortPhotos() {
switch (this.galleryService.sorting.value) {
case SortingMethods.ascName:
this.media.sort((a: PhotoDTO, b: PhotoDTO) => {
if (a.name.toLowerCase() < b.name.toLowerCase()) {
return -1;
}
if (a.name.toLowerCase() > b.name.toLowerCase()) {
return 1;
}
return 0;
});
this.media.sort((a: PhotoDTO, b: PhotoDTO) => compare()(a.name, b.name));
break;
case SortingMethods.descName:
this.media.sort((a: PhotoDTO, b: PhotoDTO) => {
if (a.name.toLowerCase() < b.name.toLowerCase()) {
return 1;
}
if (a.name.toLowerCase() > b.name.toLowerCase()) {
return -1;
}
return 0;
});
this.media.sort((a: PhotoDTO, b: PhotoDTO) => compare({order: 'desc' })(a.name, b.name));
break;
case SortingMethods.ascDate:
this.media.sort((a: PhotoDTO, b: PhotoDTO) => {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff