Skip to content

Commit 1dd7543

Browse files
author
Jicheng Lu
committed
refine agent header reset
1 parent 97cea81 commit 1dd7543

File tree

8 files changed

+54
-17
lines changed

8 files changed

+54
-17
lines changed

src/lib/helpers/utils/common.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,19 @@ export function getPagingQueryParams(args, defaults = { defaultPageSize: 12, max
120120
/**
121121
* @param {URL} url
122122
* @param {import('$commonTypes').KeyValuePair[]} pairs
123-
* @param {() => void} [callback]
123+
* @param {(args0: URL) => void} [callback]
124124
*/
125125
export function setUrlQueryParams(url, pairs, callback) {
126126
if (!pairs?.length) {
127127
return;
128128
}
129129

130+
url.search = '';
130131
pairs?.map(p => {
131132
url.searchParams.set(p.key, p.value);
132133
});
133134

134-
callback?.();
135+
callback?.(url);
135136
}
136137

137138
/**

src/lib/scss/custom/pages/_agent.scss

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,37 @@
11
.agents-header-container {
22
display: flex;
3+
flex-wrap: wrap;
34
justify-content: space-between;
5+
gap: 15px;
6+
align-items: center;
7+
8+
@media (max-width: 576px) {
9+
flex-direction: column;
10+
justify-content: center;
11+
gap: 12px;
12+
13+
> div {
14+
width: 100%;
15+
display: flex;
16+
justify-content: center;
17+
}
18+
}
419

520
.agent-filter {
621
display: flex;
7-
gap: 10px
22+
flex-wrap: wrap;
23+
gap: 10px;
24+
align-items: center;
25+
26+
@media (max-width: 576px) {
27+
width: 100%;
28+
flex-direction: column;
29+
gap: 8px;
30+
31+
> * {
32+
width: 100%;
33+
}
34+
}
835
}
936
}
1037

src/routes/VerticalLayout/Sidebar.svelte

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,15 @@
202202
203203
/** @param {string} url */
204204
const goToPage = (url) => {
205-
if (!url) return;
205+
if (!url) {
206+
return;
207+
}
206208
207209
url = getCleanUrl(url);
210+
if (url === getCleanUrl($page.url.pathname)) {
211+
return;
212+
}
213+
208214
globalEventStore.reset();
209215
goto(url);
210216
}

src/routes/page/agent/+page.svelte

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@
199199
queryParams.push({ key: 'similarName', value: encodeURIComponent(filter.similarName) });
200200
}
201201
202-
setUrlQueryParams($page.url, queryParams, () => {
202+
setUrlQueryParams($page.url, queryParams, (url) => {
203203
if (!isPageMounted) return;
204-
goToUrl(`${$page.url.pathname}${$page.url.search}`)
204+
goToUrl(`${url.pathname}${url.search}`)
205205
});
206206
}
207207
@@ -243,6 +243,9 @@
243243
function reset() {
244244
selectedAgentTypes = [];
245245
selectedAgentLabels = [];
246+
247+
filter = { ...initFilter };
248+
getPagedAgents();
246249
}
247250
248251
function refreshFilter() {
@@ -273,7 +276,7 @@
273276
<div>
274277
{#if !!user && (ADMIN_ROLES.includes(user.role || '') || !!user.permissions?.includes(UserPermission.CreateAgent))}
275278
<Button color="primary" on:click={() => createNewAgent()}>
276-
<i class="bx bx-copy" /> {$_('New Agent')}
279+
<i class="mdi mdi-content-copy" /> {$_('New Agent')}
277280
</Button>
278281
{/if}
279282
</div>
@@ -308,10 +311,10 @@
308311
<i class="mdi mdi-magnify" />
309312
</Button>
310313
<Button
311-
class="btn btn-light"
314+
class="btn btn-warning"
312315
data-bs-toggle="tooltip"
313316
data-bs-placement="bottom"
314-
title="Reset filters"
317+
title="Reset"
315318
on:click={(e) => reset()}
316319
>
317320
<i class="mdi mdi-restore" />

src/routes/page/conversation/+page.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@
189189
setUrlQueryParams($page.url, [
190190
{ key: 'page', value: `${pager.page}` },
191191
{ key: 'pageSize', value: `${pager.size}` }
192-
], () => {
192+
], (url) => {
193193
if (!isPageMounted) return;
194-
goToUrl(`${$page.url.pathname}${$page.url.search}`);
194+
goToUrl(`${url.pathname}${url.search}`);
195195
});
196196
}
197197

src/routes/page/instruction/log/+page.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@
180180
setUrlQueryParams($page.url, [
181181
{ key: 'page', value: `${pager.page}` },
182182
{ key: 'pageSize', value: `${pager.size}` }
183-
], () => {
183+
], (url) => {
184184
if (!isPageMounted) return;
185-
goToUrl(`${$page.url.pathname}${$page.url.search}`);
185+
goToUrl(`${url.pathname}${url.search}`);
186186
});
187187
}
188188

src/routes/page/plugin/+page.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@
109109
setUrlQueryParams($page.url, [
110110
{ key: 'page', value: `${pager.page}` },
111111
{ key: 'pageSize', value: `${pager.size}` }
112-
], () => {
112+
], (url) => {
113113
if (!isPageMounted) return;
114-
goToUrl(`${$page.url.pathname}${$page.url.search}`);
114+
goToUrl(`${url.pathname}${url.search}`);
115115
});
116116
}
117117

src/routes/page/users/+page.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@
162162
setUrlQueryParams($page.url, [
163163
{ key: 'page', value: `${pager.page}` },
164164
{ key: 'pageSize', value: `${pager.size}` }
165-
], () => {
165+
], (url) => {
166166
if (!isPageMounted) return;
167-
goToUrl(`${$page.url.pathname}${$page.url.search}`);
167+
goToUrl(`${url.pathname}${url.search}`);
168168
});
169169
}
170170

0 commit comments

Comments
 (0)