|
|
@ -172,7 +172,7 @@ export class EditPinPopupComponent implements OnInit, OnDestroy {
|
|
|
|
if (files.length > 0) {
|
|
|
|
if (files.length > 0) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const data = await this.exifService.getLocation(files[0]);
|
|
|
|
const data = await this.exifService.getLocation(files[0]);
|
|
|
|
if (data.latitude !== undefined && data.longitude !== undefined) {
|
|
|
|
if (data && data.latitude !== undefined && data.longitude !== undefined) {
|
|
|
|
this.autocompleteService.getAddressFromCoordinates(data.latitude, data.longitude).subscribe((address) => {
|
|
|
|
this.autocompleteService.getAddressFromCoordinates(data.latitude, data.longitude).subscribe((address) => {
|
|
|
|
if (address) {
|
|
|
|
if (address) {
|
|
|
|
this.form.get('location')?.setValue(address.display_name);
|
|
|
|
this.form.get('location')?.setValue(address.display_name);
|
|
|
@ -198,7 +198,7 @@ export class EditPinPopupComponent implements OnInit, OnDestroy {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (this.form.valid) {
|
|
|
|
if (this.form.valid) {
|
|
|
|
const uploadObservables = this.files.map(async (file) => {
|
|
|
|
const uploadObservables = await Promise.all(this.files.map(async (file) => {
|
|
|
|
if(file.size === 0) {
|
|
|
|
if(file.size === 0) {
|
|
|
|
if(file.name.includes("|")) {
|
|
|
|
if(file.name.includes("|")) {
|
|
|
|
return of({id: file.name.split("|")[1]});
|
|
|
|
return of({id: file.name.split("|")[1]});
|
|
|
@ -208,10 +208,10 @@ export class EditPinPopupComponent implements OnInit, OnDestroy {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const pictureExifDate = await this.exifService.getDateTime(file);
|
|
|
|
let fileDate = await this.exifService.getDateTime(file);
|
|
|
|
|
|
|
|
|
|
|
|
return this.imageService.postImage(file, pictureExifDate).pipe(
|
|
|
|
return this.imageService.postImage(file, fileDate).pipe(
|
|
|
|
catchError(error => {
|
|
|
|
catchError(async error => {
|
|
|
|
this.uploadError = file.name + ' : ' + error.error.detail || 'Erreur lors de l\'upload de l\'image';
|
|
|
|
this.uploadError = file.name + ' : ' + error.error.detail || 'Erreur lors de l\'upload de l\'image';
|
|
|
|
if (this.dragDropComponent) {
|
|
|
|
if (this.dragDropComponent) {
|
|
|
|
this.dragDropComponent.errorMessage = this.uploadError;
|
|
|
|
this.dragDropComponent.errorMessage = this.uploadError;
|
|
|
@ -219,9 +219,9 @@ export class EditPinPopupComponent implements OnInit, OnDestroy {
|
|
|
|
return of(null);
|
|
|
|
return of(null);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
)
|
|
|
|
)
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
forkJoin(uploadObservables).subscribe((responses) => {
|
|
|
|
forkJoin(uploadObservables).subscribe(async (responses) => {
|
|
|
|
// Vérifier si toutes les réponses sont valides
|
|
|
|
// Vérifier si toutes les réponses sont valides
|
|
|
|
if (responses.some(response => response === null)) {
|
|
|
|
if (responses.some(response => response === null)) {
|
|
|
|
return; // Ne pas continuer si une erreur s'est produite
|
|
|
|
return; // Ne pas continuer si une erreur s'est produite
|
|
|
@ -295,12 +295,6 @@ export class EditPinPopupComponent implements OnInit, OnDestroy {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getFileNames(): string[] {
|
|
|
|
getFileNames(): string[] {
|
|
|
|
return this.files.map(file => {
|
|
|
|
return this.files.map((file) => file.name ? file.name.split("|")[0] : '');
|
|
|
|
if(typeof file === 'string') {
|
|
|
|
|
|
|
|
return file;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return file.name.split("|")[0];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|