mirror of
https://github.com/jc21/nginx-proxy-manager.git
synced 2024-08-30 18:22:48 +00:00
Add user expansion to upstream model
This commit is contained in:
parent
8033d052fe
commit
1d5d3ecd7a
@ -8,6 +8,7 @@ import (
|
|||||||
"npm/internal/database"
|
"npm/internal/database"
|
||||||
"npm/internal/entity/nginxtemplate"
|
"npm/internal/entity/nginxtemplate"
|
||||||
"npm/internal/entity/upstreamserver"
|
"npm/internal/entity/upstreamserver"
|
||||||
|
"npm/internal/entity/user"
|
||||||
"npm/internal/status"
|
"npm/internal/status"
|
||||||
"npm/internal/types"
|
"npm/internal/types"
|
||||||
"npm/internal/util"
|
"npm/internal/util"
|
||||||
@ -39,6 +40,7 @@ type Model struct {
|
|||||||
// Expansions
|
// Expansions
|
||||||
Servers []upstreamserver.Model `json:"servers"`
|
Servers []upstreamserver.Model `json:"servers"`
|
||||||
NginxTemplate *nginxtemplate.Model `json:"nginx_template,omitempty"`
|
NginxTemplate *nginxtemplate.Model `json:"nginx_template,omitempty"`
|
||||||
|
User *user.Model `json:"user,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Model) getByQuery(query string, params []interface{}) error {
|
func (m *Model) getByQuery(query string, params []interface{}) error {
|
||||||
@ -121,6 +123,12 @@ func (m *Model) Expand(items []string) error {
|
|||||||
m.Servers, err = upstreamserver.GetByUpstreamID(m.ID)
|
m.Servers, err = upstreamserver.GetByUpstreamID(m.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if util.SliceContainsItem(items, "user") && m.ID > 0 {
|
||||||
|
var usr user.Model
|
||||||
|
usr, err = user.GetByID(m.UserID)
|
||||||
|
m.User = &usr
|
||||||
|
}
|
||||||
|
|
||||||
if util.SliceContainsItem(items, "nginxtemplate") && m.NginxTemplateID > 0 {
|
if util.SliceContainsItem(items, "nginxtemplate") && m.NginxTemplateID > 0 {
|
||||||
var templ nginxtemplate.Model
|
var templ nginxtemplate.Model
|
||||||
templ, err = nginxtemplate.GetByID(m.NginxTemplateID)
|
templ, err = nginxtemplate.GetByID(m.NginxTemplateID)
|
||||||
|
Loading…
Reference in New Issue
Block a user