From b3642f476267e60aa1fcd7b0c3fac9512f3754ad Mon Sep 17 00:00:00 2001 From: Ameer Dawood Date: Tue, 24 Jul 2018 00:41:33 +0500 Subject: [PATCH] luci-app-nlbwmon: add proper file names for json and csv exports. Currently, the json and csv exports are just named `data` which is not intuitive. This adds proper file name extensions using the Content-disposition HTTP header. Suggested-by: Ameer Dawood [slightly reword commit message, squash commits] Signed-off-by: Jo-Philipp Wich --- applications/luci-app-nlbwmon/luasrc/controller/nlbw.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/applications/luci-app-nlbwmon/luasrc/controller/nlbw.lua b/applications/luci-app-nlbwmon/luasrc/controller/nlbw.lua index a8c577929..72e87e8f9 100644 --- a/applications/luci-app-nlbwmon/luasrc/controller/nlbw.lua +++ b/applications/luci-app-nlbwmon/luasrc/controller/nlbw.lua @@ -57,6 +57,8 @@ function action_data() json = "application/json" } + local filename = "data." .. mtype + local args = { } local mtype = http.formvalue("type") or "json" local delim = http.formvalue("delim") or ";" @@ -92,6 +94,7 @@ function action_data() end http.prepare_content(types[mtype]) + http.header("Content-Disposition", "attachment; filename=\"%s\"" % filename) exec("/usr/sbin/nlbw", args, http.write) end -- 2.25.1