diff --git a/package.json b/package.json index 16bb130f..d9b7debe 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "json-difference": "^1.16.1", "jsonwebtoken": "^9.0.1", "kafkajs": "^2.2.4", + "keycloak-connect": "^26.0.5", "lodash": "^4.17.21", "lodash-es": "^4.17.21", "morgan": "^1.10.0", diff --git a/src/app.ts b/src/app.ts index 45cfd587..6cb198a8 100644 --- a/src/app.ts +++ b/src/app.ts @@ -6,6 +6,8 @@ import mountProxies from './main/utils/proxy'; import passport from 'passport'; import { pool } from './shared/databases/postgres'; import pgSession from 'connect-pg-simple'; +import { authProviderFactory } from './main/services/authProviderFactory'; +import path from 'path'; const app = express(); const sessionSecret: any = process.env.SESSION_SECRET @@ -27,9 +29,29 @@ mountProxies(app, proxies); app.use(express.json()); app.use(express.urlencoded({ extended: false })); app.use(cookieParser()); -app.use(passport.initialize()); -app.use(passport.session()); import './main/services/auth'; // Don't change this import position in file +import appConfig from './shared/resources/appConfig'; +const authenticationType = appConfig.AUTHENTICATION_TYPE; +const keycloakUrl = appConfig.KEYCLOAK.URL; +const keycloakClientID = appConfig.KEYCLOAK.CLIENT_ID; +const keycloakRealm = appConfig.KEYCLOAK.REALM; + +const keycloakConfig = { + resource: keycloakClientID, + realm: keycloakRealm, + authServerUrl: keycloakUrl, + bearerOnly: false +}; + +const authProvider = authProviderFactory(authenticationType,keycloakConfig, sessionStore); +app.use(authProvider.init()) +app.get('/console/logout', authProvider.authenticate(), async (req:any, res) => { + await authProvider.logout(req, res); + res.redirect('/console'); +}); +app.get('/console', authProvider.authenticate(), (req, res) => { + res.sendFile(path.join(__dirname, 'build', 'index.html')); +}); export default app; diff --git a/src/main/controllers/config.ts b/src/main/controllers/config.ts index a0b6b67a..e2cc748b 100644 --- a/src/main/controllers/config.ts +++ b/src/main/controllers/config.ts @@ -26,7 +26,8 @@ export default { "transformationFieldMaxLen":100, "denormInputFieldMaxLen":100, "alertsPerPage":10 - } + }, + "AUTHENTICATION_TYPE": appConfig.AUTHENTICATION_TYPE }) }, }; \ No newline at end of file diff --git a/src/main/controllers/user_create.ts b/src/main/controllers/user_create.ts index 9e39e5d0..9ca3eefb 100644 --- a/src/main/controllers/user_create.ts +++ b/src/main/controllers/user_create.ts @@ -1,9 +1,11 @@ import { Request, Response, NextFunction } from 'express'; -import userService from '../services/oauthUsers'; -import { v4 } from 'uuid'; -import bcrypt from 'bcryptjs'; import { transform } from '../../shared/utils/transformResponse'; import _ from 'lodash'; +import appConfig from '../../shared/resources/appConfig'; +import { userCreateWithKeycloak } from '../services/keycloak'; +import { userCreateAsBasic } from '../services/basic'; + +const authenticationType = appConfig.AUTHENTICATION_TYPE; export default { name: 'user:create', @@ -11,16 +13,15 @@ export default { try { const userRequest = _.get(req, ['body', 'request']); userRequest.user_name = userRequest.user_name.trim().replace(/\s+/g, '_'); - const { password } = userRequest; - userRequest.password = await bcrypt.hash(password, 12); - if (userRequest.mobile_number) { - const { country_code, number } = userRequest.mobile_number; - userRequest.mobile_number = `${String(country_code).trim()}_${String(number).trim()}`; + if (authenticationType === 'keycloak') { + const keycloakToken = JSON.parse(req?.session['keycloak-token']); + const access_token = keycloakToken.access_token; + const result = await userCreateWithKeycloak(access_token, userRequest); + res.status(200).json(transform({ id: req.body.id, result: { id: result.id, user_name: result.user_name, email_address: result.email_address } })); + } else if (authenticationType === 'basic') { + const result = await userCreateAsBasic(userRequest); + res.status(200).json(transform({ id: req.body.id, result: { id: result.id, user_name: result.user_name, email_address: result.email_address } })); } - const userIdentifier = { id: v4(), created_on: new Date().toISOString() }; - const userInfo = { ...userRequest, ...userIdentifier }; - const result = await userService.save(userInfo); - res.status(200).json(transform({ id: req.body.id, result: { id: result.id, user_name: result.user_name, email_address: result.email_address } })); } catch (error) { next(error); } diff --git a/src/main/controllers/user_read.ts b/src/main/controllers/user_read.ts index a3bbe4f9..a92ed0c1 100644 --- a/src/main/controllers/user_read.ts +++ b/src/main/controllers/user_read.ts @@ -2,13 +2,38 @@ import { NextFunction, Request, Response } from 'express'; import _ from 'lodash'; import userService from '../services/oauthUsers'; import { transform } from '../../shared/utils/transformResponse'; +import appConfig from '../../shared/resources/appConfig'; + +const authenticationType = appConfig.AUTHENTICATION_TYPE; + +const getUserDetails = function (request: Request) { + if (authenticationType === 'basic') { + const token = _.get(request, ['session', 'token']); + const userName = _.get(request, ['session', 'userDetails', 'user_name']); + const userDetails = { + token: token, + sessionUserName: userName, + }; + return userDetails; + } else if (authenticationType === 'keycloak') { + const keycloakToken = JSON.parse(request?.session['keycloak-token']); + const access_token = keycloakToken?.access_token; + const preferred_username = request?.session?.preferred_username; + const userDetails = { + token: access_token, + sessionUserName: preferred_username, + }; + return userDetails; + } +}; export default { name: 'user:read', handler: () => async (request: Request, response: Response, next: NextFunction) => { try { const { user_name } = _.get(request, ['params']); - const sessionUserName = _.get(request, ['session', 'userDetails', 'user_name']); + const sessionUserDetails = getUserDetails(request); + const sessionUserName = sessionUserDetails?.sessionUserName; if (user_name !== sessionUserName) { response.status(403).json( transform({ @@ -29,7 +54,7 @@ export default { const { fields } = _.get(request, ['query']); const includeToken = _.toLower(_.toString(fields)) === 'user_token'; if (includeToken) { - responseData.result.token = _.get(request, ['session', 'token']); + responseData.result.token = sessionUserDetails?.token; } response.status(200).json(transform(responseData)); } catch (error) { diff --git a/src/main/helpers/oauth/index.ts b/src/main/helpers/oauth/index.ts index 669c4b79..4f27474b 100644 --- a/src/main/helpers/oauth/index.ts +++ b/src/main/helpers/oauth/index.ts @@ -12,6 +12,7 @@ import appConfig from "../../../shared/resources/appConfig"; const server = oauth2orize.createServer(); const baseURL = appConfig.BASE_URL; +const authenticationType = appConfig.AUTHENTICATION_TYPE; server.serializeClient((client, done) => { return done(null, client.id) @@ -165,14 +166,26 @@ export const token = [ ]; export const ensureLoggedInMiddleware = (request: Request, response: Response, next: NextFunction) => { - if (!request?.session?.passport?.user) { - const errorObj = { - status: 401, - message: "You don't have access to view this resource", - responseCode: 'UNAUTHORIZED', - errorCode: 'UNAUTHORIZED', - }; - return next(errorObj) + if(authenticationType === 'basic'){ + if (!request?.session?.passport?.user) { + const errorObj = { + status: 401, + message: "You don't have access to view this resource", + responseCode: 'UNAUTHORIZED', + errorCode: 'UNAUTHORIZED', + }; + return next(errorObj); + } + } else if(authenticationType === 'keycloak'){ + if (!request?.session['keycloak-token']) { + const errorObj = { + status: 401, + message: "You don't have access to view this resource", + responseCode: 'UNAUTHORIZED', + errorCode: 'UNAUTHORIZED', + }; + return next(errorObj); + } } return next(); -} +}; diff --git a/src/main/helpers/proxy.ts b/src/main/helpers/proxy.ts index cd8a93ae..2bef4b66 100644 --- a/src/main/helpers/proxy.ts +++ b/src/main/helpers/proxy.ts @@ -1,6 +1,10 @@ +/* eslint-disable prettier/prettier */ import { Request, Response } from "express"; import _ from 'lodash' import { incrementApiCalls, incrementFailedApiCalls, setQueryResponseTime } from "./prometheus"; +import appConfig from "../../shared/resources/appConfig"; + +const authenticationType = appConfig.AUTHENTICATION_TYPE; export const onError = ({ entity }: any) => (err: any, req: Request, res: Response) => { incrementFailedApiCalls({ entity, endpoint: req.url }); @@ -19,9 +23,14 @@ export const onProxyRes = ({ entity }: any) => (proxyReq: any, req: any, res: Re export const onProxyReq = ({ entity }: any) => (proxyReq: any, req: any, res: Response) => { const startTime = Date.now(); req.startTime = startTime; - const jwtToken: string = req.session?.token; - if (jwtToken) { + if(authenticationType === 'keycloak'){ + const keycloakToken = JSON.parse(req?.session['keycloak-token']); + const access_token: string = keycloakToken.access_token; + proxyReq.setHeader('x-user-token', `${access_token}`); + }else if(authenticationType === 'basic'){ + const jwtToken: string = req.session?.token; proxyReq.setHeader('x-user-token', `${jwtToken}`); + } incrementApiCalls({ entity, endpoint: req.url }); } \ No newline at end of file diff --git a/src/main/resources/routesConfig.ts b/src/main/resources/routesConfig.ts index 4ac8343a..a9e65c54 100644 --- a/src/main/resources/routesConfig.ts +++ b/src/main/resources/routesConfig.ts @@ -23,13 +23,6 @@ export default [ method: 'POST', middlewares: [passportAuthenticateCallback.handler()], }, - { - path: 'logout', - method: 'GET', - middlewares: [ - controllers.get('auth:logout')?.handler({}), - ], - }, { path: 'authorize', method: 'GET', diff --git a/src/main/services/authProviderFactory.ts b/src/main/services/authProviderFactory.ts new file mode 100644 index 00000000..3a9bc97d --- /dev/null +++ b/src/main/services/authProviderFactory.ts @@ -0,0 +1,15 @@ +import { PassportAuthProvider } from './passportAuthProvider'; +import { KeycloakAuthProvider } from './keycloakAuthProvider'; +import { BaseAuthProvider } from '../types'; + +export const authProviderFactory: (type: string, config?: any, sessionStore?: any) => BaseAuthProvider = (type, config, sessionStore) => { + switch (type) { + case 'keycloak': + return new KeycloakAuthProvider(config, sessionStore); + case 'basic': + return new PassportAuthProvider(); + default: + throw new Error("Invalid authentication service type"); + } +}; +export { BaseAuthProvider }; diff --git a/src/main/services/basic.ts b/src/main/services/basic.ts new file mode 100644 index 00000000..94b2ef96 --- /dev/null +++ b/src/main/services/basic.ts @@ -0,0 +1,17 @@ +import _ from 'lodash'; +import { v4 } from 'uuid'; +import bcrypt from 'bcryptjs'; +import userService from '../services/oauthUsers'; + +export const userCreateAsBasic = async (userRequest: any) => { + const { password } = userRequest; + userRequest.password = await bcrypt.hash(password, 12); + if (userRequest.mobile_number) { + const { country_code, number } = userRequest.mobile_number; + userRequest.mobile_number = `${String(country_code).trim()}_${String(number).trim()}`; + } + const userIdentifier = { id: v4(), created_on: new Date().toISOString() }; + const userInfo = { ...userRequest, ...userIdentifier }; + const result = await userService.save(userInfo); + return result; +}; diff --git a/src/main/services/keycloak.ts b/src/main/services/keycloak.ts new file mode 100644 index 00000000..e7a5d84a --- /dev/null +++ b/src/main/services/keycloak.ts @@ -0,0 +1,106 @@ +import axios from 'axios'; +import appConfig from '../../shared/resources/appConfig'; +import _ from 'lodash'; +import userService from '../services/oauthUsers'; + +const keycloakUrl = appConfig.KEYCLOAK.URL; +const keycloakHTTPClient = axios.create({ baseURL: keycloakUrl }); +const keycloakRealm = appConfig.KEYCLOAK.REALM; + +export const authenticated = async (request: any) => { + try { + const userId = request?.kauth?.grant?.access_token?.content?.sub?.split(':'); + const email_address = request?.kauth?.grant?.access_token?.content?.email; + const preferred_username = request?.kauth?.grant?.access_token?.content?.preferred_username; + + request.session.userId = userId?.[userId.length - 1]; + request.session.email_address = email_address; + request.session.preferred_username = preferred_username; + + const user = await userService.find({ id: userId?.[0] }); + request.session.roles = user?.roles; + } catch (err) { + console.log('user not authenticated', request?.kauth?.grant?.access_token?.content?.sub, err); + } +}; + +export const deauthenticated = function (request: any) { + delete request?.session?.roles; + delete request?.session?.userId; + delete request?.session?.email_address; + delete request?.session?.preferred_username; + delete request?.session?.auth_redirect_uri; + delete request?.session?.['keycloak-token']; + + if (request?.session) { + request.session.sessionEvents = request?.session?.sessionEvents || []; + delete request?.session?.sessionEvents; + } +}; + +export const userCreate = async (access_token: any, userRequest: any) => { + const { user_name, email_address } = userRequest; + const password = _.trim(userRequest.password); + const payload = { + email: email_address, + username: user_name, + enabled: true, + credentials: [ + { + type: 'password', + value: password, + temporary: false, + }, + ], + }; + + return keycloakHTTPClient + .post(`/admin/realms/${keycloakRealm}/users`, payload, { + headers: { + Authorization: `Bearer ${access_token}`, + }, + }) + .then((response) => { + const location = _.get(response, 'headers.location'); + const userId = location ? _.last(location.split('/')) : null; + console.log('keyuser', userId); + if (!userId) { + throw new Error('UserId not found'); + } + return userId; + }) + .catch((error) => { + console.log(error); + }); +}; + +export const userCreateWithKeycloak = async (access_token: any, userRequest: any) => { + const { user_name, email_address, roles } = userRequest; + const id = await userCreate(access_token, userRequest); + const created_on = new Date().toISOString(); + const userInfo = { id, user_name, email_address, created_on, roles }; + const result = await userService.save(userInfo); + return result; +}; + +export const keycloakLogout = async (req: any) => { + const userId = req?.session?.userId; + const access_token = req?.kauth?.grant?.access_token?.token; + const refresh_token = req?.kauth?.grant?.refresh_token?.token; + + const data = new URLSearchParams({ + client_id: req?.kauth?.grant?.access_token?.clientId, + refresh_token: refresh_token, + }); + + return keycloakHTTPClient + .post(`admin/realms/${keycloakRealm}/users/${userId}/logout`, data, { + headers: { + Authorization: `Bearer ${access_token}`, + }, + }) + .then() + .catch((error) => { + console.log(error); + }); +}; diff --git a/src/main/services/keycloakAuthProvider.ts b/src/main/services/keycloakAuthProvider.ts new file mode 100644 index 00000000..48e746b1 --- /dev/null +++ b/src/main/services/keycloakAuthProvider.ts @@ -0,0 +1,31 @@ +import Keycloak from 'keycloak-connect'; +import {authenticated, deauthenticated, keycloakLogout} from './keycloak'; +import {Request, Response, NextFunction, RequestHandler} from 'express'; +import { BaseAuthProvider } from '../types'; + +export class KeycloakAuthProvider implements BaseAuthProvider { + private keycloak: Keycloak.Keycloak; + + constructor(keycloakConfig: Keycloak.KeycloakConfig, sessionStore: any) { + this.keycloak = new Keycloak({store: sessionStore}, keycloakConfig); + this.keycloak.authenticated = authenticated; + } + + init(): RequestHandler[] { + return this.keycloak.middleware(); + } + + authenticate(): (req: Request, res: Response, next: NextFunction) => void { + return this.keycloak.protect(); + } + + async logout(req: Request, res: Response): Promise { + try { + await keycloakLogout(req); + deauthenticated(req); + } catch (error) { + console.error('Logout error:', error); + res.status(500).send('Logout failed'); + } + } +} \ No newline at end of file diff --git a/src/main/services/passportAuthProvider.ts b/src/main/services/passportAuthProvider.ts new file mode 100644 index 00000000..a48172b4 --- /dev/null +++ b/src/main/services/passportAuthProvider.ts @@ -0,0 +1,30 @@ +import {Request, Response, NextFunction, RequestHandler} from 'express'; +import passport from 'passport'; +import { BaseAuthProvider } from '../types'; + +export class PassportAuthProvider implements BaseAuthProvider { + + init(): (req: Request, res: Response, next: NextFunction) => void { + return (req: Request, res: Response, next: NextFunction) => { + passport.initialize()(req, res, () => { + passport.session()(req, res, next); + }); + }; + } + + authenticate(): (req: Request, res: Response, next: NextFunction) => void { + return passport.authenticate('session'); + } + async logout(req: Request, res: Response): Promise { + return new Promise((resolve) => { + req.logout({ keepSessionInfo: false }, ((error: any) => { + error && console.log("Error while logout", error) + })) + delete req.session.roles; + delete req.session.userDetails; + delete req.session.token; + delete req.session.passport; + resolve(); + }); + } +} \ No newline at end of file diff --git a/src/main/types/index.ts b/src/main/types/index.ts index aaf49f29..f24190c4 100644 --- a/src/main/types/index.ts +++ b/src/main/types/index.ts @@ -1,3 +1,4 @@ +import {Request, Response, NextFunction, RequestHandler} from 'express'; export interface User { id: string; user_name: string; @@ -28,4 +29,9 @@ export enum ValidationMode { export enum DatasetType { Dataset = 'event', MasterDataset = 'master', +} +export interface BaseAuthProvider { + init(): RequestHandler[] | ((req: Request, res: Response, next: NextFunction) => void); + authenticate(): (req: Request, res: Response, next: NextFunction) => void; + logout: (req: Request, res: Response) => Promise; } \ No newline at end of file diff --git a/src/main/utils/validationSchemas/userCreate.ts b/src/main/utils/validationSchemas/userCreate.ts index cfc181fa..050bea2e 100644 --- a/src/main/utils/validationSchemas/userCreate.ts +++ b/src/main/utils/validationSchemas/userCreate.ts @@ -66,7 +66,7 @@ export default { type: 'array', items: { type: 'string', - enum: ['admin', 'dataset_manager', 'viewer', 'dataset_creator', 'ingestor'], + enum: ['admin', 'dataset_manager', 'viewer', 'dataset_creator', 'ingestor', 'operations_admin'], }, minItems: 1, uniqueItems: true, diff --git a/src/main/utils/validationSchemas/userList.ts b/src/main/utils/validationSchemas/userList.ts index bb389020..63ca6b2b 100644 --- a/src/main/utils/validationSchemas/userList.ts +++ b/src/main/utils/validationSchemas/userList.ts @@ -59,7 +59,7 @@ export default { type: 'array', items: { type: 'string', - enum: ['admin', 'dataset_manager', 'viewer', 'dataset_creator', 'ingestor'], + enum: ['admin', 'dataset_manager', 'viewer', 'dataset_creator', 'ingestor', 'operations_admin'], }, minItems: 1, uniqueItems: true, diff --git a/src/main/utils/validationSchemas/userManageRole.ts b/src/main/utils/validationSchemas/userManageRole.ts index 23762243..72844187 100644 --- a/src/main/utils/validationSchemas/userManageRole.ts +++ b/src/main/utils/validationSchemas/userManageRole.ts @@ -39,7 +39,7 @@ export default { properties: { value: { type: 'string', - enum: ['admin', 'dataset_manager', 'viewer', 'dataset_creator', 'ingestor'], + enum: ['admin', 'dataset_manager', 'viewer', 'dataset_creator', 'ingestor', 'operations_admin'], minLength: 1, }, action: { diff --git a/src/shared/resources/appConfig.ts b/src/shared/resources/appConfig.ts index 079c883d..a07a20c1 100644 --- a/src/shared/resources/appConfig.ts +++ b/src/shared/resources/appConfig.ts @@ -64,4 +64,12 @@ export default { }, BASE_URL: env.BASE_URL || '/console', USER_TOKEN_PRIVATE_KEY: env.USER_TOKEN_PRIVATE_KEY || '', + AUTHENTICATION_TYPE: env.AUTHENTICATION_TYPE || 'basic', + KEYCLOAK: { + URL: env.KEYCLOAK_SERVER_URL || 'http://localhost:8080', + REALM: env.KEYCLOAK_REALM || 'obsrvWebConsole', + CLIENT_ID: env.KEYCLOAK_CLIENT_ID || 'webConsole', + PUBLIC_CLIENT: env.KEYCLOAK_PUBLIC_CLIENT || 'false', + SSL_REQUIRED: env.KEYCLOAK_SSL_REQUIRED || 'external', + }, }; diff --git a/web-console-v2/package.json b/web-console-v2/package.json index 8cf46d1a..d12c58b2 100644 --- a/web-console-v2/package.json +++ b/web-console-v2/package.json @@ -55,7 +55,7 @@ "react-dropzone": "14.2.3", "react-gauge-chart": "^0.5.1", "react-intl": "6.6.8", - "react-lottie": "^1.2.4", + "react-lottie": "1.2.4", "react-router-dom": "^6.23.0", "react-scripts": "5.0.1", "react-split-pane": "2.0.3", diff --git a/web-console-v2/src/Chip.ts b/web-console-v2/src/Chip.ts deleted file mode 100644 index 0405f16f..00000000 --- a/web-console-v2/src/Chip.ts +++ /dev/null @@ -1,89 +0,0 @@ -// material-ui -import { Theme } from '@mui/material/styles'; - -// project import -import getColors from 'utils/getColors'; - -// types -import { ExtendedStyleProps } from 'types/extended'; - -// ==============================|| CHIP - COLORS ||============================== // - -function getColor({ color, theme }: ExtendedStyleProps) { - const colors = getColors(theme, color); - const { dark } = colors; - - return { - '&.Mui-focusVisible': { - outline: `2px solid ${dark}`, - outlineOffset: 2 - } - }; -} - -function getColorStyle({ color, theme }: ExtendedStyleProps) { - const colors = getColors(theme, color); - const { light, lighter, main } = colors; - - return { - color: main, - backgroundColor: lighter, - borderColor: light, - '& .MuiChip-deleteIcon': { - color: main, - '&:hover': { - color: light - } - } - }; -} - -// ==============================|| OVERRIDES - CHIP ||============================== // - -export default function Chip(theme: Theme) { - const defaultLightChip = getColorStyle({ color: 'secondary', theme }); - return { - MuiChip: { - styleOverrides: { - root: { - borderRadius: 4, - '&:active': { - boxShadow: 'none' - }, - '&.MuiChip-colorPrimary': getColor({ color: 'primary', theme }), - '&.MuiChip-colorSecondary': getColor({ color: 'secondary', theme }), - '&.MuiChip-colorError': getColor({ color: 'error', theme }), - '&.MuiChip-colorInfo': getColor({ color: 'info', theme }), - '&.MuiChip-colorSuccess': getColor({ color: 'success', theme }), - '&.MuiChip-colorWarning': getColor({ color: 'warning', theme }) - }, - sizeLarge: { - fontSize: '1rem', - height: 40 - }, - sizeMedium: { - fontSize: '0.875rem', - }, - light: { - ...defaultLightChip, - '&.MuiChip-lightPrimary': getColorStyle({ color: 'primary', theme }), - '&.MuiChip-lightSecondary': getColorStyle({ color: 'secondary', theme }), - '&.MuiChip-lightError': getColorStyle({ color: 'error', theme }), - '&.MuiChip-lightInfo': getColorStyle({ color: 'info', theme }), - '&.MuiChip-lightSuccess': getColorStyle({ color: 'success', theme }), - '&.MuiChip-lightWarning': getColorStyle({ color: 'warning', theme }) - }, - combined: { - border: '1px solid', - ...defaultLightChip, - '&.MuiChip-combinedPrimary': getColorStyle({ color: 'primary', theme }), - '&.MuiChip-combinedSecondary': getColorStyle({ color: 'secondary', theme }), - '&.MuiChip-combinedError': getColorStyle({ color: 'error', theme }), - '&.MuiChip-combinedInfo': getColorStyle({ color: 'info', theme }), - '&.MuiChip-combinedSuccess': getColorStyle({ color: 'success', theme }), - '&.MuiChip-combinedWarning': getColorStyle({ color: 'warning', theme }) - } - } - } - }; -} diff --git a/web-console-v2/src/components/AlertDialog.tsx b/web-console-v2/src/components/AlertDialog.tsx deleted file mode 100644 index 22b40ffc..00000000 --- a/web-console-v2/src/components/AlertDialog.tsx +++ /dev/null @@ -1,39 +0,0 @@ -/* eslint-disable */ -import { Button, Dialog, DialogContentText } from '@mui/material'; -import { Box, DialogActions, DialogContent, DialogTitle } from '@mui/material'; -import interactIds from 'data/telemetry/interact.json'; - -const AlertDialog = ({ handleClose, action = null, open = false, context = {} }: any) => { - const handleAction = () => { - if (action) action(); - handleClose(true); - }; - - context.show = context.show === undefined ? true : context.show; - - return ( - <> - - - {context?.title} - - {context?.content} - {context?.component} - - {context.show === true && ( - - - - - )} - - - - ); -}; - -export default AlertDialog; diff --git a/web-console-v2/src/components/Buttons.tsx b/web-console-v2/src/components/Buttons.tsx deleted file mode 100644 index 88931de1..00000000 --- a/web-console-v2/src/components/Buttons.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { styled } from '@mui/material/styles'; -import { Button } from '@mui/material'; - -const StandardWidthButton = styled(Button)(({ theme }) => ({ - outline: 'none', - margin: theme.spacing(1), - width: '14.375rem', - height: '2.75rem', -})); - - -export { StandardWidthButton }; diff --git a/web-console-v2/src/components/Cards/DatasetMetricsCard/DatasetMetricsCard.tsx b/web-console-v2/src/components/Cards/DatasetMetricsCard/DatasetMetricsCard.tsx index 55b66bcd..52669fd5 100644 --- a/web-console-v2/src/components/Cards/DatasetMetricsCard/DatasetMetricsCard.tsx +++ b/web-console-v2/src/components/Cards/DatasetMetricsCard/DatasetMetricsCard.tsx @@ -14,8 +14,8 @@ import { druidQueries } from 'services/druid'; import { useParams } from 'react-router-dom'; import { useAlert } from 'contexts/AlertContextProvider'; import { DatasetStatus, DatasetType } from 'types/datasets'; -import ApexWithFilters from 'sections/dashboard/analytics/ChartFilters'; -import ApexChart from 'sections/dashboard/analytics/apex'; +import ApexWithFilters from 'pages/Dashboard/analytics/ChartFilters'; +import ApexChart from 'pages/Dashboard/analytics/apex'; import filters from 'data/chartFilters'; const getQueryByType = (queryType: string, datasetId: any, isMasterDataset: boolean, interval: string) => { diff --git a/web-console-v2/src/components/CheckboxWithInfoIcon/CheckboxWithInfoIcon.module.css b/web-console-v2/src/components/CheckboxWithInfoIcon/CheckboxWithInfoIcon.module.css deleted file mode 100644 index 2ebb7e34..00000000 --- a/web-console-v2/src/components/CheckboxWithInfoIcon/CheckboxWithInfoIcon.module.css +++ /dev/null @@ -1,4 +0,0 @@ -.iconStyle { - width: 1.25rem; - height: 1.25rem; -} diff --git a/web-console-v2/src/components/CheckboxWithInfoIcon/CheckboxWithInfoIcon.tsx b/web-console-v2/src/components/CheckboxWithInfoIcon/CheckboxWithInfoIcon.tsx deleted file mode 100644 index ebb2866c..00000000 --- a/web-console-v2/src/components/CheckboxWithInfoIcon/CheckboxWithInfoIcon.tsx +++ /dev/null @@ -1,134 +0,0 @@ -import React from 'react'; -import { Box, FormControlLabel, Checkbox, Tooltip, IconButton, Stack } from '@mui/material'; -import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'; -import { WidgetProps } from '@rjsf/utils'; - -// Define props for CustomCheckbox -interface CustomCheckboxProps { - label: string; - value: boolean; - onChange: (value: boolean) => void; - description?: string; // Optional description -} - -// Checkbox with info icon component -const CheckboxWithInfoWidget: React.FC = ({ - id, - value, - label, - onChange, - schema, - uiSchema -}) => { - const { title } = schema; - const { 'ui:help': help } = uiSchema || {}; - return ( - - onChange(event.target.checked)} - color="primary" - /> - } - label={label} - sx={{ - '& .MuiTypography-root': { - color: '#111111', - fontSize: '16px' - } - }} - /> - {help && ( - - - - - - )} - - ); -}; - -// Custom checkbox component with description -export const CustomCheckbox: React.FC = ({ - label, - value, - onChange, - description -}) => { - return ( - - onChange(event.target.checked)} - color="primary" - /> - } - label={label} - sx={{ - '& .MuiTypography-root': { - color: '#111111', - fontSize: '16px' - } - }} - /> - {description && ( - - - - - - )} - - ); -}; - -// Custom checkbox widget component -export const CustomCheckboxWidget: React.FC = ({ - value = [], - onChange, - options, - uiSchema -}) => { - const enumDescriptions = (uiSchema?.['ui:options']?.enumDescriptions || {}) as { - [key: string]: string; - }; - const formattedValue = typeof value === 'string' ? [value] : value; - - const handleChange = (item: string) => { - const newValue = formattedValue.includes(item) - ? formattedValue.filter((v: string) => v !== item) - : [...formattedValue, item]; - onChange(newValue); - }; - - return ( - - {options.enumOptions && - options.enumOptions.map((option, index) => ( - handleChange(option.value as string)} - description={enumDescriptions[option.value as string]} - /> - ))} - - ); -}; - -export default CheckboxWithInfoWidget; diff --git a/web-console-v2/src/components/EditDataset/EditDataset.tsx b/web-console-v2/src/components/EditDataset/EditDataset.tsx index 300d7833..1c05360b 100644 --- a/web-console-v2/src/components/EditDataset/EditDataset.tsx +++ b/web-console-v2/src/components/EditDataset/EditDataset.tsx @@ -2,7 +2,7 @@ import * as yup from 'yup'; import en from '../../utils/locales/en.json'; import * as _ from 'lodash'; import { hasSpacesInField, hasSpecialCharacters, invalidNewFieldRegex, validFieldName, nameRegex } from '../../services/utils'; -import { validFormatTypes } from 'pages/StepsPages/Ingestion/SchemaDetails/SchemaDetails'; +import { validFormatTypes } from 'pages/DatasetCreation/Ingestion/SchemaDetails/SchemaDetails'; export const filterForObjectArrivalFormat = (data: any[]) => { const result: any[] = []; @@ -64,12 +64,12 @@ export const inputFields = ( })); } - const defaultDatatypeOptions = validFormatTypes.map((item) => ({ + const defaultDatatypeOptions: any[] = validFormatTypes.map((item: any) => ({ label: item, value: item })); - const arrivalType: any[] = extractMainKeys(datamappings).map((item) => item); + const arrivalType: any[] = extractMainKeys(datamappings).map((item: any) => item); const dataTypeOptions: any[] = dataTypeStoreFormat.filter( (option: any) => option.arrivalType === arrivalFormat ); diff --git a/web-console-v2/src/components/EditDatasetTags/EditDatasetTags.tsx b/web-console-v2/src/components/EditDatasetTags/EditDatasetTags.tsx deleted file mode 100644 index da9bb5b8..00000000 --- a/web-console-v2/src/components/EditDatasetTags/EditDatasetTags.tsx +++ /dev/null @@ -1,163 +0,0 @@ -import React from 'react'; -import { useEffect, useRef, useState } from 'react'; -import * as _ from 'lodash'; -import { - Popover, - Card, - Box, - TextField, - Typography, - Button, - Chip, - Tooltip, - InputAdornment, -} from '@mui/material'; -import AddIcon from '@mui/icons-material/Add'; -import { Dataset } from '../../types/dataset'; -interface EditDatasetTagsProps { - open: boolean; - anchorEl: HTMLElement | null; - handleClose: () => void; - dataset: Dataset; - handleSave: (dataset: Dataset, tags: string[], initialTags: string[]) => void; -} - -const EditDatasetTags: React.FC = ({ - open, - anchorEl, - handleClose, - dataset, - handleSave, -}) => { - const textRef: any = useRef(); - const [disable, setDisable] = useState(true); - const [initialTags, setInitialTags] = useState([]); - - const [tagsData, setTagsData] = useState( - _.get(dataset, 'tags') || [], - ); - - const saveTags = () => { - handleSave(dataset, tagsData, initialTags); - handleClose(); - }; - - const addTag = (e: any) => { - let newTag: any = textRef.current.value.trim(); - - newTag = _.toLower(newTag); - - if (newTag && !tagsData.map((tag) => _.toLower(tag)).includes(newTag)) { - setTagsData([...tagsData, _.startCase(newTag)]); - } - textRef.current.value = ''; - setDisable(false); - }; - - const handleChange = () => { - return null; - }; - - const deleteTag = (tag: string) => { - setTagsData((prevState: string[]) => { - const data = _.filter(prevState, (tagd: string) => tagd !== tag); - return data; - }); - setDisable(false); - }; - - useEffect(() => { - setTagsData(_.get(dataset, 'tags') || []); - setInitialTags(_.get(dataset, 'tags') || []); - }, [dataset]); - - return ( - - - - ) => { - if (e.key === 'Enter') addTag(e); - }} - InputProps={{ - endAdornment: ( - - - - ), - }} - /> - - {tagsData && - tagsData.map((tag: string, index: number) => ( - - - {tag} - - } - onDelete={() => deleteTag(tag)} - /> - - ))} - {tagsData.length < 1 &&

