mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-08-16 22:06:51 +00:00
Moved v3 code from NginxProxyManager/nginx-proxy-manager-3 to NginxProxyManager/nginx-proxy-manager
This commit is contained in:
34
frontend/src/api/npm/helpers.ts
Normal file
34
frontend/src/api/npm/helpers.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { decamelize } from "humps";
|
||||
|
||||
/**
|
||||
* This will convert a react-table sort object into
|
||||
* a string that the backend api likes:
|
||||
* name.asc,id.desc
|
||||
*/
|
||||
export function tableSortToAPI(sortBy: any): string | undefined {
|
||||
if (sortBy?.length > 0) {
|
||||
const strs: string[] = [];
|
||||
sortBy.map((item: any) => {
|
||||
strs.push(decamelize(item.id) + "." + (item.desc ? "desc" : "asc"));
|
||||
return undefined;
|
||||
});
|
||||
return strs.join(",");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will convert a react-table filters object into
|
||||
* a string that the backend api likes:
|
||||
* name:contains=jam
|
||||
*/
|
||||
export function tableFiltersToAPI(filters: any): { [key: string]: string } {
|
||||
const items: { [key: string]: string } = {};
|
||||
if (filters?.length > 0) {
|
||||
filters.map((item: any) => {
|
||||
items[`${decamelize(item.id)}:${item.value.modifier}`] = item.value.value;
|
||||
return undefined;
|
||||
});
|
||||
}
|
||||
return items;
|
||||
}
|
Reference in New Issue
Block a user