diff --git a/app/static/catalogue/catalogue.css b/app/static/catalogue/catalogue.css index 6064e35b..75459c86 100644 --- a/app/static/catalogue/catalogue.css +++ b/app/static/catalogue/catalogue.css @@ -10,12 +10,15 @@ .bench-shelf.st-community .shelf-dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--status-color); } .shelf-n { color: var(--text-faint); font-weight: 500; } /* four cards a line on a wide screen, two on a narrower one, one on a phone */ -.bench-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; } -@media (max-width: 1180px) { .bench-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } } -@media (max-width: 640px) { .bench-grid { grid-template-columns: minmax(0, 1fr); } } +.bench-grid { --n: 4; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 16px; } +@media (max-width: 1180px) { .bench-grid { --n: 2; } } +@media (max-width: 640px) { .bench-grid { --n: 1; } } +/* more than three stats (--stats, from _cards.html): every card wide enough for them on one line, 72px a stat, so + fewer cards a line - at most --n, and at least one however narrow the screen */ +.bench-grid:has(.bench-stats > :nth-child(4)) { grid-template-columns: repeat(auto-fill, minmax(min(100%, max((100% - (var(--n) - 1) * 16px) / var(--n) - .1px, var(--stats) * 80px + 34px)), 1fr)); } /* a card (templates/_cards.html): its title's link stretched over it, so the whole card opens it; a checkbox, a button or a value with a tooltip sits above that link */ -.bench-card { position: relative; display: flex; flex-direction: column; gap: 14px; padding: 20px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border-soft); color: var(--text); transition: border-color .13s ease; } +.bench-card { container-type: inline-size; position: relative; display: flex; flex-direction: column; gap: 14px; padding: 20px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border-soft); color: var(--text); transition: border-color .13s ease; } .bench-card:hover { border-color: var(--accent); } .card-link, .card-link:hover { color: inherit; text-decoration: none; } .card-link::after { content: ""; position: absolute; inset: -1px; border-radius: 12px; } @@ -23,18 +26,28 @@ .card-link:focus-visible::after { box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent); } .bench-card :is(input, button, .btn, [title]) { position: relative; z-index: 1; } .bench-card [title]:not(input, button, .btn) { cursor: pointer; } /* raised for its tooltip, it still opens the card */ -.bench-card-top .bench-harness { margin-left: auto; } -.bench-card-actions { display: flex; flex-wrap: wrap; gap: 8px; } +.bench-card-foot .bench-harness { margin-left: auto; } +.bench-card-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; } .bench-shelf.st-community .bench-card { background: transparent; border-style: dashed; border-color: var(--border); } .bench-shelf.st-community .bench-card:hover { border-color: var(--accent); } -.bench-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; } +.bench-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; line-height: 18px; min-height: 18px; } /* one height with or without a status glyph, so stats line up across a row */ .bench-card-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; } .bench-harness { font: 12px var(--mono); color: var(--text-faint); } .bench-card-title { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 500; letter-spacing: -.01em; } +/* the check and the delete at the title row's right, level with its first line however the title wraps */ +.bench-card-corner { flex: none; align-self: flex-start; display: flex; align-items: center; gap: 6px; height: 1lh; margin-left: auto; } +.bench-card-corner [data-check] { margin: 0; } +/* a name with a control of its own after its last word (a title's `after`), wrapping as text */ +.bench-card-name { min-width: 0; } +.bench-card-name > .icon-btn { vertical-align: middle; } .bench-mark { flex: none; width: 22px; height: 22px; color: var(--accent); } .bench-card-domain { margin-top: -6px; font-size: 14px; line-height: 1.5; color: var(--text-dim); } -/* up to three stats in columns of one width, each its label then its value */ -.bench-stats { display: grid; grid-template-columns: repeat(3, minmax(min-content, 1fr)); gap: 8px; margin: auto 0 0; padding-top: 14px; border-top: 1px solid var(--border-soft); } +/* the stats in columns of one width, a column each, each its label then its value; on a card too narrow for one + line (a phone), two balanced rows: 4 as 2+2, 5 as 3+2, 6 as 3+3 */ +.bench-stats { display: grid; grid-template-columns: repeat(var(--cols, var(--stats, 3)), minmax(min-content, 1fr)); gap: 8px; margin: auto 0 0; padding-top: 14px; border-top: 1px solid var(--border-soft); } +@container (max-width: 311.9px) { .bench-stats:has(> :nth-child(4)) { --cols: 2; } } +@container (max-width: 391.9px) { .bench-stats:has(> :nth-child(5)) { --cols: 3; } } +@container (max-width: 471.9px) { .bench-stats:has(> :nth-child(6)) { --cols: 3; } } .bench-stats > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; } .bench-stats dd { margin: 0; font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; } .bench-stats dd.word { font-size: 14px; line-height: 1.35; padding-top: 3px; } diff --git a/app/static/tables.js b/app/static/tables.js index ad394d5c..d966c587 100644 --- a/app/static/tables.js +++ b/app/static/tables.js @@ -229,7 +229,8 @@ window.NulliusTable = { how many show once the changes pause, counted in the live region's data-noun. A click anywhere on a card but on a control of its own follows the card's link, in a new tab or window with the keys or the - button a link takes; a click that ends a text selection does not. */ + button a link takes; a click that ends a text selection does not. Sort by, + when it has one, sorts the cards within their grids as a table's rows. */ cards(root) { const items = [...root.querySelectorAll('[data-card]')], empty = document.querySelector(`[data-empty="${CSS.escape(root.id)}"]`); const live = document.querySelector(`[data-live="${CSS.escape(root.id)}"]`), say = this.voice(live); @@ -252,7 +253,21 @@ window.NulliusTable = { empty.hidden = n > 0; say(n ? `${n} of ${items.length} ${live.dataset.noun}` : empty.textContent); }; - const passes = this.narrow(document.getElementById(root.id + '-tools'), draw); + const tools = document.getElementById(root.id + '-tools'), passes = this.narrow(tools, draw); + const [sbtn, smenu] = [tools.querySelector('[data-tools-btn="sort"]'), tools.querySelector('[data-tools="sort"]')]; + if (smenu) { // the table's Sort by, over each card's data-s- + const dirs = [...smenu.querySelectorAll('[data-sort-dir]')]; + const sort = e => { + const c = smenu.querySelector('[data-sort-col]:checked'), on = c.value, num = c.dataset.type === 'num'; + const dir = e?.target.matches('[data-sort-dir]') ? (e.target.value === 'asc' ? 1 : -1) : (num ? -1 : 1); + dirs.forEach(r => { r.checked = Boolean(on) && r.value === (dir > 0 ? 'asc' : 'desc'); r.disabled = !on; }); + const key = card => { const raw = card.getAttribute('data-s-' + on) ?? ''; return num ? parseFloat(raw) || 0 : raw.toLowerCase(); }; + (on ? [...items].sort((a, b) => { const x = key(a), y = key(b); return (x < y ? -1 : x > y ? 1 : 0) * dir; }) : items).forEach(c => c.parentNode.appendChild(c)); + }; + smenu.addEventListener('change', sort); + sort(); + this.menu(sbtn, smenu); + } draw(); }, diff --git a/app/templates/_cards.html b/app/templates/_cards.html index bb2970f4..ec616128 100644 --- a/app/templates/_cards.html +++ b/app/templates/_cards.html @@ -1,11 +1,16 @@ {#- The card toolkit: items as cards over the same field list as the table toolkit (_tables.html), run by static/tables.js (NulliusTable.cards) and styled in catalogue/catalogue.css. A field's `card` names the slot it fills; a field without one is not on the card, and `table` false keeps a card-only field off a table. Slots, in - order: `status`, `tag`*, `meta`, `check` (the top row); `icon`, `title` (exactly one); `text`; `badge`*, `note`*; - `stat` (up to 3, below a line); `alert`; `action`* (* any number, the others at most one). - An item is a dict of display values by field key: a string, a dict {text, class, title, label, href, value} or a - list of them, empty for none; a filter reads a value's `value`, else its text. Plus `href` (its title's link), - `id`, `search` (what the search reads) and `keys`. + order: `icon`, `title` (exactly one), `check`, `delete` (the title row, the two at its right); `text`; `badge`*, `note`*; + `stat`* (below a line, a column each, a missing value as —; a few, what reads at a glance); `alert`; `action`*; + `status`, `tag`*, `meta` (the last row, the meta at its right) (* any number, the others at most one). More than + three stats widen every card of the page so they keep one line; on a screen too narrow they wrap in two rows. + An item is a dict of display values by field key: a string, a dict {text, class, title, label, href, value, attrs} + or a list of them, empty for none; a filter and Sort by read a value's `value`, else its text; an action's + `attrs` are its button's own attributes, its `class` added to the button's, and a `delete` takes the same shape (a quiet + trash button). Plus `href` (its title's link), + `id`, `search` (what the search reads) and `keys`. A title's `after` is markup in the flow of its name, after its + last word (a control of its own), and its `class` goes on the title row. A field's `class` goes on each of its values; `card_label` names a stat when its column header does not, and a value's `label` names it for that item; `style` 'code' sets the text as code; `icon` puts #i- before a note. `icon` values are image URLs: when one item has one, the others show initials; when none has, no icon. -#} @@ -19,54 +24,60 @@ {% macro pill(f, v) %}{% set cls = [f.class, v.class]|select|join(' ') %}{{ v.text }}{% endmacro %} {# A collection of cards (NulliusTable.cards): its controls row, its cards, the note when none passes. `id` names it; - `search`, `choices`, `only` and each field's `filter` as the table's controls; `noun` what the live region counts. + `search`, `choices`, `only`, `layout` and each field's `filter` as the table's controls; `sort` the Sort by menu, over + the fields that are not blank; `noun` what the live region counts. The call block, when given, writes the cards instead (grid for each group, such as the Benchmarks' shelves); a section in it marked data-group hides when none of its cards shows, and its data-group-n counts them. #} -{% macro cards(id, cols, items, search='', choices={}, only={}, empty='No items match.', noun='items') %} -{{ controls(id, cols, search, choices=choices, only=only, sort=false) }} -
{% if caller is defined %}{{ caller() }}{% else %}{{ grid(cols, items, choices=choices) }}{% endif %}
+{% macro cards(id, cols, items, search='', choices={}, only={}, empty='No items match.', noun='items', sort=false, layout=none) %} +{{ controls(id, cols, search, choices=choices, only=only, sort=sort, layout=layout) }} +
{% if caller is defined %}{{ caller() }}{% else %}{{ grid(cols, items, choices=choices, sort=sort) }}{% endif %}
{{ empty_note(id, empty) }} {% endmacro %} {# The cards of `items`. `every`: the collection the icon rule reads, when `items` is a part of it; `choices`: the - filtered fields, each written on the card for the filter. #} -{% macro grid(cols, items, every=none, choices={}) %} + filtered fields, each written on the card for the filter; `sort`: the fields Sort by reads, each written too. #} +{% macro grid(cols, items, every=none, choices={}, sort=false) %} {%- set fields = cols|selectattr('card')|list %} -{%- set by = {} %}{% for slot in ['status', 'tag', 'meta', 'check', 'icon', 'title', 'text', 'badge', 'note', 'stat', 'alert', 'action'] %}{% set _ = by.update({slot: fields|selectattr('card', 'equalto', slot)|list}) %}{% endfor %} -{#- the limits, each failing the page: one title, at most three stats, at most one of each other single slot #} -{%- if not by.title or by.stat|length > 3 %}{{ cards_take_one_title_and_at_most_three_stats() }}{% endif %} -{%- for slot in ['status', 'meta', 'check', 'icon', 'title', 'text', 'alert'] if by[slot]|length > 1 %}{{ cards_take_one_of_each_single_slot() }}{% endfor %} +{%- set by = {} %}{% for slot in ['status', 'tag', 'meta', 'check', 'delete', 'icon', 'title', 'text', 'badge', 'note', 'stat', 'alert', 'action'] %}{% set _ = by.update({slot: fields|selectattr('card', 'equalto', slot)|list}) %}{% endfor %} +{#- the limits, each failing the page: one title, at most one of each other single slot #} +{%- if not by.title %}{{ cards_take_one_title() }}{% endif %} +{%- for slot in ['status', 'meta', 'check', 'delete', 'icon', 'title', 'text', 'alert'] if by[slot]|length > 1 %}{{ cards_take_one_of_each_single_slot() }}{% endfor %} {%- set icon = by.icon[0] if by.icon else none %} {%- set icons = icon and (every or items)|selectattr(icon.key)|list|length > 0 %} -
+
{%- for item in items %}
- {%- set top %}{% call(f, v) each(item, by.status) %}{{ pill(f, v) }}{% endcall %} - {%- set tags %}{% call(f, v) each(item, by.tag) %}{{ pill(f, v) }}{% endcall %}{% endset %}{% if tags %}{{ tags }}{% endif %} - {%- call(f, v) each(item, by.meta) %}{{ v.text }}{% endcall %} - {%- call(f, v) each(item, by.check) %}{% endcall %}{% endset %} - {%- if top %} -
{{ top }}
{% endif %} - {%- set title = by.title[0] %}{% set name = item.get(title.key) %}{% set name = name.text if name is mapping else name %} -
{% if icons %}{% set src = item.get(icon.key) %} + {%- for f in cols if f.key in choices %} data-f-{{ f.key }}="{% call(f, v) each(item, [f]) %}{{ v.get('value', v.text) }} {% endcall %}"{% endfor %} + {%- for f in fields if sort and not f.blank %} data-s-{{ f.key }}="{% call(f, v) each(item, [f]) %}{{ v.get('value', v.text) }}{% endcall %}"{% endfor %}> + {%- set title = by.title[0] %}{% set v = item.get(title.key) %}{% set v = v if v is mapping else {'text': v} %}{% set name = v.text %} + {%- set cls = [title.class, v.class]|select|join(' ') %} +
{% if icons %}{% set src = item.get(icon.key) %} {%- if not src %} {%- elif '#' in src %} {%- else %}{% endif %}{% endif -%} - {{ name }}
+ {%- set link %}{{ name }}{% endset %} + {%- if v.after %}{{ link }} {{ v.after }}{% else %}{{ link }}{% endif %} + {%- set corner %}{% call(f, v) each(item, by.check) %}{% endcall %} + {%- call(f, v) each(item, by.delete) %}{% endcall %}{% endset %} + {%- if corner %}{{ corner }}{% endif %}
{%- call(f, v) each(item, by.text) %}
{% if f.style == 'code' %}{{ v.text }}{% else %}{{ v.text }}{% endif %}
{% endcall %} {%- set badges %}{% call(f, v) each(item, by.badge) %}{{ pill(f, v) }}{% endcall %}{% endset %}{% if badges %}
{{ badges }}
{% endif %} {%- call(f, v) each(item, by.note) %}
{% if f.icon %}{% endif %}{{ v.text }}
{% endcall %} - {%- set stats %}{% call(f, v) each(item, by.stat) %}
{{ v.label or f.card_label or f.label }}
{{ v.text }}
{% endcall %}{% endset %}{% if stats %} -
{{ stats }}
{% endif %} + {%- if by.stat %} +
{% for f in by.stat %}{% set v = item.get(f.key) %}{% set v = v if v is mapping else {'text': v} -%} +
{{ v.label or f.card_label or f.label }}
{{ '—' if v.text is none or v.text == '' else v.text }}
{% endfor %}
{% endif %} {%- call(f, v) each(item, by.alert) %}
{{ v.text }}
{% endcall %} - {%- set actions %}{% call(f, v) each(item, by.action) %}{% if v.href %}{{ v.text }}{% else %}{% endif %}{% endcall %}{% endset %}{% if actions %} + {%- set actions %}{% call(f, v) each(item, by.action) %}{% if v.href %}{{ v.text }}{% else %}{% endif %}{% endcall %}{% endset %}{% if actions %}
{{ actions }}
{% endif %} + {%- set foot %}{% call(f, v) each(item, by.status) %}{{ pill(f, v) }}{% endcall %} + {%- set tags %}{% call(f, v) each(item, by.tag) %}{{ pill(f, v) }}{% endcall %}{% endset %}{% if tags %}{{ tags }}{% endif %} + {%- call(f, v) each(item, by.meta) %}{{ v.text }}{% endcall %}{% endset %}{% if foot %} +
{{ foot }}
{% endif %}
{%- endfor %}
diff --git a/app/templates/_tables.html b/app/templates/_tables.html index f69afa77..7fbea968 100644 --- a/app/templates/_tables.html +++ b/app/templates/_tables.html @@ -31,13 +31,13 @@ {# A whole table (static/tables.js `wire`): its controls row, its headers from `cols`, a row of `rows` each, and its pages. `id` names it, and keys what a viewer chooses; `class` adds to its classes; `tr`: a macro writing a row's attributes. The call block writes a cell: it is called with a row and a column, in the order of `cols`, and - writes that cell with the cell macro. Opt-ins: `search`, `columns`, `choices`, `only`, `views`, `actions` as - controls'; `empty` and `noun` as pager's; `sticky_head`: its header row pinned while it scrolls down, and `tr`'s + writes that cell with the cell macro. Opt-ins: `search`, `columns`, `choices`, `only`, `views`, `actions`, `layout` + as controls'; `empty` and `noun` as pager's; `sticky_head`: its header row pinned while it scrolls down, and `tr`'s rows with data-sticky under it (tables.js `sticky`), the controls row with them up to the table's end. #} -{% macro table(id, cols, rows, tr, class='', search='', columns=false, choices={}, only={}, empty='No rows match.', noun='rows', views=none, actions=none, sticky_head=false) %} +{% macro table(id, cols, rows, tr, class='', search='', columns=false, choices={}, only={}, empty='No rows match.', noun='rows', views=none, actions=none, layout=none, sticky_head=false) %} {%- if sticky_head %}
{% endif %} {%- set cols = cols|rejectattr('table', 'sameas', false)|list %} -{{ controls(id, cols, search, columns, choices, only, views, actions) }} +{{ controls(id, cols, search, columns, choices, only, views, actions, layout=layout) }} {%- for c in cols if c.width == 'expand' %} {%- endfor %} @@ -69,15 +69,16 @@ Columns menu; `choices`: column -> its (value, label) pairs to filter by; `only`: column -> the one value chosen at load; then the Sort by menu, unless `sort` is false. `views` and `actions`: macros writing a page's own buttons, each any number of them, run by the page: views (how the table looks) before Columns, actions (on the - rows or the selection) last. The search goes left, the buttons right. A column's + rows or the selection) after Sort by. `layout` 'table' or 'cards', the one shown: a toggle of links to the + page's other one (?view=cards), its other query kept, at the end. The search goes left, the buttons right. A column's `filter` says where its choices go, one form or a list of them: 'button' (the default), in the Filter menu; 'dropdown', a menu of its own; 'pills', a row of toggles under the controls. A column's `filter_icon`, a sprite id without its `i-`, leads its dropdown's button and its pills. `id`: the table's. #} -{% macro controls(id, cols, search='', columns=false, choices={}, only={}, views=none, actions=none, sort=true) %} +{% macro controls(id, cols, search='', columns=false, choices={}, only={}, views=none, actions=none, sort=true, layout=none) %} {%- set by = {'button': [], 'dropdown': [], 'pills': []} %}{% for c in cols if c.key in choices %}{% for f in ([c.filter] if c.filter is string else c.filter or ['button']) %}{% set _ = by[f].append(c) %}{% endfor %}{% endfor %}
{% if search %}{% endif %} - {% if columns or by.dropdown or by.button or sort or views or actions %}
+ {% if columns or by.dropdown or by.button or sort or views or actions or layout %}
{{ slot('views', views) }} {% if columns %}{% endif %} {% for c in by.dropdown %}
{% endif %} {{ slot('actions', actions) }} + {% if layout %}{% set q = dict(request.view_args, **request.args.to_dict(flat=false)) %}{% endif %}
{% endif %} {% for c in by.pills %}
diff --git a/app/templates/base.html b/app/templates/base.html index 0e2964f2..59a29d81 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -73,6 +73,7 @@ + diff --git a/app/templates/workspaces/workspaces.html b/app/templates/workspaces/workspaces.html index b95e9c63..0e226d33 100644 --- a/app/templates/workspaces/workspaces.html +++ b/app/templates/workspaces/workspaces.html @@ -1,4 +1,5 @@ {% from '_tables.html' import table, cell, greyed %} +{% from '_cards.html' import cards %} {% extends "base.html" %} {% from '_page.html' import page_head %} {% block title %}Workspaces — Nullius{% endblock %} @@ -9,44 +10,66 @@ {% endblock %} {#- A workspace's row: the open one marked, what its search reads. #} {% macro ws_tr(ws) %} class="{{ 'ws-current' if workspace and ws.name == workspace.name }}" data-ws="{{ ws.name }}" data-search="{{ ws.label }} {{ ws.name }}"{% endmacro %} +{#- A workspace's launches, a link to them when it has any; when it was last opened, as digits to sort by (UTC, as every + workspace records it; never opened sorts last, newest first). #} +{% macro launches(ws) %}{% set n = n_launches[ws.name] %}{% if n %}{{ n }} + {%- else %}{{ greyed('Launches of ' ~ ws.label ~ ': 0', '', 'No launches in ' ~ ws.label, 'none-' ~ ws.name, icon='launches', class='btn ghost sm count-btn', text='0') }}{% endif %}{% endmacro %} +{% macro roots(ws) %}{% endmacro %} +{#- A workspace's rename: the pencil, and the form it swaps in for the name (the page's script); `view` the one to return to. #} +{% macro pencil(ws) %}{% endmacro %} +{% macro rename(ws, view=none) %}{% endmacro %} +{% macro opened(ws) %}{{ ws.opened[:19]|replace('-', '')|replace(':', '')|replace('T', '') or 0 }}{% endmacro %} {% block body %} {% set actions %}New workspace{% endset %} {{ page_head('Workspaces', actions=actions) }} {% if workspaces %} -{% set labels = workspaces|map(attribute='label')|list %} -{% set cols = [dict(key='open', label='Open', blank=true), dict(key='name', label='Name', width='expand'), dict(key='runs', label='Runs', type='num'), - dict(key='checks', label='Checks', type='num'), dict(key='opened', label='Last opened', type='num', align='left'), - dict(key='launches', label='Launches', type='num', align='right'), dict(key='roots', label='Roots', type='num', align='right'), dict(key='actions', label='Actions', blank=true)] %} -{% call(ws, c) table('workspaces', cols, workspaces, ws_tr, class='ws-table', search='Search by name', noun='workspaces') %} +{% set labels = workspaces|map(attribute='label')|list %}{% set trash %}{% endset %} +{% set cols = [dict(key='open', label='Open', blank=true, card='status'), dict(key='name', label='Name', width='expand', card='title'), + dict(key='disk', label='Folder', blank=true, table=false, card='text', class='mono faint'), + dict(key='runs', label='Runs', type='num', card='stat'), dict(key='checks', label='Checks', type='num', card='stat'), + dict(key='opened', label='Last opened', type='num', align='left', card='meta'), + dict(key='launches', label='Launches', type='num', align='right', card='stat'), dict(key='roots', label='Roots', type='num', align='right', card='stat'), + dict(key='actions', label='Actions', blank=true, card='delete')] %} +{% if request.args.get('view') == 'cards' %} +{#- the same fields as the table's columns, each in its card slot; a rename only in the table #} +{% set items = [] %} +{% for ws in workspaces %}{% set current = workspace and ws.name == workspace.name %} + {%- set open %}{% if current %}●{% endif %}{% endset %} + {%- set _ = items.append(dict(open=open, name=dict(text=ws.label, class='ws-name', after=pencil(ws) ~ rename(ws, 'cards')), disk=ws.name if labels.count(ws.label) > 1 else '', runs=counts[ws.name].runs, checks=counts[ws.name].checks, + opened=dict(text=ws.opened[:16]|replace('T', ' '), value=opened(ws)), launches=dict(text=launches(ws), value=n_launches[ws.name]), + roots=dict(text=roots(ws), value=ws.roots|length), + actions=dict(title='Delete workspace', attrs={'data-ask': 'ws-ask-delete', 'data-label': ws.label, 'data-action': url_for('workspace_delete', name=ws.name), 'data-judged': n_judged[ws.name], 'aria-haspopup': 'dialog', 'aria-label': 'Delete workspace ' ~ ws.label}), + search=ws.label ~ ' ' ~ ws.name)) %} +{%- endfor %} +{{ cards('workspaces', cols, items, search='Search by name', empty='No workspace matches.', noun='workspaces', sort=true, layout='cards') }} +{% else %} +{% call(ws, c) table('workspaces', cols, workspaces, ws_tr, class='ws-table', search='Search by name', noun='workspaces', layout='table') %} {%- set current = workspace and ws.name == workspace.name %}{% set clash = labels.count(ws.label) > 1 %} {%- if c.key == 'open' %}{% call cell(c) %}{% if current %}●{% endif %}{% endcall %} {%- elif c.key == 'name' %}{% call cell(c, sort=ws.label, class='ws-name') %} {#- the label; the name on disk too where two labels are alike #} {{ ws.label }}{% if clash %} {{ ws.name }}{% endif %} - - + {{ pencil(ws) }} + {{ rename(ws) }} {% endcall %} {%- elif c.key == 'runs' %}{% call cell(c) %}{{ counts[ws.name].runs }}{% endcall %} {%- elif c.key == 'checks' %}{% call cell(c) %}{{ counts[ws.name].checks }}{% endcall %} - {#- the time as digits, UTC as every workspace records it; never opened sorts last, newest first #} - {%- elif c.key == 'opened' %}{% call cell(c, sort=ws.opened[:19]|replace('-', '')|replace(':', '')|replace('T', '') or 0, class='mono faint nowrap') %}{{ ws.opened[:16]|replace('T', ' ') }}{% endcall %} - {%- elif c.key == 'launches' %}{% call cell(c) %}{% set n = n_launches[ws.name] %}{% if n %}{{ n }} - {%- else %}{{ greyed('Launches of ' ~ ws.label ~ ': 0', '', 'No launches in ' ~ ws.label, 'none-' ~ ws.name, icon='launches', class='btn ghost sm count-btn', text='0') }}{% endif %}{% endcall %} - {%- elif c.key == 'roots' %}{% call cell(c, sort=ws.roots|length) %} - - {% endcall %} + {%- elif c.key == 'opened' %}{% call cell(c, sort=opened(ws), class='mono faint nowrap') %}{{ ws.opened[:16]|replace('T', ' ') }}{% endcall %} + {%- elif c.key == 'launches' %}{% call cell(c) %}{{ launches(ws) }}{% endcall %} + {%- elif c.key == 'roots' %}{% call cell(c, sort=ws.roots|length) %}{{ roots(ws) }}{% endcall %} {%- elif c.key == 'actions' %}{% call cell(c, class='acts-col') %} - + {% endcall %} {%- endif %} {% endcall %} +{% endif %} {#- every row's Delete, filled from its button #}