mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-16 04:02:52 -06:00
#7081: Fix APISelect loading of paginated data
This commit is contained in:
parent
679bbd3e76
commit
5b87232f59
BIN
netbox/project-static/dist/config.js
vendored
BIN
netbox/project-static/dist/config.js
vendored
Binary file not shown.
BIN
netbox/project-static/dist/config.js.map
vendored
BIN
netbox/project-static/dist/config.js.map
vendored
Binary file not shown.
BIN
netbox/project-static/dist/jobs.js
vendored
BIN
netbox/project-static/dist/jobs.js
vendored
Binary file not shown.
BIN
netbox/project-static/dist/jobs.js.map
vendored
BIN
netbox/project-static/dist/jobs.js.map
vendored
Binary file not shown.
BIN
netbox/project-static/dist/lldp.js
vendored
BIN
netbox/project-static/dist/lldp.js
vendored
Binary file not shown.
BIN
netbox/project-static/dist/lldp.js.map
vendored
BIN
netbox/project-static/dist/lldp.js.map
vendored
Binary file not shown.
BIN
netbox/project-static/dist/netbox.js
vendored
BIN
netbox/project-static/dist/netbox.js
vendored
Binary file not shown.
BIN
netbox/project-static/dist/netbox.js.map
vendored
BIN
netbox/project-static/dist/netbox.js.map
vendored
Binary file not shown.
BIN
netbox/project-static/dist/status.js
vendored
BIN
netbox/project-static/dist/status.js
vendored
Binary file not shown.
BIN
netbox/project-static/dist/status.js.map
vendored
BIN
netbox/project-static/dist/status.js.map
vendored
Binary file not shown.
@ -470,6 +470,7 @@ export class APISelect {
|
|||||||
break;
|
break;
|
||||||
case 'replace':
|
case 'replace':
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasMore(data)) {
|
if (hasMore(data)) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import Cookie from 'cookie';
|
import Cookie from 'cookie';
|
||||||
|
import queryString from 'query-string';
|
||||||
|
|
||||||
type Method = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
|
type Method = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
|
||||||
type ReqData = URLSearchParams | Dict | undefined | unknown;
|
type ReqData = URLSearchParams | Dict | undefined | unknown;
|
||||||
@ -127,16 +128,31 @@ function getCsrfToken(): string {
|
|||||||
*
|
*
|
||||||
* @param path Relative path _after_ (excluding) the `BASE_PATH`.
|
* @param path Relative path _after_ (excluding) the `BASE_PATH`.
|
||||||
*/
|
*/
|
||||||
function buildUrl(path: string): string {
|
function buildUrl(destination: string): string {
|
||||||
|
// Separate the path from any URL search params.
|
||||||
|
const [pathname, search] = destination.split(/(?=\?)/g);
|
||||||
|
|
||||||
|
// If the `origin` exists in the API path (as in the case of paginated responses), remove it.
|
||||||
|
const origin = new RegExp(window.location.origin, 'g');
|
||||||
|
const path = pathname.replaceAll(origin, '');
|
||||||
|
|
||||||
const basePath = getBasePath();
|
const basePath = getBasePath();
|
||||||
|
|
||||||
|
// Combine `BASE_PATH` with this request's path, removing _all_ slashes.
|
||||||
let combined = [...basePath.split('/'), ...path.split('/')].filter(p => p);
|
let combined = [...basePath.split('/'), ...path.split('/')].filter(p => p);
|
||||||
|
|
||||||
if (combined[0] !== '/') {
|
if (combined[0] !== '/') {
|
||||||
|
// Ensure the URL has a leading slash.
|
||||||
combined = ['', ...combined];
|
combined = ['', ...combined];
|
||||||
}
|
}
|
||||||
if (combined[combined.length - 1] !== '/') {
|
if (combined[combined.length - 1] !== '/') {
|
||||||
|
// Ensure the URL has a trailing slash.
|
||||||
combined = [...combined, ''];
|
combined = [...combined, ''];
|
||||||
}
|
}
|
||||||
return combined.join('/');
|
const url = combined.join('/');
|
||||||
|
// Construct an object from the URL search params so it can be re-serialized with the new URL.
|
||||||
|
const query = Object.fromEntries(new URLSearchParams(search).entries());
|
||||||
|
return queryString.stringifyUrl({ url, query });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function apiRequest<R extends Dict, D extends ReqData = undefined>(
|
export async function apiRequest<R extends Dict, D extends ReqData = undefined>(
|
||||||
|
Loading…
Reference in New Issue
Block a user