mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
feat: config history
This commit is contained in:
parent
771859d3b8
commit
57b8dfd2f9
15 changed files with 823 additions and 75 deletions
13
api/config/history.go
Normal file
13
api/config/history.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"github.com/0xJacky/Nginx-UI/model"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/uozi-tech/cosy"
|
||||
)
|
||||
|
||||
func GetConfigHistory(c *gin.Context) {
|
||||
cosy.Core[model.ConfigBackup](c).
|
||||
SetEqual("filepath").
|
||||
PagingList()
|
||||
}
|
|
@ -47,6 +47,12 @@ func EditConfig(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
err = config.CheckAndCreateHistory(absPath, content)
|
||||
if err != nil {
|
||||
cosy.ErrHandler(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
if content != "" && content != string(origContent) {
|
||||
err = os.WriteFile(absPath, []byte(content), 0644)
|
||||
if err != nil {
|
||||
|
|
|
@ -18,4 +18,6 @@ func InitRouter(r *gin.RouterGroup) {
|
|||
o.POST("config_mkdir", Mkdir)
|
||||
o.POST("config_rename", Rename)
|
||||
}
|
||||
|
||||
r.GET("config_histories", GetConfigHistory)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue