Compare commits
3 Commits
48b19fbfd7
...
c50d17a497
Author | SHA1 | Date |
---|---|---|
Paolo Asperti | c50d17a497 | |
Paolo Asperti | af9d4b0c14 | |
Paolo Asperti | 923b589a00 |
|
@ -49,5 +49,5 @@ func main() {
|
||||||
- reboot/shutdown from web
|
- reboot/shutdown from web
|
||||||
- shutdown behavior
|
- shutdown behavior
|
||||||
- user management + roles (admin, port-reboot, port-on, port-off, readonly, ..) + api key
|
- user management + roles (admin, port-reboot, port-on, port-off, readonly, ..) + api key
|
||||||
|
- ups: username and password are required in webui
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,7 +1,18 @@
|
||||||
package webui
|
package webui
|
||||||
|
|
||||||
import "gopkg.in/macaron.v1"
|
import (
|
||||||
|
"path"
|
||||||
|
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
"gopkg.in/macaron.v1"
|
||||||
|
)
|
||||||
|
|
||||||
func backupPage(ctx *macaron.Context) {
|
func backupPage(ctx *macaron.Context) {
|
||||||
ctx.HTML(200, "backup")
|
ctx.HTML(200, "backup")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func backupDownload(ctx *macaron.Context) {
|
||||||
|
cfgFile := viper.ConfigFileUsed()
|
||||||
|
_, fileName := path.Split(cfgFile)
|
||||||
|
ctx.ServeFile(cfgFile, fileName)
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ func StartServer() {
|
||||||
m.Post("/ups", binding.Bind(UPSPostForm{}), upsPost)
|
m.Post("/ups", binding.Bind(UPSPostForm{}), upsPost)
|
||||||
m.Get("/syslog", syslogPage)
|
m.Get("/syslog", syslogPage)
|
||||||
m.Get("/backup", backupPage)
|
m.Get("/backup", backupPage)
|
||||||
|
m.Post("/backup", backupDownload)
|
||||||
m.Get("/json/status", jsonStatus)
|
m.Get("/json/status", jsonStatus)
|
||||||
m.Post("/json/outlet/:id/toggle", jsonOutletToggle)
|
m.Post("/json/outlet/:id/toggle", jsonOutletToggle)
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,19 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- /.box-header -->
|
<!-- /.box-header -->
|
||||||
|
|
||||||
|
<form class="form-horizontal" method="post">
|
||||||
|
<div class="box-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="port" class="col-sm-6 control-label">Configuration backup</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<button type="submit" class="btn btn-info" name="download">Download</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div> <!-- /.box-body -->
|
||||||
|
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue