From f7aee436bbaebf9429de6eddaf7d2e55e742f899 Mon Sep 17 00:00:00 2001 From: Rakshitha-D Date: Fri, 15 Nov 2024 23:13:22 +0530 Subject: [PATCH 01/23] #OBS-I346: added keycloak authentication --- package.json | 1 + src/app.ts | 26 ++++- src/main/helpers/oauth/index.ts | 31 ++++-- src/main/services/authProviderFactory.ts | 15 +++ src/main/services/basicAuthProvider.ts | 31 ++++++ src/main/services/keycloak.ts | 103 ++++++++++++++++++ src/main/services/keycloakAuthProvider.ts | 31 ++++++ src/main/services/passportAuthProvider.ts | 30 +++++ src/main/types/index.ts | 6 + src/shared/resources/appConfig.ts | 8 ++ .../src/components/Sidebar/Sidebar.tsx | 9 +- 11 files changed, 275 insertions(+), 16 deletions(-) create mode 100644 src/main/services/authProviderFactory.ts create mode 100644 src/main/services/basicAuthProvider.ts create mode 100644 src/main/services/keycloak.ts create mode 100644 src/main/services/keycloakAuthProvider.ts create mode 100644 src/main/services/passportAuthProvider.ts 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/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/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/basicAuthProvider.ts b/src/main/services/basicAuthProvider.ts new file mode 100644 index 00000000..48e746b1 --- /dev/null +++ b/src/main/services/basicAuthProvider.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/keycloak.ts b/src/main/services/keycloak.ts new file mode 100644 index 00000000..d8cab83b --- /dev/null +++ b/src/main/services/keycloak.ts @@ -0,0 +1,103 @@ +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); + console.log('usercreate',result); + 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/shared/resources/appConfig.ts b/src/shared/resources/appConfig.ts index 5472784e..8e8e1b45 100644 --- a/src/shared/resources/appConfig.ts +++ b/src/shared/resources/appConfig.ts @@ -61,4 +61,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/src/components/Sidebar/Sidebar.tsx b/web-console-v2/src/components/Sidebar/Sidebar.tsx index 04edbe97..b2db9aa8 100644 --- a/web-console-v2/src/components/Sidebar/Sidebar.tsx +++ b/web-console-v2/src/components/Sidebar/Sidebar.tsx @@ -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'); - }) + } }; From ffbfdee426d348c75e300d8508cd4f662a1bfbf6 Mon Sep 17 00:00:00 2001 From: Rakshitha-D Date: Mon, 18 Nov 2024 12:36:00 +0530 Subject: [PATCH 02/23] #OBS-I346: updated keycloak files --- src/main/controllers/user_create.ts | 25 ++++++++------- src/main/controllers/user_read.ts | 29 +++++++++++++++-- src/main/helpers/proxy.ts | 13 ++++++-- src/main/resources/routesConfig.ts | 7 ----- src/main/services/basic.ts | 17 ++++++++++ src/main/services/basicAuthProvider.ts | 31 ------------------- src/main/services/keycloak.ts | 3 -- .../utils/validationSchemas/userCreate.ts | 2 +- src/main/utils/validationSchemas/userList.ts | 2 +- .../utils/validationSchemas/userManageRole.ts | 2 +- 10 files changed, 71 insertions(+), 60 deletions(-) create mode 100644 src/main/services/basic.ts delete mode 100644 src/main/services/basicAuthProvider.ts 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/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/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/basicAuthProvider.ts b/src/main/services/basicAuthProvider.ts deleted file mode 100644 index 48e746b1..00000000 --- a/src/main/services/basicAuthProvider.ts +++ /dev/null @@ -1,31 +0,0 @@ -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/keycloak.ts b/src/main/services/keycloak.ts index d8cab83b..dc744ca4 100644 --- a/src/main/services/keycloak.ts +++ b/src/main/services/keycloak.ts @@ -7,8 +7,6 @@ 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(':'); @@ -78,7 +76,6 @@ export const userCreateWithKeycloak = async (access_token: any, userRequest: any const created_on = new Date().toISOString(); const userInfo = { id, user_name, email_address, created_on, roles }; const result = await userService.save(userInfo); - console.log('usercreate',result); return result; }; 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: { From 1cca4aade2624d328fb103a4d70427b8e6038bd1 Mon Sep 17 00:00:00 2001 From: Rakshitha-D Date: Mon, 18 Nov 2024 15:12:53 +0530 Subject: [PATCH 03/23] #OBS-I346: getting data using optional chaining --- src/main/services/keycloak.ts | 48 ++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/src/main/services/keycloak.ts b/src/main/services/keycloak.ts index dc744ca4..e7a5d84a 100644 --- a/src/main/services/keycloak.ts +++ b/src/main/services/keycloak.ts @@ -9,29 +9,32 @@ 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]; + 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; + + 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); + 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; + 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; } }; @@ -50,6 +53,7 @@ export const userCreate = async (access_token: any, userRequest: any) => { }, ], }; + return keycloakHTTPClient .post(`/admin/realms/${keycloakRealm}/users`, payload, { headers: { @@ -59,7 +63,7 @@ export const userCreate = async (access_token: any, userRequest: any) => { .then((response) => { const location = _.get(response, 'headers.location'); const userId = location ? _.last(location.split('/')) : null; - console.log('keyuser',userId); + console.log('keyuser', userId); if (!userId) { throw new Error('UserId not found'); } @@ -80,13 +84,15 @@ export const userCreateWithKeycloak = async (access_token: any, userRequest: any }; 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 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, + client_id: req?.kauth?.grant?.access_token?.clientId, refresh_token: refresh_token, }); + return keycloakHTTPClient .post(`admin/realms/${keycloakRealm}/users/${userId}/logout`, data, { headers: { From c6691a19a7248dbb464f84affb4d8e9214a9c90a Mon Sep 17 00:00:00 2001 From: Rakshitha-D Date: Mon, 18 Nov 2024 17:16:06 +0530 Subject: [PATCH 04/23] #OBS-I346: updated redirection for unauthorized user --- src/main/controllers/config.ts | 3 ++- web-console-v2/src/services/http.ts | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) 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/web-console-v2/src/services/http.ts b/web-console-v2/src/services/http.ts index 906f9fa0..402a1c1c 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") === 'keycloak') { + window.location.href = '/console/logout'; + } else { + // alert('Unauthorized access !!'); + navigate(`/login`); + } } } From 97a16b15aaa73b0569a9ae140c175122d34bb9fe Mon Sep 17 00:00:00 2001 From: Rakshitha-D Date: Mon, 18 Nov 2024 17:30:24 +0530 Subject: [PATCH 05/23] #OBS-I346: updated condition for authentication type --- web-console-v2/src/services/http.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-console-v2/src/services/http.ts b/web-console-v2/src/services/http.ts index 402a1c1c..5f35d714 100644 --- a/web-console-v2/src/services/http.ts +++ b/web-console-v2/src/services/http.ts @@ -10,7 +10,7 @@ const responseInterceptor = (response: any) => response; const checkForSessionExpiry = (config: any) => { const { navigate, status } = config; if (status === 401) { - if (getConfigValueV1("AUTHENTICATION_TYPE") === 'keycloak') { + if (getConfigValueV1("AUTHENTICATION_TYPE") !== 'basic') { window.location.href = '/console/logout'; } else { // alert('Unauthorized access !!'); From 7324e8e1ccdbdeeca2b80edc282a6085dd455db2 Mon Sep 17 00:00:00 2001 From: Harish Kumar Gangula Date: Wed, 20 Nov 2024 12:40:55 +0530 Subject: [PATCH 06/23] #I319: Removed unused code --- web-console-v2/src/components/AlertDialog.tsx | 39 ----- .../EditDatasetTags/EditDatasetTags.tsx | 163 ------------------ .../pages/Dashboard/Processing/Processing.tsx | 7 - .../src/pages/Settings/Settings.tsx | 7 - .../StepsPages/PreviewAndSave/Preview.tsx | 5 +- .../StepsPages/Processing/Processing.tsx | 9 +- .../src/pages/StepsPages/Storage/Storage.tsx | 1 - .../components/ViewRuleHeader.tsx | 2 +- .../dashboardV1/ReadyToPublishDatasets.tsx | 16 +- .../src/pages/dashboardV1/datasetsList.tsx | 2 +- .../pages/dashboardV1/draftDatasetsList.tsx | 4 +- .../notificationChannels/ViewChannel.tsx | 2 +- .../components/NotificationChannelsTable.tsx | 2 +- web-console-v2/src/router/index.tsx | 4 - web-console-v2/src/services/configData.ts | 15 +- web-console-v2/src/services/dataset.ts | 99 ++++++++--- web-console-v2/src/services/datasetV1.ts | 2 - web-console-v2/src/services/utils.ts | 18 +- web-console-v2/src/utils/localStorage.ts | 28 +++ web-console-v2/src/utils/sessionStorage.ts | 59 ------- 20 files changed, 141 insertions(+), 343 deletions(-) delete mode 100644 web-console-v2/src/components/AlertDialog.tsx delete mode 100644 web-console-v2/src/components/EditDatasetTags/EditDatasetTags.tsx delete mode 100644 web-console-v2/src/pages/Dashboard/Processing/Processing.tsx delete mode 100644 web-console-v2/src/pages/Settings/Settings.tsx create mode 100644 web-console-v2/src/utils/localStorage.ts delete mode 100644 web-console-v2/src/utils/sessionStorage.ts 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/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/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/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/PreviewAndSave/Preview.tsx b/web-console-v2/src/pages/StepsPages/PreviewAndSave/Preview.tsx index a1db66a9..177105eb 100644 --- a/web-console-v2/src/pages/StepsPages/PreviewAndSave/Preview.tsx +++ b/web-console-v2/src/pages/StepsPages/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/Processing/Processing.tsx b/web-console-v2/src/pages/StepsPages/Processing/Processing.tsx index bf819841..6a91d162 100644 --- a/web-console-v2/src/pages/StepsPages/Processing/Processing.tsx +++ b/web-console-v2/src/pages/StepsPages/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 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/Storage/Storage.tsx b/web-console-v2/src/pages/StepsPages/Storage/Storage.tsx index 37adb424..fb39dda9 100644 --- a/web-console-v2/src/pages/StepsPages/Storage/Storage.tsx +++ b/web-console-v2/src/pages/StepsPages/Storage/Storage.tsx @@ -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/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/dashboardV1/ReadyToPublishDatasets.tsx b/web-console-v2/src/pages/dashboardV1/ReadyToPublishDatasets.tsx index bf995bdc..95a71308 100644 --- a/web-console-v2/src/pages/dashboardV1/ReadyToPublishDatasets.tsx +++ b/web-console-v2/src/pages/dashboardV1/ReadyToPublishDatasets.tsx @@ -6,25 +6,20 @@ 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'; @@ -292,6 +287,7 @@ const ReadyToPublishDatasetsList = ({ setDatasetType, sourceConfigs }: any) => { const fileName = `${row?.name}_${row?.status}_${row?.version}`; if (row?.onlyTag) return null; const status = _.toLower(row?.status) + const isOlapEnabled = _.get(row,"dataset_config.indexing_config.olap_store_enabled"); const publishDataset: boolean = _.toLower(status) !== _.toLower(DatasetStatus.ReadyToPublish) || isLoading return publish(row)}> @@ -335,18 +331,18 @@ const ReadyToPublishDatasetsList = ({ setDatasetType, sourceConfigs }: any) => { - {/* navigateToPath(`/datasets/management/${row?.dataset_id}?status=${DatasetStatus.ReadyToPublish}`)}> + navigateToPath(`/datasets/management/${row?.dataset_id}?status=${DatasetStatus.ReadyToPublish}`)}> - */} + }, { path: `/connector-management`, label: "Connector Management", element: }, { path: `/connector-management/manage`, label: "Manage", element: }, - { path: `/settings`, label: "Settings", element: }, { path: `/alertRules`, label: "Alert Rules", diff --git a/web-console-v2/src/services/configData.ts b/web-console-v2/src/services/configData.ts index dc1bdf84..69cf6c4a 100644 --- a/web-console-v2/src/services/configData.ts +++ b/web-console-v2/src/services/configData.ts @@ -1,12 +1,13 @@ 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); @@ -14,21 +15,21 @@ export const fetchSystemSettings = async () => { } export const getConfigValueV1 = (variable: string) => { - const config: string | any = sessionStorage.getItem('systemSettings'); - return _.get(JSON.parse(config), variable); + const config: string | any = fetchLocalStorageItem('systemSettings'); + return _.get(config, variable); }; export const getConfigValue = (variable: string) => { - const config: string | any = sessionStorage.getItem('configDetails'); - return _.get(JSON.parse(config), variable); + const config: string | any = fetchLocalStorageItem('configDetails'); + return _.get(config, variable); }; export const setVersionKey = (value: string) => { - const config = JSON.parse(sessionStorage.getItem('configDetails') || '{}'); + const config = fetchLocalStorageItem('configDetails') || {}; _.set(config, 'version_key', value); - return sessionStorage.setItem('configDetails', JSON.stringify(config)); + return storeLocalStorageItem('configDetails', config); }; export const getBaseURL = () => { diff --git a/web-console-v2/src/services/dataset.ts b/web-console-v2/src/services/dataset.ts index d8bae29a..55deae38 100644 --- a/web-console-v2/src/services/dataset.ts +++ b/web-console-v2/src/services/dataset.ts @@ -1,25 +1,12 @@ -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'; - -// const ENDPOINTS = { -// DATASETS_READ: '/console/config/v2/datasets/read', -// CREATE_DATASET: '/console/config/v2/datasets/create', -// UPLOAD_FILES: '/console/config/v2/files/generate-url', -// GENERATE_JSON_SCHEMA: '/console/config/v2/datasets/dataschema', -// UPDATE_DATASCHEMA: '/console/config/v2/datasets/update', -// LIST_DATASET: '/console/config/v2/datasets/list', -// DATASETS_DIFF: '/console/api/dataset/diff', -// PUBLISH_DATASET: '/console/config/v2/datasets/status-transition', -// LIST_CONNECTORS: '/console/config/v2/connectors/list', -// READ_CONNECTORS: '/console/config/v2/connectors/read' -// }; - -//USE THESE ROUTES FOR LOCAL TESTING +import { DatasetStatus } from 'types/datasets'; +import { generateDatasetState } from './datasetState'; const ENDPOINTS = { DATASETS_READ: '/config/v2/datasets/read', @@ -132,7 +119,7 @@ export const useCreateDataset = () => dataset_id: _.get(response, 'id') }; - storeSessionStorageItem(configDetailKey, configDetail); + storeLocalStorageItem(configDetailKey, configDetail); } }); @@ -157,7 +144,7 @@ export const useUpdateDataset = () => if(data?.data_schema) { data['data_schema'] = omitSuggestions(data?.data_schema) } - const configDetail = fetchSessionStorageItem('configDetails') || {}; + const configDetail = fetchLocalStorageItem('configDetails') || {}; const request = generateRequestBody({ request: { ...data, @@ -199,9 +186,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, }); }; @@ -253,10 +239,75 @@ const omitSuggestions = (schema: any): any => { } export const getConfigValue = (variable: string) => { - const config: string | any = sessionStorage.getItem('systemSettings'); - return _.get(JSON.parse(config), variable); + const config: string | any = fetchLocalStorageItem('systemSettings'); + return _.get(config, variable); +}; + +export const datasetRead = ({ datasetId, config = {} }: any) => { + return http.get(`${ENDPOINTS.DATASETS_READ}/${datasetId}`, { + ...config + }) +} + +export const formatNewFields = (newFields: Record, dataMappings: any) => { + if (newFields.length > 0) { + const final = _.map(newFields, (item: any) => { + const columnKey = _.join(_.map(_.split(_.get(item, "column"), '.'), payload => `properties.${payload}`), '.') + return { + ...item, + "column": item.column, + "type": _.get(item, 'datatype') || "string", + "key": columnKey, + "ref": columnKey, + "isModified": true, + "required": false, + "data_type": _.get(item, 'datatype'), + ...(dataMappings && { "arrival_format": getArrivalFormat(_.get(item, '_transformedFieldSchemaType'), dataMappings) || _.get(item, 'arrival_format') }) + } + }); + return final; + } + else return []; +} + +const getArrivalFormat = (data_type: string | undefined, dataMappings: Record) => { + let result = null; + if (data_type) { + _.forEach(dataMappings, (value, key) => { + if (_.includes(_.get(value, 'arrival_format'), data_type)) { + result = key; + } + }); + } + return result; +} + +// eslint-disable-next-line @typescript-eslint/no-inferrable-types +export const getDatasetState = async (datasetId: string, status: string = DatasetStatus.Draft, createAction: boolean = false) => { + const dataset = await fetchDataset(datasetId, status); + return await generateDatasetState(dataset, createAction); +} + + +export const fieldsByStatus: { [key: string]: string } = { + Draft: 'name,type,id,dataset_id,version,validation_config,extraction_config,dedup_config,data_schema,denorm_config,router_config,dataset_config,tags,status,created_by,updated_by,created_date,updated_date,version_key,api_version,entry_topic,transformations_config,connectors_config,sample_data', + default: 'name,type,id,dataset_id,version,validation_config,extraction_config,dedup_config,data_schema,denorm_config,router_config,dataset_config,tags,status,created_by,updated_by,created_date,updated_date,api_version,entry_topic,sample_data' }; +export const fetchDataset = (datasetId: string, status: string) => { + const fields = fieldsByStatus[status] || fieldsByStatus.default; + const params = status === 'Draft' ? `mode=edit&fields=${fields}` : `fields=${fields}`; + const url = `${ENDPOINTS.DATASETS_READ}/${datasetId}?${params}`; + return http.get(url).then(transform); +}; + +export const transform = (response: any) => _.get(response, 'data.result') + +export const generateJsonSchema = (payload: any) => { + const transitionRequest = generateRequestBody({ request: payload?.data, apiId: "api.datasets.dataschema" }) + return http.post(`${ENDPOINTS.GENERATE_JSON_SCHEMA}`, transitionRequest) + .then(transform); +} export const isJsonSchema = (jsonObject: any) => { if (typeof jsonObject !== "object" || jsonObject === null) { return false; diff --git a/web-console-v2/src/services/datasetV1.ts b/web-console-v2/src/services/datasetV1.ts index ae246129..5a8cb3a1 100644 --- a/web-console-v2/src/services/datasetV1.ts +++ b/web-console-v2/src/services/datasetV1.ts @@ -9,7 +9,6 @@ import { generateRequestBody } from './utils'; import { fetchDataset, generateDatasetState } from './datasetState'; import moment from 'moment'; import { v4 as uuid } from 'uuid'; -import { useAlert } from 'contexts/AlertContextProvider'; export const DEFAULT_TIMESTAMP = { indexValue: "obsrv_meta.syncts", @@ -410,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); diff --git a/web-console-v2/src/services/utils.ts b/web-console-v2/src/services/utils.ts index 2b615e63..9aa7ac49 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,29 @@ export const getDatasetType = (type: boolean) => { }; export const setVersionKey = (value: number) => { + if(!value) { + return; + } const configDetailKey = 'configDetails'; - const configDetail = fetchSessionStorageItem(configDetailKey) || {}; + const configDetail = fetchLocalStorageItem(configDetailKey) || {}; _.set(configDetail, 'version_key', String(value)); - storeSessionStorageItem(configDetailKey, configDetail); + storeLocalStorageItem(configDetailKey, configDetail); }; export const setDatasetId = (value: number) => { + if(!value) { + return; + } const configDetailKey = 'configDetails'; - const configDetail = fetchSessionStorageItem(configDetailKey) || {}; + const configDetail = fetchLocalStorageItem(configDetailKey) || {}; _.set(configDetail, 'dataset_id', String(value)); - storeSessionStorageItem(configDetailKey, configDetail); + storeLocalStorageItem(configDetailKey, configDetail); }; export const transformResponse = (response: AxiosResponse) => _.get(response, ['data', 'result']); @@ -208,4 +214,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 -}; From f78a445625158b2b4c1475598de9740403113958 Mon Sep 17 00:00:00 2001 From: Harish Kumar Gangula Date: Wed, 20 Nov 2024 17:52:36 +0530 Subject: [PATCH 07/23] #I319: Deleted unused code --- .../CheckboxWithInfoIcon.module.css | 4 - .../CheckboxWithInfoIcon.tsx | 134 ------------------ .../{cardsV1/statistics => }/ReportCard.tsx | 0 .../statistics/AnalyticsDataCard.tsx | 42 ------ .../cardsComponent/statistics/AsyncLabel.tsx | 50 ------- .../cardsComponent/statistics/BigNumber.tsx | 53 ------- .../cardsComponent/statistics/ReportCard.tsx | 104 -------------- .../cardsV1/statistics/AnalyticsDataCard.tsx | 42 ------ .../cardsV1/statistics/AsyncLabel.tsx | 50 ------- .../cardsV1/statistics/BigNumber.tsx | 53 ------- web-console-v2/src/constants/Enpoints.ts | 6 - web-console-v2/src/constants/endpoints.ts | 16 +-- web-console-v2/src/data/Charts/header.ts | 2 +- web-console-v2/src/data/Charts/infra.ts | 2 +- web-console-v2/src/data/Charts/ingestion.ts | 2 +- web-console-v2/src/data/Charts/processing.ts | 2 +- web-console-v2/src/data/Charts/storage.ts | 2 +- .../ProcessingSection/DedupeEvent/Schema.ts | 60 -------- .../src/pages/dashboardV1/datasetsDetails.tsx | 3 +- .../src/services/DatasetServices.tsx | 28 ++-- web-console-v2/src/services/chartMetrics.ts | 2 +- 21 files changed, 21 insertions(+), 636 deletions(-) delete mode 100644 web-console-v2/src/components/CheckboxWithInfoIcon/CheckboxWithInfoIcon.module.css delete mode 100644 web-console-v2/src/components/CheckboxWithInfoIcon/CheckboxWithInfoIcon.tsx rename web-console-v2/src/components/{cardsV1/statistics => }/ReportCard.tsx (100%) delete mode 100644 web-console-v2/src/components/cardsComponent/statistics/AnalyticsDataCard.tsx delete mode 100644 web-console-v2/src/components/cardsComponent/statistics/AsyncLabel.tsx delete mode 100644 web-console-v2/src/components/cardsComponent/statistics/BigNumber.tsx delete mode 100644 web-console-v2/src/components/cardsComponent/statistics/ReportCard.tsx delete mode 100644 web-console-v2/src/components/cardsV1/statistics/AnalyticsDataCard.tsx delete mode 100644 web-console-v2/src/components/cardsV1/statistics/AsyncLabel.tsx delete mode 100644 web-console-v2/src/components/cardsV1/statistics/BigNumber.tsx delete mode 100644 web-console-v2/src/constants/Enpoints.ts delete mode 100644 web-console-v2/src/pages/StepsPages/Processing/ProcessingSection/DedupeEvent/Schema.ts 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/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/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 0ad0c083..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 && } - - {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/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 index 64e35922..6646b0f2 100644 --- a/web-console-v2/src/constants/endpoints.ts +++ b/web-console-v2/src/constants/endpoints.ts @@ -1,10 +1,6 @@ -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 +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/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/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/dashboardV1/datasetsDetails.tsx b/web-console-v2/src/pages/dashboardV1/datasetsDetails.tsx index b3bc0222..f191e4d3 100644 --- a/web-console-v2/src/pages/dashboardV1/datasetsDetails.tsx +++ b/web-console-v2/src/pages/dashboardV1/datasetsDetails.tsx @@ -1,11 +1,10 @@ /* 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'; 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/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'; From 9c0c8e5469b80a1f38a5aee49368358da006c7aa Mon Sep 17 00:00:00 2001 From: Harish Kumar Gangula Date: Thu, 21 Nov 2024 10:33:27 +0530 Subject: [PATCH 08/23] #I319: Refactoring code --- web-console-v2/src/components/Buttons.tsx | 12 ------- .../src/components/Sidebar/Sidebar.tsx | 2 +- web-console-v2/src/constants/endpoints.ts | 26 ++++++++++++++++ web-console-v2/src/data/apiEndpoints.ts | 31 ------------------- .../src/data/chartsComponents/api.ts | 2 +- .../src/data/chartsComponents/druid.ts | 2 +- .../src/data/chartsComponents/infra.ts | 2 +- .../src/data/chartsComponents/ingestion.ts | 2 +- .../src/data/chartsComponents/jdbc.ts | 7 ++--- .../src/data/chartsComponents/processing.ts | 2 +- .../src/data/chartsComponents/storage.ts | 2 +- web-console-v2/src/data/chartsV1/api.ts | 2 +- web-console-v2/src/data/chartsV1/druid.ts | 2 +- web-console-v2/src/data/chartsV1/infra.ts | 2 +- web-console-v2/src/data/chartsV1/ingestion.ts | 2 +- web-console-v2/src/data/chartsV1/jdbc.ts | 14 ++++----- web-console-v2/src/data/chartsV1/object.ts | 4 +-- .../src/data/chartsV1/processing.ts | 2 +- web-console-v2/src/data/chartsV1/storage.ts | 2 +- .../DatasetMetrics.tsx | 0 .../MoreOptions.tsx | 0 .../ReadyToPublishDatasets.tsx | 2 +- .../RetiredDatasets.tsx | 0 .../createEvents.tsx | 1 - .../datasets.tsx | 0 .../datasetsDetails.tsx | 0 .../datasetsList.tsx | 0 .../draftDatasetsList.tsx | 0 .../components/NotificationComponent.tsx | 1 - .../alertManager/components/RunQuery.tsx | 2 +- web-console-v2/src/router/index.tsx | 4 +-- web-console-v2/src/services/datasetState.ts | 2 +- web-console-v2/src/services/datasetV1.ts | 2 +- web-console-v2/src/services/systemV1.ts | 2 +- 34 files changed, 58 insertions(+), 78 deletions(-) delete mode 100644 web-console-v2/src/components/Buttons.tsx delete mode 100644 web-console-v2/src/data/apiEndpoints.ts rename web-console-v2/src/pages/{dashboardV1 => DatasetListV1}/DatasetMetrics.tsx (100%) rename web-console-v2/src/pages/{dashboardV1 => DatasetListV1}/MoreOptions.tsx (100%) rename web-console-v2/src/pages/{dashboardV1 => DatasetListV1}/ReadyToPublishDatasets.tsx (99%) rename web-console-v2/src/pages/{dashboardV1 => DatasetListV1}/RetiredDatasets.tsx (100%) rename web-console-v2/src/pages/{dashboardV1 => DatasetListV1}/createEvents.tsx (99%) rename web-console-v2/src/pages/{dashboardV1 => DatasetListV1}/datasets.tsx (100%) rename web-console-v2/src/pages/{dashboardV1 => DatasetListV1}/datasetsDetails.tsx (100%) rename web-console-v2/src/pages/{dashboardV1 => DatasetListV1}/datasetsList.tsx (100%) rename web-console-v2/src/pages/{dashboardV1 => DatasetListV1}/draftDatasetsList.tsx (100%) 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/Sidebar/Sidebar.tsx b/web-console-v2/src/components/Sidebar/Sidebar.tsx index 04edbe97..9a69b8d0 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'; diff --git a/web-console-v2/src/constants/endpoints.ts b/web-console-v2/src/constants/endpoints.ts index 6646b0f2..07abaf8d 100644 --- a/web-console-v2/src/constants/endpoints.ts +++ b/web-console-v2/src/constants/endpoints.ts @@ -3,4 +3,30 @@ export default { 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/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/dashboardV1/DatasetMetrics.tsx b/web-console-v2/src/pages/DatasetListV1/DatasetMetrics.tsx similarity index 100% rename from web-console-v2/src/pages/dashboardV1/DatasetMetrics.tsx rename to web-console-v2/src/pages/DatasetListV1/DatasetMetrics.tsx 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/dashboardV1/ReadyToPublishDatasets.tsx b/web-console-v2/src/pages/DatasetListV1/ReadyToPublishDatasets.tsx similarity index 99% rename from web-console-v2/src/pages/dashboardV1/ReadyToPublishDatasets.tsx rename to web-console-v2/src/pages/DatasetListV1/ReadyToPublishDatasets.tsx index 95a71308..2dccbaa6 100644 --- a/web-console-v2/src/pages/dashboardV1/ReadyToPublishDatasets.tsx +++ b/web-console-v2/src/pages/DatasetListV1/ReadyToPublishDatasets.tsx @@ -24,7 +24,7 @@ import { downloadJsonFile } from 'utils/downloadUtils'; import { alertDialogContext } from './draftDatasetsList'; import { getDraftSourceConfig, renderNoDatasetsMessage } from './datasets'; 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 100% rename from web-console-v2/src/pages/dashboardV1/RetiredDatasets.tsx rename to web-console-v2/src/pages/DatasetListV1/RetiredDatasets.tsx diff --git a/web-console-v2/src/pages/dashboardV1/createEvents.tsx b/web-console-v2/src/pages/DatasetListV1/createEvents.tsx similarity index 99% rename from web-console-v2/src/pages/dashboardV1/createEvents.tsx rename to web-console-v2/src/pages/DatasetListV1/createEvents.tsx index 49a27d58..981e7605 100644 --- a/web-console-v2/src/pages/dashboardV1/createEvents.tsx +++ b/web-console-v2/src/pages/DatasetListV1/createEvents.tsx @@ -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/datasets.tsx b/web-console-v2/src/pages/DatasetListV1/datasets.tsx similarity index 100% rename from web-console-v2/src/pages/dashboardV1/datasets.tsx rename to web-console-v2/src/pages/DatasetListV1/datasets.tsx diff --git a/web-console-v2/src/pages/dashboardV1/datasetsDetails.tsx b/web-console-v2/src/pages/DatasetListV1/datasetsDetails.tsx similarity index 100% rename from web-console-v2/src/pages/dashboardV1/datasetsDetails.tsx rename to web-console-v2/src/pages/DatasetListV1/datasetsDetails.tsx diff --git a/web-console-v2/src/pages/dashboardV1/datasetsList.tsx b/web-console-v2/src/pages/DatasetListV1/datasetsList.tsx similarity index 100% rename from web-console-v2/src/pages/dashboardV1/datasetsList.tsx rename to web-console-v2/src/pages/DatasetListV1/datasetsList.tsx diff --git a/web-console-v2/src/pages/dashboardV1/draftDatasetsList.tsx b/web-console-v2/src/pages/DatasetListV1/draftDatasetsList.tsx similarity index 100% rename from web-console-v2/src/pages/dashboardV1/draftDatasetsList.tsx rename to web-console-v2/src/pages/DatasetListV1/draftDatasetsList.tsx 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..378f05c8 100644 --- a/web-console-v2/src/pages/alertManager/components/RunQuery.tsx +++ b/web-console-v2/src/pages/alertManager/components/RunQuery.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Grid, Stack } from "@mui/material"; import _ from 'lodash'; import dayjs from 'dayjs'; -import endpoints from 'data/apiEndpoints'; +import endpoints from 'constants/Endpoints'; import ApexChart from "sections/dashboard/analytics/apex"; import { Button } from "@mui/material"; import { CloseOutlined } from "@ant-design/icons"; diff --git a/web-console-v2/src/router/index.tsx b/web-console-v2/src/router/index.tsx index 286908b4..a0f96e43 100644 --- a/web-console-v2/src/router/index.tsx +++ b/web-console-v2/src/router/index.tsx @@ -14,8 +14,8 @@ import SelectConnectorPage from 'pages/SelectConnector/SelectConnector'; import ManageConnectorsPage from 'pages/ConnectorManagement/Manage/Manage'; import Dashboard from 'pages/Dashboard/Dashboard'; import IndividualMetricDashboards from 'pages/Dashboard/IndividualDashboardPage/IndividualDashboardPage'; -import DatasetCreateEvents from 'pages/dashboardV1/createEvents'; -import ClusterHealth from 'pages/dashboardV1/datasets'; +import DatasetCreateEvents from 'pages/DatasetListV1/createEvents'; +import ClusterHealth from 'pages/DatasetListV1/datasets'; import StepperPage from 'pages/StepsPages/StepperPage'; import AlertRules from 'pages/alertManager/views/AlertRules'; import SystemAlerts from 'pages/alertManager/views/SystemRules'; diff --git a/web-console-v2/src/services/datasetState.ts b/web-console-v2/src/services/datasetState.ts index a3a57e37..8318e64d 100644 --- a/web-console-v2/src/services/datasetState.ts +++ b/web-console-v2/src/services/datasetState.ts @@ -3,7 +3,7 @@ import { DatasetType } from "types/datasets"; import moment from "moment"; import { v4 as uuid } from 'uuid'; import { http } from "./http"; -import apiEndpoints from "data/apiEndpoints"; +import apiEndpoints from "constants/Endpoints"; type Payload = Record; export const generateJsonSchema = (payload: Payload) => { diff --git a/web-console-v2/src/services/datasetV1.ts b/web-console-v2/src/services/datasetV1.ts index 5a8cb3a1..709e61b2 100644 --- a/web-console-v2/src/services/datasetV1.ts +++ b/web-console-v2/src/services/datasetV1.ts @@ -2,7 +2,7 @@ import * as _ from 'lodash'; import { http } from 'services/http'; import { flattenSchema, setAdditionalProperties, updateDenormDerived, updateJSONSchema } from './json-schema'; -import apiEndpoints from 'data/apiEndpoints'; +import apiEndpoints from 'constants/Endpoints'; import { DatasetStatus, DatasetType } from 'types/datasets'; import { aggregationFunctions, allowedSegmentGranurality } from './commonUtils'; import { generateRequestBody } from './utils'; 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) => { From 5368bcdf08c1df8b55378ea368b316bf653d6d1b Mon Sep 17 00:00:00 2001 From: Harish Kumar Gangula Date: Thu, 21 Nov 2024 13:46:53 +0530 Subject: [PATCH 09/23] #I319: V1 Dataset list page names updated --- ...eateEvents.tsx => DatasetCreateEvents.tsx} | 0 .../src/pages/DatasetListV1/LiveDatasets.tsx | 526 ++++++++++++++ .../DatasetListV1/ReadyToPublishDatasets.tsx | 2 +- .../pages/DatasetListV1/RetiredDatasets.tsx | 2 +- .../src/pages/DatasetListV1/datasets.tsx | 194 ------ .../src/pages/DatasetListV1/datasetsList.tsx | 658 +++++------------- .../pages/DatasetListV1/draftDatasetsList.tsx | 2 +- web-console-v2/src/router/index.tsx | 6 +- 8 files changed, 695 insertions(+), 695 deletions(-) rename web-console-v2/src/pages/DatasetListV1/{createEvents.tsx => DatasetCreateEvents.tsx} (100%) create mode 100644 web-console-v2/src/pages/DatasetListV1/LiveDatasets.tsx delete mode 100644 web-console-v2/src/pages/DatasetListV1/datasets.tsx diff --git a/web-console-v2/src/pages/DatasetListV1/createEvents.tsx b/web-console-v2/src/pages/DatasetListV1/DatasetCreateEvents.tsx similarity index 100% rename from web-console-v2/src/pages/DatasetListV1/createEvents.tsx rename to web-console-v2/src/pages/DatasetListV1/DatasetCreateEvents.tsx diff --git a/web-console-v2/src/pages/DatasetListV1/LiveDatasets.tsx b/web-console-v2/src/pages/DatasetListV1/LiveDatasets.tsx new file mode 100644 index 00000000..a1854e76 --- /dev/null +++ b/web-console-v2/src/pages/DatasetListV1/LiveDatasets.tsx @@ -0,0 +1,526 @@ +import React from 'react'; +import { useEffect, useMemo, useState } from 'react'; +import { Chip, CircularProgress, Stack, Tooltip, Typography, Box } from '@mui/material'; +import MainCard from 'components/MainCard'; +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/AlertDialog'; +import { useNavigate } from 'react-router'; +import { fetchChartData } from 'services/clusterMetrics'; +import { druidQueries } from 'services/druid'; +import dayjs from 'dayjs'; +import chartMeta from 'data/chartsV1'; +import * as _ from 'lodash'; +import interactIds from 'data/telemetry/interact.json'; +import EditDatasetTags from 'components/EditDatasetTags'; +import { createDraftversion, exportDataset, fetchDatasets, retireLiveDataset, updateLiveDataset } from 'services/datasetV1'; +import FiberManualRecordIcon from '@mui/icons-material/FiberManualRecord'; +import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; +import ChevronRightIcon from '@mui/icons-material/ChevronRight'; +import { v4 } from 'uuid'; +import { renderSkeleton } from 'services/skeleton'; +import { DatasetStatus, DatasetType, DatasetActions } from 'types/datasets'; +import en from 'utils/locales/en.json'; +import { FormattedMessage } from 'react-intl'; +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 './datasetsList'; +import { useAlert } from 'contexts/AlertContextProvider'; + +const dateFormat = 'YYYY-MM-DDT00:00:00+05:30' + +const statusColors: Record = { + [_.toLower(DatasetStatus.Live)]: "success", + [_.toLower(DatasetStatus.Retired)]: "secondary", + [_.toLower(DatasetStatus.Purged)]: "secondary", +} +export const pageMeta = { pageId: 'datasetConfiguration' }; + +const LiveDatasets = ({ setDatasetType, sourceConfigs }: any) => { + const { showAlert } = useAlert(); + const [openAlertDialog, setOpenAlertDialog] = useState(false); + const [data, setData] = useState([]); + const [tagSelection, setTagSelection] = useState({}); + const [anchorEl, setAnchorEl] = useState(null); + const [refreshData, setRefreshData] = useState('false'); + const [loading, setLoading] = useState(false); + const open = Boolean(anchorEl); + const [selection, setSelection] = useState(null); + const navigate = useNavigate(); + const navigateToPath = (path: string) => { + navigate(path); + } + const [executeAction, setExecuteAction] = useState(""); + const alertDialogContext = (datasetName = "") => { + switch (executeAction) { + case DatasetActions.Retire: + return { title: , content: }; + case DatasetActions.Edit: + return { title: , content: }; + case DatasetActions.AddRollup: + return { title: , content: }; + default: + break; + } + } + + const getDatasets = async () => { + setLoading(true); + try { + const liveDatasetRecord = await fetchDatasets({ data: { filters: { status: [DatasetStatus.Live] } } }) + const liveDatasets = _.get(liveDatasetRecord, "data") + _.map(liveDatasets, async (item: any) => getLiveSourceConfig(item, sourceConfigs)); + setData(liveDatasets); + } catch (err: any) { + showAlert(en['datasets-fetch-failure'], 'error'); + } finally { + setLoading(false); + } + } + + useEffect(() => { + getDatasets(); + }, []) + + const AsyncColumnData = (query: Record, datasetId: any, cellKey: string) => { + const [isLoading, setIsLoading] = useState(false); + + useEffect(() => { + const fetchData = async (value: any) => { + setIsLoading(true); + try { + const data = await fetchChartData(value); + const responseData = _.isArray(data) ? _.first(data) : data; + + // Always store the successful response in localStorage under datasetId and cellKey + const storedData: any = localStorage.getItem(datasetId); + const parsedData = !_.isEmpty(storedData) ? JSON.parse(storedData) : {}; + parsedData[cellKey] = responseData; + localStorage.setItem(datasetId, JSON.stringify(parsedData)); + } catch (error) { + // Check if localStorage already has a value for cellKey, and only store the error if no value exists + const storedData: any = localStorage.getItem(datasetId); + const parsedData = !_.isEmpty(storedData) ? JSON.parse(storedData) : {}; + if (!parsedData[cellKey]) { + // If localStorage doesn't contain a value for this cellKey, store 0 as value + parsedData[cellKey] = 0; + localStorage.setItem(datasetId, JSON.stringify(parsedData)); + } + } finally { + setIsLoading(false); + } + }; + fetchData(query); + }, []); + + if (isLoading) { + return ; + } + + // Always read from localStorage on render, specific to the current cellKey + const storedData = localStorage.getItem(datasetId); + let parsedData = null; + try { + parsedData = storedData ? JSON.parse(storedData) : null; + } catch (error) { + console.error("Failed to parse stored data:", error); + parsedData = null; + } + const cellData = parsedData ? parsedData[cellKey] : null; + + // Check if the stored data is an error + if (cellData?.error) return cellData.error; + + if ([null, undefined].includes(cellData)) return "N/A"; + + const hoverValue = _.get(cellData, "hoverValue") || ""; + const value: any = _.get(cellData, "value") || cellData; + + return ( +
+ {value} +
+ ); + }; + + const updateDatasetProps = ({ dataset_id, status, id, name, tags }: any) => { + setData((prevState: any) => { + const prevData = _.cloneDeep(prevState); + const index = _.findIndex(prevData, (data: any) => { + return dataset_id === _.get(data, 'dataset_id') && status === _.get(data, 'status') && id === _.get(data, 'id') && name === _.get(data, 'name') + }); + _.set(prevData[index], 'tags', tags); + return prevData; + }); + resetEditTags(); + } + + const onSaveTags = async (dataset: any, tagsData: any) => { + const { dataset_id, name, status, id } = dataset; + const payload = { + dataset_id, + name, + status, + tags: tagsData, + } + try { + setLoading(true) + await updateLiveDataset({ data: { ...payload } }); + updateDatasetProps({ dataset_id, status, id, name, tags: tagsData, }); + setRefreshData(v4()); + } catch (err: any) { + showAlert("Failed to update tags", "error"); + } finally { + handlePopClose(); + setLoading(false) + } + } + + const resetEditTags = () => { + setTagSelection({}); + handlePopClose(); + } + + const handleDownloadButton = async (dataset_id: string, version: number, status: string, fileName: string) => { + try { + const exportDatasetResponse = await exportDataset(dataset_id, DatasetStatus.Live); + const jsonSchema: any = _.get(exportDatasetResponse, 'data.result') + if (jsonSchema) { + downloadJsonFile(jsonSchema, fileName); + } + } + catch (err) { + showAlert("Unable to export dataset", "error"); + } + } + + const handleLiveRollups = async () => { + await createDraftversion({ selection: _.get(selection, "dataset_id") || "", navigateToPath, rollupRedirect: true, showAlert }) + } + + const execute = () => { + switch (executeAction) { + case DatasetActions.Retire: + retireDataset(); + break; + case DatasetActions.Edit: + editLiveDataset(); + break; + case DatasetActions.AddRollup: + handleLiveRollups(); + break; + default: + break; + } + } + + const columns = useMemo( + () => [ + + { + Header: 'Name', + accessor: 'name', + disableFilters: true, + disableGroupBy: true, + Aggregated: () => null, + Cell: (value: any) => { + const row = value?.cell?.row?.original || {}; + return + { + row?.status && row?.type && ( + + + + {row?.name} + + + + ) + } + { + row?.onlyTag && ( + + + {row?.name} + } + color="secondary" + variant="outlined" + size="small" + /> + + {`(${row?.count})`} + + + ) + } + + { + row?.sources && row?.sources.map((connector: string, index: number) => ( + + + {connector} + } + color="primary" + variant="outlined" size="small" + /> + + )) + } + {row?.type && + + {_.toUpper(row?.type)} + } + color={row?.type == "dataset" ? "success" : "info"} + variant="outlined" + size="small" + />} + { + row?.tags && row?.tags?.map((tag: string, index: number) => ( + + + {tag} + } + color={"secondary"} + variant="outlined" + size="small" + /> + + )) + } + + + } + }, + { + Header: () => null, + accessor: 'tags', + disableFilters: true, + }, + { + Header: 'Total Events (Today)', + disableFilters: true, + Cell: ({ value, cell }: any) => { + const row = cell?.row?.original || {}; + const isMasterDataset = _.get(row, 'type') === DatasetType.MasterDataset; + const datasetId = row?.dataset_id; + const startDate = dayjs().format(dateFormat); + const endDate = dayjs().add(1, 'day').format(dateFormat); + const body = druidQueries.total_events_processed({ datasetId, intervals: `${startDate}/${endDate}`, master: isMasterDataset, }) + const query = _.get(chartMeta, 'total_events_processed.query'); + if (row?.onlyTag) return null; + return AsyncColumnData({ ...query, body }, datasetId, "total_events"); + } + }, + { + Header: 'Total Events (Yesterday)', + disableFilters: true, + Cell: ({ value, cell }: any) => { + const row = cell?.row?.original || {}; + const isMasterDataset = _.get(row, 'type') === DatasetType.MasterDataset; + const datasetId = row?.dataset_id; + const startDate = dayjs().subtract(1, 'day').format(dateFormat); + const endDate = dayjs().format(dateFormat); + const body = druidQueries.total_events_processed({ datasetId, intervals: `${startDate}/${endDate}`, master: isMasterDataset, }) + const query = _.get(chartMeta, 'total_events_processed.query'); + if (row?.onlyTag) return null; + return AsyncColumnData({ ...query, body }, datasetId, "total_events_yesterday"); + } + }, + { + Header: 'Avg Processing Time (Today)', + disableFilters: true, + Cell: ({ value, cell }: any) => { + const row = cell?.row?.original || {}; + const isMasterDataset = _.get(row, 'type') === DatasetType.MasterDataset; + const datasetId = row?.dataset_id; + const startDate = dayjs().format(dateFormat); + const endDate = dayjs().add(1, 'day').format(dateFormat); + const body = druidQueries.druid_avg_processing_time({ datasetId, intervals: `${startDate}/${endDate}`, master: isMasterDataset, }) + const query = _.get(chartMeta, 'druid_avg_processing_time.query'); + if (row?.onlyTag) return null; + return AsyncColumnData({ ...query, body }, datasetId, "average_processing_time"); + } + }, + { + Header: 'Avg Processing Time (Yesterday)', + disableFilters: true, + Cell: ({ value, cell }: any) => { + const row = cell?.row?.original || {}; + const isMasterDataset = _.get(row, 'type') === DatasetType.MasterDataset; + const datasetId = row?.dataset_id; + const startDate = dayjs().subtract(1, 'day').format(dateFormat); + const endDate = dayjs().format(dateFormat); + const body = druidQueries.druid_avg_processing_time({ datasetId, intervals: `${startDate}/${endDate}`, master: isMasterDataset, }) + const query = _.get(chartMeta, 'druid_avg_processing_time.query'); + if (row?.onlyTag) return null; + return AsyncColumnData({ ...query, body }, datasetId, "average_processing_time_yesterday"); + } + }, + { + Header: 'Last Synced Time', + disableFilters: true, + Cell: ({ value, cell }: any) => { + const row = cell?.row?.original || {}; + const isMasterDataset = _.get(row, 'type') === DatasetType.MasterDataset; + const datasetId = row?.dataset_id; + const startDate = dayjs().subtract(10, 'day').format(dateFormat); + const endDate = dayjs().add(1, 'day').format(dateFormat); + const body = druidQueries.last_synced_time({ datasetId, intervals: `${startDate}/${endDate}`, master: isMasterDataset, }) + const query = _.get(chartMeta, 'last_synced_relative_time.query'); + if (row?.onlyTag) return null; + return AsyncColumnData({ ...query, body }, datasetId, "last_synced_time"); + } + }, + { + Header: 'Event Failed (Today)', + disableFilters: true, + Cell: ({ value, cell }: any) => { + const row = cell?.row?.original || {}; + const isMasterDataset = _.get(row, 'type') === DatasetType.MasterDataset; + const datasetId = _.get(row, 'dataset_id'); + const endDate = dayjs().endOf('day').unix(); + const query = isMasterDataset ? + _.get(chartMeta, 'failed_events_summary_master_datasets.query') : + _.get(chartMeta, 'failed_events_summary.query'); + if (row?.onlyTag) return null; + return AsyncColumnData({ ...query, time: endDate, dataset: datasetId, master: isMasterDataset, }, datasetId, "events_failed"); + } + }, + { + Header: 'Actions', + accessor: 'color', + disableFilters: true, + Cell: ({ value, cell }: any) => { + const row = cell?.row?.original || {}; + if (row?.onlyTag) return null; + const isMaster: boolean = row?.type == DatasetType.MasterDataset; + const fileName = `${row?.name}_${row?.status}_${row?.version}`; + return + navigateToPath(`/datasets/view/${row?.dataset_id}?master=${isMaster}&status=${DatasetStatus.Live}`)}> + + + + + navigateToPath(`/datasets/metrics/${row?.dataset_id}`)}> + + < DashboardOutlined /> + + + + handleClick(e, row)} + disabled={true} + > + + + + + + + + } + } + ], + [] + ); + + const retireDataset = async () => { + if (selection) { + setLoading(true); + try { + await retireLiveDataset({ id: _.get(selection, "dataset_id") }) + setDatasetType(DatasetStatus.Retired) + navigateToPath(`?status=${DatasetStatus.Retired}`) + showAlert("Dataset retired successfully", "success"); + + } catch (err: any) { + const errMessage = _.get(err, 'response.data.params.errmsg') || en["dataset-retire-failure"]; + showAlert(errMessage, "error"); + } finally { + getDatasets(); + setLoading(false); + setSelection(null) + } + } + } + + const handleRetire = (datasetPayload: Record) => { + setSelection(datasetPayload) + setOpenAlertDialog(true) + } + + const handleEdit = (datasetPayload: Record) => { + setSelection(datasetPayload) + setOpenAlertDialog(true) + } + + const handleClose = (status: boolean) => { + setOpenAlertDialog(false) + } + + const handlePopClose = () => { + setAnchorEl(null); + } + + const handleClick = (event: React.MouseEvent, dataset: any) => { + setAnchorEl(event.currentTarget); + setTagSelection(dataset); + }; + + const editLiveDataset = async () => { + setOpenAlertDialog(true) + const response = await createDraftversion({ selection: _.get(selection, "dataset_id") || "", navigateToPath, showAlert }) + } + + return ( + + {loading ? renderSkeleton({ config: { type: "table", width: "100%" } }) : + <> + {_.isEmpty(data) ? renderNoDatasetsMessage(en['datasets-not-found']) : <> + + + + + + } + + } + + ); +}; + +export default LiveDatasets; diff --git a/web-console-v2/src/pages/DatasetListV1/ReadyToPublishDatasets.tsx b/web-console-v2/src/pages/DatasetListV1/ReadyToPublishDatasets.tsx index 2dccbaa6..0a75d5f5 100644 --- a/web-console-v2/src/pages/DatasetListV1/ReadyToPublishDatasets.tsx +++ b/web-console-v2/src/pages/DatasetListV1/ReadyToPublishDatasets.tsx @@ -22,7 +22,7 @@ import en from 'utils/locales/en.json'; import { DatasetStatus, DatasetType } from 'types/datasets'; import { downloadJsonFile } from 'utils/downloadUtils'; import { alertDialogContext } from './draftDatasetsList'; -import { getDraftSourceConfig, renderNoDatasetsMessage } from './datasets'; +import { getDraftSourceConfig, renderNoDatasetsMessage } from './datasetsList'; import { http } from 'services/http'; import apiEndpoints from 'constants/Endpoints'; import { useAlert } from 'contexts/AlertContextProvider'; diff --git a/web-console-v2/src/pages/DatasetListV1/RetiredDatasets.tsx b/web-console-v2/src/pages/DatasetListV1/RetiredDatasets.tsx index 31e9cb21..84ca614f 100644 --- a/web-console-v2/src/pages/DatasetListV1/RetiredDatasets.tsx +++ b/web-console-v2/src/pages/DatasetListV1/RetiredDatasets.tsx @@ -14,7 +14,7 @@ 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/DatasetListV1/datasets.tsx b/web-console-v2/src/pages/DatasetListV1/datasets.tsx deleted file mode 100644 index de012d79..00000000 --- a/web-console-v2/src/pages/DatasetListV1/datasets.tsx +++ /dev/null @@ -1,194 +0,0 @@ -/* eslint-disable */ -import { useEffect, useState } 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 useImpression from 'hooks/useImpression'; -import pageIds from 'data/telemetry/pageIds'; -import RetiredDatasets from './RetiredDatasets'; -import { Button } from '@mui/material'; -import { useNavigate } from 'react-router'; -import { DatasetStatus } from 'types/datasets'; -import { ImportOutlined, PlusOutlined } from '@ant-design/icons'; -import { TabContext, TabList, TabPanel } from '@mui/lab'; -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'; - -export const getLiveSourceConfig: any = (liveDataset: any, liveSourceConfigs: any) => { - const condition = (config: any) => { - return (_.get(liveDataset, 'dataset_id') === _.get(config, 'dataset_id')) && (_.get(liveDataset, 'status') === _.get(config, 'status')); - } - _.map(liveSourceConfigs, (config: any) => { - const existingConnectors = _.get(liveDataset, 'sources') || []; - if (condition(config)) - _.set(liveDataset, 'sources', _.map([_.get(config, 'connector_type'), ...existingConnectors,], _.toUpper)); - }); - _.set(liveDataset, 'sources', ['API', ..._.uniq(_.get(liveDataset, 'sources') || [])]); - return liveDataset; -} - -export const getDraftSourceConfig: any = (draftDataset: any, draftSourceConfigs: any) => { - if (!draftDataset?.sources) { - _.set(draftDataset, "sources", ["API"]) - _.forEach(draftSourceConfigs, config => { - if (draftDataset?.id === config?.dataset_id) { - const datasetSource = draftDataset?.sources; - _.uniq(datasetSource.push(_.toUpper(config?.connector_type))) - _.set(draftDataset, "sources", datasetSource) - } - }) - } - return draftDataset; -} - -const showNoDatasetsError = (message = ) => {message} -export const renderNoDatasetsMessage = (message: string | any) => {showNoDatasetsError(message)} - -const ClusterHealth = () => { - const theme = useTheme(); - const [params] = useSearchParams(); - const datasetStatus: string = params.get("status") || DatasetStatus.Live - const navigate = useNavigate(); - useImpression({ type: "list", pageid: _.get(pageIds, 'dataset.list') }); - const [datasetType, setDatasetType] = useState(datasetStatus); - const [openModal, setOpenModal] = useState(false); - const handleOpen = () => setOpenModal(true); - const handleClose = () => setOpenModal(false); - - const handleTabChange = (event: any, newValue: any) => { - setDatasetType(newValue); - navigate(`?status=${newValue}`) - } - - const renderDatasets = (status: string) => { - switch (status) { - case DatasetStatus.Live: return - - - - case DatasetStatus.ReadyToPublish: return - - - - case DatasetStatus.Draft: return - - - - case DatasetStatus.Retired: return - - - - default: return renderNoDatasetsMessage("No Datasets"); - } - } - - - const datasetsTab = [ - { id: DatasetStatus.Live, label: , color: "success", tooltip: }, - { id: DatasetStatus.ReadyToPublish, label: , color: "info", tooltip: }, - { id: DatasetStatus.Draft, label: , color: "warning", tooltip: }, - { id: DatasetStatus.Retired, label: , color: "error", tooltip: } - ] - - const actions = [{ - id: "import", - label: , - icon: , - onClick: handleOpen, - disabled: false - }, { - id: "add-dataset", - label: , - onClick: () => navigate(`/dataset/create`), - icon: , - disabled: false - }] - - const renderDatasetTables = () => { - return <> - {renderDatasets(DatasetStatus.Live)} - {renderDatasets(DatasetStatus.ReadyToPublish)} - {renderDatasets(DatasetStatus.Draft)} - {renderDatasets(DatasetStatus.Retired)} - {renderDatasets(DatasetStatus.Purged)} - - } - - const renderDatasetActions = (action: Record) => { - const { id, label, onClick, disabled, icon } = action; - return - } - - const renderDatasetTableHeaders = (field: Record) => { - const { id, label, color, tooltip } = field; - return - - - {label} - -
} value={id} /> - } - - const renderDatasetTabs = () => { - return - - - - - {_.map(datasetsTab, renderDatasetTableHeaders)} - - - {_.map(actions, renderDatasetActions)} - - - - - {renderDatasetTables()} - - - - } - - return ( - - {renderDatasetTabs()} - - - - ) -}; - -export default ClusterHealth; diff --git a/web-console-v2/src/pages/DatasetListV1/datasetsList.tsx b/web-console-v2/src/pages/DatasetListV1/datasetsList.tsx index 7d2fe6a8..128bbab4 100644 --- a/web-console-v2/src/pages/DatasetListV1/datasetsList.tsx +++ b/web-console-v2/src/pages/DatasetListV1/datasetsList.tsx @@ -1,526 +1,194 @@ -import React from 'react'; -import { useEffect, useMemo, useState } from 'react'; -import { Chip, CircularProgress, Stack, Tooltip, Typography, Box } from '@mui/material'; -import MainCard from 'components/MainCard'; -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/AlertDialog'; -import { useNavigate } from 'react-router'; -import { fetchChartData } from 'services/clusterMetrics'; -import { druidQueries } from 'services/druid'; -import dayjs from 'dayjs'; -import chartMeta from 'data/chartsV1'; +/* eslint-disable */ +import { useEffect, useState } from 'react'; +import { Alert, Box, Grid, Stack, Tab, Tooltip, Typography, useTheme } from '@mui/material'; import * as _ from 'lodash'; -import interactIds from 'data/telemetry/interact.json'; -import EditDatasetTags from 'components/EditDatasetTags'; -import { createDraftversion, exportDataset, fetchDatasets, retireLiveDataset, updateLiveDataset } from 'services/datasetV1'; +import LiveDatasets from './LiveDatasets'; +import DraftDatasetsList from './draftDatasetsList'; +import useImpression from 'hooks/useImpression'; +import pageIds from 'data/telemetry/pageIds'; +import RetiredDatasets from './RetiredDatasets'; +import { Button } from '@mui/material'; +import { useNavigate } from 'react-router'; +import { DatasetStatus } from 'types/datasets'; +import { ImportOutlined, PlusOutlined } from '@ant-design/icons'; +import { TabContext, TabList, TabPanel } from '@mui/lab'; import FiberManualRecordIcon from '@mui/icons-material/FiberManualRecord'; -import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; -import ChevronRightIcon from '@mui/icons-material/ChevronRight'; -import { v4 } from 'uuid'; -import { renderSkeleton } from 'services/skeleton'; -import { DatasetStatus, DatasetType, DatasetActions } from 'types/datasets'; -import en from 'utils/locales/en.json'; +import ReadyToPublishDatasetsList from './ReadyToPublishDatasets'; import { FormattedMessage } from 'react-intl'; -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 { useAlert } from 'contexts/AlertContextProvider'; - -const dateFormat = 'YYYY-MM-DDT00:00:00+05:30' - -const statusColors: Record = { - [_.toLower(DatasetStatus.Live)]: "success", - [_.toLower(DatasetStatus.Retired)]: "secondary", - [_.toLower(DatasetStatus.Purged)]: "secondary", -} -export const pageMeta = { pageId: 'datasetConfiguration' }; +import { useSearchParams } from 'react-router-dom'; +import { Dialog, DialogTitle, DialogContent, DialogActions } from '@mui/material'; +import ImportDataset from 'pages/datasetV1/ImportDataset'; -const DatasetsList = ({ setDatasetType, sourceConfigs }: any) => { - const { showAlert } = useAlert(); - const [openAlertDialog, setOpenAlertDialog] = useState(false); - const [data, setData] = useState([]); - const [tagSelection, setTagSelection] = useState({}); - const [anchorEl, setAnchorEl] = useState(null); - const [refreshData, setRefreshData] = useState('false'); - const [loading, setLoading] = useState(false); - const open = Boolean(anchorEl); - const [selection, setSelection] = useState(null); - const navigate = useNavigate(); - const navigateToPath = (path: string) => { - navigate(path); - } - const [executeAction, setExecuteAction] = useState(""); - const alertDialogContext = (datasetName = "") => { - switch (executeAction) { - case DatasetActions.Retire: - return { title: , content: }; - case DatasetActions.Edit: - return { title: , content: }; - case DatasetActions.AddRollup: - return { title: , content: }; - default: - break; - } - } - - const getDatasets = async () => { - setLoading(true); - try { - const liveDatasetRecord = await fetchDatasets({ data: { filters: { status: [DatasetStatus.Live] } } }) - const liveDatasets = _.get(liveDatasetRecord, "data") - _.map(liveDatasets, async (item: any) => getLiveSourceConfig(item, sourceConfigs)); - setData(liveDatasets); - } catch (err: any) { - showAlert(en['datasets-fetch-failure'], 'error'); - } finally { - setLoading(false); - } - } - - useEffect(() => { - getDatasets(); - }, []) - - const AsyncColumnData = (query: Record, datasetId: any, cellKey: string) => { - const [isLoading, setIsLoading] = useState(false); - - useEffect(() => { - const fetchData = async (value: any) => { - setIsLoading(true); - try { - const data = await fetchChartData(value); - const responseData = _.isArray(data) ? _.first(data) : data; - - // Always store the successful response in localStorage under datasetId and cellKey - const storedData: any = localStorage.getItem(datasetId); - const parsedData = !_.isEmpty(storedData) ? JSON.parse(storedData) : {}; - parsedData[cellKey] = responseData; - localStorage.setItem(datasetId, JSON.stringify(parsedData)); - } catch (error) { - // Check if localStorage already has a value for cellKey, and only store the error if no value exists - const storedData: any = localStorage.getItem(datasetId); - const parsedData = !_.isEmpty(storedData) ? JSON.parse(storedData) : {}; - if (!parsedData[cellKey]) { - // If localStorage doesn't contain a value for this cellKey, store 0 as value - parsedData[cellKey] = 0; - localStorage.setItem(datasetId, JSON.stringify(parsedData)); - } - } finally { - setIsLoading(false); - } - }; - fetchData(query); - }, []); - - if (isLoading) { - return ; - } - - // Always read from localStorage on render, specific to the current cellKey - const storedData = localStorage.getItem(datasetId); - let parsedData = null; - try { - parsedData = storedData ? JSON.parse(storedData) : null; - } catch (error) { - console.error("Failed to parse stored data:", error); - parsedData = null; - } - const cellData = parsedData ? parsedData[cellKey] : null; - - // Check if the stored data is an error - if (cellData?.error) return cellData.error; - - if ([null, undefined].includes(cellData)) return "N/A"; - - const hoverValue = _.get(cellData, "hoverValue") || ""; - const value: any = _.get(cellData, "value") || cellData; - - return ( -
- {value} -
- ); - }; - - const updateDatasetProps = ({ dataset_id, status, id, name, tags }: any) => { - setData((prevState: any) => { - const prevData = _.cloneDeep(prevState); - const index = _.findIndex(prevData, (data: any) => { - return dataset_id === _.get(data, 'dataset_id') && status === _.get(data, 'status') && id === _.get(data, 'id') && name === _.get(data, 'name') - }); - _.set(prevData[index], 'tags', tags); - return prevData; - }); - resetEditTags(); +export const getLiveSourceConfig: any = (liveDataset: any, liveSourceConfigs: any) => { + const condition = (config: any) => { + return (_.get(liveDataset, 'dataset_id') === _.get(config, 'dataset_id')) && (_.get(liveDataset, 'status') === _.get(config, 'status')); } + _.map(liveSourceConfigs, (config: any) => { + const existingConnectors = _.get(liveDataset, 'sources') || []; + if (condition(config)) + _.set(liveDataset, 'sources', _.map([_.get(config, 'connector_type'), ...existingConnectors,], _.toUpper)); + }); + _.set(liveDataset, 'sources', ['API', ..._.uniq(_.get(liveDataset, 'sources') || [])]); + return liveDataset; +} - const onSaveTags = async (dataset: any, tagsData: any) => { - const { dataset_id, name, status, id } = dataset; - const payload = { - dataset_id, - name, - status, - tags: tagsData, - } - try { - setLoading(true) - await updateLiveDataset({ data: { ...payload } }); - updateDatasetProps({ dataset_id, status, id, name, tags: tagsData, }); - setRefreshData(v4()); - } catch (err: any) { - showAlert("Failed to update tags", "error"); - } finally { - handlePopClose(); - setLoading(false) - } +export const getDraftSourceConfig: any = (draftDataset: any, draftSourceConfigs: any) => { + if (!draftDataset?.sources) { + _.set(draftDataset, "sources", ["API"]) + _.forEach(draftSourceConfigs, config => { + if (draftDataset?.id === config?.dataset_id) { + const datasetSource = draftDataset?.sources; + _.uniq(datasetSource.push(_.toUpper(config?.connector_type))) + _.set(draftDataset, "sources", datasetSource) + } + }) } + return draftDataset; +} - const resetEditTags = () => { - setTagSelection({}); - handlePopClose(); - } +const showNoDatasetsError = (message = ) => {message} +export const renderNoDatasetsMessage = (message: string | any) => {showNoDatasetsError(message)} - const handleDownloadButton = async (dataset_id: string, version: number, status: string, fileName: string) => { - try { - const exportDatasetResponse = await exportDataset(dataset_id, DatasetStatus.Live); - const jsonSchema: any = _.get(exportDatasetResponse, 'data.result') - if (jsonSchema) { - downloadJsonFile(jsonSchema, fileName); - } - } - catch (err) { - showAlert("Unable to export dataset", "error"); - } +const DatasetsList = () => { + const theme = useTheme(); + const [params] = useSearchParams(); + const datasetStatus: string = params.get("status") || DatasetStatus.Live + const navigate = useNavigate(); + useImpression({ type: "list", pageid: _.get(pageIds, 'dataset.list') }); + const [datasetType, setDatasetType] = useState(datasetStatus); + const [openModal, setOpenModal] = useState(false); + const handleOpen = () => setOpenModal(true); + const handleClose = () => setOpenModal(false); + + const handleTabChange = (event: any, newValue: any) => { + setDatasetType(newValue); + navigate(`?status=${newValue}`) } - const handleLiveRollups = async () => { - await createDraftversion({ selection: _.get(selection, "dataset_id") || "", navigateToPath, rollupRedirect: true, showAlert }) - } + const renderDatasets = (status: string) => { + switch (status) { + case DatasetStatus.Live: return + + - const execute = () => { - switch (executeAction) { - case DatasetActions.Retire: - retireDataset(); - break; - case DatasetActions.Edit: - editLiveDataset(); - break; - case DatasetActions.AddRollup: - handleLiveRollups(); - break; - default: - break; - } - } + case DatasetStatus.ReadyToPublish: return + + - const columns = useMemo( - () => [ - - { - Header: 'Name', - accessor: 'name', - disableFilters: true, - disableGroupBy: true, - Aggregated: () => null, - Cell: (value: any) => { - const row = value?.cell?.row?.original || {}; - return - { - row?.status && row?.type && ( - - - - {row?.name} - - - - ) - } - { - row?.onlyTag && ( - - - {row?.name} - } - color="secondary" - variant="outlined" - size="small" - /> - - {`(${row?.count})`} - - - ) - } - - { - row?.sources && row?.sources.map((connector: string, index: number) => ( - - - {connector} - } - color="primary" - variant="outlined" size="small" - /> - - )) - } - {row?.type && - - {_.toUpper(row?.type)} - } - color={row?.type == "dataset" ? "success" : "info"} - variant="outlined" - size="small" - />} - { - row?.tags && row?.tags?.map((tag: string, index: number) => ( - - - {tag} - } - color={"secondary"} - variant="outlined" - size="small" - /> - - )) - } - - - } - }, - { - Header: () => null, - accessor: 'tags', - disableFilters: true, - }, - { - Header: 'Total Events (Today)', - disableFilters: true, - Cell: ({ value, cell }: any) => { - const row = cell?.row?.original || {}; - const isMasterDataset = _.get(row, 'type') === DatasetType.MasterDataset; - const datasetId = row?.dataset_id; - const startDate = dayjs().format(dateFormat); - const endDate = dayjs().add(1, 'day').format(dateFormat); - const body = druidQueries.total_events_processed({ datasetId, intervals: `${startDate}/${endDate}`, master: isMasterDataset, }) - const query = _.get(chartMeta, 'total_events_processed.query'); - if (row?.onlyTag) return null; - return AsyncColumnData({ ...query, body }, datasetId, "total_events"); - } - }, - { - Header: 'Total Events (Yesterday)', - disableFilters: true, - Cell: ({ value, cell }: any) => { - const row = cell?.row?.original || {}; - const isMasterDataset = _.get(row, 'type') === DatasetType.MasterDataset; - const datasetId = row?.dataset_id; - const startDate = dayjs().subtract(1, 'day').format(dateFormat); - const endDate = dayjs().format(dateFormat); - const body = druidQueries.total_events_processed({ datasetId, intervals: `${startDate}/${endDate}`, master: isMasterDataset, }) - const query = _.get(chartMeta, 'total_events_processed.query'); - if (row?.onlyTag) return null; - return AsyncColumnData({ ...query, body }, datasetId, "total_events_yesterday"); - } - }, - { - Header: 'Avg Processing Time (Today)', - disableFilters: true, - Cell: ({ value, cell }: any) => { - const row = cell?.row?.original || {}; - const isMasterDataset = _.get(row, 'type') === DatasetType.MasterDataset; - const datasetId = row?.dataset_id; - const startDate = dayjs().format(dateFormat); - const endDate = dayjs().add(1, 'day').format(dateFormat); - const body = druidQueries.druid_avg_processing_time({ datasetId, intervals: `${startDate}/${endDate}`, master: isMasterDataset, }) - const query = _.get(chartMeta, 'druid_avg_processing_time.query'); - if (row?.onlyTag) return null; - return AsyncColumnData({ ...query, body }, datasetId, "average_processing_time"); - } - }, - { - Header: 'Avg Processing Time (Yesterday)', - disableFilters: true, - Cell: ({ value, cell }: any) => { - const row = cell?.row?.original || {}; - const isMasterDataset = _.get(row, 'type') === DatasetType.MasterDataset; - const datasetId = row?.dataset_id; - const startDate = dayjs().subtract(1, 'day').format(dateFormat); - const endDate = dayjs().format(dateFormat); - const body = druidQueries.druid_avg_processing_time({ datasetId, intervals: `${startDate}/${endDate}`, master: isMasterDataset, }) - const query = _.get(chartMeta, 'druid_avg_processing_time.query'); - if (row?.onlyTag) return null; - return AsyncColumnData({ ...query, body }, datasetId, "average_processing_time_yesterday"); - } - }, - { - Header: 'Last Synced Time', - disableFilters: true, - Cell: ({ value, cell }: any) => { - const row = cell?.row?.original || {}; - const isMasterDataset = _.get(row, 'type') === DatasetType.MasterDataset; - const datasetId = row?.dataset_id; - const startDate = dayjs().subtract(10, 'day').format(dateFormat); - const endDate = dayjs().add(1, 'day').format(dateFormat); - const body = druidQueries.last_synced_time({ datasetId, intervals: `${startDate}/${endDate}`, master: isMasterDataset, }) - const query = _.get(chartMeta, 'last_synced_relative_time.query'); - if (row?.onlyTag) return null; - return AsyncColumnData({ ...query, body }, datasetId, "last_synced_time"); - } - }, - { - Header: 'Event Failed (Today)', - disableFilters: true, - Cell: ({ value, cell }: any) => { - const row = cell?.row?.original || {}; - const isMasterDataset = _.get(row, 'type') === DatasetType.MasterDataset; - const datasetId = _.get(row, 'dataset_id'); - const endDate = dayjs().endOf('day').unix(); - const query = isMasterDataset ? - _.get(chartMeta, 'failed_events_summary_master_datasets.query') : - _.get(chartMeta, 'failed_events_summary.query'); - if (row?.onlyTag) return null; - return AsyncColumnData({ ...query, time: endDate, dataset: datasetId, master: isMasterDataset, }, datasetId, "events_failed"); - } - }, - { - Header: 'Actions', - accessor: 'color', - disableFilters: true, - Cell: ({ value, cell }: any) => { - const row = cell?.row?.original || {}; - if (row?.onlyTag) return null; - const isMaster: boolean = row?.type == DatasetType.MasterDataset; - const fileName = `${row?.name}_${row?.status}_${row?.version}`; - return - navigateToPath(`/datasets/view/${row?.dataset_id}?master=${isMaster}&status=${DatasetStatus.Live}`)}> - - - - - navigateToPath(`/datasets/metrics/${row?.dataset_id}`)}> - - < DashboardOutlined /> - - - - handleClick(e, row)} - disabled={true} - > - - - - - - - - } - } - ], - [] - ); + case DatasetStatus.Draft: return + + - const retireDataset = async () => { - if (selection) { - setLoading(true); - try { - await retireLiveDataset({ id: _.get(selection, "dataset_id") }) - setDatasetType(DatasetStatus.Retired) - navigateToPath(`?status=${DatasetStatus.Retired}`) - showAlert("Dataset retired successfully", "success"); + case DatasetStatus.Retired: return + + - } catch (err: any) { - const errMessage = _.get(err, 'response.data.params.errmsg') || en["dataset-retire-failure"]; - showAlert(errMessage, "error"); - } finally { - getDatasets(); - setLoading(false); - setSelection(null) - } + default: return renderNoDatasetsMessage("No Datasets"); } } - const handleRetire = (datasetPayload: Record) => { - setSelection(datasetPayload) - setOpenAlertDialog(true) - } - const handleEdit = (datasetPayload: Record) => { - setSelection(datasetPayload) - setOpenAlertDialog(true) + const datasetsTab = [ + { id: DatasetStatus.Live, label: , color: "success", tooltip: }, + { id: DatasetStatus.ReadyToPublish, label: , color: "info", tooltip: }, + { id: DatasetStatus.Draft, label: , color: "warning", tooltip: }, + { id: DatasetStatus.Retired, label: , color: "error", tooltip: } + ] + + const actions = [{ + id: "import", + label: , + icon: , + onClick: handleOpen, + disabled: false + }, { + id: "add-dataset", + label: , + onClick: () => navigate(`/dataset/create`), + icon: , + disabled: false + }] + + const renderDatasetTables = () => { + return <> + {renderDatasets(DatasetStatus.Live)} + {renderDatasets(DatasetStatus.ReadyToPublish)} + {renderDatasets(DatasetStatus.Draft)} + {renderDatasets(DatasetStatus.Retired)} + {renderDatasets(DatasetStatus.Purged)} + } - const handleClose = (status: boolean) => { - setOpenAlertDialog(false) + const renderDatasetActions = (action: Record) => { + const { id, label, onClick, disabled, icon } = action; + return } - const handlePopClose = () => { - setAnchorEl(null); + const renderDatasetTableHeaders = (field: Record) => { + const { id, label, color, tooltip } = field; + return + + + {label} + + } value={id} /> } - const handleClick = (event: React.MouseEvent, dataset: any) => { - setAnchorEl(event.currentTarget); - setTagSelection(dataset); - }; - - const editLiveDataset = async () => { - setOpenAlertDialog(true) - const response = await createDraftversion({ selection: _.get(selection, "dataset_id") || "", navigateToPath, showAlert }) + const renderDatasetTabs = () => { + return + + + + + {_.map(datasetsTab, renderDatasetTableHeaders)} + + + {_.map(actions, renderDatasetActions)} + + + + + {renderDatasetTables()} + + + } return ( - - {loading ? renderSkeleton({ config: { type: "table", width: "100%" } }) : - <> - {_.isEmpty(data) ? renderNoDatasetsMessage(en['datasets-not-found']) : <> - - - - - - } - - } - - ); + + {renderDatasetTabs()} + + + + ) }; export default DatasetsList; diff --git a/web-console-v2/src/pages/DatasetListV1/draftDatasetsList.tsx b/web-console-v2/src/pages/DatasetListV1/draftDatasetsList.tsx index 23befd1f..89c149e9 100644 --- a/web-console-v2/src/pages/DatasetListV1/draftDatasetsList.tsx +++ b/web-console-v2/src/pages/DatasetListV1/draftDatasetsList.tsx @@ -24,7 +24,7 @@ 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 { getDraftSourceConfig, renderNoDatasetsMessage } from './datasetsList'; import { useAlert } from 'contexts/AlertContextProvider'; export const alertDialogContext = (datasetName: string = "") => ({ title: , content: }) diff --git a/web-console-v2/src/router/index.tsx b/web-console-v2/src/router/index.tsx index a0f96e43..44f5f769 100644 --- a/web-console-v2/src/router/index.tsx +++ b/web-console-v2/src/router/index.tsx @@ -14,8 +14,8 @@ import SelectConnectorPage from 'pages/SelectConnector/SelectConnector'; import ManageConnectorsPage from 'pages/ConnectorManagement/Manage/Manage'; import Dashboard from 'pages/Dashboard/Dashboard'; import IndividualMetricDashboards from 'pages/Dashboard/IndividualDashboardPage/IndividualDashboardPage'; -import DatasetCreateEvents from 'pages/DatasetListV1/createEvents'; -import ClusterHealth from 'pages/DatasetListV1/datasets'; +import DatasetCreateEvents from 'pages/DatasetListV1/DatasetCreateEvents'; +import DatasetListV1 from 'pages/DatasetListV1/datasetsList'; import StepperPage from 'pages/StepsPages/StepperPage'; import AlertRules from 'pages/alertManager/views/AlertRules'; import SystemAlerts from 'pages/alertManager/views/SystemRules'; @@ -81,7 +81,7 @@ 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: } From e638294ae087b13393de02933f062de5f0fa0c02 Mon Sep 17 00:00:00 2001 From: Harish Kumar Gangula Date: Thu, 21 Nov 2024 13:48:35 +0530 Subject: [PATCH 10/23] Rename datasetsDetails.tsx to DatasetsDetails.tsx --- .../DatasetListV1/{datasetsDetails.tsx => DatasetsDetails.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename web-console-v2/src/pages/DatasetListV1/{datasetsDetails.tsx => DatasetsDetails.tsx} (100%) diff --git a/web-console-v2/src/pages/DatasetListV1/datasetsDetails.tsx b/web-console-v2/src/pages/DatasetListV1/DatasetsDetails.tsx similarity index 100% rename from web-console-v2/src/pages/DatasetListV1/datasetsDetails.tsx rename to web-console-v2/src/pages/DatasetListV1/DatasetsDetails.tsx From ea7d738b4c6f847d7d811b80f7d3496d3b818ef5 Mon Sep 17 00:00:00 2001 From: Harish Kumar Gangula Date: Thu, 21 Nov 2024 13:53:34 +0530 Subject: [PATCH 11/23] Rename datasetsList.tsx to DatasetsList.tsx --- .../pages/DatasetListV1/{datasetsList.tsx => DatasetsList.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename web-console-v2/src/pages/DatasetListV1/{datasetsList.tsx => DatasetsList.tsx} (100%) diff --git a/web-console-v2/src/pages/DatasetListV1/datasetsList.tsx b/web-console-v2/src/pages/DatasetListV1/DatasetsList.tsx similarity index 100% rename from web-console-v2/src/pages/DatasetListV1/datasetsList.tsx rename to web-console-v2/src/pages/DatasetListV1/DatasetsList.tsx From 2715867c765b2018d32b976f6969ce5f036fa863 Mon Sep 17 00:00:00 2001 From: Harish Kumar Gangula Date: Thu, 21 Nov 2024 13:53:49 +0530 Subject: [PATCH 12/23] Rename draftDatasetsList.tsx to DraftDatasetsList.tsx --- .../{draftDatasetsList.tsx => DraftDatasetsList.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename web-console-v2/src/pages/DatasetListV1/{draftDatasetsList.tsx => DraftDatasetsList.tsx} (100%) diff --git a/web-console-v2/src/pages/DatasetListV1/draftDatasetsList.tsx b/web-console-v2/src/pages/DatasetListV1/DraftDatasetsList.tsx similarity index 100% rename from web-console-v2/src/pages/DatasetListV1/draftDatasetsList.tsx rename to web-console-v2/src/pages/DatasetListV1/DraftDatasetsList.tsx From e458ca6259023e193facebd7e9cf2ed608edb71c Mon Sep 17 00:00:00 2001 From: Harish Kumar Gangula Date: Thu, 21 Nov 2024 15:53:39 +0530 Subject: [PATCH 13/23] Rename endpoints.ts to Endpoints.ts --- web-console-v2/src/constants/{endpoints.ts => Endpoints.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename web-console-v2/src/constants/{endpoints.ts => Endpoints.ts} (100%) diff --git a/web-console-v2/src/constants/endpoints.ts b/web-console-v2/src/constants/Endpoints.ts similarity index 100% rename from web-console-v2/src/constants/endpoints.ts rename to web-console-v2/src/constants/Endpoints.ts From f7ff57055c4758e6ec6b3739fb6fe1e39e77a917 Mon Sep 17 00:00:00 2001 From: Harish Kumar Gangula Date: Fri, 22 Nov 2024 11:00:39 +0530 Subject: [PATCH 14/23] #I319: Removed some more code and renamed some files --- web-console-v2/package.json | 2 +- web-console-v2/src/pages/DatasetListV1/DatasetMetrics.tsx | 2 +- web-console-v2/src/pages/DatasetListV1/DatasetsList.tsx | 7 +++---- .../src/pages/DatasetListV1/DraftDatasetsList.tsx | 6 +----- web-console-v2/src/pages/DatasetListV1/LiveDatasets.tsx | 2 +- .../src/pages/DatasetListV1/ReadyToPublishDatasets.tsx | 4 ++-- web-console-v2/src/pages/DatasetListV1/RetiredDatasets.tsx | 3 +-- web-console-v2/src/router/index.tsx | 2 +- 8 files changed, 11 insertions(+), 17 deletions(-) diff --git a/web-console-v2/package.json b/web-console-v2/package.json index 47406fa6..42e0d05c 100644 --- a/web-console-v2/package.json +++ b/web-console-v2/package.json @@ -53,7 +53,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/pages/DatasetListV1/DatasetMetrics.tsx b/web-console-v2/src/pages/DatasetListV1/DatasetMetrics.tsx index cbdac954..cedea602 100644 --- a/web-console-v2/src/pages/DatasetListV1/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/DatasetListV1/DatasetsList.tsx b/web-console-v2/src/pages/DatasetListV1/DatasetsList.tsx index 128bbab4..07a0a75b 100644 --- a/web-console-v2/src/pages/DatasetListV1/DatasetsList.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 LiveDatasets from './LiveDatasets'; -import DraftDatasetsList from './draftDatasetsList'; +import DraftDatasetsList from './DraftDatasetsList'; import useImpression from 'hooks/useImpression'; import pageIds from 'data/telemetry/pageIds'; import RetiredDatasets from './RetiredDatasets'; @@ -16,7 +16,6 @@ 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'; export const getLiveSourceConfig: any = (liveDataset: any, liveSourceConfigs: any) => { diff --git a/web-console-v2/src/pages/DatasetListV1/DraftDatasetsList.tsx b/web-console-v2/src/pages/DatasetListV1/DraftDatasetsList.tsx index 89c149e9..22245de6 100644 --- a/web-console-v2/src/pages/DatasetListV1/DraftDatasetsList.tsx +++ b/web-console-v2/src/pages/DatasetListV1/DraftDatasetsList.tsx @@ -15,17 +15,13 @@ import interactIds from 'data/telemetry/interact.json'; 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 './datasetsList'; 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/DatasetListV1/LiveDatasets.tsx b/web-console-v2/src/pages/DatasetListV1/LiveDatasets.tsx index a1854e76..add59716 100644 --- a/web-console-v2/src/pages/DatasetListV1/LiveDatasets.tsx +++ b/web-console-v2/src/pages/DatasetListV1/LiveDatasets.tsx @@ -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 './datasetsList'; +import { getLiveSourceConfig, renderNoDatasetsMessage } from './DatasetsList'; import { useAlert } from 'contexts/AlertContextProvider'; const dateFormat = 'YYYY-MM-DDT00:00:00+05:30' diff --git a/web-console-v2/src/pages/DatasetListV1/ReadyToPublishDatasets.tsx b/web-console-v2/src/pages/DatasetListV1/ReadyToPublishDatasets.tsx index 0a75d5f5..de2b6efd 100644 --- a/web-console-v2/src/pages/DatasetListV1/ReadyToPublishDatasets.tsx +++ b/web-console-v2/src/pages/DatasetListV1/ReadyToPublishDatasets.tsx @@ -21,8 +21,8 @@ import PostAddIcon from '@mui/icons-material/PostAdd'; import en from 'utils/locales/en.json'; import { DatasetStatus, DatasetType } from 'types/datasets'; import { downloadJsonFile } from 'utils/downloadUtils'; -import { alertDialogContext } from './draftDatasetsList'; -import { getDraftSourceConfig, renderNoDatasetsMessage } from './datasetsList'; +import { alertDialogContext } from './DraftDatasetsList'; +import { getDraftSourceConfig, renderNoDatasetsMessage } from './DatasetsList'; import { http } from 'services/http'; import apiEndpoints from 'constants/Endpoints'; import { useAlert } from 'contexts/AlertContextProvider'; diff --git a/web-console-v2/src/pages/DatasetListV1/RetiredDatasets.tsx b/web-console-v2/src/pages/DatasetListV1/RetiredDatasets.tsx index 84ca614f..b3928c20 100644 --- a/web-console-v2/src/pages/DatasetListV1/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 './datasetsList'; +import { getDraftSourceConfig, renderNoDatasetsMessage } from './DatasetsList'; import en from 'utils/locales/en.json'; import { useAlert } from 'contexts/AlertContextProvider'; diff --git a/web-console-v2/src/router/index.tsx b/web-console-v2/src/router/index.tsx index 44f5f769..3560af3c 100644 --- a/web-console-v2/src/router/index.tsx +++ b/web-console-v2/src/router/index.tsx @@ -15,7 +15,7 @@ import ManageConnectorsPage from 'pages/ConnectorManagement/Manage/Manage'; import Dashboard from 'pages/Dashboard/Dashboard'; import IndividualMetricDashboards from 'pages/Dashboard/IndividualDashboardPage/IndividualDashboardPage'; import DatasetCreateEvents from 'pages/DatasetListV1/DatasetCreateEvents'; -import DatasetListV1 from 'pages/DatasetListV1/datasetsList'; +import DatasetListV1 from 'pages/DatasetListV1/DatasetsList'; import StepperPage from 'pages/StepsPages/StepperPage'; import AlertRules from 'pages/alertManager/views/AlertRules'; import SystemAlerts from 'pages/alertManager/views/SystemRules'; From bd2158b18b7f678bda75621005b2da88672fa22e Mon Sep 17 00:00:00 2001 From: Harish Kumar Gangula Date: Fri, 22 Nov 2024 14:27:57 +0530 Subject: [PATCH 15/23] #I319: Change location of file --- .../datasetManagement/{components => }/DatasetManagement.tsx | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename web-console-v2/src/pages/datasetManagement/{components => }/DatasetManagement.tsx (100%) diff --git a/web-console-v2/src/pages/datasetManagement/components/DatasetManagement.tsx b/web-console-v2/src/pages/datasetManagement/DatasetManagement.tsx similarity index 100% rename from web-console-v2/src/pages/datasetManagement/components/DatasetManagement.tsx rename to web-console-v2/src/pages/datasetManagement/DatasetManagement.tsx From 98bfc5dd2726a813582e5e885bac8c4794008d2e Mon Sep 17 00:00:00 2001 From: Harish Kumar Gangula Date: Fri, 22 Nov 2024 14:47:09 +0530 Subject: [PATCH 16/23] #I319: Deleted unused old dataset view code --- .../DatasetListV1/DatasetCreateEvents.tsx | 2 +- .../src/pages/DatasetListV1/DatasetsList.tsx | 2 +- .../datasetManagement/DatasetManagement.tsx | 2 +- .../ReviewAllConfigurations/DataFormats.tsx | 71 ---------- .../ReviewAllConfigurations/Datakey.tsx | 35 ----- .../ReviewAllConfigurations/Datasource.tsx | 86 ------------ .../ReviewAllConfigurations/Deduplication.tsx | 35 ----- .../Denormalization.tsx | 99 -------------- .../TimestampField.tsx | 31 ----- .../Transformations.tsx | 95 ------------- .../ReviewAllConfigurations/Validation.tsx | 35 ----- .../ReviewAllConfigurations/ingestionSpec.tsx | 128 ------------------ .../ImportDataset.tsx | 0 .../ImportDialog.tsx | 0 .../ReviewAllConfigurations/index.tsx | 0 .../UploadFiles.tsx | 0 .../utils/PasteData.tsx | 0 .../utils/renderCells.tsx | 0 web-console-v2/src/router/index.tsx | 2 +- 19 files changed, 4 insertions(+), 619 deletions(-) delete mode 100644 web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/DataFormats.tsx delete mode 100644 web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Datakey.tsx delete mode 100644 web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Datasource.tsx delete mode 100644 web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Deduplication.tsx delete mode 100644 web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Denormalization.tsx delete mode 100644 web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/TimestampField.tsx delete mode 100644 web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Transformations.tsx delete mode 100644 web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/Validation.tsx delete mode 100644 web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/ingestionSpec.tsx rename web-console-v2/src/pages/{datasetV1 => datasetView}/ImportDataset.tsx (100%) rename web-console-v2/src/pages/{datasetV1 => datasetView}/ImportDialog.tsx (100%) rename web-console-v2/src/pages/{datasetV1 => datasetView}/ReviewAllConfigurations/index.tsx (100%) rename web-console-v2/src/pages/{datasetV1 => datasetView}/UploadFiles.tsx (100%) rename web-console-v2/src/pages/{datasetV1 => datasetView}/utils/PasteData.tsx (100%) rename web-console-v2/src/pages/{datasetV1 => datasetView}/utils/renderCells.tsx (100%) diff --git a/web-console-v2/src/pages/DatasetListV1/DatasetCreateEvents.tsx b/web-console-v2/src/pages/DatasetListV1/DatasetCreateEvents.tsx index 981e7605..f7f6d54c 100644 --- a/web-console-v2/src/pages/DatasetListV1/DatasetCreateEvents.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 'pages/datasetView/UploadFiles'; import { useState } from 'react'; import { useParams } from 'react-router'; import { datasetRead, sendEvents } from 'services/datasetV1'; diff --git a/web-console-v2/src/pages/DatasetListV1/DatasetsList.tsx b/web-console-v2/src/pages/DatasetListV1/DatasetsList.tsx index 07a0a75b..095d826f 100644 --- a/web-console-v2/src/pages/DatasetListV1/DatasetsList.tsx +++ b/web-console-v2/src/pages/DatasetListV1/DatasetsList.tsx @@ -16,7 +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 ImportDataset from 'pages/datasetV1/ImportDataset'; +import ImportDataset from 'pages/datasetView/ImportDataset'; export const getLiveSourceConfig: any = (liveDataset: any, liveSourceConfigs: any) => { const condition = (config: any) => { diff --git a/web-console-v2/src/pages/datasetManagement/DatasetManagement.tsx b/web-console-v2/src/pages/datasetManagement/DatasetManagement.tsx index c5179c3d..9dbaa724 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/ReviewAllConfigurations"; import { useAlert } from "contexts/AlertContextProvider"; import { getDatasetState } from "services/datasetV1"; import { margin } from "@mui/system"; 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/ImportDataset.tsx b/web-console-v2/src/pages/datasetView/ImportDataset.tsx similarity index 100% rename from web-console-v2/src/pages/datasetV1/ImportDataset.tsx rename to web-console-v2/src/pages/datasetView/ImportDataset.tsx diff --git a/web-console-v2/src/pages/datasetV1/ImportDialog.tsx b/web-console-v2/src/pages/datasetView/ImportDialog.tsx similarity index 100% rename from web-console-v2/src/pages/datasetV1/ImportDialog.tsx rename to web-console-v2/src/pages/datasetView/ImportDialog.tsx diff --git a/web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/index.tsx b/web-console-v2/src/pages/datasetView/ReviewAllConfigurations/index.tsx similarity index 100% rename from web-console-v2/src/pages/datasetV1/ReviewAllConfigurations/index.tsx rename to web-console-v2/src/pages/datasetView/ReviewAllConfigurations/index.tsx diff --git a/web-console-v2/src/pages/datasetV1/UploadFiles.tsx b/web-console-v2/src/pages/datasetView/UploadFiles.tsx similarity index 100% rename from web-console-v2/src/pages/datasetV1/UploadFiles.tsx rename to web-console-v2/src/pages/datasetView/UploadFiles.tsx diff --git a/web-console-v2/src/pages/datasetV1/utils/PasteData.tsx b/web-console-v2/src/pages/datasetView/utils/PasteData.tsx similarity index 100% rename from web-console-v2/src/pages/datasetV1/utils/PasteData.tsx rename to web-console-v2/src/pages/datasetView/utils/PasteData.tsx diff --git a/web-console-v2/src/pages/datasetV1/utils/renderCells.tsx b/web-console-v2/src/pages/datasetView/utils/renderCells.tsx similarity index 100% rename from web-console-v2/src/pages/datasetV1/utils/renderCells.tsx rename to web-console-v2/src/pages/datasetView/utils/renderCells.tsx diff --git a/web-console-v2/src/router/index.tsx b/web-console-v2/src/router/index.tsx index 3560af3c..3d9a4bad 100644 --- a/web-console-v2/src/router/index.tsx +++ b/web-console-v2/src/router/index.tsx @@ -26,7 +26,7 @@ import ListChannels from 'pages/notificationChannels/ListChannels'; import AddChannel from 'pages/notificationChannels/AddChannel'; import ViewChannel from 'pages/notificationChannels/ViewChannel'; import UpdateChannel from 'pages/notificationChannels/UpdateChannel'; -import DatasetManagement from 'pages/datasetManagement/components/DatasetManagement'; +import DatasetManagement from 'pages/datasetManagement/DatasetManagement'; import Loadable from 'pages/auth/components/Loadable'; // Type definition for the route configuration From 4003f2120cb0f5a39edb323789b1136acc17050f Mon Sep 17 00:00:00 2001 From: Harish Kumar Gangula Date: Fri, 22 Nov 2024 15:23:26 +0530 Subject: [PATCH 17/23] #I319: Rearranged and deleted some more files --- .../DatasetListV1/DatasetCreateEvents.tsx | 2 +- .../src/pages/DatasetListV1/DatasetsList.tsx | 2 +- .../ImportDataset.tsx | 2 +- .../ImportDialog.tsx | 0 .../utils => DatasetListV1}/PasteData.tsx | 0 .../UploadFiles.tsx | 2 +- .../datasetManagement/DatasetManagement.tsx | 2 +- .../{ReviewAllConfigurations => }/index.tsx | 0 .../pages/datasetView/utils/renderCells.tsx | 468 ------------------ 9 files changed, 5 insertions(+), 473 deletions(-) rename web-console-v2/src/pages/{datasetView => DatasetListV1}/ImportDataset.tsx (99%) rename web-console-v2/src/pages/{datasetView => DatasetListV1}/ImportDialog.tsx (100%) rename web-console-v2/src/pages/{datasetView/utils => DatasetListV1}/PasteData.tsx (100%) rename web-console-v2/src/pages/{datasetView => DatasetListV1}/UploadFiles.tsx (99%) rename web-console-v2/src/pages/datasetView/{ReviewAllConfigurations => }/index.tsx (100%) delete mode 100644 web-console-v2/src/pages/datasetView/utils/renderCells.tsx diff --git a/web-console-v2/src/pages/DatasetListV1/DatasetCreateEvents.tsx b/web-console-v2/src/pages/DatasetListV1/DatasetCreateEvents.tsx index f7f6d54c..478e5e87 100644 --- a/web-console-v2/src/pages/DatasetListV1/DatasetCreateEvents.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/datasetView/UploadFiles'; +import UploadFiles from './UploadFiles'; import { useState } from 'react'; import { useParams } from 'react-router'; import { datasetRead, sendEvents } from 'services/datasetV1'; diff --git a/web-console-v2/src/pages/DatasetListV1/DatasetsList.tsx b/web-console-v2/src/pages/DatasetListV1/DatasetsList.tsx index 095d826f..7b5ed147 100644 --- a/web-console-v2/src/pages/DatasetListV1/DatasetsList.tsx +++ b/web-console-v2/src/pages/DatasetListV1/DatasetsList.tsx @@ -16,7 +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 ImportDataset from 'pages/datasetView/ImportDataset'; +import ImportDataset from 'pages/DatasetListV1/ImportDataset'; export const getLiveSourceConfig: any = (liveDataset: any, liveSourceConfigs: any) => { const condition = (config: any) => { diff --git a/web-console-v2/src/pages/datasetView/ImportDataset.tsx b/web-console-v2/src/pages/DatasetListV1/ImportDataset.tsx similarity index 99% rename from web-console-v2/src/pages/datasetView/ImportDataset.tsx rename to web-console-v2/src/pages/DatasetListV1/ImportDataset.tsx index 96fd1006..92e64e6f 100644 --- a/web-console-v2/src/pages/datasetView/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/datasetView/ImportDialog.tsx b/web-console-v2/src/pages/DatasetListV1/ImportDialog.tsx similarity index 100% rename from web-console-v2/src/pages/datasetView/ImportDialog.tsx rename to web-console-v2/src/pages/DatasetListV1/ImportDialog.tsx diff --git a/web-console-v2/src/pages/datasetView/utils/PasteData.tsx b/web-console-v2/src/pages/DatasetListV1/PasteData.tsx similarity index 100% rename from web-console-v2/src/pages/datasetView/utils/PasteData.tsx rename to web-console-v2/src/pages/DatasetListV1/PasteData.tsx diff --git a/web-console-v2/src/pages/datasetView/UploadFiles.tsx b/web-console-v2/src/pages/DatasetListV1/UploadFiles.tsx similarity index 99% rename from web-console-v2/src/pages/datasetView/UploadFiles.tsx rename to web-console-v2/src/pages/DatasetListV1/UploadFiles.tsx index 339fa2bc..230f53d0 100644 --- a/web-console-v2/src/pages/datasetView/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/datasetManagement/DatasetManagement.tsx b/web-console-v2/src/pages/datasetManagement/DatasetManagement.tsx index 9dbaa724..af755602 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/datasetView/ReviewAllConfigurations"; +import ReviewAllCongurations from "pages/datasetView"; import { useAlert } from "contexts/AlertContextProvider"; import { getDatasetState } from "services/datasetV1"; import { margin } from "@mui/system"; diff --git a/web-console-v2/src/pages/datasetView/ReviewAllConfigurations/index.tsx b/web-console-v2/src/pages/datasetView/index.tsx similarity index 100% rename from web-console-v2/src/pages/datasetView/ReviewAllConfigurations/index.tsx rename to web-console-v2/src/pages/datasetView/index.tsx diff --git a/web-console-v2/src/pages/datasetView/utils/renderCells.tsx b/web-console-v2/src/pages/datasetView/utils/renderCells.tsx deleted file mode 100644 index 4663ab7e..00000000 --- a/web-console-v2/src/pages/datasetView/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 }; From bbd555674e1d236b7ec03c91ec6b16b9f74b7095 Mon Sep 17 00:00:00 2001 From: Harish Kumar Gangula Date: Fri, 22 Nov 2024 15:35:01 +0530 Subject: [PATCH 18/23] #I319: Rearranged files --- .../ConnectorConfiguration.module.css | 0 .../ConnectorConfiguration.tsx | 0 .../Ingestion/Constant.ts | 0 .../Ingestion/Ingestion.module.css | 0 .../Ingestion/Ingestion.tsx | 2 +- .../Ingestion/Schema.ts | 0 .../SchemaDetails/EditLiveDataset.tsx | 0 .../SchemaDetails/SchemaDetails.module.css | 0 .../Ingestion/SchemaDetails/SchemaDetails.tsx | 2 +- .../NewDataset/NewDataset.module.css | 0 .../NewDataset/NewDataset.test.tsx | 0 .../NewDataset/NewDataset.tsx | 0 .../Preview.tsx | 0 .../PreviewAndSave/AdditionSummary.tsx | 0 .../PreviewAndSave/AllConfigurations.tsx | 0 .../PreviewAndSave/DeletionSummary.tsx | 0 .../PreviewAndSave/Preview.module.css | 0 .../PreviewAndSave/Preview.tsx | 0 .../PreviewAndSave/PreviewSummary.tsx | 0 .../PreviewAndSave/UpdateSummary.tsx | 0 .../PreviewAndSave/response.ts | 0 .../Processing/Constant.ts | 0 .../Processing/Processing.module.css | 0 .../Processing/Processing.tsx | 0 .../AddTransformationExpression.tsx | 0 .../DataValidation/DataValidation.tsx | 0 .../ProcessingSection/DataValidation/Schema.ts | 0 .../DedupeEvent/DedupeEvent.tsx | 0 .../Denormalization/DataDenormalization.tsx | 0 .../Denormalization/Schema.ts | 0 .../ProcessingSection/Derived/AddNewField.tsx | 0 .../Processing/ProcessingSection/Pii/Pii.tsx | 0 .../ProcessingSection/ProcessingSection.tsx | 0 .../Processing/utils/dataTypeUtil.tsx | 0 .../ReUploadFiles.tsx | 8 ++++---- .../SelectConnector/FilterTypes.ts | 0 .../SelectConnector/SelectConnector.module.css | 0 .../SelectConnector/SelectConnector.test.tsx | 2 +- .../SelectConnector/SelectConnector.tsx | 0 .../StepperPage.tsx | 0 .../Storage/Storage.module.css | 0 .../Storage/Storage.tsx | 0 .../wizard => DatasetCreation}/UploadFiles.tsx | 0 web-console-v2/src/router/index.tsx | 18 +++++++++--------- 44 files changed, 16 insertions(+), 16 deletions(-) rename web-console-v2/src/pages/{ => DatasetCreation}/ConnectorConfiguration/ConnectorConfiguration.module.css (100%) rename web-console-v2/src/pages/{ => DatasetCreation}/ConnectorConfiguration/ConnectorConfiguration.tsx (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Ingestion/Constant.ts (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Ingestion/Ingestion.module.css (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Ingestion/Ingestion.tsx (99%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Ingestion/Schema.ts (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Ingestion/SchemaDetails/EditLiveDataset.tsx (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Ingestion/SchemaDetails/SchemaDetails.module.css (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Ingestion/SchemaDetails/SchemaDetails.tsx (99%) rename web-console-v2/src/pages/{ => DatasetCreation}/NewDataset/NewDataset.module.css (100%) rename web-console-v2/src/pages/{ => DatasetCreation}/NewDataset/NewDataset.test.tsx (100%) rename web-console-v2/src/pages/{ => DatasetCreation}/NewDataset/NewDataset.tsx (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Preview.tsx (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/PreviewAndSave/AdditionSummary.tsx (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/PreviewAndSave/AllConfigurations.tsx (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/PreviewAndSave/DeletionSummary.tsx (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/PreviewAndSave/Preview.module.css (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/PreviewAndSave/Preview.tsx (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/PreviewAndSave/PreviewSummary.tsx (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/PreviewAndSave/UpdateSummary.tsx (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/PreviewAndSave/response.ts (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Processing/Constant.ts (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Processing/Processing.module.css (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Processing/Processing.tsx (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Processing/ProcessingSection/AddTransformationExpression/AddTransformationExpression.tsx (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Processing/ProcessingSection/DataValidation/DataValidation.tsx (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Processing/ProcessingSection/DataValidation/Schema.ts (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Processing/ProcessingSection/DedupeEvent/DedupeEvent.tsx (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Processing/ProcessingSection/Denormalization/DataDenormalization.tsx (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Processing/ProcessingSection/Denormalization/Schema.ts (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Processing/ProcessingSection/Derived/AddNewField.tsx (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Processing/ProcessingSection/Pii/Pii.tsx (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Processing/ProcessingSection/ProcessingSection.tsx (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Processing/utils/dataTypeUtil.tsx (100%) rename web-console-v2/src/pages/{Dataset/wizard => DatasetCreation}/ReUploadFiles.tsx (97%) rename web-console-v2/src/pages/{ => DatasetCreation}/SelectConnector/FilterTypes.ts (100%) rename web-console-v2/src/pages/{ => DatasetCreation}/SelectConnector/SelectConnector.module.css (100%) rename web-console-v2/src/pages/{ => DatasetCreation}/SelectConnector/SelectConnector.test.tsx (96%) rename web-console-v2/src/pages/{ => DatasetCreation}/SelectConnector/SelectConnector.tsx (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/StepperPage.tsx (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Storage/Storage.module.css (100%) rename web-console-v2/src/pages/{StepsPages => DatasetCreation}/Storage/Storage.tsx (100%) rename web-console-v2/src/pages/{Dataset/wizard => DatasetCreation}/UploadFiles.tsx (100%) 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..723ff2fe 100644 --- a/web-console-v2/src/pages/StepsPages/Ingestion/Ingestion.tsx +++ b/web-console-v2/src/pages/DatasetCreation/Ingestion/Ingestion.tsx @@ -13,7 +13,7 @@ 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 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 100% rename from web-console-v2/src/pages/StepsPages/Ingestion/SchemaDetails/EditLiveDataset.tsx rename to web-console-v2/src/pages/DatasetCreation/Ingestion/SchemaDetails/EditLiveDataset.tsx 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..3cf9f46c 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'; 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 100% rename from web-console-v2/src/pages/NewDataset/NewDataset.tsx rename to web-console-v2/src/pages/DatasetCreation/NewDataset/NewDataset.tsx 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 100% rename from web-console-v2/src/pages/StepsPages/PreviewAndSave/Preview.tsx rename to web-console-v2/src/pages/DatasetCreation/PreviewAndSave/Preview.tsx 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 100% rename from web-console-v2/src/pages/StepsPages/Processing/Processing.tsx rename to web-console-v2/src/pages/DatasetCreation/Processing/Processing.tsx 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 100% 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 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 100% 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 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 100% 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 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 100% rename from web-console-v2/src/pages/StepsPages/Storage/Storage.tsx rename to web-console-v2/src/pages/DatasetCreation/Storage/Storage.tsx 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/router/index.tsx b/web-console-v2/src/router/index.tsx index 3d9a4bad..e21a0ce5 100644 --- a/web-console-v2/src/router/index.tsx +++ b/web-console-v2/src/router/index.tsx @@ -3,20 +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 Dashboard from 'pages/Dashboard/Dashboard'; import IndividualMetricDashboards from 'pages/Dashboard/IndividualDashboardPage/IndividualDashboardPage'; import DatasetCreateEvents from 'pages/DatasetListV1/DatasetCreateEvents'; import DatasetListV1 from 'pages/DatasetListV1/DatasetsList'; -import StepperPage from 'pages/StepsPages/StepperPage'; +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'; From e8cc596ef45ab3fd5ecda40413e421b58d73e1ea Mon Sep 17 00:00:00 2001 From: Harish Kumar Gangula Date: Fri, 22 Nov 2024 17:08:42 +0530 Subject: [PATCH 19/23] #I319: Rearranged files --- web-console-v2/src/components/EditDataset/EditDataset.tsx | 6 +++--- .../src/pages/DatasetCreation/Ingestion/Ingestion.tsx | 2 +- .../src/pages/DatasetCreation/Processing/Processing.tsx | 2 +- .../AddTransformationExpression.tsx | 2 +- .../Denormalization/DataDenormalization.tsx | 3 +-- .../Processing/ProcessingSection/Derived/AddNewField.tsx | 2 +- .../src/pages/DatasetCreation/Storage/Storage.tsx | 2 +- web-console-v2/src/pages/datasetView/index.tsx | 2 +- 8 files changed, 10 insertions(+), 11 deletions(-) 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/pages/DatasetCreation/Ingestion/Ingestion.tsx b/web-console-v2/src/pages/DatasetCreation/Ingestion/Ingestion.tsx index 723ff2fe..3c2d15a1 100644 --- a/web-console-v2/src/pages/DatasetCreation/Ingestion/Ingestion.tsx +++ b/web-console-v2/src/pages/DatasetCreation/Ingestion/Ingestion.tsx @@ -12,7 +12,7 @@ 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 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'; diff --git a/web-console-v2/src/pages/DatasetCreation/Processing/Processing.tsx b/web-console-v2/src/pages/DatasetCreation/Processing/Processing.tsx index 6a91d162..6e7c1a54 100644 --- a/web-console-v2/src/pages/DatasetCreation/Processing/Processing.tsx +++ b/web-console-v2/src/pages/DatasetCreation/Processing/Processing.tsx @@ -3,7 +3,7 @@ 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 _, { mapKeys } from 'lodash'; import AccordionSection from 'components/Accordian/AccordionSection'; diff --git a/web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/AddTransformationExpression/AddTransformationExpression.tsx b/web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/AddTransformationExpression/AddTransformationExpression.tsx index 42a694fa..d8c42501 100644 --- a/web-console-v2/src/pages/DatasetCreation/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/DatasetCreation/Processing/ProcessingSection/Denormalization/DataDenormalization.tsx b/web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/Denormalization/DataDenormalization.tsx index 2c0f4969..c039041d 100644 --- a/web-console-v2/src/pages/DatasetCreation/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/DatasetCreation/Processing/ProcessingSection/Derived/AddNewField.tsx b/web-console-v2/src/pages/DatasetCreation/Processing/ProcessingSection/Derived/AddNewField.tsx index 55198729..f41b35ff 100644 --- a/web-console-v2/src/pages/DatasetCreation/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/DatasetCreation/Storage/Storage.tsx b/web-console-v2/src/pages/DatasetCreation/Storage/Storage.tsx index fb39dda9..cad2acd6 100644 --- a/web-console-v2/src/pages/DatasetCreation/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'; diff --git a/web-console-v2/src/pages/datasetView/index.tsx b/web-console-v2/src/pages/datasetView/index.tsx index aaf80a35..2d1a40a0 100644 --- a/web-console-v2/src/pages/datasetView/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'; From f72d2fcc8ad74fa60243619a6db8bb72db237dfa Mon Sep 17 00:00:00 2001 From: Harish Kumar Gangula Date: Fri, 22 Nov 2024 17:20:22 +0530 Subject: [PATCH 20/23] #I319: Rearranged files --- web-console-v2/src/Chip.ts | 89 ------------------- .../DatasetMetricsCard/DatasetMetricsCard.tsx | 4 +- .../Dashboard}/analytics/ChartFilters.tsx | 0 .../Dashboard}/analytics/GrafanaEmbedded.tsx | 0 .../Dashboard}/analytics/IngestionCharts.tsx | 0 .../Dashboard}/analytics/apex.tsx | 0 .../Dashboard}/analytics/guageChart.tsx | 0 .../analytics/objectProcessedStatus.tsx | 0 .../src/pages/Dashboard/metrics.tsx | 8 +- .../Dashboard}/widgets/Cluster.tsx | 4 +- .../Dashboard}/widgets/ClusterMetrics.tsx | 0 .../Dashboard}/widgets/ClusterNodes.tsx | 4 +- .../widgets/HoursSinceLastBackup.tsx | 0 .../pages/DatasetListV1/DatasetsDetails.tsx | 4 +- .../alertManager/components/RunQuery.tsx | 2 +- 15 files changed, 12 insertions(+), 103 deletions(-) delete mode 100644 web-console-v2/src/Chip.ts rename web-console-v2/src/{sections/dashboard => pages/Dashboard}/analytics/ChartFilters.tsx (100%) rename web-console-v2/src/{sections/dashboard => pages/Dashboard}/analytics/GrafanaEmbedded.tsx (100%) rename web-console-v2/src/{sections/dashboard => pages/Dashboard}/analytics/IngestionCharts.tsx (100%) rename web-console-v2/src/{sections/dashboard => pages/Dashboard}/analytics/apex.tsx (100%) rename web-console-v2/src/{sections/dashboard => pages/Dashboard}/analytics/guageChart.tsx (100%) rename web-console-v2/src/{sections/dashboard => pages/Dashboard}/analytics/objectProcessedStatus.tsx (100%) rename web-console-v2/src/{sections => pages/Dashboard}/widgets/Cluster.tsx (93%) rename web-console-v2/src/{sections => pages/Dashboard}/widgets/ClusterMetrics.tsx (100%) rename web-console-v2/src/{sections => pages/Dashboard}/widgets/ClusterNodes.tsx (94%) rename web-console-v2/src/{sections => pages/Dashboard}/widgets/HoursSinceLastBackup.tsx (100%) 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/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/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 100% rename from web-console-v2/src/sections/dashboard/analytics/GrafanaEmbedded.tsx rename to web-console-v2/src/pages/Dashboard/analytics/GrafanaEmbedded.tsx 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/DatasetListV1/DatasetsDetails.tsx b/web-console-v2/src/pages/DatasetListV1/DatasetsDetails.tsx index f191e4d3..b17671c5 100644 --- a/web-console-v2/src/pages/DatasetListV1/DatasetsDetails.tsx +++ b/web-console-v2/src/pages/DatasetListV1/DatasetsDetails.tsx @@ -9,8 +9,8 @@ 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/alertManager/components/RunQuery.tsx b/web-console-v2/src/pages/alertManager/components/RunQuery.tsx index 378f05c8..c15383cc 100644 --- a/web-console-v2/src/pages/alertManager/components/RunQuery.tsx +++ b/web-console-v2/src/pages/alertManager/components/RunQuery.tsx @@ -3,7 +3,7 @@ import { Grid, Stack } from "@mui/material"; import _ from 'lodash'; import dayjs from 'dayjs'; import endpoints from 'constants/Endpoints'; -import ApexChart from "sections/dashboard/analytics/apex"; +import ApexChart from "pages/Dashboard/analytics/apex"; import { Button } from "@mui/material"; import { CloseOutlined } from "@ant-design/icons"; import { useEffect, useState } from "react"; From 0dedb2d03443038ded9588fbccc8bc50fbe61523 Mon Sep 17 00:00:00 2001 From: Harish Kumar Gangula Date: Fri, 22 Nov 2024 18:29:20 +0530 Subject: [PATCH 21/23] #I319: updated the code --- .../src/pages/auth/components/logo/index.tsx | 2 - web-console-v2/src/services/alerts.ts | 48 ++++--------------- 2 files changed, 10 insertions(+), 40 deletions(-) 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/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 From 96e2f24aa2355ad80dd862dd4f5f9833af19993f Mon Sep 17 00:00:00 2001 From: Harish Kumar Gangula Date: Mon, 25 Nov 2024 11:32:15 +0530 Subject: [PATCH 22/23] #I319: Removed config details --- .../src/components/Navbar/Navbar.tsx | 6 +++--- .../IndividualDashboardPage.tsx | 5 ++--- .../Dashboard/analytics/GrafanaEmbedded.tsx | 4 ++-- .../SchemaDetails/EditLiveDataset.tsx | 2 +- .../Ingestion/SchemaDetails/SchemaDetails.tsx | 1 - .../DatasetCreation/NewDataset/NewDataset.tsx | 3 --- .../src/pages/auth/components/AuthLogin.tsx | 4 ++-- .../auth/components/LoginSocialButton.tsx | 4 ++-- web-console-v2/src/services/configData.ts | 18 ++++++------------ ...connector-utils.tsx => connectorUtils.tsx} | 0 web-console-v2/src/services/dataset.ts | 19 ++++--------------- web-console-v2/src/services/grafana.ts | 4 ++-- web-console-v2/src/services/telemetry.ts | 4 ++-- web-console-v2/src/services/utils.ts | 16 ++-------------- 14 files changed, 28 insertions(+), 62 deletions(-) rename web-console-v2/src/services/{connector-utils.tsx => connectorUtils.tsx} (100%) diff --git a/web-console-v2/src/components/Navbar/Navbar.tsx b/web-console-v2/src/components/Navbar/Navbar.tsx index 021732ee..eb4fa42d 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'; @@ -147,10 +147,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/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/analytics/GrafanaEmbedded.tsx b/web-console-v2/src/pages/Dashboard/analytics/GrafanaEmbedded.tsx index d412fb7e..2f071613 100644 --- a/web-console-v2/src/pages/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/pages/DatasetCreation/Ingestion/SchemaDetails/EditLiveDataset.tsx b/web-console-v2/src/pages/DatasetCreation/Ingestion/SchemaDetails/EditLiveDataset.tsx index cc3d98f3..a376764e 100644 --- a/web-console-v2/src/pages/DatasetCreation/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/DatasetCreation/Ingestion/SchemaDetails/SchemaDetails.tsx b/web-console-v2/src/pages/DatasetCreation/Ingestion/SchemaDetails/SchemaDetails.tsx index 3cf9f46c..d74d8591 100644 --- a/web-console-v2/src/pages/DatasetCreation/Ingestion/SchemaDetails/SchemaDetails.tsx +++ b/web-console-v2/src/pages/DatasetCreation/Ingestion/SchemaDetails/SchemaDetails.tsx @@ -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/DatasetCreation/NewDataset/NewDataset.tsx b/web-console-v2/src/pages/DatasetCreation/NewDataset/NewDataset.tsx index b533e89a..6938ce37 100644 --- a/web-console-v2/src/pages/DatasetCreation/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/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/services/configData.ts b/web-console-v2/src/services/configData.ts index 69cf6c4a..3f34a455 100644 --- a/web-console-v2/src/services/configData.ts +++ b/web-console-v2/src/services/configData.ts @@ -14,25 +14,19 @@ export const fetchSystemSettings = async () => { } } -export const getConfigValueV1 = (variable: string) => { +export const getSystemSetting = (variable: string) => { const config: string | any = fetchLocalStorageItem('systemSettings'); return _.get(config, variable); }; -export const getConfigValue = (variable: string) => { - const config: string | any = fetchLocalStorageItem('configDetails'); - return _.get(config, variable); -}; - export const setVersionKey = (value: string) => { - const config = fetchLocalStorageItem('configDetails') || {}; - - _.set(config, 'version_key', value); - - return storeLocalStorageItem('configDetails', 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 55deae38..9415fb25 100644 --- a/web-console-v2/src/services/dataset.ts +++ b/web-console-v2/src/services/dataset.ts @@ -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') - }; - - storeLocalStorageItem(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 = fetchLocalStorageItem('configDetails') || {}; + const version_key = fetchLocalStorageItem('version_key') || {}; const request = generateRequestBody({ request: { ...data, - ..._.pick(configDetail, ['version_key']) + version_key }, apiId: 'api.datasets.update' }); @@ -238,11 +232,6 @@ const omitSuggestions = (schema: any): any => { return schema; } -export const getConfigValue = (variable: string) => { - const config: string | any = fetchLocalStorageItem('systemSettings'); - return _.get(config, variable); -}; - export const datasetRead = ({ datasetId, config = {} }: any) => { return http.get(`${ENDPOINTS.DATASETS_READ}/${datasetId}`, { ...config 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/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 9aa7ac49..ea03bdf1 100644 --- a/web-console-v2/src/services/utils.ts +++ b/web-console-v2/src/services/utils.ts @@ -112,26 +112,14 @@ export const setVersionKey = (value: number) => { if(!value) { return; } - const configDetailKey = 'configDetails'; - - const configDetail = fetchLocalStorageItem(configDetailKey) || {}; - - _.set(configDetail, 'version_key', String(value)); - - storeLocalStorageItem(configDetailKey, configDetail); + storeLocalStorageItem('version_key', String(value)); }; export const setDatasetId = (value: number) => { if(!value) { return; } - const configDetailKey = 'configDetails'; - - const configDetail = fetchLocalStorageItem(configDetailKey) || {}; - - _.set(configDetail, 'dataset_id', String(value)); - - storeLocalStorageItem(configDetailKey, configDetail); + storeLocalStorageItem('dataset_id', String(value)); }; export const transformResponse = (response: AxiosResponse) => _.get(response, ['data', 'result']); From c9f4c9f637e5a8e7a8b98a6509982dc710534164 Mon Sep 17 00:00:00 2001 From: Harish Kumar Gangula Date: Mon, 25 Nov 2024 14:42:52 +0530 Subject: [PATCH 23/23] #I319: 404 page added --- .../src/components/Navbar/Navbar.tsx | 1 + .../src/pages/NotFound/NotFound.module.css | 13 +++++++++ .../src/pages/NotFound/NotFound.tsx | 27 +++++++++++++++++++ web-console-v2/src/router/index.tsx | 5 +++- 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 web-console-v2/src/pages/NotFound/NotFound.module.css create mode 100644 web-console-v2/src/pages/NotFound/NotFound.tsx diff --git a/web-console-v2/src/components/Navbar/Navbar.tsx b/web-console-v2/src/components/Navbar/Navbar.tsx index eb4fa42d..fa8d9c79 100644 --- a/web-console-v2/src/components/Navbar/Navbar.tsx +++ b/web-console-v2/src/components/Navbar/Navbar.tsx @@ -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 }; 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/router/index.tsx b/web-console-v2/src/router/index.tsx index e21a0ce5..1fc31f71 100644 --- a/web-console-v2/src/router/index.tsx +++ b/web-console-v2/src/router/index.tsx @@ -28,6 +28,7 @@ import ViewChannel from 'pages/notificationChannels/ViewChannel'; import UpdateChannel from 'pages/notificationChannels/UpdateChannel'; import DatasetManagement from 'pages/datasetManagement/DatasetManagement'; import Loadable from 'pages/auth/components/Loadable'; +import { NotFound } from 'pages/NotFound/NotFound'; // Type definition for the route configuration interface RouteConfig { @@ -84,7 +85,9 @@ export const routeConfigurations: RouteConfig[] = [ { 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/view/:datasetId`, label: "View", element: }, + { path: '*', element: } + ]; const AppRouter = () => (