No tags available

} -
-
- - - - -
-
- ); -}; - -export default EditDatasetTags; diff --git a/web-console-v2/src/components/Navbar/Navbar.tsx b/web-console-v2/src/components/Navbar/Navbar.tsx index 021732ee..fa8d9c79 100644 --- a/web-console-v2/src/components/Navbar/Navbar.tsx +++ b/web-console-v2/src/components/Navbar/Navbar.tsx @@ -10,7 +10,7 @@ import Notification from 'components/NotificationBar/AlertNotification'; import { useEffect, useState } from 'react'; import { fetchFiringAlerts } from 'services/alerts'; import logoIcon from 'assets/images/obsrv-logo.svg'; -import { getBaseURL, getConfigValueV1 } from 'services/configData'; +import { getBaseURL, getSystemSetting } from 'services/configData'; import { errorInterceptor, responseInterceptor } from 'services/http'; import { addHttpRequestsInterceptor } from 'services/http'; import { routeConfigurations } from 'router'; @@ -74,6 +74,7 @@ function BasicBreadcrumbs(): JSX.Element { // Recursive function to find a matching route, including support for nested routes and dynamic segments const findRoute = (routes: any, path: string) => { for (const route of routes) { + if (route.path === '*') return route; // Check for an exact match or a dynamic match const dynamicRegex = getDynamicRegex(route.path); if (dynamicRegex.test(path)) return { ...route, path: path }; @@ -147,10 +148,10 @@ function BasicBreadcrumbs(): JSX.Element {
{ navigate(getConfigValueV1("GRAFANA_URL")) }}> + onClick={() => { navigate(getSystemSetting("GRAFANA_URL")) }}>
-
{ navigate(getConfigValueV1("SUPERSET_URL")) }}> +
{ navigate(getSystemSetting("SUPERSET_URL")) }}>
diff --git a/web-console-v2/src/components/cardsV1/statistics/ReportCard.tsx b/web-console-v2/src/components/ReportCard.tsx similarity index 100% rename from web-console-v2/src/components/cardsV1/statistics/ReportCard.tsx rename to web-console-v2/src/components/ReportCard.tsx diff --git a/web-console-v2/src/components/Sidebar/Sidebar.tsx b/web-console-v2/src/components/Sidebar/Sidebar.tsx index 04edbe97..922dc149 100644 --- a/web-console-v2/src/components/Sidebar/Sidebar.tsx +++ b/web-console-v2/src/components/Sidebar/Sidebar.tsx @@ -12,7 +12,7 @@ import ListItemIcon from '@mui/material/ListItemIcon'; import { useTheme } from '@mui/material/styles'; import Tooltip from '@mui/material/Tooltip'; import { useAlert } from 'contexts/AlertContextProvider'; -import apiEndpoints from 'data/apiEndpoints'; +import apiEndpoints from 'constants/Endpoints'; import _ from 'lodash'; import React, { useEffect, useState } from 'react'; import { useLocation, useNavigate } from 'react-router-dom'; @@ -132,13 +132,12 @@ const Sidebar: React.FC = ({ onExpandToggle, expand }) => { }; const handleLogout = () => { - http.get(apiEndpoints.logout).then(() => { + try { localStorage.clear(); - //navigate(`/login`); - window.location.href = '/console/login' - }).catch(() => { + window.location.href = '/console/logout'; + } catch (err) { showAlert('Failed to logout', 'error'); - }) + } }; diff --git a/web-console-v2/src/components/cardsComponent/statistics/AnalyticsDataCard.tsx b/web-console-v2/src/components/cardsComponent/statistics/AnalyticsDataCard.tsx deleted file mode 100644 index a8eca10a..00000000 --- a/web-console-v2/src/components/cardsComponent/statistics/AnalyticsDataCard.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { Box, Stack, Typography, Paper, Tooltip, Grid } from '@mui/material'; -import MainCard from 'components/MainCard'; -import { ReloadOutlined } from '@ant-design/icons'; -import globalConfig from 'data/initialConfig'; -import React, { useState } from 'react'; -import _ from 'lodash'; - -const AnalyticsDataCard = (props: any) => { - const { uuid, title, tasks = [], children, description = '' } = props; - const [refresh, setRefresh] = useState(0); - - const renderTask = (task: any) => { - return - {React.cloneElement(task, { uuid, refresh })} - - } - - return - - - - - - - setRefresh(pre => pre + 1)} /> - - - - {title} - - - {_.map(tasks, renderTask)} - - {children} - - - - - -}; - -export default AnalyticsDataCard; diff --git a/web-console-v2/src/components/cardsComponent/statistics/AsyncLabel.tsx b/web-console-v2/src/components/cardsComponent/statistics/AsyncLabel.tsx deleted file mode 100644 index 3a1ade14..00000000 --- a/web-console-v2/src/components/cardsComponent/statistics/AsyncLabel.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import { Typography } from "@mui/material"; -import { useEffect, useState } from "react"; -import { fetchMultipleMetrics } from "services/clusterMetrics"; -import globalConfig from 'data/initialConfig'; -import Loader from "components/Loader"; - -const AsyncLabel = (props: any) => { - - const { uuid, refresh, query, transformer, suffix = '', prefix = '', ...rest } = props; - const [label, setLabel] = useState(''); - const [loading, setLoading] = useState(false); - - const fetchMetric = async (query: any) => { - setLoading(true) - try { - const response = await fetchMultipleMetrics(query, { uuid }); - const transformedLabel = (transformer && transformer(response)) || response; - setLabel(transformedLabel as any); - } catch (error) { } - finally { - setLoading(false) - } - } - - useEffect(() => { - if (refresh) { - fetchMetric(query); - } - }, [refresh]) - - const configureMetricFetcher = (query: any) => { - const frequency = globalConfig.clusterMenu.frequency; - fetchMetric(query); - return setInterval(() => fetchMetric(query), frequency * 1000) - } - - useEffect(() => { - const interval = configureMetricFetcher(query); - return () => interval && clearInterval(interval) - }, []); - - return <> - {loading && } - - {prefix} {label} {suffix} - - -}; - -export default AsyncLabel; diff --git a/web-console-v2/src/components/cardsComponent/statistics/BigNumber.tsx b/web-console-v2/src/components/cardsComponent/statistics/BigNumber.tsx deleted file mode 100644 index d196b300..00000000 --- a/web-console-v2/src/components/cardsComponent/statistics/BigNumber.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import { styled } from '@mui/material/styles'; -import { Card, CardContent, Grid, Typography } from '@mui/material'; - -import { GenericCardProps } from 'types/root'; - -const IconWrapper = styled('div')({ - position: 'absolute', - left: '-17px', - bottom: '-27px', - color: '#fff', - transform: 'rotate(25deg)', - '& svg': { - width: '100px', - height: '100px', - opacity: '0.35' - } -}); - -interface MetricsProps { - primary: string; - secondary: string; - iconPrimary: GenericCardProps['iconPrimary']; - color: string; - onClick: any -} - -const BigNumberCard = ({ primary, secondary, iconPrimary, color, onClick }: MetricsProps) => { - const IconPrimary = iconPrimary!; - const primaryIcon = iconPrimary ? : null; - - return ( - - - {primaryIcon} - - - - {secondary} - - - - - {primary} - - - - - - ); -}; - -export default BigNumberCard; diff --git a/web-console-v2/src/components/cardsComponent/statistics/ReportCard.tsx b/web-console-v2/src/components/cardsComponent/statistics/ReportCard.tsx deleted file mode 100644 index bcb6d65c..00000000 --- a/web-console-v2/src/components/cardsComponent/statistics/ReportCard.tsx +++ /dev/null @@ -1,104 +0,0 @@ -import { Grid, Stack, Tooltip, Typography, useTheme } from '@mui/material'; -import MainCard from 'components/MainCard'; -import { useEffect, useState } from 'react'; -import { fetchChartData } from 'services/clusterMetrics'; -import { GenericCardProps } from 'types/root'; -import globalConfig from 'data/initialConfig'; -import * as _ from 'lodash'; -import { Paper } from '@mui/material'; -import { ReloadOutlined } from '@ant-design/icons'; -import Loader from 'components/Loader'; - -type ReportCardProps = GenericCardProps - -const ReportCard = ({ uuid, primary, suffix, secondary, iconPrimary, color, query, description = '', }: ReportCardProps) => { - const theme = useTheme(); - const IconPrimary = iconPrimary!; - const primaryIcon = iconPrimary ? : null; - const [primaryLabel, setPrimaryLabel] = useState(primary); - const [colorType, setColorType] = useState("primary"); - const [fullValue, setFullValue] = useState(""); - const [loading, setLoading] = useState(false); - const fullHeightWidth = { width: '100%', 'height': '100%', 'background': 'white' }; - const contentSx = { height: '100%', width: '100%', px: 3, }; - - const fetchData = async () => { - const { type } = query; - if (type === 'api') { - setLoading(true) - try { - const seriesData = await fetchChartData(query, { uuid }); - if (Array.isArray(seriesData)) { - const [data, color] = seriesData; - setPrimaryLabel(data); - color && setColorType(color); - } else if(typeof seriesData === 'object') { - const value = _.get(seriesData, 'value') - const hoverValue = _.get(seriesData, 'hoverValue') - setPrimaryLabel(value) - setFullValue(hoverValue) - } else { - setPrimaryLabel(seriesData); - } - } catch (error) { } - finally { - setLoading(false) - } - } - } - - const configureMetricFetcher = () => { - const frequency = globalConfig.clusterMenu.frequency; - fetchData(); - return setInterval(() => { - fetchData(); - }, frequency * 1000) - } - - useEffect(() => { - const interval = query && configureMetricFetcher(); - return () => interval && clearInterval(interval); - }, []) - - return ( - <> - {loading && } - - - - - - - - fetchData()} /> - - - - - - - - {primaryLabel} {suffix} - - - - - {secondary} - - - - - - - {primaryIcon} - - - - - - - - ); -}; - -export default ReportCard; diff --git a/web-console-v2/src/components/cardsV1/statistics/AnalyticsDataCard.tsx b/web-console-v2/src/components/cardsV1/statistics/AnalyticsDataCard.tsx deleted file mode 100644 index a8eca10a..00000000 --- a/web-console-v2/src/components/cardsV1/statistics/AnalyticsDataCard.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { Box, Stack, Typography, Paper, Tooltip, Grid } from '@mui/material'; -import MainCard from 'components/MainCard'; -import { ReloadOutlined } from '@ant-design/icons'; -import globalConfig from 'data/initialConfig'; -import React, { useState } from 'react'; -import _ from 'lodash'; - -const AnalyticsDataCard = (props: any) => { - const { uuid, title, tasks = [], children, description = '' } = props; - const [refresh, setRefresh] = useState(0); - - const renderTask = (task: any) => { - return - {React.cloneElement(task, { uuid, refresh })} - - } - - return - - - - - - - setRefresh(pre => pre + 1)} /> - - - - {title} - - - {_.map(tasks, renderTask)} - - {children} - - - - - -}; - -export default AnalyticsDataCard; diff --git a/web-console-v2/src/components/cardsV1/statistics/AsyncLabel.tsx b/web-console-v2/src/components/cardsV1/statistics/AsyncLabel.tsx deleted file mode 100644 index f433182f..00000000 --- a/web-console-v2/src/components/cardsV1/statistics/AsyncLabel.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import { Typography } from "@mui/material"; -import { useEffect, useState } from "react"; -import { fetchMultipleMetrics } from "services/clusterMetrics"; -import globalConfig from 'data/initialConfig'; -import Loader from "components/Loader"; - -const AsyncLabel = (props: any) => { - - const { uuid, refresh, query, transformer, suffix = '', prefix = '', ...rest } = props; - const [label, setLabel] = useState(''); - const [loading, setLoading] = useState(false); - - const fetchMetric = async (query: any) => { - setLoading(true) - try { - const response = await fetchMultipleMetrics(query, { uuid }); - const transformedLabel = (transformer && transformer(response)) || response; - setLabel(transformedLabel as any); - } catch (error) { } - finally { - setLoading(false) - } - } - - useEffect(() => { - if (refresh) { - fetchMetric(query); - } - }, [refresh]) - - const configureMetricFetcher = (query: any) => { - const frequency = globalConfig.clusterMenu.frequency; - fetchMetric(query); - return setInterval(() => fetchMetric(query), frequency * 1000) - } - - useEffect(() => { - const interval = configureMetricFetcher(query); - return () => interval && clearInterval(interval) - }, []); - - return <> - {loading && } - {!loading && - {prefix} {label} {suffix} - } - -}; - -export default AsyncLabel; diff --git a/web-console-v2/src/components/cardsV1/statistics/BigNumber.tsx b/web-console-v2/src/components/cardsV1/statistics/BigNumber.tsx deleted file mode 100644 index cdcd13ed..00000000 --- a/web-console-v2/src/components/cardsV1/statistics/BigNumber.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import { styled } from '@mui/material/styles'; -import { Card, CardContent, Grid, Typography } from '@mui/material'; - -import { GenericCardProps } from 'types/rootV1'; - -const IconWrapper = styled('div')({ - position: 'absolute', - left: '-17px', - bottom: '-27px', - color: '#fff', - transform: 'rotate(25deg)', - '& svg': { - width: '100px', - height: '100px', - opacity: '0.35' - } -}); - -interface MetricsProps { - primary: string; - secondary: string; - iconPrimary: GenericCardProps['iconPrimary']; - color: string; - onClick: any -} - -const BigNumberCard = ({ primary, secondary, iconPrimary, color, onClick }: MetricsProps) => { - const IconPrimary = iconPrimary!; - const primaryIcon = iconPrimary ? : null; - - return ( - - - {primaryIcon} - - - - {secondary} - - - - - {primary} - - - - - - ); -}; - -export default BigNumberCard; diff --git a/web-console-v2/src/constants/Endpoints.ts b/web-console-v2/src/constants/Endpoints.ts new file mode 100644 index 00000000..07abaf8d --- /dev/null +++ b/web-console-v2/src/constants/Endpoints.ts @@ -0,0 +1,32 @@ +export default { + infrastructureMetricsURL: '/config/v2/data/metrics', + prometheusRead: '/prom/api/v1/query', + prometheusReadRange: '/prom/api/v1/query_range', + druidNativeQuery: '/config/v2/data/metrics', + getAllFields: "/api/web-console/generate-fields", + generateJsonSchema: "/config/v2/datasets/dataschema", + generateIngestionSpec: "/config/dataset/v1/ingestionspec", + saveDatset: "/config/v2/datasets/create", + updateDataset: "/config/v2/datasets/update", + updateLiveDataset: "/config/datasets/v1/update", + readDataset: "/config/v2/datasets/read", + statusTransition: "/config/v2/datasets/status-transition", + saveDatasource: "/config/datasources/v1/update", + deleteDraftDatasources: "/config/datasources/v1/delete", + listDatasources: "/config/datasources/v1/list", + listDatasets: "/config/v2/datasets/list", + sendEvents: "/config/v2/data/in", + detectPiiFields: "/system/data/v1/analyze/pii", + generateURL: "/config/v2/files/generate-url", + alerts: "/alertmanager/api/prometheus/grafana/api/v1/rules", + query_metrics_series: "/prom/api/v1/series", + logout: "/api/oauth/v1/logout", + sourceConfig: "/config/datasets/v1/source/config/list", + fetchConfigData: "/api/config/data", + testConnection: "/api/connector/test", + fetchDatasetState: "/api/dataset/state", + datasetExport: "/config/v2/datasets/export", + importDataset: "/config/v2/datasets/import", + datasetDiff: "/api/dataset/diff", + fetchObjectMetadata: "/config/connector/v1/metadata/read/:datasetId" +}; diff --git a/web-console-v2/src/constants/Enpoints.ts b/web-console-v2/src/constants/Enpoints.ts deleted file mode 100644 index 6646b0f2..00000000 --- a/web-console-v2/src/constants/Enpoints.ts +++ /dev/null @@ -1,6 +0,0 @@ -export default { - infrastructureMetricsURL: '/config/v2/data/metrics', - prometheusRead: '/prom/api/v1/query', - prometheusReadRange: '/prom/api/v1/query_range', - druidNativeQuery: '/config/v2/data/metrics', -}; diff --git a/web-console-v2/src/constants/endpoints.ts b/web-console-v2/src/constants/endpoints.ts deleted file mode 100644 index 64e35922..00000000 --- a/web-console-v2/src/constants/endpoints.ts +++ /dev/null @@ -1,10 +0,0 @@ -export const DATASETS_LIST_ENDPOINT = '/datasets/list'; -export const DATASET_READ_ENDPOINT = (datasetId: string) => - `/datasets/read/${datasetId}?fields=version_key&mode=edit`; -export const DATASET_HEALTH_ENDPOINT = '/datasets/health'; -export const DATASET_STATUS_TRANSITION_ENDPOINT = '/datasets/status-transition'; -export const DATASET_UPDATE_ENDPOINT = '/datasets/update'; -export const DATASET_EXPORT_ENDPOINT = (datasetId: string, status: string) => - `/datasets/export/${datasetId}?status=${status}`; -export const DATASET_COPY_ENDPOINT = '/datasets/copy'; -export const DATASET_READ = (datasetId: string, params: string) => `/datasets/read/${datasetId}?${params}`; \ No newline at end of file diff --git a/web-console-v2/src/data/Charts/header.ts b/web-console-v2/src/data/Charts/header.ts index b23ec9d3..616281fd 100644 --- a/web-console-v2/src/data/Charts/header.ts +++ b/web-console-v2/src/data/Charts/header.ts @@ -2,7 +2,7 @@ import defaultConf from './common'; import dayjs from 'dayjs'; import _ from 'lodash'; import promql from '../../constants/Queries'; -import endpoints from '../../constants/Enpoints'; +import endpoints from '../../constants/Endpoints'; export default { node_memory: { diff --git a/web-console-v2/src/data/Charts/infra.ts b/web-console-v2/src/data/Charts/infra.ts index 3c58bd51..8f4028cc 100644 --- a/web-console-v2/src/data/Charts/infra.ts +++ b/web-console-v2/src/data/Charts/infra.ts @@ -1,6 +1,6 @@ import promql from '../../constants/Queries'; import _ from 'lodash'; -import endpoints from '../../constants/Enpoints'; +import endpoints from '../../constants/Endpoints'; import prettyMilliseconds from 'pretty-ms'; import dayjs from 'dayjs'; diff --git a/web-console-v2/src/data/Charts/ingestion.ts b/web-console-v2/src/data/Charts/ingestion.ts index bb8c2d11..3b1d4405 100644 --- a/web-console-v2/src/data/Charts/ingestion.ts +++ b/web-console-v2/src/data/Charts/ingestion.ts @@ -1,4 +1,4 @@ -import endpoints from '../../constants/Enpoints'; +import endpoints from '../../constants/Endpoints'; import _ from 'lodash'; import dayjs from 'dayjs'; const dateFormat = 'YYYY-MM-DDT00:00:00+05:30'; diff --git a/web-console-v2/src/data/Charts/processing.ts b/web-console-v2/src/data/Charts/processing.ts index 8140241f..6c8b9092 100644 --- a/web-console-v2/src/data/Charts/processing.ts +++ b/web-console-v2/src/data/Charts/processing.ts @@ -1,7 +1,7 @@ import * as _ from 'lodash'; import dayjs from 'dayjs'; import prettyMilliseconds from 'pretty-ms'; -import endpoints from '../../constants/Enpoints'; +import endpoints from '../../constants/Endpoints'; const dateFormat = 'YYYY-MM-DDT00:00:00+05:30'; diff --git a/web-console-v2/src/data/Charts/storage.ts b/web-console-v2/src/data/Charts/storage.ts index 094c3883..595d1bf7 100644 --- a/web-console-v2/src/data/Charts/storage.ts +++ b/web-console-v2/src/data/Charts/storage.ts @@ -2,7 +2,7 @@ import * as _ from 'lodash'; import prettyBytes from 'pretty-bytes'; import dayjs from 'dayjs'; import promql from '../../constants/Queries'; -import endpoints from '../../constants/Enpoints'; +import endpoints from '../../constants/Endpoints'; import prettyMilliseconds from 'pretty-ms'; import relativeTime from 'dayjs/plugin/relativeTime'; dayjs.extend(relativeTime); diff --git a/web-console-v2/src/data/apiEndpoints.ts b/web-console-v2/src/data/apiEndpoints.ts deleted file mode 100644 index 18a97853..00000000 --- a/web-console-v2/src/data/apiEndpoints.ts +++ /dev/null @@ -1,31 +0,0 @@ -export default { - getAllFields:"/api/web-console/generate-fields", - generateJsonSchema: "/config/v2/datasets/dataschema", - generateIngestionSpec: "/config/dataset/v1/ingestionspec", - saveDatset: "/config/v2/datasets/create", - updateDataset: "/config/v2/datasets/update", - updateLiveDataset: "/config/datasets/v1/update", - readDataset: "/config/v2/datasets/read", - statusTransition: "/config/v2/datasets/status-transition", - saveDatasource: "/config/datasources/v1/update", - deleteDraftDatasources: "/config/datasources/v1/delete", - listDatasources: "/config/datasources/v1/list", - listDatasets: "/config/v2/datasets/list", - sendEvents: "/config/v2/data/in", - detectPiiFields: "/system/data/v1/analyze/pii", - druidNativeQuery: "/config/v2/data/metrics", - generateURL: "/config/v2/files/generate-url", - alerts: "/alertmanager/api/prometheus/grafana/api/v1/rules", - query_metrics_series: "/prom/api/v1/series", - prometheusRead: "/prom/api/v1/query", - prometheusReadRange: "/prom/api/v1/query_range", - logout: "/api/oauth/v1/logout", - sourceConfig: "/config/datasets/v1/source/config/list", - fetchConfigData: "/api/config/data", - testConnection: "/api/connector/test", - fetchDatasetState: "/api/dataset/state", - datasetExport: "/config/v2/datasets/export", - importDataset: "/config/v2/datasets/import", - datasetDiff: "/api/dataset/diff", - fetchObjectMetadata: "/config/connector/v1/metadata/read/:datasetId" -} \ No newline at end of file diff --git a/web-console-v2/src/data/chartsComponents/api.ts b/web-console-v2/src/data/chartsComponents/api.ts index 51fd1feb..3837a4f4 100644 --- a/web-console-v2/src/data/chartsComponents/api.ts +++ b/web-console-v2/src/data/chartsComponents/api.ts @@ -4,7 +4,7 @@ import prettyMilliseconds from 'pretty-ms'; import promql from 'data/promql'; import defaultConf from './common'; -import endpoints from 'data/apiEndpoints'; +import endpoints from 'constants/Endpoints'; const labelsMapping = { "alert-manager": "Alerts", diff --git a/web-console-v2/src/data/chartsComponents/druid.ts b/web-console-v2/src/data/chartsComponents/druid.ts index 0773ddb5..e82b82b5 100644 --- a/web-console-v2/src/data/chartsComponents/druid.ts +++ b/web-console-v2/src/data/chartsComponents/druid.ts @@ -3,7 +3,7 @@ import prettyMilliseconds from 'pretty-ms'; import dayjs from 'dayjs'; import promql from '../promql'; import defaultConf from './common'; -import endpoints from 'data/apiEndpoints'; +import endpoints from 'constants/Endpoints'; import relativeTime from 'dayjs/plugin/relativeTime'; dayjs.extend(relativeTime); diff --git a/web-console-v2/src/data/chartsComponents/infra.ts b/web-console-v2/src/data/chartsComponents/infra.ts index 134c7524..3ca6ca8f 100644 --- a/web-console-v2/src/data/chartsComponents/infra.ts +++ b/web-console-v2/src/data/chartsComponents/infra.ts @@ -2,7 +2,7 @@ import * as _ from 'lodash'; import dayjs from 'dayjs'; import promql from '../promql'; import defaultConf from './common' -import endpoints from 'data/apiEndpoints'; +import endpoints from 'constants/Endpoints'; import prettyBytes from 'pretty-bytes'; export default { diff --git a/web-console-v2/src/data/chartsComponents/ingestion.ts b/web-console-v2/src/data/chartsComponents/ingestion.ts index d7bb58f3..aa43d2c4 100644 --- a/web-console-v2/src/data/chartsComponents/ingestion.ts +++ b/web-console-v2/src/data/chartsComponents/ingestion.ts @@ -1,7 +1,7 @@ import * as _ from 'lodash'; import dayjs from 'dayjs'; import defaultConf from './common'; -import endpoints from 'data/apiEndpoints'; +import endpoints from 'constants/Endpoints'; const dateFormat = 'YYYY-MM-DDT00:00:00+05:30' diff --git a/web-console-v2/src/data/chartsComponents/jdbc.ts b/web-console-v2/src/data/chartsComponents/jdbc.ts index 28ae9606..224d9486 100644 --- a/web-console-v2/src/data/chartsComponents/jdbc.ts +++ b/web-console-v2/src/data/chartsComponents/jdbc.ts @@ -1,11 +1,10 @@ import promql from 'data/promql'; -import endpoints from 'data/apiEndpoints'; +import endpoints from 'constants/Endpoints'; import _ from 'lodash'; import defaultConf from './common'; import prettyMilliseconds from 'pretty-ms'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; -import apiEndpoints from 'data/apiEndpoints'; dayjs.extend(utc) @@ -14,7 +13,7 @@ export default { query: { id: 'jdbcStatus', type: 'api', - url: apiEndpoints.sourceConfig, + url: endpoints.sourceConfig, method: 'POST', headers: {}, body: { @@ -49,7 +48,7 @@ export default { query: { id: 'jdbcLastRunTime', type: 'api', - url: apiEndpoints.sourceConfig, + url: endpoints.sourceConfig, method: 'POST', headers: {}, body: { diff --git a/web-console-v2/src/data/chartsComponents/processing.ts b/web-console-v2/src/data/chartsComponents/processing.ts index 5cac1747..a3cafca4 100644 --- a/web-console-v2/src/data/chartsComponents/processing.ts +++ b/web-console-v2/src/data/chartsComponents/processing.ts @@ -2,7 +2,7 @@ import * as _ from 'lodash'; import dayjs from 'dayjs'; import defaultConf from './common'; import prettyMilliseconds from 'pretty-ms'; -import endpoints from 'data/apiEndpoints'; +import endpoints from 'constants/Endpoints'; const dateFormat = 'YYYY-MM-DDT00:00:00+05:30' diff --git a/web-console-v2/src/data/chartsComponents/storage.ts b/web-console-v2/src/data/chartsComponents/storage.ts index 95d2a791..714a3afc 100644 --- a/web-console-v2/src/data/chartsComponents/storage.ts +++ b/web-console-v2/src/data/chartsComponents/storage.ts @@ -3,7 +3,7 @@ import prettyBytes from 'pretty-bytes'; import dayjs from 'dayjs'; import defaultConf from './common'; import promql from 'data/promql'; -import endpoints from 'data/apiEndpoints'; +import endpoints from 'constants/Endpoints'; import prettyMilliseconds from 'pretty-ms'; import relativeTime from 'dayjs/plugin/relativeTime'; dayjs.extend(relativeTime); diff --git a/web-console-v2/src/data/chartsV1/api.ts b/web-console-v2/src/data/chartsV1/api.ts index abece790..74ba30d1 100644 --- a/web-console-v2/src/data/chartsV1/api.ts +++ b/web-console-v2/src/data/chartsV1/api.ts @@ -4,7 +4,7 @@ import prettyMilliseconds from 'pretty-ms'; import promql from 'data/promql'; import defaultConf from './common'; -import endpoints from 'data/apiEndpoints'; +import endpoints from 'constants/Endpoints'; const labelsMapping = { "alert-manager": "Alerts", diff --git a/web-console-v2/src/data/chartsV1/druid.ts b/web-console-v2/src/data/chartsV1/druid.ts index 1373727d..31a42cff 100644 --- a/web-console-v2/src/data/chartsV1/druid.ts +++ b/web-console-v2/src/data/chartsV1/druid.ts @@ -3,7 +3,7 @@ import prettyMilliseconds from 'pretty-ms'; import dayjs from 'dayjs'; import promql from '../promql'; import defaultConf from './common'; -import endpoints from 'data/apiEndpoints'; +import endpoints from 'constants/Endpoints'; import relativeTime from 'dayjs/plugin/relativeTime'; dayjs.extend(relativeTime); diff --git a/web-console-v2/src/data/chartsV1/infra.ts b/web-console-v2/src/data/chartsV1/infra.ts index 53ca2f22..3c03b8ab 100644 --- a/web-console-v2/src/data/chartsV1/infra.ts +++ b/web-console-v2/src/data/chartsV1/infra.ts @@ -2,7 +2,7 @@ import * as _ from 'lodash'; import dayjs from 'dayjs'; import promql from '../promql'; import defaultConf from './common' -import endpoints from 'data/apiEndpoints'; +import endpoints from 'constants/Endpoints'; import prettyBytes from 'pretty-bytes'; export default { diff --git a/web-console-v2/src/data/chartsV1/ingestion.ts b/web-console-v2/src/data/chartsV1/ingestion.ts index d7bb58f3..aa43d2c4 100644 --- a/web-console-v2/src/data/chartsV1/ingestion.ts +++ b/web-console-v2/src/data/chartsV1/ingestion.ts @@ -1,7 +1,7 @@ import * as _ from 'lodash'; import dayjs from 'dayjs'; import defaultConf from './common'; -import endpoints from 'data/apiEndpoints'; +import endpoints from 'constants/Endpoints'; const dateFormat = 'YYYY-MM-DDT00:00:00+05:30' diff --git a/web-console-v2/src/data/chartsV1/jdbc.ts b/web-console-v2/src/data/chartsV1/jdbc.ts index c0018b7b..f870aa76 100644 --- a/web-console-v2/src/data/chartsV1/jdbc.ts +++ b/web-console-v2/src/data/chartsV1/jdbc.ts @@ -1,11 +1,11 @@ import promql from 'data/promql'; -import endpoints from 'data/apiEndpoints'; import _ from 'lodash'; import defaultConf from './common'; import prettyMilliseconds from 'pretty-ms'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; -import apiEndpoints from 'data/apiEndpoints'; +import apiEndpoints from 'constants/Endpoints'; +import api from 'data/chartsComponents/api'; dayjs.extend(utc) @@ -75,7 +75,7 @@ export default { query: { id: 'jdbcNumberOfEventsProcessed', type: 'api', - url: endpoints.prometheusRead, + url: apiEndpoints.prometheusRead, method: 'GET', headers: {}, body: {}, @@ -100,7 +100,7 @@ export default { query: { id: 'jdbcNumberOfFailedEvents', type: 'api', - url: endpoints.prometheusRead, + url: apiEndpoints.prometheusRead, method: 'GET', headers: {}, body: {}, @@ -124,7 +124,7 @@ export default { query: { id: 'jdbcAvgProcessingTime', type: 'api', - url: endpoints.prometheusRead, + url: apiEndpoints.prometheusRead, method: 'GET', headers: {}, body: {}, @@ -214,7 +214,7 @@ export default { query: { id: 'jdbcNumberOfEventsProcessed', type: 'api', - url: endpoints.prometheusReadRange, + url: apiEndpoints.prometheusReadRange, method: 'GET', headers: {}, body: {}, @@ -305,7 +305,7 @@ export default { query: { id: 'jdbcNumberOfFailedEvents', type: 'api', - url: endpoints.prometheusReadRange, + url: apiEndpoints.prometheusReadRange, method: 'GET', headers: {}, body: {}, diff --git a/web-console-v2/src/data/chartsV1/object.ts b/web-console-v2/src/data/chartsV1/object.ts index 21ee8af2..bf709ae9 100644 --- a/web-console-v2/src/data/chartsV1/object.ts +++ b/web-console-v2/src/data/chartsV1/object.ts @@ -1,11 +1,11 @@ import promql from 'data/promql'; -import endpoints from 'data/apiEndpoints'; +import endpoints from 'constants/Endpoints'; import _ from 'lodash'; import defaultConf from './common'; import prettyMilliseconds from 'pretty-ms'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc' -import apiEndpoints from 'data/apiEndpoints'; +import apiEndpoints from 'constants/Endpoints'; import chartMeta from 'data/chartsV1'; import { fetchChartData } from 'services/clusterMetrics'; import { IChartFetchRequest } from 'types/metadata'; diff --git a/web-console-v2/src/data/chartsV1/processing.ts b/web-console-v2/src/data/chartsV1/processing.ts index 5cac1747..a3cafca4 100644 --- a/web-console-v2/src/data/chartsV1/processing.ts +++ b/web-console-v2/src/data/chartsV1/processing.ts @@ -2,7 +2,7 @@ import * as _ from 'lodash'; import dayjs from 'dayjs'; import defaultConf from './common'; import prettyMilliseconds from 'pretty-ms'; -import endpoints from 'data/apiEndpoints'; +import endpoints from 'constants/Endpoints'; const dateFormat = 'YYYY-MM-DDT00:00:00+05:30' diff --git a/web-console-v2/src/data/chartsV1/storage.ts b/web-console-v2/src/data/chartsV1/storage.ts index d363fd79..060d2f9f 100644 --- a/web-console-v2/src/data/chartsV1/storage.ts +++ b/web-console-v2/src/data/chartsV1/storage.ts @@ -3,7 +3,7 @@ import prettyBytes from 'pretty-bytes'; import dayjs from 'dayjs'; import defaultConf from './common'; import promql from 'data/promql'; -import endpoints from 'data/apiEndpoints'; +import endpoints from 'constants/Endpoints'; import prettyMilliseconds from 'pretty-ms'; import relativeTime from 'dayjs/plugin/relativeTime'; dayjs.extend(relativeTime); diff --git a/web-console-v2/src/pages/Dashboard/IndividualDashboardPage/IndividualDashboardPage.tsx b/web-console-v2/src/pages/Dashboard/IndividualDashboardPage/IndividualDashboardPage.tsx index 6eda5741..08249399 100644 --- a/web-console-v2/src/pages/Dashboard/IndividualDashboardPage/IndividualDashboardPage.tsx +++ b/web-console-v2/src/pages/Dashboard/IndividualDashboardPage/IndividualDashboardPage.tsx @@ -5,13 +5,12 @@ import React, { useEffect, useState } from 'react'; import MainCard from 'components/MainCard'; import { useNavigate, useParams } from 'react-router-dom'; import { InfoCircleOutlined } from '@ant-design/icons'; -import { navigateToGrafana } from 'services/grafana'; import Grafana from 'assets/icons/Grafana'; import intereactIds from 'data/telemetry/interact.json' import { v4 } from 'uuid'; import Health from '../health'; import { metricsMetadata } from '../metrics'; -import { getConfigValueV1 } from 'services/configData'; +import { getSystemSetting } from 'services/configData'; import KeyboardBackspaceIcon from '@mui/icons-material/KeyboardBackspace'; const IndividualMetricDashboards = (props: any) => { @@ -86,7 +85,7 @@ const IndividualMetricDashboards = (props: any) => { const link = _.get(metadata, 'links.grafana.link') if (!link) return null; return ( - { navigateToGrafana(getConfigValueV1("GRAFANA_URL")) }}> + { navigateToGrafana(getSystemSetting("GRAFANA_URL")) }}> diff --git a/web-console-v2/src/pages/Dashboard/Processing/Processing.tsx b/web-console-v2/src/pages/Dashboard/Processing/Processing.tsx deleted file mode 100644 index b29999d4..00000000 --- a/web-console-v2/src/pages/Dashboard/Processing/Processing.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import React from 'react'; - -const Processing = () => { - return
Processing
; -}; - -export default Processing; diff --git a/web-console-v2/src/sections/dashboard/analytics/ChartFilters.tsx b/web-console-v2/src/pages/Dashboard/analytics/ChartFilters.tsx similarity index 100% rename from web-console-v2/src/sections/dashboard/analytics/ChartFilters.tsx rename to web-console-v2/src/pages/Dashboard/analytics/ChartFilters.tsx diff --git a/web-console-v2/src/sections/dashboard/analytics/GrafanaEmbedded.tsx b/web-console-v2/src/pages/Dashboard/analytics/GrafanaEmbedded.tsx similarity index 81% rename from web-console-v2/src/sections/dashboard/analytics/GrafanaEmbedded.tsx rename to web-console-v2/src/pages/Dashboard/analytics/GrafanaEmbedded.tsx index d412fb7e..2f071613 100644 --- a/web-console-v2/src/sections/dashboard/analytics/GrafanaEmbedded.tsx +++ b/web-console-v2/src/pages/Dashboard/analytics/GrafanaEmbedded.tsx @@ -1,11 +1,11 @@ import { Paper } from "@mui/material" import MainCard from "components/MainCard" import globalConfig from 'data/initialConfig'; -import { getConfigValueV1 } from "services/configData"; +import { getSystemSetting } from "services/configData"; const GrafanaChart = (props: any) => { const { url, width, height } = props; - const graphanaUrl = getConfigValueV1("GRAFANA_URL"); + const graphanaUrl = getSystemSetting("GRAFANA_URL"); return <> diff --git a/web-console-v2/src/sections/dashboard/analytics/IngestionCharts.tsx b/web-console-v2/src/pages/Dashboard/analytics/IngestionCharts.tsx similarity index 100% rename from web-console-v2/src/sections/dashboard/analytics/IngestionCharts.tsx rename to web-console-v2/src/pages/Dashboard/analytics/IngestionCharts.tsx diff --git a/web-console-v2/src/sections/dashboard/analytics/apex.tsx b/web-console-v2/src/pages/Dashboard/analytics/apex.tsx similarity index 100% rename from web-console-v2/src/sections/dashboard/analytics/apex.tsx rename to web-console-v2/src/pages/Dashboard/analytics/apex.tsx diff --git a/web-console-v2/src/sections/dashboard/analytics/guageChart.tsx b/web-console-v2/src/pages/Dashboard/analytics/guageChart.tsx similarity index 100% rename from web-console-v2/src/sections/dashboard/analytics/guageChart.tsx rename to web-console-v2/src/pages/Dashboard/analytics/guageChart.tsx diff --git a/web-console-v2/src/sections/dashboard/analytics/objectProcessedStatus.tsx b/web-console-v2/src/pages/Dashboard/analytics/objectProcessedStatus.tsx similarity index 100% rename from web-console-v2/src/sections/dashboard/analytics/objectProcessedStatus.tsx rename to web-console-v2/src/pages/Dashboard/analytics/objectProcessedStatus.tsx diff --git a/web-console-v2/src/pages/Dashboard/metrics.tsx b/web-console-v2/src/pages/Dashboard/metrics.tsx index 55e10ddf..3ca60ace 100644 --- a/web-console-v2/src/pages/Dashboard/metrics.tsx +++ b/web-console-v2/src/pages/Dashboard/metrics.tsx @@ -1,18 +1,16 @@ /* eslint-disable */ import { CloudServerOutlined, BarChartOutlined, DotChartOutlined, ApiOutlined, DatabaseOutlined, SettingOutlined, PartitionOutlined } from "@ant-design/icons"; import * as _ from 'lodash'; -import ApexChart from "sections/dashboard/analytics/apex"; +import ApexChart from "pages/Dashboard/analytics/apex"; import chartMeta from 'data/chartsComponents'; -// import AlertsMessages from "components/cardsComponent/statistics/Alerts"; -import ApexWithFilters from "sections/dashboard/analytics/ChartFilters"; +import ApexWithFilters from "pages/Dashboard/analytics/ChartFilters"; import filters from 'data/chartFilters'; import { totalVsRunningNodes, percentageUsage, cpuPercentageUsage, alertsFilterByLabels, pvUsage, checkHealthStatus, toPercentage } from 'services/transformers'; import BasicCard2 from "components/Cards/BasicCard2/BasicCard2"; import GaugeChart from "components/Charts/GaugeChart"; import AsyncLabel from "components/AsyncLabel"; import MetricsCard from "components/Cards/MetricsCard/MetricsCard"; -import IngestionCharts from "sections/dashboard/analytics/IngestionCharts"; -import HoursSinceLastBackup from "sections/widgets/HoursSinceLastBackup"; +import IngestionCharts from "pages/Dashboard/analytics/IngestionCharts"; import StorageMetricsCard from "components/Cards/StorageMetricCard"; import DatasetMetricsCard from "components/Cards/DatasetMetricsCard/DatasetMetricsCard"; diff --git a/web-console-v2/src/sections/widgets/Cluster.tsx b/web-console-v2/src/pages/Dashboard/widgets/Cluster.tsx similarity index 93% rename from web-console-v2/src/sections/widgets/Cluster.tsx rename to web-console-v2/src/pages/Dashboard/widgets/Cluster.tsx index a3d9f81d..3a843d36 100644 --- a/web-console-v2/src/sections/widgets/Cluster.tsx +++ b/web-console-v2/src/pages/Dashboard/widgets/Cluster.tsx @@ -1,6 +1,6 @@ import { Card, Stack, Typography, Breadcrumbs, } from '@mui/material'; -import chartMeta from '../../data/chartsComponents' -import ApexChart from 'sections/dashboard/analytics/apex'; +import chartMeta from '../../../data/chartsComponents' +import ApexChart from 'pages/Dashboard/analytics/apex'; import ClusterMetrics from './ClusterMetrics'; import globalConfig from 'data/initialConfig' import ClusterNodes from './ClusterNodes'; diff --git a/web-console-v2/src/sections/widgets/ClusterMetrics.tsx b/web-console-v2/src/pages/Dashboard/widgets/ClusterMetrics.tsx similarity index 100% rename from web-console-v2/src/sections/widgets/ClusterMetrics.tsx rename to web-console-v2/src/pages/Dashboard/widgets/ClusterMetrics.tsx diff --git a/web-console-v2/src/sections/widgets/ClusterNodes.tsx b/web-console-v2/src/pages/Dashboard/widgets/ClusterNodes.tsx similarity index 94% rename from web-console-v2/src/sections/widgets/ClusterNodes.tsx rename to web-console-v2/src/pages/Dashboard/widgets/ClusterNodes.tsx index 1ae366fb..63fe02fd 100644 --- a/web-console-v2/src/sections/widgets/ClusterNodes.tsx +++ b/web-console-v2/src/pages/Dashboard/widgets/ClusterNodes.tsx @@ -1,9 +1,9 @@ import { useEffect, useMemo, useState } from "react"; import * as _ from 'lodash'; -import chartMeta from '../../data/chartsComponents' +import chartMeta from '../../../data/chartsComponents' import { fetchChartData } from "services/clusterMetrics"; import globalConfig from 'data/initialConfig'; -import GaugeChart from "sections/dashboard/analytics/guageChart"; +import GaugeChart from "pages/Dashboard/analytics/guageChart"; import { Stack } from "@mui/material"; import AsyncLabel from "components/AsyncLabel"; diff --git a/web-console-v2/src/sections/widgets/HoursSinceLastBackup.tsx b/web-console-v2/src/pages/Dashboard/widgets/HoursSinceLastBackup.tsx similarity index 100% rename from web-console-v2/src/sections/widgets/HoursSinceLastBackup.tsx rename to web-console-v2/src/pages/Dashboard/widgets/HoursSinceLastBackup.tsx diff --git a/web-console-v2/src/pages/ConnectorConfiguration/ConnectorConfiguration.module.css b/web-console-v2/src/pages/DatasetCreation/ConnectorConfiguration/ConnectorConfiguration.module.css similarity index 100% rename from web-console-v2/src/pages/ConnectorConfiguration/ConnectorConfiguration.module.css rename to web-console-v2/src/pages/DatasetCreation/ConnectorConfiguration/ConnectorConfiguration.module.css diff --git a/web-console-v2/src/pages/ConnectorConfiguration/ConnectorConfiguration.tsx b/web-console-v2/src/pages/DatasetCreation/ConnectorConfiguration/ConnectorConfiguration.tsx similarity index 100% rename from web-console-v2/src/pages/ConnectorConfiguration/ConnectorConfiguration.tsx rename to web-console-v2/src/pages/DatasetCreation/ConnectorConfiguration/ConnectorConfiguration.tsx diff --git a/web-console-v2/src/pages/StepsPages/Ingestion/Constant.ts b/web-console-v2/src/pages/DatasetCreation/Ingestion/Constant.ts similarity index 100% rename from web-console-v2/src/pages/StepsPages/Ingestion/Constant.ts rename to web-console-v2/src/pages/DatasetCreation/Ingestion/Constant.ts diff --git a/web-console-v2/src/pages/StepsPages/Ingestion/Ingestion.module.css b/web-console-v2/src/pages/DatasetCreation/Ingestion/Ingestion.module.css similarity index 100% rename from web-console-v2/src/pages/StepsPages/Ingestion/Ingestion.module.css rename to web-console-v2/src/pages/DatasetCreation/Ingestion/Ingestion.module.css diff --git a/web-console-v2/src/pages/StepsPages/Ingestion/Ingestion.tsx b/web-console-v2/src/pages/DatasetCreation/Ingestion/Ingestion.tsx similarity index 99% rename from web-console-v2/src/pages/StepsPages/Ingestion/Ingestion.tsx rename to web-console-v2/src/pages/DatasetCreation/Ingestion/Ingestion.tsx index d814a056..3c2d15a1 100644 --- a/web-console-v2/src/pages/StepsPages/Ingestion/Ingestion.tsx +++ b/web-console-v2/src/pages/DatasetCreation/Ingestion/Ingestion.tsx @@ -12,8 +12,8 @@ import Retry from 'components/Retry/Retry'; import { useAlert } from 'contexts/AlertContextProvider'; import { useFormik } from 'formik'; import _, { isEmpty } from 'lodash'; -import styles from 'pages/ConnectorConfiguration/ConnectorConfiguration.module.css'; -import UploadFiles from 'pages/Dataset/wizard/UploadFiles'; +import styles from 'pages/DatasetCreation/ConnectorConfiguration/ConnectorConfiguration.module.css'; +import UploadFiles from 'pages/DatasetCreation/UploadFiles'; import React, { useEffect, useMemo, useRef, useState } from 'react'; import { useLocation, useNavigate, useParams } from 'react-router-dom'; import { diff --git a/web-console-v2/src/pages/StepsPages/Ingestion/Schema.ts b/web-console-v2/src/pages/DatasetCreation/Ingestion/Schema.ts similarity index 100% rename from web-console-v2/src/pages/StepsPages/Ingestion/Schema.ts rename to web-console-v2/src/pages/DatasetCreation/Ingestion/Schema.ts diff --git a/web-console-v2/src/pages/StepsPages/Ingestion/SchemaDetails/EditLiveDataset.tsx b/web-console-v2/src/pages/DatasetCreation/Ingestion/SchemaDetails/EditLiveDataset.tsx similarity index 99% rename from web-console-v2/src/pages/StepsPages/Ingestion/SchemaDetails/EditLiveDataset.tsx rename to web-console-v2/src/pages/DatasetCreation/Ingestion/SchemaDetails/EditLiveDataset.tsx index cc3d98f3..a376764e 100644 --- a/web-console-v2/src/pages/StepsPages/Ingestion/SchemaDetails/EditLiveDataset.tsx +++ b/web-console-v2/src/pages/DatasetCreation/Ingestion/SchemaDetails/EditLiveDataset.tsx @@ -11,7 +11,7 @@ import { inputFields } from '../../../../components/EditDataset/EditDataset'; import { renderFieldsOnConditionForEditDataset, validateFormValues -} from '../../../../services/connector-utils'; +} from '../../../../services/connectorUtils'; import { useAlert } from '../../../../contexts/AlertContextProvider'; export interface RowType { diff --git a/web-console-v2/src/pages/StepsPages/Ingestion/SchemaDetails/SchemaDetails.module.css b/web-console-v2/src/pages/DatasetCreation/Ingestion/SchemaDetails/SchemaDetails.module.css similarity index 100% rename from web-console-v2/src/pages/StepsPages/Ingestion/SchemaDetails/SchemaDetails.module.css rename to web-console-v2/src/pages/DatasetCreation/Ingestion/SchemaDetails/SchemaDetails.module.css diff --git a/web-console-v2/src/pages/StepsPages/Ingestion/SchemaDetails/SchemaDetails.tsx b/web-console-v2/src/pages/DatasetCreation/Ingestion/SchemaDetails/SchemaDetails.tsx similarity index 99% rename from web-console-v2/src/pages/StepsPages/Ingestion/SchemaDetails/SchemaDetails.tsx rename to web-console-v2/src/pages/DatasetCreation/Ingestion/SchemaDetails/SchemaDetails.tsx index d9161589..d74d8591 100644 --- a/web-console-v2/src/pages/StepsPages/Ingestion/SchemaDetails/SchemaDetails.tsx +++ b/web-console-v2/src/pages/DatasetCreation/Ingestion/SchemaDetails/SchemaDetails.tsx @@ -25,7 +25,7 @@ import Loader from 'components/Loader'; import Retry from 'components/Retry/Retry'; import IconButtonWithTips from 'components/ToolTip/IconButtonWithTips'; import { useAlert } from 'contexts/AlertContextProvider'; -import ReUploadFiles from 'pages/Dataset/wizard/ReUploadFiles'; +import ReUploadFiles from 'pages/DatasetCreation/ReUploadFiles'; import { useNavigate, useParams } from 'react-router-dom'; import { useFetchDatasetsById, useUpdateDataset } from 'services/dataset'; import { dataMappings } from 'utils/dataMappings'; @@ -106,7 +106,6 @@ function SuggestionsIcon(props: SvgIconProps) { ); } -const configDetailKey = 'configDetails'; const SchemaDetails = (props: { showTableOnly?: boolean }) => { const { showTableOnly } = props; diff --git a/web-console-v2/src/pages/NewDataset/NewDataset.module.css b/web-console-v2/src/pages/DatasetCreation/NewDataset/NewDataset.module.css similarity index 100% rename from web-console-v2/src/pages/NewDataset/NewDataset.module.css rename to web-console-v2/src/pages/DatasetCreation/NewDataset/NewDataset.module.css diff --git a/web-console-v2/src/pages/NewDataset/NewDataset.test.tsx b/web-console-v2/src/pages/DatasetCreation/NewDataset/NewDataset.test.tsx similarity index 100% rename from web-console-v2/src/pages/NewDataset/NewDataset.test.tsx rename to web-console-v2/src/pages/DatasetCreation/NewDataset/NewDataset.test.tsx diff --git a/web-console-v2/src/pages/NewDataset/NewDataset.tsx b/web-console-v2/src/pages/DatasetCreation/NewDataset/NewDataset.tsx similarity index 94% rename from web-console-v2/src/pages/NewDataset/NewDataset.tsx rename to web-console-v2/src/pages/DatasetCreation/NewDataset/NewDataset.tsx index b533e89a..6938ce37 100644 --- a/web-console-v2/src/pages/NewDataset/NewDataset.tsx +++ b/web-console-v2/src/pages/DatasetCreation/NewDataset/NewDataset.tsx @@ -8,9 +8,6 @@ import datasetImg from 'assets/images/DatasetLaunch.svg'; const NewDataset: React.FC = () => { const navigate = useNavigate(); const handleClick = () => { - sessionStorage.removeItem('configDetails'); - sessionStorage.removeItem('connectorConfigDetails'); - navigate('/dataset/edit/connector/list/'); }; return ( diff --git a/web-console-v2/src/pages/StepsPages/Preview.tsx b/web-console-v2/src/pages/DatasetCreation/Preview.tsx similarity index 100% rename from web-console-v2/src/pages/StepsPages/Preview.tsx rename to web-console-v2/src/pages/DatasetCreation/Preview.tsx diff --git a/web-console-v2/src/pages/StepsPages/PreviewAndSave/AdditionSummary.tsx b/web-console-v2/src/pages/DatasetCreation/PreviewAndSave/AdditionSummary.tsx similarity index 100% rename from web-console-v2/src/pages/StepsPages/PreviewAndSave/AdditionSummary.tsx rename to web-console-v2/src/pages/DatasetCreation/PreviewAndSave/AdditionSummary.tsx diff --git a/web-console-v2/src/pages/StepsPages/PreviewAndSave/AllConfigurations.tsx b/web-console-v2/src/pages/DatasetCreation/PreviewAndSave/AllConfigurations.tsx similarity index 100% rename from web-console-v2/src/pages/StepsPages/PreviewAndSave/AllConfigurations.tsx rename to web-console-v2/src/pages/DatasetCreation/PreviewAndSave/AllConfigurations.tsx diff --git a/web-console-v2/src/pages/StepsPages/PreviewAndSave/DeletionSummary.tsx b/web-console-v2/src/pages/DatasetCreation/PreviewAndSave/DeletionSummary.tsx similarity index 100% rename from web-console-v2/src/pages/StepsPages/PreviewAndSave/DeletionSummary.tsx rename to web-console-v2/src/pages/DatasetCreation/PreviewAndSave/DeletionSummary.tsx diff --git a/web-console-v2/src/pages/StepsPages/PreviewAndSave/Preview.module.css b/web-console-v2/src/pages/DatasetCreation/PreviewAndSave/Preview.module.css similarity index 100% rename from web-console-v2/src/pages/StepsPages/PreviewAndSave/Preview.module.css rename to web-console-v2/src/pages/DatasetCreation/PreviewAndSave/Preview.module.css diff --git a/web-console-v2/src/pages/StepsPages/PreviewAndSave/Preview.tsx b/web-console-v2/src/pages/DatasetCreation/PreviewAndSave/Preview.tsx similarity index 97% rename from web-console-v2/src/pages/StepsPages/PreviewAndSave/Preview.tsx rename to web-console-v2/src/pages/DatasetCreation/PreviewAndSave/Preview.tsx index a1db66a9..177105eb 100644 --- a/web-console-v2/src/pages/StepsPages/PreviewAndSave/Preview.tsx +++ b/web-console-v2/src/pages/DatasetCreation/PreviewAndSave/Preview.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { useLocation, useNavigate } from 'react-router-dom'; +import { useLocation, useNavigate, useParams } from 'react-router-dom'; import { FC, ReactElement, useState, useEffect } from 'react'; import { Box, Button, Stack, Tab, Tabs } from '@mui/material'; import AllConfigurations from './AllConfigurations'; @@ -9,7 +9,6 @@ import KeyboardBackspaceIcon from '@mui/icons-material/KeyboardBackspace'; import styles from './Preview.module.css'; import Actions from 'components/ActionButtons/Actions'; import { useFetchDatasetsById, usePublishDataset } from 'services/dataset'; -import { fetchSessionStorageValue } from 'utils/sessionStorage'; import AlertDialog from 'components/AlertDialog/AlertDialog'; import en from 'utils/locales/en.json'; import Loader from 'components/Loader'; @@ -30,7 +29,7 @@ const renderContent = (selectedTab: number) => { const Preview: FC = (): ReactElement => { const navigate = useNavigate(); - const datasetId = fetchSessionStorageValue('configDetails', 'dataset_id') || ''; + const { datasetId }: any = useParams(); const { search, state } = useLocation(); const [selectedTab, setSelectedTab] = useState(0); diff --git a/web-console-v2/src/pages/StepsPages/PreviewAndSave/PreviewSummary.tsx b/web-console-v2/src/pages/DatasetCreation/PreviewAndSave/PreviewSummary.tsx similarity index 100% rename from web-console-v2/src/pages/StepsPages/PreviewAndSave/PreviewSummary.tsx rename to web-console-v2/src/pages/DatasetCreation/PreviewAndSave/PreviewSummary.tsx diff --git a/web-console-v2/src/pages/StepsPages/PreviewAndSave/UpdateSummary.tsx b/web-console-v2/src/pages/DatasetCreation/PreviewAndSave/UpdateSummary.tsx similarity index 100% rename from web-console-v2/src/pages/StepsPages/PreviewAndSave/UpdateSummary.tsx rename to web-console-v2/src/pages/DatasetCreation/PreviewAndSave/UpdateSummary.tsx diff --git a/web-console-v2/src/pages/StepsPages/PreviewAndSave/response.ts b/web-console-v2/src/pages/DatasetCreation/PreviewAndSave/response.ts similarity index 100% rename from web-console-v2/src/pages/StepsPages/PreviewAndSave/response.ts rename to web-console-v2/src/pages/DatasetCreation/PreviewAndSave/response.ts diff --git a/web-console-v2/src/pages/StepsPages/Processing/Constant.ts b/web-console-v2/src/pages/DatasetCreation/Processing/Constant.ts similarity index 100% rename from web-console-v2/src/pages/StepsPages/Processing/Constant.ts rename to web-console-v2/src/pages/DatasetCreation/Processing/Constant.ts diff --git a/web-console-v2/src/pages/StepsPages/Processing/Processing.module.css b/web-console-v2/src/pages/DatasetCreation/Processing/Processing.module.css similarity index 100% rename from web-console-v2/src/pages/StepsPages/Processing/Processing.module.css rename to web-console-v2/src/pages/DatasetCreation/Processing/Processing.module.css diff --git a/web-console-v2/src/pages/StepsPages/Processing/Processing.tsx b/web-console-v2/src/pages/DatasetCreation/Processing/Processing.tsx similarity index 98% rename from web-console-v2/src/pages/StepsPages/Processing/Processing.tsx rename to web-console-v2/src/pages/DatasetCreation/Processing/Processing.tsx index bf819841..6e7c1a54 100644 --- a/web-console-v2/src/pages/StepsPages/Processing/Processing.tsx +++ b/web-console-v2/src/pages/DatasetCreation/Processing/Processing.tsx @@ -1,11 +1,11 @@ -import React, { useEffect, useState } from 'react'; +import React, { useCallback, useEffect, useState } from 'react'; import Action from 'components/ActionButtons/Actions'; import { Box, Button } from '@mui/material'; import KeyboardBackspaceIcon from '@mui/icons-material/KeyboardBackspace'; import HelpSection from 'components/HelpSection/HelpSection'; -import styles from 'pages/ConnectorConfiguration/ConnectorConfiguration.module.css'; +import styles from 'pages/DatasetCreation/ConnectorConfiguration/ConnectorConfiguration.module.css'; import processingStyle from './Processing.module.css'; -import _ from 'lodash'; +import _, { mapKeys } from 'lodash'; import AccordionSection from 'components/Accordian/AccordionSection'; import { theme } from 'theme'; import ProcessingSection from './ProcessingSection/ProcessingSection'; @@ -20,7 +20,6 @@ import { TransformationMode } from 'types/datasets'; import { useNavigate, useParams } from 'react-router-dom'; import Loader from 'components/Loader'; import { useDetectPiiFields } from 'services/system'; -import { fetchSessionStorageValue } from 'utils/sessionStorage'; import { flattenObject, setAdditionalProperties } from 'services/json-schema'; import ProcessingHelpText from 'assets/help/processing'; export const extractTransformationOptions = (schema: any, path: string[] = []): string[] => { @@ -205,7 +204,7 @@ const Processing: React.FC = () => { setCanProceed(value); }; - const handleAddOrEdit = (data: any, mapKey: string) => { + const handleAddOrEdit = useCallback((data: any, mapKey: string) => { const keyName = keyMapping[mapKey]; if (mapKey === 'validation') { @@ -219,7 +218,7 @@ const Processing: React.FC = () => { } else { updateDataset({ data: { [keyName]: data, dataset_id: datasetId } }); } - }; + }, []); const handleDelete = (fieldKey: string, data: any) => { let newData = { diff --git a/web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/AddTransformationExpression/AddTransformationExpression.tsx b/web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/AddTransformationExpression/AddTransformationExpression.tsx similarity index 99% rename from web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/AddTransformationExpression/AddTransformationExpression.tsx rename to web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/AddTransformationExpression/AddTransformationExpression.tsx index 42a694fa..d8c42501 100644 --- a/web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/AddTransformationExpression/AddTransformationExpression.tsx +++ b/web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/AddTransformationExpression/AddTransformationExpression.tsx @@ -25,7 +25,7 @@ import { Stack } from '@mui/material'; import CloseOutlinedIcon from '@mui/icons-material/CloseOutlined'; import { RJSFSchema, UiSchema } from '@rjsf/utils'; import JSONataPlayground from 'components/JsonPlay/JSONataPlayground'; -import { evaluateDataType } from 'pages/StepsPages/Processing/utils/dataTypeUtil'; +import { evaluateDataType } from 'pages/DatasetCreation/Processing/utils/dataTypeUtil'; import { Alert } from '@mui/material'; import en from 'utils/locales/en.json'; diff --git a/web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/DataValidation/DataValidation.tsx b/web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/DataValidation/DataValidation.tsx similarity index 100% rename from web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/DataValidation/DataValidation.tsx rename to web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/DataValidation/DataValidation.tsx diff --git a/web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/DataValidation/Schema.ts b/web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/DataValidation/Schema.ts similarity index 100% rename from web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/DataValidation/Schema.ts rename to web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/DataValidation/Schema.ts diff --git a/web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/DedupeEvent/DedupeEvent.tsx b/web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/DedupeEvent/DedupeEvent.tsx similarity index 100% rename from web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/DedupeEvent/DedupeEvent.tsx rename to web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/DedupeEvent/DedupeEvent.tsx diff --git a/web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/Denormalization/DataDenormalization.tsx b/web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/Denormalization/DataDenormalization.tsx similarity index 99% rename from web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/Denormalization/DataDenormalization.tsx rename to web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/Denormalization/DataDenormalization.tsx index 2c0f4969..c039041d 100644 --- a/web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/Denormalization/DataDenormalization.tsx +++ b/web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/Denormalization/DataDenormalization.tsx @@ -15,12 +15,11 @@ import BasicReactTable from 'components/CustomeTable/CustomTable'; import React, { useEffect, useState } from 'react'; import config from 'data/initialConfig'; import * as _ from 'lodash'; -import { useNavigate } from 'react-router'; +import { useNavigate } from 'react-router-dom'; import { DatasetStatus, DatasetType } from 'types/datasets'; import schema from './Schema'; import { ReactComponent as DeleteIcon } from 'assets/upload/Trash.svg'; import JSONataPlayground from 'components/JsonPlay/JSONataPlayground'; -import { evaluateDataType } from 'pages/StepsPages/Processing/utils/dataTypeUtil'; import { theme } from 'theme'; import { FormControl } from '@mui/material'; import { InputLabel } from '@mui/material'; diff --git a/web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/Denormalization/Schema.ts b/web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/Denormalization/Schema.ts similarity index 100% rename from web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/Denormalization/Schema.ts rename to web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/Denormalization/Schema.ts diff --git a/web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/Derived/AddNewField.tsx b/web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/Derived/AddNewField.tsx similarity index 99% rename from web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/Derived/AddNewField.tsx rename to web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/Derived/AddNewField.tsx index 55198729..f41b35ff 100644 --- a/web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/Derived/AddNewField.tsx +++ b/web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/Derived/AddNewField.tsx @@ -22,7 +22,7 @@ import { Stack } from '@mui/material'; import CloseOutlinedIcon from '@mui/icons-material/CloseOutlined'; import { RJSFSchema, UiSchema } from '@rjsf/utils'; import JSONataPlayground from 'components/JsonPlay/JSONataPlayground'; -import { evaluateDataType } from 'pages/StepsPages/Processing/utils/dataTypeUtil'; +import { evaluateDataType } from 'pages/DatasetCreation/Processing/utils/dataTypeUtil'; interface FormData { [key: string]: unknown; diff --git a/web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/Pii/Pii.tsx b/web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/Pii/Pii.tsx similarity index 100% rename from web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/Pii/Pii.tsx rename to web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/Pii/Pii.tsx diff --git a/web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/ProcessingSection.tsx b/web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/ProcessingSection.tsx similarity index 100% rename from web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/ProcessingSection.tsx rename to web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/ProcessingSection.tsx diff --git a/web-console-v2/src/pages/StepsPages/Processing/utils/dataTypeUtil.tsx b/web-console-v2/src/pages/DatasetCreation/Processing/utils/dataTypeUtil.tsx similarity index 100% rename from web-console-v2/src/pages/StepsPages/Processing/utils/dataTypeUtil.tsx rename to web-console-v2/src/pages/DatasetCreation/Processing/utils/dataTypeUtil.tsx diff --git a/web-console-v2/src/pages/Dataset/wizard/ReUploadFiles.tsx b/web-console-v2/src/pages/DatasetCreation/ReUploadFiles.tsx similarity index 97% rename from web-console-v2/src/pages/Dataset/wizard/ReUploadFiles.tsx rename to web-console-v2/src/pages/DatasetCreation/ReUploadFiles.tsx index a607eab3..306ef492 100644 --- a/web-console-v2/src/pages/Dataset/wizard/ReUploadFiles.tsx +++ b/web-console-v2/src/pages/DatasetCreation/ReUploadFiles.tsx @@ -9,10 +9,10 @@ import { useUploadToUrl, useGenerateJsonSchema, useUpdateDataset -} from '../../../services/dataset'; -import { readJsonFileContents } from '../../../services/utils'; -import AlertDialog from '../../../components/AlertDialog/AlertDialog'; -import { useAlert } from '../../../contexts/AlertContextProvider'; +} from '../../services/dataset'; +import { readJsonFileContents } from '../../services/utils'; +import AlertDialog from '../../components/AlertDialog/AlertDialog'; +import { useAlert } from '../../contexts/AlertContextProvider'; import UploadFiles from './UploadFiles'; import { useParams } from 'react-router-dom'; diff --git a/web-console-v2/src/pages/SelectConnector/FilterTypes.ts b/web-console-v2/src/pages/DatasetCreation/SelectConnector/FilterTypes.ts similarity index 100% rename from web-console-v2/src/pages/SelectConnector/FilterTypes.ts rename to web-console-v2/src/pages/DatasetCreation/SelectConnector/FilterTypes.ts diff --git a/web-console-v2/src/pages/SelectConnector/SelectConnector.module.css b/web-console-v2/src/pages/DatasetCreation/SelectConnector/SelectConnector.module.css similarity index 100% rename from web-console-v2/src/pages/SelectConnector/SelectConnector.module.css rename to web-console-v2/src/pages/DatasetCreation/SelectConnector/SelectConnector.module.css diff --git a/web-console-v2/src/pages/SelectConnector/SelectConnector.test.tsx b/web-console-v2/src/pages/DatasetCreation/SelectConnector/SelectConnector.test.tsx similarity index 96% rename from web-console-v2/src/pages/SelectConnector/SelectConnector.test.tsx rename to web-console-v2/src/pages/DatasetCreation/SelectConnector/SelectConnector.test.tsx index 10fb8cfe..a722b32a 100644 --- a/web-console-v2/src/pages/SelectConnector/SelectConnector.test.tsx +++ b/web-console-v2/src/pages/DatasetCreation/SelectConnector/SelectConnector.test.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { render, screen, fireEvent, waitFor } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import SelectConnector from './SelectConnector'; -import { connectorList } from '../../components/connectorList'; +import { connectorList } from '../../../components/connectorList'; import { BrowserRouter } from 'react-router-dom'; test('renders the SelectConnector component', () => { diff --git a/web-console-v2/src/pages/SelectConnector/SelectConnector.tsx b/web-console-v2/src/pages/DatasetCreation/SelectConnector/SelectConnector.tsx similarity index 100% rename from web-console-v2/src/pages/SelectConnector/SelectConnector.tsx rename to web-console-v2/src/pages/DatasetCreation/SelectConnector/SelectConnector.tsx diff --git a/web-console-v2/src/pages/StepsPages/StepperPage.tsx b/web-console-v2/src/pages/DatasetCreation/StepperPage.tsx similarity index 100% rename from web-console-v2/src/pages/StepsPages/StepperPage.tsx rename to web-console-v2/src/pages/DatasetCreation/StepperPage.tsx diff --git a/web-console-v2/src/pages/StepsPages/Storage/Storage.module.css b/web-console-v2/src/pages/DatasetCreation/Storage/Storage.module.css similarity index 100% rename from web-console-v2/src/pages/StepsPages/Storage/Storage.module.css rename to web-console-v2/src/pages/DatasetCreation/Storage/Storage.module.css diff --git a/web-console-v2/src/pages/StepsPages/Storage/Storage.tsx b/web-console-v2/src/pages/DatasetCreation/Storage/Storage.tsx similarity index 99% rename from web-console-v2/src/pages/StepsPages/Storage/Storage.tsx rename to web-console-v2/src/pages/DatasetCreation/Storage/Storage.tsx index 37adb424..cad2acd6 100644 --- a/web-console-v2/src/pages/StepsPages/Storage/Storage.tsx +++ b/web-console-v2/src/pages/DatasetCreation/Storage/Storage.tsx @@ -7,7 +7,7 @@ import Loader from 'components/Loader'; import { GenericCard } from 'components/Styled/Cards'; import { useAlert } from 'contexts/AlertContextProvider'; import _ from 'lodash'; -import styles from 'pages/ConnectorConfiguration/ConnectorConfiguration.module.css'; +import styles from 'pages/DatasetCreation/ConnectorConfiguration/ConnectorConfiguration.module.css'; import React, { useEffect, useState } from 'react'; import { useNavigate, useParams } from 'react-router-dom'; import { useFetchDatasetsById, useUpdateDataset } from 'services/dataset'; @@ -43,7 +43,6 @@ const Storage = () => { const [datasetType, setDatasetType] = useState('event'); const updateDatasetMutate = useUpdateDataset(); - const sessionData = sessionStorage.getItem('configDetails'); const { datasetId } : any = useParams(); const navigate = useNavigate(); diff --git a/web-console-v2/src/pages/Dataset/wizard/UploadFiles.tsx b/web-console-v2/src/pages/DatasetCreation/UploadFiles.tsx similarity index 100% rename from web-console-v2/src/pages/Dataset/wizard/UploadFiles.tsx rename to web-console-v2/src/pages/DatasetCreation/UploadFiles.tsx diff --git a/web-console-v2/src/pages/dashboardV1/createEvents.tsx b/web-console-v2/src/pages/DatasetListV1/DatasetCreateEvents.tsx similarity index 98% rename from web-console-v2/src/pages/dashboardV1/createEvents.tsx rename to web-console-v2/src/pages/DatasetListV1/DatasetCreateEvents.tsx index 49a27d58..478e5e87 100644 --- a/web-console-v2/src/pages/dashboardV1/createEvents.tsx +++ b/web-console-v2/src/pages/DatasetListV1/DatasetCreateEvents.tsx @@ -3,7 +3,7 @@ import { QuestionCircleFilled } from '@ant-design/icons'; import { Alert, Grid, Button, Box, Typography, } from '@mui/material'; import MainCard from 'components/MainCard'; import interactIds from 'data/telemetry/interact.json'; -import UploadFiles from 'pages/datasetV1/UploadFiles'; +import UploadFiles from './UploadFiles'; import { useState } from 'react'; import { useParams } from 'react-router'; import { datasetRead, sendEvents } from 'services/datasetV1'; @@ -15,7 +15,6 @@ import { readJsonFileContents } from 'services/utils'; import AnimateButton from 'components/@extended/AnimateButton'; import RejectionFiles from 'components/third-party/dropzone/RejectionFiles'; import Loader from 'components/Loader'; -import { DatasetStatus } from 'types/datasets'; import { useAlert } from 'contexts/AlertContextProvider'; const DatasetCreateEvents = () => { diff --git a/web-console-v2/src/pages/dashboardV1/DatasetMetrics.tsx b/web-console-v2/src/pages/DatasetListV1/DatasetMetrics.tsx similarity index 99% rename from web-console-v2/src/pages/dashboardV1/DatasetMetrics.tsx rename to web-console-v2/src/pages/DatasetListV1/DatasetMetrics.tsx index cbdac954..cedea602 100644 --- a/web-console-v2/src/pages/dashboardV1/DatasetMetrics.tsx +++ b/web-console-v2/src/pages/DatasetListV1/DatasetMetrics.tsx @@ -4,7 +4,7 @@ import { useState, cloneElement, useEffect } from "react"; import { useParams } from "react-router"; import _ from 'lodash'; import { DotChartOutlined } from "@ant-design/icons"; -import DatasetDetails from "./datasetsDetails"; +import DatasetDetails from "./DatasetsDetails"; import MainCard from "components/MainCard"; import { Typography } from "@mui/material"; import Skeleton from "components/Skeleton"; diff --git a/web-console-v2/src/pages/dashboardV1/datasetsDetails.tsx b/web-console-v2/src/pages/DatasetListV1/DatasetsDetails.tsx similarity index 98% rename from web-console-v2/src/pages/dashboardV1/datasetsDetails.tsx rename to web-console-v2/src/pages/DatasetListV1/DatasetsDetails.tsx index b3bc0222..b17671c5 100644 --- a/web-console-v2/src/pages/dashboardV1/datasetsDetails.tsx +++ b/web-console-v2/src/pages/DatasetListV1/DatasetsDetails.tsx @@ -1,17 +1,16 @@ /* eslint-disable */ import { Grid, Typography } from '@mui/material'; -import MainCard from 'components/MainCard'; import { useEffect, useState, useMemo } from 'react'; import { useParams } from 'react-router'; import { datasetRead } from 'services/datasetV1'; import * as _ from 'lodash'; -import ReportCard from 'components/cardsV1/statistics/ReportCard'; +import ReportCard from 'components/ReportCard'; import { BarChartOutlined } from '@ant-design/icons'; import { druidQueries } from 'services/druid'; import dayjs from 'dayjs'; import chartMeta from 'data/chartsV1'; -import ApexChart from 'sections/dashboard/analytics/apex'; -import ApexWithFilters from 'sections/dashboard/analytics/ChartFilters'; +import ApexChart from 'pages/Dashboard/analytics/apex'; +import ApexWithFilters from 'pages/Dashboard/analytics/ChartFilters'; import filters from 'data/chartFilters'; import { DatasetStatus, DatasetType } from 'types/datasets'; import { useAlert } from 'contexts/AlertContextProvider'; diff --git a/web-console-v2/src/pages/dashboardV1/datasets.tsx b/web-console-v2/src/pages/DatasetListV1/DatasetsList.tsx similarity index 94% rename from web-console-v2/src/pages/dashboardV1/datasets.tsx rename to web-console-v2/src/pages/DatasetListV1/DatasetsList.tsx index de012d79..7b5ed147 100644 --- a/web-console-v2/src/pages/dashboardV1/datasets.tsx +++ b/web-console-v2/src/pages/DatasetListV1/DatasetsList.tsx @@ -1,9 +1,9 @@ -/* eslint-disable */ -import { useEffect, useState } from 'react'; +import { useState } from 'react'; +import React from 'react'; import { Alert, Box, Grid, Stack, Tab, Tooltip, Typography, useTheme } from '@mui/material'; import * as _ from 'lodash'; -import DatasetsList from './datasetsList'; -import DraftDatasetsList from './draftDatasetsList'; +import LiveDatasets from './LiveDatasets'; +import DraftDatasetsList from './DraftDatasetsList'; import useImpression from 'hooks/useImpression'; import pageIds from 'data/telemetry/pageIds'; import RetiredDatasets from './RetiredDatasets'; @@ -16,8 +16,7 @@ import FiberManualRecordIcon from '@mui/icons-material/FiberManualRecord'; import ReadyToPublishDatasetsList from './ReadyToPublishDatasets'; import { FormattedMessage } from 'react-intl'; import { useSearchParams } from 'react-router-dom'; -import { Dialog, DialogTitle, DialogContent, DialogActions } from '@mui/material'; -import ImportDataset from 'pages/datasetV1/ImportDataset'; +import ImportDataset from 'pages/DatasetListV1/ImportDataset'; export const getLiveSourceConfig: any = (liveDataset: any, liveSourceConfigs: any) => { const condition = (config: any) => { @@ -49,7 +48,7 @@ export const getDraftSourceConfig: any = (draftDataset: any, draftSourceConfigs: const showNoDatasetsError = (message = ) => {message} export const renderNoDatasetsMessage = (message: string | any) => {showNoDatasetsError(message)} -const ClusterHealth = () => { +const DatasetsList = () => { const theme = useTheme(); const [params] = useSearchParams(); const datasetStatus: string = params.get("status") || DatasetStatus.Live @@ -68,7 +67,7 @@ const ClusterHealth = () => { const renderDatasets = (status: string) => { switch (status) { case DatasetStatus.Live: return - + case DatasetStatus.ReadyToPublish: return @@ -191,4 +190,4 @@ const ClusterHealth = () => { ) }; -export default ClusterHealth; +export default DatasetsList; diff --git a/web-console-v2/src/pages/dashboardV1/draftDatasetsList.tsx b/web-console-v2/src/pages/DatasetListV1/DraftDatasetsList.tsx similarity index 97% rename from web-console-v2/src/pages/dashboardV1/draftDatasetsList.tsx rename to web-console-v2/src/pages/DatasetListV1/DraftDatasetsList.tsx index d4120c1f..22245de6 100644 --- a/web-console-v2/src/pages/dashboardV1/draftDatasetsList.tsx +++ b/web-console-v2/src/pages/DatasetListV1/DraftDatasetsList.tsx @@ -7,25 +7,21 @@ import ScrollX from 'components/ScrollX'; import { IconButton, Box } from '@mui/material'; import { EditOutlined, DeleteFilled } from '@ant-design/icons'; import FilteringTable from 'components/filtering-table'; -import AlertDialog from 'components/AlertDialog'; +import AlertDialog from 'components/AlertDialog/AlertDialog'; import { useNavigate } from 'react-router'; import dayjs from 'dayjs'; import * as _ from 'lodash'; import interactIds from 'data/telemetry/interact.json'; -import { fetchDatasets, deleteDataset, updateDataset, getDraftTagsPayload, versionKeyMap, setVersionKey } from 'services/datasetV1'; +import { fetchDatasets, deleteDataset, updateDataset, getDraftTagsPayload, setVersionKey } from 'services/datasetV1'; import EditDatasetTags from 'components/EditDatasetTags'; import StyleIcon from '@mui/icons-material/Style'; -import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; -import ChevronRightIcon from '@mui/icons-material/ChevronRight'; import { v4 } from 'uuid'; -import Loader from 'components/Loader'; import { renderSkeleton } from 'services/skeleton'; import { FormattedMessage } from 'react-intl'; import en from 'utils/locales/en.json'; import { DatasetStatus, DatasetType } from 'types/datasets'; -import FiberManualRecordIcon from '@mui/icons-material/FiberManualRecord'; -import { getDraftSourceConfig, renderNoDatasetsMessage } from './datasets'; import { useAlert } from 'contexts/AlertContextProvider'; +import { getDraftSourceConfig, renderNoDatasetsMessage } from './DatasetsList'; export const alertDialogContext = (datasetName: string = "") => ({ title: , content: }) diff --git a/web-console-v2/src/pages/datasetV1/ImportDataset.tsx b/web-console-v2/src/pages/DatasetListV1/ImportDataset.tsx similarity index 99% rename from web-console-v2/src/pages/datasetV1/ImportDataset.tsx rename to web-console-v2/src/pages/DatasetListV1/ImportDataset.tsx index 96fd1006..92e64e6f 100644 --- a/web-console-v2/src/pages/datasetV1/ImportDataset.tsx +++ b/web-console-v2/src/pages/DatasetListV1/ImportDataset.tsx @@ -7,7 +7,7 @@ import AnimateButton from 'components/@extended/AnimateButton'; import PlaceholderContent from 'components/Dropzone/PlaceholderContent'; import uploadIcon from 'assets/upload/upload_icon.svg'; import { datasetRead, fetchDatasets, importDataset } from 'services/datasetV1'; -import ImportDialog from './ImportDialog'; // Import your dialog component +import ImportDialog from './ImportDialog'; import HtmlTooltip from 'components/HtmlTooltip'; import _ from 'lodash'; import { DatasetStatus } from 'types/datasets'; diff --git a/web-console-v2/src/pages/datasetV1/ImportDialog.tsx b/web-console-v2/src/pages/DatasetListV1/ImportDialog.tsx similarity index 100% rename from web-console-v2/src/pages/datasetV1/ImportDialog.tsx rename to web-console-v2/src/pages/DatasetListV1/ImportDialog.tsx diff --git a/web-console-v2/src/pages/dashboardV1/datasetsList.tsx b/web-console-v2/src/pages/DatasetListV1/LiveDatasets.tsx similarity index 99% rename from web-console-v2/src/pages/dashboardV1/datasetsList.tsx rename to web-console-v2/src/pages/DatasetListV1/LiveDatasets.tsx index fe1520f1..add59716 100644 --- a/web-console-v2/src/pages/dashboardV1/datasetsList.tsx +++ b/web-console-v2/src/pages/DatasetListV1/LiveDatasets.tsx @@ -6,7 +6,7 @@ import ScrollX from 'components/ScrollX'; import { IconButton } from '@mui/material'; import { DashboardOutlined, EyeOutlined } from '@ant-design/icons'; import FilteringTable from 'components/filtering-table'; -import AlertDialog from 'components/AlertDialog'; +import AlertDialog from 'components/AlertDialog/AlertDialog'; import { useNavigate } from 'react-router'; import { fetchChartData } from 'services/clusterMetrics'; import { druidQueries } from 'services/druid'; @@ -28,7 +28,7 @@ import { downloadJSONSchemaV1, flattenSchema } from 'services/json-schema'; import { downloadJsonFile } from 'utils/downloadUtils'; import MoreOptions from './MoreOptions'; import StyleIcon from '@mui/icons-material/Style'; -import { getLiveSourceConfig, renderNoDatasetsMessage } from './datasets'; +import { getLiveSourceConfig, renderNoDatasetsMessage } from './DatasetsList'; import { useAlert } from 'contexts/AlertContextProvider'; const dateFormat = 'YYYY-MM-DDT00:00:00+05:30' @@ -40,7 +40,7 @@ const statusColors: Record = { } export const pageMeta = { pageId: 'datasetConfiguration' }; -const DatasetsList = ({ setDatasetType, sourceConfigs }: any) => { +const LiveDatasets = ({ setDatasetType, sourceConfigs }: any) => { const { showAlert } = useAlert(); const [openAlertDialog, setOpenAlertDialog] = useState(false); const [data, setData] = useState([]); @@ -523,4 +523,4 @@ const DatasetsList = ({ setDatasetType, sourceConfigs }: any) => { ); }; -export default DatasetsList; +export default LiveDatasets; diff --git a/web-console-v2/src/pages/dashboardV1/MoreOptions.tsx b/web-console-v2/src/pages/DatasetListV1/MoreOptions.tsx similarity index 100% rename from web-console-v2/src/pages/dashboardV1/MoreOptions.tsx rename to web-console-v2/src/pages/DatasetListV1/MoreOptions.tsx diff --git a/web-console-v2/src/pages/datasetV1/utils/PasteData.tsx b/web-console-v2/src/pages/DatasetListV1/PasteData.tsx similarity index 100% rename from web-console-v2/src/pages/datasetV1/utils/PasteData.tsx rename to web-console-v2/src/pages/DatasetListV1/PasteData.tsx diff --git a/web-console-v2/src/pages/dashboardV1/ReadyToPublishDatasets.tsx b/web-console-v2/src/pages/DatasetListV1/ReadyToPublishDatasets.tsx similarity index 97% rename from web-console-v2/src/pages/dashboardV1/ReadyToPublishDatasets.tsx rename to web-console-v2/src/pages/DatasetListV1/ReadyToPublishDatasets.tsx index f0492221..de2b6efd 100644 --- a/web-console-v2/src/pages/dashboardV1/ReadyToPublishDatasets.tsx +++ b/web-console-v2/src/pages/DatasetListV1/ReadyToPublishDatasets.tsx @@ -6,30 +6,25 @@ import ScrollX from 'components/ScrollX'; import { IconButton, Box } from '@mui/material'; import { PlayCircleOutlined, EditOutlined, DeleteFilled, ExportOutlined } from '@ant-design/icons'; import FilteringTable from 'components/filtering-table'; -import AlertDialog from 'components/AlertDialog'; +import AlertDialog from 'components/AlertDialog/AlertDialog'; import { useNavigate } from 'react-router'; import { publishDataset } from 'services/systemV1'; import dayjs from 'dayjs'; import * as _ from 'lodash'; import interactIds from 'data/telemetry/interact.json'; -import { exportDataset, fetchDatasets, deleteDataset, updateDataset, getDraftTagsPayload, versionKeyMap, setVersionKey } from 'services/datasetV1'; +import { exportDataset, fetchDatasets, deleteDataset, updateDataset, getDraftTagsPayload, setVersionKey } from 'services/datasetV1'; import EditDatasetTags from 'components/EditDatasetTags'; import StyleIcon from '@mui/icons-material/Style'; -import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; -import ChevronRightIcon from '@mui/icons-material/ChevronRight'; import { v4 } from 'uuid'; -import Loader from 'components/Loader'; import { renderSkeleton } from 'services/skeleton'; import PostAddIcon from '@mui/icons-material/PostAdd'; import en from 'utils/locales/en.json'; import { DatasetStatus, DatasetType } from 'types/datasets'; -import FiberManualRecordIcon from '@mui/icons-material/FiberManualRecord'; -import { downloadJSONSchemaV1, flattenSchema } from 'services/json-schema'; import { downloadJsonFile } from 'utils/downloadUtils'; -import { alertDialogContext } from './draftDatasetsList'; -import { getDraftSourceConfig, renderNoDatasetsMessage } from './datasets'; +import { alertDialogContext } from './DraftDatasetsList'; +import { getDraftSourceConfig, renderNoDatasetsMessage } from './DatasetsList'; import { http } from 'services/http'; -import apiEndpoints from 'data/apiEndpoints'; +import apiEndpoints from 'constants/Endpoints'; import { useAlert } from 'contexts/AlertContextProvider'; const ReadyToPublishDatasetsList = ({ setDatasetType, sourceConfigs }: any) => { diff --git a/web-console-v2/src/pages/dashboardV1/RetiredDatasets.tsx b/web-console-v2/src/pages/DatasetListV1/RetiredDatasets.tsx similarity index 99% rename from web-console-v2/src/pages/dashboardV1/RetiredDatasets.tsx rename to web-console-v2/src/pages/DatasetListV1/RetiredDatasets.tsx index 31e9cb21..b3928c20 100644 --- a/web-console-v2/src/pages/dashboardV1/RetiredDatasets.tsx +++ b/web-console-v2/src/pages/DatasetListV1/RetiredDatasets.tsx @@ -9,12 +9,11 @@ import dayjs from 'dayjs'; import * as _ from 'lodash'; import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; import ChevronRightIcon from '@mui/icons-material/ChevronRight'; -import Loader from 'components/Loader'; import { renderSkeleton } from 'services/skeleton'; import FiberManualRecordIcon from '@mui/icons-material/FiberManualRecord'; import { fetchDatasets } from 'services/datasetV1'; import { DatasetStatus } from 'types/datasets'; -import { getDraftSourceConfig, renderNoDatasetsMessage } from './datasets'; +import { getDraftSourceConfig, renderNoDatasetsMessage } from './DatasetsList'; import en from 'utils/locales/en.json'; import { useAlert } from 'contexts/AlertContextProvider'; diff --git a/web-console-v2/src/pages/datasetV1/UploadFiles.tsx b/web-console-v2/src/pages/DatasetListV1/UploadFiles.tsx similarity index 99% rename from web-console-v2/src/pages/datasetV1/UploadFiles.tsx rename to web-console-v2/src/pages/DatasetListV1/UploadFiles.tsx index 339fa2bc..230f53d0 100644 --- a/web-console-v2/src/pages/datasetV1/UploadFiles.tsx +++ b/web-console-v2/src/pages/DatasetListV1/UploadFiles.tsx @@ -12,7 +12,7 @@ import { readJsonFileContents } from 'services/utils'; import interactIds from 'data/telemetry/interact.json'; import Loader from 'components/Loader'; import { useAlert } from 'contexts/AlertContextProvider'; -import PasteData from './utils/PasteData'; +import PasteData from './PasteData'; const tabProps = (index: number) => ({ id: `tab-${index}`, 'aria-controls': `tabpanel-${index}` }); diff --git a/web-console-v2/src/pages/NotFound/NotFound.module.css b/web-console-v2/src/pages/NotFound/NotFound.module.css new file mode 100644 index 00000000..82ac2545 --- /dev/null +++ b/web-console-v2/src/pages/NotFound/NotFound.module.css @@ -0,0 +1,13 @@ +.errorIcon { + height: 20rem; + width: 20rem; +} + +.container { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + text-align: center; + height: calc(100vh - 4.7rem); +} \ No newline at end of file diff --git a/web-console-v2/src/pages/NotFound/NotFound.tsx b/web-console-v2/src/pages/NotFound/NotFound.tsx new file mode 100644 index 00000000..05e17bf7 --- /dev/null +++ b/web-console-v2/src/pages/NotFound/NotFound.tsx @@ -0,0 +1,27 @@ +import { Button, Typography } from "@mui/material"; +import { Box } from "@mui/system"; +import React, { useCallback } from "react"; +import Error from '../../assets/ErrorSvg'; +import styles from './NotFound.module.css'; +import { useNavigate } from "react-router-dom"; + +export const NotFound = () => { + const navigate = useNavigate(); + const handleHome = useCallback(() => { + navigate("/dashboard") + }, []); + return ( + + + + + + + + + Page not found + + ) +} \ No newline at end of file diff --git a/web-console-v2/src/pages/Settings/Settings.tsx b/web-console-v2/src/pages/Settings/Settings.tsx deleted file mode 100644 index ceb90fcc..00000000 --- a/web-console-v2/src/pages/Settings/Settings.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import React from 'react'; - -const Settings = () => { - return
Settings
; -}; - -export default Settings; diff --git a/web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/DedupeEvent/Schema.ts b/web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/DedupeEvent/Schema.ts deleted file mode 100644 index e1e6eb2d..00000000 --- a/web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/DedupeEvent/Schema.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { RJSFSchema, UiSchema } from '@rjsf/utils'; -import { CustomCheckboxWidget } from 'components/CheckboxWithInfoIcon/CheckboxWithInfoIcon'; - -interface FormSchema { - title: string; - schema: RJSFSchema; - uiSchema: UiSchema; -} - -const schema: FormSchema = -{ - title: '', - schema: { - type: 'object', - properties: { - section1: { - title: '', - type: 'object', - properties: { - dropDuplicates: { - type: 'array', - items: { - type: 'string', - enum: ['Enable Deduplication'] - }, - uniqueItems: true - }, - dedupeKey: { - type: 'string', - title: 'Select Dedupe Key', - enum: [''], - uniqueItems: true - } - } - } - } - }, - uiSchema: { - 'ui:submitButtonOptions': { - norender: true - }, - section1: { - 'ui:submitButtonOptions': { - norender: true - }, - dropDuplicates: { - 'ui:widget': CustomCheckboxWidget, - 'ui:options': { - inline: true - } - }, - dedupeKey: { - 'ui:widget': 'select', - 'ui:help': 'Select a unique event id from the list of fields' - } - } - } -}; - -export default schema; \ No newline at end of file diff --git a/web-console-v2/src/pages/alertManager/components/NotificationComponent.tsx b/web-console-v2/src/pages/alertManager/components/NotificationComponent.tsx index bf1a3900..e3af2ee4 100644 --- a/web-console-v2/src/pages/alertManager/components/NotificationComponent.tsx +++ b/web-console-v2/src/pages/alertManager/components/NotificationComponent.tsx @@ -1,7 +1,6 @@ import React from 'react'; import { Box, Button, Grid, Stack, Typography } from "@mui/material"; import MUIForm from "components/form"; -import { StandardWidthButton } from "components/Styled/Buttons"; import { useEffect, useRef, useState } from "react"; import { fetchChannels } from "services/notificationChannels"; import interactIds from "data/telemetry/interact.json"; diff --git a/web-console-v2/src/pages/alertManager/components/RunQuery.tsx b/web-console-v2/src/pages/alertManager/components/RunQuery.tsx index caf5daae..c15383cc 100644 --- a/web-console-v2/src/pages/alertManager/components/RunQuery.tsx +++ b/web-console-v2/src/pages/alertManager/components/RunQuery.tsx @@ -2,8 +2,8 @@ import React from 'react'; import { Grid, Stack } from "@mui/material"; import _ from 'lodash'; import dayjs from 'dayjs'; -import endpoints from 'data/apiEndpoints'; -import ApexChart from "sections/dashboard/analytics/apex"; +import endpoints from 'constants/Endpoints'; +import ApexChart from "pages/Dashboard/analytics/apex"; import { Button } from "@mui/material"; import { CloseOutlined } from "@ant-design/icons"; import { useEffect, useState } from "react"; diff --git a/web-console-v2/src/pages/alertManager/components/ViewRuleHeader.tsx b/web-console-v2/src/pages/alertManager/components/ViewRuleHeader.tsx index e11ab3b8..0ea43420 100644 --- a/web-console-v2/src/pages/alertManager/components/ViewRuleHeader.tsx +++ b/web-console-v2/src/pages/alertManager/components/ViewRuleHeader.tsx @@ -5,7 +5,7 @@ import { Box, Button, Grid, Stack, Tooltip, Typography } from '@mui/material'; import { useNavigate } from 'react-router'; import { addSilence, deleteAlert, deleteSilence, publishAlert } from 'services/alerts'; import { useMemo, useState } from 'react'; -import AlertDialog from 'components/AlertDialog'; +import AlertDialog from 'components/AlertDialog/AlertDialog'; import { alertHealthStatus, dialogBoxContext, SilenceDialog } from '../services/utils'; import { NotificationsActiveOutlined, NotificationsOff, RefreshOutlined } from '@mui/icons-material'; import dayjs from 'dayjs'; diff --git a/web-console-v2/src/pages/auth/components/AuthLogin.tsx b/web-console-v2/src/pages/auth/components/AuthLogin.tsx index fd7d11dd..571e8c02 100644 --- a/web-console-v2/src/pages/auth/components/AuthLogin.tsx +++ b/web-console-v2/src/pages/auth/components/AuthLogin.tsx @@ -6,10 +6,10 @@ import LoginForm from './LoginForm'; import { TabPanel } from './TabPanel'; import pageIds from 'data/telemetry/pageIds'; import useImpression from 'hooks/useImpression'; -import { getConfigValue } from 'services/configData'; +import { getSystemSetting } from 'services/configData'; const AuthLogin = () => { - const allowedAuthTypes = getConfigValue("AUTHENTICATION_ALLOWED_TYPES") || 'obsrv'; + const allowedAuthTypes = getSystemSetting("AUTHENTICATION_ALLOWED_TYPES") || 'obsrv'; const [showPassword, setShowPassword] = React.useState(false); const [searchParams] = useSearchParams(); const [tabIndex, setTabIndex] = useState(0); diff --git a/web-console-v2/src/pages/auth/components/LoginSocialButton.tsx b/web-console-v2/src/pages/auth/components/LoginSocialButton.tsx index afca65ec..97e862f7 100644 --- a/web-console-v2/src/pages/auth/components/LoginSocialButton.tsx +++ b/web-console-v2/src/pages/auth/components/LoginSocialButton.tsx @@ -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 { getConfigValueV1 } from 'services/configData'; +import { getSystemSetting } from 'services/configData'; const LoginSocialButton = () => { const theme = useTheme(); const matchDownSM = useMediaQuery(theme.breakpoints.down('sm')); - const allowedAuthTypes = getConfigValueV1("AUTHENTICATION_ALLOWED_TYPES") || "" + const allowedAuthTypes = getSystemSetting("AUTHENTICATION_ALLOWED_TYPES") || "" const renderSocialButtons = (option: any) => { return ( diff --git a/web-console-v2/src/pages/auth/components/logo/index.tsx b/web-console-v2/src/pages/auth/components/logo/index.tsx index be092f72..f6ab959a 100644 --- a/web-console-v2/src/pages/auth/components/logo/index.tsx +++ b/web-console-v2/src/pages/auth/components/logo/index.tsx @@ -1,11 +1,9 @@ /* eslint-disable */ -import { Link } from 'react-router-dom'; import { To } from 'history'; import { ButtonBase } from '@mui/material'; import { SxProps } from '@mui/system'; import Logo from './LogoMain'; import LogoIcon from './LogoIcon'; -import config from 'config'; interface Props { reverse?: boolean; diff --git a/web-console-v2/src/pages/DatasetManagement/DatasetManagement.tsx b/web-console-v2/src/pages/datasetManagement/DatasetManagement.tsx similarity index 97% rename from web-console-v2/src/pages/DatasetManagement/DatasetManagement.tsx rename to web-console-v2/src/pages/datasetManagement/DatasetManagement.tsx index 2598ba78..c2507ff0 100644 --- a/web-console-v2/src/pages/DatasetManagement/DatasetManagement.tsx +++ b/web-console-v2/src/pages/datasetManagement/DatasetManagement.tsx @@ -6,7 +6,7 @@ import { useEffect, useState } from "react"; import { Box, Typography } from "@mui/material"; import { DatasetStatus } from "types/datasets"; import Loader from "components/Loader"; -import ReviewAllCongurations from "pages/datasetV1/ReviewAllConfigurations"; +import ReviewAllCongurations from "pages/datasetView"; import { useAlert } from "contexts/AlertContextProvider"; import { getDatasetState } from "services/datasetV1"; import ListRollups from "pages/Rollup/components/ListRollups"; diff --git a/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/DataFormats.tsx b/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/DataFormats.tsx deleted file mode 100644 index e35aba8f..00000000 --- a/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/DataFormats.tsx +++ /dev/null @@ -1,71 +0,0 @@ -/* eslint-disable */ -import React from "react"; -import { - Box, Typography, Alert, Grid, Checkbox -} from '@mui/material'; -import * as _ from "lodash"; -import { WarningOutlined } from '@ant-design/icons'; -import { Stack } from '@mui/material'; -import FiberManualRecordIcon from '@mui/icons-material/FiberManualRecord'; - -const DataFormats = (props: any) => { - const { datasetState } = props; - const dataFormatConfig: any = _.get(datasetState, ['pages', 'dataFormat']); - - const displayBatchColumns = [ - { id: 'extractionKey', label: 'Extraction Key' }, - { id: 'batchId', label: 'Batch ID' }, - { id: 'dedupeRequired', label: 'Dedup Required' }, - { id: 'dedupePeriod', label: 'Dedup Period' }, - ]; - - const dataFormatSection = () => <> - - - - - - {"Individual Events"} - - - - {_.lowerCase(dataFormatConfig.value.type) === "yes" && - <> - - - - - - - {"Batch Mode"} - - - - - - - - Extraction Key : {dataFormatConfig.value[displayBatchColumns[0].id]} - - - - Batch Identifier : {dataFormatConfig.value[displayBatchColumns[1].id]} - - - - - - - } - - ; - if (dataFormatConfig) - return ( - <> - {dataFormatSection()} - - ); - else return (}>No information to display); -} - -export default DataFormats \ No newline at end of file diff --git a/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Datakey.tsx b/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Datakey.tsx deleted file mode 100644 index 53ea30a3..00000000 --- a/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Datakey.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import React from "react"; -import { - Box, Typography, Alert, Grid -} from '@mui/material'; -import * as _ from "lodash"; -import { WarningOutlined } from '@ant-design/icons'; -import FiberManualRecordIcon from '@mui/icons-material/FiberManualRecord'; - -const Datakey = (props: any) => { - const { datasetState } = props; - const denormDataKey: any = _.get(datasetState, ['pages', 'dataKey']); - - const denormDataKeySection = () => <> - - - - - - Data Key : {_.get(denormDataKey, "dataKey")} - - - - - - - if (denormDataKey) - return ( - <> - {denormDataKey && denormDataKeySection()} - - ); - else return (}>No information to display); -} - -export default Datakey \ No newline at end of file diff --git a/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Datasource.tsx b/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Datasource.tsx deleted file mode 100644 index c655cacb..00000000 --- a/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Datasource.tsx +++ /dev/null @@ -1,86 +0,0 @@ -import React, { useState } from 'react' -import { - Box, Typography, Alert, Grid, Accordion, AccordionSummary, AccordionDetails, -} from '@mui/material'; -import { flattenObject } from 'services/utils'; -import MainCard from 'components/MainCard'; -import { getKeyAlias } from 'services/keysAlias'; -import BasicReactTable from 'components/BasicReactTable'; -import * as _ from "lodash" -import { WarningOutlined } from '@ant-design/icons'; -import DataIngestCURLCopy from 'data/review/copyDataIngestionCurl'; - -const Datasource = (props: any) => { - const { datasetState } = props; - const dataSourceConfig: any = _.get(datasetState, ['pages', 'dataSource']); - const [expanded, setExpanded] = useState('panel1'); - const datasetId = _.get(datasetState, ["pages", "datasetConfiguration", "state", "config", "dataset_id"]) || "" - const dataFormatConfig: any = _.get(datasetState, ['pages', 'dataFormat']); - - const dataSourceSection = () => { - const handleChange = - (panel: string) => (event: React.SyntheticEvent, newExpanded: boolean) => { - setExpanded(newExpanded ? panel : false); - }; - - return <> - {_.map(dataSourceConfig.formFieldSelection, (field: any) => { - if (field !== "kafka-connector-1.0.0" && field !== "api") { - // Skip rendering for other fields - return null; - } - const connectorConfigs = _.get(dataSourceConfig, ["value", field]) || {}; - const filteredConfigs = _.omit(connectorConfigs, ["connector_type", "authenticationMechanism", "id", "prefix", "fileFormat.compressed"]) - const values = flattenObject(filteredConfigs) || []; - - const columns = [ - { - Header: () => null, - accessor: 'key', - disableFilters: true, - Cell: (cell: any) => { - const payload = _.get(cell, ["cell", "row", "original"]) || {}; - const { key, value } = payload; - return {_.capitalize(getKeyAlias(key))} - } - }, - { - Header: () => null, - accessor: 'value', - disableFilters: true, - Cell: (cell: any) => { - const payload = _.get(cell, ["cell", "row", "original"]) || {}; - const { key, value } = payload; - return {value} - } - } - ] - - return - - {_.toUpper(getKeyAlias(field))} - - - - - - {field == "api" && } - {!_.isEmpty(values) && } - - - - - - })} - - } - if (dataSourceConfig) - return ( - <> - {dataSourceSection()} - - ); - else return (}>No information to display); -} - -export default Datasource \ No newline at end of file diff --git a/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Deduplication.tsx b/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Deduplication.tsx deleted file mode 100644 index 54e77522..00000000 --- a/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Deduplication.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import React from "react"; -import { - Box, Typography, Alert, Grid -} from '@mui/material'; -import * as _ from "lodash"; -import { WarningOutlined } from '@ant-design/icons'; -import FiberManualRecordIcon from '@mui/icons-material/FiberManualRecord'; - -const Deduplication = (props: any) => { - const { datasetState } = props; - const dedupeKey: any = _.get(datasetState, ['pages', 'dedupe', 'optionSelection', 'dedupeKey']); - - const dedupeBox = () => ( - - - Dedup Field : {dedupeKey} - - ); - - if (dedupeKey) - return ( - <> - - - {dedupeKey && - {dedupeBox()} - } - - - - ); - else return (}>No information to display); -} - -export default Deduplication \ No newline at end of file diff --git a/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Denormalization.tsx b/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Denormalization.tsx deleted file mode 100644 index af73bb1b..00000000 --- a/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Denormalization.tsx +++ /dev/null @@ -1,99 +0,0 @@ -import React from "react"; -import { - Table, TableBody, - TableCell, TableContainer, TableHead, - TableRow, Alert, Grid, Tooltip -} from '@mui/material'; -import * as _ from "lodash"; -import { WarningOutlined } from '@ant-design/icons'; -import { OverflowTypography } from 'components/Styled/Typography'; -import { useEffect, useState } from 'react'; -import { fetchDatasets } from 'services/datasetV1'; -import { DatasetStatus, DatasetType } from 'types/datasets'; - -export const getMasterDatasets = (datasets: Array) => { - return _.filter(datasets, (dataset: Record) => _.get(dataset, 'type') === DatasetType.MasterDataset && [DatasetStatus.Live,].includes(_.get(dataset, 'status'))); -} -const Denormalization = (props: any) => { - const { datasetState } = props; - const [datasets, setDatasets] = useState([]) - const denorms: any = _.get(datasetState, ['pages', 'denorm', 'values']); - - const masterDatasets = getMasterDatasets(datasets) - const dataset = (value: any) => _.find(masterDatasets, ['dataset_config.cache_config.redis_db', value]); - const displayColumns: any = { - "denorm_key": "Dataset Field", - "dataset_id": "Master Dataset", - "denorm_out_field": "New Field Name" - } - - const fetchDatasetsList = async () => { - try { - const datasets = await fetchDatasets({}) - setDatasets(_.get(datasets, "data")) - } catch (error) { - setDatasets([]) - } - } - - useEffect(() => { - fetchDatasetsList() - }, []) - - const dedupeOptionTable = (title: string, config: any) => - <> - - - - - {Object.values(displayColumns).map((item: any, index: any) => ( - - {item} - - ))} - - - - {denorms.map((item: any, i:any) => { - item = { - denorm_key: item?.denorm_key, - dataset_id: item?.dataset_id, - denorm_out_field: item?.denorm_out_field - } - const masterDataset = _.find(masterDatasets, (dataset: any) => { - return _.get(dataset, "dataset_id") === _.get(item, "dataset_id") - }) - const masterDatasetName = _.get(masterDataset, "name") - return - {Object.entries(item).map(([key, value]: any) => ( - - - - {key === "dataset_id" ? masterDatasetName : value} - - - - ))} - - })} - -
-
- ; - - if (!_.isEmpty(denorms)) - return ( - <> - - {_.size(denorms) > 0 && ( - - {dedupeOptionTable("Denormalization", denorms)} - - )} - - - ); - else return (}>No information to display); -} - -export default Denormalization \ No newline at end of file diff --git a/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/TimestampField.tsx b/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/TimestampField.tsx deleted file mode 100644 index cb82a021..00000000 --- a/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/TimestampField.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import React from "react"; -import { - Typography, Alert -} from '@mui/material'; -import { DEFAULT_TIMESTAMP } from 'services/datasetV1'; -import * as _ from "lodash" -import { WarningOutlined } from '@ant-design/icons'; -import FiberManualRecordIcon from '@mui/icons-material/FiberManualRecord'; - -const TimestampField = (props: any) => { - const { datasetState } = props; - const indexCol: any = _.get(datasetState, ['pages', 'timestamp', 'indexCol']); - const timestampCol: string = indexCol == DEFAULT_TIMESTAMP.indexValue ? "Event Arrival Time" : indexCol - - const timestampField = () => ( - - - Timestamp Field : {timestampCol} - - ) - - if (timestampCol) - return ( - <> - {timestampCol && timestampField()} - - ); - else return (}>No information to display); -} - -export default TimestampField \ No newline at end of file diff --git a/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Transformations.tsx b/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Transformations.tsx deleted file mode 100644 index f5ab550b..00000000 --- a/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Transformations.tsx +++ /dev/null @@ -1,95 +0,0 @@ -/* eslint-disable */ -import React from "react"; -import { - Table, TableBody, - TableCell, TableContainer, TableHead, - TableRow, Alert, Grid, Tooltip, -} from '@mui/material'; -import * as _ from "lodash"; -import { OverflowTypography } from 'components/Styled/Typography'; -import { WarningOutlined } from '@ant-design/icons'; - -const displayModifiedColumns: any = () => { - return ([ - { id: 'column', label: 'Field' }, - { id: '_transformationType', label: 'Transformation' }, - { id: "transformation_mode", label: "Mode" } - ]) -}; - -const Transformations = (props: any) => { - const { datasetState } = props; - const transformationFields: any = _.get(datasetState, ['pages', 'transform', 'selection']) || []; - const additionalFields: any = _.get(datasetState, ['pages', 'derived', 'selection']) || []; - const piiFields: any = _.get(datasetState, ['pages', 'pii', 'selection']) || []; - const allTransformations = [...piiFields, ...transformationFields, ...additionalFields]; - const customTypes = [ - { id: "transformations", title: "Transformations", data: allTransformations }, - ] - const renderTable = (title: string, data: any, id: string) => - <> - - - - - {displayModifiedColumns(id).map((item: any) => ( - - {item.label} - - ))} - - - - {data.map((item: any) => ( - - {displayModifiedColumns(id).map((cellName: any) => { - if (cellName.id === "_transformationType" && item[cellName.id] === "custom") - return ( - - - - {item["transformation"]} - - - - ) - else return ( - - - - {item[cellName.id]} - - - - ) - })} - - ))} - -
-
- ; - - if (allTransformations.length > 0) - return ( - <> - {customTypes.length > 0 && - - {customTypes.map(({ title, data, id }, i: any) => { - if (_.size(data) > 0) - return ( - - {renderTable(title, data, id)} - - ); else return null; - }) - } - - } - - ); - else return (}>No information to display); - -} - -export default Transformations; \ No newline at end of file diff --git a/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Validation.tsx b/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Validation.tsx deleted file mode 100644 index fb695217..00000000 --- a/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Validation.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import React from "react"; -import { - Box, Typography, Alert, Grid -} from '@mui/material'; -import * as _ from "lodash"; -import { WarningOutlined } from '@ant-design/icons'; -import FiberManualRecordIcon from '@mui/icons-material/FiberManualRecord'; - - -const Validation = (props: any) => { - const { datasetState } = props; - const dataValidation: any = _.get(datasetState, ['pages', 'dataValidation', 'formFieldSelection']); - - const dataValidationBox = () => ( - - - Data Validation : {dataValidation} - - ); - if (dataValidation) - return ( - <> - - - {dataValidation && - {dataValidationBox()} - } - - - - ); - else return (}>No information to display); -} - -export default Validation \ No newline at end of file diff --git a/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/ingestionSpec.tsx b/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/ingestionSpec.tsx deleted file mode 100644 index 339fb049..00000000 --- a/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/ingestionSpec.tsx +++ /dev/null @@ -1,128 +0,0 @@ -import React from "react"; -import ExpandingTable from 'components/ExpandingTable/ExpandingTable'; -import { useEffect, useMemo, useState } from 'react'; -import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; -import ChevronRightIcon from '@mui/icons-material/ChevronRight'; -import { DefaultColumnFilter } from 'utils/react-table'; -import _ from 'lodash'; -import { renderColumnCell } from 'pages/datasetV1/utils/renderCells'; -import { Box, Grid, Typography, useTheme } from '@mui/material'; -import { getNestingV1 } from 'services/json-schema'; -import { getAllFields } from 'services/datasetV1'; -import { renderSkeleton } from 'services/skeleton'; - -const IngestionSpec = (props: any) => { - const { datasetState } = props; - const [flattenedData, setFlattenedData] = useState>>([]); - const [loading, setLoading] = useState(false); - const dataset_state = !_.isEmpty(datasetState) ? datasetState : ""; - const jsonSchema = _.get(dataset_state, 'pages.jsonSchema.schema'); - const theme = useTheme(); - - const updateFields = async () => { - setLoading(true) - try { - const status = _.get(dataset_state, "pages.status") - const fields: any = await getAllFields(datasetState?.pages?.datasetConfiguration?.state?.config?.dataset_id, status) - const result = fields?.data[0] || []; - setFlattenedData(result); - } catch (error: any) { - console.log(error); - } finally { - setLoading(false) - } - } - - useEffect(() => { - updateFields(); - }, []); - - const persistState = (data?: any) => { - return; - } - - const columns = useMemo( - () => [ - { - Header: () => null, - id: 'expander', - className: 'cell-center', - tipText: '', - editable: false, - Cell: ({ row }: any) => { - const collapseIcon = row.isExpanded ? : ; - return ( - row.canExpand && - row.depth === 0 && ( - - {collapseIcon} - - ) - ); - }, - SubCell: () => null - }, - { - Header: 'Field', - accessor: 'column', - tipText: 'Name of the field.', - editable: false, - Filter: DefaultColumnFilter, - isReadOnly: true, - filter: 'includes', - Cell: ({ value, cell }: any) => { - const [edit, setEdit] = useState(false); - const [text, setText] = useState(''); - return renderColumnCell({ - cell, - value, - persistState, - setFlattenedData, - theme, - text, - setText, - edit, - setEdit, - disabled: true - }); - } - }, - { - Header: 'Data type', - accessor: 'data_type', - tipText: 'Data type of the field', - errorBg: true, - editable: false, - isReadOnly: true, - Filter: DefaultColumnFilter, - filter: 'includes', - Cell: ({ value, cell, row }: any) => { - const dataType = _.get(row, 'original._transformedFieldDataType') || _.get(row, 'original.data_type'); - return {dataType}; - } - } - ], - [] - ); - - return ( - - {loading ? renderSkeleton({ config: { type: "table", width: "100%" } }) : - {}} - // eslint-disable-next-line - skipPageReset={()=>{}} - limitHeight - tHeadHeight={52} - showSearchBar={false} - styles={{ '&.MuiTableCell-root': { border: '1px solid #D9D9D9' } }} - /> - } - - ); -}; - -export default IngestionSpec; diff --git a/web-console-v2/src/pages/datasetV1/utils/renderCells.tsx b/web-console-v2/src/pages/datasetV1/utils/renderCells.tsx deleted file mode 100644 index 4663ab7e..00000000 --- a/web-console-v2/src/pages/datasetV1/utils/renderCells.tsx +++ /dev/null @@ -1,468 +0,0 @@ -/* eslint-disable */ -import React from "react"; -import { - Box, Typography, Button, Dialog, DialogTitle, Select, DialogContent, TextareaAutosize, FormControl, MenuItem, Popover, FormControlLabel, Stack, IconButton, Tooltip -} from "@mui/material"; -import RequiredSwitch from "components/RequiredSwitch"; -import { CloseCircleOutlined, PlusOutlined, CheckOutlined, DeleteOutlined, InfoCircleOutlined, } from '@ant-design/icons'; -import * as _ from "lodash"; -import HtmlTooltip from "components/HtmlTooltip"; -import { VerticalOverflowText } from "components/Styled/Typography"; -import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; -import ChevronRightIcon from '@mui/icons-material/ChevronRight'; -import interactIds from 'data/telemetry/interact.json'; - -const renderColumnCell = ({ - cell, setFlattenedData, persistState, value, - theme, edit, setEdit, text, setText, disabled = false, -}: any) => { - const row = cell?.row?.original || {}; - const mainRow = cell?.row || {}; - const collapseIcon = mainRow.isExpanded ? : ; - const editDescription = () => { - updateState(); - setEdit((prevState: any) => !prevState); - } - - const handleClose = () => { - setEdit((prevState: any) => !prevState); - } - - const handleChange = (e: React.ChangeEvent) => { - setText(e.target.value); - } - - const updateState = () => { - setFlattenedData((preState: Array>) => { - const updatedValues = { ...row }; - const values = _.map(preState, state => { - if (_.get(state, 'column') === _.get(updatedValues, 'originalColumn')) - return { ...state, ...updatedValues, isModified: true, description: text, column: _.get(updatedValues, 'originalColumn') }; - else return state; - }); - persistState(values); - return values; - }); - } - - return ( - 0 ? mainRow.depth * 3 : 0}> - - - - {mainRow?.canExpand && mainRow?.depth > 0 && ( - - {collapseIcon} - - )} - - {value} - - - - {!row.description && !disabled && - - } - - {row.description && - - - {row.description} - - - } - - - - - {value} - - - - - - - - - - - - - - - - - ); -} - -const renderDataTypeCell = ({ - cell, value, pageData, anchorEl, setAnchorEl, - updateDataType, persistState, setFlattenedData, - resetSuggestionResolve, validDatatypes, disabled, dataMappings -}: any) => { - const row = cell?.row?.original || {}; - const hasConflicts = _.get(row, 'suggestions.length'); - const isResolved = _.get(row, 'resolved') || false; - const open = Boolean(anchorEl); - const handleSuggestions = (e: React.MouseEvent | React.MouseEvent) => { - setAnchorEl(e.currentTarget); - } - - const handleClose = () => { - setAnchorEl(null); - } - - const renderSuggestions = () => { - return row?.oneof?.map((suggestion: any) => { - if (suggestion.type !== value) return ( - - ); - else return null; - }) - } - if ((disabled || row?.disableActions) && !row?.isModified) return ( - {value} - ); - - if (row?.isModified && row?.isNewlyAdded && row?.arrival_format === "object") return ( - {value} - ); - - return ( - - {row?.oneof && !isResolved && !row?.arrivalOneOf && - - } - {row?.oneof && isResolved && !row?.arrivalOneOf && - - } - < FormControl variant="standard" sx={{ mx: 1, minWidth: 100 }}> - - - - - {isResolved && ( - <> - - Resolved - - Data type of field {row?.column} is resolved to "{value}" - - - - - - - )} - {!isResolved && ( - <> - - Must-Fix - - The field {row?.column} has multiple data type values available - - - {renderSuggestions()} - {row?.data_type && - - - - } - - )} - - - - ); -} - -const renderRequiredCell = ({ - cell, value, setFlattenedData, persistState, disabled -}: any) => { - const row = cell?.row?.original || {}; - const handleChange = (e: React.ChangeEvent) => { - setFlattenedData((preState: Array>) => { - const updatedValues = { ...row }; - const values = _.map(preState, state => { - if (_.get(state, 'column') === _.get(updatedValues, 'originalColumn')) - return { ...state, ...updatedValues, isModified: true, required: e.target.checked, column: _.get(updatedValues, 'originalColumn') }; - else return state - }); - persistState(values); - return values; - }); - } - switch (value) { - default: - if (row?.disableActions) return null; - return - - } - label={''} - disabled={disabled} - /> - - ; - } -} - -const renderActionsCell = ({ cell, setSelection, setOpenAlertDialog, theme, generateInteractTelemetry }: any) => { - const row = cell?.row?.original || {}; - - const handleDeleteColumn = () => { - generateInteractTelemetry({ edata: { id: interactIds.delete_schema } }) - setSelection(row); - setOpenAlertDialog(true); - } - - if (row?.disableActions) return null; - return ( - - - - - - ); -} - - -const renderArrivalFormatCell = ({ - cell, value, pageData, anchorEl, setAnchorEl, - updateFormatType, persistState, setFlattenedData, validFormatTypes, dataMappings, disabled, resetSuggestionResolve -}: any) => { - const row = cell?.row?.original || {}; - const hasConflicts = _.get(row, 'suggestions.length'); - const isResolved = _.get(row, 'resolved') || false; - const open = Boolean(anchorEl); - - const handleSuggestions = (e: React.MouseEvent | React.MouseEvent) => { - setAnchorEl(e.currentTarget); - } - - const handleClose = () => { - setAnchorEl(null); - } - - const renderSuggestions = () => { - return row?.arrivalOneOf?.map((suggestion: any) => { - if (suggestion.type !== value) return ( - - ); - else return null; - }) - } - - if ((disabled || row?.disableActions) && !row?.isModified) return ( - {value} - ); - - if (row?.isModified && row?.isNewlyAdded && row?.arrival_format === "object") return ( - {value} - ); - - return ( - - {row?.arrivalOneOf && !isResolved && - - } - {row?.arrivalOneOf && isResolved && - - } - < FormControl variant="standard" sx={{ mx: 1, minWidth: 120 }}> - - - - - {isResolved && ( - <> - - Resolved - - Arrival Format of field {row?.column} is resolved to "{value}" - - - - - - - )} - {!isResolved && ( - <> - - Must-Fix - - The field {row?.column} has multiple arrival format values available - - - {renderSuggestions()} - {row?.arrival_format && - - - - } - - )} - - - - ); -} - -export { renderColumnCell, renderDataTypeCell, renderRequiredCell, renderActionsCell, renderArrivalFormatCell }; diff --git a/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/index.tsx b/web-console-v2/src/pages/datasetView/index.tsx similarity index 97% rename from web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/index.tsx rename to web-console-v2/src/pages/datasetView/index.tsx index aaf80a35..2d1a40a0 100644 --- a/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/index.tsx +++ b/web-console-v2/src/pages/datasetView/index.tsx @@ -4,7 +4,7 @@ import { downloadJSONSchemaV1 } from 'services/json-schema'; import { downloadJsonFileV1 } from 'utils/downloadUtils'; import { DownloadOutlined } from '@ant-design/icons'; import { Button, Grid, Stack, Typography, Box } from '@mui/material'; -import AllConfigurations from "pages/StepsPages/PreviewAndSave/AllConfigurations"; +import AllConfigurations from "pages/DatasetCreation/PreviewAndSave/AllConfigurations"; import KeyboardBackspaceIcon from '@mui/icons-material/KeyboardBackspace'; import { useNavigate } from 'react-router-dom'; diff --git a/web-console-v2/src/pages/notificationChannels/ViewChannel.tsx b/web-console-v2/src/pages/notificationChannels/ViewChannel.tsx index 7cd40eb5..6b12ac53 100644 --- a/web-console-v2/src/pages/notificationChannels/ViewChannel.tsx +++ b/web-console-v2/src/pages/notificationChannels/ViewChannel.tsx @@ -16,7 +16,7 @@ import { DeleteOutlined, EditOutlined, MessageOutlined, PlayCircleOutlined } fro import SendTestMessage from "./components/SendTestMessage"; import { getKeyAlias } from "services/keysAlias"; import { dialogBoxContext } from "pages/alertManager/services/utils"; -import AlertDialog from "components/AlertDialog"; +import AlertDialog from "components/AlertDialog/AlertDialog"; import { renderSkeleton } from "services/skeleton"; import { useAlert } from "contexts/AlertContextProvider"; import { styled } from '@mui/material/styles'; diff --git a/web-console-v2/src/pages/notificationChannels/components/NotificationChannelsTable.tsx b/web-console-v2/src/pages/notificationChannels/components/NotificationChannelsTable.tsx index 46e43fa1..2b5409a8 100644 --- a/web-console-v2/src/pages/notificationChannels/components/NotificationChannelsTable.tsx +++ b/web-console-v2/src/pages/notificationChannels/components/NotificationChannelsTable.tsx @@ -14,7 +14,7 @@ import { Chip } from '@mui/material'; import { publishChannel, retireChannel } from 'services/notificationChannels'; import NotificationChannelsHeader from './NotificationChannelsHeader'; import { alertStatusColor, dialogBoxContext } from 'pages/alertManager/services/utils'; -import AlertDialog from 'components/AlertDialog'; +import AlertDialog from 'components/AlertDialog/AlertDialog'; import { renderSkeleton } from 'services/skeleton'; import { useAlert } from 'contexts/AlertContextProvider'; diff --git a/web-console-v2/src/router/index.tsx b/web-console-v2/src/router/index.tsx index 842ad9e3..c380d051 100644 --- a/web-console-v2/src/router/index.tsx +++ b/web-console-v2/src/router/index.tsx @@ -3,22 +3,20 @@ import { Routes, Route, Navigate } from 'react-router-dom'; // Import pages for different routes -import NewDatasetPage from 'pages/NewDataset/NewDataset'; -import IngestionPage from 'pages/StepsPages/Ingestion/Ingestion'; -import ProcessingPage from 'pages/StepsPages/Processing/Processing'; -import StoragePage from 'pages/StepsPages/Storage/Storage'; -import PreviewPage from 'pages/StepsPages/Preview'; -import SchemaDetailsPage from 'pages/StepsPages/Ingestion/SchemaDetails/SchemaDetails'; -import ConnectorConfigurationPage from 'pages/ConnectorConfiguration/ConnectorConfiguration'; -import SelectConnectorPage from 'pages/SelectConnector/SelectConnector'; +import NewDatasetPage from 'pages/DatasetCreation/NewDataset/NewDataset'; +import IngestionPage from 'pages/DatasetCreation/Ingestion/Ingestion'; +import ProcessingPage from 'pages/DatasetCreation/Processing/Processing'; +import StoragePage from 'pages/DatasetCreation/Storage/Storage'; +import PreviewPage from 'pages/DatasetCreation/Preview'; +import SchemaDetailsPage from 'pages/DatasetCreation/Ingestion/SchemaDetails/SchemaDetails'; +import ConnectorConfigurationPage from 'pages/DatasetCreation/ConnectorConfiguration/ConnectorConfiguration'; +import SelectConnectorPage from 'pages/DatasetCreation/SelectConnector/SelectConnector'; import ManageConnectorsPage from 'pages/ConnectorManagement/Manage/Manage'; -import SettingsPage from 'pages/Settings/Settings'; import Dashboard from 'pages/Dashboard/Dashboard'; import IndividualMetricDashboards from 'pages/Dashboard/IndividualDashboardPage/IndividualDashboardPage'; -import DatasetMetrics from 'pages/dashboardV1/DatasetMetrics'; -import DatasetCreateEvents from 'pages/dashboardV1/createEvents'; -import ClusterHealth from 'pages/dashboardV1/datasets'; -import StepperPage from 'pages/StepsPages/StepperPage'; +import DatasetCreateEvents from 'pages/DatasetListV1/DatasetCreateEvents'; +import DatasetListV1 from 'pages/DatasetListV1/DatasetsList'; +import StepperPage from 'pages/DatasetCreation/StepperPage'; import AlertRules from 'pages/alertManager/views/AlertRules'; import SystemAlerts from 'pages/alertManager/views/SystemRules'; import AddAlert from 'pages/alertManager/views/AddRule'; @@ -29,6 +27,7 @@ import AddChannel from 'pages/notificationChannels/AddChannel'; import ViewChannel from 'pages/notificationChannels/ViewChannel'; import UpdateChannel from 'pages/notificationChannels/UpdateChannel'; import Loadable from 'pages/auth/components/Loadable'; +import { NotFound } from 'pages/NotFound/NotFound'; import RollupConfig from 'pages/Rollup/components'; import DatasetManagement from 'pages/DatasetManagement/DatasetManagement'; @@ -69,7 +68,6 @@ export const routeConfigurations: RouteConfig[] = [ { path: `/dashboard/storage`, label: "Storage", element: }, { path: `/connector-management`, label: "Connector Management", element: }, { path: `/connector-management/manage`, label: "Manage", element: }, - { path: `/settings`, label: "Settings", element: }, { path: `/alertRules`, label: "Alert Rules", @@ -86,12 +84,14 @@ export const routeConfigurations: RouteConfig[] = [ { path: `/alertChannels/new`, label: "New", element: }, { path: `/alertChannels/edit/:id`, label: "Edit", element: }, { path: `/alertChannels/view/:id`, label: "View", element: }, - { path: `/datasets`, label: "Datasets", element: }, + { path: `/datasets`, label: "Datasets", element: }, { path: `/datasets/metrics/:datasetId`, label: "Metrics", element: }, { path: `/datasets/addEvents/:datasetId`, label: "Add Events", element: }, { path: `/datasets/view/:datasetId`, label: "View", element: }, { path: `/datasets/rollups/:datasetId`, element: }, - { path: `/datasets/management/:datasetId`, label: "Rollups", element: } + { path: `/datasets/management/:datasetId`, label: "Rollups", element: }, + { path: '*', element: } + ]; const AppRouter = () => ( diff --git a/web-console-v2/src/services/DatasetServices.tsx b/web-console-v2/src/services/DatasetServices.tsx index 0621fbbb..c213cc86 100644 --- a/web-console-v2/src/services/DatasetServices.tsx +++ b/web-console-v2/src/services/DatasetServices.tsx @@ -2,18 +2,6 @@ import { v4 as uuidv4 } from 'uuid'; import _ from 'lodash'; import axios from 'axios'; import { Dataset, CopyDatasetRequest, FilterCriteria } from '../types/dataset'; -import { - DATASETS_LIST_ENDPOINT, - DATASET_READ_ENDPOINT, - DATASET_HEALTH_ENDPOINT, - DATASET_STATUS_TRANSITION_ENDPOINT, - DATASET_UPDATE_ENDPOINT, - DATASET_EXPORT_ENDPOINT, - DATASET_COPY_ENDPOINT, - DATASET_READ, -} from './../constants/endpoints'; -import { response } from 'express'; -import { useFetchDatasetsById } from './dataset'; enum datasetStatus { Live = 'Live', @@ -29,7 +17,7 @@ const axiosInstance = axios.create({ export const fetchDatasets = (): Promise<{ datasets: Dataset[] }> => { const msgId = uuidv4(); return axiosInstance - .post(DATASETS_LIST_ENDPOINT, { + .post('/datasets/list', { id: 'api.datasets.list', ver: 'v2', ts: new Date().toISOString(), @@ -52,7 +40,7 @@ export const fetchDatasets = (): Promise<{ datasets: Dataset[] }> => { }; export const fetchVersionKey = (datasetId: string): Promise => { return axiosInstance - .get(DATASET_READ_ENDPOINT(datasetId)) + .get(`/datasets/read/${datasetId}?fields=version_key&mode=edit`) .then((response) => { const versionKey = response.data.result.version_key; return versionKey; @@ -62,7 +50,7 @@ export const fetchVersionKey = (datasetId: string): Promise => { export const getDatasetHealth = (datasetId: string): Promise => { const msgId = uuidv4(); return axiosInstance - .post(DATASET_HEALTH_ENDPOINT, { + .post('/datasets/health', { id: 'api.datasets.health', ver: '2', ts: new Date().toISOString(), @@ -93,7 +81,7 @@ export const combineDatasetWithHealth = async (): Promise<{ const datasetRead = await Promise.all(datasets.map((dataset: Dataset) => { const defaultFields = ["dataset_id", "name", "type", "status", "tags", "version", "api_version", "dataset_config", "created_date", "updated_date",'data_schema','validation_config','dedup_config','denorm_config']; const params = (dataset.status === "Draft") ? `fields=${[...defaultFields, "connectors_config"]}&mode=edit` : `fields=${defaultFields}`; - return axiosInstance.get(DATASET_READ(dataset.dataset_id, params)).then((response) => {return (response.data.result)}); + return axiosInstance.get(`/datasets/read/${dataset?.dataset_id}?${params}`).then((response) => {return (response.data.result)}); })); console.log('datasetRead',datasetRead); const datasetHealthPromises = datasetRead.map((dataset: Dataset) => { @@ -140,7 +128,7 @@ export const datasetTransition = ( ): Promise => { const msgId = uuidv4(); return axiosInstance - .post(DATASET_STATUS_TRANSITION_ENDPOINT, { + .post('/datasets/status-transition', { id: 'api.datasets.status-transition', ver: 'v2', ts: new Date().toISOString(), @@ -203,7 +191,7 @@ export const editTags = async ( }; const response = await axiosInstance.patch( - DATASET_UPDATE_ENDPOINT, + '/datasets/update', requestBody, ); return response.data; @@ -215,7 +203,7 @@ export const editTags = async ( export const exportDataset = async (dataset: Dataset) => { try { const response = await axiosInstance.get( - DATASET_EXPORT_ENDPOINT(dataset.dataset_id, dataset.status), + `/datasets/export/${dataset?.dataset_id}?status=${dataset?.status}`, { responseType: 'blob', }, @@ -263,7 +251,7 @@ export const copyDataset = async ( try { const response = await axiosInstance.post( - DATASET_COPY_ENDPOINT, + '/datasets/copy', requestBody, ); if (response.data.responseCode !== 'OK') { diff --git a/web-console-v2/src/services/alerts.ts b/web-console-v2/src/services/alerts.ts index 5b68e29a..c7360b4c 100644 --- a/web-console-v2/src/services/alerts.ts +++ b/web-console-v2/src/services/alerts.ts @@ -1,36 +1,8 @@ import _ from "lodash"; import { http } from "./http"; -//For local -const ENDPOINTS = { - GRAFANA_RULES: "/alertmanager/api/prometheus/grafana/api/v1/rules", - SEARCH_ALERTS: "/config/alerts/v1/search", - GET_ALERT: "/config/alerts/v1/get", - UPDATE_ALERT: "/config/alerts/v1/update", - RETIRE_ALERT: "/config/alerts/v1/delete", - PUBLISH_ALERT: "/config/alerts/v1/publish", - ADD_CUSTOM_ALERTS: "/config/alerts/v1/create", - LIST_METRICS_ALIAS: "/config/alerts/v1/metric/alias/search", - ADD_SILENCE: "/config/alerts/v1/silence/create", - DELETE_SILENCE: "/config/alerts/v1/silence/delete" -}; - -// For dev -// const ENDPOINTS = { -// GRAFANA_RULES: "/console/alertmanager/api/prometheus/grafana/api/v1/rules", -// SEARCH_ALERTS: "/console/config/alerts/v1/search", -// GET_ALERT: "/console/config/alerts/v1/get", -// UPDATE_ALERT: "/console/config/alerts/v1/update", -// RETIRE_ALERT: "/console/config/alerts/v1/retire", -// PUBLISH_ALERT: "/console/config/alerts/v1/publish", -// ADD_CUSTOM_ALERTS: "/console/config/alerts/v1/create", -// LIST_METRICS_ALIAS: "/console/config/alerts/v1/metric/alias/search", -// ADD_SILENCE: "/console/config/alerts/v1/silence/create", -// DELETE_SILENCE: "/console/config/alerts/v1/silence/delete" -// }; - const fetchGrafanaRules = ({ rules = [] }) => { - return http.get(`${ENDPOINTS.GRAFANA_RULES}`).then((response) => _.get(response, 'data.data.groups')); + return http.get("/alertmanager/api/prometheus/grafana/api/v1/rules").then((response) => _.get(response, 'data.data.groups')); }; export const fetchFiringAlerts = async ({ groups = [] }) => { @@ -63,39 +35,39 @@ export const transformAlertDescription = (payload: Record) => { } export const searchAlert = ({ config }: any) => { - return http.post(`${ENDPOINTS.SEARCH_ALERTS}`, config).then((response) => _.get(response, 'data.result')); + return http.post("/config/alerts/v1/search", config).then((response) => _.get(response, 'data.result')); }; export const addAlert = (payload: any) => { - return http.post(`${ENDPOINTS.ADD_CUSTOM_ALERTS}`, payload).then((response) => _.get(response, 'data.result')); + return http.post(`/config/alerts/v1/create`, payload).then((response) => _.get(response, 'data.result')); }; export const deleteAlert = ({ id }: any) => { - return http.delete(`${ENDPOINTS.RETIRE_ALERT}/${id}`).then((response) => _.get(response, 'data.result')); + return http.delete(`/config/alerts/v1/delete/${id}`).then((response) => _.get(response, 'data.result')); }; export const editAlert = ({ id, data }: any) => { - return http.patch(`${ENDPOINTS.UPDATE_ALERT}/${id}`, data).then((response) => _.get(response, 'data.result')); + return http.patch(`/config/alerts/v1/update/${id}`, data).then((response) => _.get(response, 'data.result')); } export const getAlertDetail = ({ id }: any) => { - return http.get(`${ENDPOINTS.GET_ALERT}/${id}`).then((response: any) => _.get(response, 'data.result.alerts')); + return http.get(`/config/alerts/v1/get/${id}`).then((response: any) => _.get(response, 'data.result.alerts')); }; export const publishAlert = ({ id }: any) => { - return http.get(`${ENDPOINTS.PUBLISH_ALERT}/${id}`).then((response: any) => _.get(response, "data.result")); + return http.get(`/config/alerts/v1/publish/${id}`).then((response: any) => _.get(response, "data.result")); }; export const getMetricAlias = ({ config }: any) => { - return http.post(`${ENDPOINTS.LIST_METRICS_ALIAS}`, config).then((response) => _.get(response, 'data.result')); + return http.post(`/config/alerts/v1/metric/alias/search`, config).then((response) => _.get(response, 'data.result')); } export const addSilence = (payload: any) => { - return http.post(`${ENDPOINTS.ADD_SILENCE}`, payload).then((response) => _.get(response, 'data.result')); + return http.post(`/config/alerts/v1/silence/create`, payload).then((response) => _.get(response, 'data.result')); } export const deleteSilence = (silenceId: string) => { - return http.delete(`${ENDPOINTS.DELETE_SILENCE}/${silenceId}`).then((response) => _.get(response, 'data.result')); + return http.delete(`/config/alerts/v1/silence/delete/${silenceId}`).then((response) => _.get(response, 'data.result')); } \ No newline at end of file diff --git a/web-console-v2/src/services/chartMetrics.ts b/web-console-v2/src/services/chartMetrics.ts index 6b4c151f..f1400ef0 100644 --- a/web-console-v2/src/services/chartMetrics.ts +++ b/web-console-v2/src/services/chartMetrics.ts @@ -1,4 +1,4 @@ -import endpoints from '../constants/Enpoints'; +import endpoints from '../constants/Endpoints'; import { IChartFetchRequest } from '../types/metadata'; import { http } from './http'; diff --git a/web-console-v2/src/services/configData.ts b/web-console-v2/src/services/configData.ts index dc1bdf84..3f34a455 100644 --- a/web-console-v2/src/services/configData.ts +++ b/web-console-v2/src/services/configData.ts @@ -1,37 +1,32 @@ import _ from 'lodash'; import { http } from './http'; +import { storeLocalStorageItem, fetchLocalStorageItem } from 'utils/localStorage'; export const fetchSystemSettings = async () => { try { const { data } = await http.get(`/api/config/data`); if (data) { - sessionStorage.setItem("systemSettings", JSON.stringify(data)); + storeLocalStorageItem("systemSettings", data); } } catch (error) { console.log(error); } } -export const getConfigValueV1 = (variable: string) => { - const config: string | any = sessionStorage.getItem('systemSettings'); - return _.get(JSON.parse(config), variable); -}; - -export const getConfigValue = (variable: string) => { - const config: string | any = sessionStorage.getItem('configDetails'); - return _.get(JSON.parse(config), variable); +export const getSystemSetting = (variable: string) => { + const config: string | any = fetchLocalStorageItem('systemSettings'); + return _.get(config, variable); }; export const setVersionKey = (value: string) => { - const config = JSON.parse(sessionStorage.getItem('configDetails') || '{}'); - - _.set(config, 'version_key', value); - - return sessionStorage.setItem('configDetails', JSON.stringify(config)); + if(!value) { + return; + } + return storeLocalStorageItem('version_key', value); }; export const getBaseURL = () => { - const baseUrl = getConfigValueV1('BASE_URL') || process.env.REACT_APP_BASE_URL || '/console'; + const baseUrl = getSystemSetting('BASE_URL') || process.env.REACT_APP_BASE_URL || '/console'; return baseUrl; }; diff --git a/web-console-v2/src/services/connector-utils.tsx b/web-console-v2/src/services/connectorUtils.tsx similarity index 100% rename from web-console-v2/src/services/connector-utils.tsx rename to web-console-v2/src/services/connectorUtils.tsx diff --git a/web-console-v2/src/services/dataset.ts b/web-console-v2/src/services/dataset.ts index bda73fce..9415fb25 100644 --- a/web-console-v2/src/services/dataset.ts +++ b/web-console-v2/src/services/dataset.ts @@ -1,8 +1,8 @@ -import { useMutation, useQuery, UseQueryOptions } from '@tanstack/react-query'; +import { skipToken, useMutation, useQuery, UseQueryOptions } from '@tanstack/react-query'; import { http } from './http'; import { AxiosResponse } from 'axios'; import _ from 'lodash'; -import { fetchSessionStorageItem, storeSessionStorageItem } from 'utils/sessionStorage'; +import { fetchLocalStorageItem, storeLocalStorageItem } from 'utils/localStorage'; import { generateRequestBody, setDatasetId, setVersionKey, transformResponse } from './utils'; import { queryClient } from 'queryClient'; import { DatasetStatus } from 'types/datasets'; @@ -24,8 +24,6 @@ const ENDPOINTS = { export const endpoints = ENDPOINTS -const configDetailKey = 'configDetails'; - export const useFetchDatasetsById = ({ datasetId, queryParams @@ -114,12 +112,8 @@ export const useCreateDataset = () => return http.post(ENDPOINTS.CREATE_DATASET, request, config).then(transformResponse); }, onSuccess: (response, variables) => { - const configDetail = { - version_key: _.get(response, 'version_key'), - dataset_id: _.get(response, 'id') - }; - - storeSessionStorageItem(configDetailKey, configDetail); + setVersionKey(_.get(response, 'version_key')); + setDatasetId(_.get(response, 'id')); } }); @@ -144,11 +138,11 @@ export const useUpdateDataset = () => if(data?.data_schema) { data['data_schema'] = omitSuggestions(data?.data_schema) } - const configDetail = fetchSessionStorageItem('configDetails') || {}; + const version_key = fetchLocalStorageItem('version_key') || {}; const request = generateRequestBody({ request: { ...data, - ..._.pick(configDetail, ['version_key']) + version_key }, apiId: 'api.datasets.update' }); @@ -186,9 +180,8 @@ export const useFetchDatasetDiff = ({ datasetId }: { datasetId: string }) => { export const useFetchDatasetExists = ({ datasetId }: { datasetId: string }) => { return useQuery({ - queryKey: ['fetchDatasetExists', 'datasetId'], - queryFn: () => http.get(`${ENDPOINTS.DATASET_EXISTS}/${datasetId}`).then((res) => res.data), - enabled: !!datasetId + queryKey: ['fetchDatasetExists'], + queryFn: () => datasetId ? http.get(`${ENDPOINTS.DATASET_EXISTS}/${datasetId}`).then((res) => res.data): skipToken, }); }; @@ -239,11 +232,6 @@ const omitSuggestions = (schema: any): any => { return schema; } -export const getConfigValue = (variable: string) => { - const config: string | any = sessionStorage.getItem('systemSettings'); - return _.get(JSON.parse(config), variable); -}; - export const datasetRead = ({ datasetId, config = {} }: any) => { return http.get(`${ENDPOINTS.DATASETS_READ}/${datasetId}`, { ...config diff --git a/web-console-v2/src/services/datasetState.ts b/web-console-v2/src/services/datasetState.ts index ba1feb61..e93033a1 100644 --- a/web-console-v2/src/services/datasetState.ts +++ b/web-console-v2/src/services/datasetState.ts @@ -1,6 +1,30 @@ import { DatasetType } from "types/datasets"; import { generateJsonSchema } from "./dataset"; import _ from "lodash"; +import moment from "moment"; +import { v4 as uuid } from 'uuid'; +import { http } from "./http"; +import apiEndpoints from "constants/Endpoints"; +type Payload = Record; + +export const generateJsonSchema = (payload: Payload) => { + const transitionRequest = generateRequestBody({ request: payload?.data, apiId: "api.datasets.dataschema" }) + return http.post(`${apiEndpoints.generateJsonSchema}`, transitionRequest) + .then(transform); +} + +export const generateRequestBody = (configs: Record) => { + const { apiId, request } = configs; + return { + "id": apiId, + "ver": "v2", + "ts": moment().format(), + "params": { + "msgid": uuid() + }, + "request": request + } +} const getDedupeState = (dataset: Record, createAction?: boolean) => { const dedupeConfig = _.get(dataset, 'dedup_config') || {}; diff --git a/web-console-v2/src/services/datasetV1.ts b/web-console-v2/src/services/datasetV1.ts index 0b8de303..c4042d47 100644 --- a/web-console-v2/src/services/datasetV1.ts +++ b/web-console-v2/src/services/datasetV1.ts @@ -1,14 +1,14 @@ /*eslint-disable*/ import * as _ from 'lodash'; import { http } from 'services/http'; -import { flattenSchema, updateJSONSchema } from './json-schema'; -import apiEndpoints from 'data/apiEndpoints'; -import { DatasetStatus } from 'types/datasets'; +import { flattenSchema, setAdditionalProperties, updateDenormDerived, updateJSONSchema } from './json-schema'; +import apiEndpoints from 'constants/Endpoints'; +import { DatasetStatus, DatasetType } from 'types/datasets'; +import { aggregationFunctions, allowedSegmentGranurality } from './commonUtils'; import { generateRequestBody } from './utils'; -import { generateDatasetState } from './datasetState'; +import { fetchDataset, generateDatasetState } from './datasetState'; import moment from 'moment'; import { v4 as uuid } from 'uuid'; -import { fetchDataset } from './dataset'; export const DEFAULT_TIMESTAMP = { indexValue: "obsrv_meta.syncts", @@ -219,6 +219,93 @@ export const generateDimensionExclusions = (list: any) => { return dimensionExclusions } +export const generateMetrics = (list: any[]) => { + const validTypes = aggregationFunctions; + const filteredData = list.filter(item => item?.aggregateFunctions); + const newMetrics: any[] = [] + filteredData.forEach(item => { + // Check if the object has 'aggregateFunctions' key and it's an array of strings + if (item.aggregateFunctions && Array.isArray(item.aggregateFunctions)) { + item.aggregateFunctions.forEach((func: any) => { + if (typeof func === 'string' && validTypes.includes(func.trim())) { + newMetrics.push({ + type: func.trim(), + path: item.column, + outputField: `${item.column.replace(/\./g, '_')}_${func.trim()}`, + }); + } + }); + } else { + // If 'aggregateFunctions' is not present or not an array, create a default payload + newMetrics.push({ + type: item.type, + path: item.column, + outputField: `${item.column.replace(/\./g, '_')}_${item.type}`, + }); + } + }); + return newMetrics +}; + +export const generateRollupIngestionSpec = async (list: any, schema: any, datasetId: any, maskedDataSourceName: any, granularity: any, config = {}, filterRollup = {}) => { + const jsonSchema = _.get(schema, 'jsonSchema'); + const timestampCol = _.get(schema, 'timestamp.indexCol') || DEFAULT_TIMESTAMP.indexValue; + let updatedColumns = _.get(schema, 'columns.state.schema', []); + const transformedFields = _.get(schema, 'transformation.selection', []); + let newField: any = _.get(schema, 'additionalFields.selection') || []; + updatedColumns = _.map(updatedColumns, (item) => { + const transformedData = _.find(transformedFields, { column: item.column }); + if (transformedData) { + return { + ...item, + type: _.get(transformedData, '_transformedFieldSchemaType') || "string", + ...transformedData, + }; + } + return item; + }); + newField = formatNewFields(newField, null); + let ingestionPayload = { schema: [...flattenSchema(_.get(schema, 'jsonSchema.schema')), ...newField] }; + if (timestampCol === DEFAULT_TIMESTAMP.indexValue) + ingestionPayload = { schema: [...flattenSchema(_.get(schema, 'jsonSchema.schema')), ...defaultTsObject, ...newField] }; + + const updatedIngestionPayload = _.get(updateJSONSchema(jsonSchema, ingestionPayload), 'schema'); + + const payload = { + schema: updatedIngestionPayload, + config: { + "dataset": maskedDataSourceName || `${datasetId}_day`, + "indexCol": _.get(schema, "timestamp.indexCol"), + "granularitySpec": { + "rollup": true, + "segmentGranularity": allowedSegmentGranurality.includes(granularity) ? 'day' : granularity, + "queryGranularity": granularity, + }, + "tuningConfig": { + "maxRowPerSegment": 500000, + "taskCount": 1 + }, + "ioConfig": { + "topic": datasetId, + "taskDuration": "PT1H", + }, + "rollup": { + "dimensionExclusions": generateDimensionExclusions(list), + "metrics": generateMetrics(list) + } + } + }; + + const modifiedPayload = !_.isEmpty(filterRollup) ? + { + ...payload, + config: { ...payload.config, transformSpec: filterRollup } + } : payload + + return http.post(apiEndpoints.generateIngestionSpec, modifiedPayload, config); +} + + export const publishDataset = async (state: Record, storeState: any, master: any, masterDatasets: any) => { const dataset_id = _.get(state, 'pages.datasetConfiguration.state.config.dataset_id') const { status } = await getVersionKey(dataset_id) @@ -322,7 +409,6 @@ export const updateDatasetStatus = async (id: string, dataset_id: string, status export const createDraftversion = async ({ selection, navigateToPath, rollupRedirect, showAlert }: any) => { try { const datasetResponse = await editLiveDataset({ datasetId: selection }); - sessionStorage.setItem(`${selection}_activePage`, "0"); if (rollupRedirect) { const transitionRequest = generateRequestBody({ request: { dataset_id: datasetResponse?.data?.result?.dataset_id, status: "ReadyToPublish" }, apiId: "api.datasets.status-transition" }) await http.post(`${apiEndpoints.statusTransition}`, transitionRequest); @@ -381,4 +467,3 @@ export const setVersionKey = (config: Record) => { const resultantKeys = { ...versionKeyMap.version_keys, ...versionKeyList } _.set(versionKeyList, "version_keys", resultantKeys) } - diff --git a/web-console-v2/src/services/grafana.ts b/web-console-v2/src/services/grafana.ts index 0b8eaab5..0cc1a70c 100644 --- a/web-console-v2/src/services/grafana.ts +++ b/web-console-v2/src/services/grafana.ts @@ -1,7 +1,7 @@ -import { getConfigValue } from "./configData"; +import { getSystemSetting } from "./configData"; export const navigateToGrafana = (dashboardLink: string) => { - const graphanaUrl = getConfigValue("GRAFANA_URL") + const graphanaUrl = getSystemSetting("GRAFANA_URL") if (graphanaUrl) { const url = `${graphanaUrl}/${dashboardLink}` window.open(url); diff --git a/web-console-v2/src/services/http.ts b/web-console-v2/src/services/http.ts index 906f9fa0..5f35d714 100644 --- a/web-console-v2/src/services/http.ts +++ b/web-console-v2/src/services/http.ts @@ -1,5 +1,5 @@ import axios from 'axios'; -import { getBaseURL } from './configData'; +import { getBaseURL, getConfigValueV1 } from './configData'; axios.defaults.headers.common['Cache-Control'] = 'no-store'; axios.defaults.headers.common['Pragma'] = 'no-store'; @@ -10,8 +10,12 @@ const responseInterceptor = (response: any) => response; const checkForSessionExpiry = (config: any) => { const { navigate, status } = config; if (status === 401) { - // alert('Unauthorized access !!'); - navigate(`/login`); + if (getConfigValueV1("AUTHENTICATION_TYPE") !== 'basic') { + window.location.href = '/console/logout'; + } else { + // alert('Unauthorized access !!'); + navigate(`/login`); + } } } diff --git a/web-console-v2/src/services/systemV1.ts b/web-console-v2/src/services/systemV1.ts index 0105713c..bf19d7be 100644 --- a/web-console-v2/src/services/systemV1.ts +++ b/web-console-v2/src/services/systemV1.ts @@ -1,7 +1,7 @@ import * as _ from 'lodash'; import { http } from 'services/http'; import { v4 } from 'uuid'; -import apiEndpoints from 'data/apiEndpoints'; +import apiEndpoints from 'constants/Endpoints'; import { generateRequestBody } from './utils'; export const publishDataset = ({ data, config = {} }: any) => { diff --git a/web-console-v2/src/services/telemetry.ts b/web-console-v2/src/services/telemetry.ts index 3eba32f1..6dc36feb 100644 --- a/web-console-v2/src/services/telemetry.ts +++ b/web-console-v2/src/services/telemetry.ts @@ -1,6 +1,6 @@ import * as _ from 'lodash'; import { v4 } from 'uuid' -import { getConfigValueV1 } from './configData'; +import { getSystemSetting } from './configData'; const getOptions = () => { return { @@ -13,7 +13,7 @@ const getOptions = () => { type: 'User' }, context: { - env: getConfigValueV1("ENV") || "local", + env: getSystemSetting("ENV") || "local", sid: '42342', pdata: { id: 'dev.obsrv.console', diff --git a/web-console-v2/src/services/utils.ts b/web-console-v2/src/services/utils.ts index 2b615e63..ea03bdf1 100644 --- a/web-console-v2/src/services/utils.ts +++ b/web-console-v2/src/services/utils.ts @@ -2,7 +2,7 @@ import moment from 'moment'; import _ from 'lodash'; import { v4 as uuid } from 'uuid'; import { AxiosResponse } from 'axios'; -import { fetchSessionStorageItem, storeSessionStorageItem } from 'utils/sessionStorage'; +import { fetchLocalStorageItem, storeLocalStorageItem } from 'utils/localStorage'; import { DatasetType } from 'types/datasets'; export const charsRegEx = /[!@#$%^&*()+{}\\[\]:;<>,?~\\|]/; @@ -109,23 +109,17 @@ export const getDatasetType = (type: boolean) => { }; export const setVersionKey = (value: number) => { - const configDetailKey = 'configDetails'; - - const configDetail = fetchSessionStorageItem(configDetailKey) || {}; - - _.set(configDetail, 'version_key', String(value)); - - storeSessionStorageItem(configDetailKey, configDetail); + if(!value) { + return; + } + storeLocalStorageItem('version_key', String(value)); }; export const setDatasetId = (value: number) => { - const configDetailKey = 'configDetails'; - - const configDetail = fetchSessionStorageItem(configDetailKey) || {}; - - _.set(configDetail, 'dataset_id', String(value)); - - storeSessionStorageItem(configDetailKey, configDetail); + if(!value) { + return; + } + storeLocalStorageItem('dataset_id', String(value)); }; export const transformResponse = (response: AxiosResponse) => _.get(response, ['data', 'result']); @@ -208,4 +202,4 @@ export const generateDatesBetweenInterval = (start: any, end: any) => { } return datesBetween; -}; +}; \ No newline at end of file diff --git a/web-console-v2/src/utils/localStorage.ts b/web-console-v2/src/utils/localStorage.ts new file mode 100644 index 00000000..1a823a81 --- /dev/null +++ b/web-console-v2/src/utils/localStorage.ts @@ -0,0 +1,28 @@ +import _ from 'lodash'; + + +export const clearLocalStorage = (): void => localStorage.clear(); + +export const deleteLocalStorageItem = (key: string): void => localStorage.removeItem(key); + +export const fetchLocalStorageItem = (key: string): T | null => { + const storedItem = localStorage.getItem(key); + + if (!storedItem) return null; + + try { + return JSON.parse(storedItem) as T; + } catch { + return storedItem as unknown as T; + } +}; + +export const fetchLocalStorageValue = (key: string, path: string) => { + const item = fetchLocalStorageItem(key); + + return _.get(item, path, null); +}; + +export const storeLocalStorageItem = (key: string, value: T): void => + localStorage.setItem(key, JSON.stringify(value)); + diff --git a/web-console-v2/src/utils/sessionStorage.ts b/web-console-v2/src/utils/sessionStorage.ts deleted file mode 100644 index 42b1c8c2..00000000 --- a/web-console-v2/src/utils/sessionStorage.ts +++ /dev/null @@ -1,59 +0,0 @@ -import _ from 'lodash'; - -/** - * Clears all items from session storage. - */ -const clearSessionStorage = (): void => sessionStorage.clear(); - -/** - * Deletes a specific item from session storage by its key. - * @param key - The key of the item to remove. - */ -const deleteSessionStorageItem = (key: string): void => sessionStorage.removeItem(key); - -/** - * Retrieves an item from session storage, parsing it as JSON if possible. - * If parsing fails, returns the raw string. - * @param key - The key of the item to retrieve. - * @returns The parsed item or raw string, or null if the item doesn't exist. - */ -const fetchSessionStorageItem = (key: string): T | null => { - const storedItem = sessionStorage.getItem(key); - - if (!storedItem) return null; - - try { - return JSON.parse(storedItem) as T; - } catch { - // Return the raw string if JSON parsing fails - return storedItem as unknown as T; - } -}; - -/** - * Retrieves a specific value from a JSON-encoded item in session storage. - * Uses lodash to get the value from a specified path. - * @param key - The key of the item containing the JSON data. - * @param path - The path to the specific value within the JSON data. - */ -const fetchSessionStorageValue = (key: string, path: string) => { - const item = fetchSessionStorageItem(key); - - return _.get(item, path, null); -}; - -/** - * Stores a JSON-encoded item in session storage. - * @param key - The key under which to store the item. - * @param value - The value to store, which will be JSON-encoded. - */ -const storeSessionStorageItem = (key: string, value: T): void => - sessionStorage.setItem(key, JSON.stringify(value)); - -export { - clearSessionStorage, - deleteSessionStorageItem, - fetchSessionStorageItem, - fetchSessionStorageValue, - storeSessionStorageItem -};