diff --git a/ui/src/app/data/enums/upload-image-errors.enum.ts b/ui/src/app/data/enums/upload-image-errors.enum.ts
new file mode 100644
index 0000000000..feefb4901c
--- /dev/null
+++ b/ui/src/app/data/enums/upload-image-errors.enum.ts
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2020 the original author or authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+export enum UploadImageErrors {
+ InvalidFileSize = 'Invalid File Size',
+ InvalidFileType = 'Invalid File Type',
+}
diff --git a/ui/src/app/features/image-holder/image-holder.component.html b/ui/src/app/features/image-holder/image-holder.component.html
index c1ade69512..d1296a29ee 100644
--- a/ui/src/app/features/image-holder/image-holder.component.html
+++ b/ui/src/app/features/image-holder/image-holder.component.html
@@ -18,7 +18,7 @@
-
+
diff --git a/ui/src/app/features/image-holder/image-holder.component.ts b/ui/src/app/features/image-holder/image-holder.component.ts
index 5fd419e124..cb2dd45e56 100644
--- a/ui/src/app/features/image-holder/image-holder.component.ts
+++ b/ui/src/app/features/image-holder/image-holder.component.ts
@@ -16,6 +16,7 @@
import { EventEmitter, SimpleChanges } from '@angular/core';
import { Component, Input, Output, ChangeDetectionStrategy, OnChanges } from '@angular/core';
import { CircleLoadingProgressEnum } from 'src/app/data/enums/circle-loading-progress.enum';
+import { UploadImageErrors } from 'src/app/data/enums/upload-image-errors.enum';
import { CollectionItem } from 'src/app/data/interfaces/collection';
@Component({
@@ -29,6 +30,7 @@ export class ImageHolderComponent implements OnChanges {
@Input() selectionMode: CollectionItem;
isDeleteVisible: boolean;
+ checkedUrl: string;
@Output() onDelete = new EventEmitter();
@Output() onCancel = new EventEmitter();
@@ -36,6 +38,9 @@ export class ImageHolderComponent implements OnChanges {
ngOnChanges(changes: SimpleChanges): void {
if (changes.item?.currentValue) {
+ this.checkedUrl =
+ this.item?.error && this.item?.error.includes(UploadImageErrors.InvalidFileType) ? 'assets/img/plug-image.svg' : this.item.url;
+
this.isDeleteVisible =
this.item.status === CircleLoadingProgressEnum.Uploaded || this.item.status === CircleLoadingProgressEnum.Failed;
}
diff --git a/ui/src/app/store/manage-collectiom/effects.ts b/ui/src/app/store/manage-collectiom/effects.ts
index cf60f381e3..8a0ca98a4c 100644
--- a/ui/src/app/store/manage-collectiom/effects.ts
+++ b/ui/src/app/store/manage-collectiom/effects.ts
@@ -63,6 +63,8 @@ import { selectCurrentApiKey } from '../model/selectors';
import { SubjectModeEnum } from 'src/app/data/enums/subject-mode.enum';
import { CollectionItem } from 'src/app/data/interfaces/collection';
import { selectMaxFileSize } from '../image-size/selectors';
+import { AVAILABLE_IMAGE_EXTENSIONS } from 'src/app/core/constants';
+import { UploadImageErrors } from 'src/app/data/enums/upload-image-errors.enum';
@Injectable()
export class CollectionEffects {
@@ -185,7 +187,12 @@ export class CollectionEffects {
const resSubject = new Subject<{ file: File; url: string; subject: string }>();
fileReader.onload = e => {
- const url = e.target.result as string;
+ let url = e.target.result as string;
+ const fileExtension = file.name.split('.').pop().toLowerCase();
+
+ if (!AVAILABLE_IMAGE_EXTENSIONS.includes(fileExtension)) {
+ url += new Date().getTime();
+ }
if (fileUrls.indexOf(url) !== -1) return;
@@ -247,10 +254,10 @@ export class CollectionEffects {
const type = /(\/jpg|\/jpeg|\/webp|\/png)$/i;
if (sizeInBytes && file.size > sizeInBytes) {
- return of(uploadImageFail({ error: `Invalid File Size ! \n File Name: ${file.name}`, item, continueUpload }));
+ return of(uploadImageFail({ error: `${UploadImageErrors.InvalidFileSize}! \n File Name: ${file.name}`, item, continueUpload }));
}
if (!ext.exec(file.name) || !type.exec(file.type)) {
- return of(uploadImageFail({ error: `Invalid File Type ! \n File Name: ${file.name}`, item, continueUpload }));
+ return of(uploadImageFail({ error: `${UploadImageErrors.InvalidFileType}! \n File Name: ${file.name}`, item, continueUpload }));
}
return this.collectionService.uploadSubjectExamples(item, subject, apiKey).pipe(
diff --git a/ui/src/assets/img/plug-image.svg b/ui/src/assets/img/plug-image.svg
new file mode 100644
index 0000000000..dfd9eb863a
--- /dev/null
+++ b/ui/src/assets/img/plug-image.svg
@@ -0,0 +1,3 @@
+