~emersion/drmdb

36d4f0b20bb1f6abcdbb743ef53cfa4a7a08486d — Simon Ser 2 years ago 308aa38
Add filter indicators
M public/assets/style.css => public/assets/style.css +14 -3
@@ 135,10 135,21 @@ dd.muted {
}

.driver-support {
  display: flex;
  flex-wrap: wrap;
    display: flex;
    flex-wrap: wrap;
}

.driver-support > div {
  min-width: 25%;
    min-width: 25%;
}

.filter {
    background-color: #888;
    color: white;
    padding: 5px;
}

.filter a {
    text-decoration: none;
    color: white;
}

M public/capabilities.html => public/capabilities.html +10 -0
@@ 5,6 5,16 @@

  <p><a href="/">Back to index</a></p>

  {{with .DriverFilter}}
  <p>
      Filters:
      <span class="filter">
          {{.}}
          <a href="/capabilities" title="Clear filter">×</a>
      </span>
  </p>
  {{end}}

  <h2>Driver capabilities</h2>

  <table>

M public/devices.html => public/devices.html +10 -0
@@ 4,6 4,16 @@

<p><a href="/">Back to index</a></p>

{{with .DriverFilter}}
<p>
    Filters:
    <span class="filter">
        {{.}}
        <a href="/devices" title="Clear filter">×</a>
    </span>
</p>
{{end}}

<table>
    <thead>
        <tr>

M public/formats.html => public/formats.html +18 -0
@@ 5,6 5,24 @@

  <p><a href="/">Back to index</a></p>

  {{if or .DriverFilter .PlaneFilter}}
  <p>
      Filters:
      {{with .DriverFilter}}
      <span class="filter">
          {{.}}
          <a href="/formats" title="Clear filter">×</a>
      </span>
      {{end}}
      {{with .PlaneFilter}}
      <span class="filter">
          {{.}}
          <a href="/formats" title="Clear filter">×</a>
      </span>
      {{end}}
  </p>
  {{end}}

  <h2 id="in-formats">Input formats</h2>

  {{define "pct-cell"}}

M public/properties.html => public/properties.html +18 -0
@@ 5,6 5,24 @@

  <p><a href="/">Back to index</a></p>

  {{if or .DriverFilter .ObjectTypeFilter}}
  <p>
      Filters:
      {{with .DriverFilter}}
      <span class="filter">
          {{.}}
          <a href="/formatrs" title="Clear filter">×</a>
      </span>
      {{end}}
      {{with .ObjectTypeFilter}}
      <span class="filter">
          {{.}}
          <a href="/properties" title="Clear filter">×</a>
      </span>
      {{end}}
  </p>
  {{end}}

  <table>
      <thead>
          <tr>

M public/property-devices.html => public/property-devices.html +10 -0
@@ 4,6 4,16 @@

<p><a href="/">Back to index</a></p>

{{with .DriverFilter}}
<p>
    Filters:
    <span class="filter">
        {{.}}
        <a href="/properties/{{printf "%d" $.ObjectType}}/{{$.PropertyName}}/devices" title="Clear filter">×</a>
    </span>
</p>
{{end}}

<table>
    <thead>
        <tr>

