Skip to content

Commit

Permalink
Use System IDs instead of UUIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
dokempf committed Sep 24, 2024
1 parent 6315e3e commit a704035
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 62 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ If you find any issues with using this component, please open an issue.
Preferrably, include the following information:

* The instance URL where this is happening
* The UUID of the object that triggers the behaviour (if non-standard, also the mask)
* The System ID of the object that triggers the behaviour (if non-standard, also the mask)
* A screenshot of the intended and the observed behaviour
3 changes: 1 addition & 2 deletions bundle/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
customElements.whenDefined("easydb-detail-view").then(() => {
setTimeout(() => {
let ele = document.getElementById("my-easydb");
console.log(ele);
var link = document.createElement("link");
link.setAttribute("rel", "stylesheet");
link.setAttribute(
Expand All @@ -26,6 +25,6 @@
</script>
</head>
<body>
<easydb-detail-view id="my-easydb" uuid="e95dcb74-77f6-4794-b468-506da8b7a3a1"/>
<easydb-detail-view id="my-easydb" systemid="e95dcb74-77f6-4794-b468-506da8b7a3a1"/>
</body>
</html>
54 changes: 27 additions & 27 deletions src/App.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script>
import { Button, Heading, Input, Label, MultiSelect, Select } from "flowbite-svelte";
import { appLanguageStore, easydbInstanceStore, easydbInstanceDataStore, easydbInstanceDataPromiseStore, easydbTokenPromiseStore, masksToRenderStore, userTokenStore, uuidStore, viewerPanelStateStore } from "./lib/stores";
import { appLanguageStore, easydbInstanceStore, easydbInstanceDataStore, easydbInstanceDataPromiseStore, easydbTokenPromiseStore, masksToRenderStore, systemidStore, userTokenStore, viewerPanelStateStore } from "./lib/stores";
import EasyDbDetailView from "./components/EasyDBDetailView.svelte";
let uuid = "859e2318-32f6-4013-8468-ef8cec0b581b";
let systemid = "906249";
let mask = "";
let instance = "https://heidicon.ub.uni-heidelberg.de";
let token = "";
Expand All @@ -30,7 +30,7 @@
console.log("easydbTokenPromiseStore: ", $easydbTokenPromiseStore);
console.log("masksToRenderStore: ", $masksToRenderStore);
console.log("userTokenStore: ", $userTokenStore);
console.log("uuidStore: ", $uuidStore);
console.log("systemidStore: ", $systemidStore);
console.log("viewerPanelStateStore: ", $viewerPanelStateStore);
}
</script>
Expand Down Expand Up @@ -59,93 +59,93 @@
</div>
<div class="space-y-2 p-4">
<Label>
UUID of EasyDB record
System ID of EasyDB record
</Label>
<Input type="text" bind:value={uuid} size="lg" class="w-full"></Input>
<Input type="text" bind:value={systemid} size="lg" class="w-full"></Input>
</div>
<div class="space-y-2 p-4">
<Label>
Some pre-selected UUIDs:
Some pre-selected System IDs:
</Label>
<Button class="w-full" on:click={
() => {
uuid = "6deddff8-c600-447e-8892-3359c3516a94";
systemid = "23823812";
instance = "https://heidicon.ub.uni-heidelberg.de";
}
}>
6deddff8-c600-447e-8892-3359c3516a94@HeidICON
23823812@HeidICON
</Button>
<Button class="w-full" on:click={
() => {
uuid = "859e2318-32f6-4013-8468-ef8cec0b581b";
systemid = "906249";
instance = "https://heidicon.ub.uni-heidelberg.de";
}
}>
859e2318-32f6-4013-8468-ef8cec0b581b@HeidICON
906249@HeidICON
</Button>
<Button class="w-full" on:click={
() => {
uuid = "acbc91a3-2c1f-49be-b937-9d78de838640";
systemid = "360156";
instance = "https://heidicon.ub.uni-heidelberg.de";
}
}>
acbc91a3-2c1f-49be-b937-9d78de838640@HeidICON
360156@HeidICON
</Button>
<Button class="w-full" on:click={
() => {
uuid = "2ee862d1-180d-4222-bbbf-41a8ec06e41a";
systemid = "23817051";
instance = "https://heidicon.ub.uni-heidelberg.de";
}
}>
2ee862d1-180d-4222-bbbf-41a8ec06e41a@HeidICON
23817051@HeidICON
</Button>
<Button class="w-full" on:click={
() => {
uuid = "a3f6109f-feb4-45f8-8e76-c4466efd0d20";
systemid = "23824557";
instance = "https://heidicon.ub.uni-heidelberg.de";
}
}>
a3f6109f-feb4-45f8-8e76-c4466efd0d20@HeidICON
23824557@HeidICON
</Button>
<Button class="w-full" on:click={
() => {
uuid = "bb7c84ae-4796-4c20-8df0-a4c5c49a7ac6";
systemid = "1748947";
instance = "https://heidicon.ub.uni-heidelberg.de";
}
}>
bb7c84ae-4796-4c20-8df0-a4c5c49a7ac6@HeidICON
1748947@HeidICON
</Button>
<Button class="w-full" on:click={
() => {
uuid = "1fde05f5-7767-448f-a104-4f4af9d8f9ed";
systemid = "1706516";
instance = "https://heidicon.ub.uni-heidelberg.de";
}
}>
1fde05f5-7767-448f-a104-4f4af9d8f9ed@HeidICON
1706516@HeidICON
</Button>
<Button class="w-full" on:click={
() => {
uuid = "e95dcb74-77f6-4794-b468-506da8b7a3a1";
systemid = "1019633";
instance = "https://heidicon.ub.uni-heidelberg.de";
}
}>
e95dcb74-77f6-4794-b468-506da8b7a3a1@HeidICON
1019633@HeidICON
</Button>
<Button class="w-full" on:click={
() => {
uuid = "a1b154b0-2c89-4317-8bac-2a7e684740b8";
systemid = "1655171";
instance = "https://heidicon.ub.uni-heidelberg.de";
}
}>
a1b154b0-2c89-4317-8bac-2a7e684740b8@HeidICON
1655171@HeidICON
</Button>
<Button class="w-full" on:click={
() => {
uuid = "bc679b8c-e8af-48d3-9339-5260c20c3e77";
systemid = "6493";
instance = "https://dmmp.ub.uni-heidelberg.de";
}
}>
bc679b8c-e8af-48d3-9339-5260c20c3e77@DMMP
6493@DMMP
</Button>
</div>
<div class="space-y-2 p-4">
Expand Down Expand Up @@ -182,7 +182,7 @@
</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} mask={mask} masksToRender={selected_masks} />
<EasyDbDetailView systemid={systemid} appLanguage={selected_app_language} dataLanguages={selected_data_languages} easydbInstance={instance} mask={mask} masksToRender={selected_masks} />
</div>
</div>
</main>
6 changes: 3 additions & 3 deletions src/components/EasyDBDetailView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import '../app.pcss';
import { pregen_instance } from "../lib/easydbPregen";
import { appLanguageStore, dataLanguagesStore, easydbInstanceStore, easydbInstanceDataStore, userGivenMasksToRenderStore, uuidStore } from "../lib/stores";
import { appLanguageStore, dataLanguagesStore, easydbInstanceStore, easydbInstanceDataStore, systemidStore, userGivenMasksToRenderStore } from "../lib/stores";
import DetailViewImpl from "./logic/DetailViewImpl.svelte";
import Waiting from "./utils/Waiting.svelte";
export let uuid = "";
export let systemid = "";
export let appLanguage = "de-DE";
export let dataLanguages = ["de-DE", "en-US"];
export let easydbInstance = pregen_instance;
Expand All @@ -20,7 +20,7 @@
$: dataLanguagesStore.set(dataLanguages);
$: easydbInstanceStore.set(easydbInstance);
$: userGivenMasksToRenderStore.set(masksToRender)
$: uuidStore.set([uuid]);
$: systemidStore.set([systemid]);
</script>

{#if !$easydbInstanceDataStore }
Expand Down
6 changes: 3 additions & 3 deletions src/components/fields/Link.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script>
import { fieldData, hasField, standardHasAsset, selectStandardAsset } from "../../lib/easydbHelpers";
import { dataLanguagesStore, pushUUID, masksToRenderStore } from "../../lib/stores";
import { dataLanguagesStore, pushSystemID, masksToRenderStore } from "../../lib/stores";
import { A, Breadcrumb, BreadcrumbItem, Card, P, Popover } from "flowbite-svelte";
import FieldLabel from "./FieldLabel.svelte";
Expand All @@ -24,7 +24,7 @@
function handleClick() {
if(!requiresPopover()) {
pushUUID(fdata._uuid);
pushSystemID(fdata._system_object_id);
}
else {
detailViewComponent = import("../logic/DetailViewImpl.svelte");
Expand Down Expand Up @@ -81,7 +81,7 @@
{#if detailViewComponent }
{#await detailViewComponent then { default : DetailViewImpl }}
<Popover class="w-[800px] h-[800px] overflow-auto z-20" triggeredBy="#link" trigger="click">
<DetailViewImpl uuid={fdata._uuid} />
<DetailViewImpl systemid={fdata._system_object_id} />
</Popover>
{/await}
{/if}
8 changes: 4 additions & 4 deletions src/components/logic/DetailControls.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import { appLanguageStore, popUUID, uuidStore, viewerPanelStateStore } from "../../lib/stores";
import { appLanguageStore, popSystemID, systemidStore, viewerPanelStateStore } from "../../lib/stores";
import { Button, ButtonGroup, Tooltip } from "flowbite-svelte";
import { BackwardStepOutline, ImageOutline, MapPinAltOutline, RectangleListOutline } from "flowbite-svelte-icons";
Expand Down Expand Up @@ -40,12 +40,12 @@
</script>

<ButtonGroup class="pb-2">
{#if $uuidStore.length > 1}
<Button id="back-nav" on:click={popUUID}>
{#if $systemidStore.length > 1}
<Button id="back-nav" on:click={popSystemID}>
<BackwardStepOutline class="inline-block w-6 h-6"/>
</Button>
<Tooltip triggeredBy="#back-nav" placement="bottom" class="z-10">
{l10n.returntext[$appLanguageStore]}{$uuidStore.at(-2)}
{l10n.returntext[$appLanguageStore]}{$systemidStore.at(-2)}
</Tooltip>
{/if}
{#if hasRelations()}
Expand Down
6 changes: 3 additions & 3 deletions src/components/logic/DetailViewImpl.svelte
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<script>
import { easydb_api_object } from "../../lib/apiaccess";
import { maskObj } from "../../lib/easydbHelpers";
import { uuidStore } from "../../lib/stores";
import { systemidStore } from "../../lib/stores";
import RecursiveEasyDbDetailView from "./RecursiveEasyDBDetailView.svelte";
import TitleDisplay from "./TitleDisplay.svelte";
import ViewerPanel from "./ViewerPanel.svelte";
import Waiting from "../utils/Waiting.svelte";
import DetailControls from "./DetailControls.svelte";
export let uuid;
export let systemid;
export let mask = "";
</script>

{#await easydb_api_object(uuid ? uuid : $uuidStore.at(-1), mask) }
{#await easydb_api_object(systemid ? systemid : $systemidStore.at(-1), mask) }
<Waiting>
Waiting for API response...
</Waiting>
Expand Down
6 changes: 3 additions & 3 deletions src/components/logic/HierarchyViewer.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script>
import { easydbChildrenObject } from "../../lib/apiaccess";
import { pushUUID } from "../../lib/stores";
import { pushSystemID } from "../../lib/stores";
import { A, Accordion, AccordionItem } from "flowbite-svelte";
import StandardRendering from "./StandardRendering.svelte";
Expand All @@ -15,7 +15,7 @@
{#if root._has_children}
<AccordionItem open={openids.includes(root[table]._id)}>
<span slot="header">
<A on:click={ () => { pushUUID(root._uuid); }}>
<A on:click={ () => { pushSystemID(root._system_object_id); }}>
<StandardRendering data={root} asset={true}/>
</A>
</span>
Expand All @@ -34,7 +34,7 @@
<div slot="arrowup" />
<div slot="arrowdown" />
<span slot="header">
<A on:click={ () => { pushUUID(root._uuid); }}>
<A on:click={ () => { pushSystemID(root._system_object_id); }}>
<StandardRendering data={root} asset={true}/>
</A>
</span>
Expand Down
6 changes: 3 additions & 3 deletions src/components/logic/RecursiveEasyDBDetailView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@
return false;
}
function loadAdditionalUUID(field) {
function loadAdditionalSystemID(field) {
const fdata = fieldData(data, table, field);
return easydb_api_object(fdata._uuid, fdata._mask);
return easydb_api_object(fdata._system_object_id, fdata._mask);
}
</script>

Expand Down Expand Up @@ -182,7 +182,7 @@
<Link field={firstField} data={data} table={table} condensed={condensed} />
{:else if firstField.inline === "text" }
<Card horizontal class="max-w-full block">
{#await loadAdditionalUUID(firstField)}
{#await loadAdditionalSystemID(firstField)}
<Waiting>
Accessing API...
</Waiting>
Expand Down
4 changes: 2 additions & 2 deletions src/components/splitter/UBHDObjMaskSplitter.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import { appLanguageStore, pushUUID } from "../../lib/stores";
import { appLanguageStore, pushSystemID } from "../../lib/stores";
import { A, P } from "flowbite-svelte";
import { ArrowDownOutline, ArrowRightOutline } from "flowbite-svelte-icons";
Expand Down Expand Up @@ -31,7 +31,7 @@
</script>

<P class="text-right ubhd-obj-mask-splitter-text">
<A on:click={() => { pushUUID(data._uuid); }}>
<A on:click={() => { pushSystemID(data._system_object_id); }}>
{l10n.hinweistext1[$appLanguageStore]}
{l10n[options.label][$appLanguageStore]}
{l10n.hinweistext2[$appLanguageStore]}
Expand Down
8 changes: 4 additions & 4 deletions src/lib/apiaccess.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { get } from 'svelte/store';
import { easydbTokenPromiseStore, easydbInstanceStore, userTokenStore } from './stores';

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

let url = `${get(easydbInstanceStore)}/api/objects/uuid/${uuid}`;
let url = `${get(easydbInstanceStore)}/api/objects/id/${systemid}`;
if (mask !== '') {
url = `${url}/mask/${mask}`;
}
Expand All @@ -17,7 +17,7 @@ export async function easydb_api_object(uuid, mask) {
// Fetch the schema data for this instance
const response = await fetch(url);
if(response.status != 200) {
throw new Error(`Could not fetch the data for uuid: ${uuid}`);
throw new Error(`Could not fetch the data for systemid: ${systemid}`);
}
const response_json = await response.json();
return response_json;
Expand Down
14 changes: 7 additions & 7 deletions src/lib/stores.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export const appLanguageStore = writable(null);
// This manages the global state of the current data language
export const dataLanguagesStore = writable(null);

// This manages the global state of the currently shown object UUID
// This manages the global state of the currently shown object System ID
// It is organized as a stack to allow for back navigation
export const uuidStore = writable([]);
export const systemidStore = writable([]);

// This manages the global state of the EasyDB instance we are talking to
export const easydbInstanceStore = writable(null);
Expand Down Expand Up @@ -86,14 +86,14 @@ export const easydbInstanceDataStore = derivedPromise(easydbInstanceDataPromiseS
// Possible values are "hierarchy", "asset" and "map" (currently).
export const viewerPanelStateStore = writable("asset");

// A helper function to add a new UUID to the store and reset relevant other stores
export function pushUUID(uuid) {
uuidStore.update(uuids => [...uuids, uuid]);
// A helper function to add a new System ID to the store and reset relevant other stores
export function pushSystemID(systemid) {
systemidStore.update(systemids => [...systemids, systemid]);
viewerPanelStateStore.set("asset");
}

export function popUUID() {
uuidStore.update(uuids => uuids.slice(0, -1));
export function popSystemID() {
systemidStore.update(systemids => systemids.slice(0, -1));
viewerPanelStateStore.set("asset");
}

Expand Down

0 comments on commit a704035

Please sign in to comment.