Skip to content

Commit

Permalink
Merge pull request #107 from Sanketika-Obsrv/release-branch
Browse files Browse the repository at this point in the history
Release branch
  • Loading branch information
pallakartheekreddy authored Nov 12, 2024
2 parents b3f13c8 + f6a749c commit 44596f9
Show file tree
Hide file tree
Showing 22 changed files with 629 additions and 362 deletions.
30 changes: 30 additions & 0 deletions src/main/controllers/dataset_exists.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { NextFunction, Request, Response } from "express";
import { fetchDataset, fetchDraftDataset } from "../services/dataset";
import _ from "lodash";
import { getDiff } from "json-difference";

export default {
name: 'dataset:exists',
handler: () => async (request: Request, response: Response, next: NextFunction) => {
const { datasetId } = request.params;
try {
const liveDataset = await Promise.allSettled([fetchDataset({ datasetId })])
if(liveDataset[0].status == 'fulfilled') {
return response.status(200).json(liveDataset[0].value)
}

const draftDataset = await Promise.allSettled([fetchDraftDataset({ datasetId })])
if(draftDataset[0].status == 'fulfilled') {
return response.status(200).json(draftDataset[0].value)
}

if(draftDataset[0].status == 'rejected') {
return response.status(_.get(draftDataset[0], ['reason', 'status'])).json(_.get(draftDataset[0], ['reason', 'response', 'data']))
}


} catch (error) {
next(error);
}
}
};
8 changes: 8 additions & 0 deletions src/main/resources/routesConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ export default [
ensureLoggedInMiddleware,
controllers.get('dataset:diff')?.handler({})
]
},
{
path: 'exists/:datasetId',
method: 'GET',
middlewares: [
ensureLoggedInMiddleware,
controllers.get('dataset:exists')?.handler({})
]
}
]
},
Expand Down
11 changes: 2 additions & 9 deletions web-console-v2/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@ import SideBar from 'components/Sidebar/Sidebar';
import Navbar from 'components/Navbar/Navbar';
import _ from 'lodash';
import { AlertContextProvider } from 'contexts/AlertContextProvider';
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import { BrowserRouter } 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 { fetchSystemSettings, getBaseURL } from 'services/configData';
import Loadable from 'pages/auth/components/Loadable';
const Login = Loadable(lazy(() => import('pages/auth/Login')));