M server.go => server.go +34 -21
@@ 216,8 216,9 @@ func New() *echo.Echo {
		}

		return c.Render(http.StatusOK, "devices.html", struct {
			Devices []deviceData
		}{devices})
			DriverFilter string
			Devices      []deviceData
		}{driverFilter, devices})
	})

	e.GET("/devices/:key", func(c echo.Context) error {


@@ 296,14 297,14 @@ func New() *echo.Echo {
	})

	e.GET("/capabilities", func(c echo.Context) error {
		driverName := c.QueryParam("driver")
		driverFilter := c.QueryParam("driver")

		var drivers []string
		caps := make(map[string]map[string]*uint64)
		clientCaps := make(map[string]map[string]bool)
		err := walkLatest(db, walkLatestDriver, func(k string, n *drmtree.Node) error {
			drv := n.Driver.Name
			if driverName != "" && drv != driverName {
			if driverFilter != "" && drv != driverFilter {
				return nil
			}



@@ 330,10 331,11 @@ func New() *echo.Echo {
		}

		return c.Render(http.StatusOK, "capabilities.html", struct {
			Drivers    []string
			Caps       map[string]map[string]*uint64
			ClientCaps map[string]map[string]bool
		}{drivers, caps, clientCaps})
			DriverFilter string
			Drivers      []string
			Caps         map[string]map[string]*uint64
			ClientCaps   map[string]map[string]bool
		}{driverFilter, drivers, caps, clientCaps})
	})

	e.GET("/properties", func(c echo.Context) error {


@@ 344,16 346,16 @@ func New() *echo.Echo {
			Drivers    map[string]bool
		}

		var objectType drm.ObjectType
		var objectTypeFilter drm.ObjectType
		if s := c.QueryParam("object-type"); s != "" {
			if i, err := strconv.Atoi(s); err != nil {
				return c.String(http.StatusBadRequest, "invalid object type")
			} else {
				objectType = drm.ObjectType(i)
				objectTypeFilter = drm.ObjectType(i)
			}
		}

		driverName := c.QueryParam("driver")
		driverFilter := c.QueryParam("driver")

		type propKey struct {
			Name       string


@@ 364,14 366,14 @@ func New() *echo.Echo {
		props := make(map[propKey]propertyData)
		err := db.Walk(func(k string, n *drmtree.Node) error {
			drv := n.Driver.Name
			if driverName != "" && drv != driverName {
			if driverFilter != "" && drv != driverFilter {
				return nil
			}

			drivers[drv] = struct{}{}

			return walkNodeProps(n, func(obj drm.AnyID, name string, prop *drmtree.Property) error {
				if objectType != drm.ObjectAny && obj.Type() != objectType {
				if objectTypeFilter != drm.ObjectAny && obj.Type() != objectTypeFilter {
					return nil
				}
				k := propKey{name, obj.Type()}


@@ 400,9 402,11 @@ func New() *echo.Echo {
		})

		return c.Render(http.StatusOK, "properties.html", struct {
			Drivers    map[string]struct{}
			Properties []propertyData
		}{drivers, propList})
			DriverFilter     string
			ObjectTypeFilter drm.ObjectType
			Drivers          map[string]struct{}
			Properties       []propertyData
		}{driverFilter, objectTypeFilter, drivers, propList})
	})

	e.GET("/properties/:obj/:name", func(c echo.Context) error {


@@ 539,10 543,11 @@ func New() *echo.Echo {
		}

		return c.Render(http.StatusOK, "property-devices.html", struct {
			DriverFilter string
			ObjectType   drm.ObjectType
			PropertyName string
			Devices      []deviceData
		}{objectType, propertyName, devices})
		}{driverFilter, objectType, propertyName, devices})
	})

	e.GET("/formats", func(c echo.Context) error {


@@ 626,11 631,19 @@ func New() *echo.Echo {
			return err
		}

		var planeFilterPtr *drm.PlaneType
		if planeFilter >= 0 {
			pt := drm.PlaneType(planeFilter)
			planeFilterPtr = &pt
		}

		return c.Render(http.StatusOK, "formats.html", struct {
			Planes  map[drm.PlaneType]int
			Drivers map[string]int
			Formats map[modifierAndFormat]formatData
		}{planes, drivers, formats})
			PlaneFilter  *drm.PlaneType
			DriverFilter string
			Planes       map[drm.PlaneType]int
			Drivers      map[string]int
			Formats      map[modifierAndFormat]formatData
		}{planeFilterPtr, driverFilter, planes, drivers, formats})
	})

	e.Static("/assets", "public/assets")