mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
Added missing parameters when sending action to ic
Signed-off-by: Andrii Podriez <andrey5577990@gmail.com>
This commit is contained in:
parent
55a9254548
commit
270ae4de4b
2 changed files with 29 additions and 5 deletions
|
@ -35,7 +35,7 @@ import WidgetButton from './widgets/button';
|
|||
import WidgetInput from './widgets/input';
|
||||
import WidgetSlider from './widgets/slider';
|
||||
// import WidgetTopology from './widgets/topology';
|
||||
import WidgetPlayer from './widgets/player';
|
||||
import WidgetPlayer from './widgets/player.jsx';
|
||||
//import WidgetHTML from './widgets/html';
|
||||
import '../../../styles/widgets.css';
|
||||
import { useGetICSQuery, useGetSignalsQuery, useGetConfigsQuery } from '../../../store/apiSlice';
|
||||
|
|
|
@ -33,7 +33,7 @@ const ConfigActionBoard = ({selectedConfigs, scenarioID}) => {
|
|||
const [triggerGetSignals] = useLazyGetSignalsQuery();
|
||||
|
||||
const [sendAction] = useSendActionMutation();
|
||||
const [addResult] = useAddResultMutation();
|
||||
const [addResult, {isError: isErrorAddingResult}] = useAddResultMutation();
|
||||
//we only need to update results table in case new result being added
|
||||
const { refetch: refetchResults } = useGetResultsQuery(scenarioID);
|
||||
|
||||
|
@ -43,8 +43,14 @@ const ConfigActionBoard = ({selectedConfigs, scenarioID}) => {
|
|||
const handleConfigStart = async () => {
|
||||
for(const config of selectedConfigs){
|
||||
try {
|
||||
if(isResultRequested){
|
||||
const action = {
|
||||
icid: config.icID,
|
||||
action: "start",
|
||||
when: Math.round(new Date(time).getTime() / 1000),
|
||||
parameters: {...config.startParameters}
|
||||
}
|
||||
|
||||
if(isResultRequested){
|
||||
const signalsInRes = await triggerGetSignals({configID: config.id, direction: "in"}, ).unwrap();
|
||||
const signalsOutRes = await triggerGetSignals({configID: config.id, direction: "out"}, ).unwrap();
|
||||
|
||||
|
@ -73,10 +79,28 @@ const ConfigActionBoard = ({selectedConfigs, scenarioID}) => {
|
|||
}
|
||||
}
|
||||
|
||||
await addResult({result: newResult})
|
||||
//get result id (if successfull) before sending an action
|
||||
const res = await addResult({result: newResult}).unwrap();
|
||||
|
||||
if(!isErrorAddingResult){
|
||||
console.log("result", res)
|
||||
const url = window.location.origin;
|
||||
action.results = {
|
||||
url: `slew.k8s.eonerc.rwth-aachen.de/results/${res.result.id}/file`,
|
||||
type: "url",
|
||||
token: sessionToken
|
||||
}
|
||||
await sendAction(action).unwrap();
|
||||
} else {
|
||||
notificationsDataManager.addNotification(NotificationsFactory.LOAD_ERROR("Error adding result"));
|
||||
}
|
||||
|
||||
refetchResults();
|
||||
} else {
|
||||
await sendAction(action).unwrap();
|
||||
}
|
||||
await sendAction({ icid: config.icID, action: "start", when: Math.round(new Date(time).getTime() / 1000), parameters: {} }).unwrap();
|
||||
|
||||
notificationsDataManager.addNotification(NotificationsFactory.ACTION_INFO());
|
||||
} catch (err) {
|
||||
if(err.data){
|
||||
notificationsDataManager.addNotification(NotificationsFactory.LOAD_ERROR(err.data.message));
|
||||
|
|
Loading…
Add table
Reference in a new issue