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

View File

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

View File

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

View File

@ -23,7 +23,7 @@
<form> <form>
<div class="field has-addons"> <div class="field has-addons">
<p class="control"> <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>
<p class="control"> <p class="control">
<button class="button is-primary">{{ i18n("button.search") }}</button> <button class="button is-primary">{{ i18n("button.search") }}</button>