delete profile from TerminusX when clicking delete
This commit is contained in:
parent
56671bdae2
commit
4d8e668c51
|
|
@ -43,7 +43,7 @@ type KeyValuePair = [string, unknown];
|
||||||
let Name = '';
|
let Name = '';
|
||||||
let hasCredential = {};
|
let hasCredential = {};
|
||||||
let cid
|
let cid
|
||||||
let primary_url, profileImage, Description
|
let primary_url, profileImage, Description, terminusID
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
await client.connect()
|
await client.connect()
|
||||||
|
|
@ -66,7 +66,7 @@ type KeyValuePair = [string, unknown];
|
||||||
const jsonObjects = await getJSONFromWNFS()
|
const jsonObjects = await getJSONFromWNFS()
|
||||||
console.log("jsonObjects", jsonObjects)
|
console.log("jsonObjects", jsonObjects)
|
||||||
// Find the JSON object with the username "tester"
|
// Find the JSON object with the username "tester"
|
||||||
const usernameJSONObject = jsonObjects.find(obj => obj.name === 'tester')
|
const usernameJSONObject = jsonObjects.find(obj => obj.name === username)
|
||||||
|
|
||||||
// Log the CID of the "username.json" file to the console
|
// Log the CID of the "username.json" file to the console
|
||||||
cid = usernameJSONObject ? usernameJSONObject.cid : null
|
cid = usernameJSONObject ? usernameJSONObject.cid : null
|
||||||
|
|
@ -156,7 +156,7 @@ type KeyValuePair = [string, unknown];
|
||||||
const jsonObjects = await getJSONFromWNFS()
|
const jsonObjects = await getJSONFromWNFS()
|
||||||
console.log(jsonObjects)
|
console.log(jsonObjects)
|
||||||
// Find the JSON object with the username "tester"
|
// Find the JSON object with the username "tester"
|
||||||
const usernameJSONObject = jsonObjects.find(obj => obj.name === 'tester')
|
const usernameJSONObject = jsonObjects.find(obj => obj.name === username)
|
||||||
|
|
||||||
// Log the CID of the "username.json" file to the console
|
// Log the CID of the "username.json" file to the console
|
||||||
cid = usernameJSONObject ? usernameJSONObject.cid : null
|
cid = usernameJSONObject ? usernameJSONObject.cid : null
|
||||||
|
|
@ -217,6 +217,8 @@ type KeyValuePair = [string, unknown];
|
||||||
const terminusperson = await client.getDocument({ type: 'person', as_list: true, query: queryTemplate });
|
const terminusperson = await client.getDocument({ type: 'person', as_list: true, query: queryTemplate });
|
||||||
console.log("result ", terminusperson);
|
console.log("result ", terminusperson);
|
||||||
const real_id: string = terminusperson[0]['@id'];
|
const real_id: string = terminusperson[0]['@id'];
|
||||||
|
terminusID = real_id
|
||||||
|
console.log("terminusID", terminusID)
|
||||||
const num_id: string = real_id.split('/').pop() || '';
|
const num_id: string = real_id.split('/').pop() || '';
|
||||||
|
|
||||||
// Create a new object without the '@id' key
|
// Create a new object without the '@id' key
|
||||||
|
|
@ -239,6 +241,9 @@ const searchResult = await index.addDocuments(newDocumentsArray);
|
||||||
const addedPerson = await client.addDocument(entryObj);
|
const addedPerson = await client.addDocument(entryObj);
|
||||||
console.log("added document", addedPerson)
|
console.log("added document", addedPerson)
|
||||||
addNotification(`profile has been added to knowledge graph`, 'success')
|
addNotification(`profile has been added to knowledge graph`, 'success')
|
||||||
|
const addedID = extractPersonId(String(addedPerson))
|
||||||
|
terminusID = addedID
|
||||||
|
console.log("terminusID", terminusID)
|
||||||
}
|
}
|
||||||
const entries2 = await client.getDocument({"graph_type":"instance","as_list":true,"type":"person"})
|
const entries2 = await client.getDocument({"graph_type":"instance","as_list":true,"type":"person"})
|
||||||
console.log(entries2);
|
console.log(entries2);
|
||||||
|
|
@ -260,6 +265,12 @@ const searchResult = await index.addDocuments(newDocumentsArray);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
|
console.log("deleting", terminusID);
|
||||||
|
|
||||||
|
const deleted = await client.deleteDocument({id:terminusID});
|
||||||
|
if (deleted){
|
||||||
|
addNotification(`profile has been deleted from knowledge graph`, 'success')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue