~emersion/drmdb

5d97779435a5a762121c1b4795e5a76c6646b127 — Simon Ser 2 years ago 4d007f2
Allow to filter per plane/driver in /formats view
3 files changed, 24 insertions(+), 2 deletions(-)

M public/assets/style.css
M public/formats.html
M server.go
M public/assets/style.css => public/assets/style.css +4 -0
@@ 38,6 38,10 @@ thead {
    color: white;
}

thead a, thead a:active, thead a:visited {
    color: white;
}

td.status-supported {
    color: green;
}

M public/formats.html => public/formats.html +2 -2
@@ 20,10 20,10 @@
        </tr>
        <tr>
            {{range $plane, $_ := .Planes}}
            <th>{{$plane.String}}</th>
            <th><a href="?plane={{printf "%d" $plane}}">{{$plane.String}}</a></th>
            {{end}}
            {{range $drv, $_ := .Drivers}}
            <th>{{$drv}}</th>
            <th><a href="?driver={{$drv}}">{{$drv}}</a></th>
            {{end}}
        </tr>
    </thead>

M server.go => server.go +18 -0
@@ 7,6 7,7 @@ import (
	"net/http"
	"os"
	"sort"
	"strconv"
	"strings"

	"git.sr.ht/~emersion/drmdb/drmtree"


@@ 400,6 401,15 @@ func New() *echo.Echo {
			Drivers map[string]int
		}

		planeFilter := -1
		if s := c.QueryParam("plane"); s != "" {
			var err error
			if planeFilter, err = strconv.Atoi(s); err != nil {
				return c.String(http.StatusBadRequest, "invalid plane")
			}
		}
		driverFilter := c.QueryParam("driver")

		// For each (modifier, format) pair, build two tables by walking each
		// device:
		// - Number of devices supporting it by plane type (max: number of


@@ 410,12 420,20 @@ func New() *echo.Echo {
		drivers := make(map[string]int)
		formats := make(map[modifierAndFormat]formatData)
		err := walkLatest(walkLatestDevice, func(k string, n *drmtree.Node) error {
			if driverFilter != "" && n.Driver.Name != driverFilter {
				return nil
			}

			drivers[n.Driver.Name]++

			planeFormats := make(map[drm.PlaneType]map[modifierAndFormat]bool)
			driverFormats := make(map[modifierAndFormat]bool)

			for _, plane := range n.Planes {
				if planeFilter >= 0 && plane.Type() != drm.PlaneType(planeFilter) {
					continue
				}

				if _, ok := planeFormats[plane.Type()]; !ok {
					planeFormats[plane.Type()] = make(map[modifierAndFormat]bool)
					planes[plane.Type()]++