Use relative URLs throughout the UI

To allow serving from a subdirectory using a reverse proxy.
This commit is contained in:
Zaid Abdulla committed 2020-07-22 11:07:32 -07:00
1 parent c2c24f5c24
commit 5a9e03db2c
12 files changed
+30 -30

No files matched your search

+1 -1
View File
@@ -140,7 +140,7 @@ const component: ClosureComponent = (): Component => {
m( m(
"a.download-csv", "a.download-csv",
{ {
href: `/api/devices/${encodeURIComponent( href: `api/devices/${encodeURIComponent(
device["DeviceID.ID"].value[0] device["DeviceID.ID"].value[0]
)}.csv`, )}.csv`,
download: "", download: "",
+1 -1
View File
@@ -47,7 +47,7 @@ const memoizedGetSortable = memoize(p => {
const getDownloadUrl = memoize((filter, indexParameters) => { const getDownloadUrl = memoize((filter, indexParameters) => {
const columns = {}; const columns = {};
for (const p of indexParameters) columns[p.label] = stringify(p.parameter); for (const p of indexParameters) columns[p.label] = stringify(p.parameter);
return `/api/devices.csv?${m.buildQueryString({ return `api/devices.csv?${m.buildQueryString({
filter: stringify(filter), filter: stringify(filter),
columns: JSON.stringify(columns) columns: JSON.stringify(columns)
})}`; })}`;
+1 -1
View File
@@ -51,7 +51,7 @@ const getDownloadUrl = memoize(filter => {
attr.id === "timestamp" ? `DATE_STRING(${attr.id})` : attr.id; attr.id === "timestamp" ? `DATE_STRING(${attr.id})` : attr.id;
} }
return `/api/faults.csv?${m.buildQueryString({ return `api/faults.csv?${m.buildQueryString({
filter: stringify(filter), filter: stringify(filter),
columns: JSON.stringify(cols) columns: JSON.stringify(cols)
})}`; })}`;
+2 -2
View File
@@ -108,7 +108,7 @@ function putActionHandler(action, _object): Promise<ValidationErrors> {
.xhrRequest({ .xhrRequest({
method: "PUT", method: "PUT",
headers: headers, headers: headers,
url: `/api/files/${encodeURIComponent(id)}`, url: `api/files/${encodeURIComponent(id)}`,
serialize: body => body, // Identity function to prevent JSON.parse on blob data serialize: body => body, // Identity function to prevent JSON.parse on blob data
body: file body: file
}) })
@@ -132,7 +132,7 @@ function putActionHandler(action, _object): Promise<ValidationErrors> {
const getDownloadUrl = memoize(filter => { const getDownloadUrl = memoize(filter => {
const cols = {}; const cols = {};
for (const attr of attributes) cols[attr.label] = attr.id; for (const attr of attributes) cols[attr.label] = attr.id;
return `/api/files.csv?${m.buildQueryString({ return `api/files.csv?${m.buildQueryString({
filter: stringify(filter), filter: stringify(filter),
columns: JSON.stringify(cols) columns: JSON.stringify(cols)
})}`; })}`;
+1 -1
View File
@@ -157,7 +157,7 @@ const formData = {
const getDownloadUrl = memoize(filter => { const getDownloadUrl = memoize(filter => {
const cols = {}; const cols = {};
for (const attr of attributes) cols[attr.label] = attr.id; for (const attr of attributes) cols[attr.label] = attr.id;
return `/api/permissions.csv?${m.buildQueryString({ return `api/permissions.csv?${m.buildQueryString({
filter: stringify(filter), filter: stringify(filter),
columns: JSON.stringify(cols) columns: JSON.stringify(cols)
})}`; })}`;
+2 -2
View File
@@ -49,7 +49,7 @@ function drawChart(chartData): Children {
m( m(
"a", "a",
{ {
href: `/#!/devices/?${m.buildQueryString({ href: `#!/devices/?${m.buildQueryString({
filter: memoizedStringify(slice["filter"]) filter: memoizedStringify(slice["filter"])
})}` })}`
}, },
@@ -89,7 +89,7 @@ function drawChart(chartData): Children {
m( m(
"a", "a",
{ {
"xlink:href": `/#!/devices/?${m.buildQueryString({ "xlink:href": `#!/devices/?${m.buildQueryString({
filter: memoizedStringify(slice["filter"]) filter: memoizedStringify(slice["filter"])
})}` })}`
}, },
+3 -3
View File
@@ -134,7 +134,7 @@ const formData = {
const getDownloadUrl = memoize(filter => { const getDownloadUrl = memoize(filter => {
const cols = {}; const cols = {};
for (const attr of attributes) cols[attr.label] = attr.id; for (const attr of attributes) cols[attr.label] = attr.id;
return `/api/presets.csv?${m.buildQueryString({ return `api/presets.csv?${m.buildQueryString({
filter: stringify(filter), filter: stringify(filter),
columns: JSON.stringify(cols) columns: JSON.stringify(cols)
})}`; })}`;
@@ -240,7 +240,7 @@ export const component: ClosureComponent = (): Component => {
const valueCallback = (attr, preset): {} => { const valueCallback = (attr, preset): {} => {
if (attr.id === "precondition") { if (attr.id === "precondition") {
let devicesUrl = "/#!/devices"; let devicesUrl = "#!/devices";
if (preset["precondition"].length) { if (preset["precondition"].length) {
devicesUrl += `?${m.buildQueryString({ devicesUrl += `?${m.buildQueryString({
filter: preset["precondition"] filter: preset["precondition"]
@@ -259,7 +259,7 @@ export const component: ClosureComponent = (): Component => {
return m( return m(
"a", "a",
{ {
href: `/#!/admin/provisions?${m.buildQueryString({ href: `#!/admin/provisions?${m.buildQueryString({
filter: `Q("ID", "${preset["provision"]}")` filter: `Q("ID", "${preset["provision"]}")`
})}` })}`
}, },
+1 -1
View File
@@ -114,7 +114,7 @@ const formData = {
const getDownloadUrl = memoize(filter => { const getDownloadUrl = memoize(filter => {
const cols = {}; const cols = {};
for (const attr of attributes) cols[attr.label] = attr.id; for (const attr of attributes) cols[attr.label] = attr.id;
return `/api/provisions.csv?${m.buildQueryString({ return `api/provisions.csv?${m.buildQueryString({
filter: stringify(filter), filter: stringify(filter),
columns: JSON.stringify(cols) columns: JSON.stringify(cols)
})}`; })}`;
+13 -13
View File
@@ -91,7 +91,7 @@ class QueryResponse {
function checkConnection(): void { function checkConnection(): void {
m.request({ m.request({
url: "/status", url: "status",
method: "GET", method: "GET",
background: true, background: true,
extract: xhr => { extract: xhr => {
@@ -387,7 +387,7 @@ export function fulfill(accessTimestamp, _fulfillTimestamp): Promise<boolean> {
xhrRequest({ xhrRequest({
method: "HEAD", method: "HEAD",
url: url:
`/api/${resourceType}/?` + `api/${resourceType}/?` +
m.buildQueryString({ m.buildQueryString({
filter: memoizedStringify(filter) filter: memoizedStringify(filter)
}), }),
@@ -433,7 +433,7 @@ export function fulfill(accessTimestamp, _fulfillTimestamp): Promise<boolean> {
xhrRequest({ xhrRequest({
method: "GET", method: "GET",
url: url:
`/api/${resourceType}/?` + `api/${resourceType}/?` +
m.buildQueryString({ m.buildQueryString({
filter: memoizedStringify(filter), filter: memoizedStringify(filter),
limit: 1, limit: 1,
@@ -526,7 +526,7 @@ export function fulfill(accessTimestamp, _fulfillTimestamp): Promise<boolean> {
xhrRequest({ xhrRequest({
method: "GET", method: "GET",
url: url:
`/api/${resourceType}/?` + `api/${resourceType}/?` +
m.buildQueryString({ m.buildQueryString({
filter: memoizedStringify(combinedFilterDiff) filter: memoizedStringify(combinedFilterDiff)
}) })
@@ -588,7 +588,7 @@ export function postTasks(deviceId, tasks): Promise<string> {
return xhrRequest({ return xhrRequest({
method: "POST", method: "POST",
url: `/api/devices/${encodeURIComponent(deviceId)}/tasks`, url: `api/devices/${encodeURIComponent(deviceId)}/tasks`,
body: tasks, body: tasks,
extract: xhr => { extract: xhr => {
if (xhr.status !== 200) throw new Error(xhr.response); if (xhr.status !== 200) throw new Error(xhr.response);
@@ -609,7 +609,7 @@ export function postTasks(deviceId, tasks): Promise<string> {
export function updateTags(deviceId, tags): Promise<void> { export function updateTags(deviceId, tags): Promise<void> {
return xhrRequest({ return xhrRequest({
method: "POST", method: "POST",
url: `/api/devices/${encodeURIComponent(deviceId)}/tags`, url: `api/devices/${encodeURIComponent(deviceId)}/tags`,
body: tags body: tags
}); });
} }
@@ -617,7 +617,7 @@ export function updateTags(deviceId, tags): Promise<void> {
export function deleteResource(resourceType, id): Promise<void> { export function deleteResource(resourceType, id): Promise<void> {
return xhrRequest({ return xhrRequest({
method: "DELETE", method: "DELETE",
url: `/api/${resourceType}/${encodeURIComponent(id)}` url: `api/${resourceType}/${encodeURIComponent(id)}`
}); });
} }
@@ -626,7 +626,7 @@ export function putResource(resourceType, id, object): Promise<void> {
return xhrRequest({ return xhrRequest({
method: "PUT", method: "PUT",
url: `/api/${resourceType}/${encodeURIComponent(id)}`, url: `api/${resourceType}/${encodeURIComponent(id)}`,
body: object body: object
}); });
} }
@@ -646,7 +646,7 @@ export function resourceExists(resource, id): Promise<number> {
return xhrRequest({ return xhrRequest({
method: "HEAD", method: "HEAD",
url: url:
`/api/${resource}/?` + `api/${resource}/?` +
m.buildQueryString({ m.buildQueryString({
filter: memoizedStringify(filter) filter: memoizedStringify(filter)
}), }),
@@ -669,7 +669,7 @@ export function changePassword(
if (authPassword) body["authPassword"] = authPassword; if (authPassword) body["authPassword"] = authPassword;
return xhrRequest({ return xhrRequest({
method: "PUT", method: "PUT",
url: `/api/users/${username}/password`, url: `api/users/${username}/password`,
background: true, background: true,
body body
}); });
@@ -678,7 +678,7 @@ export function changePassword(
export function logIn(username, password): Promise<void> { export function logIn(username, password): Promise<void> {
return xhrRequest({ return xhrRequest({
method: "POST", method: "POST",
url: "/login", url: "login",
background: true, background: true,
body: { username, password } body: { username, password }
}); });
@@ -687,13 +687,13 @@ export function logIn(username, password): Promise<void> {
export function logOut(): Promise<void> { export function logOut(): Promise<void> {
return xhrRequest({ return xhrRequest({
method: "POST", method: "POST",
url: "/logout" url: "logout"
}); });
} }
export function ping(host): Promise<{}> { export function ping(host): Promise<{}> {
return xhrRequest({ return xhrRequest({
url: `/api/ping/${encodeURIComponent(host)}`, url: `api/ping/${encodeURIComponent(host)}`,
background: true background: true
}); });
} }
+1 -1
View File
@@ -137,7 +137,7 @@ const getDownloadUrl = memoize(filter => {
const cols = {}; const cols = {};
for (const attr of attributes) cols[attr.label] = attr.id; for (const attr of attributes) cols[attr.label] = attr.id;
return `/api/users.csv?${m.buildQueryString({ return `api/users.csv?${m.buildQueryString({
filter: stringify(filter), filter: stringify(filter),
columns: JSON.stringify(cols) columns: JSON.stringify(cols)
})}`; })}`;
+1 -1
View File
@@ -114,7 +114,7 @@ const formData = {
const getDownloadUrl = memoize(filter => { const getDownloadUrl = memoize(filter => {
const cols = {}; const cols = {};
for (const attr of attributes) cols[attr.label] = attr.id; for (const attr of attributes) cols[attr.label] = attr.id;
return `/api/virtualParameters.csv?${m.buildQueryString({ return `api/virtualParameters.csv?${m.buildQueryString({
filter: stringify(filter), filter: stringify(filter),
columns: JSON.stringify(cols) columns: JSON.stringify(cols)
})}`; })}`;
+3 -3
View File
@@ -21,7 +21,7 @@ import m, { ClosureComponent, Component } from "mithril";
import * as notifications from "./notifications"; import * as notifications from "./notifications";
export async function init(): Promise<{}> { export async function init(): Promise<{}> {
return m.request({ url: "/init" }); return m.request({ url: "init" });
} }
export const component: ClosureComponent = (vnode): Component => { export const component: ClosureComponent = (vnode): Component => {
@@ -82,12 +82,12 @@ export const component: ClosureComponent = (vnode): Component => {
m.request({ m.request({
method: "POST", method: "POST",
url: "/init", url: "init",
body: opts body: opts
}) })
.then(() => { .then(() => {
setTimeout(() => { setTimeout(() => {
m.request({ url: "/init" }).then(o => { m.request({ url: "init" }).then(o => {
e.target.disabled = false; e.target.disabled = false;
options = o; options = o;
notifications.push("success", "Initialization complete", { notifications.push("success", "Initialization complete", {