diff --git a/src/main/java/org/chainoptim/desktop/core/main/controller/AppController.java b/src/main/java/org/chainoptim/desktop/core/main/controller/AppController.java index dfe57842..ddaca62a 100644 --- a/src/main/java/org/chainoptim/desktop/core/main/controller/AppController.java +++ b/src/main/java/org/chainoptim/desktop/core/main/controller/AppController.java @@ -24,7 +24,6 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.function.Consumer; -import static org.chainoptim.desktop.core.organization.model.Organization.SubscriptionPlanTier.PRO; /** * Root controller managing the currently displayed main content @@ -103,7 +102,7 @@ private Result handleUserResponse(Result result) { User user = result.getData(); - user.getOrganization().setSubscriptionPlanTier(PRO); + user.getOrganization().setSubscriptionPlanTier(result.getData().getOrganization().getSubscriptionPlanTier()); // Set user to TenantContext for reuse throughout the app TenantContext.setCurrentUser(user); diff --git a/src/main/java/org/chainoptim/desktop/core/organization/controller/OrganizationController.java b/src/main/java/org/chainoptim/desktop/core/organization/controller/OrganizationController.java index c31cfa68..3b73c958 100644 --- a/src/main/java/org/chainoptim/desktop/core/organization/controller/OrganizationController.java +++ b/src/main/java/org/chainoptim/desktop/core/organization/controller/OrganizationController.java @@ -13,7 +13,6 @@ import org.chainoptim.desktop.shared.httphandling.Result; import org.chainoptim.desktop.shared.util.DataReceiver; import org.chainoptim.desktop.shared.util.resourceloader.CommonViewsLoader; -import org.chainoptim.desktop.shared.util.resourceloader.FXMLLoaderService; import com.google.inject.Inject; import javafx.application.Platform; @@ -29,9 +28,7 @@ import java.io.IOException; import java.net.URL; import java.util.List; -import java.util.Optional; import java.util.ResourceBundle; -import static org.chainoptim.desktop.core.organization.model.Organization.SubscriptionPlanTier.PRO; public class OrganizationController implements Initializable { @@ -166,7 +163,7 @@ private Result handleOrganizationResponse(Result res } organizationViewData.setOrganization(result.getData()); - organizationViewData.getOrganization().setSubscriptionPlanTier(PRO); + organizationViewData.getOrganization().setSubscriptionPlanTier(result.getData().getSubscriptionPlanTier()); initializeUI(); diff --git a/src/main/java/org/chainoptim/desktop/core/organization/controller/OrganizationSubscriptionPlanController.java b/src/main/java/org/chainoptim/desktop/core/organization/controller/OrganizationSubscriptionPlanController.java index 2d441256..9f758f53 100644 --- a/src/main/java/org/chainoptim/desktop/core/organization/controller/OrganizationSubscriptionPlanController.java +++ b/src/main/java/org/chainoptim/desktop/core/organization/controller/OrganizationSubscriptionPlanController.java @@ -1,10 +1,7 @@ package org.chainoptim.desktop.core.organization.controller; import org.chainoptim.desktop.core.context.SupplyChainSnapshotContext; -import org.chainoptim.desktop.core.organization.model.Organization; -import org.chainoptim.desktop.core.organization.model.OrganizationViewData; -import org.chainoptim.desktop.core.organization.model.PlanDetails; -import org.chainoptim.desktop.core.organization.model.SubscriptionPlans; +import org.chainoptim.desktop.core.organization.model.*; import org.chainoptim.desktop.shared.util.DataReceiver; import com.google.inject.Inject; @@ -31,8 +28,8 @@ public class OrganizationSubscriptionPlanController implements DataReceiver PLANS = Map.of( - Organization.SubscriptionPlanTier.NONE, NONE_PLAN, - Organization.SubscriptionPlanTier.BASIC, BASIC_PLAN, - Organization.SubscriptionPlanTier.PRO, PRO_PLAN + private static final Map PLANS = Map.of( + SubscriptionPlanTier.NONE, NONE_PLAN, + SubscriptionPlanTier.BASIC, BASIC_PLAN, + SubscriptionPlanTier.PROFESSIONAL, PROFESSIONAL_PLAN, + SubscriptionPlanTier.ENTERPRISE, ENTERPRISE_PLAN ); - public static Map getPlans() { + public static Map getPlans() { return PLANS; } + + public static PlanDetails getPlan(SubscriptionPlanTier tier) { + return PLANS.get(tier); + } } diff --git a/src/main/java/org/chainoptim/desktop/core/organization/model/Organization.java b/src/main/java/org/chainoptim/desktop/core/organization/model/Organization.java index c5d89d8b..faaba99b 100644 --- a/src/main/java/org/chainoptim/desktop/core/organization/model/Organization.java +++ b/src/main/java/org/chainoptim/desktop/core/organization/model/Organization.java @@ -18,18 +18,7 @@ public class Organization { private Set users; - public enum SubscriptionPlanTier { - NONE, - BASIC, - PRO; - - @Override - public String toString() { - return name().charAt(0) + name().substring(1).toLowerCase(); - } - } - public PlanDetails getSubscriptionPlan() { - return SubscriptionPlans.getPlans().get(subscriptionPlanTier); + return BaseSubscriptionPlans.getPlans().get(subscriptionPlanTier); } } diff --git a/src/main/java/org/chainoptim/desktop/core/organization/model/PlanDetails.java b/src/main/java/org/chainoptim/desktop/core/organization/model/PlanDetails.java index 04b6ca00..32e8bd80 100644 --- a/src/main/java/org/chainoptim/desktop/core/organization/model/PlanDetails.java +++ b/src/main/java/org/chainoptim/desktop/core/organization/model/PlanDetails.java @@ -21,6 +21,8 @@ public class PlanDetails { private int maxProducts; private int maxComponents; private int maxProductStages; + private int maxTransportRoutes; + private int maxPricings; // Factories private int maxFactories; @@ -31,6 +33,8 @@ public class PlanDetails { // Warehouses private int maxWarehouses; private int maxWarehouseInventoryItems; + private int maxCompartments; + private int maxCrates; // Suppliers private int maxSuppliers; @@ -43,4 +47,7 @@ public class PlanDetails { private int maxClientOrders; private int maxClientShipments; private boolean clientPerformanceOn; + + // Locations + private int maxLocations; } diff --git a/src/main/java/org/chainoptim/desktop/core/organization/model/SubscriptionPlanTier.java b/src/main/java/org/chainoptim/desktop/core/organization/model/SubscriptionPlanTier.java new file mode 100644 index 00000000..2402b198 --- /dev/null +++ b/src/main/java/org/chainoptim/desktop/core/organization/model/SubscriptionPlanTier.java @@ -0,0 +1,13 @@ +package org.chainoptim.desktop.core.organization.model; + +public enum SubscriptionPlanTier { + NONE, + BASIC, + PROFESSIONAL, + ENTERPRISE; + + @Override + public String toString() { + return name().charAt(0) + name().substring(1).toLowerCase(); + } +} diff --git a/src/main/java/org/chainoptim/desktop/core/overview/controller/TimelineController.java b/src/main/java/org/chainoptim/desktop/core/overview/controller/TimelineController.java index aea80cd9..9ce3db23 100644 --- a/src/main/java/org/chainoptim/desktop/core/overview/controller/TimelineController.java +++ b/src/main/java/org/chainoptim/desktop/core/overview/controller/TimelineController.java @@ -138,6 +138,12 @@ private Result> handleEventsException(Throwable throwable) { private void renderTimeline() { titleLabel.setText("Upcoming Events (" + events.size() + ")"); eventsHBox.getChildren().clear(); + if (events.isEmpty()) { + Label noEventsLabel = new Label("No upcoming events"); + noEventsLabel.getStyleClass().add("general-label-large"); + eventsHBox.getChildren().add(noEventsLabel); + return; + } DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMM dd, yyyy hh:mm a"); diff --git a/src/main/java/org/chainoptim/desktop/core/overview/service/UpcomingEventServiceImpl.java b/src/main/java/org/chainoptim/desktop/core/overview/service/UpcomingEventServiceImpl.java index da3b6148..03dcda64 100644 --- a/src/main/java/org/chainoptim/desktop/core/overview/service/UpcomingEventServiceImpl.java +++ b/src/main/java/org/chainoptim/desktop/core/overview/service/UpcomingEventServiceImpl.java @@ -46,6 +46,7 @@ public CompletableFuture>> getUpcomingEventsByOrganiz String cacheKey = CacheKeyBuilder.buildAdvancedSearchKey( "upcoming-events", "organization", organizationId.toString(), searchParams); String routeAddress = rootAddress + cacheKey; + System.out.println("Route address: " + routeAddress); HttpRequest request = requestBuilder.buildReadRequest(routeAddress, tokenManager.getToken()); diff --git a/src/main/java/org/chainoptim/desktop/features/product/controller/ProductPricingController.java b/src/main/java/org/chainoptim/desktop/features/product/controller/ProductPricingController.java index 5f377c20..b1ea8f39 100644 --- a/src/main/java/org/chainoptim/desktop/features/product/controller/ProductPricingController.java +++ b/src/main/java/org/chainoptim/desktop/features/product/controller/ProductPricingController.java @@ -99,8 +99,11 @@ private void updatePricing(float quantity) { } private float calculatePrice(float quantity) { - TreeMap pricePerVolume = this.pricing.getProductPricing().getPricePerVolume(); - if (pricePerVolume == null || pricePerVolume.isEmpty()) { + TreeMap pricePerVolume = new TreeMap<>(); + if (this.pricing.getProductPricing().getPricePerVolume() != null) { + pricePerVolume.putAll(this.pricing.getProductPricing().getPricePerVolume()); + } + if (pricePerVolume.isEmpty()) { return quantity * this.pricing.getProductPricing().getPricePerUnit(); } @@ -121,6 +124,10 @@ private void renderPricing() { float previousQuantity = 0; int rowIndex = 0; + if (this.pricing.getProductPricing().getPricePerVolume() == null) { + return; + } + for (Map.Entry entry : this.pricing.getProductPricing().getPricePerVolume().entrySet()) { String rangeLabelContent; if (previousQuantity == 0) { diff --git a/src/main/java/org/chainoptim/desktop/features/product/controller/productproduction/CreateProductStageController.java b/src/main/java/org/chainoptim/desktop/features/product/controller/productproduction/CreateProductStageController.java index 71064a22..7bff5ac4 100644 --- a/src/main/java/org/chainoptim/desktop/features/product/controller/productproduction/CreateProductStageController.java +++ b/src/main/java/org/chainoptim/desktop/features/product/controller/productproduction/CreateProductStageController.java @@ -79,7 +79,7 @@ private void loadFallbackManager() { private void loadSelectProductView() { // Initialize time selection input view FXMLLoader selectProductLoader = fxmlLoaderService.setUpLoader( - "/org/chainoptim/desktop/shared/common/uielements/Select/SelectProductView.fxml", + "/org/chainoptim/desktop/shared/common/uielements/select/SelectProductView.fxml", controllerFactory::createController ); try { diff --git a/src/main/java/org/chainoptim/desktop/features/supplier/controller/SupplierOrdersController.java b/src/main/java/org/chainoptim/desktop/features/supplier/controller/SupplierOrdersController.java index f65a0d6a..bec1328c 100644 --- a/src/main/java/org/chainoptim/desktop/features/supplier/controller/SupplierOrdersController.java +++ b/src/main/java/org/chainoptim/desktop/features/supplier/controller/SupplierOrdersController.java @@ -538,7 +538,7 @@ private CreateSupplierOrderDTO getCreateSupplierOrderDTO(SupplierOrder order) { } createSupplierOrderDTO.setOrganizationId(supplier.getOrganizationId()); createSupplierOrderDTO.setSupplierId(supplier.getId()); - createSupplierOrderDTO.setComponentId(order.getComponent().getId()); + createSupplierOrderDTO.setComponentId(order.getComponent() != null ? order.getComponent().getId() : null); createSupplierOrderDTO.setQuantity(order.getQuantity()); createSupplierOrderDTO.setDeliveredQuantity(order.getDeliveredQuantity()); createSupplierOrderDTO.setOrderDate(order.getOrderDate()); diff --git a/src/main/java/org/chainoptim/desktop/shared/search/filters/FilterBar.java b/src/main/java/org/chainoptim/desktop/shared/search/filters/FilterBar.java index ceb2e4f0..789132f9 100644 --- a/src/main/java/org/chainoptim/desktop/shared/search/filters/FilterBar.java +++ b/src/main/java/org/chainoptim/desktop/shared/search/filters/FilterBar.java @@ -47,7 +47,7 @@ private void initializeUI() { private void setUpKeyComboBox() { keyComboBox.setPromptText("Filter by..."); - keyComboBox.getStyleClass().setAll("custom-combo-box"); + keyComboBox.getStyleClass().add("custom-combo-box"); keyComboBox.getItems().addAll(filterOptions.stream().map(FilterOption::getKey).toList()); keyComboBox.valueProperty().addListener((observable, oldValue, newValue) -> diff --git a/src/main/java/org/chainoptim/desktop/shared/table/TableToolbarController.java b/src/main/java/org/chainoptim/desktop/shared/table/TableToolbarController.java index a3237a8c..779fee7a 100644 --- a/src/main/java/org/chainoptim/desktop/shared/table/TableToolbarController.java +++ b/src/main/java/org/chainoptim/desktop/shared/table/TableToolbarController.java @@ -118,7 +118,7 @@ private void setTitle(String titleText, String titleIconPath) { ColorAdjust colorAdjust = new ColorAdjust(); colorAdjust.setBrightness(-0.84); titleIconView.setEffect(colorAdjust); - title.setGraphic(titleIconView); +// title.setGraphic(titleIconView); title.setContentDisplay(ContentDisplay.LEFT); } diff --git a/src/main/java/org/chainoptim/desktop/shared/util/resourceloader/CommonViewsLoaderImpl.java b/src/main/java/org/chainoptim/desktop/shared/util/resourceloader/CommonViewsLoaderImpl.java index 8810aec7..399a3ea3 100644 --- a/src/main/java/org/chainoptim/desktop/shared/util/resourceloader/CommonViewsLoaderImpl.java +++ b/src/main/java/org/chainoptim/desktop/shared/util/resourceloader/CommonViewsLoaderImpl.java @@ -111,7 +111,7 @@ public GenericConfirmDialogController loadConfirmDialog(StackPane confirm public SelectOrCreateLocationController loadSelectOrCreateLocation(StackPane selectOrCreateLocationContainer) { FXMLLoader loader = fxmlLoaderService.setUpLoader( - "/org/chainoptim/desktop/shared/common/uielements/Select/SelectOrCreateLocationView.fxml", + "/org/chainoptim/desktop/shared/common/uielements/select/SelectOrCreateLocationView.fxml", controllerFactory::createController ); try { @@ -126,7 +126,7 @@ public SelectOrCreateLocationController loadSelectOrCreateLocation(StackPane sel public SelectOrCreateUnitOfMeasurementController loadSelectOrCreateUnitOfMeasurement(StackPane unitOfMeasurementContainer) { FXMLLoader loader = fxmlLoaderService.setUpLoader( - "/org/chainoptim/desktop/shared/common/uielements/Select/SelectOrCreateUnitOfMeasurementView.fxml", + "/org/chainoptim/desktop/shared/common/uielements/select/SelectOrCreateUnitOfMeasurementView.fxml", controllerFactory::createController ); try { @@ -141,7 +141,7 @@ public SelectOrCreateUnitOfMeasurementController loadSelectOrCreateUnitOfMeasure public SelectDurationController loadSelectDurationView(StackPane durationInputContainer) { FXMLLoader timeInputLoader = fxmlLoaderService.setUpLoader( - "/org/chainoptim/desktop/shared/common/uielements/Select/SelectDurationView.fxml", + "/org/chainoptim/desktop/shared/common/uielements/select/SelectDurationView.fxml", controllerFactory::createController ); try { @@ -157,7 +157,7 @@ public SelectDurationController loadSelectDurationView(StackPane durationInputCo public SelectStageController loadSelectStageView(StackPane selectStageContainer) { // Initialize time selection input view FXMLLoader selectStageLoader = fxmlLoaderService.setUpLoader( - "/org/chainoptim/desktop/shared/common/uielements/Select/SelectStageView.fxml", + "/org/chainoptim/desktop/shared/common/uielements/select/SelectStageView.fxml", controllerFactory::createController ); try { @@ -173,7 +173,7 @@ public SelectStageController loadSelectStageView(StackPane selectStageContainer) public SelectFactoryController loadSelectFactoryView(StackPane selectFactoryContainer) { // Initialize time selection input view FXMLLoader selectFactoryLoader = fxmlLoaderService.setUpLoader( - "/org/chainoptim/desktop/shared/common/uielements/Select/SelectFactoryView.fxml", + "/org/chainoptim/desktop/shared/common/uielements/select/SelectFactoryView.fxml", MainApplication.injector::getInstance ); try { diff --git a/src/main/resources/org/chainoptim/desktop/shared/common/uielements/Select/SelectComponentView.fxml b/src/main/resources/org/chainoptim/desktop/shared/common/uielements/select/SelectComponentView.fxml similarity index 100% rename from src/main/resources/org/chainoptim/desktop/shared/common/uielements/Select/SelectComponentView.fxml rename to src/main/resources/org/chainoptim/desktop/shared/common/uielements/select/SelectComponentView.fxml diff --git a/src/main/resources/org/chainoptim/desktop/shared/common/uielements/Select/SelectDurationView.fxml b/src/main/resources/org/chainoptim/desktop/shared/common/uielements/select/SelectDurationView.fxml similarity index 100% rename from src/main/resources/org/chainoptim/desktop/shared/common/uielements/Select/SelectDurationView.fxml rename to src/main/resources/org/chainoptim/desktop/shared/common/uielements/select/SelectDurationView.fxml diff --git a/src/main/resources/org/chainoptim/desktop/shared/common/uielements/Select/SelectFactoryView.fxml b/src/main/resources/org/chainoptim/desktop/shared/common/uielements/select/SelectFactoryView.fxml similarity index 100% rename from src/main/resources/org/chainoptim/desktop/shared/common/uielements/Select/SelectFactoryView.fxml rename to src/main/resources/org/chainoptim/desktop/shared/common/uielements/select/SelectFactoryView.fxml diff --git a/src/main/resources/org/chainoptim/desktop/shared/common/uielements/Select/SelectOrCreateLocationView.fxml b/src/main/resources/org/chainoptim/desktop/shared/common/uielements/select/SelectOrCreateLocationView.fxml similarity index 100% rename from src/main/resources/org/chainoptim/desktop/shared/common/uielements/Select/SelectOrCreateLocationView.fxml rename to src/main/resources/org/chainoptim/desktop/shared/common/uielements/select/SelectOrCreateLocationView.fxml diff --git a/src/main/resources/org/chainoptim/desktop/shared/common/uielements/Select/SelectOrCreateUnitOfMeasurementView.fxml b/src/main/resources/org/chainoptim/desktop/shared/common/uielements/select/SelectOrCreateUnitOfMeasurementView.fxml similarity index 100% rename from src/main/resources/org/chainoptim/desktop/shared/common/uielements/Select/SelectOrCreateUnitOfMeasurementView.fxml rename to src/main/resources/org/chainoptim/desktop/shared/common/uielements/select/SelectOrCreateUnitOfMeasurementView.fxml diff --git a/src/main/resources/org/chainoptim/desktop/shared/common/uielements/Select/SelectProductView.fxml b/src/main/resources/org/chainoptim/desktop/shared/common/uielements/select/SelectProductView.fxml similarity index 100% rename from src/main/resources/org/chainoptim/desktop/shared/common/uielements/Select/SelectProductView.fxml rename to src/main/resources/org/chainoptim/desktop/shared/common/uielements/select/SelectProductView.fxml diff --git a/src/main/resources/org/chainoptim/desktop/shared/common/uielements/Select/SelectStageView.fxml b/src/main/resources/org/chainoptim/desktop/shared/common/uielements/select/SelectStageView.fxml similarity index 100% rename from src/main/resources/org/chainoptim/desktop/shared/common/uielements/Select/SelectStageView.fxml rename to src/main/resources/org/chainoptim/desktop/shared/common/uielements/select/SelectStageView.fxml