-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add sorting and filter functionality in PEPhub search. #100
Comments
Related to #99 |
Are we envisioning client-side or server-side filtering? |
Sorting functionality is added to pepdbagent. Now we can add it to pephub |
I'm not positive that the pepdbagent sorting is working. I think there are two issues:
An example for 1: Sort by last update (newest). I want most recently updated projects to show up: An example for 2: Sort by name (A-Z). I want projects that start with "A" to come before projects that start with "Z": Everything seems ok from the get-go. My forked GSE's come before projects like Let me know if I am using things incorrectly. For specificity, here is the select I am using to make this request: <select
value={`${orderBy}+${order}`}
onChange={(e) => {
const [orderBy, order] = e.target.value.split('+');
setOrderBy(orderBy);
setOrder(order);
}}
className="form-control form-select"
>
<option value={'name+asc'}>Name (A-Z)</option>
<option value={'name+desc'}>Name (Z-A)</option>
<option value={'update_date+desc'}>Last update (newest)</option>
<option value={'update_date+asc'}>Last update (oldest)</option>
<option value={'submission_date+desc'}>Submission date (newest)</option>
<option value={'submission_date+asc'}>Submission date (oldest)</option>
</select> Then in the actual typescript to call the endpoint: export const getNamespaceProjects = (
namespace: string,
token: string | null = null,
{ search, offset, limit, orderBy, order }: PaginationParams,
) => {
// construct query based on search, offset, and limit
const query = new URLSearchParams();
if (search) {
query.set('q', search);
}
if (offset) {
query.set('offset', offset.toString());
}
if (limit) {
query.set('limit', limit.toString());
}
if (orderBy) {
query.set('order_by', orderBy);
}
if (order) {
if (order === 'asc') {
query.set('order_desc', 'false');
} else {
query.set('order_desc', 'true');
}
}
const url = `${API_BASE}/namespaces/${namespace}/projects?${query.toString()}`;
if (!token) {
return axios.get<NamespaceProjectsResponse>(url).then((res) => res.data);
} else {
return axios
.get<NamespaceProjectsResponse>(url, { headers: { Authorization: `Bearer ${token}` } })
.then((res) => res.data);
}
}; |
The latest |
It will be useful to add filter and sort to PEPhub. This functionality can include:
The text was updated successfully, but these errors were encountered: