summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-nlbwmon/luasrc/controller
diff options
context:
space:
mode:
authorAmeer Dawood <ameer1234567890@gmail.com>2018-07-24 00:41:33 +0500
committerJo-Philipp Wich <jo@mein.io>2018-09-29 14:59:42 +0200
commitb3642f476267e60aa1fcd7b0c3fac9512f3754ad (patch)
tree8b53fb96b415acfa4f888af7c3109f104cf975d5 /applications/luci-app-nlbwmon/luasrc/controller
parent32ee1873ac89f2bd510d8982d702e127fc19d39b (diff)
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 <ameer1234567890@gmail.com> [slightly reword commit message, squash commits] Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'applications/luci-app-nlbwmon/luasrc/controller')
-rw-r--r--applications/luci-app-nlbwmon/luasrc/controller/nlbw.lua3
1 files changed, 3 insertions, 0 deletions
diff --git a/applications/luci-app-nlbwmon/luasrc/controller/nlbw.lua b/applications/luci-app-nlbwmon/luasrc/controller/nlbw.lua
index a8c577929a..72e87e8f90 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