From fe8cf2620d3e429cc9bcfb92ca016adfcae3271c Mon Sep 17 00:00:00 2001 From: proddy Date: Sun, 14 Jun 2026 17:03:52 +0200 Subject: [PATCH] show execute button in table --- interface/src/app/main/Commands.tsx | 32 +++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/interface/src/app/main/Commands.tsx b/interface/src/app/main/Commands.tsx index 4a20e1c39..c3f483260 100644 --- a/interface/src/app/main/Commands.tsx +++ b/interface/src/app/main/Commands.tsx @@ -4,9 +4,11 @@ import { toast } from 'react-toastify'; import AddIcon from '@mui/icons-material/Add'; import CancelIcon from '@mui/icons-material/Cancel'; +import PlayArrowIcon from '@mui/icons-material/PlayArrow'; import WarningIcon from '@mui/icons-material/Warning'; -import { Box, Button, Typography } from '@mui/material'; +import { Box, Button, IconButton, Typography } from '@mui/material'; +import { callAction } from '@/api/app'; import { Body, Cell, @@ -46,7 +48,7 @@ const DEFAULT_COMMAND_ITEM: Omit = { const commandsTheme = { Table: ` - --data-table-library_grid-template-columns: repeat(1, minmax(100px, 1fr)) repeat(1, minmax(100px, 1fr)) 160px; + --data-table-library_grid-template-columns: repeat(1, minmax(100px, 1fr)) repeat(1, minmax(100px, 1fr)) 160px 32px; `, BaseRow: ` font-size: 14px; @@ -141,6 +143,21 @@ const CommandsPage = () => { } }; + const { send: executeCommand } = useRequest( + (id: string) => callAction({ action: 'executeCommand', param: id }), + { immediate: false } + ) + .onSuccess(() => { + toast.success(LL.EXECUTE_COMMAND_SENT()); + }) + .onError((error) => { + toast.error(String(error.error?.message || 'An error occurred')); + }); + + const execute = async (name: string) => { + await executeCommand(name); + }; + const editItem = (ci: CommandItem) => { setCreating(false); setSelectedItem(ci); @@ -205,6 +222,7 @@ const CommandsPage = () => { {LL.COMMAND(0)} {LL.VALUE(0)} {LL.NAME(0)} + @@ -213,6 +231,16 @@ const CommandsPage = () => { {ci.cmd} {ci.value} {ci.name} + + {numChanges === 0 && ( + execute(ci.name)} + style={{ backgroundColor: 'transparent' }} + > + + + )} + ))}