Skip to content

Commit

Permalink
Add mask property
Browse files Browse the repository at this point in the history
  • Loading branch information
dokempf committed Jul 19, 2024
1 parent a1e2ecf commit 6c6d808
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import EasyDbDetailView from "./components/EasyDBDetailView.svelte";
let uuid = "859e2318-32f6-4013-8468-ef8cec0b581b";
let mask = "";
let instance = "https://heidicon.ub.uni-heidelberg.de";
let languages = [
Expand Down Expand Up @@ -64,9 +65,15 @@
</Label>
<MultiSelect items={languages} bind:value={selected_data_languages} />
</div>
<div class="space-y-2 p-4">
<Label>
Mask (leave empty for default mask):
</Label>
<Input bind:value={mask} />
</div>
</div>
<div class="w-1/2 p-4 border border-gray-300">
<EasyDbDetailView uuid={uuid} appLanguage={selected_app_language} dataLanguages={selected_data_languages} easydbInstance={instance} />
<EasyDbDetailView uuid={uuid} appLanguage={selected_app_language} dataLanguages={selected_data_languages} easydbInstance={instance} mask={mask}/>
</div>
</div>
</main>
3 changes: 2 additions & 1 deletion src/components/EasyDBDetailView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
export let appLanguage = "de-DE";
export let dataLanguages = ["de-DE", "en-US"];
export let easydbInstance = pregen_instance;
export let mask = "";
$: appLanguageStore.set(appLanguage);
$: dataLanguagesStore.set(dataLanguages);
Expand All @@ -19,7 +20,7 @@
{#await $easydbDataPromiseStore }
Accessing the EasyDB instance...
{:then}
{#await easydb_api_object(uuid) }
{#await easydb_api_object(uuid, mask) }
Waiting for API response...
{:then data }
<RecursiveEasyDbDetailView fields={maskObj(data).fields} data={data} table={maskObj(data).table_name_hint}/>
Expand Down
9 changes: 7 additions & 2 deletions src/lib/apiaccess.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { get } from 'svelte/store';
import { easydbInstanceStore } from './stores';

export async function easydb_api_object(uuid) {
export async function easydb_api_object(uuid, mask) {
if (!uuid) {
return {}
}

let url = `${get(easydbInstanceStore)}/api/objects/uuid/${uuid}`;
if (mask !== '') {
url = `${url}/mask/${mask}`;
}

// Fetch the schema data for this instance
const response = await fetch(`${get(easydbInstanceStore)}/api/objects/uuid/${uuid}`);
const response = await fetch(url);
if(response.status != 200) {
throw new Error(`Could not fetch the data for uuid: ${uuid}`);
}
Expand Down

0 comments on commit 6c6d808

Please sign in to comment.