mirror of
https://github.com/jc21/nginx-proxy-manager.git
synced 2024-08-30 18:22:48 +00:00
Fix schema responses not matching tests
This commit is contained in:
parent
4b39ef0eba
commit
c849938da2
@ -14,6 +14,7 @@ import (
|
||||
"npm/internal/entity/dnsprovider"
|
||||
"npm/internal/entity/host"
|
||||
"npm/internal/entity/nginxtemplate"
|
||||
"npm/internal/entity/setting"
|
||||
"npm/internal/entity/stream"
|
||||
"npm/internal/entity/upstream"
|
||||
"npm/internal/entity/user"
|
||||
@ -133,8 +134,11 @@ func applyRoutes(r chi.Router) chi.Router {
|
||||
|
||||
// Settings
|
||||
r.With(middleware.EnforceSetup(true), middleware.Enforce(user.CapabilitySettingsManage)).Route("/settings", func(r chi.Router) {
|
||||
// r.With(middleware.Filters(setting.GetFilterSchema())).
|
||||
r.Get("/", handler.GetSettings())
|
||||
// List
|
||||
r.With(
|
||||
middleware.Filters(setting.Model{}),
|
||||
).Get("/", handler.GetSettings())
|
||||
|
||||
r.Get("/{name}", handler.GetSetting())
|
||||
r.With(middleware.EnforceRequestSchema(schema.CreateSetting())).
|
||||
Post("/", handler.CreateSetting())
|
||||
|
@ -40,7 +40,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (entity.ListResponse,
|
||||
Total: totalRows,
|
||||
Limit: pageInfo.Limit,
|
||||
Offset: pageInfo.Offset,
|
||||
Sort: pageInfo.Sort,
|
||||
Sort: pageInfo.GetSort(defaultSort),
|
||||
Filter: filters,
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter, expand []string) (ent
|
||||
Total: totalRows,
|
||||
Limit: pageInfo.Limit,
|
||||
Offset: pageInfo.Offset,
|
||||
Sort: pageInfo.Sort,
|
||||
Sort: pageInfo.GetSort(defaultSort),
|
||||
Filter: filters,
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (entity.ListResponse,
|
||||
Total: totalRows,
|
||||
Limit: pageInfo.Limit,
|
||||
Offset: pageInfo.Offset,
|
||||
Sort: pageInfo.Sort,
|
||||
Sort: pageInfo.GetSort(defaultSort),
|
||||
Filter: filters,
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (entity.ListResponse,
|
||||
Total: totalRows,
|
||||
Limit: pageInfo.Limit,
|
||||
Offset: pageInfo.Offset,
|
||||
Sort: pageInfo.Sort,
|
||||
Sort: pageInfo.GetSort(defaultSort),
|
||||
Filter: filters,
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter, expand []string) (ent
|
||||
Total: totalRows,
|
||||
Limit: pageInfo.Limit,
|
||||
Offset: pageInfo.Offset,
|
||||
Sort: pageInfo.Sort,
|
||||
Sort: pageInfo.GetSort(defaultSort),
|
||||
Filter: filters,
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (entity.ListResponse,
|
||||
Total: totalRows,
|
||||
Limit: pageInfo.Limit,
|
||||
Offset: pageInfo.Offset,
|
||||
Sort: pageInfo.Sort,
|
||||
Sort: pageInfo.GetSort(defaultSort),
|
||||
Filter: filters,
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"npm/internal/logger"
|
||||
"npm/internal/model"
|
||||
|
||||
"gorm.io/gorm"
|
||||
@ -36,6 +37,8 @@ func ScopeOrderBy(pageInfo *model.PageInfo, defaultSort model.Sort) func(db *gor
|
||||
}
|
||||
|
||||
func ScopeFilters(filters []model.Filter, filterMap map[string]filterMapValue) func(db *gorm.DB) *gorm.DB {
|
||||
logger.Debug("FILTERS: %+v", filters)
|
||||
logger.Debug("FILTERMAP: %+v", filterMap)
|
||||
return func(db *gorm.DB) *gorm.DB {
|
||||
for _, f := range filters {
|
||||
// Lookup this filter field from the name map
|
||||
|
@ -49,7 +49,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (entity.ListResponse,
|
||||
Total: totalRows,
|
||||
Limit: pageInfo.Limit,
|
||||
Offset: pageInfo.Offset,
|
||||
Sort: pageInfo.Sort,
|
||||
Sort: pageInfo.GetSort(defaultSort),
|
||||
Filter: filters,
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (entity.ListResponse,
|
||||
Total: totalRows,
|
||||
Limit: pageInfo.Limit,
|
||||
Offset: pageInfo.Offset,
|
||||
Sort: pageInfo.Sort,
|
||||
Sort: pageInfo.GetSort(defaultSort),
|
||||
Filter: filters,
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter, expand []string) (ent
|
||||
Total: totalRows,
|
||||
Limit: pageInfo.Limit,
|
||||
Offset: pageInfo.Offset,
|
||||
Sort: pageInfo.Sort,
|
||||
Sort: pageInfo.GetSort(defaultSort),
|
||||
Filter: filters,
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter) (entity.ListResponse,
|
||||
Total: totalRows,
|
||||
Limit: pageInfo.Limit,
|
||||
Offset: pageInfo.Offset,
|
||||
Sort: pageInfo.Sort,
|
||||
Sort: pageInfo.GetSort(defaultSort),
|
||||
Filter: filters,
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ func List(pageInfo model.PageInfo, filters []model.Filter, expand []string) (ent
|
||||
Total: totalRows,
|
||||
Limit: pageInfo.Limit,
|
||||
Offset: pageInfo.Offset,
|
||||
Sort: pageInfo.Sort,
|
||||
Sort: pageInfo.GetSort(defaultSort),
|
||||
Filter: filters,
|
||||
}
|
||||
|
||||
|
@ -14,3 +14,11 @@ type Sort struct {
|
||||
Field string `json:"field"`
|
||||
Direction string `json:"direction"`
|
||||
}
|
||||
|
||||
// TableName overrides the table name used by gorm
|
||||
func (p *PageInfo) GetSort(def Sort) []Sort {
|
||||
if p.Sort == nil {
|
||||
return []Sort{def}
|
||||
}
|
||||
return p.Sort
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user