Add initial portal frontend for configuration managemetn

This commit is contained in:
Dominic Ferrando
2026-07-08 13:25:07 -04:00
parent cec0d17312
commit 2804f2cbf9
2 changed files with 442 additions and 277 deletions
+7 -4
View File
@@ -55,9 +55,10 @@ class CalculatorStandardsConfigService {
return Date.now() - this.lastRefreshedAt >= this.refreshInterval;
},
isIncomplete: function () {
return !this.data.datasetId || !this.data.config
return !this.data.id || !this.data.datasetId || !this.data.config
},
data: {
id: null as string | null,
datasetId: null as string | null,
config: null as StandardsConfig | null
},
@@ -65,10 +66,10 @@ class CalculatorStandardsConfigService {
constructor(private name: string) { }
async get(): Promise<StandardsConfig> {
async get(): Promise<StandardsConfig & { id: string }> {
await this.refresh({ onlyIfStale: true });
if (!this.cache.data.config) throw new CalculatorUnavailableError("Unable to determine the calculator's standards configuration");
return this.cache.data.config;
if (!this.cache.data.id || !this.cache.data.config) throw new CalculatorUnavailableError("Unable to determine the calculator's standards configuration");
return { id: this.cache.data.id, ...this.cache.data.config };
}
async refresh(opt: { onlyIfStale?: boolean } = {}): Promise<void> {
@@ -79,6 +80,7 @@ class CalculatorStandardsConfigService {
.innerJoin("standards_configs", "standards_configs.id", "calculators.standards_config_id")
.innerJoin("standards_datasets", "standards_datasets.id", "standards_configs.dataset_id")
.select([
"standards_configs.id as id",
"standards_configs.dataset_id as datasetId",
"standards_configs.params as params",
"standards_datasets.data as data",
@@ -89,6 +91,7 @@ class CalculatorStandardsConfigService {
Value.Assert(StandardsParamsSchema, result.params);
Value.Assert(StandardsDataSchema, result.data);
this.cache.data.id = result.id;
this.cache.data.datasetId = result.datasetId;
this.cache.data.config = {
data: result.data,