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 hasCredential = {};
|
||||
let cid
|
||||
let primary_url, profileImage, Description
|
||||
let primary_url, profileImage, Description, terminusID
|
||||
|
||||
onMount(async () => {
|
||||
await client.connect()
|
||||
|
|
@ -66,7 +66,7 @@ type KeyValuePair = [string, unknown];
|
|||
const jsonObjects = await getJSONFromWNFS()
|
||||
console.log("jsonObjects", jsonObjects)
|
||||
// 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
|
||||
cid = usernameJSONObject ? usernameJSONObject.cid : null
|
||||
|
|
@ -156,7 +156,7 @@ type KeyValuePair = [string, unknown];
|
|||
const jsonObjects = await getJSONFromWNFS()
|
||||
console.log(jsonObjects)
|
||||
// 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
|
||||
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 });
|
||||
console.log("result ", terminusperson);
|
||||
const real_id: string = terminusperson[0]['@id'];
|
||||
terminusID = real_id
|
||||
console.log("terminusID", terminusID)
|
||||
const num_id: string = real_id.split('/').pop() || '';
|
||||
|
||||
// Create a new object without the '@id' key
|
||||
|
|
@ -239,6 +241,9 @@ const searchResult = await index.addDocuments(newDocumentsArray);
|
|||
const addedPerson = await client.addDocument(entryObj);
|
||||
console.log("added document", addedPerson)
|
||||
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"})
|
||||
console.log(entries2);
|
||||
|
|
@ -260,6 +265,12 @@ const searchResult = await index.addDocuments(newDocumentsArray);
|
|||
} catch (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>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue