Finish basic setup for configuration loading
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
DEFAULT_STANDARDS_CONFIG,
|
||||
FALLBACK_STANDARDS_CONFIG,
|
||||
StandardsDataSchema,
|
||||
StandardsParamsSchema,
|
||||
} from "@blade-and-brawn/calculator";
|
||||
@@ -19,9 +19,9 @@ async function seedStandardsDataset(): Promise<string> {
|
||||
return existing.id;
|
||||
}
|
||||
|
||||
Value.Assert(StandardsDataSchema, DEFAULT_STANDARDS_CONFIG.data);
|
||||
Value.Assert(StandardsDataSchema, FALLBACK_STANDARDS_CONFIG.data);
|
||||
const result = await db.insertInto("standards_datasets")
|
||||
.values({ name: DEFAULT_NAME, data: DEFAULT_STANDARDS_CONFIG.data })
|
||||
.values({ name: DEFAULT_NAME, data: FALLBACK_STANDARDS_CONFIG.data })
|
||||
.returning("id")
|
||||
.executeTakeFirstOrThrow();
|
||||
log.info({ id: result.id }, "seeded default standards dataset");
|
||||
@@ -43,12 +43,12 @@ async function seedStandardsConfig(datasetId: string): Promise<void> {
|
||||
.where("is_selected", "=", true)
|
||||
.executeTakeFirst();
|
||||
|
||||
Value.Assert(StandardsParamsSchema, DEFAULT_STANDARDS_CONFIG.params);
|
||||
Value.Assert(StandardsParamsSchema, FALLBACK_STANDARDS_CONFIG.params);
|
||||
const result = await db.insertInto("standards_configs")
|
||||
.values({
|
||||
name: DEFAULT_NAME,
|
||||
dataset_id: datasetId,
|
||||
params: DEFAULT_STANDARDS_CONFIG.params,
|
||||
params: FALLBACK_STANDARDS_CONFIG.params,
|
||||
is_selected: !hasSelected,
|
||||
})
|
||||
.returning("id")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
type Levels,
|
||||
DEFAULT_STANDARDS_CONFIG,
|
||||
FALLBACK_STANDARDS_CONFIG,
|
||||
} from "@blade-and-brawn/calculator";
|
||||
import { Activity, clamp, Gender, range } from "@blade-and-brawn/domain";
|
||||
import { levenbergMarquardt as LM } from "ml-levenberg-marquardt";
|
||||
@@ -15,7 +15,7 @@ for (const activity of Object.values(Activity)) {
|
||||
}
|
||||
|
||||
for (const gender of Object.values(Gender)) {
|
||||
const standardsByGender = DEFAULT_STANDARDS_CONFIG.data[
|
||||
const standardsByGender = FALLBACK_STANDARDS_CONFIG.data[
|
||||
activity
|
||||
].standards.filter((s) => s["metrics"].gender === gender);
|
||||
const ages = [...new Set(standardsByGender.map((s) => s.metrics.age))];
|
||||
|
||||
@@ -104,7 +104,7 @@ export const app = new Elysia()
|
||||
(app) => app
|
||||
// Non-authenticated
|
||||
.post("/calculate", async ({ body }) => {
|
||||
return { levels: s.Calculator.calculate(body.player, body.activityPerformances) };
|
||||
return { levels: await s.Calculator.calculate(body.player, body.activityPerformances) };
|
||||
}, {
|
||||
body: t.Object({
|
||||
player: PlayerSchema,
|
||||
|
||||
@@ -1,14 +1,25 @@
|
||||
import { LevelCalculator, Standards, DEFAULT_STANDARDS_CONFIG, type StandardsParams, StandardsParamsSchema, StandardsDataSchema, type StandardsConfig } from "@blade-and-brawn/calculator";
|
||||
import { LevelCalculator, Standards, FALLBACK_STANDARDS_CONFIG, type StandardsParams, StandardsParamsSchema, StandardsDataSchema, type StandardsConfig } from "@blade-and-brawn/calculator";
|
||||
import type { ActivityPerformance, Player } from "@blade-and-brawn/domain";
|
||||
import { db } from "../database/db";
|
||||
import { Value } from "@sinclair/typebox/value";
|
||||
import { log } from "../util";
|
||||
|
||||
export class CalculatorService {
|
||||
private Calculator = new LevelCalculator(new Standards(DEFAULT_STANDARDS_CONFIG));
|
||||
private Calculator = new LevelCalculator(new Standards(FALLBACK_STANDARDS_CONFIG));
|
||||
Standards: StandardsService = new StandardsService(this.Calculator);
|
||||
private ready: Promise<void>;
|
||||
|
||||
calculate(player: Player, activityPerformances: ActivityPerformance[]) {
|
||||
constructor() {
|
||||
// Load the selected config on startup instead of waiting for the
|
||||
// first `calculate()` call. If it fails (e.g. no config selected
|
||||
// yet, DB unreachable at boot), fall back to DEFAULT_STANDARDS_CONFIG
|
||||
// and keep serving — it'll retry on the next refresh.
|
||||
this.ready = this.Standards.Config.refresh()
|
||||
.catch((err) => log.error({ err }, "failed to load initial standards config, falling back to defaults"));
|
||||
}
|
||||
|
||||
async calculate(player: Player, activityPerformances: ActivityPerformance[]) {
|
||||
await this.ready;
|
||||
this.Standards.Config.refresh({ onlyIfStale: true }).catch((err) => log.error({ err }, "failed to refresh standards config"));
|
||||
return this.Calculator.calculate(player, activityPerformances);
|
||||
}
|
||||
@@ -92,7 +103,7 @@ class StandardsConfigService {
|
||||
.set({ is_selected: true })
|
||||
.where("id", "=", id)
|
||||
.execute();
|
||||
if (result[0]?.numUpdatedRows === 0n) throw new Error(`No config with id "${id}"`);
|
||||
if (result[0]?.numUpdatedRows === 0n) throw new Error(`No standards config with id "${id}"`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import {
|
||||
Standards,
|
||||
type Standard,
|
||||
type StandardsParams,
|
||||
type StandardsConfig,
|
||||
} from "@blade-and-brawn/calculator";
|
||||
import {
|
||||
Activity,
|
||||
@@ -17,7 +17,7 @@
|
||||
selected: {
|
||||
activity: Activity;
|
||||
metrics: Metrics;
|
||||
params: StandardsParams;
|
||||
standardsConfig: StandardsConfig;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
<div>
|
||||
<div class="flex items-center">
|
||||
<p class="text-xs label">
|
||||
{#if selected.params.activity[selected.activity].enableGeneration && allStandards
|
||||
{#if selected.standardsConfig.params.activity[selected.activity].enableGeneration && allStandards
|
||||
.byActivity(selected.activity)
|
||||
.getMetadata().generators.length}
|
||||
(Generated data: {allStandards
|
||||
@@ -87,7 +87,7 @@
|
||||
? parseFloat(kgToLb(standard.metrics.weight).toFixed(2))
|
||||
: "None"}</th
|
||||
>
|
||||
{#each range(selected.params.global.maxLevel).map((i) => ++i) as lvl}
|
||||
{#each range(selected.standardsConfig.params.global.maxLevel).map((i) => ++i) as lvl}
|
||||
<td>{getLvlValue(activity, standard, lvl)}</td>
|
||||
{/each}
|
||||
</tr>
|
||||
@@ -99,7 +99,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Body weight</th>
|
||||
{#each range(selected.params.global.maxLevel).map((i) => ++i) as lvl}
|
||||
{#each range(selected.standardsConfig.params.global.maxLevel).map((i) => ++i) as lvl}
|
||||
<td>{lvl}</td>
|
||||
{/each}
|
||||
</tr>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
DEFAULT_STANDARDS_CONFIG,
|
||||
Standards,
|
||||
type StandardsParams,
|
||||
StandardsConfigSchema,
|
||||
type StandardsConfig,
|
||||
} from "@blade-and-brawn/calculator";
|
||||
import {
|
||||
Activity,
|
||||
@@ -12,6 +12,9 @@
|
||||
} from "@blade-and-brawn/domain";
|
||||
import StandardsTable from "$lib/components/StandardsTable.svelte";
|
||||
import PlayersTable from "$lib/components/PlayersTable.svelte";
|
||||
import { api } from "$lib/api";
|
||||
import { Value } from "@sinclair/typebox/value";
|
||||
import { onMount } from "svelte";
|
||||
|
||||
let activeTab = $state("standards");
|
||||
|
||||
@@ -22,9 +25,7 @@
|
||||
age: null as number | null,
|
||||
weight: null as number | null, // lb
|
||||
},
|
||||
params: structuredClone(
|
||||
DEFAULT_STANDARDS_CONFIG.params,
|
||||
) as StandardsParams,
|
||||
standardsConfig: null as StandardsConfig | null,
|
||||
});
|
||||
|
||||
const selected = $derived({
|
||||
@@ -34,288 +35,333 @@
|
||||
age: input.metrics.age ?? 0,
|
||||
weight: lbToKg(input.metrics.weight ?? 0),
|
||||
} as Metrics,
|
||||
params: input.params,
|
||||
standardsConfig: input.standardsConfig,
|
||||
});
|
||||
|
||||
const allStandards = $derived(
|
||||
new Standards({
|
||||
data: DEFAULT_STANDARDS_CONFIG.data,
|
||||
params: selected.params,
|
||||
}),
|
||||
selected.standardsConfig
|
||||
? new Standards($state.snapshot(selected.standardsConfig))
|
||||
: null,
|
||||
);
|
||||
|
||||
$effect(() => {
|
||||
const savedParameters = localStorage.getItem("parameters");
|
||||
if (!savedParameters) return;
|
||||
let standardsConfigLoadError = $state<string | null>(null);
|
||||
|
||||
const parsed = JSON.parse(savedParameters);
|
||||
if (parsed?.params) input = parsed;
|
||||
onMount(async () => {
|
||||
try {
|
||||
const savedInputStringified = localStorage.getItem("input");
|
||||
if (savedInputStringified) {
|
||||
input = JSON.parse(savedInputStringified);
|
||||
} else {
|
||||
const res = await api.calculator.config.get();
|
||||
if (res.error) throw res.error;
|
||||
Value.Assert(StandardsConfigSchema, res.data);
|
||||
input.standardsConfig = res.data;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("failed to load standards config", err);
|
||||
const value = (err as { value?: { error?: string } })?.value;
|
||||
standardsConfigLoadError =
|
||||
value?.error ??
|
||||
(err instanceof Error ? err.message : "Unknown error");
|
||||
}
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
localStorage.setItem("parameters", JSON.stringify(input));
|
||||
localStorage.setItem("input", JSON.stringify(input));
|
||||
});
|
||||
</script>
|
||||
|
||||
<section class="w-full flex justify-between gap-2 pt-10 items-center">
|
||||
<fieldset class="fieldset bg-base-200 p-6 max-w-lg">
|
||||
<legend class="fieldset-legend text-lg font-semibold"> Data </legend>
|
||||
{#if !(input.standardsConfig && allStandards)}
|
||||
<div class="w-full flex justify-center pt-10">
|
||||
{#if standardsConfigLoadError}
|
||||
<div role="alert" class="alert alert-error max-w-lg">
|
||||
<span>
|
||||
Failed to load the standards configuration: {standardsConfigLoadError}
|
||||
</span>
|
||||
</div>
|
||||
{:else}
|
||||
<span class="loading loading-spinner loading-lg"></span>
|
||||
{/if}
|
||||
</div>
|
||||
{:else}
|
||||
{@const standardsConfig = input.standardsConfig}
|
||||
<section class="w-full flex justify-between gap-2 pt-10 items-center">
|
||||
<fieldset class="fieldset bg-base-200 p-6 max-w-lg">
|
||||
<legend class="fieldset-legend text-lg font-semibold">
|
||||
Data
|
||||
</legend>
|
||||
|
||||
<div class="flex gap-4">
|
||||
<fieldset class="fieldset bg-base-300 p-3 max-w-xl">
|
||||
<legend class="fieldset-legend text-sm font-semibold">
|
||||
General
|
||||
<div class="flex gap-4">
|
||||
<fieldset class="fieldset bg-base-300 p-3 max-w-xl">
|
||||
<legend class="fieldset-legend text-sm font-semibold">
|
||||
General
|
||||
</legend>
|
||||
|
||||
<div class="grid grid-cols-1 gap-4">
|
||||
<label>
|
||||
<span class="label mb-1">Activity</span>
|
||||
<select
|
||||
class="select w-full"
|
||||
name="activities"
|
||||
bind:value={input.activity}
|
||||
>
|
||||
{#each Object.values(Activity) as activity}
|
||||
<option value={activity}>
|
||||
{allStandards
|
||||
.byActivity(activity)
|
||||
.getMetadata().name}
|
||||
</option>
|
||||
{/each}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
<span class="label mb-1">Max level</span>
|
||||
<input
|
||||
class="input w-full"
|
||||
type="number"
|
||||
min="1"
|
||||
max="100"
|
||||
placeholder="5"
|
||||
bind:value={
|
||||
standardsConfig.params.global.maxLevel
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="fieldset bg-base-300 p-3 max-w-3xs">
|
||||
<legend class="fieldset-legend text-sm font-semibold">
|
||||
Data Generation
|
||||
</legend>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<label class="label">
|
||||
<input
|
||||
type="checkbox"
|
||||
bind:checked={
|
||||
standardsConfig.params.activity[
|
||||
selected.activity
|
||||
].enableGeneration
|
||||
}
|
||||
class="toggle toggle-lg m-auto"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span class="label mb-1">Weight significance</span>
|
||||
<input
|
||||
class="input w-full"
|
||||
type="number"
|
||||
min="-1"
|
||||
max="1"
|
||||
step=".05"
|
||||
placeholder=".1"
|
||||
bind:value={
|
||||
standardsConfig.params.activity[
|
||||
selected.activity
|
||||
].weightModifier
|
||||
}
|
||||
disabled={!standardsConfig.params.activity[
|
||||
selected.activity
|
||||
].enableGeneration}
|
||||
/>
|
||||
</label>
|
||||
<!-- <label> -->
|
||||
<!-- <span class="label mb-1">Weight skew</span> -->
|
||||
<!-- <input -->
|
||||
<!-- class="input w-full" -->
|
||||
<!-- type="number" -->
|
||||
<!-- min="-1" -->
|
||||
<!-- max="1" -->
|
||||
<!-- step=".05" -->
|
||||
<!-- bind:value={ -->
|
||||
<!-- inputSelected.cfg.activity[selected.activity] -->
|
||||
<!-- .weightSkew -->
|
||||
<!-- } -->
|
||||
<!-- disabled={!selected.params.activity[selected.activity] -->
|
||||
<!-- .enableGeneration} -->
|
||||
<!-- /> -->
|
||||
<!-- </label> -->
|
||||
<label>
|
||||
<span class="label mb-1">Difficulty modifier</span>
|
||||
<input
|
||||
class="input w-full"
|
||||
type="number"
|
||||
min="-1"
|
||||
max="1"
|
||||
step=".05"
|
||||
bind:value={
|
||||
standardsConfig.params.activity[
|
||||
selected.activity
|
||||
].difficultyModifier
|
||||
}
|
||||
disabled={!standardsConfig.params.activity[
|
||||
selected.activity
|
||||
].enableGeneration}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span class="label mb-1">Age significance</span>
|
||||
<input
|
||||
class="input w-full"
|
||||
type="number"
|
||||
min="-1"
|
||||
max="1"
|
||||
step=".05"
|
||||
bind:value={
|
||||
standardsConfig.params.activity[
|
||||
selected.activity
|
||||
].ageModifier
|
||||
}
|
||||
disabled={!standardsConfig.params.activity[
|
||||
selected.activity
|
||||
].enableGeneration}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span class="label mb-1">Peak age</span>
|
||||
<input
|
||||
class="input w-full"
|
||||
type="number"
|
||||
min="1"
|
||||
max="100"
|
||||
step="1"
|
||||
bind:value={
|
||||
standardsConfig.params.activity[
|
||||
selected.activity
|
||||
].peakAge
|
||||
}
|
||||
disabled={!standardsConfig.params.activity[
|
||||
selected.activity
|
||||
].enableGeneration}
|
||||
/>
|
||||
</label>
|
||||
|
||||
<fieldset class="fieldset bg-base-200 p-3 max-w-xl">
|
||||
<legend
|
||||
class="fieldset-legend text-sm font-semibold"
|
||||
>
|
||||
Stretch
|
||||
</legend>
|
||||
<label>
|
||||
<span class="label mb-1">Lower</span>
|
||||
<input
|
||||
class="input w-full"
|
||||
type="number"
|
||||
min="0"
|
||||
max="10"
|
||||
step="1"
|
||||
bind:value={
|
||||
standardsConfig.params.activity[
|
||||
selected.activity
|
||||
].stretch.lower
|
||||
}
|
||||
disabled={!standardsConfig.params.activity[
|
||||
selected.activity
|
||||
].enableGeneration}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span class="label mb-1">Upper</span>
|
||||
<input
|
||||
class="input w-full"
|
||||
type="number"
|
||||
min="0"
|
||||
max="10"
|
||||
step="1"
|
||||
bind:value={
|
||||
standardsConfig.params.activity[
|
||||
selected.activity
|
||||
].stretch.upper
|
||||
}
|
||||
disabled={!standardsConfig.params.activity[
|
||||
selected.activity
|
||||
].enableGeneration}
|
||||
/>
|
||||
</label>
|
||||
</fieldset>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
{#if activeTab === "standards"}
|
||||
<fieldset class="fieldset bg-base-200 p-6 max-w-lg">
|
||||
<legend class="fieldset-legend text-lg font-semibold">
|
||||
Metrics
|
||||
</legend>
|
||||
|
||||
<div class="grid grid-cols-1 gap-4">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<label>
|
||||
<span class="label mb-1">Activity</span>
|
||||
<span class="label mb-1">Gender</span>
|
||||
<select
|
||||
class="select w-full"
|
||||
name="activities"
|
||||
bind:value={input.activity}
|
||||
name="genders"
|
||||
bind:value={input.metrics.gender}
|
||||
>
|
||||
{#each Object.values(Activity) as activity}
|
||||
<option value={activity}>
|
||||
{allStandards
|
||||
.byActivity(activity)
|
||||
.getMetadata().name}
|
||||
</option>
|
||||
{#each Object.values(Gender) as gender}
|
||||
<option value={gender}>{gender}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span class="label mb-1">Max level</span>
|
||||
<span class="label mb-1">Age</span>
|
||||
<input
|
||||
class="input w-full"
|
||||
type="number"
|
||||
min="1"
|
||||
min="0"
|
||||
max="100"
|
||||
placeholder="5"
|
||||
bind:value={input.params.global.maxLevel}
|
||||
placeholder="18"
|
||||
bind:value={input.metrics.age}
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span class="label mb-1">Weight (lb)</span>
|
||||
<input
|
||||
class="input w-full"
|
||||
type="number"
|
||||
min="0"
|
||||
max="600"
|
||||
placeholder="170"
|
||||
bind:value={input.metrics.weight}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
<fieldset class="fieldset bg-base-300 p-3 max-w-3xs">
|
||||
<legend class="fieldset-legend text-sm font-semibold">
|
||||
Data Generation
|
||||
</legend>
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<label class="label">
|
||||
<input
|
||||
type="checkbox"
|
||||
bind:checked={
|
||||
input.params.activity[selected.activity]
|
||||
.enableGeneration
|
||||
}
|
||||
class="toggle toggle-lg m-auto"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span class="label mb-1">Weight significance</span>
|
||||
<input
|
||||
class="input w-full"
|
||||
type="number"
|
||||
min="-1"
|
||||
max="1"
|
||||
step=".05"
|
||||
placeholder=".1"
|
||||
bind:value={
|
||||
input.params.activity[selected.activity]
|
||||
.weightModifier
|
||||
}
|
||||
disabled={!selected.params.activity[
|
||||
selected.activity
|
||||
].enableGeneration}
|
||||
/>
|
||||
</label>
|
||||
<!-- <label> -->
|
||||
<!-- <span class="label mb-1">Weight skew</span> -->
|
||||
<!-- <input -->
|
||||
<!-- class="input w-full" -->
|
||||
<!-- type="number" -->
|
||||
<!-- min="-1" -->
|
||||
<!-- max="1" -->
|
||||
<!-- step=".05" -->
|
||||
<!-- bind:value={ -->
|
||||
<!-- inputSelected.cfg.activity[selected.activity] -->
|
||||
<!-- .weightSkew -->
|
||||
<!-- } -->
|
||||
<!-- disabled={!selected.params.activity[selected.activity] -->
|
||||
<!-- .enableGeneration} -->
|
||||
<!-- /> -->
|
||||
<!-- </label> -->
|
||||
<label>
|
||||
<span class="label mb-1">Difficulty modifier</span>
|
||||
<input
|
||||
class="input w-full"
|
||||
type="number"
|
||||
min="-1"
|
||||
max="1"
|
||||
step=".05"
|
||||
bind:value={
|
||||
input.params.activity[selected.activity]
|
||||
.difficultyModifier
|
||||
}
|
||||
disabled={!selected.params.activity[
|
||||
selected.activity
|
||||
].enableGeneration}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span class="label mb-1">Age significance</span>
|
||||
<input
|
||||
class="input w-full"
|
||||
type="number"
|
||||
min="-1"
|
||||
max="1"
|
||||
step=".05"
|
||||
bind:value={
|
||||
input.params.activity[selected.activity]
|
||||
.ageModifier
|
||||
}
|
||||
disabled={!selected.params.activity[
|
||||
selected.activity
|
||||
].enableGeneration}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span class="label mb-1">Peak age</span>
|
||||
<input
|
||||
class="input w-full"
|
||||
type="number"
|
||||
min="1"
|
||||
max="100"
|
||||
step="1"
|
||||
bind:value={
|
||||
input.params.activity[selected.activity].peakAge
|
||||
}
|
||||
disabled={!selected.params.activity[
|
||||
selected.activity
|
||||
].enableGeneration}
|
||||
/>
|
||||
</label>
|
||||
<div role="tablist" class="tabs tabs-border">
|
||||
<button
|
||||
role="tab"
|
||||
class="tab"
|
||||
class:tab-active={activeTab === "standards"}
|
||||
onclick={() => (activeTab = "standards")}
|
||||
>
|
||||
Standards
|
||||
</button>
|
||||
|
||||
<fieldset class="fieldset bg-base-200 p-3 max-w-xl">
|
||||
<legend class="fieldset-legend text-sm font-semibold">
|
||||
Stretch
|
||||
</legend>
|
||||
<label>
|
||||
<span class="label mb-1">Lower</span>
|
||||
<input
|
||||
class="input w-full"
|
||||
type="number"
|
||||
min="0"
|
||||
max="10"
|
||||
step="1"
|
||||
bind:value={
|
||||
input.params.activity[selected.activity]
|
||||
.stretch.lower
|
||||
}
|
||||
disabled={!selected.params.activity[
|
||||
selected.activity
|
||||
].enableGeneration}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span class="label mb-1">Upper</span>
|
||||
<input
|
||||
class="input w-full"
|
||||
type="number"
|
||||
min="0"
|
||||
max="10"
|
||||
step="1"
|
||||
bind:value={
|
||||
input.params.activity[selected.activity]
|
||||
.stretch.upper
|
||||
}
|
||||
disabled={!selected.params.activity[
|
||||
selected.activity
|
||||
].enableGeneration}
|
||||
/>
|
||||
</label>
|
||||
</fieldset>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</fieldset>
|
||||
<button
|
||||
role="tab"
|
||||
class="tab"
|
||||
class:tab-active={activeTab === "players"}
|
||||
onclick={() => (activeTab = "players")}
|
||||
>
|
||||
Players
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if activeTab === "standards"}
|
||||
<fieldset class="fieldset bg-base-200 p-6 max-w-lg">
|
||||
<legend class="fieldset-legend text-lg font-semibold">
|
||||
Metrics
|
||||
</legend>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<label>
|
||||
<span class="label mb-1">Gender</span>
|
||||
<select
|
||||
class="select w-full"
|
||||
name="genders"
|
||||
bind:value={input.metrics.gender}
|
||||
>
|
||||
{#each Object.values(Gender) as gender}
|
||||
<option value={gender}>{gender}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span class="label mb-1">Age</span>
|
||||
<input
|
||||
class="input w-full"
|
||||
type="number"
|
||||
min="0"
|
||||
max="100"
|
||||
placeholder="18"
|
||||
bind:value={input.metrics.age}
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span class="label mb-1">Weight (lb)</span>
|
||||
<input
|
||||
class="input w-full"
|
||||
type="number"
|
||||
min="0"
|
||||
max="600"
|
||||
placeholder="170"
|
||||
bind:value={input.metrics.weight}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
<StandardsTable
|
||||
selected={{ ...selected, standardsConfig }}
|
||||
{allStandards}
|
||||
/>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
<div class="divider"></div>
|
||||
|
||||
<div role="tablist" class="tabs tabs-border">
|
||||
<button
|
||||
role="tab"
|
||||
class="tab"
|
||||
class:tab-active={activeTab === "standards"}
|
||||
onclick={() => (activeTab = "standards")}
|
||||
>
|
||||
Standards
|
||||
</button>
|
||||
|
||||
<button
|
||||
role="tab"
|
||||
class="tab"
|
||||
class:tab-active={activeTab === "players"}
|
||||
onclick={() => (activeTab = "players")}
|
||||
>
|
||||
Players
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if activeTab === "standards"}
|
||||
<StandardsTable {selected} {allStandards} />
|
||||
{/if}
|
||||
|
||||
{#if activeTab === "players"}
|
||||
<PlayersTable {allStandards} />
|
||||
{#if activeTab === "players"}
|
||||
<PlayersTable {allStandards} />
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user