mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-01-28 06:51:45 +01:00
move list filter preset to url
This commit is contained in:
@@ -456,7 +456,7 @@ func HandleSearchBar(rw http.ResponseWriter, r *http.Request, buildInfo web.Buil
|
|||||||
http.Redirect(rw, r, "/monitoring/jobs/?startTime="+fromTime+"-"+untilTime+"&arrayJobId="+url.QueryEscape(strings.Trim(splitSearch[1], " ")), http.StatusFound) // All Users: Redirect to Tablequery
|
http.Redirect(rw, r, "/monitoring/jobs/?startTime="+fromTime+"-"+untilTime+"&arrayJobId="+url.QueryEscape(strings.Trim(splitSearch[1], " ")), http.StatusFound) // All Users: Redirect to Tablequery
|
||||||
case "username":
|
case "username":
|
||||||
if user.HasAnyRole([]schema.Role{schema.RoleAdmin, schema.RoleSupport, schema.RoleManager}) {
|
if user.HasAnyRole([]schema.Role{schema.RoleAdmin, schema.RoleSupport, schema.RoleManager}) {
|
||||||
http.Redirect(rw, r, "/monitoring/users/?user="+url.QueryEscape(strings.Trim(splitSearch[1], " ")), http.StatusFound)
|
http.Redirect(rw, r, "/monitoring/users/?user="+url.QueryEscape(strings.Trim(splitSearch[1], " "))+"&startTime=last30d", http.StatusFound)
|
||||||
} else {
|
} else {
|
||||||
web.RenderTemplate(rw, "message.tmpl", &web.Page{Title: "Error", MsgType: "alert-danger", Message: "Missing Access Rights", User: *user, Roles: availableRoles, Build: buildInfo})
|
web.RenderTemplate(rw, "message.tmpl", &web.Page{Title: "Error", MsgType: "alert-danger", Message: "Missing Access Rights", User: *user, Roles: availableRoles, Build: buildInfo})
|
||||||
}
|
}
|
||||||
@@ -464,10 +464,10 @@ func HandleSearchBar(rw http.ResponseWriter, r *http.Request, buildInfo web.Buil
|
|||||||
usernames, _ := repo.FindColumnValues(user, strings.Trim(splitSearch[1], " "), "user", "username", "name")
|
usernames, _ := repo.FindColumnValues(user, strings.Trim(splitSearch[1], " "), "user", "username", "name")
|
||||||
if len(usernames) != 0 {
|
if len(usernames) != 0 {
|
||||||
joinedNames := strings.Join(usernames, "&user=")
|
joinedNames := strings.Join(usernames, "&user=")
|
||||||
http.Redirect(rw, r, "/monitoring/users/?user="+joinedNames, http.StatusFound)
|
http.Redirect(rw, r, "/monitoring/users/?user="+joinedNames+"&startTime=last30d", http.StatusFound)
|
||||||
} else {
|
} else {
|
||||||
if user.HasAnyRole([]schema.Role{schema.RoleAdmin, schema.RoleSupport, schema.RoleManager}) {
|
if user.HasAnyRole([]schema.Role{schema.RoleAdmin, schema.RoleSupport, schema.RoleManager}) {
|
||||||
http.Redirect(rw, r, "/monitoring/users/?user=NoUserNameFound", http.StatusPermanentRedirect)
|
http.Redirect(rw, r, "/monitoring/users/?user=NoUserNameFound&startTime=last30d", http.StatusPermanentRedirect)
|
||||||
} else {
|
} else {
|
||||||
web.RenderTemplate(rw, "message.tmpl", &web.Page{Title: "Error", MsgType: "alert-danger", Message: "Missing Access Rights", User: *user, Roles: availableRoles, Build: buildInfo})
|
web.RenderTemplate(rw, "message.tmpl", &web.Page{Title: "Error", MsgType: "alert-danger", Message: "Missing Access Rights", User: *user, Roles: availableRoles, Build: buildInfo})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,19 +95,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* On Mount */
|
/* On Mount */
|
||||||
onMount(() => {
|
onMount(() => filterComponent.updateFilters());
|
||||||
// By default, look at the jobs of the last 30 days:
|
|
||||||
if (filterPresets?.startTime == null) {
|
|
||||||
if (filterPresets == null) filterPresets = {};
|
|
||||||
|
|
||||||
filterPresets.startTime = {
|
|
||||||
range: "last30d",
|
|
||||||
text: "Last 30 Days",
|
|
||||||
};
|
|
||||||
};
|
|
||||||
// Init Filter
|
|
||||||
filterComponent.updateFilters();
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Row cols={{ xs: 1, md: 2}}>
|
<Row cols={{ xs: 1, md: 2}}>
|
||||||
|
|||||||
@@ -91,38 +91,38 @@
|
|||||||
/* State Init */
|
/* State Init */
|
||||||
// svelte-ignore state_referenced_locally
|
// svelte-ignore state_referenced_locally
|
||||||
let filters = $state({
|
let filters = $state({
|
||||||
dbId: filterPresets.dbId || [],
|
dbId: filterPresets?.dbId || [],
|
||||||
jobId: filterPresets.jobId || "",
|
jobId: filterPresets?.jobId || "",
|
||||||
jobIdMatch: filterPresets.jobIdMatch || "eq",
|
jobIdMatch: filterPresets?.jobIdMatch || "eq",
|
||||||
arrayJobId: filterPresets.arrayJobId || null,
|
arrayJobId: filterPresets?.arrayJobId || null,
|
||||||
jobName: filterPresets.jobName || "",
|
jobName: filterPresets?.jobName || "",
|
||||||
project: filterPresets.project || "",
|
project: filterPresets?.project || "",
|
||||||
projectMatch: filterPresets.projectMatch || "contains",
|
projectMatch: filterPresets?.projectMatch || "contains",
|
||||||
user: filterPresets.user || "",
|
user: filterPresets?.user || "",
|
||||||
userMatch: filterPresets.userMatch || "contains",
|
userMatch: filterPresets?.userMatch || "contains",
|
||||||
cluster: filterPresets.cluster || null,
|
cluster: filterPresets?.cluster || null,
|
||||||
partition: filterPresets.partition || null,
|
partition: filterPresets?.partition || null,
|
||||||
states:
|
states:
|
||||||
filterPresets.states || filterPresets.state
|
filterPresets?.states || filterPresets?.state
|
||||||
? [filterPresets.state].flat()
|
? [filterPresets.state].flat()
|
||||||
: allJobStates,
|
: allJobStates,
|
||||||
shared: filterPresets.shared || "",
|
shared: filterPresets?.shared || "",
|
||||||
schedule: filterPresets.schedule || "",
|
schedule: filterPresets?.schedule || "",
|
||||||
startTime: filterPresets.startTime || { from: null, to: null, range: ""},
|
startTime: filterPresets?.startTime || { from: null, to: null, range: ""},
|
||||||
duration: filterPresets.duration || {
|
duration: filterPresets?.duration || {
|
||||||
lessThan: null,
|
lessThan: null,
|
||||||
moreThan: null,
|
moreThan: null,
|
||||||
from: null,
|
from: null,
|
||||||
to: null,
|
to: null,
|
||||||
},
|
},
|
||||||
tags: filterPresets.tags || [],
|
tags: filterPresets?.tags || [],
|
||||||
numNodes: filterPresets.numNodes || { from: null, to: null },
|
numNodes: filterPresets?.numNodes || { from: null, to: null },
|
||||||
numHWThreads: filterPresets.numHWThreads || { from: null, to: null },
|
numHWThreads: filterPresets?.numHWThreads || { from: null, to: null },
|
||||||
numAccelerators: filterPresets.numAccelerators || { from: null, to: null },
|
numAccelerators: filterPresets?.numAccelerators || { from: null, to: null },
|
||||||
node: filterPresets.node || null,
|
node: filterPresets?.node || null,
|
||||||
nodeMatch: filterPresets.nodeMatch || "eq",
|
nodeMatch: filterPresets?.nodeMatch || "eq",
|
||||||
energy: filterPresets.energy || { from: null, to: null },
|
energy: filterPresets?.energy || { from: null, to: null },
|
||||||
stats: filterPresets.stats || [],
|
stats: filterPresets?.stats || [],
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Opened States */
|
/* Opened States */
|
||||||
|
|||||||
@@ -92,7 +92,7 @@
|
|||||||
{/each}
|
{/each}
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
{:else}
|
{:else} <!-- Lists -->
|
||||||
<Dropdown nav inNavbar {direction}>
|
<Dropdown nav inNavbar {direction}>
|
||||||
<DropdownToggle nav caret>
|
<DropdownToggle nav caret>
|
||||||
<Icon name={item.icon} />
|
<Icon name={item.icon} />
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
</DropdownToggle>
|
</DropdownToggle>
|
||||||
<DropdownMenu class="dropdown-menu-lg-end">
|
<DropdownMenu class="dropdown-menu-lg-end">
|
||||||
<DropdownItem
|
<DropdownItem
|
||||||
href={item.href}
|
href={`${item.href}?startTime=last30d`}
|
||||||
>
|
>
|
||||||
All Clusters
|
All Clusters
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
@@ -112,12 +112,12 @@
|
|||||||
</DropdownToggle>
|
</DropdownToggle>
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownItem class="py-1 px-2"
|
<DropdownItem class="py-1 px-2"
|
||||||
href={`${item.href}?cluster=${cn}`}
|
href={`${item.href}?cluster=${cn}&startTime=last30d`}
|
||||||
>
|
>
|
||||||
All Jobs
|
All Jobs
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
<DropdownItem class="py-1 px-2"
|
<DropdownItem class="py-1 px-2"
|
||||||
href={`${item.href}?cluster=${cn}&state=running`}
|
href={`${item.href}?cluster=${cn}&state=running&startTime=last30d`}
|
||||||
>
|
>
|
||||||
Running Jobs
|
Running Jobs
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
|
|||||||
@@ -171,7 +171,7 @@
|
|||||||
Users
|
Users
|
||||||
</InputGroupText>
|
</InputGroupText>
|
||||||
<Input class="flex-grow-1" style="background-color: white;" type="text" value="{userList?.length || 0} User{(userList?.length == 1) ? '': 's'}" disabled />
|
<Input class="flex-grow-1" style="background-color: white;" type="text" value="{userList?.length || 0} User{(userList?.length == 1) ? '': 's'}" disabled />
|
||||||
<a title="Show users active on this node" href="/monitoring/users/?cluster={cluster}&state=running&node={hostname}" target="_blank" class="btn btn-outline-primary" role="button" aria-disabled="true" >
|
<a title="Show users active on this node" href="/monitoring/users/?cluster={cluster}&state=running&startTime=last30d&node={hostname}" target="_blank" class="btn btn-outline-primary" role="button" aria-disabled="true" >
|
||||||
<Icon name="view-list" />
|
<Icon name="view-list" />
|
||||||
List
|
List
|
||||||
</a>
|
</a>
|
||||||
@@ -192,7 +192,7 @@
|
|||||||
Projects
|
Projects
|
||||||
</InputGroupText>
|
</InputGroupText>
|
||||||
<Input class="flex-grow-1" style="background-color: white;" type="text" value="{projectList?.length || 0} Project{(projectList?.length == 1) ? '': 's'}" disabled />
|
<Input class="flex-grow-1" style="background-color: white;" type="text" value="{projectList?.length || 0} Project{(projectList?.length == 1) ? '': 's'}" disabled />
|
||||||
<a title="Show projects active on this node" href="/monitoring/projects/?cluster={cluster}&state=running&node={hostname}" target="_blank" class="btn btn-outline-primary" role="button" aria-disabled="true" >
|
<a title="Show projects active on this node" href="/monitoring/projects/?cluster={cluster}&state=running&startTime=last30d&node={hostname}" target="_blank" class="btn btn-outline-primary" role="button" aria-disabled="true" >
|
||||||
<Icon name="view-list" />
|
<Icon name="view-list" />
|
||||||
List
|
List
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user