mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
Adjusted recreate action to recreate every managed component, including manager
Signed-off-by: SystemsPurge <naktiyoussef@proton.me>
This commit is contained in:
parent
3bad4e4509
commit
5fee4f3a9e
2 changed files with 21 additions and 9 deletions
|
@ -19,13 +19,13 @@ import { Form, Row, Col } from 'react-bootstrap';
|
|||
import DateTimePicker from 'react-datetime-picker';
|
||||
import ActionBoardButtonGroup from '../../common/buttons/action-board-button-group';
|
||||
import classNames from 'classnames';
|
||||
import { useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import { sessionToken } from '../../localStorage';
|
||||
import { clearCheckedICs, deleteIC, sendActionToIC } from '../../store/icSlice';
|
||||
import { clearCheckedICs, deleteIC, loadICbyId, sendActionToIC } from '../../store/icSlice';
|
||||
import { useGetICSQuery } from '../../store/apiSlice';
|
||||
|
||||
const ICActionBoard = (props) => {
|
||||
const ICActionBoard = ({externalICs}) => {
|
||||
const dispatch = useDispatch();
|
||||
const {refetch: refetchICs} = useGetICSQuery();
|
||||
const checkedICsIds = useSelector(state => state.infrastructure.checkedICsIds);
|
||||
|
@ -45,14 +45,26 @@ const ICActionBoard = (props) => {
|
|||
});
|
||||
}
|
||||
|
||||
const onRecreate = () => {
|
||||
const onRecreate =() => {
|
||||
console.log(externalICs)
|
||||
let newAction = {};
|
||||
newAction['action'] = 'create';
|
||||
newAction['when'] = time;
|
||||
|
||||
checkedICsIds.forEach((id) => {
|
||||
dispatch(sendActionToIC({token: sessionToken, id: id, actions: newAction}));
|
||||
});
|
||||
for (let checkedIC of checkedICsIds){
|
||||
let IC = externalICs.find(e=>{
|
||||
return e.id == checkedIC
|
||||
})
|
||||
if(IC){
|
||||
let manager = externalICs.find(e=>{
|
||||
return e.uuid == IC.manager
|
||||
})
|
||||
if(manager){
|
||||
newAction['parameters'] = IC.properties ? IC.properties : IC.statusupdateraw.properties
|
||||
dispatch(sendActionToIC({token:sessionToken,id:manager.id,actions:newAction}))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const onDelete = () => {
|
||||
|
|
|
@ -179,7 +179,7 @@ const Infrastructure = () => {
|
|||
category={"equipment"}
|
||||
/>
|
||||
|
||||
{currentUser.role === "Admin" ? <ICActionBoard /> : null}
|
||||
{currentUser.role === "Admin" ? <ICActionBoard externalICs={ics} /> : null}
|
||||
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue