From f85a1f885c8e28d63b9b9fc8e06f18cf83d73974 Mon Sep 17 00:00:00 2001 From: Jerke Combee Date: Sat, 2 Nov 2024 14:30:31 +0100 Subject: [PATCH] Add endpoint for listing all windows --- resources/js/electron-plugin/dist/server/api/window.js | 3 +++ resources/js/electron-plugin/src/server/api/window.ts | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/resources/js/electron-plugin/dist/server/api/window.js b/resources/js/electron-plugin/dist/server/api/window.js index a58329b0..4e41bf47 100644 --- a/resources/js/electron-plugin/dist/server/api/window.js +++ b/resources/js/electron-plugin/dist/server/api/window.js @@ -91,6 +91,9 @@ router.get('/current', (req, res) => { const id = Object.keys(state.windows).find(key => state.windows[key] === currentWindow); res.json(getWindowData(id)); }); +router.get('/all', (req, res) => { + res.json(Object.keys(state.windows).map(id => getWindowData(id))); +}); router.get('/get/:id', (req, res) => { const { id } = req.params; if (state.windows[id] === undefined) { diff --git a/resources/js/electron-plugin/src/server/api/window.ts b/resources/js/electron-plugin/src/server/api/window.ts index ecb4da71..08418c96 100644 --- a/resources/js/electron-plugin/src/server/api/window.ts +++ b/resources/js/electron-plugin/src/server/api/window.ts @@ -125,6 +125,12 @@ router.get('/current', (req, res) => { res.json(getWindowData(id)); }); +router.get('/all', (req, res) => { + res.json( + Object.keys(state.windows).map(id => getWindowData(id)) + ); +}); + router.get('/get/:id', (req, res) => { const {id} = req.params;