File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import (
1010 "github.com/0xJacky/Nginx-UI/settings"
1111 "github.com/gin-gonic/gin"
1212 "github.com/spf13/cast"
13+ "gorm.io/gorm"
1314 "net/http"
1415)
1516
@@ -28,12 +29,19 @@ func GetEnvironment(c *gin.Context) {
2829}
2930
3031func GetEnvironmentList (c * gin.Context ) {
31- cosy.Core [model.Environment ](c ).
32- SetFussy ("name" ).
33- SetEqual ("enabled" ).
34- SetTransformer (func (m * model.Environment ) any {
35- return analytic .GetNode (m )
36- }).PagingList ()
32+ core := cosy.Core [model.Environment ](c ).
33+ SetFussy ("name" )
34+
35+ // fix for sqlite
36+ if c .Query ("enabled" ) != "" {
37+ core .GormScope (func (tx * gorm.DB ) * gorm.DB {
38+ return tx .Where ("enabled = ?" , cast .ToInt (cast .ToBool (c .Query ("enabled" ))))
39+ })
40+ }
41+
42+ core .SetTransformer (func (m * model.Environment ) any {
43+ return analytic .GetNode (m )
44+ }).PagingList ()
3745}
3846
3947func AddEnvironment (c * gin.Context ) {
You can’t perform that action at this time.
0 commit comments