feat: rework list searchbar, adds project-specific mode, add to user-joblist

This commit is contained in:
Christoph Kluge 2024-05-23 15:43:09 +02:00
parent 420bec7c46
commit 8d1228c9e8
4 changed files with 40 additions and 16 deletions

View File

@ -38,6 +38,7 @@
? !!ccconfig[`plot_list_showFootprint:${filterPresets.cluster}`] ? !!ccconfig[`plot_list_showFootprint:${filterPresets.cluster}`]
: !!ccconfig.plot_list_showFootprint; : !!ccconfig.plot_list_showFootprint;
let selectedCluster = filterPresets?.cluster ? filterPresets.cluster : null; let selectedCluster = filterPresets?.cluster ? filterPresets.cluster : null;
let presetProject = filterPresets?.project ? filterPresets.project : ""
// The filterPresets are handled by the Filters component, // The filterPresets are handled by the Filters component,
// so we need to wait for it to be ready before we can start a query. // so we need to wait for it to be ready before we can start a query.
@ -87,6 +88,7 @@
<Col xs="3" style="margin-left: auto;"> <Col xs="3" style="margin-left: auto;">
<TextFilter <TextFilter
{presetProject}
bind:authlevel bind:authlevel
bind:roles bind:roles
on:update={({ detail }) => filterComponent.update(detail)} on:update={({ detail }) => filterComponent.update(detail)}

View File

@ -12,6 +12,7 @@
} from "@sveltestrap/sveltestrap"; } from "@sveltestrap/sveltestrap";
import { queryStore, gql, getContextClient } from "@urql/svelte"; import { queryStore, gql, getContextClient } from "@urql/svelte";
import Filters from "./filters/Filters.svelte"; import Filters from "./filters/Filters.svelte";
import TextFilter from "./filters/TextFilter.svelte"
import JobList from "./joblist/JobList.svelte"; import JobList from "./joblist/JobList.svelte";
import Sorting from "./joblist/SortSelection.svelte"; import Sorting from "./joblist/SortSelection.svelte";
import Refresher from "./joblist/Refresher.svelte"; import Refresher from "./joblist/Refresher.svelte";
@ -132,6 +133,11 @@
/> />
</Col> </Col>
<Col xs="auto" style="margin-left: auto;"> <Col xs="auto" style="margin-left: auto;">
<TextFilter
on:update={({ detail }) => filterComponent.update(detail)}
/>
</Col>
<Col xs="auto">
<Refresher on:reload={() => jobList.refresh()} /> <Refresher on:reload={() => jobList.refresh()} />
</Col> </Col>
</Row> </Row>

View File

@ -194,7 +194,7 @@
if (filters.project) opts.push(`project=${filters.project}`); if (filters.project) opts.push(`project=${filters.project}`);
if (filters.jobName) opts.push(`jobName=${filters.jobName}`); if (filters.jobName) opts.push(`jobName=${filters.jobName}`);
if (filters.arrayJobId) opts.push(`arrayJobId=${filters.arrayJobId}`); if (filters.arrayJobId) opts.push(`arrayJobId=${filters.arrayJobId}`);
if (filters.projectMatch != "contains") if (filters.project && filters.projectMatch != "contains")
opts.push(`projectMatch=${filters.projectMatch}`); opts.push(`projectMatch=${filters.projectMatch}`);
if (opts.length == 0 && window.location.search.length <= 1) return; if (opts.length == 0 && window.location.search.length <= 1) return;

View File

@ -1,28 +1,29 @@
<script> <script>
import { InputGroup, Input } from "@sveltestrap/sveltestrap"; import { InputGroup, Input, Button, Icon } from "@sveltestrap/sveltestrap";
import { createEventDispatcher } from "svelte"; import { createEventDispatcher } from "svelte";
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
export let authlevel; export let presetProject = ""; // If page with this component has project preset, keep preset until reset
export let roles; export let authlevel = null;
let mode = "user"; export let roles = null;
let mode = presetProject ? "jobName" : "project";
let term = ""; let term = "";
let user = ""; let user = "";
let project = ""; let project = presetProject ? presetProject : "";
let jobName = ""; let jobName = "";
const throttle = 500; const throttle = 500;
function modeChanged() { function modeChanged() {
if (mode == "user") { if (mode == "user") {
project = term; project = presetProject ? presetProject : "";
term = user; jobName = "";
} else if (mode == "project") { } else if (mode == "project") {
user = term; user = "";
term = project; jobName = "";
} else { } else {
jobName = term; project = presetProject ? presetProject : "";
term = jobName; user = "";
} }
termChanged(0); termChanged(0);
} }
@ -30,7 +31,7 @@
let timeoutId = null; let timeoutId = null;
// Compatibility: Handle "user role" and "no role" identically // Compatibility: Handle "user role" and "no role" identically
function termChanged(sleep = throttle) { function termChanged(sleep = throttle) {
if (authlevel >= roles.manager) { if (roles && authlevel >= roles.manager) {
if (mode == "user") user = term; if (mode == "user") user = term;
else if (mode == "project") project = term; else if (mode == "project") project = term;
else jobName = term; else jobName = term;
@ -58,6 +59,14 @@
}, sleep); }, sleep);
} }
} }
function resetProject () {
mode = "project"
term = ""
presetProject = ""
project = ""
termChanged(0);
}
</script> </script>
<InputGroup> <InputGroup>
@ -67,10 +76,12 @@
bind:value={mode} bind:value={mode}
on:change={modeChanged} on:change={modeChanged}
> >
{#if authlevel >= roles.manager} {#if !presetProject}
<option value={"project"}>Search Project</option>
{/if}
{#if roles && authlevel >= roles.manager}
<option value={"user"}>Search User</option> <option value={"user"}>Search User</option>
{/if} {/if}
<option value={"project"}>Search Project</option>
<option value={"jobName"}>Search Jobname</option> <option value={"jobName"}>Search Jobname</option>
</select> </select>
<Input <Input
@ -78,7 +89,12 @@
bind:value={term} bind:value={term}
on:change={() => termChanged()} on:change={() => termChanged()}
on:keyup={(event) => termChanged(event.key == "Enter" ? 0 : throttle)} on:keyup={(event) => termChanged(event.key == "Enter" ? 0 : throttle)}
placeholder={`filter ${mode}...`} placeholder={presetProject ? `Filter ${mode} in ${presetProject} ...` : `Filter ${mode} ...`}
/> />
{#if presetProject}
<Button title="Reset Project" on:click={resetProject}
><Icon name="arrow-counterclockwise" /></Button
>
{/if}
</InputGroup> </InputGroup>