Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into Send-events
Browse files Browse the repository at this point in the history
  • Loading branch information
JeraldJF committed Oct 30, 2024
2 parents 8b0a8a3 + 9b72116 commit 4b68fc4
Show file tree
Hide file tree
Showing 23 changed files with 154 additions and 73 deletions.
2 changes: 1 addition & 1 deletion web-console-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"homepage": "/console",
"proxy": "http://localhost:3000/console",
"proxy": "http://localhost:3000/",
"dependencies": {
"@ant-design/colors": "^6.0.0",
"@ant-design/icons": "^5.5.1",
Expand Down
13 changes: 10 additions & 3 deletions web-console-v2/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import React, { useState, useCallback, FC, lazy } from 'react';
import React, { useState, useCallback, FC, lazy, useEffect } from 'react';
import { QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import SideBar from 'components/Sidebar/Sidebar';
import Navbar from 'components/Navbar/Navbar';
import _ from 'lodash';
import { AlertContextProvider } from 'contexts/AlertContextProvider';
import { BrowserRouter, Route, Routes, useLocation } from 'react-router-dom';
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import AlertComponent from 'components/@extended/CustomAlert';
import AppRouter from 'router';
import styles from 'App.module.css';
import { queryClient } from 'queryClient';
import Locales from 'components/Locales';
import { getBaseURL } from 'services/configData';
import { fetchSystemSettings, getBaseURL } from 'services/configData';
import Loadable from 'pages/auth/components/Loadable';
const Login = Loadable(lazy(() => import('pages/auth/Login')));

Expand All @@ -38,6 +38,12 @@ const useSidebarToggle = () => {
const App: FC = () => {
const { isSidebarExpanded, toggleSidebar } = useSidebarToggle();

useEffect(() => {
fetchSystemSettings();
}, []);



return (
<QueryClientProvider client={queryClient}>
<Locales>
Expand Down Expand Up @@ -65,3 +71,4 @@ const App: FC = () => {
};

export default App;

14 changes: 10 additions & 4 deletions web-console-v2/src/components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { Typography, Breadcrumbs, Grid, Box, Badge } from '@mui/material';
import { NavLink, useLocation } from 'react-router-dom';
import { NavLink, useLocation, useNavigate } from 'react-router-dom';
import NotificationsNoneOutlinedIcon from '@mui/icons-material/NotificationsNoneOutlined';
import styles from './Navbar.module.css';
import Grafana from 'assets/icons/Grafana';
Expand All @@ -11,12 +11,15 @@ import Notification from 'components/NotificationBar/AlertNotification';
import { useEffect, useState } from 'react';
import { fetchFiringAlerts } from 'services/alerts';
import logo from 'assets/images/obsrvLogo.svg';
import { getBaseURL } from 'services/configData';
import { getBaseURL, getConfigValueV1 } from 'services/configData';
import { errorInterceptor, responseInterceptor } from 'services/http';
import { addHttpRequestsInterceptor } from 'services/http';

const OBSRV_WEB_CONSOLE = process.env.REACT_APP_OBSRV_WEB_CONSOLE as string || "/console/datasets?status=Live";

function BasicBreadcrumbs(): JSX.Element {
const location = useLocation();
const rnavigate = useNavigate();
const pathname = location.pathname;

const [openNotification, setOpenNotification] = useState(false);
Expand All @@ -38,6 +41,9 @@ function BasicBreadcrumbs(): JSX.Element {
window.location.assign(OBSRV_WEB_CONSOLE);
};

useEffect(() => {
addHttpRequestsInterceptor({ responseInterceptor, errorInterceptor: errorInterceptor({ navigate: rnavigate }) })
}, [])
useEffect(() => {
const fetchAlerts = async () => {
try {
Expand Down Expand Up @@ -95,10 +101,10 @@ function BasicBreadcrumbs(): JSX.Element {
</Grid>
<Grid item xs={1} className={styles.navIcons}>
<div className={styles.icons}
onClick={() => { navigate(getConfigValue("GRAFANA_URL")) }}>
onClick={() => { navigate(getConfigValueV1("GRAFANA_URL")) }}>
<Grafana color="secondary" />
</div>
<div className={styles.icons} onClick={() => { navigate(getConfigValue("SUPERSET_URL")) }}>
<div className={styles.icons} onClick={() => { navigate(getConfigValueV1("SUPERSET_URL")) }}>
<Superset />
</div>
<div className={styles.icons} onClick={toggleNotification}>
Expand Down
25 changes: 20 additions & 5 deletions web-console-v2/src/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import styles from './Sidebar.module.css';
import SidebarElements from './SidebarElements';
import { useTheme } from '@mui/material/styles';
import _ from 'lodash';
import apiEndpoints from 'data/apiEndpoints';
import { http } from 'services/http';
import { useAlert } from 'contexts/AlertContextProvider';

interface Props {
onExpandToggle: () => void;
Expand All @@ -29,6 +32,7 @@ const redirectUrl: any = [""];
const Sidebar: React.FC<Props> = ({ onExpandToggle, expand }) => {
const theme = useTheme();
const elements = SidebarElements();
const { showAlert } = useAlert();
const navigate = useNavigate();
const location = useLocation();
const pathname = location.pathname;
Expand All @@ -47,6 +51,13 @@ const Sidebar: React.FC<Props> = ({ onExpandToggle, expand }) => {
pathSegments[1] === 'preview'
) {
setSelectedItem('/home/new-dataset');
} else if (
pathSegments[1] === 'alertRules'
) {
const mainRoute = `/${pathSegments[0]}/${pathSegments[1]}`;
const subRoute = location.pathname;
setSelectedItem(mainRoute);
(mainRoute.match(subRoute)?.index === 0) ? navigate(mainRoute+'/custom') : navigate(subRoute);
} else if (pathSegments.length > 2) {
const mainRoute = `/${pathSegments[0]}/${pathSegments[1]}`;
const subRoute = location.pathname;
Expand Down Expand Up @@ -100,7 +111,11 @@ const Sidebar: React.FC<Props> = ({ onExpandToggle, expand }) => {
};

const handleLogout = () => {
alert('logout');
http.get(apiEndpoints.logout).then(() => {
navigate(`/login`);
}).catch(() => {
showAlert('Failed to logout', 'error');
})
};

const DrawerList = (
Expand Down Expand Up @@ -247,8 +262,8 @@ const Sidebar: React.FC<Props> = ({ onExpandToggle, expand }) => {
})}
</List>

{/* <List sx={{ marginTop: 'auto' }}>
<Tooltip title={!expand ? 'Settings' : ''} placement="right">
<List sx={{ marginTop: 'auto' }}>
{/* <Tooltip title={!expand ? 'Settings' : ''} placement="right">
<ListItem
className={`${styles.listItem} ${
selectedItem === '/home/settings'
Expand Down Expand Up @@ -294,7 +309,7 @@ const Sidebar: React.FC<Props> = ({ onExpandToggle, expand }) => {
)}
</ListItemButton>
</ListItem>
</Tooltip>
</Tooltip> */}
<Tooltip title={!expand ? 'Logout' : ''} placement="right">
<ListItemButton onClick={handleLogout}>
<Icon>
Expand All @@ -311,7 +326,7 @@ const Sidebar: React.FC<Props> = ({ onExpandToggle, expand }) => {
)}
</ListItemButton>
</Tooltip>
</List> */}
</List>
</Box>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion web-console-v2/src/components/Sidebar/SidebarElements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const SidebarElements = () => {
id: 'alertmanagement',
icon: React.createElement(AlertOutlined),
title: 'Alerts',
route: '/home/alertRules/custom'
route: '/home/alertRules'
},
{
id: 'notifications',
Expand Down
24 changes: 20 additions & 4 deletions web-console-v2/src/components/Stepper/DynamicStepper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,33 @@ const DynamicStepper = ({ steps: initialSteps, initialSelectedStep }: StepperPro
queryParams: 'fields=status'
});

const handleRouteNavigation = (route: string, datasetId: string) => {
const routeMapping: Record<string, string> = {
ingestion: `/home/ingestion/schema-details/${datasetId}`,
processing: `/home/processing/${datasetId}`,
storage: `/home/storage/${datasetId}`,
preview: `/home/preview/${datasetId}`
};

const targetRoute = routeMapping[route] || route;
navigate(targetRoute);
};

return (
<Box className={styles.stepper}>
{steps.map((step, idx) => (
<Box
key={idx}
className={`${styles.step} ${step.completed ? styles.completed : ''} ${step.index === selectedStep || step.onProgress ? styles.selected : ''}`}
onClick={() =>
fetchLiveDataset?.data === undefined ? handleClick(step.route, step.index, step.completed, step.onProgress) : () => {
// eslint-disable-next-line @typescript-eslint/no-empty-function
onClick={() => {
if (!fetchLiveDataset?.data) {
if (['ingestion', 'processing', 'storage', 'preview'].includes(step.route)) {
handleRouteNavigation(step.route, datasetId);
} else {
handleClick(step.route, step.index, step.completed, step.onProgress);
}
}
}
}}
>
<Box
className={`${styles.circle} ${step.completed && !step.onProgress ? styles.completed : ''} ${step.index === selectedStep || step.onProgress ? styles.selected : ''}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { NotificationsActiveOutlined, NotificationsOff, RefreshOutlined } from '
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import Loader from 'components/Loader';
import { getConfigValue } from 'services/configData';
import { useAlert } from 'contexts/AlertContextProvider';

dayjs.extend(utc);
Expand Down
4 changes: 2 additions & 2 deletions web-console-v2/src/pages/auth/components/LoginSocialButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { useTheme } from '@mui/material/styles';
import { useMediaQuery, Button, Stack } from '@mui/material';
import socialbuttons from './socialbuttons';
import interactIds from 'data/telemetry/interact.json'
import { getConfigValue } from 'services/configData';
import { getConfigValueV1 } from 'services/configData';

const LoginSocialButton = () => {

const theme = useTheme();
const matchDownSM = useMediaQuery(theme.breakpoints.down('sm'));
const allowedAuthTypes = getConfigValue("AUTHENTICATION_ALLOWED_TYPES") || ""
const allowedAuthTypes = getConfigValueV1("AUTHENTICATION_ALLOWED_TYPES") || ""

const renderSocialButtons = (option) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion web-console-v2/src/pages/dashboardV1/datasets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ const ClusterHealth = () => {
onClose={handleClose}
/>
</Box>

)
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
import React from "react";
import {
Box, Typography, Alert, Grid, Checkbox
Expand All @@ -22,10 +23,7 @@ const DataFormats = (props: any) => {
<Grid container display={"flex"} flexDirection={"column"}>
<Grid item xs={4}>
<Box display="flex" alignItems="center">
<Checkbox checked={true} onChange={
// eslint-disable-next-line
() => { }
} />
<Checkbox checked={true} />
<Typography variant="h6" fontWeight={400}>
{"Individual Events"}
</Typography>
Expand All @@ -37,10 +35,7 @@ const DataFormats = (props: any) => {
<Grid container display={"flex"} flexDirection={"column"}>
<Grid item xs={3}>
<Box display="flex" alignItems="center">
<Checkbox checked={true} onChange={
// eslint-disable-next-line
() => { }
} />
<Checkbox checked={true} />
<Typography variant="h6" fontWeight={400}>
{"Batch Mode"}
</Typography>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
import React from "react";
import {
Table, TableBody,
Expand Down Expand Up @@ -39,8 +40,8 @@ const Transformations = (props: any) => {
</TableRow>
</TableHead>
<TableBody>
{data.map((item: any, i: any) => (
<TableRow key={i}>
{data.map((item: any) => (
<TableRow key={item.id}>
{displayModifiedColumns(id).map((cellName: any) => {
if (cellName.id === "_transformationType" && item[cellName.id] === "custom")
return (
Expand Down Expand Up @@ -77,7 +78,7 @@ const Transformations = (props: any) => {
{customTypes.map(({ title, data, id }, i: any) => {
if (_.size(data) > 0)
return (
<Grid item xs={12} sm={12} md={12} lg={12} key={i}>
<Grid item xs={12} sm={12} md={12} lg={12} key={id}>
{renderTable(title, data, id)}
</Grid>
); else return null;
Expand Down
5 changes: 3 additions & 2 deletions web-console-v2/src/pages/datasetV1/utils/renderCells.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
import React from "react";
import {
Box, Typography, Button, Dialog, DialogTitle, Select, DialogContent, TextareaAutosize, FormControl, MenuItem, Popover, FormControlLabel, Stack, IconButton, Tooltip
Expand Down Expand Up @@ -211,7 +212,7 @@ const renderDataTypeCell = ({
<Typography variant="h6" fontWeight="bold">
Resolved
<Typography variant="body1" my={2}>
Data type of field <strong>{row?.column}</strong> is resolved to '{value}'
Data type of field <strong>{row?.column}</strong> is resolved to &quot;{value}&quot;
</Typography>
</Typography>
<Box my={1}>
Expand Down Expand Up @@ -411,7 +412,7 @@ const renderArrivalFormatCell = ({
<Typography variant="h6" fontWeight="bold">
Resolved
<Typography variant="body1" my={2}>
Arrival Format of field <strong>{row?.column}</strong> is resolved to '{value}'
Arrival Format of field <strong>{row?.column}</strong> is resolved to &quot;{value}&quot;
</Typography>
</Typography>
<Box my={1}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { useNavigate } from 'react-router';
import { renderSections } from 'pages/alertManager/services/utils';
import SendTestMessage from './components/SendTestMessage';
import Loader from 'components/Loader';
import { getConfigValue } from 'services/configData';
import { useAlert } from 'contexts/AlertContextProvider';

const isValid = (config: Record<string, any>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { renderSections } from 'pages/alertManager/services/utils';
import MainCard from 'components/MainCard';
import SendTestMessage from './components/SendTestMessage';
import { renderSkeleton } from 'services/skeleton';
import { getConfigValue } from 'services/configData';
import { useAlert } from 'contexts/AlertContextProvider';

const isValid = (config: Record<string, any>) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
import React from "react";
import { Grid } from "@mui/material";
import MUIForm from "components/form";
Expand All @@ -16,8 +17,6 @@ const validator = asyncValidation();
const SelectChannelType = (props: any) => {
const { setFormData, sectionLabel, existingState = {} } = props;
const [value, subscribe] = useState<any>(existingState);
// eslint-disable-next-line
const onSubmission = (value: any) => { };
const validationConfigs = { notificationChannelNameMaxLen: 100 }
const formikRef = useRef(null);

Expand Down Expand Up @@ -82,7 +81,6 @@ const SelectChannelType = (props: any) => {
initialValues={value}
enableReinitialize={true}
subscribe={subscribe}
onSubmit={(value: any) => onSubmission(value)}
fields={fields}
size={{ sm: 6, xs: 6, lg: 6 }}
validationSchema={validationSchema}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Paper } from "@mui/material"
import MainCard from "components/MainCard"
import globalConfig from 'data/initialConfig';
import { getConfigValue } from "services/configData";
import { getConfigValueV1 } from "services/configData";

const GrafanaChart = (props: any) => {
const { url, width, height } = props;
const graphanaUrl = getConfigValue("GRAFANA_URL");
const graphanaUrl = getConfigValueV1("GRAFANA_URL");
return <>
<Paper elevation={globalConfig.elevation}>
<MainCard content={false} sx={{ mt: 1.5 }}>
Expand Down
Loading

0 comments on commit 4b68fc4

Please sign in to comment.