mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-04 06:38:16 -06:00
Fixes #7162: Fix API-populated form fields when BASE_PATH is defined
This commit is contained in:
parent
27c0e6dd5e
commit
acb24489d1
@ -5,6 +5,7 @@
|
|||||||
* [#7131](https://github.com/netbox-community/netbox/issues/7131) - Fix issue where Site fields were hidden when editing a VLAN group
|
* [#7131](https://github.com/netbox-community/netbox/issues/7131) - Fix issue where Site fields were hidden when editing a VLAN group
|
||||||
* [#7148](https://github.com/netbox-community/netbox/issues/7148) - Fix issue where static query parameters with multiple values were not queried properly
|
* [#7148](https://github.com/netbox-community/netbox/issues/7148) - Fix issue where static query parameters with multiple values were not queried properly
|
||||||
* [#7153](https://github.com/netbox-community/netbox/issues/7153) - Allow clearing of assigned device type images
|
* [#7153](https://github.com/netbox-community/netbox/issues/7153) - Allow clearing of assigned device type images
|
||||||
|
* [#7162](https://github.com/netbox-community/netbox/issues/7162) - Fix API-populated form fields when `BASE_PATH` is defined
|
||||||
* [#7164](https://github.com/netbox-community/netbox/issues/7164) - Fix styling of "decommissioned" label for circuits
|
* [#7164](https://github.com/netbox-community/netbox/issues/7164) - Fix styling of "decommissioned" label for circuits
|
||||||
* [#7169](https://github.com/netbox-community/netbox/issues/7169) - Fix CSV import file upload
|
* [#7169](https://github.com/netbox-community/netbox/issues/7169) - Fix CSV import file upload
|
||||||
|
|
||||||
|
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.
@ -1,5 +1,5 @@
|
|||||||
import { createToast } from './bs';
|
import { createToast } from './bs';
|
||||||
import { getElements, apiPatch, hasError, getSelectedOptions } from './util';
|
import { getElements, apiPatch, buildUrl, hasError, getSelectedOptions } from './util';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark each option element in the selected columns element as 'selected' so they are submitted to
|
* Mark each option element in the selected columns element as 'selected' so they are submitted to
|
||||||
@ -54,7 +54,8 @@ function removeColumns(event: Event): void {
|
|||||||
* Submit form configuration to the NetBox API.
|
* Submit form configuration to the NetBox API.
|
||||||
*/
|
*/
|
||||||
async function submitFormConfig(formConfig: Dict<Dict>): Promise<APIResponse<APIUserConfig>> {
|
async function submitFormConfig(formConfig: Dict<Dict>): Promise<APIResponse<APIUserConfig>> {
|
||||||
return await apiPatch<APIUserConfig>('/api/users/config/', formConfig);
|
const url = buildUrl('/api/users/config/');
|
||||||
|
return await apiPatch<APIUserConfig>(url, formConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,7 +111,8 @@ function getCsrfToken(): string {
|
|||||||
* Get the NetBox `settings.BASE_PATH` from the `<html/>` element's data attributes.
|
* Get the NetBox `settings.BASE_PATH` from the `<html/>` element's data attributes.
|
||||||
*
|
*
|
||||||
* @returns If there is no `BASE_PATH` specified, the return value will be `''`.
|
* @returns If there is no `BASE_PATH` specified, the return value will be `''`.
|
||||||
*/ function getBasePath(): string {
|
*/
|
||||||
|
function getBasePath(): string {
|
||||||
const value = document.documentElement.getAttribute('data-netbox-base-path');
|
const value = document.documentElement.getAttribute('data-netbox-base-path');
|
||||||
if (value === null) {
|
if (value === null) {
|
||||||
return '';
|
return '';
|
||||||
@ -156,7 +157,7 @@ function queryParamsToObject(params: string): Record<string, Stringifiable[]> {
|
|||||||
*
|
*
|
||||||
* @param path Relative path _after_ (excluding) the `BASE_PATH`.
|
* @param path Relative path _after_ (excluding) the `BASE_PATH`.
|
||||||
*/
|
*/
|
||||||
function buildUrl(destination: string): string {
|
export function buildUrl(destination: string): string {
|
||||||
// Separate the path from any URL search params.
|
// Separate the path from any URL search params.
|
||||||
const [pathname, search] = destination.split(/(?=\?)/g);
|
const [pathname, search] = destination.split(/(?=\?)/g);
|
||||||
|
|
||||||
@ -184,7 +185,7 @@ function buildUrl(destination: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function apiRequest<R extends Dict, D extends ReqData = undefined>(
|
export async function apiRequest<R extends Dict, D extends ReqData = undefined>(
|
||||||
path: string,
|
url: string,
|
||||||
method: Method,
|
method: Method,
|
||||||
data?: D,
|
data?: D,
|
||||||
): Promise<APIResponse<R>> {
|
): Promise<APIResponse<R>> {
|
||||||
@ -196,7 +197,6 @@ export async function apiRequest<R extends Dict, D extends ReqData = undefined>(
|
|||||||
body = JSON.stringify(data);
|
body = JSON.stringify(data);
|
||||||
headers.set('content-type', 'application/json');
|
headers.set('content-type', 'application/json');
|
||||||
}
|
}
|
||||||
const url = buildUrl(path);
|
|
||||||
|
|
||||||
const res = await fetch(url, { method, body, headers, credentials: 'same-origin' });
|
const res = await fetch(url, { method, body, headers, credentials: 'same-origin' });
|
||||||
const contentType = res.headers.get('Content-Type');
|
const contentType = res.headers.get('Content-Type');
|
||||||
|
Loading…
Reference in New Issue
Block a user