Skip to content

Commit

Permalink
Merge branch 'enterprise-features' into release-enterprise
Browse files Browse the repository at this point in the history
  • Loading branch information
HarishGangula committed Nov 12, 2024
2 parents 9023183 + 84198e6 commit 55a80c2
Show file tree
Hide file tree
Showing 39 changed files with 3,048 additions and 187 deletions.
4 changes: 4 additions & 0 deletions src/main/middlewares/passportAuthenticate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import _ from 'lodash';
import passport from 'passport';
import appConfig from '../../shared/resources/appConfig';
import { User } from '../types';
import { logger } from '../../shared/utils/logger';

const baseURL = appConfig.BASE_URL;
const private_key: string = appConfig.USER_TOKEN_PRIVATE_KEY;
Expand All @@ -24,13 +25,15 @@ export default {
handler: () => (req: Request, res: Response, next: NextFunction) => {
passport.authenticate('local', (err: Error, user: User) => {
if (err) {
logger.error("err:", err)
return next(err);
}
if (!user) {
return res.redirect(`${baseURL}/login`);
}
return req.login(user, (loginErr) => {
if (loginErr) {
logger.error("loginErr: ", loginErr)
return next(loginErr);
}
return generateToken(user)
Expand All @@ -41,6 +44,7 @@ export default {
return res.redirect(baseURL || '/');
})
.catch((tokenError) => {
logger.error("tokenError: ", tokenError)
return next(tokenError);
});
});
Expand Down
22 changes: 22 additions & 0 deletions src/main/proxies/configExt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { createProxyMiddleware } from 'http-proxy-middleware';
import appConfig from '../../shared/resources/appConfig';
import { onError, onProxyReq, onProxyRes } from '../helpers/proxy';
import promEntities from '../resources/prometheusEntities'

const entity = promEntities.config;
const baseURL = appConfig.BASE_URL;

export default {
path: `${baseURL}/configV1`,
name: 'config_ext',
handler() {
return createProxyMiddleware({
target: appConfig.CONFIG_API_EXT.URL,
changeOrigin: true,
pathRewrite: function (path: string, req: any) { return path.replace(`${baseURL}/configV1`, '') },
onProxyReq: onProxyReq({ entity }),
onProxyRes: onProxyRes({ entity }),
onError: onError({ entity })
})
}
}
4 changes: 2 additions & 2 deletions src/shared/middlewares/globalErrorHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { NextFunction, Request, Response } from 'express';
import { transform } from '../utils/transformResponse';
import appConfig from '../resources/appConfig';
import { logger } from '../utils/logger';

export default {
name: 'globalErrorHandler',
Expand All @@ -14,11 +15,10 @@ export default {
} = error;

const { id = 'api' } = request.responsePayload || {};

logger.error(error)
if (request.url.includes("oauth/v1/login")) {
return response.redirect(`${appConfig.BASE_URL}/login?err=Invalid Credentials`);
}

response.status(status).json(transform({ id, responseCode, params: { err: errorCode, errmsg: message } }));
},
};
3 changes: 3 additions & 0 deletions src/shared/resources/appConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export default {
CONFIG_API: {
URL: env.CONFIG_API_URL || 'http://localhost:4000',
},
CONFIG_API_EXT: {
URL: env.CONFIG_API_EXT_URL || 'http://localhost:4001',
},
SYSTEM_API: {
URL: env.SYSTEM_API_URL || 'http://localhost:4002',
},
Expand Down
3 changes: 3 additions & 0 deletions web-console-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
"framer-motion": "^7.5.3",
"match-sorter": "^6.3.1",
"jsonata": "2.0.2",
"jsoneditor": "^9.10.4",
"jsoneditor-react": "^3.1.2",
"lodash": "4.17.21",
"lottie-web": "^5.12.2",
"millify": "^6.1.0",
Expand Down Expand Up @@ -107,6 +109,7 @@
"@types/react": "18.2.0",
"@types/react-dom": "18.2.0",
"@types/react-gauge-chart": "^0.4.3",
"@types/react-json-editor-ajrm": "^2.5.3",
"@types/react-lottie": "^1.2.10",
"@types/react-table": "7.7.20",
"@types/uuid": "^10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion web-console-v2/src/components/@extended/AnimateButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable */
import React from 'react';
import { ReactNode } from 'react';

import { motion, useCycle } from 'framer-motion';
Expand Down
12 changes: 6 additions & 6 deletions web-console-v2/src/components/BasicReactTable.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable */
import React from 'react';
import { Table, TableBody, TableCell, TableHead, TableRow, Typography } from '@mui/material';
import { useTable } from 'react-table';

Expand All @@ -12,10 +12,10 @@ function BasicReactTable({ columns, data, striped, header = true, styles = {} }:
<Table {...getTableProps()}>
{header &&
(<TableHead>
{headerGroups.map((headerGroup) => (
<TableRow {...headerGroup.getHeaderGroupProps()}>
{headerGroups.map((headerGroup, i) => (
<TableRow {...headerGroup.getHeaderGroupProps()} key={i}>
{headerGroup.headers.map((column: any) => (
<TableCell sx={{ ...styles, textTransform: 'unset' }} {...column.getHeaderProps([{ className: column.className }])}>
<TableCell key={i} sx={{ ...styles, textTransform: 'unset' }} {...column.getHeaderProps([{ className: column.className }])}>
<Typography variant="h5">{column.render('Header')}</Typography>
</TableCell>
))}
Expand All @@ -27,9 +27,9 @@ function BasicReactTable({ columns, data, striped, header = true, styles = {} }:
{rows.map((row, i) => {
prepareRow(row);
return (
<TableRow {...row.getRowProps()}>
<TableRow {...row.getRowProps()} key={i}>
{row.cells.map((cell: any) => (
<TableCell sx={{ ...styles }} {...cell.getCellProps([{ className: cell.column.className }])}>{cell.render('Cell')}</TableCell>
<TableCell key={i} sx={{ ...styles }} {...cell.getCellProps([{ className: cell.column.className }])}>{cell.render('Cell')}</TableCell>
))}
</TableRow>
);
Expand Down
134 changes: 134 additions & 0 deletions web-console-v2/src/components/ExpandingTable/ExpandingTableV1.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import React from 'react';
import { Fragment } from 'react';
import * as _ from "lodash";
import { checkForMustFixConflict } from 'services/json-schema';
import { TableContainer, Table, TableBody, TableCell, TableHead, TableRow, Typography, Skeleton } from '@mui/material';
import { useTable, useFilters, Column, useExpanded } from 'react-table';
import MainCard from 'components/MainCard';
import ScrollX from 'components/ScrollX';
import HtmlTooltip from '../HtmlTooltip';

interface Props {
columns: Column[];
data: [];
updateMyData: (rowIndex: number, columnId: any, value: any) => void;
skipPageReset: boolean;
limitHeight: boolean;
tHeadHeight?: number;
renderRowSubComponent: any;
showSearchBar: boolean,
styles?: any;
context?: Record<string, any>
}

function ReactTable({ columns, data, updateMyData, skipPageReset, limitHeight, tHeadHeight, renderRowSubComponent, showSearchBar, styles = {}, context = {} }: Props) {
const tableSx = limitHeight ? { height: 'auto', overflowY: 'scroll' } : {};
const { disableRowColor = false } = context;
const {
getTableProps,
getTableBodyProps,
headerGroups,
prepareRow,
rows,
visibleColumns,
} = useTable(
{
columns,
data,
getSubRows: (row: any) => row.subRows,
},
useExpanded
);

return (
<TableContainer sx={tableSx}>
<Table stickyHeader sx={{ borderCollapse: 'collapse' }} size="small" {...getTableProps()}>
<TableHead sx={tHeadHeight ? { height: tHeadHeight } : {}}>
{headerGroups.map((headerGroup, i) => (
<TableRow {...headerGroup.getHeaderGroupProps()} key={i}>
{headerGroup.headers.map((column: any) => (
<HtmlTooltip
disableFocusListener
disableTouchListener
title={
<>
<Typography color="inherit">{column.render('tipText')}</Typography>
<em>{"Editable - "}</em> <b>{`${column.render('editable')}`}</b>
</>
}
key={i}
placement="top-start"
arrow
>
<TableCell sx={{ p: 0.5, ...styles }} {...column.getHeaderProps()}>
<Typography variant="h5" textTransform='capitalize'>{column.render('Header')}</Typography>
</TableCell>
</HtmlTooltip>
))}
</TableRow>
))}
</TableHead>
<TableBody {...getTableBodyProps()}>
{headerGroups.map((group: any, i) => (
<TableRow {...group.getHeaderGroupProps()} key={i}>
{group.headers.map((column: any, i:any) => (
<TableCell sx={{ ...styles }}{...column.getHeaderProps([{ className: column.className }])} key={i}>
{column.canFilter ? column.render('Filter') : null}
</TableCell>
))}
</TableRow>
))}
{rows.map((row: any, i: number) => {
prepareRow(row);
const [hasSevereConflict, areAllConflictsResolved] = checkForMustFixConflict(_.get(row, 'original'));

const bgColor = () => {
if (hasSevereConflict && !areAllConflictsResolved) return { bgcolor: `#FFEEEE` };
else if (hasSevereConflict && areAllConflictsResolved) return { bgcolor: `#EAFBEE` };
else if (row?.original?.isNewlyAdded) return { bgcolor: `#EAFBEE` };
else return {};
}

return (
<Fragment key={i}>
<TableRow {...row.getRowProps()} sx={{ ...(!disableRowColor && bgColor()) }}>
{
row.cells.map((cell: any) => (
<TableCell sx={cell.column.errorBg ? { p: 0.5, ...styles } : { p: 0.5, ...styles }} {...cell.getCellProps()} key={i}>
{cell.render('Cell')}
</TableCell>
))
}
</TableRow>
</Fragment>
);
})}
</TableBody>
</Table>
</TableContainer>
);
}

const ExpandingTable = ({ columns, data, updateMyData, skipPageReset, limitHeight, tHeadHeight, showSearchBar = true, styles = {}, context = {} }: any) => {

return (
<MainCard content={false}>
<ScrollX>
<ReactTable
columns={columns}
data={data}
updateMyData={updateMyData}
renderRowSubComponent={null}
skipPageReset={skipPageReset}
limitHeight={limitHeight}
tHeadHeight={tHeadHeight}
showSearchBar={showSearchBar}
styles={styles}
context={context}
/>
</ScrollX>
</MainCard>
);
};

export default ExpandingTable;
1 change: 1 addition & 0 deletions web-console-v2/src/components/ScrollX.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
// material-ui
import { styled } from '@mui/material/styles';

Expand Down
1 change: 1 addition & 0 deletions web-console-v2/src/components/Styled/Buttons.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import { styled } from '@mui/material/styles';
import { Button } from '@mui/material';

Expand Down
2 changes: 2 additions & 0 deletions web-console-v2/src/components/Styled/Cards.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from 'react';
import { styled } from '@mui/material/styles';
import { Card, Typography } from '@mui/material';

const GenericCard = styled(Card)(({ theme }) => ({
outline: 'none',
padding: theme.spacing(3, 3),
margin: theme.spacing(1, 0),
boxShadow: 'none'
}));

const CardTitle = styled(Typography)(({ theme }) => ({
Expand Down
1 change: 1 addition & 0 deletions web-console-v2/src/components/Styled/Typography.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import { styled } from '@mui/material/styles';
import { Typography } from '@mui/material';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ const AsyncLabel = (props: any) => {

return <>
{loading && <Loader loading={loading} />}
<Typography {...rest} >
{!loading && <Typography {...rest} >
{prefix} {label} {suffix}
</Typography>
</Typography>}
</>
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
[class*='MuiTypography-root'][class*='MuiTypography-h5'] {
font-size: 1.125rem;
margin-bottom: -0.375rem;
font-weight: 600;
}

.button {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react';
import { DownloadOutlined } from '@ant-design/icons';
import _ from 'lodash';
import { Stack, Typography, Box, Button } from '@mui/material';

import AnimateButton from 'components/@extended/AnimateButton';
import { StandardWidthButton } from 'components/Styled/Buttons';

const WizardNavigator = ({ showPrevious, gotoPreviousSection, gotoNextSection, enableDownload, handleDownload, master, section = undefined, nextDisabled = false, edit }: any) => {

return <Stack direction="row" justifyContent={showPrevious ? 'space-between' : 'flex-end'} mx={6}>

{showPrevious && gotoPreviousSection &&
<Button
variant="outlined"
type="button"
onClick={gotoPreviousSection}
>
<Typography variant="buttonSecondaryCTA">Previous</Typography>
</Button>
}

<Box display="flex" justifyContent="space-evenly" alignItems="center">
{enableDownload && handleDownload &&
<Button
startIcon={<DownloadOutlined style={{ fontSize: '1.25rem' }} />}
sx={{ width: 'auto' }}
type="button"
onClick={handleDownload}
variant='outlined'
>
<Typography variant="buttonSecondaryCTA">Download JSON Schema</Typography>
</Button>
}

{gotoNextSection &&
<Button
variant="contained"
type="button"
onClick={gotoNextSection}
disabled={nextDisabled}>
<Typography variant="button">Proceed</Typography>
</Button>
}
</Box>
</Stack>
};

export default WizardNavigator;
Loading

0 comments on commit 55a80c2

Please sign in to comment.