diff --git a/demand-capacity-mgmt-backend/src/main/java/org/eclipse/tractusx/demandcapacitymgmt/demandcapacitymgmtbackend/services/impl/CapacityGroupServiceImpl.java b/demand-capacity-mgmt-backend/src/main/java/org/eclipse/tractusx/demandcapacitymgmt/demandcapacitymgmtbackend/services/impl/CapacityGroupServiceImpl.java index cd2f4386..b26ee594 100644 --- a/demand-capacity-mgmt-backend/src/main/java/org/eclipse/tractusx/demandcapacitymgmt/demandcapacitymgmtbackend/services/impl/CapacityGroupServiceImpl.java +++ b/demand-capacity-mgmt-backend/src/main/java/org/eclipse/tractusx/demandcapacitymgmt/demandcapacitymgmtbackend/services/impl/CapacityGroupServiceImpl.java @@ -1,4 +1,4 @@ -/* + /* * ******************************************************************************* * Copyright (c) 2023 BMW AG * Copyright (c) 2023 Contributors to the Eclipse Foundation @@ -324,13 +324,9 @@ private UnitMeasure enrichUnitMeasure(UnitMeasureEntity unitMeasureEntity) { private CapacityRequest convertCapacityTimeSeries(CapacityTimeSeries capacityTimeSeries) { CapacityRequest capacityRequest = new CapacityRequest(); - capacityRequest.setActualCapacity(new BigDecimal(capacityTimeSeries.getActualCapacity())); - capacityRequest.setMaximumCapacity(new BigDecimal(capacityTimeSeries.getMaximumCapacity())); - - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - String formattedDate = capacityTimeSeries.getCalendarWeek().format(formatter); - - capacityRequest.setCalendarWeek(formattedDate); + capacityRequest.setActualCapacity(BigDecimal.valueOf(capacityTimeSeries.getActualCapacity())); + capacityRequest.setMaximumCapacity(BigDecimal.valueOf(capacityTimeSeries.getMaximumCapacity())); + capacityRequest.setCalendarWeek(capacityTimeSeries.getCalendarWeek().toString()); return capacityRequest; } diff --git a/demand-capacity-mgmt-backend/src/main/java/org/eclipse/tractusx/demandcapacitymgmt/demandcapacitymgmtbackend/services/impl/FavoriteServiceImpl.java b/demand-capacity-mgmt-backend/src/main/java/org/eclipse/tractusx/demandcapacitymgmt/demandcapacitymgmtbackend/services/impl/FavoriteServiceImpl.java index 03b1fac5..b4e84c59 100644 --- a/demand-capacity-mgmt-backend/src/main/java/org/eclipse/tractusx/demandcapacitymgmt/demandcapacitymgmtbackend/services/impl/FavoriteServiceImpl.java +++ b/demand-capacity-mgmt-backend/src/main/java/org/eclipse/tractusx/demandcapacitymgmt/demandcapacitymgmtbackend/services/impl/FavoriteServiceImpl.java @@ -66,9 +66,9 @@ public FavoriteResponse createFavorite(FavoriteRequest favoriteRequest) { @Override public FavoriteResponse updateFavorite(UUID id, FavoriteType type, FavoriteRequest favoriteRequest) { FavoriteEntity entity = favoriteRepository.findByFavoriteIdAndTypeAndId( - id, - type, - UUID.fromString("8842f835-38e9-42b1-8c07-fb310b90ef3a") + id, + type, + UUID.fromString("8842f835-38e9-42b1-8c07-fb310b90ef3a") ); //TODO FETCH USER ID TO UPDATE OPERATION if (entity != null) { @@ -100,10 +100,10 @@ private FavoriteResponse convertFavoriteResponse(FavoriteEntity request) { private FavoriteEntity generateFavoriteEntity(FavoriteRequest request) { return FavoriteEntity - .builder() - .id(UUID.randomUUID()) //TODO USER ID HERE - .favoriteId(UUID.fromString(request.getFavoriteId())) - .type(FavoriteType.valueOf(request.getfType())) - .build(); + .builder() + .id(UUID.randomUUID()) //TODO USER ID HERE + .favoriteId(UUID.fromString(request.getFavoriteId())) + .type(FavoriteType.valueOf(request.getfType())) + .build(); } -} +} \ No newline at end of file diff --git a/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupChronogram.tsx b/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupChronogram.tsx index c2336106..6923cdaa 100644 --- a/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupChronogram.tsx +++ b/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupChronogram.tsx @@ -27,9 +27,11 @@ import { YAxis, CartesianGrid, Tooltip, - Legend, Brush + Legend, + Brush, ReferenceArea, BarChart } from "recharts"; import {SingleCapacityGroup} from "../../interfaces/capacitygroup_interfaces"; +import {useEffect, useRef, useState} from "react"; type CapacityGroupChronogramProps = { capacityGroup: SingleCapacityGroup | null | undefined; @@ -38,10 +40,18 @@ type CapacityGroupChronogramProps = { const computeLinkedDemandSum = (capacityGroup: SingleCapacityGroup | null | undefined) => { if (!capacityGroup || !capacityGroup.linkedDemandSeries) return 0; + return capacityGroup.linkedDemandSeries.length; }; function CapacityGroupChronogram(props: CapacityGroupChronogramProps) { + + type SelectedRangeType = { + start: string | null; + end: string | null; + }; + + const { capacityGroup } = props; const rawCapacities = capacityGroup?.capacities || []; @@ -51,11 +61,18 @@ function CapacityGroupChronogram(props: CapacityGroupChronogramProps) { // Sorted data by date - const data = rawCapacities.map(d => ({ - ...d, - Demand: linkedDemandSum, - dateEpoch: new Date(d.calendarWeek).getTime() - })).sort((a, b) => a.dateEpoch - b.dateEpoch); +// Sorted data by date + const data = rawCapacities.map(d => { + // Convert to Date and back to simplified string format + const simplifiedDate = new Date(d.calendarWeek).toISOString().split('T')[0]; + + return { + ...d, + Demand: linkedDemandSum, + dateEpoch: new Date(simplifiedDate).getTime(), + calendarWeek: simplifiedDate + }; + }).sort((a, b) => a.dateEpoch - b.dateEpoch); const getWeekNumber = (d: Date) => { d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate())); @@ -106,8 +123,37 @@ function CapacityGroupChronogram(props: CapacityGroupChronogramProps) { }; + const [selectedRange, setSelectedRange] = useState({ start: null, end: null }); + type BrushStartEndIndex = { + startIndex?: number; + endIndex?:number; + }; + + const timer = useRef(2000); + const brushIndexesRef = useRef(null); + + const handleBrushChange = (newIndex: BrushStartEndIndex) => { + if (typeof newIndex.startIndex === 'number' && typeof newIndex.endIndex === 'number') { + brushIndexesRef.current = newIndex; + } + }; + + + + useEffect(() => { + const interval = setInterval(() => { + if (brushIndexesRef.current?.startIndex !== undefined && brushIndexesRef.current?.endIndex !== undefined) { + const start = data[brushIndexesRef.current.startIndex].calendarWeek; + const end = data[brushIndexesRef.current.endIndex].calendarWeek; + setSelectedRange({ start, end }); + } + }, timer.current); + + return () => clearInterval(interval); + }, [data]); return ( +
- + + + + + {/* Mini preview AreaChart */} + + + + + + {/* Highlighted area based on the brush selection from the main graph */} + {selectedRange.start && selectedRange.end && ( + + )} + +
); } diff --git a/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupSumView.tsx b/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupSumView.tsx index f8850e26..1d83ea2e 100644 --- a/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupSumView.tsx +++ b/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupSumView.tsx @@ -258,9 +258,6 @@ const CapacityGroupSumView: React.FC = () => { const totalWeeksCurrentYear = monthsCurrentYear.reduce((total, month) => total + month.weeks.length, 0); const totalWeeksNextYear = monthsNextYear.reduce((total, month) => total + month.weeks.length, 0); - // Object to store the demand values based on year, month, and week - type DemandValuesMap = Record>>; - let [demandValuesMap] = useState({}); //Mapping of categories const idToNumericIdMap: Record = {}; @@ -271,7 +268,6 @@ const CapacityGroupSumView: React.FC = () => { }); } - console.log(demandValuesMap); // Track which Demand.description rows are expanded const [expandedDemandRows, setExpandedDemandRows] = useState>({}); diff --git a/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupsView.tsx b/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupsView.tsx index 3ae3c162..946261e9 100644 --- a/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupsView.tsx +++ b/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupsView.tsx @@ -23,9 +23,9 @@ import React, { useContext, useState, useMemo } from 'react'; import { Form, Col, Row, Button, OverlayTrigger, Tooltip,Dropdown } from 'react-bootstrap'; import { CapacityGroupContext } from '../../contexts/CapacityGroupsContextProvider'; -import Pagination from '../Pagination'; +import Pagination from '../common/Pagination'; import CapacityGroupsTable from './CapacityGroupsTable'; -import Search from '../Search'; +import Search from '../common/Search'; import '../../index.css'; import { FaCopy, FaEllipsisV, FaSearch } from 'react-icons/fa'; diff --git a/demand-capacity-mgmt-frontend/src/components/CapacityGroupDetails.tsx b/demand-capacity-mgmt-frontend/src/components/common/CapacityGroupDetails.tsx similarity index 90% rename from demand-capacity-mgmt-frontend/src/components/CapacityGroupDetails.tsx rename to demand-capacity-mgmt-frontend/src/components/common/CapacityGroupDetails.tsx index 7320dc88..ff8c90e5 100644 --- a/demand-capacity-mgmt-frontend/src/components/CapacityGroupDetails.tsx +++ b/demand-capacity-mgmt-frontend/src/components/common/CapacityGroupDetails.tsx @@ -20,8 +20,8 @@ * ******************************************************************************** */ -import CapacityGroupsList from "./capacitygroup/CapacityGroupsView"; -import CapacityGroupContext from "../contexts/CapacityGroupsContextProvider"; +import CapacityGroupsList from "../capacitygroup/CapacityGroupsView"; +import CapacityGroupContext from "../../contexts/CapacityGroupsContextProvider"; function CapacityGroupDetails() { diff --git a/demand-capacity-mgmt-frontend/src/components/CompanyOptions.tsx b/demand-capacity-mgmt-frontend/src/components/common/CompanyOptions.tsx similarity index 96% rename from demand-capacity-mgmt-frontend/src/components/CompanyOptions.tsx rename to demand-capacity-mgmt-frontend/src/components/common/CompanyOptions.tsx index 7ab7c7cf..76859c5b 100644 --- a/demand-capacity-mgmt-frontend/src/components/CompanyOptions.tsx +++ b/demand-capacity-mgmt-frontend/src/components/common/CompanyOptions.tsx @@ -21,7 +21,7 @@ */ import React, { useContext } from 'react'; -import { CompanyContext } from '../contexts/CompanyContextProvider'; +import { CompanyContext } from '../../contexts/CompanyContextProvider'; interface CompanyOptionsProps { selectedCompanyName: string; diff --git a/demand-capacity-mgmt-frontend/src/components/Pagination.tsx b/demand-capacity-mgmt-frontend/src/components/common/Pagination.tsx similarity index 100% rename from demand-capacity-mgmt-frontend/src/components/Pagination.tsx rename to demand-capacity-mgmt-frontend/src/components/common/Pagination.tsx diff --git a/demand-capacity-mgmt-frontend/src/components/QuickAcessItems.tsx b/demand-capacity-mgmt-frontend/src/components/common/QuickAcessItems.tsx similarity index 94% rename from demand-capacity-mgmt-frontend/src/components/QuickAcessItems.tsx rename to demand-capacity-mgmt-frontend/src/components/common/QuickAcessItems.tsx index d33e064d..2b210f84 100644 --- a/demand-capacity-mgmt-frontend/src/components/QuickAcessItems.tsx +++ b/demand-capacity-mgmt-frontend/src/components/common/QuickAcessItems.tsx @@ -23,9 +23,9 @@ import { FaChartLine, FaLink } from 'react-icons/fa'; import { FcComboChart } from 'react-icons/fc'; import { Modal, Button } from 'react-bootstrap'; import { useState } from 'react'; -import DemandsPage from './demands/DemandPage'; -import DemandContextProvider from '../contexts/DemandContextProvider'; -import '../index.css'; +import DemandsPage from '../demands/DemandPage'; +import DemandContextProvider from '../../contexts/DemandContextProvider'; +import '../../index.css'; function QuickAcessItems() { diff --git a/demand-capacity-mgmt-frontend/src/components/Search.tsx b/demand-capacity-mgmt-frontend/src/components/common/Search.tsx similarity index 100% rename from demand-capacity-mgmt-frontend/src/components/Search.tsx rename to demand-capacity-mgmt-frontend/src/components/common/Search.tsx diff --git a/demand-capacity-mgmt-frontend/src/components/TopMenu.tsx b/demand-capacity-mgmt-frontend/src/components/common/TopMenu.tsx similarity index 98% rename from demand-capacity-mgmt-frontend/src/components/TopMenu.tsx rename to demand-capacity-mgmt-frontend/src/components/common/TopMenu.tsx index 1dcd019d..04b025e2 100644 --- a/demand-capacity-mgmt-frontend/src/components/TopMenu.tsx +++ b/demand-capacity-mgmt-frontend/src/components/common/TopMenu.tsx @@ -24,7 +24,7 @@ import Container from 'react-bootstrap/Container'; import Nav from 'react-bootstrap/Nav'; import Navbar from 'react-bootstrap/Navbar'; import { FiSettings,FiLogOut } from 'react-icons/fi'; -import InfoMenu from "./menu/InfoMenu"; +import InfoMenu from "../menu/InfoMenu"; function TopMenuLinks() { diff --git a/demand-capacity-mgmt-frontend/src/components/UnitsofMeasureOptions.tsx b/demand-capacity-mgmt-frontend/src/components/common/UnitsofMeasureOptions.tsx similarity index 95% rename from demand-capacity-mgmt-frontend/src/components/UnitsofMeasureOptions.tsx rename to demand-capacity-mgmt-frontend/src/components/common/UnitsofMeasureOptions.tsx index 4d5240f1..c4336a71 100644 --- a/demand-capacity-mgmt-frontend/src/components/UnitsofMeasureOptions.tsx +++ b/demand-capacity-mgmt-frontend/src/components/common/UnitsofMeasureOptions.tsx @@ -21,7 +21,7 @@ */ import React, { useContext } from 'react'; -import { UnitsofMeasureContext } from '../contexts/UnitsOfMeasureContextProvider'; +import { UnitsofMeasureContext } from '../../contexts/UnitsOfMeasureContextProvider'; interface UnitsOfMeasureOptionsProps { selectedUnitMeasureId: string; diff --git a/demand-capacity-mgmt-frontend/src/components/demands/DemandAddForm.tsx b/demand-capacity-mgmt-frontend/src/components/demands/DemandAddForm.tsx index 91d031b3..552c52cd 100644 --- a/demand-capacity-mgmt-frontend/src/components/demands/DemandAddForm.tsx +++ b/demand-capacity-mgmt-frontend/src/components/demands/DemandAddForm.tsx @@ -26,9 +26,9 @@ import { DemandContext } from '../../contexts/DemandContextProvider'; import DemandCategoryContextProvider from '../../contexts/DemandCategoryProvider'; import DemandCategoryOptions from './DemandCategoryOptions'; import CompanyContextProvider from '../../contexts/CompanyContextProvider'; -import CompanyOptions from '../CompanyOptions'; +import CompanyOptions from '../common/CompanyOptions'; import UnitsofMeasureContextContextProvider from '../../contexts/UnitsOfMeasureContextProvider'; -import UnitsOfMeasureOptions from '../UnitsofMeasureOptions'; +import UnitsOfMeasureOptions from '../common/UnitsofMeasureOptions'; import { Demand } from '../../interfaces/demand_interfaces'; import '../../App.css'; diff --git a/demand-capacity-mgmt-frontend/src/components/demands/DemandEditForm.tsx b/demand-capacity-mgmt-frontend/src/components/demands/DemandEditForm.tsx index f14d47a1..15268379 100644 --- a/demand-capacity-mgmt-frontend/src/components/demands/DemandEditForm.tsx +++ b/demand-capacity-mgmt-frontend/src/components/demands/DemandEditForm.tsx @@ -23,8 +23,8 @@ import React, { useContext, useState, useEffect } from 'react'; import { Form, Button, Col, Row } from 'react-bootstrap'; import { DemandContext } from '../../contexts/DemandContextProvider'; import { Demand, DemandSeriesValue, DemandProp, DemandSeries } from '../../interfaces/demand_interfaces'; -import CompanyOptions from '../CompanyOptions'; -import UnitsOfMeasureOptions from '../UnitsofMeasureOptions'; +import CompanyOptions from '../common/CompanyOptions'; +import UnitsOfMeasureOptions from '../common/UnitsofMeasureOptions'; import Spinner from 'react-bootstrap/Spinner'; import { FiSave } from 'react-icons/fi'; diff --git a/demand-capacity-mgmt-frontend/src/components/demands/DemandPage.tsx b/demand-capacity-mgmt-frontend/src/components/demands/DemandPage.tsx index 3d0074f0..ade0eba9 100644 --- a/demand-capacity-mgmt-frontend/src/components/demands/DemandPage.tsx +++ b/demand-capacity-mgmt-frontend/src/components/demands/DemandPage.tsx @@ -23,9 +23,9 @@ import React, { useContext, useState, useMemo, useCallback } from 'react'; import { Modal, Button, Form, Col, Row, Breadcrumb, Dropdown } from 'react-bootstrap'; import { DemandProp, DemandSeries, DemandSeriesValue } from '../../interfaces/demand_interfaces'; -import Pagination from '../Pagination'; +import Pagination from '../common/Pagination'; import DemandsTable from './DemandsTable'; -import DemandsSearch from '../Search'; +import DemandsSearch from '../common/Search'; import EditForm from './DemandEditForm'; import { FaEllipsisV, FaSearch} from 'react-icons/fa'; import AddForm from './DemandAddForm'; @@ -33,7 +33,7 @@ import { DemandContext } from '../../contexts/DemandContextProvider'; import UnitsofMeasureContextContextProvider from '../../contexts/UnitsOfMeasureContextProvider'; import DemandCategoryContextProvider from '../../contexts/DemandCategoryProvider'; import CompanyContextProvider from '../../contexts/CompanyContextProvider'; -import WeeklyView from '../WeeklyView'; +import WeeklyView from './DemandsOverview'; const DemandsPage: React.FC = () => { const [showEditModal, setIsEditModalOpen] = useState(false); diff --git a/demand-capacity-mgmt-frontend/src/components/WeeklyView.tsx b/demand-capacity-mgmt-frontend/src/components/demands/DemandsOverview.tsx similarity index 98% rename from demand-capacity-mgmt-frontend/src/components/WeeklyView.tsx rename to demand-capacity-mgmt-frontend/src/components/demands/DemandsOverview.tsx index bfe0fb98..b1f59f73 100644 --- a/demand-capacity-mgmt-frontend/src/components/WeeklyView.tsx +++ b/demand-capacity-mgmt-frontend/src/components/demands/DemandsOverview.tsx @@ -21,11 +21,11 @@ */ import React, { useContext, useState, useEffect } from 'react'; -import '../../src/index.css'; -import { DemandCategoryContext } from '../contexts/DemandCategoryProvider'; -import { Demand, DemandCategory, DemandProp, DemandSeriesValue, MaterialDemandSery } from '../interfaces/demand_interfaces'; +import '../../index.css'; +import { DemandCategoryContext } from '../../contexts/DemandCategoryProvider'; +import { Demand, DemandCategory, DemandProp, DemandSeriesValue, MaterialDemandSery } from '../../interfaces/demand_interfaces'; import { Button, ButtonGroup, ToggleButton, OverlayTrigger, Tooltip } from 'react-bootstrap'; -import { DemandContext } from '../contexts/DemandContextProvider'; +import { DemandContext } from '../../contexts/DemandContextProvider'; import moment from 'moment'; import 'moment-weekday-calc'; diff --git a/demand-capacity-mgmt-frontend/src/components/menu/Component63.tsx b/demand-capacity-mgmt-frontend/src/components/menu/Component63.tsx deleted file mode 100644 index aa865839..00000000 --- a/demand-capacity-mgmt-frontend/src/components/menu/Component63.tsx +++ /dev/null @@ -1,43 +0,0 @@ -/* - * ******************************************************************************* - * Copyright (c) 2023 BMW AG - * Copyright (c) 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 Nav from "react-bootstrap/Nav"; -import {FaArrowDown, FaArrowUp, FaStar} from "react-icons/fa"; - -function Component63() { - - return ( - <> - - - - ); -} - -export default Component63; \ No newline at end of file diff --git a/demand-capacity-mgmt-frontend/src/components/menu/InfoMenu.tsx b/demand-capacity-mgmt-frontend/src/components/menu/InfoMenu.tsx index b7bb9dd3..72ff6108 100644 --- a/demand-capacity-mgmt-frontend/src/components/menu/InfoMenu.tsx +++ b/demand-capacity-mgmt-frontend/src/components/menu/InfoMenu.tsx @@ -21,8 +21,8 @@ */ import Nav from "react-bootstrap/Nav"; -import {FaArrowDown, FaArrowUp, FaStar} from "react-icons/fa"; -import {useInfoMenu } from "../../contexts/InfoMenuContextProvider"; +import { FaArrowDown, FaArrowUp, FaStar } from "react-icons/fa"; +import { useInfoMenu } from "../../contexts/InfoMenuContextProvider"; function InfoMenu() { const { data } = useInfoMenu(); @@ -31,28 +31,28 @@ function InfoMenu() { return ( <>