Closed Monviech closed 4 months ago
@fichtner Could you give this one a look? The part I'm unsure of, is if it violates coding guidelines to offer a button that directly redirects a user to an API endpoint. I can remove that.
The download button works as expected and everything uses the configd and API framework for security.
Gonna cook this one for a little while longer since I want to show the Caddyfile in a modal in that diagnostic view, too. It's the most important human readable file for quick troubleshooting and getting help from the caddy community.
I just have to find out how to funnel it through all the API stuff and leave the indentations, whitespaces, etc... all intact.
Does this look okay? I like it. (It's scrollable btw)
Now it is pretty good and fleshed out. The only thing that is not included since it would inflate the code a lot, is error handling for the download button. It is displayed to the user, that there is an error with the file, in the display area for the Caddyfile or the JSON.
If somebody clicks on download, it will download the file containing the error message.
Implementing flags to track all errors is kinda meh so I would rather just leave it at that, these validation edge cases almost never happen.
Also looks nice and responsive now and works like a charm on all sizes of displays, almost never hiding the buttons.
Nice work, merged. Thanks!
Adds a new Diagnostics view in which a download button can download the latest caddy configuration with timestamp.
The autosave.json file is used, since it's json, which makes it easy to validate that it is indeed valid json. Also, it includes all custom imports which users might have dropped into the filesystem, unlike the raw Caddyfile would.
The new API endpoint /api/caddy/diagnostics/showconfig can also be invoked, to show the json configuration in the Browser in real time. There is no view for that, to keep it simple. The API is only used for the Download button, and with a button that shows the json configuration in the browser.