From 2a967303cb744861863ba5d65d300ec195b0fcf0 Mon Sep 17 00:00:00 2001 From: Arksine Date: Thu, 3 Sep 2020 21:01:38 -0400 Subject: [PATCH] test client: add support for websocket file delete Signed-off-by: Eric Callahan --- test/client/index.html | 4 ++-- test/client/js/main.js | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/test/client/index.html b/test/client/index.html index 7fbb7c2..8e962c1 100644 --- a/test/client/index.html +++ b/test/client/index.html @@ -2,7 +2,7 @@ - +

Klippy Web API Test

@@ -41,7 +41,7 @@




-

+

diff --git a/test/client/js/main.js b/test/client/js/main.js index 8a34319..6c488ec 100644 --- a/test/client/js/main.js +++ b/test/client/js/main.js @@ -86,6 +86,9 @@ var api = { delete: "server.files.delete_directory" } }, + delete_file: { + method: "server.files.delete_file" + }, upload: { url: "/server/files/upload" }, @@ -480,6 +483,19 @@ function get_metadata(file_name) { }); } +function delete_file(file_path) { + json_rpc.call_method_with_kwargs( + api.delete_file.method, {'path': file_path}) + .then((result) => { + // result is an "ok" acknowledgement that the + // print has started + console.log(result); + }) + .catch((error) => { + update_error(api.delete_file.method, error); + }); +} + function get_gcode_help() { json_rpc.call_method(api.gcode_help.method) .then((result) => { @@ -1046,7 +1062,8 @@ window.onload = () => { settings.headers = {"X-Api-Key": apikey}; $.ajax(settings); } else { - console.log("File Delete not supported over websocket") + let fname = file_list_type + "/" + filename; + delete_file(fname); } } });