github.com/kyleu/dbaudit@v0.0.2-0.20240321155047-ff2f2c940496/views/components/view/Map.html (about)

     1  <!-- Content managed by Project Forge, see [projectforge.md] for details. -->
     2  {% import (
     3    "fmt"
     4  
     5    "github.com/kyleu/dbaudit/app/controller/cutil"
     6    "github.com/kyleu/dbaudit/app/lib/filter"
     7    "github.com/kyleu/dbaudit/app/util"
     8    "github.com/kyleu/dbaudit/views/components"
     9  ) %}
    10  
    11  {% func MapArray(maps []util.ValueMap, params *filter.Params, preserveWhitespace bool, ps *cutil.PageState) %}{% stripspace %}
    12    {%- if len(maps) == 0 -%}
    13    <em>no results</em>
    14    {%- else -%}
    15    <div class="overflow full-width">
    16      <table>
    17        <thead>
    18        <tr>
    19          {%- for _, k := range maps[0].Keys() -%}
    20          {%= components.TableHeaderSimple("map", k, k, "", params, nil, ps) %}
    21          {%- endfor -%}
    22        </tr>
    23        </thead>
    24        <tbody>
    25          {%- for _, m := range maps -%}
    26          <tr>
    27            {%- for _, k := range m.Keys() -%}
    28            {%- code
    29              res := ""
    30              switch t := m[k].(type) {
    31              case string:
    32                res = t
    33              case []byte:
    34                res = string(t)
    35              default:
    36                res = fmt.Sprint(m[k])
    37              }
    38            -%}
    39            {%- if preserveWhitespace -%}
    40            <td class="prews">{%s res %}</td>
    41            {%- else -%}
    42            <td>{%s res %}</td>
    43            {%- endif -%}
    44            {%- endfor -%}
    45          </tr>
    46          {%- endfor -%}
    47        </tbody>
    48      </table>
    49    </div>
    50    {%- endif -%}
    51  {% endstripspace %}{% endfunc %}