Skip to content

Commit f389fbf

Browse files
committed
Store table sort state in the URL
1 parent 54ffe3b commit f389fbf

File tree

1 file changed

+31
-2
lines changed
  • site/frontend/src/pages/detailed-query

1 file changed

+31
-2
lines changed

site/frontend/src/pages/detailed-query/page.vue

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script setup lang="ts">
22
import {ref, onMounted, Ref, computed} from "vue";
33
import {
4-
getUrlParams
4+
getUrlParams,
5+
changeUrl
56
} from "../../utils/navigation";
67
import {postMsgpack} from "../../utils/requests";
78
import {SELF_PROFILE_DATA_URL} from "../../urls";
@@ -104,7 +105,7 @@ const tableData = computed(() => {
104105
}
105106
106107
// Handle string vs number comparison
107-
let comparison;
108+
let comparison: number;
108109
if (typeof aValue === "string" && typeof bValue === "string") {
109110
comparison = aValue.localeCompare(bValue);
110111
} else {
@@ -129,9 +130,34 @@ function handlePerfettoClick(event: Event, link: string, title: string) {
129130
openTraceInPerfetto(link, title);
130131
}
131132
133+
function loadSortFromUrl(urlParams: Dict<string>) {
134+
const sort = urlParams["sort"] ?? "-timeSeconds"; // Default to descending timeSeconds
135+
// Handle sort format: either "columnName" for asc or "-columnName" for desc
136+
if (sort.startsWith("-")) {
137+
currentSortColumn.value = sort.substring(1);
138+
currentSortDirection.value = "desc";
139+
} else {
140+
currentSortColumn.value = sort;
141+
currentSortDirection.value = "asc";
142+
}
143+
}
144+
145+
function storeSortToUrl() {
146+
const params = getUrlParams();
147+
const sortValue = currentSortDirection.value === "desc"
148+
? `-${currentSortColumn.value}`
149+
: currentSortColumn.value;
150+
params["sort"] = sortValue;
151+
changeUrl(params);
152+
}
153+
132154
async function loadData() {
133155
const params = getUrlParams();
134156
const {commit, base_commit, benchmark, scenario} = params;
157+
158+
// Load sort state from URL
159+
loadSortFromUrl(params);
160+
135161
const currentSelector: Selector = {
136162
commit,
137163
base_commit: base_commit ?? null,
@@ -168,6 +194,9 @@ function sortTable(columnName: string, defaultDirection: number) {
168194
currentSortColumn.value = columnName;
169195
currentSortDirection.value = defaultDirection === 1 ? "asc" : "desc";
170196
}
197+
198+
// Update URL with new sort state
199+
storeSortToUrl();
171200
}
172201
173202
function getSortAttributes(columnName: string) {

0 commit comments

Comments
 (0)