Commit 73778786 authored by Michail Tzanatos's avatar Michail Tzanatos
Browse files

improved error displays with toastr

parent 9c9279f7
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ export class AssignServiceSpecificationComponent implements OnInit {
        this.dataSource.data = this.selectedSpecs;
        this.dataSource.sort = this.sort;
      },
      error => console.error(error)
    error => this.toast.error('Failed to fetch Service Specifications', error)
    );
  }

@@ -160,7 +160,6 @@ export class AssignServiceSpecificationComponent implements OnInit {
      });

      dialogRef.afterClosed().subscribe(result => {
        console.log(result);
        this.executeAssignment(result);
      });
    }
@@ -254,7 +253,6 @@ export class AssignServiceSpecificationComponent implements OnInit {
        }
      },
      error => {
        console.error('Update failed', error);
        this.toast.error('Failed to update Product Specification');
      }
    );
@@ -305,7 +303,6 @@ export class AssignServiceSpecificationComponent implements OnInit {
    }).subscribe(
      data => {}, 
      error => {
        console.error(error);
        this.toast.warning('Service assigned, but failed to clean up auto-assigned characteristics.');
        this.dialogRef.close('updated'); 
      },
+4 −2
Original line number Diff line number Diff line
import { trigger } from "@angular/animations";
import { Component, Inject, OnInit } from "@angular/core";
import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog";
import { Toast, ToastrService } from "ngx-toastr";
import { ProductSpecification, ProductSpecificationCharacteristicRes, ProductSpecificationUpdate } from "src/app/openApis/productCatalogManagement/models";
import { ProductSpecificationService } from "src/app/openApis/productCatalogManagement/services";
import { fadeIn, simpleFade } from "src/app/shared/animations/animations";
@@ -20,7 +21,8 @@ export class DeleteProductSpecCharacteristicsComponent implements OnInit {
        specToBeDeleted: ProductSpecificationCharacteristicRes
        },
        private dialogRef: MatDialogRef<DeleteProductSpecCharacteristicsComponent>,
        private specService: ProductSpecificationService
        private specService: ProductSpecificationService,
        private toast: ToastrService
    ) { }

    ngOnInit() {
@@ -34,7 +36,7 @@ export class DeleteProductSpecCharacteristicsComponent implements OnInit {

        this.specService.patchProductSpecification({ id: this.data.productSpec.id, productSpecification: updateSpecObj }).subscribe(
        data => {},
        error => console.error(error),
        error => this.toast.error("An error occurred while deleting the Product Specification Characteristic"),
        () => this.dialogRef.close('deleted')
        )
    }
+1 −5
Original line number Diff line number Diff line
@@ -192,18 +192,14 @@ export class EditProductSpecCharacteristicsComponent implements OnInit {
            const updateCharacteristIndex = this.data.productSpec.productSpecCharacteristic.findIndex(char => char.uuid === this.data.specToBeUpdated.uuid)
            this.data.productSpec.productSpecCharacteristic[updateCharacteristIndex] = this.editFormCharacteristic.getRawValue()
        }
        console.log(this.newSpec);
        console.log(this.data.productSpec);

        const updateCharacteristicObj: ProductSpecificationUpdate = {
            productSpecCharacteristic: this.data.productSpec.productSpecCharacteristic
        }

        // console.log(updateCharacteristicObj);

        this.specService.patchProductSpecification({ id: this.data.productSpec.id, productSpecification: updateCharacteristicObj }).subscribe(
            data => { },
            error => { console.error(error); this.toast.error("An error occurred upon updating Spec Characteristics") },
            error => this.toast.error("An error occurred upon updating Spec Characteristics"),
            () => { this.dialogRef.close('updated') }
        )
    }
+11 −5
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ export class EditProductSpecsComponent implements OnInit {
  retrieveProductSpec() {
    this.specService.retrieveProductSpecification({id: this.specID}).subscribe(
      data => this.spec = data,
      error => {console.error(error), this.toast.error("An error occurred while loading Product Specification")},
      error => this.toast.error("An error occurred while loading Product Specification"),
      () => {
        if (this.spec) {
          this.finishedLoading = true
@@ -193,7 +193,7 @@ export class EditProductSpecsComponent implements OnInit {
      if (this.newSpecification) {
        this.specService.createProductSpecification(updateObj).subscribe(
          data => { updatedSpec = data },
          error => console.error(error),
          error => this.toast.error("An error occurred while creating the Product Specification"),
          () => {
            this.newSpecification = false
            this.toast.success("Product Specification was successfully created")
@@ -204,7 +204,7 @@ export class EditProductSpecsComponent implements OnInit {
      else {
        this.specService.patchProductSpecification({ id: this.specID, productSpecification: updateObj }).subscribe(
          data => { updatedSpec = data },
          error => console.error(error),
          error => this.toast.error("An error occurred while updating the Product Specification"),
          () => {
            this.toast.success("Product Specification was successfully updated")
            this.refreshProductSpecification(updatedSpec)
@@ -243,7 +243,7 @@ export class EditProductSpecsComponent implements OnInit {

    this.specService.patchProductSpecification({id: this.spec.id, productSpecification: updateCharacteristicObj}).subscribe(
      data => {},
      error => console.error(error),
      error => this.toast.error("An error occurred while cloning the Product Specification Characteristic"),
      () => {
        this.toast.success("Product Specification Characteristics list was successfully updated");
        this.retrieveProductSpec();
@@ -275,9 +275,12 @@ export class EditProductSpecsComponent implements OnInit {
    dialogRef.afterClosed().subscribe (
      result => { 
        if (result){ 
          this.toast.success("Product Specification Characteristics list was successfully updated")
          this.toast.success("Product Specification Characteristics list was successfully updated");
          this.retrieveProductSpec()
        }
        else {
          this.toast.error("An error occurred while updating Product Specification Characteristics list");
        }
      }
    )
  }
@@ -297,6 +300,9 @@ export class EditProductSpecsComponent implements OnInit {
          this.toast.success("Product Specification Characteristics list was successfully updated");
          this.retrieveProductSpec();
        }
        else {
          this.toast.error("An error occurred while updating Product Specification Characteristics list");
        }
      }
    )
  }