Fix volume filtering

This commit is contained in:
cuigh 2018-04-16 18:49:33 +08:00
parent adb2874e60
commit 8fecfb5ba2
4 changed files with 10 additions and 8 deletions

View File

@ -5,7 +5,7 @@ ADD . .
RUN CGO_ENABLED=0 go build -ldflags "-s -w"
FROM alpine:3.7
MAINTAINER cuigh <noname@live.com>
LABEL maintainer="cuigh <noname@live.com>"
WORKDIR /app
COPY --from=build /go/src/github.com/cuigh/swirl/swirl .
COPY --from=build /go/src/github.com/cuigh/swirl/config ./config/

View File

@ -13,7 +13,7 @@ import (
)
// VolumeList return volumes on the host.
func VolumeList(pageIndex, pageSize int) (volumes []*types.Volume, totalCount int, err error) {
func VolumeList(name string, pageIndex, pageSize int) (volumes []*types.Volume, totalCount int, err error) {
var (
ctx context.Context
cli *client.Client
@ -26,9 +26,11 @@ func VolumeList(pageIndex, pageSize int) (volumes []*types.Volume, totalCount in
}
f := filters.NewArgs()
f.Add("dangling", "true")
//f.Add("dangling", "true")
//f.Add("driver", "xx")
//f.Add("name", "xx")
if name != "" {
f.Add("name", name)
}
resp, err = cli.VolumeList(ctx, f)
if err != nil {
return

View File

@ -36,15 +36,15 @@ func Volume() (c *VolumeController) {
}
func volumeList(ctx web.Context) error {
//name := ctx.Q("name")
name := ctx.Q("name")
page := cast.ToInt(ctx.Q("page"), 1)
volumes, totalCount, err := docker.VolumeList(page, model.PageSize)
volumes, totalCount, err := docker.VolumeList(name, page, model.PageSize)
if err != nil {
return err
}
m := newPagerModel(ctx, totalCount, model.PageSize, page).
//Set("Name", name).
Set("Name", name).
Set("Volumes", volumes)
return ctx.Render("volume/list", m)
}

View File

@ -23,7 +23,7 @@
<form>
<div class="field has-addons">
<p class="control">
<input name="name" value="" class="input" placeholder="Search by name">
<input name="name" value="{{ .Name }}" class="input" placeholder="Search by name">
</p>
<p class="control">
<button class="button is-primary">{{ i18n("button.search") }}</button>