const useSidebarToggle = () => {

const sidebarExpandValue = localStorage.getItem('sidebarExpand')
const [isSidebarExpanded, setSidebarExpanded] = useState<boolean>(
_.isEqual(localStorage.getItem('sidebarExpand'), "true")
_.isEqual(localStorage.getItem('sidebarExpand'), "true") && window.location.pathname !== '/console/login'
);

const toggleSidebar = useCallback(() => {
Expand All @@ -42,15 +40,10 @@ const App: FC = () => {
fetchSystemSettings();
}, []);



return (
<QueryClientProvider client={queryClient}>
<Locales>
<BrowserRouter basename={getBaseURL()}>
<Routes>
<Route path='/login' element={<Login />} />
</Routes>
<Navbar />
<div
className={`${styles.appContainer} ${isSidebarExpanded ? styles.expanded : styles.collapsed}`}
Expand Down
2 changes: 1 addition & 1 deletion web-console-v2/src/components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function BasicBreadcrumbs(): JSX.Element {
// Capitalize first letter apart from datasetId
// const displayName = isLast ? name : _.capitalize(name);
if(matchedRoute){
const displayName = matchedRoute?.label !== undefined ? matchedRoute.label : name;
const displayName = matchedRoute?.label !== undefined ? matchedRoute.label : _.capitalize(name);
return isLast ? (
<Typography
variant="body1"
Expand Down
60 changes: 14 additions & 46 deletions web-console-v2/src/components/Stepper/DynamicStepper.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { useEffect, useState } from 'react';
import { useLocation, useNavigate, useParams } from 'react-router-dom';
import { Box, Typography } from '@mui/material';
import { Box, StepButton, StepLabel, Step, Stepper, Typography } from '@mui/material';
import styles from './Stepper.module.css';
import { theme } from 'theme';

interface Step {
name: string;
Expand All @@ -25,12 +24,6 @@ const DynamicStepper = ({ steps: initialSteps, initialSelectedStep }: StepperPro
const { datasetId }: any = useParams();
const [selectedStep, setSelectedStep] = useState(initialSelectedStep);
const [steps, setSteps] = useState(initialSteps);
const handleClick = (route: string, index: number, completed: boolean, onProgress: boolean) => {
if (completed || onProgress) {
setSelectedStep(index);
navigate(route);
}
};

useEffect(() => {
const queryParams = new URLSearchParams(location.search);
Expand Down Expand Up @@ -60,7 +53,7 @@ const DynamicStepper = ({ steps: initialSteps, initialSelectedStep }: StepperPro
}
}, [location, initialSteps]);

const handleRouteNavigation = (route: string, datasetId: string) => {
const handleRouteNavigation = (route: string) => {
const routeMapping: Record<string, string> = {
connector: `/dataset/edit/connector/configure/${datasetId}`,
ingestion: `/dataset/edit/ingestion/schema/${datasetId}`,
Expand Down Expand Up @@ -107,43 +100,18 @@ const DynamicStepper = ({ steps: initialSteps, initialSelectedStep }: StepperPro

return (
<Box className={styles.stepper}>
{steps.map((step, idx) => (
<Box
key={idx}
className={`${styles.step} ${step.completed ? styles.completed : ''} ${step.active ? styles.selected : ''}`}
onClick={() => {
if (['connector', 'ingestion', 'processing', 'storage', 'preview'].includes(step.route)) {
handleRouteNavigation(step.route, datasetId);
} else {
handleClick(step.route, step.index, step.completed, step.active);
}
}}
>
<Box
className={`${styles.circle} ${step.completed ? styles.completed : ''} ${step.active ? styles.selected : ''}`}
sx={{
backgroundColor: step.completed ? 'secondary.main' : step.active ? 'secondary.light' : 'var(--body-secondary-background)',
border: step.active || step.completed ? `0.125rem solid ${theme.palette.secondary.main}` : ' 0.125rem solid var(--body-secondary)'
}}
>
{step.completed ? (
<span>&#10003;</span>
) : (
<Typography color={step.active ? 'secondary.main' : 'var(--body-secondary)'}>
{step.index}
</Typography>
)}
</Box>
<Typography
variant={step.completed && !step.active ? 'body1' : step.active ? 'h1' : 'body1'}
color={step.completed && !step.active ? '' : step.index === selectedStep ? 'secondary.main' : ''}
sx={{fontSize: '0.8rem'}}
>
{step.name}
</Typography>
</Box>
))}
</Box>
<Stepper nonLinear activeStep={selectedStep - 1} sx={{ width: '48rem' }} >
{steps.map((step) => {
return (
<Step key={step.route} completed={step.completed}>
<StepButton onClick={() => handleRouteNavigation(step.route)}>
<StepLabel optional={<Typography variant="body1">Optional</Typography>} StepIconProps={{sx: {classes: step.completed ? 'completed':''}}}>{step.name}</StepLabel>
</StepButton>
</Step>
);
})}
</Stepper>
</Box>
);
};

Expand Down
12 changes: 12 additions & 0 deletions web-console-v2/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,16 @@ div.HelpSection_expanded__vqSxk {

.MuiAccordionSummary-content {
margin-bottom: 5px !important;
}

.MuiStepIcon-root.Mui-completed {
color: #f58601 !important;
}

.MuiStepIcon-root.Mui-active {
color: #f58601 !important;
}

.MuiStepLabel-label.Mui-active {
color: #f58601 !important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import HelpSection from 'components/HelpSection/HelpSection';
import _ from 'lodash';
import React, { useEffect, useState } from 'react';
import { useLocation, useNavigate, useParams } from 'react-router-dom';
import { endpoints, useFetchDatasetsById, useReadConnectors } from 'services/dataset';
import { endpoints, useFetchDatasetsById, useReadConnectors, useUpdateDataset } from 'services/dataset';
import styles from './ConnectorConfiguration.module.css';
import sampleSchema from './Schema';
import { customizeValidator } from '@rjsf/validator-ajv8';
Expand Down Expand Up @@ -126,7 +126,7 @@ const ConnectorConfiguration: React.FC = () => {
}
const readConnector = useReadConnectors({ connectorId: selectedConnectorId });

const dataset = useFetchDatasetsById({datasetId, queryParams: 'status=Draft&mode=edit&fields=connectors_config'});
const dataset = useFetchDatasetsById({datasetId, queryParams: 'status=Draft&mode=edit&fields=connectors_config,version_key'});
useEffect(() => {
if (dataset.data && dataset.data.connectors_config[0]) {
const connectorId = _.get(dataset.data.connectors_config[0], 'connector_id')
Expand Down Expand Up @@ -244,19 +244,46 @@ const ConnectorConfiguration: React.FC = () => {
return combinedHelp;
};

const updateDataset = useUpdateDataset();

const handleButtonClick = () => {

navigate(`/dataset/edit/ingestion/meta/${datasetId}?step=connector&skipped=false&completed=true`, {
state: {
connectorConfig: {
id: selectedConnectorId,
connector_id: selectedConnectorId,
connector_config: formData || {},
operations_config: opFormData || {}
if(datasetId === '<new>') {
navigate(`/dataset/edit/ingestion/meta/${datasetId}?step=connector&skipped=false&completed=true`, {
state: {
connectorConfig: {
id: selectedConnectorId,
connector_id: selectedConnectorId,
connector_config: formData || {},
operations_config: opFormData || {}
},
selectedConnectorId
}
});
} else {
updateDataset.mutate(
{
data: {
dataset_id: datasetId,
connectors_config: [{
value: {
id: `${datasetId}_${selectedConnectorId}`,
connector_id: selectedConnectorId,
connector_config: formData || {},
operations_config: opFormData || {},
version: 'v2'
},
action: "upsert"
}]
}
},
selectedConnectorId
}
});
{
onSuccess: () => {
navigate(`/dataset/edit/ingestion/meta/${datasetId}?step=connector&skipped=false&completed=true`);
}
}
);
}
};

const handleHelpSectionToggle = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import intereactIds from 'data/telemetry/interact.json'
import { v4 } from 'uuid';
import Health from '../health';
import { metricsMetadata } from '../metrics';
import { getConfigValueV1 } from 'services/configData';

const IndividualMetricDashboards = (props: any) => {
const { id } = props;
Expand Down Expand Up @@ -73,11 +74,16 @@ const IndividualMetricDashboards = (props: any) => {
}
}

const navigateToGrafana = (path: any) => {
if (path) {
window.open(path);
}
}
const renderGrafanaIcon = () => {
const link = _.get(metadata, 'links.grafana.link')
if (!link) return null;
return (
<Tooltip title="Navigate to Grafana Dashboard" onClick={_ => navigateToGrafana(link)}>
<Tooltip title="Navigate to Grafana Dashboard" onClick={() => { navigateToGrafana(getConfigValueV1("GRAFANA_URL")) }}>
<IconButton
data-edataid={`${intereactIds.grafana_navigate}:${metricId}`}
color="secondary" variant="light" sx={{ color: 'text.primary', bgcolor: 'transparent', ml: 0.75 }}>
Expand Down
6 changes: 3 additions & 3 deletions web-console-v2/src/pages/Rollup/components/ListRollups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const ListRollups = () => {
})

const addNewRollup = () => {
navigate(`/home/datasets/rollups/${datasetId}`, { state: { rollupGranularityOption: rollupGranularityOption, edit: false } })
navigate(`/datasets/rollups/${datasetId}`, { state: { rollupGranularityOption: rollupGranularityOption, edit: false } })
}

const handleClose = () => {
Expand All @@ -94,7 +94,7 @@ const ListRollups = () => {
return <Box sx={{ marginLeft: -1.5 }}>
<IconButton color="primary" size="large"
onClick={() => {
navigate(`/home/datasets/rollups/${datasetId}`,
navigate(`/datasets/rollups/${datasetId}`,
{ state: { rollupGranularityOption: rollupGranularityOption, edit: true, rollupDatasourceName: value.row.original.datasourceId, aggregationLevel: value.row.original.aggregation } })
}}
>
Expand Down Expand Up @@ -147,7 +147,7 @@ const ListRollups = () => {
</> : renderRollups()}
<Grid item xs={12}>
{rollups.length === granularityOptions.length ? <></> : <Stack direction="row" justifyContent="space-between" alignItems="center" mt={1}>
<Button size="medium" startIcon={<ArrowLeftOutlined />} sx={{ fontWeight: 500 }} onClick={() => navigate(`/home/datasets?status=${DatasetStatus.ReadyToPublish}`)}>
<Button size="medium" startIcon={<ArrowLeftOutlined />} sx={{ fontWeight: 500 }} onClick={() => navigate(`/datasets?status=${DatasetStatus.ReadyToPublish}`)}>
Previous
</Button>
<Button size="medium" startIcon={<PlusOutlined />} sx={{ fontWeight: 500 }} onClick={addNewRollup}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const ReviewRollup = (props: any) => {
};

const handleFinish = () => {
navigate(`/home/datasets/management/${datasetId}?status=${DatasetStatus.Draft}`, { state: { jsonSchema: datasetState } });
navigate(`/datasets/management/${datasetId}?status=${DatasetStatus.Draft}`, { state: { jsonSchema: datasetState } });
};

const columns = useMemo(
Expand Down
Loading

0 comments on commit 44596f9

Please sign in to comment.