Skip to content

Commit

Permalink
add toastr error && fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
HamoudaAmine committed May 16, 2019
1 parent 70aee11 commit 1c2c02d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ <h5 class="modal-title">{{title}} </h5>
<ngb-alert class='alert' *ngIf="alert" [dismissible]="false" type="danger">{{alert}}</ngb-alert>
<div class="custom-control custom-checkbox">
<input type="checkbox" formControlName='main_photo' class="custom-control-input" id="customCheck1">
<label class="custom-control-label" for="customCheck1">Photo affichée dans la gallerie</label>
<label class="custom-control-label" for="customCheck1">Photo affichée dans la galerie</label>
</div>
</div>
<div class="modal-footer">
Expand Down
9 changes: 7 additions & 2 deletions front-backOffice/src/app/add-photo/add-photo.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class AddPhotoComponent implements OnInit {
private modalRef: NgbModalRef;
disableButton = false;
btn_text = 'Ajouter';
title = 'Ajouter une Photo';
title = 'Ajouter une photo';
alert: any;
@Output() photoModal = new EventEmitter();
@Input() inputImage = null;
Expand Down Expand Up @@ -90,7 +90,7 @@ export class AddPhotoComponent implements OnInit {
this.licences = results[0];
this.authors = results[1];
if (this.inputImage) {
this.title = 'Modifier la Photo';
this.title = 'Modifier la photo';
this.btn_text = 'Modifier';
this.updateForm();
} else {
Expand Down Expand Up @@ -179,6 +179,7 @@ export class AddPhotoComponent implements OnInit {
photoForm.value.path_file_photo = this.imageName;
if (/\s/.test(this.imageName)) {
this.alert = 'Le nom de la photo ne doit pas contenir des espaces ';
this.disableButton = false;
} else {
if (this.inputImage) {
this.spinner.show();
Expand Down Expand Up @@ -233,6 +234,8 @@ export class AddPhotoComponent implements OnInit {
this.router.navigate(['']);
this.toastr.error('votre session est expirée', '', { positionClass: 'toast-bottom-right' });
}
else
this.toastr.error("Une erreur est survenue sur le serveur.", '', { positionClass: 'toast-bottom-right' });
}
);
}
Expand Down Expand Up @@ -262,6 +265,8 @@ export class AddPhotoComponent implements OnInit {
this.router.navigate(['']);
this.toastr.error('votre session est expirée', '', { positionClass: 'toast-bottom-right' });
}
else
this.toastr.error("Une erreur est survenue sur le serveur.", '', { positionClass: 'toast-bottom-right' });
},
() => {
this.photoModal.emit(this.inputImage.t_site);
Expand Down
15 changes: 14 additions & 1 deletion front-backOffice/src/app/add-site/add-site.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export class AddSiteComponent implements OnInit, OnDestroy {
this.siteJson.path_file_guide_site = path_file_guide_site;
this.uploadNotice();
this.spinner.show();
console.log('spinner');
if (!this.id_site) {
this.sitesService.addSite(this.siteJson).subscribe(
(site) => {
Expand All @@ -250,6 +251,9 @@ export class AddSiteComponent implements OnInit, OnDestroy {
this.router.navigate(['']);
this.toastr.error('votre session est expirée', '', { positionClass: 'toast-bottom-right' });
}
else {
this.toastr.error("Une erreur est survenue sur le serveur.", '', { positionClass: 'toast-bottom-right' });
}
}
);
} else {
Expand Down Expand Up @@ -369,6 +373,8 @@ export class AddSiteComponent implements OnInit, OnDestroy {
this.router.navigate(['']);
this.toastr.error('votre session est expirée', '', { positionClass: 'toast-bottom-right' });
}
else
this.toastr.error("Une erreur est survenue sur le serveur.", '', { positionClass: 'toast-bottom-right' });
}
);
}
Expand All @@ -389,7 +395,10 @@ export class AddSiteComponent implements OnInit, OnDestroy {
this.photos.push({ 'id_photo': photo.id_photo, 'imgUrl': Conf.staticPicturesUrl + photo.sm, 'name': photo.path_file_photo });
});
},
(err) => console.log('err', err),
(err) => {
console.log('err', err);
this.toastr.error("Une erreur est survenue sur le serveur.", '', { positionClass: 'toast-bottom-right' });
},
() => {
this.initMarker(this.site.geom[0], this.site.geom[1]);
this.patchForm();
Expand Down Expand Up @@ -494,6 +503,8 @@ export class AddSiteComponent implements OnInit, OnDestroy {
this.router.navigate(['']);
this.toastr.error('votre session est expirée', '', { positionClass: 'toast-bottom-right' });
}
else
this.toastr.error("Une erreur est survenue sur le serveur.", '', { positionClass: 'toast-bottom-right' });
}
);
}
Expand Down Expand Up @@ -558,6 +569,8 @@ export class AddSiteComponent implements OnInit, OnDestroy {
this.router.navigate(['']);
this.toastr.error('votre session est expirée', '', { positionClass: 'toast-bottom-right' });
}
else
this.toastr.error("Une erreur est survenue sur le serveur.", '', { positionClass: 'toast-bottom-right' });
}
);
this.modalRef.close();
Expand Down
9 changes: 6 additions & 3 deletions front-backOffice/src/app/gallery/gallery.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export class GalleryComponent implements OnInit {
},
(error) => {
this.spinner.hide();
console.log('getGallery error', error)
console.log('getGallery error', error);
this.toastr.error("Une erreur est survenue sur le serveur.", '', { positionClass: 'toast-bottom-right' });
},
);

Expand All @@ -60,7 +61,8 @@ export class GalleryComponent implements OnInit {
this.spinner.hide();
},
(error) => {
console.log('getPhotosSite error', error)
console.log('getPhotosSite error', error);
this.toastr.error("Une erreur est survenue sur le serveur.", '', { positionClass: 'toast-bottom-right' });
this.spinner.hide();
}
);
Expand All @@ -86,7 +88,8 @@ export class GalleryComponent implements OnInit {
if (err.status === 403) {
this.router.navigate(['']);
this.toastr.error('votre session est expirée', '', { positionClass: 'toast-bottom-right' });
}
} else
this.toastr.error("Une erreur est survenue sur le serveur.", '', { positionClass: 'toast-bottom-right' });
},
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Conf } from './../config';
import { Router } from '@angular/router';
import * as L from 'leaflet';
import { NgxSpinnerService } from 'ngx-spinner';
import { ToastrService } from 'ngx-toastr';

@Component({
selector: 'app-manage-sites',
Expand All @@ -32,6 +33,7 @@ export class ManageSitesComponent implements OnInit, OnDestroy {
protected router: Router,
private changeDetector: ChangeDetectorRef,
private spinner: NgxSpinnerService,
private toastr: ToastrService,
private zone: NgZone) {
}

Expand Down Expand Up @@ -107,6 +109,7 @@ export class ManageSitesComponent implements OnInit, OnDestroy {
},
(err) => {
this.spinner.hide();
this.toastr.error("Une erreur est survenue sur le serveur.", '', { positionClass: 'toast-bottom-right' });
console.log('get site error: ', err)},
);
}
Expand Down

0 comments on commit 1c2c02d

Please sign in to comment.