update schema for Person, add schema for organization. Allow Person data to be updated
This commit is contained in:
parent
19ec820233
commit
77ea389b5c
|
|
@ -1,13 +1,47 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onDestroy } from 'svelte'
|
import { onDestroy } from 'svelte'
|
||||||
|
import { onMount } from 'svelte'
|
||||||
|
|
||||||
import TerminusClient from "@terminusdb/terminusdb-client";
|
import TerminusClient from "@terminusdb/terminusdb-client"
|
||||||
import { filesystemStore, sessionStore } from '$src/stores'
|
import { filesystemStore, sessionStore } from '$src/stores'
|
||||||
import { AREAS, galleryStore } from '$routes/gallery/stores'
|
import { AREAS, galleryStore } from '$routes/gallery/stores'
|
||||||
import { getImagesFromWNFS, type Image } from '$routes/gallery/lib/gallery'
|
import { getImagesFromWNFS, type Image } from '$routes/gallery/lib/gallery'
|
||||||
import FileUploadCard from '$routes/gallery/components/upload/FileUploadCard.svelte'
|
import FileUploadCard from '$routes/gallery/components/upload/FileUploadCard.svelte'
|
||||||
import ImageCard from '$routes/gallery/components/imageGallery/ImageCard.svelte'
|
import ImageCard from '$routes/gallery/components/imageGallery/ImageCard.svelte'
|
||||||
import ImageModal from '$routes/gallery/components/imageGallery/ImageModal.svelte'
|
import ImageModal from '$routes/gallery/components/imageGallery/ImageModal.svelte'
|
||||||
|
|
||||||
|
const client = new TerminusClient.WOQLClient(
|
||||||
|
"https://cloud.terminusdb.com/Myseelia",{
|
||||||
|
user:"zaldarren@gmail.com",
|
||||||
|
organization:"Myseelia",
|
||||||
|
db: "Myseelia",
|
||||||
|
token: "dGVybWludXNkYjovLy9kYXRhL2tleXNfYXBpLzg5OTY0ZGI5OWFlYjQ1Zjc5OGM5ZTRiZWI2MzExOGJhZjhiOWRiOWNlOTJiNmU2NGI0NDEzZjIzNDFmOGVkMjc=_869e9bd2465ad84126151962994fcfa22d4b7ec9375edf16b4182e7f36e4b2b820075ba22e78f629e0691eddbeae6998a6504d5ce287aa1df2602cb556b58e1730b0b93feb0e9304"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
let username = $sessionStore.username;
|
||||||
|
let bioregion = '';
|
||||||
|
let ecozone = '';
|
||||||
|
let affiliatedOrganizations = "Organization/8c8368b55dc80f18ba254771701f6d1bc79a3a90f127c28b3145a2c2204e97ce";
|
||||||
|
let givenName = '';
|
||||||
|
let hasCredential = {};
|
||||||
|
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
try{
|
||||||
|
await client.connect()
|
||||||
|
const schema = await client.getSchema("myseelia", "main")
|
||||||
|
// console.log("Schema");
|
||||||
|
// console.log(schema);
|
||||||
|
// console.log("result");
|
||||||
|
|
||||||
|
// const result = await client.getDocument({as_list:true,type:"Person",query: { userName: "tester" }})
|
||||||
|
// console.log(result);
|
||||||
|
}catch(err){
|
||||||
|
console.error("this is it" + err.message)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open the ImageModal and pass it the selected `image` from the gallery
|
* Open the ImageModal and pass it the selected `image` from the gallery
|
||||||
* @param image
|
* @param image
|
||||||
|
|
@ -47,33 +81,31 @@
|
||||||
unsubscribeSessionStore()
|
unsubscribeSessionStore()
|
||||||
})
|
})
|
||||||
|
|
||||||
let bioregion = '';
|
|
||||||
let ecozone = '';
|
|
||||||
let skills = '';
|
|
||||||
let interests = '';
|
|
||||||
let associatedOrganizations = '';
|
|
||||||
|
|
||||||
function handleSubmit() {
|
function handleSubmit() {
|
||||||
alert("submitted");
|
|
||||||
makeConnection();
|
makeConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function makeConnection(){
|
export async function makeConnection(){
|
||||||
try{
|
try{
|
||||||
const client = new TerminusClient.WOQLClient(
|
const entryObj =
|
||||||
"https://cloud.terminusdb.com/Myseelia",{
|
{
|
||||||
user:"zaldarren@gmail.com",
|
"@type" : "Person",
|
||||||
organization:"Myseelia",
|
"userName" : username,
|
||||||
token: "dGVybWludXNkYjovLy9kYXRhL2tleXNfYXBpLzg5OTY0ZGI5OWFlYjQ1Zjc5OGM5ZTRiZWI2MzExOGJhZjhiOWRiOWNlOTJiNmU2NGI0NDEzZjIzNDFmOGVkMjc=_869e9bd2465ad84126151962994fcfa22d4b7ec9375edf16b4182e7f36e4b2b820075ba22e78f629e0691eddbeae6998a6504d5ce287aa1df2602cb556b58e1730b0b93feb0e9304"
|
"givenName" : givenName,
|
||||||
}
|
"bioregion": bioregion,
|
||||||
);
|
"ecozone": ecozone,
|
||||||
await client.connect()
|
"hasCredential": hasCredential,
|
||||||
const schema = await client.getSchema("myseelia", "main")
|
"affiliation": affiliatedOrganizations
|
||||||
console.log("Schema");
|
};
|
||||||
console.log(schema);
|
if (username == entryObj.userName){
|
||||||
const entries = await client.getDocument({"graph_type":"instance","as_list":true,"type":"Entry"})
|
await client.updateDocument(entryObj)
|
||||||
console.log("Entries");
|
} else{
|
||||||
console.log(entries);
|
await client.addDocument(entryObj);
|
||||||
|
}
|
||||||
|
const entries2 = await client.getDocument({"graph_type":"instance","as_list":true,"type":"Person"})
|
||||||
|
console.log(entries2);
|
||||||
}catch(err){
|
}catch(err){
|
||||||
console.error(err.message)
|
console.error(err.message)
|
||||||
}
|
}
|
||||||
|
|
@ -90,6 +122,11 @@ label {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input{
|
||||||
|
background-color: rgb(255, 255, 255);
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
button{
|
button{
|
||||||
background-color: #4CAF50; /* Green */
|
background-color: #4CAF50; /* Green */
|
||||||
padding: 12px 20px;
|
padding: 12px 20px;
|
||||||
|
|
@ -108,29 +145,29 @@ button{
|
||||||
{#each $galleryStore.selectedArea === AREAS.PRIVATE ? $galleryStore.privateImages : $galleryStore.publicImages as image}{/each}
|
{#each $galleryStore.selectedArea === AREAS.PRIVATE ? $galleryStore.privateImages : $galleryStore.publicImages as image}{/each}
|
||||||
</div>
|
</div>
|
||||||
<form on:submit|preventDefault={handleSubmit}>
|
<form on:submit|preventDefault={handleSubmit}>
|
||||||
|
<label class="label dark:text-white">
|
||||||
|
Given Name:
|
||||||
|
<input class="input text-white dark:text-black" type="text" bind:value={givenName} />
|
||||||
|
</label>
|
||||||
|
<br />
|
||||||
<label class="label dark:text-white">
|
<label class="label dark:text-white">
|
||||||
Bioregion:
|
Bioregion:
|
||||||
<input type="text" bind:value={bioregion} />
|
<input class="input text-white dark:text-black" type="text" bind:value={bioregion} />
|
||||||
</label>
|
</label>
|
||||||
<br />
|
<br />
|
||||||
<label class="label dark:text-white">
|
<label class="label dark:text-white">
|
||||||
Ecozone:
|
Ecozone:
|
||||||
<input type="text" bind:value={ecozone} />
|
<input class="input text-white dark:text-black" type="text" bind:value={ecozone} />
|
||||||
</label >
|
</label >
|
||||||
<br />
|
<br />
|
||||||
<label class="label dark:text-white">
|
<label class="label dark:text-white">
|
||||||
Skills:
|
Has Credential:
|
||||||
<input type="text" bind:value={skills} />
|
<input class="input text-white dark:text-black" type="text" bind:value={hasCredential} />
|
||||||
</label>
|
</label >
|
||||||
<br />
|
<br />
|
||||||
<label class="label dark:text-white">
|
<label class="label dark:text-white">
|
||||||
Interests:
|
Affiliated organizations:
|
||||||
<input type="text" bind:value={interests} />
|
<input class="input text-white dark:text-black" type="text" bind:value={affiliatedOrganizations}/>
|
||||||
</label>
|
|
||||||
<br />
|
|
||||||
<label class="label dark:text-white">
|
|
||||||
Associated organizations:
|
|
||||||
<input type="text" bind:value={associatedOrganizations} />
|
|
||||||
</label>
|
</label>
|
||||||
<br />
|
<br />
|
||||||
<button class="bg-blue-500 text-white dark:text-black" type="submit">Submit</button>
|
<button class="bg-blue-500 text-white dark:text-black" type="submit">Submit</button>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue