From e9b5758909475b071c4a4765ace2c33bb0902b4a Mon Sep 17 00:00:00 2001 From: Patrik Braun Date: Fri, 21 Jul 2017 19:14:22 +0200 Subject: [PATCH] fixing loading sign error --- backend/model/sql/GalleryManager.ts | 2 ++ backend/model/sql/enitites/DirectoryEntity.ts | 17 +++++++---------- backend/model/sql/enitites/UserEntity.ts | 10 +++------- backend/model/threading/DiskMangerWorker.ts | 2 ++ common/entities/DirectoryDTO.ts | 2 +- frontend/app/gallery/cache.gallery.service.ts | 7 ++++++- frontend/app/gallery/gallery.component.css | 2 +- frontend/app/gallery/gallery.component.html | 2 +- frontend/app/gallery/gallery.service.ts | 3 ++- 9 files changed, 25 insertions(+), 22 deletions(-) diff --git a/backend/model/sql/GalleryManager.ts b/backend/model/sql/GalleryManager.ts index 5dae6dae..e750d324 100644 --- a/backend/model/sql/GalleryManager.ts +++ b/backend/model/sql/GalleryManager.ts @@ -59,8 +59,10 @@ export class GalleryManager implements IGalleryManager { .where("photo.directory = :dir", { dir: dir.directories[i].id }) + .orderBy("photo.metadata.creationDate", "ASC") .setLimit(Config.Server.folderPreviewSize) .getMany(); + dir.directories[i].isPartial = true; for (let j = 0; j < dir.directories[i].photos.length; j++) { dir.directories[i].photos[j].directory = dir.directories[i]; diff --git a/backend/model/sql/enitites/DirectoryEntity.ts b/backend/model/sql/enitites/DirectoryEntity.ts index b95d1562..8a999ff5 100644 --- a/backend/model/sql/enitites/DirectoryEntity.ts +++ b/backend/model/sql/enitites/DirectoryEntity.ts @@ -8,25 +8,22 @@ export class DirectoryEntity implements DirectoryDTO { @PrimaryGeneratedColumn() id: number; - @Column({ - length: 500 - }) + @Column() name: string; - @Column({ - length: 500 - }) + @Column() path: string; - - @Column('number') + @Column() public lastModified: number; - @Column('number') + @Column() public lastScanned: number; - @Column({type: 'smallint', length: 1}) + @Column() public scanned: boolean; + isPartial?: boolean; + @ManyToOne(type => DirectoryEntity, directory => directory.directories, {onDelete: "CASCADE"}) public parent: DirectoryEntity; diff --git a/backend/model/sql/enitites/UserEntity.ts b/backend/model/sql/enitites/UserEntity.ts index 8bf0d282..8fbcd7de 100644 --- a/backend/model/sql/enitites/UserEntity.ts +++ b/backend/model/sql/enitites/UserEntity.ts @@ -7,17 +7,13 @@ export class UserEntity implements UserDTO { @PrimaryGeneratedColumn() id: number; - @Column({ - length: 500 - }) + @Column() name: string; - @Column({ - length: 500 - }) + @Column() password: string; - @Column("int") + @Column("smallint") role: UserRoles; @Column("string", {nullable: true}) diff --git a/backend/model/threading/DiskMangerWorker.ts b/backend/model/threading/DiskMangerWorker.ts index b31037a5..8d267cb0 100644 --- a/backend/model/threading/DiskMangerWorker.ts +++ b/backend/model/threading/DiskMangerWorker.ts @@ -41,6 +41,7 @@ export class DiskMangerWorker { lastModified: Math.max(stat.ctime.getTime(), stat.mtime.getTime()), lastScanned: Date.now(), directories: [], + isPartial: false, photos: [] }; fs.readdir(absoluteDirectoryName, async (err, list) => { @@ -57,6 +58,7 @@ export class DiskMangerWorker { Config.Server.folderPreviewSize, true ); d.lastScanned = 0; //it was not a fully scan + d.isPartial = true; directory.directories.push(d); } else if (DiskMangerWorker.isImage(fullFilePath)) { directory.photos.push({ diff --git a/common/entities/DirectoryDTO.ts b/common/entities/DirectoryDTO.ts index 5404a8c6..6fa1932f 100644 --- a/common/entities/DirectoryDTO.ts +++ b/common/entities/DirectoryDTO.ts @@ -6,7 +6,7 @@ export interface DirectoryDTO { path: string; lastModified: number; lastScanned: number; - scanned: boolean; + isPartial?: boolean; parent: DirectoryDTO; directories: Array; photos: Array; diff --git a/frontend/app/gallery/cache.gallery.service.ts b/frontend/app/gallery/cache.gallery.service.ts index d13bd8ef..ff6c0108 100644 --- a/frontend/app/gallery/cache.gallery.service.ts +++ b/frontend/app/gallery/cache.gallery.service.ts @@ -27,7 +27,12 @@ export class GalleryCacheService { return; } - localStorage.setItem(Utils.concatUrls(directory.path, directory.name), JSON.stringify(directory)); + const key = Utils.concatUrls(directory.path, directory.name); + if (directory.isPartial == true && localStorage.getItem(key)) { + return; + } + + localStorage.setItem(key, JSON.stringify(directory)); directory.directories.forEach((dir: DirectoryDTO) => { let name = Utils.concatUrls(dir.path, dir.name); diff --git a/frontend/app/gallery/gallery.component.css b/frontend/app/gallery/gallery.component.css index e5ad8261..c0ff8bb3 100644 --- a/frontend/app/gallery/gallery.component.css +++ b/frontend/app/gallery/gallery.component.css @@ -17,7 +17,7 @@ gallery-directory { } .spinner { - margin-top: calc(50vh - 40px); + margin-top: 50px; width: 80px; height: 80px; background-color: #333; diff --git a/frontend/app/gallery/gallery.component.html b/frontend/app/gallery/gallery.component.html index 9b89c714..b8a1b030 100644 --- a/frontend/app/gallery/gallery.component.html +++ b/frontend/app/gallery/gallery.component.html @@ -57,7 +57,7 @@
diff --git a/frontend/app/gallery/gallery.service.ts b/frontend/app/gallery/gallery.service.ts index 2e513ffb..d884258b 100644 --- a/frontend/app/gallery/gallery.service.ts +++ b/frontend/app/gallery/gallery.service.ts @@ -42,7 +42,8 @@ export class GalleryService { } } - if (content.directory && content.directory.lastModified && content.directory.lastScanned) { + if (content.directory && content.directory.lastModified && content.directory.lastScanned && + !content.directory.isPartial) { params['knownLastModified'] = content.directory.lastModified; params['knownLastScanned'] = content.directory.lastScanned; }