From 82ef586a169826c74fe0a2b3a80efe9c9a42ad2f Mon Sep 17 00:00:00 2001 From: Himani Dwivedi Date: Wed, 29 Nov 2023 21:09:28 +0100 Subject: [PATCH] feat: monitoring and graph UI --- .../app/pages/dco/addRelease/newRelease.tsx | 24 ++-- .../pages/dco/monitoring/MonitoringList.tsx | 131 +++++++++++------ .../app/pages/dco/monitoring/graphModal.tsx | 15 ++ .../pages/dco/monitoring/weather/index.tsx | 135 ------------------ .../releaseManagementList.tsx | 14 +- .../functionReleaseManagement.services.ts | 21 ++- 6 files changed, 135 insertions(+), 205 deletions(-) create mode 100644 developer-console-ui/app/pages/dco/monitoring/graphModal.tsx delete mode 100644 developer-console-ui/app/pages/dco/monitoring/weather/index.tsx diff --git a/developer-console-ui/app/pages/dco/addRelease/newRelease.tsx b/developer-console-ui/app/pages/dco/addRelease/newRelease.tsx index a332f6c..1d29966 100644 --- a/developer-console-ui/app/pages/dco/addRelease/newRelease.tsx +++ b/developer-console-ui/app/pages/dco/addRelease/newRelease.tsx @@ -117,19 +117,17 @@ export function NewRelease({ show, onClose, path, cellData, setToastOpenScenario const createRequestPayload = () => { const ecuData = [{ - ecu: ecuDataObj[0].ecu, - hardwareVersion: ecuDataObj[0].hardwareVersion, - componentId: ecuDataObj[0].componentId, - componentName: ecuDataObj[0].componentName, - componentVersion: ecuDataObj[0].componentVersion, - status: ecuDataObj[0].status, - lastChange: ecuDataObj[0].lastChange, - data: { - actualBatteryCapacity: ecuDataObj[0].actualBatteryCapacity, - minTemperature, - maxTemperature - } - }] + ecu: ecuDataObj[0].ecu, + hardwareVersion: ecuDataObj[0].hardwareVersion, + componentId: ecuDataObj[0].componentId, + componentName: ecuDataObj[0].componentName, + componentVersion: ecuDataObj[0].componentVersion, + status: ecuDataObj[0].status, + lastChange: ecuDataObj[0].lastChange, + actualBatteryCapacity: ecuDataObj[0].actualBatteryCapacity, + minTemperature, + maxTemperature + }] handleNewReleaseSubmitInService(releaseId, type, brands, countries, metaTrack, models, ecuData, releaseDate, releaseStatus, onClose) } diff --git a/developer-console-ui/app/pages/dco/monitoring/MonitoringList.tsx b/developer-console-ui/app/pages/dco/monitoring/MonitoringList.tsx index 158a23b..0f3bf45 100644 --- a/developer-console-ui/app/pages/dco/monitoring/MonitoringList.tsx +++ b/developer-console-ui/app/pages/dco/monitoring/MonitoringList.tsx @@ -1,48 +1,93 @@ -import React from "react"; -import ActiveLink from "../../../components/layout/ActiveLink"; -import {checkRoute} from "../../../services/functionShared"; -import router from "next/router"; -import {Flex, FlexItem, NavigationBar, NavigationBarItem} from "@dco/sdv-ui"; +import { Box, Button, Table, Toast } from "@dco/sdv-ui" +import { useStoreActions, useStoreState } from "easy-peasy" +import { useEffect, useState } from "react" +import Pagination from "../../shared/paginationTable" +import BoxToast from "../../../components/layout/boxToast" +import { + getReleaseData, + numberOfReleases, + releaseManagementRowData +} from "../../../services/functionReleaseManagement.services" +import { GraphModal } from "./graphModal" -const MonitoringList = ({ children }: any) => { - const pathname = router?.pathname - const trackTabClicked = router.pathname === '/dco/tracksMain' - const libTabClicked = router.pathname.includes('/dco/scenario') - const simulationTabClicked = router.pathname === '/dco/simulation' - const releaseTabClicked = router.pathname === '/dco/release_management' - const token = localStorage.getItem('token') +export function Selectedscenario() { + return useStoreState((state: any) => state.selectedscenario) +} + + +const MonitoringList = ({ path }: any) => { + const setCount = useStoreActions((actions: any) => actions.setCount) + const [isToastOpenScenario, setToastOpenScenario] = useState(false) + const [successMsgScenario, setSuccessMsgScenario] = useState('') + const [currentPage, setCurrentPage] = useState(1) + const [showGraphPopup, setShowGraphPopup] = useState(false) + const [pageData, setPageData] = useState({ + rowData: [], + isLoading: false, + totalPages: 0, + totalReleases: 0, + }) + + useEffect(() => { + setPageData((prevState) => ({ + ...prevState, + rowData: [], + isLoading: true, + })) + getReleaseData().then((info) => { + const filteredReleases = info?.filter((item: any) => item.releaseStatus == 'READY_FOR_RELEASE') + setPageData({ + isLoading: false, + rowData: releaseManagementRowData(filteredReleases), + totalPages: 1, + totalReleases: numberOfReleases(filteredReleases), + }) + setCount(numberOfReleases(filteredReleases)); + }) + }, []) + + const columns = [ + { + Header: 'Release ID', + accessor: 'releaseId', + }, + { + Header: 'Release Date', + accessor: 'releaseDate', + }, + { + Header: '', + accessor: 'menu', + formatter: (value: any, cell: any) => { + return () + } + }, + ] + + const showGraph = (releaseId: string) => return ( <> - {/* ... (other code) */} - - - {/* LEFT SIDEBAR */} - - - - Weather - - - - - Terrain - - - - - Routs - - - - - - - {/* */} - - + + + + + {/* Toast message for deleting a scenario */} + { +
+ +
+
+ } - ); -}; - -export default MonitoringList; \ No newline at end of file + ) +} +export default MonitoringList \ No newline at end of file diff --git a/developer-console-ui/app/pages/dco/monitoring/graphModal.tsx b/developer-console-ui/app/pages/dco/monitoring/graphModal.tsx new file mode 100644 index 0000000..547b38e --- /dev/null +++ b/developer-console-ui/app/pages/dco/monitoring/graphModal.tsx @@ -0,0 +1,15 @@ +import { Headline, Popup, Spacer } from "@dco/sdv-ui"; +import { useState } from "react"; + +export function GraphModal (props: any) { + const [closeModal, setCloseModal] = useState(false) + + return <> + + + Release ${props.releaseId} + + + + +} \ No newline at end of file diff --git a/developer-console-ui/app/pages/dco/monitoring/weather/index.tsx b/developer-console-ui/app/pages/dco/monitoring/weather/index.tsx deleted file mode 100644 index 0b8c8b8..0000000 --- a/developer-console-ui/app/pages/dco/monitoring/weather/index.tsx +++ /dev/null @@ -1,135 +0,0 @@ -import { Flex, Box, Headline, Button, NavigationBar, NavigationBarItem, StatusMessage, Spacer } from '@dco/sdv-ui' -import { useStoreActions, useStoreState } from 'easy-peasy' -import { useRouter } from 'next/router' -import { useState } from 'react' -import Layout from "../../../../components/layout/layout"; -import {checkRoute, invert} from "../../../../services/functionShared"; -import {onClickNewTrack} from "../../../../services/functionTrack.service"; -import {onClickNewSimulation} from "../../../../services/functionSimulation.service"; -import NewScenario from "../../addEditScenario/newScenario"; -import NewRelease from "../../addRelease/newRelease"; -import ActiveLink from "../../../../components/layout/ActiveLink"; -export function Count() { - return useStoreState((state: any) => state.count) -} -// main landing page -const Another = ({ children }: any) => { - const router = useRouter() - const [showScenarioPopup, setShowScenarioPopup] = useState(false) - const [showReleasePopup, setShowReleasePopup] = useState(false) - const setCompid = useStoreActions((actions: any) => actions.setCompid) - const pathname = router?.pathname - const trackTabClicked = router.pathname === '/dco/tracksMain' - const libTabClicked = router.pathname.includes('/dco/scenario') - const simulationTabClicked = router.pathname === '/dco/simulation' - const releaseTabClicked = router.pathname === '/dco/release_management' - const token = localStorage.getItem('token') - return (<>{ - - - - {token ? <> - {/* Header */} - - {/* HEADLINE */} - - - - - {libTabClicked && {Count() || 0} scenarios} - {releaseTabClicked && {Count() || 0} releases} - {trackTabClicked && {Count() || 0} tracks} - {simulationTabClicked && {Count() || 0} simulations} - - - {libTabClicked && ()} - - {/* New Release I guess */} - {releaseTabClicked && ()} - {/* */} - - {trackTabClicked && ()} - {simulationTabClicked && ()} - - - - - - - {/* NAV */} - - - - scenario - - - tracks - - - simulations - - - release management - - - monitoring - - - - {/* RIGHT */} - - - - - - - - {children} - - - - - : - <> - - - - - - - - Session has been expired click - - - - to login again - - - - - - - - - } - - - - - } - - ) -} -export default Another diff --git a/developer-console-ui/app/pages/dco/release_management/releaseManagementList.tsx b/developer-console-ui/app/pages/dco/release_management/releaseManagementList.tsx index 70335e8..b5555ea 100644 --- a/developer-console-ui/app/pages/dco/release_management/releaseManagementList.tsx +++ b/developer-console-ui/app/pages/dco/release_management/releaseManagementList.tsx @@ -78,13 +78,13 @@ const ReleaseManagementList = ({path}: any) => { } } }, - { - Header: '', - accessor: 'menu', - formatter: (value: any, cell: any) => { - return () - } - }, + // { + // Header: '', + // accessor: 'menu', + // formatter: (value: any, cell: any) => { + // return () + // } + // }, { Header: '', accessor: 'delete', diff --git a/developer-console-ui/app/services/functionReleaseManagement.services.ts b/developer-console-ui/app/services/functionReleaseManagement.services.ts index a5030e3..fa606c7 100644 --- a/developer-console-ui/app/services/functionReleaseManagement.services.ts +++ b/developer-console-ui/app/services/functionReleaseManagement.services.ts @@ -7,6 +7,8 @@ interface EcuData { status: string; lastChange: string; actualBatteryCapacity: string; + maxTemperature: string; + minTemperature: string } interface FunctionData { @@ -29,6 +31,8 @@ interface ReleaseData { interface SUMOdata { actualBatteryCapacity: string; + maxTemperature: string; + minTemperature: string } interface EcuSUMOData { @@ -71,6 +75,8 @@ function convertReleaseDataToSUMOData(input: ReleaseData): ReleaseSUMOData { lastChange: ecuData.lastChange, data: { actualBatteryCapacity: ecuData.actualBatteryCapacity, + maxTemperature: ecuData.maxTemperature, + minTemperature: ecuData.minTemperature }, }); @@ -153,8 +159,9 @@ export const createReleaseData = async (newRelease: any) => { }) .then((res) => res.json()) .then((result) => result) + .then(() => launchReleaseData(newRelease.releaseId)) .catch((error) => { - console.log('Error fetching data:::', error.message) + console.log('Error create release and trigger sumo :::', error.message) }) } @@ -215,12 +222,10 @@ export const handleNewReleaseSubmitInService = async ( componentName: string, componentVersion: string, status: string, - lastChange: string, - data: { - actualBatteryCapacity: string, - minTemperature: string, - maxTemperature: string - } + lastChange: string; + actualBatteryCapacity: string, + minTemperature: string, + maxTemperature: string }>, releaseDate: string, releaseStatus: string, @@ -271,6 +276,8 @@ const mockReleaseData: ReleaseData = { status: 'string', lastChange: 'string', actualBatteryCapacity: 'string', + maxTemperature: 'string', + minTemperature: 'string' }, ], },