From bcfeb296ae3131515016c7f25a26bc583698ea87 Mon Sep 17 00:00:00 2001 From: leandrofars Date: Sat, 22 Jun 2024 19:03:11 -0300 Subject: [PATCH] feat(frontend): switching for enterprise version --- frontend/.env | 1 + frontend/build/Dockerfile | 2 +- frontend/build/entrypoint.sh | 4 ++ frontend/src/pages/devices/cwmp/[...id].js | 47 ++++++++++++++++++---- 4 files changed, 46 insertions(+), 8 deletions(-) diff --git a/frontend/.env b/frontend/.env index 6d0a658..32dec17 100644 --- a/frontend/.env +++ b/frontend/.env @@ -2,6 +2,7 @@ NEXT_PUBLIC_REST_ENDPOINT="http://localhost:8000/api" NEXT_PUBLIC_WS_ENDPOINT="http://localhost:5000/" +NEXT_PUBLIC_ENTERPRISE_VERSION="false" # ---------------------------------------------------------------------------- # # -------------------------- Production Environment -------------------------- # diff --git a/frontend/build/Dockerfile b/frontend/build/Dockerfile index 207713b..fede4c2 100644 --- a/frontend/build/Dockerfile +++ b/frontend/build/Dockerfile @@ -6,7 +6,7 @@ COPY ../ ./ RUN npm install -RUN NEXT_PUBLIC_REST_ENDPOINT=REST_API_URL NEXT_PUBLIC_WS_ENDPOINT=WS_URL npm run build +RUN NEXT_PUBLIC_REST_ENDPOINT=REST_API_URL NEXT_PUBLIC_WS_ENDPOINT=WS_URL NEXT_PUBLIC_ENTERPRISE_VERSION=ENTERPRISE_VERSION npm run build RUN ls -la && echo "Listing directory contents done" diff --git a/frontend/build/entrypoint.sh b/frontend/build/entrypoint.sh index bf43c58..5eb5329 100644 --- a/frontend/build/entrypoint.sh +++ b/frontend/build/entrypoint.sh @@ -9,8 +9,12 @@ function apply_path { echo "Check that we have NEXT_PUBLIC_WS_ENDPOINT vars" test -n "$NEXT_PUBLIC_WS_ENDPOINT" + echo "Check that we have NEXT_PUBLIC_ENTERPRISE_VERSION vars" + test -n "$NEXT_PUBLIC_ENTERPRISE_VERSION" + find /app/.next \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s#REST_API_URL#$NEXT_PUBLIC_REST_ENDPOINT#g" find /app/.next \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s#WS_URL#$NEXT_PUBLIC_WS_ENDPOINT#g" + find /app/.next \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s#ENTERPRISE_VERSION#$NEXT_PUBLIC_ENTERPRISE_VERSION#g" } apply_path diff --git a/frontend/src/pages/devices/cwmp/[...id].js b/frontend/src/pages/devices/cwmp/[...id].js index 8baa53b..3e5c605 100644 --- a/frontend/src/pages/devices/cwmp/[...id].js +++ b/frontend/src/pages/devices/cwmp/[...id].js @@ -4,7 +4,9 @@ Tab, Tabs, SvgIcon, Breadcrumbs, -Link } from '@mui/material'; +Link, +Tooltip, +IconButton} from '@mui/material'; import { Layout as DashboardLayout } from 'src/layouts/dashboard/layout'; import { useRouter } from 'next/router'; import { DevicesRPC } from 'src/sections/devices/cwmp/devices-rpc'; @@ -19,6 +21,7 @@ import { DevicesWiFi } from 'src/sections/devices/cwmp/devices-wifi'; import { DevicesDiagnostic } from 'src/sections/devices/cwmp/devices-diagnostic'; import { SiteSurvey } from 'src/sections/devices/cwmp/site-survey'; import { ConnectedDevices } from 'src/sections/devices/cwmp/connecteddevices'; +import InformactionCircleIcon from '@heroicons/react/24/outline/InformationCircleIcon'; const Page = () => { @@ -26,6 +29,7 @@ const Page = () => { const deviceID = router.query.id[0] const section = router.query.id[1] + const enterpriseVersion = process.env.NEXT_PUBLIC_ENTERPRISE_VERSION === "true" ? true : false; const sectionHandler = () => { switch(section){ @@ -80,14 +84,43 @@ const Page = () => { + }}> - } iconPosition={"end"} label="Wi-Fi" onClick={()=>{router.push(`/devices/cwmp/${deviceID}/wifi`)}} value={"wifi"}/> - } iconPosition={"end"} label="Site Survey" onClick={()=>{router.push(`/devices/cwmp/${deviceID}/site-survey`)}} value={"site-survey"}/> - } iconPosition={"end"} label="Connected Devices" onClick={()=>{router.push(`/devices/cwmp/${deviceID}/connected-devices`)}} value={"connected-devices"}/> + } + iconPosition={"end"} + label="Wi-Fi" + onClick={()=>{router.push(`/devices/cwmp/${deviceID}/wifi`)}} + value={"wifi"}/> + } + iconPosition={"end"} + label="Site Survey" + onClick={()=>{router.push(`/devices/cwmp/${deviceID}/site-survey`)}} + value={"site-survey"} + disabled={!enterpriseVersion}/> + } + iconPosition={"end"} + label="Connected Devices" + onClick={()=>{router.push(`/devices/cwmp/${deviceID}/connected-devices`)}} + value={"connected-devices"} + disabled={!enterpriseVersion} + /> {/* {router.push(`/devices/cwmp/${deviceID}/discovery`)}} icon={} iconPosition={"end"} label="Discover Parameters" /> */} - } iconPosition={"end"} label="Diagnostic" onClick={()=>{router.push(`/devices/cwmp/${deviceID}/diagnostic`)}} value={"diagnostic"}/> - {router.push(`/devices/cwmp/${deviceID}/msg`)}} icon={} iconPosition={"end"} label="Remote Messages" /> + } + iconPosition={"end"} + label="Diagnostic" + onClick={()=>{router.push(`/devices/cwmp/${deviceID}/diagnostic`)}} + value={"diagnostic"} + disabled={!enterpriseVersion}/> + {router.push(`/devices/cwmp/${deviceID}/msg`)}} + icon={} + iconPosition={"end"} + label="Remote Messages" /> {