From d023a2539f02ae268e675c530107c566163bd04f Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 1 Jan 2025 23:53:19 +0100 Subject: [PATCH] [#437] Added support for importing action dumps. --- .../components/panels/Application/Monitor.vue | 51 ++++++++++++++----- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/platypush/backend/http/webapp/src/components/panels/Application/Monitor.vue b/platypush/backend/http/webapp/src/components/panels/Application/Monitor.vue index bd6f1e956..09b9c03f0 100644 --- a/platypush/backend/http/webapp/src/components/panels/Application/Monitor.vue +++ b/platypush/backend/http/webapp/src/components/panels/Application/Monitor.vue @@ -12,7 +12,8 @@ - + + @@ -80,18 +81,19 @@ export default { }, actionsString() { - return this.outputStrings.join('\n') - }, - - actionsStrings() { - return Object.values(this.actions).map((item) => { - try { - return JSON.stringify(item) - } catch (err) { - // Already a string - return item - } - }) + return JSON.stringify( + Object.values(this.actions || []) + .sort((a, b) => a.started_at - b.started_at) + .map((item) => { + try { + return JSON.parse(item) + } catch (err) { + // Already a string + return item + } + } + ), null, 2 + ) }, serializedActions() { @@ -122,6 +124,29 @@ export default { URL.revokeObjectURL(url) }, + importActions() { + const input = document.createElement('input') + input.type = 'file' + input.accept = '.json' + input.onchange = async () => { + const file = input.files[0] + const reader = new FileReader() + reader.onload = async () => { + try { + this.actions = JSON.parse(reader.result) + } catch (err) { + this.notify({ + error: true, + title: 'Error importing actions', + text: err.toString(), + }) + } + } + reader.readAsText(file) + } + input.click() + }, + initWs() { try { const protocol = window.location.protocol === 'https:' ? 'wss' : 'ws'