[Feature Request] Toggle on/off data download
Provide an argument option for disabling the query data download buttons altogether.
Do you have any context for this request?
Context for this would be to provide pgweb running in a container in k8s to support ops of a system. Since data in the db should not leave the environment, disabling the buttons for export would be necessary.
Something like:
pgweb --disable-download --readonly
would startup pgweb with readonly access and either hide or disable the JSON/CSV/XML buttons. Removing API route to /export may be necessary as well if the API can be accessed directly.
Sounds reasonable, although i wont be able to give any ETAs for this request.
Thanks. Doesn't seem like it would take too much work as you are using gin serve up the web app.
Basic approach might be to switch over to templates directory instead of static and and wrap the button lines with templating conditionals, something like:
{{if .disableDownload }}
<input type="button" id="json" value="JSON" class="btn btn-sm btn-default" />
<input type="button" id="csv" value="CSV" class="btn btn-sm btn-default" />
<input type="button" id="xml" value="XML" class="btn btn-sm btn-default" />
{{end}}
in cli.go add:
func startServer() {
router := gin.Default()
// Load templates
router.LoadHTMLGlob("templates/*")
...
}
and then in the api.go changing getHome to:
// GetHome renders the home page
func GetHome(prefix string, disableDownload bool) http.Handler {
if prefix != "" {
prefix = "/" + prefix
}
return http.StripPrefix(prefix, c.HTML(http.StatusOk, "index.tmpl", gin.H{"disableDownload": disableDownload}))
}
and adding in routes.go, modifiying the the call to getHome to include the command option value:
I'd be happy to put this in a PR if you agree with methodology.
If you're interested in working on a PR then go ahead, i'm more than willing to accept quality contributions.
@jgerstle4u if you're still working on this, don't forget to also disable the endpoint server-side /api/export
Coming back to this features request - while disabling the download buttons makes more sense, there's still ability to download data via regular queries and saving the output on disk manually, so there's nothing really stops one from getting the data out.
Im gonna close unless there's interest.