mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
improving photo error handling
This commit is contained in:
parent
2bdf5979f8
commit
d274613e38
@ -1,5 +1,6 @@
|
|||||||
<div class="static" *ngIf="animate == false">
|
<div class="static" *ngIf="animate == false">
|
||||||
<span class="glyphicon glyphicon-picture" aria-hidden="true">
|
<span class="glyphicon glyphicon-picture"
|
||||||
|
[ngClass]="error ? 'glyphicon-warning-sign' : 'glyphicon-picture'" aria-hidden="true">
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="sk-cube-grid animate" *ngIf="animate == true">
|
<div class="sk-cube-grid animate" *ngIf="animate == true">
|
||||||
|
@ -8,6 +8,7 @@ import {Component, Input} from "@angular/core";
|
|||||||
export class GalleryPhotoLoadingComponent {
|
export class GalleryPhotoLoadingComponent {
|
||||||
|
|
||||||
@Input() animate: boolean;
|
@Input() animate: boolean;
|
||||||
|
@Input() error: boolean;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
<img #img [src]="thumbnail.Src" *ngIf="thumbnail.Available">
|
<img #img [src]="thumbnail.Src" *ngIf="thumbnail.Available">
|
||||||
|
|
||||||
<gallery-grid-photo-loading
|
<gallery-grid-photo-loading
|
||||||
|
[error]="thumbnail.Error"
|
||||||
[animate]="thumbnail.loading"
|
[animate]="thumbnail.loading"
|
||||||
*ngIf="!thumbnail.Available">
|
*ngIf="!thumbnail.Available">
|
||||||
</gallery-grid-photo-loading>
|
</gallery-grid-photo-loading>
|
||||||
|
@ -30,7 +30,7 @@ export abstract class ThumbnailBase {
|
|||||||
protected available: boolean = false;
|
protected available: boolean = false;
|
||||||
protected src: string = null;
|
protected src: string = null;
|
||||||
protected loading: boolean = false;
|
protected loading: boolean = false;
|
||||||
protected error: boolean = true;
|
protected error: boolean = false;
|
||||||
protected onLoad: Function = null;
|
protected onLoad: Function = null;
|
||||||
protected thumbnailTask: ThumbnailTaskEntity;
|
protected thumbnailTask: ThumbnailTaskEntity;
|
||||||
|
|
||||||
@ -45,18 +45,22 @@ export abstract class ThumbnailBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
get Available() {
|
get Available(): boolean {
|
||||||
return this.available;
|
return this.available;
|
||||||
}
|
}
|
||||||
|
|
||||||
get Src() {
|
get Src(): string {
|
||||||
return this.src;
|
return this.src;
|
||||||
}
|
}
|
||||||
|
|
||||||
get Loading() {
|
get Loading(): boolean {
|
||||||
return this.loading;
|
return this.loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get Error(): boolean {
|
||||||
|
return this.error;
|
||||||
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
if (this.thumbnailTask != null) {
|
if (this.thumbnailTask != null) {
|
||||||
this.thumbnailService.removeTask(this.thumbnailTask);
|
this.thumbnailService.removeTask(this.thumbnailTask);
|
||||||
@ -96,10 +100,6 @@ export class IconThumbnail extends ThumbnailBase {
|
|||||||
this.thumbnailTask = null;
|
this.thumbnailTask = null;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.error = true;
|
this.error = true;
|
||||||
//TODO: handle error
|
|
||||||
//TODO: not an error if its from cache
|
|
||||||
console.error("something bad happened");
|
|
||||||
console.error(error);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.thumbnailTask = this.thumbnailService.loadIcon(this.photo, ThumbnailLoadingPriority.high, listener);
|
this.thumbnailTask = this.thumbnailService.loadIcon(this.photo, ThumbnailLoadingPriority.high, listener);
|
||||||
@ -153,10 +153,8 @@ export class Thumbnail extends ThumbnailBase {
|
|||||||
},
|
},
|
||||||
onError: (error) => {//onError
|
onError: (error) => {//onError
|
||||||
this.thumbnailTask = null;
|
this.thumbnailTask = null;
|
||||||
//TODO: handle error
|
this.loading = false;
|
||||||
//TODO: not an error if its from cache
|
this.error = true;
|
||||||
console.error("something bad happened");
|
|
||||||
console.error(error);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (this.photo.isReplacementThumbnailAvailable()) {
|
if (this.photo.isReplacementThumbnailAvailable()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user