adding delete feature group 86/10986/1
authorrajdeep11 <rajdeep.sin@samsung.com>
Wed, 26 Apr 2023 11:18:19 +0000 (16:48 +0530)
committerrajdeep11 <rajdeep.sin@samsung.com>
Wed, 26 Apr 2023 11:18:19 +0000 (16:48 +0530)
Issue-Id: AIMLFW-40

Change-Id: I9dba27c6fa92f388fefb2ead5ef202c1a79fee36
Signed-off-by: rajdeep11 <rajdeep.sin@samsung.com>
src/components/home/status/API_STATUS.js
src/components/home/status/ListFeatureGroup.js

index bff08e7..b5aebe6 100644 (file)
@@ -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
index 4e84556..b553e0e 100644 (file)
@@ -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 <p>Enabled</p>;
+        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 <p>Enabled</p>;
         else return <p>Disabled</p>
     };
 
@@ -96,30 +121,30 @@ const ListFeatureGroup = (props) => {
             Header: 'DataLake',
             accessor: 'datalake'
         },
-        {   
+        {
             id: 'dme',
             Header: 'DME',
             accessor: 'dme',
-            Cell: ({row}) => {
+            Cell: ({ row }) => {
                 return (
                     <div >
                         {handleDme(row.original.dme)}
                     </div>
-                );   
-              }
+                );
+            }
 
         },
         {
             id: 'info',
             Header: 'Info',
-            Cell : ({row}) => {
+            Cell: ({ row }) => {
                 return (
                     <div>
-                <Button variant="info" onClick={() => handleInfoClick(row.original.featuregroup_name)}>Info</Button>
+                        <Button variant="info" onClick={() => handleInfoClick(row.original.featuregroup_name)}>Info</Button>
                     </div>
-                );   
-              }
-    }
+                );
+            }
+        }
     ], []);
     const data = useMemo(() => featureGroups, [featureGroups]);
     const {
@@ -139,34 +164,35 @@ const ListFeatureGroup = (props) => {
     )
     return (
         <>
-        <BTable className="Status_table" responsive striped bordered hover size="sm"  {...getTableProps()}>
-            <thead>
-                {headerGroups.map(headerGroup => (
-                    <tr {...headerGroup.getHeaderGroupProps()}>
-                        {headerGroup.headers.map(column => (
-                            <th {...column.getHeaderProps()}>
-                                {column.render('Header')}
-                            </th>
-                        ))}
-                    </tr>
-                ))}
-            </thead>
-            <tbody>
-                {rows.map((row, i) => {
-                    prepareRow(row)
-                    return (
-                        <tr {...row.getRowProps()}>
-                            {row.cells.map(cell => {
-                                return (
-                                    <th {...cell.getCellProps()}>
-                                        {cell.render('Cell')}
-                                    </th>
-                                )
-                            })}
+            <Button variant="success" size="sm" onClick={e => handleDelete(e)}>Delete</Button>{' '}
+            <BTable className="Status_table" responsive striped bordered hover size="sm"  {...getTableProps()}>
+                <thead>
+                    {headerGroups.map(headerGroup => (
+                        <tr {...headerGroup.getHeaderGroupProps()}>
+                            {headerGroup.headers.map(column => (
+                                <th {...column.getHeaderProps()}>
+                                    {column.render('Header')}
+                                </th>
+                            ))}
                         </tr>
-                    )
-                })}
-            </tbody>
+                    ))}
+                </thead>
+                <tbody>
+                    {rows.map((row, i) => {
+                        prepareRow(row)
+                        return (
+                            <tr {...row.getRowProps()}>
+                                {row.cells.map(cell => {
+                                    return (
+                                        <th {...cell.getCellProps()}>
+                                            {cell.render('Cell')}
+                                        </th>
+                                    )
+                                })}
+                            </tr>
+                        )
+                    })}
+                </tbody>
             </BTable>
             <Popup show={infoPopup} onHide={closeInfoPopup} title="Feature Group Info">
                 <FeatureGroupInfo featureGroupName={featureGroupName} />