Skip to content

Commit

Permalink
feature(publish): #535 display error message
Browse files Browse the repository at this point in the history
  • Loading branch information
ds-mmaul committed Jan 25, 2024
1 parent fbf871a commit dfbb21f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 34 deletions.
50 changes: 25 additions & 25 deletions frontend/src/app/modules/page/parts/presentation/parts.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,27 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

import { AfterViewInit, Component, OnDestroy, OnInit, QueryList, ViewChildren } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { Pagination } from '@core/model/pagination.model';
import { RoleService } from '@core/user/role.service';
import { PartsFacade } from '@page/parts/core/parts.facade';
import { resetMultiSelectionAutoCompleteComponent } from '@page/parts/core/parts.helper';
import { MainAspectType } from '@page/parts/model/mainAspectType.enum';
import { AssetAsBuiltFilter, AssetAsPlannedFilter, Part } from '@page/parts/model/parts.model';
import { BomLifecycleSize } from '@shared/components/bom-lifecycle-activator/bom-lifecycle-activator.model';
import { TableType } from '@shared/components/multi-select-autocomplete/table-type.model';
import { PartsTableComponent } from '@shared/components/parts-table/parts-table.component';
import { TableEventConfig, TableHeaderSort } from '@shared/components/table/table.model';
import { ToastService } from '@shared/components/toasts/toast.service';
import { toAssetFilter, toGlobalSearchAssetFilter } from '@shared/helper/filter-helper';
import { NotificationType } from '@shared/model/notification.model';
import { View } from '@shared/model/view.model';
import { PartDetailsFacade } from '@shared/modules/part-details/core/partDetails.facade';
import { BomLifecycleSettingsService, UserSettingView } from '@shared/service/bom-lifecycle-settings.service';
import { StaticIdService } from '@shared/service/staticId.service';
import { BehaviorSubject, combineLatest, Observable, Subject } from 'rxjs';
import { map } from 'rxjs/operators';
import {AfterViewInit, Component, OnDestroy, OnInit, QueryList, ViewChildren} from '@angular/core';
import {FormControl, FormGroup} from '@angular/forms';
import {Pagination} from '@core/model/pagination.model';
import {RoleService} from '@core/user/role.service';
import {PartsFacade} from '@page/parts/core/parts.facade';
import {resetMultiSelectionAutoCompleteComponent} from '@page/parts/core/parts.helper';
import {MainAspectType} from '@page/parts/model/mainAspectType.enum';
import {AssetAsBuiltFilter, AssetAsPlannedFilter, Part} from '@page/parts/model/parts.model';
import {BomLifecycleSize} from '@shared/components/bom-lifecycle-activator/bom-lifecycle-activator.model';
import {TableType} from '@shared/components/multi-select-autocomplete/table-type.model';
import {PartsTableComponent} from '@shared/components/parts-table/parts-table.component';
import {TableEventConfig, TableHeaderSort} from '@shared/components/table/table.model';
import {ToastService} from '@shared/components/toasts/toast.service';
import {toAssetFilter, toGlobalSearchAssetFilter} from '@shared/helper/filter-helper';
import {NotificationType} from '@shared/model/notification.model';
import {View} from '@shared/model/view.model';
import {PartDetailsFacade} from '@shared/modules/part-details/core/partDetails.facade';
import {BomLifecycleSettingsService, UserSettingView} from '@shared/service/bom-lifecycle-settings.service';
import {StaticIdService} from '@shared/service/staticId.service';
import {BehaviorSubject, combineLatest, Observable, Subject} from 'rxjs';
import {map} from 'rxjs/operators';


@Component({
Expand Down Expand Up @@ -136,11 +136,11 @@ export class PartsComponent implements OnInit, OnDestroy, AfterViewInit {

}

refreshPartsOnPublish(success: boolean) {
if(!success) {
this.toastService.error("Failed to publish Assets");
refreshPartsOnPublish(message: string) {
if(message) {
this.toastService.error(message);
} else {
this.toastService.success("Request to publish Assets was successful")
this.toastService.success("requestPublishAssets.success")
this.partsFacade.setPartsAsBuilt();
this.partsFacade.setPartsAsPlanned();
this.partsTableComponents.map(component => component.clearAllRows())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { FormControl, Validators } from '@angular/forms';
import { ImportState, Part } from '@page/parts/model/parts.model';
import { Policy } from '@page/policies/model/policy.model';
import { PolicyService } from '@shared/service/policy.service';
import { Observable, Subscription } from 'rxjs';
import {Component, EventEmitter, Input, Output} from '@angular/core';
import {FormControl, Validators} from '@angular/forms';
import {ImportState, Part} from '@page/parts/model/parts.model';
import {Policy} from '@page/policies/model/policy.model';
import {PolicyService} from '@shared/service/policy.service';
import {Observable, Subscription} from 'rxjs';

@Component({
selector: 'app-asset-publisher',
Expand All @@ -16,7 +16,7 @@ export class AssetPublisherComponent {
@Input() isOpen: Observable<boolean>;
isOpenSubscription: Subscription;

@Output() submitted = new EventEmitter<boolean>();
@Output() submitted = new EventEmitter<string>();

policiesSubscription: Subscription;
policiesList: Policy[] = [];
Expand Down Expand Up @@ -49,8 +49,8 @@ export class AssetPublisherComponent {
this.policyFormControl.reset();
this.selectedAssets = [];
this.policyService.publishAssets(selectedAssetIds, this.policyFormControl.value).subscribe({
next: data => {this.submitted.emit(true);},
error: error => {this.submitted.emit(false);}
next: data => {this.submitted.emit(null);},
error: error => {this.submitted.emit(error);}
});

}
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/assets/locales/de/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@
"severity": "Gefahrenstufe",
"severityDescription": "Wählen Sie die Gefahrenstufe für das vorliegende Problem"
},
"requestPublishAssets": {
"success": "Anfrage zur Veröffentlichung der Produkte war erfolgreich",
"error": ""
},
"pagination": {
"itemsPerPageLabel": "Artikel pro Seite:",
"nextPageLabel": "Nächsten Seite",
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/assets/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@
"severity": "Severity",
"severityDescription": "Select the severity for the problem at hand"
},
"requestPublishAssets": {
"success": "Request to publish assets was successful",
"error": ""
},
"pagination": {
"itemsPerPageLabel": "Items per page:",
"nextPageLabel": "Next page",
Expand Down

0 comments on commit dfbb21f

Please sign in to comment.