From 970302106b98f753dec4efb2a1a18e5cf3dd0038 Mon Sep 17 00:00:00 2001 From: xavier-GitHub76 <82046143+xavier-GitHub76@users.noreply.github.com> Date: Wed, 8 Oct 2025 12:27:18 +0200 Subject: [PATCH] feat: delete/reset application image via ui Co-authored-by: Jannis Mattheis --- ui/src/application/AppStore.ts | 11 +++++++ ui/src/application/Applications.tsx | 47 ++++++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/ui/src/application/AppStore.ts b/ui/src/application/AppStore.ts index 9ffacb3..25c8bf1 100644 --- a/ui/src/application/AppStore.ts +++ b/ui/src/application/AppStore.ts @@ -39,6 +39,17 @@ export class AppStore extends BaseStore { this.snack('Application image updated'); }; + public async deleteImage(id: number): Promise { + try { + await axios.delete(`${config.get('url')}application/${id}/image`); + await this.refresh(); + this.snack('Application image deleted'); + } catch (error) { + console.error('Error deleting application image:', error); + throw error; + } + } + public update = async ( id: number, name: string, diff --git a/ui/src/application/Applications.tsx b/ui/src/application/Applications.tsx index 9161d82..e0d2be7 100644 --- a/ui/src/application/Applications.tsx +++ b/ui/src/application/Applications.tsx @@ -22,11 +22,35 @@ import {IApplication} from '../types'; import {LastUsedCell} from '../common/LastUsedCell'; import {useStores} from '../stores'; import {observer} from 'mobx-react-lite'; +import {makeStyles} from 'tss-react/mui'; +import {ButtonBase, Tooltip} from '@mui/material'; + +const useStyles = makeStyles()((theme) => ({ + imageContainer: { + '&::after': { + content: '"×"', + position: 'absolute', + top: 0, + left: 0, + width: 40, + height: 40, + background: theme.palette.error.main, + color: theme.palette.getContrastText(theme.palette.error.main), + fontSize: 40, + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + opacity: 0, + }, + '&:hover::after': {opacity: 1}, + }, +})); const Applications = observer(() => { const {appStore} = useStores(); const apps = appStore.getItems(); const [toDeleteApp, setToDeleteApp] = useState(); + const [toDeleteImage, setToDeleteImage] = useState(); const [toUpdateApp, setToUpdateApp] = useState(); const [createDialog, setCreateDialog] = useState(false); @@ -93,6 +117,7 @@ const Applications = observer(() => { value={app.token} lastUsed={app.lastUsed} fUpload={() => handleImageUploadClick(app.id)} + fDeleteImage={() => setToDeleteImage(app)} fDelete={() => setToDeleteApp(app)} fEdit={() => setToUpdateApp(app)} noDelete={app.internal} @@ -133,6 +158,14 @@ const Applications = observer(() => { fOnSubmit={() => appStore.remove(toDeleteApp.id)} /> )} + {toDeleteImage != null && ( + setToDeleteImage(undefined)} + fOnSubmit={() => appStore.deleteImage(toDeleteImage.id)} + /> + )} ); }); @@ -145,6 +178,7 @@ interface IRowProps { defaultPriority: number; lastUsed: string | null; fUpload: VoidFunction; + fDeleteImage: VoidFunction; image: string; fDelete: VoidFunction; fEdit: VoidFunction; @@ -159,14 +193,25 @@ const Row = ({ lastUsed, fDelete, fUpload, + fDeleteImage, image, fEdit, }: IRowProps) => { + const {classes} = useStyles(); return (
- app logo + + + app logo + +