Skip to content

Commit 6dd70d0

Browse files
authored
feat: add base path to config an all URLs (NASA-AMMOS#65)
- Will make using a dynamic app path easier later
1 parent af498da commit 6dd70d0

32 files changed

+98
-52
lines changed

src/components/constraints/ConstraintForm.svelte

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<script lang="ts">
44
import { goto } from '$app/navigation';
5+
import { base } from '$app/paths';
56
import { constraintsColumns } from '../../stores/constraints';
67
import effects from '../../utilities/effects';
78
import Chip from '../ui/Chip.svelte';
@@ -60,7 +61,7 @@
6061
);
6162
6263
if (newConstraintId !== null) {
63-
goto(`/constraints/edit/${newConstraintId}`);
64+
goto(`${base}/constraints/edit/${newConstraintId}`);
6465
}
6566
} else if (mode === 'edit') {
6667
await effects.updateConstraint(
@@ -82,7 +83,7 @@
8283
<Chip>{mode === 'create' ? 'New Constraint' : 'Edit Constraint'}</Chip>
8384

8485
<div class="right">
85-
<button class="st-button secondary ellipsis" on:click={() => goto('/constraints')}>
86+
<button class="st-button secondary ellipsis" on:click={() => goto(`${base}/constraints`)}>
8687
{mode === 'create' ? 'Cancel' : 'Close'}
8788
</button>
8889
<button class="st-button secondary ellipsis" disabled={!saveButtonEnabled} on:click={saveConstraint}>

src/components/constraints/ConstraintListItem.svelte

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<svelte:options immutable={true} />
22

33
<script lang="ts">
4+
import { base } from '$app/paths';
45
import effects from '../../utilities/effects';
56
import { tooltip } from '../../utilities/tooltip';
67
@@ -19,7 +20,7 @@
1920
<div class="constraint-actions">
2021
<button
2122
class="st-button icon"
22-
on:click|stopPropagation={() => window.open(`/constraints/edit/${constraint.id}`, '_blank')}
23+
on:click|stopPropagation={() => window.open(`${base}/constraints/edit/${constraint.id}`, '_blank')}
2324
use:tooltip={{ content: 'Edit Constraint', placement: 'left' }}
2425
>
2526
<i class="bi bi-pencil" />

src/components/constraints/Constraints.svelte

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<script lang="ts">
44
import { goto } from '$app/navigation';
5+
import { base } from '$app/paths';
56
import { constraintsAll, constraintsColumns } from '../../stores/constraints';
67
import effects from '../../utilities/effects';
78
import { tooltip } from '../../utilities/tooltip';
@@ -84,7 +85,7 @@
8485
</Input>
8586

8687
<div class="right">
87-
<button class="st-button secondary ellipsis" on:click={() => goto('/constraints/new')}> New </button>
88+
<button class="st-button secondary ellipsis" on:click={() => goto(`${base}/constraints/new`)}> New </button>
8889
</div>
8990
</svelte:fragment>
9091

@@ -107,7 +108,7 @@
107108
<div slot="actions-cell">
108109
<button
109110
class="st-button icon"
110-
on:click|stopPropagation={() => goto(`/constraints/edit/${currentRow.id}`)}
111+
on:click|stopPropagation={() => goto(`${base}/constraints/edit/${currentRow.id}`)}
111112
use:tooltip={{ content: 'Edit Constraint', placement: 'bottom' }}
112113
>
113114
<i class="bi bi-pencil" />

src/components/constraints/ConstraintsPanel.svelte

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<svelte:options immutable={true} />
22

33
<script lang="ts">
4+
import { base } from '$app/paths';
45
import { onMount } from 'svelte';
56
import { checkConstraintsStatus, constraints } from '../../stores/constraints';
67
import { plan } from '../../stores/plan';
@@ -44,7 +45,7 @@
4445
<button
4546
class="st-button secondary"
4647
name="new-constraint"
47-
on:click={() => window.open(`/constraints/new`, '_blank')}
48+
on:click={() => window.open(`${base}/constraints/new`, '_blank')}
4849
>
4950
New
5051
</button>

src/components/expansion/ExpansionRuleForm.svelte

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<script lang="ts">
44
import { goto } from '$app/navigation';
5+
import { base } from '$app/paths';
56
import { activityTypeNames, dictionaries, expansionRulesColumns, savingExpansionRule } from '../../stores/expansion';
67
import { sortedModels } from '../../stores/plan';
78
import effects from '../../utilities/effects';
@@ -50,7 +51,7 @@
5051
const newRuleId = await effects.createExpansionRule(newRule);
5152
5253
if (newRuleId !== null) {
53-
goto(`/expansion/rules/edit/${newRuleId}`);
54+
goto(`${base}/expansion/rules/edit/${newRuleId}`);
5455
}
5556
} else if (mode === 'edit') {
5657
const updatedRule: Partial<ExpansionRule> = {
@@ -73,7 +74,7 @@
7374
<Chip>{mode === 'create' ? 'New Expansion Rule' : 'Edit Expansion Rule'}</Chip>
7475

7576
<div class="right">
76-
<button class="st-button secondary ellipsis" on:click={() => goto('/expansion/rules')}>
77+
<button class="st-button secondary ellipsis" on:click={() => goto(`${base}/expansion/rules`)}>
7778
{mode === 'create' ? 'Cancel' : 'Close'}
7879
</button>
7980
<button class="st-button secondary ellipsis" disabled={!saveButtonEnabled} on:click={saveRule}>

src/components/expansion/ExpansionRules.svelte

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<script lang="ts">
44
import { goto } from '$app/navigation';
5+
import { base } from '$app/paths';
56
import { expansionRules, expansionRulesColumns } from '../../stores/expansion';
67
import effects from '../../utilities/effects';
78
import { compare } from '../../utilities/generic';
@@ -60,7 +61,7 @@
6061
</Input>
6162

6263
<div class="right">
63-
<button class="st-button secondary ellipsis" on:click={() => goto('/expansion/rules/new')}> New </button>
64+
<button class="st-button secondary ellipsis" on:click={() => goto(`${base}/expansion/rules/new`)}> New </button>
6465
</div>
6566
</svelte:fragment>
6667

@@ -85,7 +86,7 @@
8586
<div slot="actions-cell">
8687
<button
8788
class="st-button icon"
88-
on:click|stopPropagation={() => goto(`/expansion/rules/edit/${currentRow.id}`)}
89+
on:click|stopPropagation={() => goto(`${base}/expansion/rules/edit/${currentRow.id}`)}
8990
use:tooltip={{ content: 'Edit Rule', placement: 'bottom' }}
9091
>
9192
<i class="bi bi-pencil" />

src/components/expansion/ExpansionSetForm.svelte

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<script lang="ts">
44
import { goto } from '$app/navigation';
5+
import { base } from '$app/paths';
56
import { dictionaries, expansionSetsColumns, savingExpansionSet } from '../../stores/expansion';
67
import { sortedModels } from '../../stores/plan';
78
import effects from '../../utilities/effects';
@@ -41,7 +42,7 @@
4142
const newSetId = await effects.createExpansionSet(setDictionaryId, setModelId, setExpansionRuleIds);
4243
4344
if (newSetId !== null) {
44-
goto(`/expansion/sets`);
45+
goto(`${base}/expansion/sets`);
4546
}
4647
}
4748
}
@@ -67,7 +68,7 @@
6768
<Chip>New Expansion Set</Chip>
6869

6970
<div class="right">
70-
<button class="st-button secondary ellipsis" on:click={() => goto('/expansion/sets')}>
71+
<button class="st-button secondary ellipsis" on:click={() => goto(`${base}/expansion/sets`)}>
7172
{mode === 'create' ? 'Cancel' : 'Close'}
7273
</button>
7374
<button class="st-button secondary ellipsis" disabled={!saveButtonEnabled} on:click={saveSet}>

src/components/expansion/ExpansionSets.svelte

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<script lang="ts">
44
import { goto } from '$app/navigation';
5+
import { base } from '$app/paths';
56
import { expansionSets, expansionSetsColumns } from '../../stores/expansion';
67
import effects from '../../utilities/effects';
78
import { compare } from '../../utilities/generic';
@@ -62,7 +63,9 @@
6263
<Chip>Expansion Sets</Chip>
6364

6465
<div class="right">
65-
<button class="st-button secondary ellipsis" on:click={() => goto('/expansion/sets/new')}> New </button>
66+
<button class="st-button secondary ellipsis" on:click={() => goto(`${base}/expansion/sets/new`)}>
67+
New
68+
</button>
6669
</div>
6770
</svelte:fragment>
6871

src/components/menus/AppMenu.svelte

+15-8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<script lang="ts">
44
import { goto, prefetch } from '$app/navigation';
5+
import { base } from '$app/paths';
56
import { session } from '$app/stores';
67
import { env } from '../../stores/app';
78
import { showAboutModal } from '../../utilities/modal';
@@ -11,9 +12,9 @@
1112
let appMenu: Menu;
1213
1314
async function logout() {
14-
await fetch('/auth/logout', { method: 'POST' });
15+
await fetch(`${base}/auth/logout`, { method: 'POST' });
1516
$session.user = null; // Triggers redirect.
16-
goto('/login');
17+
goto(`${base}/login`);
1718
}
1819
</script>
1920

@@ -23,27 +24,33 @@
2324
<i class="bi bi-chevron-down" />
2425

2526
<Menu bind:this={appMenu}>
26-
<MenuItem on:click={() => goto('/plans')} on:pointerenter={() => prefetch('/plans')}>
27+
<MenuItem on:click={() => goto(`${base}/plans`)} on:pointerenter={() => prefetch(`${base}/plans`)}>
2728
<i class="bi bi-calendar-range" />
2829
Plans
2930
</MenuItem>
30-
<MenuItem on:click={() => goto('/models')} on:pointerenter={() => prefetch('/models')}>
31+
<MenuItem on:click={() => goto(`${base}/models`)} on:pointerenter={() => prefetch(`${base}/models`)}>
3132
<i class="bi bi-bar-chart" />
3233
Models
3334
</MenuItem>
34-
<MenuItem on:click={() => goto('/constraints')} on:pointerenter={() => prefetch('/constraints')}>
35+
<MenuItem on:click={() => goto(`${base}/constraints`)} on:pointerenter={() => prefetch(`${base}/constraints`)}>
3536
<i class="bi bi-braces-asterisk" />
3637
Constraints
3738
</MenuItem>
38-
<MenuItem on:click={() => goto('/dictionaries')} on:pointerenter={() => prefetch('/dictionaries')}>
39+
<MenuItem on:click={() => goto(`${base}/dictionaries`)} on:pointerenter={() => prefetch(`${base}/dictionaries`)}>
3940
<i class="bi bi-journal-text" />
4041
Dictionaries
4142
</MenuItem>
42-
<MenuItem on:click={() => goto('/expansion/rules')} on:pointerenter={() => prefetch('/expansion/rules')}>
43+
<MenuItem
44+
on:click={() => goto(`${base}/expansion/rules`)}
45+
on:pointerenter={() => prefetch(`${base}/expansion/rules`)}
46+
>
4347
<i class="bi bi-code-square" />
4448
Expansion
4549
</MenuItem>
46-
<MenuItem on:click={() => goto('/scheduling/goals')} on:pointerenter={() => prefetch('/scheduling/goals')}>
50+
<MenuItem
51+
on:click={() => goto(`${base}/scheduling/goals`)}
52+
on:pointerenter={() => prefetch(`${base}/scheduling/goals`)}
53+
>
4754
<i class="bi bi-calendar3" />
4855
Scheduling
4956
</MenuItem>

src/components/scheduling/SchedulingGoal.svelte

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<svelte:options immutable={true} />
22

33
<script lang="ts">
4+
import { base } from '$app/paths';
45
import effects from '../../utilities/effects';
56
import { tooltip } from '../../utilities/tooltip';
67
import ContextMenu from '../context-menu/ContextMenu.svelte';
@@ -60,7 +61,7 @@
6061

6162
<ContextMenu bind:this={contextMenu}>
6263
<ContextMenuHeader>Actions</ContextMenuHeader>
63-
<ContextMenuItem on:click={() => window.open(`/scheduling/goals/edit/${goal.id}`, '_blank')}>
64+
<ContextMenuItem on:click={() => window.open(`${base}/scheduling/goals/edit/${goal.id}`, '_blank')}>
6465
Edit Goal
6566
</ContextMenuItem>
6667
<ContextMenuHeader>Modify</ContextMenuHeader>

src/components/scheduling/SchedulingGoalForm.svelte

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<script lang="ts">
44
import { goto } from '$app/navigation';
5+
import { base } from '$app/paths';
56
import { session } from '$app/stores';
67
import { schedulingGoalsColumns } from '../../stores/scheduling';
78
import effects from '../../utilities/effects';
@@ -66,7 +67,7 @@
6667
await effects.createSchedulingSpecGoal(specGoalInsertInput);
6768
}
6869
69-
goto(`/scheduling/goals/edit/${newGoalId}`);
70+
goto(`${base}/scheduling/goals/edit/${newGoalId}`);
7071
}
7172
} else if (mode === 'edit') {
7273
const goal: Partial<SchedulingGoal> = {
@@ -89,7 +90,7 @@
8990
<Chip>{mode === 'create' ? 'New Scheduling Goal' : 'Edit Scheduling Goal'}</Chip>
9091

9192
<div class="right">
92-
<button class="st-button secondary ellipsis" on:click={() => goto('/scheduling/goals')}>
93+
<button class="st-button secondary ellipsis" on:click={() => goto(`${base}/scheduling/goals`)}>
9394
{mode === 'create' ? 'Cancel' : 'Close'}
9495
</button>
9596
<button class="st-button secondary ellipsis" disabled={!saveButtonEnabled} on:click={saveGoal}> Save </button>

src/components/scheduling/SchedulingGoals.svelte

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<script lang="ts">
44
import { goto } from '$app/navigation';
5+
import { base } from '$app/paths';
56
import { schedulingGoals, schedulingGoalsColumns } from '../../stores/scheduling';
67
import effects from '../../utilities/effects';
78
import { compare } from '../../utilities/generic';
@@ -66,7 +67,9 @@
6667
</Input>
6768

6869
<div class="right">
69-
<button class="st-button secondary ellipsis" on:click={() => goto('/scheduling/goals/new')}> New </button>
70+
<button class="st-button secondary ellipsis" on:click={() => goto(`${base}/scheduling/goals/new`)}>
71+
New
72+
</button>
7073
</div>
7174
</svelte:fragment>
7275

@@ -88,7 +91,7 @@
8891
<div slot="actions-cell">
8992
<button
9093
class="st-button icon"
91-
on:click|stopPropagation={() => goto(`/scheduling/goals/edit/${currentRow.id}`)}
94+
on:click|stopPropagation={() => goto(`${base}/scheduling/goals/edit/${currentRow.id}`)}
9295
use:tooltip={{ content: 'Edit Goal', placement: 'bottom' }}
9396
>
9497
<i class="bi bi-pencil" />

src/components/scheduling/SchedulingPanel.svelte

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<svelte:options immutable={true} />
22

33
<script lang="ts">
4+
import { base } from '$app/paths';
45
import { onMount } from 'svelte';
56
import { schedulingSpecGoals, schedulingStatus, selectedSpecId } from '../../stores/scheduling';
67
import effects from '../../utilities/effects';
@@ -38,7 +39,7 @@
3839
<button
3940
class="st-button secondary"
4041
name="new-scheduling-goal"
41-
on:click={() => window.open(`/scheduling/goals/new?specId=${$selectedSpecId}`, '_blank')}
42+
on:click={() => window.open(`${base}/scheduling/goals/new?specId=${$selectedSpecId}`, '_blank')}
4243
>
4344
New
4445
</button>

src/routes/__error.svelte

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<script lang="ts">
44
import { goto } from '$app/navigation';
5+
import { base } from '$app/paths';
56
import { onMount } from 'svelte';
67
78
const comics = [
@@ -29,7 +30,7 @@
2930
<div class="app-error">
3031
<div class="app-error-title">
3132
<div>Uh O! Sorry, we can't find that page.</div>
32-
<button class="st-button" on:click={() => goto('/')}> Return Home </button>
33+
<button class="st-button" on:click={() => goto(`${base}/`)}> Return Home </button>
3334
</div>
3435

3536
<a href={xkcdUrl} target="_blank" rel="noopener noreferrer">

src/routes/__layout.svelte

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
<script lang="ts" context="module">
2+
import { base } from '$app/paths';
23
import type { Load } from '@sveltejs/kit';
34
import '../css/app.css';
45
import { env as envStore, user as userStore, version as versionStore } from '../stores/app';
56
import { modalBodyClickListener, modalBodyKeyListener } from '../utilities/modal';
67
78
export const load: Load = async ({ fetch, session }) => {
89
// Set env store.
9-
const envResponse = await fetch('/env');
10+
const envResponse = await fetch(`${base}/env`);
1011
const env = await envResponse.json();
1112
envStore.set(env);
1213
1314
// Set version store.
14-
const versionResponse = await fetch('/version.json');
15+
const versionResponse = await fetch(`${base}/version.json`);
1516
const version = await versionResponse.json();
1617
versionStore.set(version);
1718

src/routes/auth/login.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { base } from '$app/paths';
12
import type { RequestHandler } from '@sveltejs/kit';
23
import effects from '../../utilities/effects';
34

@@ -20,7 +21,7 @@ export const POST: RequestHandler = async event => {
2021
user,
2122
},
2223
headers: {
23-
'set-cookie': `user=${userCookie}; Path=/`,
24+
'set-cookie': `user=${userCookie}; Path=${base}/`,
2425
},
2526
};
2627
} else {

src/routes/auth/logout.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { base } from '$app/paths';
12
import type { RequestHandler } from '@sveltejs/kit';
23
import effects from '../../utilities/effects';
34

@@ -17,7 +18,7 @@ export const POST: RequestHandler = async event => {
1718
success: true,
1819
},
1920
headers: {
20-
'set-cookie': 'user=deleted; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT',
21+
'set-cookie': `user=deleted; path=${base}/; expires=Thu, 01 Jan 1970 00:00:00 GMT`,
2122
},
2223
};
2324
} else {

0 commit comments

Comments
 (0)