mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
feat(site): implement site status management and update related components
This commit is contained in:
parent
402de5d987
commit
502b656bc5
12 changed files with 93 additions and 99 deletions
|
@ -28,11 +28,6 @@ func GetSite(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
enabled := true
|
||||
if _, err := os.Stat(nginx.GetConfPath("sites-enabled", name)); os.IsNotExist(err) {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
g := query.ChatGPTLog
|
||||
chatgpt, err := g.Where(g.Name.Eq(path)).FirstOrCreate()
|
||||
if err != nil {
|
||||
|
@ -63,15 +58,15 @@ func GetSite(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, Site{
|
||||
c.JSON(http.StatusOK, site.Site{
|
||||
ModifiedAt: file.ModTime(),
|
||||
Site: siteModel,
|
||||
Enabled: enabled,
|
||||
Name: name,
|
||||
Config: string(origContent),
|
||||
AutoCert: certModel.AutoCert == model.AutoCertEnabled,
|
||||
ChatGPTMessages: chatgpt.Content,
|
||||
Filepath: path,
|
||||
Status: site.GetSiteStatus(name),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
@ -96,10 +91,9 @@ func GetSite(c *gin.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, Site{
|
||||
c.JSON(http.StatusOK, site.Site{
|
||||
Site: siteModel,
|
||||
ModifiedAt: file.ModTime(),
|
||||
Enabled: enabled,
|
||||
Name: name,
|
||||
Config: nginxConfig.FmtCode(),
|
||||
Tokenized: nginxConfig,
|
||||
|
@ -107,6 +101,7 @@ func GetSite(c *gin.Context) {
|
|||
CertInfo: certInfoMap,
|
||||
ChatGPTMessages: chatgpt.Content,
|
||||
Filepath: path,
|
||||
Status: site.GetSiteStatus(name),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
package sites
|
||||
|
||||
import (
|
||||
"github.com/0xJacky/Nginx-UI/internal/cert"
|
||||
"github.com/0xJacky/Nginx-UI/internal/nginx"
|
||||
"github.com/0xJacky/Nginx-UI/model"
|
||||
"github.com/sashabaranov/go-openai"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Site struct {
|
||||
*model.Site
|
||||
Name string `json:"name"`
|
||||
ModifiedAt time.Time `json:"modified_at"`
|
||||
Enabled bool `json:"enabled"`
|
||||
Config string `json:"config"`
|
||||
AutoCert bool `json:"auto_cert"`
|
||||
ChatGPTMessages []openai.ChatCompletionMessage `json:"chatgpt_messages,omitempty"`
|
||||
Tokenized *nginx.NgxConfig `json:"tokenized,omitempty"`
|
||||
CertInfo map[int][]*cert.Info `json:"cert_info,omitempty"`
|
||||
Filepath string `json:"filepath"`
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue