mirror of
https://github.com/luscis/openlan.git
synced 2025-11-03 09:40:50 +08:00
fea: openlan: list users filter by network
This commit is contained in:
@@ -34,6 +34,16 @@ func (u Lease) List(c *cli.Context) error {
|
|||||||
if err := clt.GetJSON(url, &items); err != nil {
|
if err := clt.GetJSON(url, &items); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
name := c.String("network")
|
||||||
|
if len(name) > 0 {
|
||||||
|
tmp := items[:0]
|
||||||
|
for _, obj := range items {
|
||||||
|
if obj.Network == name {
|
||||||
|
tmp = append(tmp, obj)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
items = tmp
|
||||||
|
}
|
||||||
return u.Out(items, c.String("format"), u.Tmpl())
|
return u.Out(items, c.String("format"), u.Tmpl())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +57,10 @@ func (u Lease) Commands(app *api.App) {
|
|||||||
Name: "list",
|
Name: "list",
|
||||||
Usage: "Display all lease",
|
Usage: "Display all lease",
|
||||||
Aliases: []string{"ls"},
|
Aliases: []string{"ls"},
|
||||||
Action: u.List,
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{Name: "network"},
|
||||||
|
},
|
||||||
|
Action: u.List,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -34,6 +34,16 @@ func (u Link) List(c *cli.Context) error {
|
|||||||
if err := clt.GetJSON(url, &items); err != nil {
|
if err := clt.GetJSON(url, &items); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
name := c.String("network")
|
||||||
|
if len(name) > 0 {
|
||||||
|
tmp := items[:0]
|
||||||
|
for _, obj := range items {
|
||||||
|
if obj.Network == name {
|
||||||
|
tmp = append(tmp, obj)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
items = tmp
|
||||||
|
}
|
||||||
return u.Out(items, c.String("format"), u.Tmpl())
|
return u.Out(items, c.String("format"), u.Tmpl())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +57,10 @@ func (u Link) Commands(app *api.App) {
|
|||||||
Name: "list",
|
Name: "list",
|
||||||
Usage: "Display all links",
|
Usage: "Display all links",
|
||||||
Aliases: []string{"ls"},
|
Aliases: []string{"ls"},
|
||||||
Action: u.List,
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{Name: "network"},
|
||||||
|
},
|
||||||
|
Action: u.List,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -34,6 +34,16 @@ func (u VPNClient) List(c *cli.Context) error {
|
|||||||
if err := clt.GetJSON(url, &items); err != nil {
|
if err := clt.GetJSON(url, &items); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
name := c.String("network")
|
||||||
|
if len(name) > 0 {
|
||||||
|
tmp := items[:0]
|
||||||
|
for _, obj := range items {
|
||||||
|
if obj.Network == name {
|
||||||
|
tmp = append(tmp, obj)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
items = tmp
|
||||||
|
}
|
||||||
return u.Out(items, c.String("format"), u.Tmpl())
|
return u.Out(items, c.String("format"), u.Tmpl())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +57,10 @@ func (u VPNClient) Commands(app *api.App) {
|
|||||||
Name: "list",
|
Name: "list",
|
||||||
Usage: "Display all clients",
|
Usage: "Display all clients",
|
||||||
Aliases: []string{"ls"},
|
Aliases: []string{"ls"},
|
||||||
Action: u.List,
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{Name: "network"},
|
||||||
|
},
|
||||||
|
Action: u.List,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -34,6 +34,16 @@ func (u Point) List(c *cli.Context) error {
|
|||||||
if err := clt.GetJSON(url, &items); err != nil {
|
if err := clt.GetJSON(url, &items); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
name := c.String("network")
|
||||||
|
if len(name) > 0 {
|
||||||
|
tmp := items[:0]
|
||||||
|
for _, obj := range items {
|
||||||
|
if obj.Network == name {
|
||||||
|
tmp = append(tmp, obj)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
items = tmp
|
||||||
|
}
|
||||||
return u.Out(items, c.String("format"), u.Tmpl())
|
return u.Out(items, c.String("format"), u.Tmpl())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +57,10 @@ func (u Point) Commands(app *api.App) {
|
|||||||
Name: "list",
|
Name: "list",
|
||||||
Usage: "Display all points",
|
Usage: "Display all points",
|
||||||
Aliases: []string{"ls"},
|
Aliases: []string{"ls"},
|
||||||
Action: u.List,
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{Name: "network"},
|
||||||
|
},
|
||||||
|
Action: u.List,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -74,6 +74,16 @@ func (u User) List(c *cli.Context) error {
|
|||||||
if err := clt.GetJSON(url, &items); err != nil {
|
if err := clt.GetJSON(url, &items); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
name := c.String("network")
|
||||||
|
if len(name) > 0 {
|
||||||
|
tmp := items[:0]
|
||||||
|
for _, obj := range items {
|
||||||
|
if obj.Network == name {
|
||||||
|
tmp = append(tmp, obj)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
items = tmp
|
||||||
|
}
|
||||||
return u.Out(items, c.String("format"), u.Tmpl())
|
return u.Out(items, c.String("format"), u.Tmpl())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user