Add relative path for API requests instead of absolute paths, should help when proxying to a web subdirectory
This commit is contained in:
parent
513d1162ed
commit
91e067b193
1 changed files with 9 additions and 9 deletions
18
data.js
18
data.js
|
|
@ -278,7 +278,7 @@ function renderStats() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function refreshSimulations() {
|
async function refreshSimulations() {
|
||||||
state.simulations = await request("/api/simulations");
|
state.simulations = await request("api/simulations");
|
||||||
renderStats();
|
renderStats();
|
||||||
renderDashboard();
|
renderDashboard();
|
||||||
|
|
||||||
|
|
@ -301,7 +301,7 @@ function textOrPlaceholder(lines, fallback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadDetail(id) {
|
async function loadDetail(id) {
|
||||||
const detail = await request(`/api/simulations/${id}`);
|
const detail = await request(`api/simulations/${id}`);
|
||||||
state.selectedDetailId = id;
|
state.selectedDetailId = id;
|
||||||
|
|
||||||
$("detailTitle").textContent = `sim-${detail.id} - ${detail.title}`;
|
$("detailTitle").textContent = `sim-${detail.id} - ${detail.title}`;
|
||||||
|
|
@ -315,7 +315,7 @@ async function loadDetail(id) {
|
||||||
async function createSimulation() {
|
async function createSimulation() {
|
||||||
try {
|
try {
|
||||||
const payload = getCreatePayload();
|
const payload = getCreatePayload();
|
||||||
const created = await request("/api/simulations", {
|
const created = await request("api/simulations", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify(payload),
|
body: JSON.stringify(payload),
|
||||||
|
|
@ -330,7 +330,7 @@ async function createSimulation() {
|
||||||
|
|
||||||
async function startSimulation(id) {
|
async function startSimulation(id) {
|
||||||
try {
|
try {
|
||||||
await request(`/api/simulations/${id}/start`, { method: "POST" });
|
await request(`api/simulations/${id}/start`, { method: "POST" });
|
||||||
setStatus(`Started sim-${id}`);
|
setStatus(`Started sim-${id}`);
|
||||||
await refreshSimulations();
|
await refreshSimulations();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -340,7 +340,7 @@ async function startSimulation(id) {
|
||||||
|
|
||||||
async function cloneSimulation(id) {
|
async function cloneSimulation(id) {
|
||||||
try {
|
try {
|
||||||
const created = await request(`/api/simulations/${id}/clone`, { method: "POST" });
|
const created = await request(`api/simulations/${id}/clone`, { method: "POST" });
|
||||||
setStatus(`Cloned sim-${id} to sim-${created.id}`);
|
setStatus(`Cloned sim-${id} to sim-${created.id}`);
|
||||||
await refreshSimulations();
|
await refreshSimulations();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -350,7 +350,7 @@ async function cloneSimulation(id) {
|
||||||
|
|
||||||
async function deleteSimulation(id) {
|
async function deleteSimulation(id) {
|
||||||
try {
|
try {
|
||||||
await request(`/api/simulations/${id}`, { method: "DELETE" });
|
await request(`api/simulations/${id}`, { method: "DELETE" });
|
||||||
if (state.selectedDetailId === id) {
|
if (state.selectedDetailId === id) {
|
||||||
state.selectedDetailId = null;
|
state.selectedDetailId = null;
|
||||||
closeModal("detailModal");
|
closeModal("detailModal");
|
||||||
|
|
@ -363,7 +363,7 @@ async function deleteSimulation(id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportSimulation(id) {
|
function exportSimulation(id) {
|
||||||
window.location.href = `/api/simulations/${id}/export.csv`;
|
window.location.href = `api/simulations/${id}/export.csv`;
|
||||||
setStatus(`Exporting sim-${id} CSV...`);
|
setStatus(`Exporting sim-${id} CSV...`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -421,7 +421,7 @@ async function boot() {
|
||||||
bindEvents();
|
bindEvents();
|
||||||
try {
|
try {
|
||||||
setStatus("Loading configuration, teams and simulations...");
|
setStatus("Loading configuration, teams and simulations...");
|
||||||
const config = await request("/api/config");
|
const config = await request("api/config");
|
||||||
state.demo = config.demo;
|
state.demo = config.demo;
|
||||||
|
|
||||||
// Show/hide demo banner
|
// Show/hide demo banner
|
||||||
|
|
@ -434,7 +434,7 @@ async function boot() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
state.teams = await request("/api/teams");
|
state.teams = await request("api/teams");
|
||||||
renderTeamSelectors();
|
renderTeamSelectors();
|
||||||
await refreshSimulations();
|
await refreshSimulations();
|
||||||
setStatus(`Connected to SoccerCloud backend on port 9009.${state.demo ? " (Demo mode)" : ""}`);
|
setStatus(`Connected to SoccerCloud backend on port 9009.${state.demo ? " (Demo mode)" : ""}`);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue