Refactor code structure for improved readability and maintainability
This commit is contained in:
parent
e314c05167
commit
b99eeb8e54
5 changed files with 54 additions and 9 deletions
BIN
frontend.zip
Normal file
BIN
frontend.zip
Normal file
Binary file not shown.
|
|
@ -1,7 +1,7 @@
|
|||
```mermaid
|
||||
classDiagram
|
||||
%% Generated from LinkML manifest: /schemas/20251121/linkml/manifest.json
|
||||
%% Manifest generated: 2026-02-20T11:59:56.167Z
|
||||
%% Manifest generated: 2026-02-20T12:44:35.583Z
|
||||
direction LR
|
||||
class AbbreviatedTitle
|
||||
class AbbreviationVariant
|
||||
|
|
|
|||
|
|
@ -309,7 +309,7 @@ export interface SlotImportInfo {
|
|||
}>;
|
||||
}
|
||||
|
||||
const SCHEMA_BASE_PATH = '/schemas/20251121/linkml';
|
||||
let schemaBasePath = '/schemas/20251121/linkml';
|
||||
|
||||
/**
|
||||
* Progress tracking for schema loading
|
||||
|
|
@ -418,6 +418,33 @@ class LinkMLSchemaService {
|
|||
private progressCallbacks: Set<ProgressCallback> = new Set();
|
||||
private lastProgress: SchemaLoadingProgress | null = null;
|
||||
|
||||
setSchemaBasePath(nextBasePath: string): void {
|
||||
const normalized = nextBasePath.replace(/\/$/, '');
|
||||
if (normalized === schemaBasePath) {
|
||||
return;
|
||||
}
|
||||
|
||||
schemaBasePath = normalized;
|
||||
this.reset();
|
||||
}
|
||||
|
||||
getSchemaBasePath(): string {
|
||||
return schemaBasePath;
|
||||
}
|
||||
|
||||
private reset(): void {
|
||||
this.mainSchema = null;
|
||||
this.classSchemas = new Map();
|
||||
this.classToFile = new Map();
|
||||
this.slotSchemas = new Map();
|
||||
this.enumSchemas = new Map();
|
||||
this.mergedPrefixes = { ...COMMON_PREFIXES };
|
||||
this.loading = null;
|
||||
this.loaded = false;
|
||||
this.manifest = null;
|
||||
this.lastProgress = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to progress updates
|
||||
*/
|
||||
|
|
@ -495,7 +522,7 @@ class LinkMLSchemaService {
|
|||
if (this.manifest) return this.manifest;
|
||||
|
||||
try {
|
||||
const response = await fetch(`${SCHEMA_BASE_PATH}/manifest.json`);
|
||||
const response = await fetch(`${schemaBasePath}/manifest.json`);
|
||||
if (response.ok) {
|
||||
this.manifest = await response.json() as SchemaManifest;
|
||||
debugLog(`[LinkMLSchemaService] Loaded manifest.json (generated: ${this.manifest.generated})`);
|
||||
|
|
@ -621,7 +648,7 @@ class LinkMLSchemaService {
|
|||
let slotFileNames: string[] = this._getFilesFromManifest('slot');
|
||||
if (slotFileNames.length === 0) {
|
||||
try {
|
||||
const slotManifestResponse = await fetch(`${SCHEMA_BASE_PATH}/modules/slots/manifest.json`);
|
||||
const slotManifestResponse = await fetch(`${schemaBasePath}/modules/slots/manifest.json`);
|
||||
if (slotManifestResponse.ok) {
|
||||
const slotManifest = await slotManifestResponse.json();
|
||||
slotFileNames = slotManifest.files || [];
|
||||
|
|
|
|||
|
|
@ -110,8 +110,26 @@ export interface SchemaManifest {
|
|||
categories: SchemaCategory[];
|
||||
}
|
||||
|
||||
const SCHEMA_BASE_PATH = '/schemas/20251121/linkml';
|
||||
const MANIFEST_PATH = `${SCHEMA_BASE_PATH}/manifest.json`;
|
||||
let schemaBasePath = '/schemas/20251121/linkml';
|
||||
|
||||
function buildManifestPath(): string {
|
||||
return `${schemaBasePath}/manifest.json`;
|
||||
}
|
||||
|
||||
export function setSchemaBasePath(nextBasePath: string): void {
|
||||
const normalized = nextBasePath.replace(/\/$/, '');
|
||||
if (normalized === schemaBasePath) {
|
||||
return;
|
||||
}
|
||||
|
||||
schemaBasePath = normalized;
|
||||
cachedManifest = null;
|
||||
manifestLoadPromise = null;
|
||||
}
|
||||
|
||||
export function getSchemaBasePath(): string {
|
||||
return schemaBasePath;
|
||||
}
|
||||
|
||||
// Cache for the manifest
|
||||
let cachedManifest: SchemaManifest | null = null;
|
||||
|
|
@ -134,7 +152,7 @@ export async function loadManifest(): Promise<SchemaManifest | null> {
|
|||
// Start loading
|
||||
manifestLoadPromise = (async () => {
|
||||
try {
|
||||
const response = await fetch(MANIFEST_PATH);
|
||||
const response = await fetch(buildManifestPath());
|
||||
if (!response.ok) {
|
||||
console.error(`Failed to load manifest: ${response.status}`);
|
||||
return null;
|
||||
|
|
@ -196,7 +214,7 @@ export function getSchemaCategoriesSync(): SchemaCategory[] {
|
|||
*/
|
||||
export async function loadSchema(schemaPath: string): Promise<LinkMLSchema | null> {
|
||||
try {
|
||||
const response = await fetch(`${SCHEMA_BASE_PATH}/${schemaPath}`);
|
||||
const response = await fetch(`${schemaBasePath}/${schemaPath}`);
|
||||
if (!response.ok) {
|
||||
console.error(`Failed to load schema: ${schemaPath}`, response.status);
|
||||
return null;
|
||||
|
|
@ -215,7 +233,7 @@ export async function loadSchema(schemaPath: string): Promise<LinkMLSchema | nul
|
|||
*/
|
||||
export async function loadSchemaRaw(schemaPath: string): Promise<string | null> {
|
||||
try {
|
||||
const response = await fetch(`${SCHEMA_BASE_PATH}/${schemaPath}`);
|
||||
const response = await fetch(`${schemaBasePath}/${schemaPath}`);
|
||||
if (!response.ok) {
|
||||
console.error(`Failed to load schema: ${schemaPath}`, response.status);
|
||||
return null;
|
||||
|
|
|
|||
BIN
schemas/20251121/linkml/modules/schemata_bronhouder.zip
Normal file
BIN
schemas/20251121/linkml/modules/schemata_bronhouder.zip
Normal file
Binary file not shown.
Loading…
Reference in a new issue