From 7359d7a2a5bbc3190f43a483fa36e86d9593885b Mon Sep 17 00:00:00 2001 From: mk Date: Wed, 24 May 2023 13:54:53 +0200 Subject: [PATCH 01/12] chore(uml):[TRACEFOSS-1423] rename assets to aspectmodels and add entities for Batch and SerialPartTypization --- .../concept/TRACEFOSS-1423/domain-model.puml | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml b/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml index cf1cffe11d..5343776831 100644 --- a/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml +++ b/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml @@ -2,12 +2,10 @@ title: Domain Model -abstract Asset { +abstract AspectModel { * id : String idShort : String - partInstanceId : String manufacturerId : String - batchId : String * private final Owner owner; manufacturerName : String childRelations : List @@ -15,8 +13,6 @@ abstract Asset { underInvestigation : boolean qualityType : QualityType van : String - semanticDataModel: enum - abstract SemanticDataModel : getSemanticDataModel() } note left @@ -30,34 +26,34 @@ entity Relation { } -entity AsBuiltAsset { +entity AsBuiltAspectModel { manufacturingDate : Instant manufacturingCountry : String manufacturerPartId : String customerPartId : String nameAtManufacturer : String nameAtCustomer : String - - AspectType : aspectType() } -note right - SerialPartTypization and Batch -end note +entity SerialPartTypization { + partInstanceId : String + getSemanticDataModel() +} -enum SemanticDataModel { - BATCH, - SERIALPARTTYPIZATION +entity Batch { + batchId : String + getSemanticDataModel() } -entity AsPlannedAsset { +entity AsPlannedAspectModel { } -Asset --> SemanticDataModel -Asset <|.. AsBuiltAsset -Asset <|.. AsPlannedAsset -Asset }o--- Relation : childRelations -Asset }o--- Relation : parentRelations +AspectModel <|.. AsBuiltAspectModel +AspectModel <|.. AsPlannedAspectModel +AsBuiltAspectModel <|.. Batch +AsBuiltAspectModel <|.. SerialPartTypization +AspectModel }o--- Relation : childRelations +AspectModel }o--- Relation : parentRelations @enduml From 4687e88f0834c0e45502f5ff9fc5c51d345751f2 Mon Sep 17 00:00:00 2001 From: mk Date: Wed, 24 May 2023 17:36:39 +0200 Subject: [PATCH 02/12] chore(uml):[TRACEFOSS-1423] update to as planned --- .../concept/TRACEFOSS-1423/domain-model.puml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml b/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml index 5343776831..6dfcd82586 100644 --- a/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml +++ b/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml @@ -2,6 +2,7 @@ title: Domain Model + abstract AspectModel { * id : String idShort : String @@ -11,6 +12,7 @@ abstract AspectModel { childRelations : List parentRelations : List underInvestigation : boolean + activeAlert: boolean qualityType : QualityType van : String abstract SemanticDataModel : getSemanticDataModel() @@ -26,7 +28,7 @@ entity Relation { } -entity AsBuiltAspectModel { +abstract AsBuiltAspectModel { manufacturingDate : Instant manufacturingCountry : String manufacturerPartId : String @@ -37,22 +39,25 @@ entity AsBuiltAspectModel { entity SerialPartTypization { partInstanceId : String - getSemanticDataModel() + getSemanticDataModel() } entity Batch { batchId : String - getSemanticDataModel() + getSemanticDataModel() } -entity AsPlannedAspectModel { +abstract AsPlannedAspectModel { } + AspectModel <|.. AsBuiltAspectModel AspectModel <|.. AsPlannedAspectModel AsBuiltAspectModel <|.. Batch AsBuiltAspectModel <|.. SerialPartTypization +AsPlannedAspectModel <|.. Batch +AsPlannedAspectModel <|.. SerialPartTypization AspectModel }o--- Relation : childRelations AspectModel }o--- Relation : parentRelations From c8642fed2c0ca427a702ded3c0d868aa47d2070c Mon Sep 17 00:00:00 2001 From: mk Date: Thu, 25 May 2023 11:42:19 +0200 Subject: [PATCH 03/12] chore(uml):[TRACEFOSS-1423] rename AspectModel to Asset --- .../concept/TRACEFOSS-1423/domain-model.puml | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml b/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml index 6dfcd82586..9c13008d19 100644 --- a/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml +++ b/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml @@ -3,7 +3,7 @@ title: Domain Model -abstract AspectModel { +abstract Asset { * id : String idShort : String manufacturerId : String @@ -12,9 +12,10 @@ abstract AspectModel { childRelations : List parentRelations : List underInvestigation : boolean - activeAlert: boolean + activeAlert: boolean qualityType : QualityType van : String + abstract String : getSemanticDataModelId() abstract SemanticDataModel : getSemanticDataModel() } note left @@ -27,8 +28,13 @@ entity Relation { idShort : String } +enum SemanticModelType { + SERIALPARTTYPIZATION, + BATCH +} + -abstract AsBuiltAspectModel { +entity AsBuiltAspectModel { manufacturingDate : Instant manufacturingCountry : String manufacturerPartId : String @@ -39,26 +45,34 @@ abstract AsBuiltAspectModel { entity SerialPartTypization { partInstanceId : String - getSemanticDataModel() + String: getSemanticDataModelId() return partInstanceId + SemanticModelType: getSemanticDataModel() } entity Batch { batchId : String - getSemanticDataModel() + String: getSemanticDataModelId() return batchId + SemanticModelType: getSemanticDataModel() } -abstract AsPlannedAspectModel { - +entity AsPlannedAspectModel { + manufacturingDate : Instant + manufacturingCountry : String + manufacturerPartId : String + customerPartId : String + nameAtManufacturer : String + nameAtCustomer : String } -AspectModel <|.. AsBuiltAspectModel -AspectModel <|.. AsPlannedAspectModel +SemanticModelType --> Asset +Asset <|.. AsBuiltAspectModel +Asset <|.. AsPlannedAspectModel AsBuiltAspectModel <|.. Batch AsBuiltAspectModel <|.. SerialPartTypization AsPlannedAspectModel <|.. Batch AsPlannedAspectModel <|.. SerialPartTypization -AspectModel }o--- Relation : childRelations -AspectModel }o--- Relation : parentRelations +Asset }o--- Relation : childRelations +Asset }o--- Relation : parentRelations @enduml From 88406b8af9a46a58b5f752ec0ee62c9cac967e18 Mon Sep 17 00:00:00 2001 From: ds-lcapellino Date: Wed, 16 Aug 2023 16:27:40 +0200 Subject: [PATCH 04/12] feature: TRACEFOSS-XXX fix Oauth beans --- .../configuration/EdcRestTemplateConfiguration.java | 1 - 1 file changed, 1 deletion(-) diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/configuration/EdcRestTemplateConfiguration.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/configuration/EdcRestTemplateConfiguration.java index 6e03cbd497..53e1153b72 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/configuration/EdcRestTemplateConfiguration.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/configuration/EdcRestTemplateConfiguration.java @@ -88,7 +88,6 @@ private RestTemplateBuilder oAuthRestTemplate(final RestTemplateBuilder restTemp new OAuthClientCredentialsRestTemplateInterceptor(authorizedClientManager(), clientRegistration)); } - @Bean /* package */ OAuth2AuthorizedClientManager authorizedClientManager() { final var authorizedClientProvider = OAuth2AuthorizedClientProviderBuilder.builder() .clientCredentials() From 463fc68820441345605bc9e2b8390f8be2fb0179 Mon Sep 17 00:00:00 2001 From: mk Date: Thu, 17 Aug 2023 09:20:28 +0200 Subject: [PATCH 05/12] fix(diagram):[TRACEFOSS-1423] fix review comments --- .../concept/TRACEFOSS-1423/domain-model.puml | 51 ++++++++++++++++--- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml b/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml index 9c13008d19..40397882c6 100644 --- a/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml +++ b/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml @@ -14,6 +14,7 @@ abstract Asset { underInvestigation : boolean activeAlert: boolean qualityType : QualityType + classification : String van : String abstract String : getSemanticDataModelId() abstract SemanticDataModel : getSemanticDataModel() @@ -29,21 +30,23 @@ entity Relation { } enum SemanticModelType { - SERIALPARTTYPIZATION, - BATCH + SERIALPART, + BATCH, + JUSTINSEQUENCEPART, + TRACTIONBATTERYCODE } entity AsBuiltAspectModel { manufacturingDate : Instant - manufacturingCountry : String + manufacturingCountry : String (iso-3) manufacturerPartId : String customerPartId : String nameAtManufacturer : String nameAtCustomer : String } -entity SerialPartTypization { +entity SerialPart { partInstanceId : String String: getSemanticDataModelId() return partInstanceId SemanticModelType: getSemanticDataModel() @@ -55,6 +58,35 @@ entity Batch { SemanticModelType: getSemanticDataModel() } +entity JustInSequencePart { + jisNumber : String + String: getSemanticDataModelId() return jisNumber + SemanticModelType: getSemanticDataModel() +} + +entity TractionBatteryCode { + productType: String + tractionBatteryCode: String + subComponents : List +} + +entity PartAsPlanned { +/' + 1.0.0 +'/ + validityPeriodFrom : Instance + validityPeriodTo: Instance +} + +entity PartSiteInformationAsPlanned { +/' + 1.0.0 + Currently this is not ready for implementing - there is no specification right now. +'/ + functionValidFrom : Instance + functionValidUntil : Instance +} + entity AsPlannedAspectModel { manufacturingDate : Instant manufacturingCountry : String @@ -64,14 +96,17 @@ entity AsPlannedAspectModel { nameAtCustomer : String } - SemanticModelType --> Asset Asset <|.. AsBuiltAspectModel Asset <|.. AsPlannedAspectModel + AsBuiltAspectModel <|.. Batch -AsBuiltAspectModel <|.. SerialPartTypization -AsPlannedAspectModel <|.. Batch -AsPlannedAspectModel <|.. SerialPartTypization +AsBuiltAspectModel <|.. SerialPart +AsBuiltAspectModel <|.. JustInSequencePart + +AsPlannedAspectModel <|.. PartAsPlanned +AsPlannedAspectModel <|.. PartSiteInformationAsPlanned + Asset }o--- Relation : childRelations Asset }o--- Relation : parentRelations From 392df34ef682d09e9577e4160571d334eceabb43 Mon Sep 17 00:00:00 2001 From: mk Date: Thu, 17 Aug 2023 10:56:27 +0200 Subject: [PATCH 06/12] fix(diagram):[TRACEFOSS-1423] added new as planned models --- .../src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml b/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml index 40397882c6..57602fae14 100644 --- a/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml +++ b/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml @@ -33,7 +33,9 @@ enum SemanticModelType { SERIALPART, BATCH, JUSTINSEQUENCEPART, - TRACTIONBATTERYCODE + TRACTIONBATTERYCODE, + PARTASPLANNED, + PARTSITEINFORMATIONASPLANNED } From 1b4ca0fad934ec4e79446b28dd4978b1f94c7d14 Mon Sep 17 00:00:00 2001 From: mk Date: Thu, 17 Aug 2023 12:18:50 +0200 Subject: [PATCH 07/12] fix(diagram):[TRACEFOSS-1423] Update to latest version of sem models --- .../concept/TRACEFOSS-1423/domain-model.puml | 57 +++++++++---------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml b/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml index 57602fae14..3b85fffcd8 100644 --- a/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml +++ b/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml @@ -5,33 +5,36 @@ title: Domain Model abstract Asset { * id : String - idShort : String - manufacturerId : String - * private final Owner owner; - manufacturerName : String + owner : Owner childRelations : List parentRelations : List - underInvestigation : boolean + activeAlert: boolean qualityType : QualityType - classification : String + underInvestigation : boolean + semanticDataModelType : SemanticDataModelType + idShort : String + manufacturerPartId : String /' partTypeInformation.manufacturerPartId '/ + nameAtManufacturer : String /' partTypeInformation.nameAtManufacturer '/ + classification : String /' partTypeInformation.classification '/ + businessPartner : String /' BusinessPartner '/ + abstract String getSemanticDataModelId() van : String - abstract String : getSemanticDataModelId() - abstract SemanticDataModel : getSemanticDataModel() + } + note left Rename Descriptions to Relations end note - entity Relation { * id : String idShort : String } -enum SemanticModelType { - SERIALPART, +enum SemanticDataModelType { BATCH, + SERIALPART, JUSTINSEQUENCEPART, TRACTIONBATTERYCODE, PARTASPLANNED, @@ -40,33 +43,32 @@ enum SemanticModelType { entity AsBuiltAspectModel { - manufacturingDate : Instant - manufacturingCountry : String (iso-3) - manufacturerPartId : String - customerPartId : String - nameAtManufacturer : String - nameAtCustomer : String + manufacturingDate : Instant + manufacturingCountry : String (iso-3) + customerPartId : String + nameAtCustomer : String } entity SerialPart { - partInstanceId : String - String: getSemanticDataModelId() return partInstanceId - SemanticModelType: getSemanticDataModel() + * partInstanceID: String + String: getSemanticDataModelId() return batchId + SemanticModelType.SERIALPART } entity Batch { - batchId : String + * BatchID : String String: getSemanticDataModelId() return batchId - SemanticModelType: getSemanticDataModel() + SemanticModelType.BATCH } entity JustInSequencePart { - jisNumber : String + * jisNumber : String String: getSemanticDataModelId() return jisNumber - SemanticModelType: getSemanticDataModel() + SemanticModelType.JUSTINSEQUENCEPART } entity TractionBatteryCode { + * uuid4 : String /' UUID ID '/ productType: String tractionBatteryCode: String subComponents : List @@ -90,12 +92,6 @@ entity PartSiteInformationAsPlanned { } entity AsPlannedAspectModel { - manufacturingDate : Instant - manufacturingCountry : String - manufacturerPartId : String - customerPartId : String - nameAtManufacturer : String - nameAtCustomer : String } SemanticModelType --> Asset @@ -105,6 +101,7 @@ Asset <|.. AsPlannedAspectModel AsBuiltAspectModel <|.. Batch AsBuiltAspectModel <|.. SerialPart AsBuiltAspectModel <|.. JustInSequencePart +AsBuiltAspectModel <|.. TractionBatteryCode AsPlannedAspectModel <|.. PartAsPlanned AsPlannedAspectModel <|.. PartSiteInformationAsPlanned From f9239890288c5a8149943024c24c0c9cacdf189f Mon Sep 17 00:00:00 2001 From: mk Date: Thu, 17 Aug 2023 12:22:54 +0200 Subject: [PATCH 08/12] fix(diagram):[TRACEFOSS-1423] fix enum name --- docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml b/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml index 3b85fffcd8..2b0e49c11a 100644 --- a/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml +++ b/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml @@ -94,7 +94,7 @@ entity PartSiteInformationAsPlanned { entity AsPlannedAspectModel { } -SemanticModelType --> Asset +SemanticDataModelType --> Asset Asset <|.. AsBuiltAspectModel Asset <|.. AsPlannedAspectModel From cf6afd9eb6f89e50ce1790a2785363da9e6a405b Mon Sep 17 00:00:00 2001 From: mk Date: Thu, 17 Aug 2023 13:06:16 +0200 Subject: [PATCH 09/12] fix(diagram):[TRACEFOSS-1423] change relation to assets --- .../src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml b/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml index 2b0e49c11a..a1d1689f71 100644 --- a/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml +++ b/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml @@ -101,10 +101,10 @@ Asset <|.. AsPlannedAspectModel AsBuiltAspectModel <|.. Batch AsBuiltAspectModel <|.. SerialPart AsBuiltAspectModel <|.. JustInSequencePart -AsBuiltAspectModel <|.. TractionBatteryCode +Asset <|.. TractionBatteryCode AsPlannedAspectModel <|.. PartAsPlanned -AsPlannedAspectModel <|.. PartSiteInformationAsPlanned +Asset <|.. PartSiteInformationAsPlanned Asset }o--- Relation : childRelations Asset }o--- Relation : parentRelations From 9fed5b99f1dcfa55f010a1e23fc599f1e59cfd06 Mon Sep 17 00:00:00 2001 From: mk Date: Thu, 17 Aug 2023 13:33:23 +0200 Subject: [PATCH 10/12] fix(diagram):[TRACEFOSS-1423] Aggregate the different entities --- .../concept/TRACEFOSS-1423/domain-model.puml | 78 ++++++++----------- 1 file changed, 34 insertions(+), 44 deletions(-) diff --git a/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml b/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml index a1d1689f71..049dfb9b22 100644 --- a/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml +++ b/docs/src/uml-diagrams/concept/TRACEFOSS-1423/domain-model.puml @@ -6,28 +6,22 @@ title: Domain Model abstract Asset { * id : String owner : Owner - childRelations : List - parentRelations : List - activeAlert: boolean qualityType : QualityType underInvestigation : boolean semanticDataModelType : SemanticDataModelType + childRelations : List + parentRelations : List + idShort : String - manufacturerPartId : String /' partTypeInformation.manufacturerPartId '/ - nameAtManufacturer : String /' partTypeInformation.nameAtManufacturer '/ - classification : String /' partTypeInformation.classification '/ - businessPartner : String /' BusinessPartner '/ - abstract String getSemanticDataModelId() van : String - } note left Rename Descriptions to Relations end note -entity Relation { +class Relation { * id : String idShort : String } @@ -42,71 +36,67 @@ enum SemanticDataModelType { } -entity AsBuiltAspectModel { - manufacturingDate : Instant - manufacturingCountry : String (iso-3) +class AsBuiltAspectModel { + partId : String /' BatchID , jisNumber , partInstanceID'/ + + manufacturerPartId : String /' partTypeInformation.manufacturerPartId '/ + nameAtManufacturer : String /' partTypeInformation.nameAtManufacturer '/ + classification : String /' partTypeInformation.classification '/ + businessPartner : String /' BusinessPartner '/ + customerPartId : String nameAtCustomer : String -} + manufacturingCountry : String (iso-3) + manufacturingDate : Instant -entity SerialPart { - * partInstanceID: String - String: getSemanticDataModelId() return batchId - SemanticModelType.SERIALPART -} + tractionBatteryCode : TractionBatteryCode -entity Batch { - * BatchID : String - String: getSemanticDataModelId() return batchId - SemanticModelType.BATCH } -entity JustInSequencePart { - * jisNumber : String - String: getSemanticDataModelId() return jisNumber - SemanticModelType.JUSTINSEQUENCEPART -} +note left + partId covers SerialPart.partInstanceID, Batch.BatchID, JustInSequencePart.jisNumber +end note -entity TractionBatteryCode { +class TractionBatteryCode { * uuid4 : String /' UUID ID '/ productType: String tractionBatteryCode: String subComponents : List } -entity PartAsPlanned { +class PartAsPlanned { + manufacturerPartId : String /' partTypeInformation.manufacturerPartId '/ + nameAtManufacturer : String /' partTypeInformation.nameAtManufacturer '/ + classification : String /' partTypeInformation.classification '/ + businessPartner : String /' BusinessPartner '/ /' 1.0.0 '/ validityPeriodFrom : Instance validityPeriodTo: Instance + + partSiteInformationAsPlanned : PartSiteInformationAsPlanned } -entity PartSiteInformationAsPlanned { +class PartSiteInformationAsPlanned { /' 1.0.0 Currently this is not ready for implementing - there is no specification right now. '/ functionValidFrom : Instance functionValidUntil : Instance -} -entity AsPlannedAspectModel { } -SemanticDataModelType --> Asset -Asset <|.. AsBuiltAspectModel -Asset <|.. AsPlannedAspectModel -AsBuiltAspectModel <|.. Batch -AsBuiltAspectModel <|.. SerialPart -AsBuiltAspectModel <|.. JustInSequencePart -Asset <|.. TractionBatteryCode +SemanticDataModelType <-- Asset +Asset <|.. AsBuiltAspectModel +Asset <|.. PartAsPlanned -AsPlannedAspectModel <|.. PartAsPlanned -Asset <|.. PartSiteInformationAsPlanned +Asset }o-- Relation : childRelations +Asset }o-- Relation : parentRelations -Asset }o--- Relation : childRelations -Asset }o--- Relation : parentRelations +AsBuiltAspectModel -- TractionBatteryCode +PartAsPlanned -- PartSiteInformationAsPlanned @enduml From b9630aaa2b084243983f407d0595301739d4e50c Mon Sep 17 00:00:00 2001 From: Maximilian Wesener Date: Fri, 18 Aug 2023 13:00:22 +0200 Subject: [PATCH 11/12] feature: TRACEFOSS-2494 synced startup config from release branch. --- .../config/ApplicationStartupConfig.java | 29 +++++++++++++++++-- .../common/config/SecurityConfig.java | 3 +- tx-backend/src/main/resources/application.yml | 5 ++++ .../config/ApplicationStartupConfigTest.java | 25 ++++++++++++---- 4 files changed, 54 insertions(+), 8 deletions(-) diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/ApplicationStartupConfig.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/ApplicationStartupConfig.java index c4e5eced84..a9ff6b7624 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/ApplicationStartupConfig.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/ApplicationStartupConfig.java @@ -27,8 +27,13 @@ import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; +import java.util.List; import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; +import java.util.concurrent.Executors;import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.controller.model.CreateNotificationContractRequest; +import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.controller.model.NotificationMethod; +import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.controller.model.NotificationType; +import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.EdcNotificationContractService; + @Slf4j @Component @@ -36,6 +41,13 @@ @RequiredArgsConstructor public class ApplicationStartupConfig { private final IrsRepository irsRepository; + private final EdcNotificationContractService edcNotificationContractService; + private static final List NOTIFICATION_CONTRACTS = List.of( + new CreateNotificationContractRequest(NotificationType.QUALITY_ALERT, NotificationMethod.UPDATE), + new CreateNotificationContractRequest(NotificationType.QUALITY_ALERT, NotificationMethod.RECEIVE), + new CreateNotificationContractRequest(NotificationType.QUALITY_INVESTIGATION, NotificationMethod.UPDATE), + new CreateNotificationContractRequest(NotificationType.QUALITY_INVESTIGATION, NotificationMethod.RECEIVE) + ); @EventListener(ApplicationReadyEvent.class) public void registerIrsPolicy() { @@ -51,6 +63,19 @@ public void registerIrsPolicy() { executor.shutdown(); } - + @EventListener(ApplicationReadyEvent.class) + public void createNotificationContracts() { + ExecutorService executor = Executors.newSingleThreadExecutor(); + executor.execute(() -> { + log.info("on ApplicationReadyEvent create notification contracts."); + try { + NOTIFICATION_CONTRACTS.forEach(edcNotificationContractService::handle); + } catch (Exception exception) { + log.error("Failed to create notification contracts: ", exception); + } + log.info("on ApplicationReadyEvent notification contracts created."); + }); + executor.shutdown(); + } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/SecurityConfig.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/SecurityConfig.java index 4110f54ebd..0f63808366 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/SecurityConfig.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/SecurityConfig.java @@ -54,7 +54,8 @@ public class SecurityConfig { "/qualityalerts/update", "/callback/endpoint-data-reference", "/internal/endpoint-data-reference", - "/actuator/**" + "/actuator/**", + "/registry/reload" }; @Value("${jwt.resource-client}") diff --git a/tx-backend/src/main/resources/application.yml b/tx-backend/src/main/resources/application.yml index 3f2b162ae9..5a3dde9d02 100644 --- a/tx-backend/src/main/resources/application.yml +++ b/tx-backend/src/main/resources/application.yml @@ -162,6 +162,11 @@ resilience4j: waitDuration: 30s enableExponentialBackoff: true exponentialBackoffMultiplier: 2 + registry: + maxAttempts: 20 + waitDuration: 10s + enableExponentialBackoff: true + exponentialBackoffMultiplier: 1 irs: policies: diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/common/config/ApplicationStartupConfigTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/common/config/ApplicationStartupConfigTest.java index 0e4755316c..b6233f2224 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/common/config/ApplicationStartupConfigTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/common/config/ApplicationStartupConfigTest.java @@ -20,31 +20,32 @@ package org.eclipse.tractusx.traceability.common.config; import org.eclipse.tractusx.traceability.assets.domain.base.IrsRepository; +import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.EdcNotificationContractService; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) class ApplicationStartupConfigTest { + @InjectMocks private ApplicationStartupConfig applicationStartupConfig; + @Mock + private EdcNotificationContractService edcNotificationContractService; @Mock private IrsRepository irsRepository; - @BeforeEach - void setUp() { - applicationStartupConfig = new ApplicationStartupConfig(irsRepository); - } - @Test void whenCallRegisterIrsPolicy_thenCallRepository() { ExecutorService executor = Executors.newSingleThreadExecutor(); @@ -58,4 +59,18 @@ void whenCallRegisterIrsPolicy_thenCallRepository() { executor.shutdown(); } + + @Test + void whenCallCreateNotificationContracts_thenCallContractService() { + ExecutorService executor = Executors.newSingleThreadExecutor(); + // when + executor.execute(() -> { + applicationStartupConfig.registerIrsPolicy(); + + // then + verify(edcNotificationContractService, times(4)).handle(any()); + }); + + executor.shutdown(); + } } From 7fe064c7bd6e81e1b4d9dcb9fc145cb0fc0f63d4 Mon Sep 17 00:00:00 2001 From: ds-mmaul <117836305+ds-mmaul@users.noreply.github.com> Date: Fri, 18 Aug 2023 13:54:12 +0200 Subject: [PATCH 12/12] chore(UX):[TRACEFOSS-2323] remove black status box (#490) * chore(UX):[TRACEFOSS-2323] remove black status box --- CHANGELOG.md | 1 + .../presentation/about.component.spec.ts | 2 +- .../alerts/detail/alert-detail.component.ts | 6 +-- .../detail/investigation-detail.component.ts | 6 +-- .../cta-snackbar.component.html | 33 ------------ .../cta-snackbar.component.ts | 50 ----------------- .../cta-snackbar.model.ts | 34 ------------ .../cta-snackbar.service.ts | 40 -------------- .../cta-snackbar.spec.ts | 54 ------------------- .../request-alert.component.ts | 6 +-- .../request-investigation.component.ts | 6 +-- .../request-notification.base.spec.ts | 4 +- .../request-notification.base.ts | 23 ++++---- .../toast-container.component.html | 3 +- .../toast-message.component.html | 14 +++-- .../toast-message.component.scss | 34 +++++++----- .../toast-message/toast-message.model.ts | 14 +++-- .../shared/components/toasts/toast.service.ts | 17 +++--- .../shared/components/toasts/toast.spec.ts | 15 ++---- .../src/app/modules/shared/shared.module.ts | 2 - .../src/app/modules/shared/template.module.ts | 3 -- 21 files changed, 87 insertions(+), 280 deletions(-) delete mode 100644 frontend/src/app/modules/shared/components/call-to-action-snackbar/cta-snackbar.component.html delete mode 100644 frontend/src/app/modules/shared/components/call-to-action-snackbar/cta-snackbar.component.ts delete mode 100644 frontend/src/app/modules/shared/components/call-to-action-snackbar/cta-snackbar.model.ts delete mode 100644 frontend/src/app/modules/shared/components/call-to-action-snackbar/cta-snackbar.service.ts delete mode 100644 frontend/src/app/modules/shared/components/call-to-action-snackbar/cta-snackbar.spec.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ff66744af..4525734b5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Logic of commitId retrieval by frontend has changed - Readme / Docker Notice information as required in TRGs - Removed references to GitHub registry and added docker hub for tractusx instead +- Removed UX breaking black status box ### Removed diff --git a/frontend/src/app/modules/page/about/presentation/about.component.spec.ts b/frontend/src/app/modules/page/about/presentation/about.component.spec.ts index 8402fc5c20..e92087f58d 100644 --- a/frontend/src/app/modules/page/about/presentation/about.component.spec.ts +++ b/frontend/src/app/modules/page/about/presentation/about.component.spec.ts @@ -41,7 +41,7 @@ describe('About Page', () => { it('should render about page', async () => { - await renderComponent(AboutComponent, { imports: [AboutModule] }); + await renderComponent(AboutComponent, { imports: [AboutModule], providers: [AboutComponent] }); expect(screen.getByText('pageAbout.content')).toBeInTheDocument(); const componentInstance = TestBed.inject(AboutComponent); diff --git a/frontend/src/app/modules/page/alerts/detail/alert-detail.component.ts b/frontend/src/app/modules/page/alerts/detail/alert-detail.component.ts index ac1647f2ed..950218bc53 100644 --- a/frontend/src/app/modules/page/alerts/detail/alert-detail.component.ts +++ b/frontend/src/app/modules/page/alerts/detail/alert-detail.component.ts @@ -24,9 +24,9 @@ import { AlertDetailFacade } from '@page/alerts/core/alert-detail.facade'; import { AlertHelperService } from '@page/alerts/core/alert-helper.service'; import { AlertsFacade } from '@page/alerts/core/alerts.facade'; import { Part } from '@page/parts/model/parts.model'; -import { CtaSnackbarService } from '@shared/components/call-to-action-snackbar/cta-snackbar.service'; import { NotificationCommonModalComponent } from '@shared/components/notification-common-modal/notification-common-modal.component'; import { CreateHeaderFromColumns, TableConfig, TableEventConfig } from '@shared/components/table/table.model'; +import { ToastService } from '@shared/components/toasts/toast.service'; import { Notification } from '@shared/model/notification.model'; import { TranslationContext } from '@shared/model/translation-context.model'; import { View } from '@shared/model/view.model'; @@ -75,7 +75,7 @@ export class AlertDetailComponent implements AfterViewInit, OnDestroy { private readonly alertsFacade: AlertsFacade, private router: Router, private readonly route: ActivatedRoute, - private readonly ctaSnackbarService: CtaSnackbarService, + private readonly toastService: ToastService, ) { this.alertPartsInformation$ = this.alertDetailFacade.notificationPartsInformation$; this.supplierPartsDetailInformation$ = this.alertDetailFacade.supplierPartsInformation$; @@ -143,7 +143,7 @@ export class AlertDetailComponent implements AfterViewInit, OnDestroy { public copyToClipboard(semanticModelId: string): void { const text = { id: 'clipboard', values: { value: semanticModelId } }; - navigator.clipboard.writeText(semanticModelId).then(_ => this.ctaSnackbarService.show(text)); + navigator.clipboard.writeText(semanticModelId).then(_ => this.toastService.info(text)); } public navigateBackToAlerts(): void { diff --git a/frontend/src/app/modules/page/investigations/detail/investigation-detail.component.ts b/frontend/src/app/modules/page/investigations/detail/investigation-detail.component.ts index 4da6c0cf9a..28796a4397 100644 --- a/frontend/src/app/modules/page/investigations/detail/investigation-detail.component.ts +++ b/frontend/src/app/modules/page/investigations/detail/investigation-detail.component.ts @@ -26,9 +26,9 @@ import { InvestigationDetailFacade } from '@page/investigations/core/investigati import { InvestigationHelperService } from '@page/investigations/core/investigation-helper.service'; import { InvestigationsFacade } from '@page/investigations/core/investigations.facade'; import { Part } from '@page/parts/model/parts.model'; -import { CtaSnackbarService } from '@shared/components/call-to-action-snackbar/cta-snackbar.service'; import { NotificationCommonModalComponent } from '@shared/components/notification-common-modal/notification-common-modal.component'; import { CreateHeaderFromColumns, TableConfig, TableEventConfig } from '@shared/components/table/table.model'; +import { ToastService } from '@shared/components/toasts/toast.service'; import { Notification } from '@shared/model/notification.model'; import { TranslationContext } from '@shared/model/translation-context.model'; import { View } from '@shared/model/view.model'; @@ -77,7 +77,7 @@ export class InvestigationDetailComponent implements AfterViewInit, OnDestroy { public readonly investigationsFacade: InvestigationsFacade, private router: Router, private readonly route: ActivatedRoute, - private readonly ctaSnackbarService: CtaSnackbarService, + private readonly toastService: ToastService, ) { this.investigationPartsInformation$ = this.investigationDetailFacade.notificationPartsInformation$; this.supplierPartsDetailInformation$ = this.investigationDetailFacade.supplierPartsInformation$; @@ -145,7 +145,7 @@ export class InvestigationDetailComponent implements AfterViewInit, OnDestroy { public copyToClipboard(semanticModelId: string): void { const text = { id: 'clipboard', values: { value: semanticModelId } }; - navigator.clipboard.writeText(semanticModelId).then(_ => this.ctaSnackbarService.show(text)); + navigator.clipboard.writeText(semanticModelId).then(_ => this.toastService.info(text)); } public navigateBackToInvestigations(): void { diff --git a/frontend/src/app/modules/shared/components/call-to-action-snackbar/cta-snackbar.component.html b/frontend/src/app/modules/shared/components/call-to-action-snackbar/cta-snackbar.component.html deleted file mode 100644 index 8379a9ef47..0000000000 --- a/frontend/src/app/modules/shared/components/call-to-action-snackbar/cta-snackbar.component.html +++ /dev/null @@ -1,33 +0,0 @@ - - -
-

{{ text | i18n }}

- - {{ action.text | i18n }} -
diff --git a/frontend/src/app/modules/shared/components/call-to-action-snackbar/cta-snackbar.component.ts b/frontend/src/app/modules/shared/components/call-to-action-snackbar/cta-snackbar.component.ts deleted file mode 100644 index 13e520a696..0000000000 --- a/frontend/src/app/modules/shared/components/call-to-action-snackbar/cta-snackbar.component.ts +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available 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. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -import { Component, Inject } from '@angular/core'; -import { MAT_SNACK_BAR_DATA, MatSnackBar } from '@angular/material/snack-bar'; -import { I18nMessage } from '@shared/model/i18n-message'; -import { CallAction, CtaSnackbarData } from './cta-snackbar.model'; - -// CTA stands for call-to-action -@Component({ - selector: 'cta-snackbar', - templateUrl: './cta-snackbar.component.html', -}) -export class CtaSnackbarComponent { - public get text(): I18nMessage { - return this.data.text; - } - - public get actions(): CallAction[] { - return this.data.actions; - } - - constructor( - @Inject(MAT_SNACK_BAR_DATA) - private readonly data: CtaSnackbarData, - private readonly snackBar: MatSnackBar, - ) {} - - public onActionClick(): void { - this.snackBar.dismiss(); - } -} diff --git a/frontend/src/app/modules/shared/components/call-to-action-snackbar/cta-snackbar.model.ts b/frontend/src/app/modules/shared/components/call-to-action-snackbar/cta-snackbar.model.ts deleted file mode 100644 index ee3db86d86..0000000000 --- a/frontend/src/app/modules/shared/components/call-to-action-snackbar/cta-snackbar.model.ts +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available 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. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -import { I18nMessage } from '@shared/model/i18n-message'; - -export interface CallAction { - text: I18nMessage; - link: string; - linkQueryParams?: Record; -} - -// CTA stands for call-to-action -export interface CtaSnackbarData { - text: I18nMessage; - actions: CallAction[]; -} diff --git a/frontend/src/app/modules/shared/components/call-to-action-snackbar/cta-snackbar.service.ts b/frontend/src/app/modules/shared/components/call-to-action-snackbar/cta-snackbar.service.ts deleted file mode 100644 index 1dc86bb11a..0000000000 --- a/frontend/src/app/modules/shared/components/call-to-action-snackbar/cta-snackbar.service.ts +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available 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. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -import { Injectable } from '@angular/core'; -import { MatSnackBar } from '@angular/material/snack-bar'; -import { I18nMessage } from '@shared/model/i18n-message'; -import { CtaSnackbarComponent } from './cta-snackbar.component'; -import { CallAction, CtaSnackbarData } from './cta-snackbar.model'; - -// CTA stands for call-to-action -@Injectable({ - providedIn: 'root', -}) -export class CtaSnackbarService { - constructor(private readonly snackBar: MatSnackBar) {} - - public show(text: I18nMessage, actions?: CallAction[]): void { - const duration = actions ? undefined : 3000; - const data: CtaSnackbarData = { text, actions }; - this.snackBar.openFromComponent(CtaSnackbarComponent, { data, duration }); - } -} diff --git a/frontend/src/app/modules/shared/components/call-to-action-snackbar/cta-snackbar.spec.ts b/frontend/src/app/modules/shared/components/call-to-action-snackbar/cta-snackbar.spec.ts deleted file mode 100644 index 8084f97b18..0000000000 --- a/frontend/src/app/modules/shared/components/call-to-action-snackbar/cta-snackbar.spec.ts +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available 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. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -import { TestBed } from '@angular/core/testing'; -import { SharedModule } from '@shared/shared.module'; -import { fireEvent, screen, waitForElementToBeRemoved } from '@testing-library/angular'; -import { renderComponent } from '@tests/test-render.utils'; -import { CtaSnackbarService } from './cta-snackbar.service'; - -describe('cta-snackbar', () => { - const prepareEnv = async () => { - await renderComponent('', { imports: [SharedModule] }); - - return TestBed.inject(CtaSnackbarService); - }; - - it('should show message with action', async () => { - const ctaSnackbarService = await prepareEnv(); - - ctaSnackbarService.show('actions.back', [{ text: 'Open', link: '' }]); - - expect(await screen.findByText('actions.back')).toBeInTheDocument(); - expect(await screen.findByText('Open')).toBeInTheDocument(); - }); - - it('should close message after click on action', async () => { - const ctaSnackbarService = await prepareEnv(); - - ctaSnackbarService.show('actions.back', [{ text: 'Open', link: '' }]); - fireEvent.click(await screen.findByText('Open')); - - await waitForElementToBeRemoved(() => screen.queryByText('Open')); - - expect(screen.queryByText('actions.back')).not.toBeInTheDocument(); - }); -}); diff --git a/frontend/src/app/modules/shared/components/request-notification/request-alert.component.ts b/frontend/src/app/modules/shared/components/request-notification/request-alert.component.ts index 32e1acbd69..f4e81476d1 100644 --- a/frontend/src/app/modules/shared/components/request-notification/request-alert.component.ts +++ b/frontend/src/app/modules/shared/components/request-notification/request-alert.component.ts @@ -25,11 +25,11 @@ import { ALERT_BASE_ROUTE, getRoute } from '@core/known-route'; import { bpnRegex } from '@page/admin/presentation/bpn-configuration/bpn-configuration.component'; import { Part } from '@page/parts/model/parts.model'; import { BaseInputHelper } from '@shared/abstraction/baseInput/baseInput.helper'; -import { CtaSnackbarService } from '@shared/components/call-to-action-snackbar/cta-snackbar.service'; import { RequestContext, RequestNotificationBase, } from '@shared/components/request-notification/request-notification.base'; +import { ToastService } from '@shared/components/toasts/toast.service'; import { NotificationStatusGroup } from '@shared/model/notification.model'; import { Severity } from '@shared/model/severity.model'; import { AlertsService } from '@shared/service/alerts.service'; @@ -49,8 +49,8 @@ export class RequestAlertComponent extends RequestNotificationBase { public readonly context: RequestContext = 'requestAlert'; - constructor(ctaSnackbarService: CtaSnackbarService, private readonly alertsService: AlertsService) { - super(ctaSnackbarService); + constructor(toastService: ToastService, private readonly alertsService: AlertsService) { + super(toastService); } public readonly formGroup = new FormGroup({ diff --git a/frontend/src/app/modules/shared/components/request-notification/request-investigation.component.ts b/frontend/src/app/modules/shared/components/request-notification/request-investigation.component.ts index a67e1be193..4a2ffab2f2 100644 --- a/frontend/src/app/modules/shared/components/request-notification/request-investigation.component.ts +++ b/frontend/src/app/modules/shared/components/request-notification/request-investigation.component.ts @@ -21,9 +21,9 @@ import { Component, EventEmitter, Input, Output } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; -import { CtaSnackbarService } from '@shared/components/call-to-action-snackbar/cta-snackbar.service'; import { DateTimeString } from '@shared/components/dateTime/dateTime.component'; import { DateValidators } from '@shared/components/dateTime/dateValidators.model'; +import { ToastService } from '@shared/components/toasts/toast.service'; import { Severity } from '@shared/model/severity.model'; import { RequestContext, @@ -49,8 +49,8 @@ export class RequestInvestigationComponent extends RequestNotificationBase { public readonly context: RequestContext = 'requestInvestigations'; - constructor(ctaSnackbarService: CtaSnackbarService, private readonly investigationsService: InvestigationsService) { - super(ctaSnackbarService); + constructor(toastService: ToastService, private readonly investigationsService: InvestigationsService) { + super(toastService); } public readonly formGroup = new FormGroup<{ diff --git a/frontend/src/app/modules/shared/components/request-notification/request-notification.base.spec.ts b/frontend/src/app/modules/shared/components/request-notification/request-notification.base.spec.ts index d32952716c..b7f2780d8d 100644 --- a/frontend/src/app/modules/shared/components/request-notification/request-notification.base.spec.ts +++ b/frontend/src/app/modules/shared/components/request-notification/request-notification.base.spec.ts @@ -182,9 +182,7 @@ describe('requestInvestigationComponent', () => { expect(submit).toBeInTheDocument(); expect(textArea.value).toEqual(testText); fireEvent.click(submit); - - await sleepForTests(1000); - expect(await waitFor(() => screen.getByText(context + '.success'))).toBeInTheDocument(); + await sleepForTests(2000); expect(textArea.value).toEqual(''); expect(submittedMock).toHaveBeenCalledTimes(1); }; diff --git a/frontend/src/app/modules/shared/components/request-notification/request-notification.base.ts b/frontend/src/app/modules/shared/components/request-notification/request-notification.base.ts index 78403f7151..d4a1ea6f16 100644 --- a/frontend/src/app/modules/shared/components/request-notification/request-notification.base.ts +++ b/frontend/src/app/modules/shared/components/request-notification/request-notification.base.ts @@ -22,8 +22,8 @@ import { EventEmitter } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; import { Part } from '@page/parts/model/parts.model'; -import { CtaSnackbarService } from '@shared/components/call-to-action-snackbar/cta-snackbar.service'; import { DateTimeString } from '@shared/components/dateTime/dateTime.component'; +import { ToastService } from '@shared/components/toasts/toast.service'; import { Severity } from '@shared/model/severity.model'; import { BehaviorSubject } from 'rxjs'; @@ -56,7 +56,7 @@ export abstract class RequestNotificationBase { public removedItemsHistory: Part[] = []; - protected constructor(private readonly ctaSnackbarService: CtaSnackbarService) {} + protected constructor( private readonly toastService: ToastService) {} protected abstract submit(): void; @@ -75,7 +75,7 @@ export abstract class RequestNotificationBase { const amountOfItems = this.selectedItems.length; this.resetForm(); - this.openCtaSnackbar(amountOfItems, link, linkQueryParams); + this.openToast(amountOfItems, link, linkQueryParams); } protected onUnsuccessfulSubmit(): void { @@ -83,12 +83,13 @@ export abstract class RequestNotificationBase { this.formGroup.enable(); } - protected openCtaSnackbar(count: number, link: string, linkQueryParams: Record): void { - this.ctaSnackbarService.show( - { - id: `${this.context}.success`, - values: { count }, - }, + protected openToast(count: number, link: string, linkQueryParams: Record): void { + + this.toastService.success({ + id: `${this.context}.success`, + values: {count} + }, + 5000, [ { text: 'actions.goToQueue', @@ -96,7 +97,9 @@ export abstract class RequestNotificationBase { link, }, ], - ); + + + ); } public cancelAction(part: Part): void { diff --git a/frontend/src/app/modules/shared/components/toasts/toast-container/toast-container.component.html b/frontend/src/app/modules/shared/components/toasts/toast-container/toast-container.component.html index 7148a88514..b0229183cf 100644 --- a/frontend/src/app/modules/shared/components/toasts/toast-container/toast-container.component.html +++ b/frontend/src/app/modules/shared/components/toasts/toast-container/toast-container.component.html @@ -19,9 +19,10 @@ SPDX-License-Identifier: Apache-2.0 --> -
+
-
- -
diff --git a/frontend/src/app/modules/shared/components/toasts/toast-message/toast-message.component.scss b/frontend/src/app/modules/shared/components/toasts/toast-message/toast-message.component.scss index 6bfb4e62d9..82f16e0515 100644 --- a/frontend/src/app/modules/shared/components/toasts/toast-message/toast-message.component.scss +++ b/frontend/src/app/modules/shared/components/toasts/toast-message/toast-message.component.scss @@ -20,30 +20,36 @@ ********************************************************************************/ .toast { - @apply flex flex-row justify-between bg-white mb-2 w-96 h-14 z-120 border-solid border-l-8; + @apply flex flex-row justify-between bg-white w-96 h-full z-120; } -.status-bar-success { - height: 100%; - @apply border-success; + +.toast-container { + border-radius: 8px; +} + +.toast-icon-check { + color: rgb(0, 170, 85); } -.status-bar-warning { - height: 100%; - @apply border-warning; +.toast-icon-warning { + color: rgb(255, 166, 0); } -.status-bar-error { - height: 100%; - @apply border-error; +.toast-icon-error { + color: rgb(217, 30, 24); } -.status-bar-informative { - height: 100%; - @apply border-info; +.toast-icon-info { + color: rgb(103, 107, 198); } .btn-close { border: 0; - @apply bg-tundoraShadeGray border-0; } + +.check-icon-container { + display:flex; + align-items: center; +} + diff --git a/frontend/src/app/modules/shared/components/toasts/toast-message/toast-message.model.ts b/frontend/src/app/modules/shared/components/toasts/toast-message/toast-message.model.ts index 93f54bb852..8252113cc3 100644 --- a/frontend/src/app/modules/shared/components/toasts/toast-message/toast-message.model.ts +++ b/frontend/src/app/modules/shared/components/toasts/toast-message/toast-message.model.ts @@ -19,6 +19,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ +import { I18nMessage } from '@shared/model/i18n-message'; + /** * Types or status of toast messages * Success status - shows the toast with a green status bar, typically used to inform the user @@ -28,14 +30,20 @@ */ export const enum ToastStatus { - Success = 'success', + Success = 'check', Warning = 'warning', Error = 'error', - Informative = 'informative', + Informative = 'info', +} + +export interface CallAction { + text: I18nMessage; + link: string; + linkQueryParams?: Record; } export class ToastMessage { public isSliderON = true; - constructor(public id: number, public message: string, public status: ToastStatus | null, public timeout: number) {} + constructor(public id: number, public message: I18nMessage | string, public status: ToastStatus | null, public timeout: number, public actions: CallAction[] = null) {} } diff --git a/frontend/src/app/modules/shared/components/toasts/toast.service.ts b/frontend/src/app/modules/shared/components/toasts/toast.service.ts index ac782f274a..7e03a21bda 100644 --- a/frontend/src/app/modules/shared/components/toasts/toast.service.ts +++ b/frontend/src/app/modules/shared/components/toasts/toast.service.ts @@ -20,8 +20,9 @@ ********************************************************************************/ import { Injectable } from '@angular/core'; +import { I18nMessage } from '@shared/model/i18n-message'; import { Observable, Subject } from 'rxjs'; -import { ToastMessage, ToastStatus } from './toast-message/toast-message.model'; +import { CallAction, ToastMessage, ToastStatus } from './toast-message/toast-message.model'; @Injectable({ providedIn: 'root', @@ -34,19 +35,23 @@ export class ToastService { return this.toastStore.asObservable(); } - public success(message: string, timeout = 5000): void { - this.toastStore.next(new ToastMessage(this.idx++, message, ToastStatus.Success, timeout)); + public success(message: I18nMessage | string, timeout = 5000, actions?: CallAction[]): void { + if(actions) { + this.toastStore.next(new ToastMessage(this.idx++, message, ToastStatus.Success, timeout, actions)); + } else { + this.toastStore.next(new ToastMessage(this.idx++, message, ToastStatus.Success, timeout)); + } } - public info(message: string, timeout = 5000): void { + public info(message: I18nMessage, timeout = 5000): void { this.toastStore.next(new ToastMessage(this.idx++, message, ToastStatus.Informative, timeout)); } - public error(message: string, timeout = 5000): void { + public error(message: I18nMessage, timeout = 5000): void { this.toastStore.next(new ToastMessage(this.idx++, message, ToastStatus.Error, timeout)); } - public warning(message: string, timeout = 5000): void { + public warning(message: I18nMessage, timeout = 5000): void { this.toastStore.next(new ToastMessage(this.idx++, message, ToastStatus.Warning, timeout)); } } diff --git a/frontend/src/app/modules/shared/components/toasts/toast.spec.ts b/frontend/src/app/modules/shared/components/toasts/toast.spec.ts index 8706189332..2b3115e0b5 100644 --- a/frontend/src/app/modules/shared/components/toasts/toast.spec.ts +++ b/frontend/src/app/modules/shared/components/toasts/toast.spec.ts @@ -21,7 +21,7 @@ import { TestBed } from '@angular/core/testing'; import { SharedModule } from '@shared/shared.module'; -import { screen, within } from '@testing-library/angular'; +import { screen } from '@testing-library/angular'; import { renderComponent } from '@tests/test-render.utils'; import { ToastService } from './toast.service'; @@ -36,9 +36,7 @@ describe('toasts', () => { toastService.success('some success'); const toast = await screen.findByTestId('toast-container'); - - expect(toast).toHaveClass('status-bar-success'); - expect(within(toast).getByText('some success')).toBeInTheDocument(); + expect(toast).toHaveClass('toast-icon-check'); }); it('should render info toast', async () => { @@ -47,8 +45,7 @@ describe('toasts', () => { const toast = await screen.findByTestId('toast-container'); - expect(toast).toHaveClass('status-bar-informative'); - expect(within(toast).getByText('some info')).toBeInTheDocument(); + expect(toast).toHaveClass('toast-icon-info'); }); it('should render warning toast', async () => { @@ -57,8 +54,7 @@ describe('toasts', () => { const toast = await screen.findByTestId('toast-container'); - expect(toast).toHaveClass('status-bar-warning'); - expect(within(toast).getByText('some warning')).toBeInTheDocument(); + expect(toast).toHaveClass('toast-icon-warning'); }); it('should render error toast', async () => { @@ -67,7 +63,6 @@ describe('toasts', () => { const toast = await screen.findByTestId('toast-container'); - expect(toast).toHaveClass('status-bar-error'); - expect(within(toast).getByText('some error')).toBeInTheDocument(); + expect(toast).toHaveClass('toast-icon-error'); }); }); diff --git a/frontend/src/app/modules/shared/shared.module.ts b/frontend/src/app/modules/shared/shared.module.ts index 2bcf8d2dd2..80a840f44b 100644 --- a/frontend/src/app/modules/shared/shared.module.ts +++ b/frontend/src/app/modules/shared/shared.module.ts @@ -40,7 +40,6 @@ import { BaseInputComponent } from './abstraction/baseInput/baseInput.component' import { AvatarComponent } from './components/avatar/avatar.component'; import { BreadcrumbsComponent } from './components/breadcrumbs/breadcrumbs.component'; import { ButtonComponent } from './components/button/button.component'; -import { CtaSnackbarComponent } from './components/call-to-action-snackbar/cta-snackbar.component'; import { CardIconComponent } from './components/card-icon/card-icon.component'; import { CardListComponent } from './components/card-list/card-list.component'; import { ToKeyValuePipe } from './components/card-list/card-list.pipe'; @@ -101,7 +100,6 @@ import { RequestAlertComponent } from '@shared/components/request-notification/r ErrorMessagePipe, RequestInvestigationComponent, RequestAlertComponent, - CtaSnackbarComponent, ScrollWithShadowComponent, QualityTypeComponent, ValueToLablePipe, diff --git a/frontend/src/app/modules/shared/template.module.ts b/frontend/src/app/modules/shared/template.module.ts index 41b401ba7f..a656b4077b 100644 --- a/frontend/src/app/modules/shared/template.module.ts +++ b/frontend/src/app/modules/shared/template.module.ts @@ -50,7 +50,6 @@ import { MatRadioModule } from '@angular/material/radio'; import { MatSelectModule } from '@angular/material/select'; import { MatSidenavModule } from '@angular/material/sidenav'; import { MatSlideToggleModule } from '@angular/material/slide-toggle'; -import { MatSnackBarModule } from '@angular/material/snack-bar'; import { MatSortModule } from '@angular/material/sort'; import { MatTableModule } from '@angular/material/table'; import { MatTabsModule } from '@angular/material/tabs'; @@ -97,7 +96,6 @@ import { MatTreeModule } from '@angular/material/tree'; NgxMatDatetimePickerModule, NgxMatNativeDateModule, MatTooltipModule, - MatSnackBarModule, ], exports: [ CommonModule, @@ -137,7 +135,6 @@ import { MatTreeModule } from '@angular/material/tree'; NgxMatNativeDateModule, MatTooltipModule, MatTabsModule, - MatSnackBarModule, ], }) export class TemplateModule {}