From 2a0713c2f8694a6c4040840581e5d76c05843631 Mon Sep 17 00:00:00 2001 From: rajdeep11 Date: Wed, 26 Apr 2023 16:48:19 +0530 Subject: [PATCH] adding delete feature group Issue-Id: AIMLFW-40 Change-Id: I9dba27c6fa92f388fefb2ead5ef202c1a79fee36 Signed-off-by: rajdeep11 --- src/components/home/status/API_STATUS.js | 21 +++++ src/components/home/status/ListFeatureGroup.js | 106 +++++++++++++++---------- 2 files changed, 87 insertions(+), 40 deletions(-) diff --git a/src/components/home/status/API_STATUS.js b/src/components/home/status/API_STATUS.js index bff08e7..b5aebe6 100644 --- a/src/components/home/status/API_STATUS.js +++ b/src/components/home/status/API_STATUS.js @@ -17,4 +17,25 @@ export const invokeStartTraining = async (trainingjobNames) => { catch(error){ console.log(error); } +}; + +export const deleteFeatureGroups = async (featureGroup_names) => { + console.log('deleting feature groups', featureGroup_names); + try { + let res = await axios.delete(`${CONSTANTS.UCMgr_baseUrl}/featureGroup`, + { + data: { + "featuregroups_list": featureGroup_names + } + + } + ); + console.log('Deletion response', res); + let result = 'FeatureGroup deletion initiated for selected featureGroups ,Result' + + '\n' + JSON.stringify(res.data); + alert(result); + + } catch (error) { + console.log("error is : ", error); + } }; \ No newline at end of file diff --git a/src/components/home/status/ListFeatureGroup.js b/src/components/home/status/ListFeatureGroup.js index 4e84556..b553e0e 100644 --- a/src/components/home/status/ListFeatureGroup.js +++ b/src/components/home/status/ListFeatureGroup.js @@ -25,6 +25,7 @@ import axios from 'axios'; import { Checkbox } from './Checkbox'; import Popup from './Popup'; import FeatureGroupInfo from './FeatureGroupInfo'; +import {deleteFeatureGroups} from './API_STATUS'; const ListFeatureGroup = (props) => { @@ -57,13 +58,37 @@ const ListFeatureGroup = (props) => { const handleInfoClick = (featuregroup_name) => { console.log("feature group name is : ", featuregroup_name) setFeatureGroupName({ - featureGroupName : featuregroup_name + featureGroupName: featuregroup_name }); setInfoPopup(true); - }; + }; + + const handleDelete = async (event) => { + console.log('handle delete starts..'); - const handleDme =(dme)=>{ - if(dme===true)return

Enabled

; + if (selectedFlatRows.length > 0) { + let featureGroup_names = []; + for (const row of selectedFlatRows) { + featureGroup_names.push({ + featureGroup_name: row.original.featuregroup_name + }) + } + console.log('selected featureGroups are :', featureGroup_names) + try { + await deleteFeatureGroups(featureGroup_names); + await fetchFeatureGroups(); + } catch (error) { + console.log(error) + } + toggleAllRowsSelected(false); + } else { + alert('Please select more than one row') + } + + } + + const handleDme = (dme) => { + if (dme === true) return

Enabled

; else return

Disabled

}; @@ -96,30 +121,30 @@ const ListFeatureGroup = (props) => { Header: 'DataLake', accessor: 'datalake' }, - { + { id: 'dme', Header: 'DME', accessor: 'dme', - Cell: ({row}) => { + Cell: ({ row }) => { return (
{handleDme(row.original.dme)}
- ); - } + ); + } }, { id: 'info', Header: 'Info', - Cell : ({row}) => { + Cell: ({ row }) => { return (
- +
- ); - } - } + ); + } + } ], []); const data = useMemo(() => featureGroups, [featureGroups]); const { @@ -139,34 +164,35 @@ const ListFeatureGroup = (props) => { ) return ( <> - - - {headerGroups.map(headerGroup => ( - - {headerGroup.headers.map(column => ( - - {column.render('Header')} - - ))} - - ))} - - - {rows.map((row, i) => { - prepareRow(row) - return ( - - {row.cells.map(cell => { - return ( - - {cell.render('Cell')} - - ) - })} + {' '} + + + {headerGroups.map(headerGroup => ( + + {headerGroup.headers.map(column => ( + + {column.render('Header')} + + ))} - ) - })} - + ))} + + + {rows.map((row, i) => { + prepareRow(row) + return ( + + {row.cells.map(cell => { + return ( + + {cell.render('Cell')} + + ) + })} + + ) + })} + -- 2.16.6