mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
feat(site): add status filter #633
This commit is contained in:
parent
ef7be186c4
commit
0e1efd35fc
5 changed files with 33 additions and 18 deletions
|
@ -16,8 +16,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetDomains(c *gin.Context) {
|
func GetSiteList(c *gin.Context) {
|
||||||
name := c.Query("name")
|
name := c.Query("name")
|
||||||
|
enabled := c.Query("enabled")
|
||||||
orderBy := c.Query("order_by")
|
orderBy := c.Query("order_by")
|
||||||
sort := c.DefaultQuery("sort", "desc")
|
sort := c.DefaultQuery("sort", "desc")
|
||||||
|
|
||||||
|
@ -44,9 +45,19 @@ func GetDomains(c *gin.Context) {
|
||||||
file := configFiles[i]
|
file := configFiles[i]
|
||||||
fileInfo, _ := file.Info()
|
fileInfo, _ := file.Info()
|
||||||
if !file.IsDir() {
|
if !file.IsDir() {
|
||||||
|
// name filter
|
||||||
if name != "" && !strings.Contains(file.Name(), name) {
|
if name != "" && !strings.Contains(file.Name(), name) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// status filter
|
||||||
|
if enabled != "" {
|
||||||
|
if enabled == "true" && !enabledConfigMap[file.Name()] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if enabled == "false" && enabledConfigMap[file.Name()] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
configs = append(configs, config.Config{
|
configs = append(configs, config.Config{
|
||||||
Name: file.Name(),
|
Name: file.Name(),
|
||||||
ModifiedAt: fileInfo.ModTime(),
|
ModifiedAt: fileInfo.ModTime(),
|
||||||
|
@ -64,7 +75,7 @@ func GetDomains(c *gin.Context) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDomain(c *gin.Context) {
|
func GetSite(c *gin.Context) {
|
||||||
rewriteName, ok := c.Get("rewriteConfigFileName")
|
rewriteName, ok := c.Get("rewriteConfigFileName")
|
||||||
name := c.Param("name")
|
name := c.Param("name")
|
||||||
|
|
||||||
|
@ -164,7 +175,7 @@ func GetDomain(c *gin.Context) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func SaveDomain(c *gin.Context) {
|
func SaveSite(c *gin.Context) {
|
||||||
name := c.Param("name")
|
name := c.Param("name")
|
||||||
|
|
||||||
if name == "" {
|
if name == "" {
|
||||||
|
@ -256,10 +267,10 @@ func SaveDomain(c *gin.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GetDomain(c)
|
GetSite(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func EnableDomain(c *gin.Context) {
|
func EnableSite(c *gin.Context) {
|
||||||
configFilePath := nginx.GetConfPath("sites-available", c.Param("name"))
|
configFilePath := nginx.GetConfPath("sites-available", c.Param("name"))
|
||||||
enabledConfigFilePath := nginx.GetConfPath("sites-enabled", c.Param("name"))
|
enabledConfigFilePath := nginx.GetConfPath("sites-enabled", c.Param("name"))
|
||||||
|
|
||||||
|
@ -303,7 +314,7 @@ func EnableDomain(c *gin.Context) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func DisableDomain(c *gin.Context) {
|
func DisableSite(c *gin.Context) {
|
||||||
enabledConfigFilePath := nginx.GetConfPath("sites-enabled", c.Param("name"))
|
enabledConfigFilePath := nginx.GetConfPath("sites-enabled", c.Param("name"))
|
||||||
_, err := os.Stat(enabledConfigFilePath)
|
_, err := os.Stat(enabledConfigFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -338,7 +349,7 @@ func DisableDomain(c *gin.Context) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteDomain(c *gin.Context) {
|
func DeleteSite(c *gin.Context) {
|
||||||
var err error
|
var err error
|
||||||
name := c.Param("name")
|
name := c.Param("name")
|
||||||
availablePath := nginx.GetConfPath("sites-available", name)
|
availablePath := nginx.GetConfPath("sites-available", name)
|
||||||
|
|
|
@ -3,13 +3,13 @@ package sites
|
||||||
import "github.com/gin-gonic/gin"
|
import "github.com/gin-gonic/gin"
|
||||||
|
|
||||||
func InitRouter(r *gin.RouterGroup) {
|
func InitRouter(r *gin.RouterGroup) {
|
||||||
r.GET("domains", GetDomains)
|
r.GET("domains", GetSiteList)
|
||||||
r.GET("domain/:name", GetDomain)
|
r.GET("domain/:name", GetSite)
|
||||||
r.POST("domain/:name", SaveDomain)
|
r.POST("domain/:name", SaveSite)
|
||||||
r.POST("domain/:name/enable", EnableDomain)
|
r.POST("domain/:name/enable", EnableSite)
|
||||||
r.POST("domain/:name/disable", DisableDomain)
|
r.POST("domain/:name/disable", DisableSite)
|
||||||
r.POST("domain/:name/advance", DomainEditByAdvancedMode)
|
r.POST("domain/:name/advance", DomainEditByAdvancedMode)
|
||||||
r.DELETE("domain/:name", DeleteDomain)
|
r.DELETE("domain/:name", DeleteSite)
|
||||||
r.POST("domain/:name/duplicate", DuplicateSite)
|
r.POST("domain/:name/duplicate", DuplicateSite)
|
||||||
r.POST("auto_cert/:name", AddDomainToAutoCert)
|
r.POST("auto_cert/:name", AddDomainToAutoCert)
|
||||||
r.DELETE("auto_cert/:name", RemoveDomainFromAutoCert)
|
r.DELETE("auto_cert/:name", RemoveDomainFromAutoCert)
|
||||||
|
|
|
@ -67,6 +67,7 @@ onMounted(() => {
|
||||||
:default-active-first-option="false"
|
:default-active-first-option="false"
|
||||||
:mode="props.multiple ? 'multiple' : undefined"
|
:mode="props.multiple ? 'multiple' : undefined"
|
||||||
style="min-width: 180px"
|
style="min-width: 180px"
|
||||||
|
allow-clear
|
||||||
:get-popup-container="triggerNode => triggerNode.parentNode"
|
:get-popup-container="triggerNode => triggerNode.parentNode"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -4,7 +4,7 @@ import StdTable from '@/components/StdDesign/StdDataDisplay/StdTable.vue'
|
||||||
import type { customRender } from '@/components/StdDesign/StdDataDisplay/StdTableTransformer'
|
import type { customRender } from '@/components/StdDesign/StdDataDisplay/StdTableTransformer'
|
||||||
import { datetime } from '@/components/StdDesign/StdDataDisplay/StdTableTransformer'
|
import { datetime } from '@/components/StdDesign/StdDataDisplay/StdTableTransformer'
|
||||||
import domain from '@/api/domain'
|
import domain from '@/api/domain'
|
||||||
import { input } from '@/components/StdDesign/StdDataEntry'
|
import { input, select } from '@/components/StdDesign/StdDataEntry'
|
||||||
import SiteDuplicate from '@/views/site/components/SiteDuplicate.vue'
|
import SiteDuplicate from '@/views/site/components/SiteDuplicate.vue'
|
||||||
import InspectConfig from '@/views/config/InspectConfig.vue'
|
import InspectConfig from '@/views/config/InspectConfig.vue'
|
||||||
import type { Column, JSXElements } from '@/components/StdDesign/types'
|
import type { Column, JSXElements } from '@/components/StdDesign/types'
|
||||||
|
@ -35,6 +35,13 @@ const columns: Column[] = [{
|
||||||
|
|
||||||
return h('div', template)
|
return h('div', template)
|
||||||
},
|
},
|
||||||
|
search: {
|
||||||
|
type: select,
|
||||||
|
mask: {
|
||||||
|
true: $gettext('Enabled'),
|
||||||
|
false: $gettext('Disabled'),
|
||||||
|
},
|
||||||
|
},
|
||||||
sortable: true,
|
sortable: true,
|
||||||
pithy: true,
|
pithy: true,
|
||||||
}, {
|
}, {
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
|
|
||||||
type ConfigBackup struct {
|
type ConfigBackup struct {
|
||||||
Model
|
Model
|
||||||
|
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
FilePath string `json:"filepath"`
|
FilePath string `json:"filepath"`
|
||||||
Content string `json:"content" gorm:"type:text"`
|
Content string `json:"content" gorm:"type:text"`
|
||||||
|
@ -16,7 +15,6 @@ type ConfigBackup struct {
|
||||||
|
|
||||||
type ConfigBackupListItem struct {
|
type ConfigBackupListItem struct {
|
||||||
Model
|
Model
|
||||||
|
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
FilePath string `json:"filepath"`
|
FilePath string `json:"filepath"`
|
||||||
}
|
}
|
||||||
|
@ -25,13 +23,11 @@ func GetBackupList(path string) (configs []ConfigBackupListItem) {
|
||||||
db.Model(&ConfigBackup{}).
|
db.Model(&ConfigBackup{}).
|
||||||
Where(&ConfigBackup{FilePath: path}).
|
Where(&ConfigBackup{FilePath: path}).
|
||||||
Find(&configs)
|
Find(&configs)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetBackup(id int) (config ConfigBackup) {
|
func GetBackup(id int) (config ConfigBackup) {
|
||||||
db.First(&config, id)
|
db.First(&config, id)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue