diff --git a/ng-sdk-js/example-webapp-react-socialquery/package-lock.json b/ng-sdk-js/example-webapp-react-socialquery/package-lock.json index fdfab06..90a5412 100644 --- a/ng-sdk-js/example-webapp-react-socialquery/package-lock.json +++ b/ng-sdk-js/example-webapp-react-socialquery/package-lock.json @@ -9,16 +9,16 @@ "version": "0.0.1", "dependencies": { "@heroicons/react": "^2.2.0", - "@ldo/connected-nextgraph": "^1.0.0-alpha.11", - "@ldo/ldo": "^1.0.0-alpha.11", - "@ldo/react": "^1.0.0-alpha.11", + "@ldo/connected-nextgraph": "^1.0.0-alpha.14", + "@ldo/ldo": "^1.0.0-alpha.14", + "@ldo/react": "^1.0.0-alpha.14", "nextgraphweb": "^0.1.1-alpha.4", "react": "^19.0.0", "react-dom": "^19.0.0" }, "devDependencies": { "@eslint/js": "^9.22.0", - "@ldo/cli": "^1.0.0-alpha.11", + "@ldo/cli": "^1.0.0-alpha.14", "@types/jsonld": "^1.5.15", "@types/react": "^19.0.10", "@types/react-dom": "^19.0.4", @@ -1091,14 +1091,14 @@ } }, "node_modules/@ldo/cli": { - "version": "1.0.0-alpha.11", - "resolved": "https://registry.npmjs.org/@ldo/cli/-/cli-1.0.0-alpha.11.tgz", - "integrity": "sha512-k/5dVU9tl2goLPN+wGaTmyxm85rj2P1sunBJSCv6CSqsJsi0kYfxjJrbABVlOmnCig104aHd5diXB5hZH4EoEg==", + "version": "1.0.0-alpha.14", + "resolved": "https://registry.npmjs.org/@ldo/cli/-/cli-1.0.0-alpha.14.tgz", + "integrity": "sha512-audIkRpZTxcz4KVHaX0gSaxOIfmbkLRShfyu8bCyd3mw6zmleXVo8t+GI0ngRfa5KWixjMAkfjkXAvU2TMlOYw==", "dev": true, "license": "MIT", "dependencies": { - "@ldo/ldo": "^1.0.0-alpha.11", - "@ldo/schema-converter-shex": "^1.0.0-alpha.11", + "@ldo/ldo": "^1.0.0-alpha.14", + "@ldo/schema-converter-shex": "^1.0.0-alpha.14", "@shexjs/parser": "^1.0.0-alpha.24", "child-process-promise": "^2.2.1", "commander": "^9.3.0", @@ -1125,26 +1125,26 @@ } }, "node_modules/@ldo/connected": { - "version": "1.0.0-alpha.11", - "resolved": "https://registry.npmjs.org/@ldo/connected/-/connected-1.0.0-alpha.11.tgz", - "integrity": "sha512-C0PxBYpOSrLdCBMrL5CvT/cQ0Zah0IScoYnoX8xdUu5T1JUqXejLYibk7N2G8kQchtodZNimbCR99WGHI4hffA==", + "version": "1.0.0-alpha.14", + "resolved": "https://registry.npmjs.org/@ldo/connected/-/connected-1.0.0-alpha.14.tgz", + "integrity": "sha512-weLoICwLphScRdW9I+2cYxDe1h8G7Axv28yUeFxNC4EVRrJQIIFdqFlAMpwgIkRjFUF69pgTCMTp82P2z1iyow==", "license": "MIT", "dependencies": { - "@ldo/dataset": "^1.0.0-alpha.11", - "@ldo/ldo": "^1.0.0-alpha.11", - "@ldo/rdf-utils": "^1.0.0-alpha.11" + "@ldo/dataset": "^1.0.0-alpha.14", + "@ldo/ldo": "^1.0.0-alpha.14", + "@ldo/rdf-utils": "^1.0.0-alpha.14" } }, "node_modules/@ldo/connected-nextgraph": { - "version": "1.0.0-alpha.11", - "resolved": "https://registry.npmjs.org/@ldo/connected-nextgraph/-/connected-nextgraph-1.0.0-alpha.11.tgz", - "integrity": "sha512-n61mPY/9PYfy+e8+MQmhlxl/e2nyZaVA4arSIjgccRzE+BRWvYH0IKX5lr9Id+tcZE1VG/4GUoK+yK/G1AO5Uw==", + "version": "1.0.0-alpha.14", + "resolved": "https://registry.npmjs.org/@ldo/connected-nextgraph/-/connected-nextgraph-1.0.0-alpha.14.tgz", + "integrity": "sha512-l8CcByqTI75HnYQW9OENtOlO5Q4IVCasFXYi8mfpEXDOnZFIIuc3al4AzcpYHOe46V0RlCSGXpBszrZg9PkHlg==", "license": "MIT", "dependencies": { - "@ldo/connected": "^1.0.0-alpha.11", - "@ldo/dataset": "^1.0.0-alpha.11", - "@ldo/ldo": "^1.0.0-alpha.11", - "@ldo/rdf-utils": "^1.0.0-alpha.11", + "@ldo/connected": "^1.0.0-alpha.14", + "@ldo/dataset": "^1.0.0-alpha.14", + "@ldo/ldo": "^1.0.0-alpha.14", + "@ldo/rdf-utils": "^1.0.0-alpha.14", "@solid-notifications/subscription": "^0.1.2", "cross-fetch": "^3.1.6", "http-link-header": "^1.1.1", @@ -1152,48 +1152,48 @@ } }, "node_modules/@ldo/dataset": { - "version": "1.0.0-alpha.11", - "resolved": "https://registry.npmjs.org/@ldo/dataset/-/dataset-1.0.0-alpha.11.tgz", - "integrity": "sha512-rgJs/YfRqLJKzR3/a5arfUimt+mU3eGNwnObSAsWoChkBtLWqAMtALADDRnhf8mjzVdCfEp0+X0UyyPrrte/4g==", + "version": "1.0.0-alpha.14", + "resolved": "https://registry.npmjs.org/@ldo/dataset/-/dataset-1.0.0-alpha.14.tgz", + "integrity": "sha512-YF3Mo4zj9ArSBd4K5E8qxmMToe7UfD1WOp5tyVU2684LU7v1eySV5A4LcP1BImi/YIpUtFxmz0DqypEA57PTHQ==", "license": "MIT", "dependencies": { - "@ldo/rdf-utils": "^1.0.0-alpha.11", + "@ldo/rdf-utils": "^1.0.0-alpha.14", "@rdfjs/dataset": "^1.1.0", "buffer": "^6.0.3", "readable-stream": "^4.2.0" } }, "node_modules/@ldo/jsonld-dataset-proxy": { - "version": "1.0.0-alpha.11", - "resolved": "https://registry.npmjs.org/@ldo/jsonld-dataset-proxy/-/jsonld-dataset-proxy-1.0.0-alpha.11.tgz", - "integrity": "sha512-ZmB65u3sdj2gwkFv5hkJLQU0X+fDQfj0NLFR/HokGxRyaPqZHLHwLfZCenRabGq9UtnZ6V2ajVR2XWflEv/MOQ==", + "version": "1.0.0-alpha.14", + "resolved": "https://registry.npmjs.org/@ldo/jsonld-dataset-proxy/-/jsonld-dataset-proxy-1.0.0-alpha.14.tgz", + "integrity": "sha512-f3lKmBevIynM2eMHijYgbI1c3kR+2Qemdn+8Ac8zC5aeg751Y6/NkMB2Gvy5dEgHusLbVFKKjW6U1aeVmNRvyg==", "license": "MIT", "dependencies": { - "@ldo/rdf-utils": "^1.0.0-alpha.11", - "@ldo/subscribable-dataset": "^1.0.0-alpha.11", + "@ldo/rdf-utils": "^1.0.0-alpha.14", + "@ldo/subscribable-dataset": "^1.0.0-alpha.14", "@rdfjs/data-model": "^1.2.0", "@rdfjs/dataset": "^1.1.0", "jsonld2graphobject": "^0.0.4" } }, "node_modules/@ldo/ldo": { - "version": "1.0.0-alpha.11", - "resolved": "https://registry.npmjs.org/@ldo/ldo/-/ldo-1.0.0-alpha.11.tgz", - "integrity": "sha512-3H4CSvORnjQojeDOeqqR31HwZKKAd9pF+jcXeFSOMFeTBAmv0T1qqtsDH04kzBqJivsDPNHqCdCZ1I8Y/B/LnQ==", + "version": "1.0.0-alpha.14", + "resolved": "https://registry.npmjs.org/@ldo/ldo/-/ldo-1.0.0-alpha.14.tgz", + "integrity": "sha512-EB2TG4TwywQrdVsYnz1mQM+ucoRgoVbwJguxDW5JibfOoqTe3QFeglN56wTL6Kk1T+DTmFv83zYUPVpRK8rclw==", "license": "MIT", "dependencies": { - "@ldo/dataset": "^1.0.0-alpha.11", - "@ldo/jsonld-dataset-proxy": "^1.0.0-alpha.11", - "@ldo/subscribable-dataset": "^1.0.0-alpha.11", + "@ldo/dataset": "^1.0.0-alpha.14", + "@ldo/jsonld-dataset-proxy": "^1.0.0-alpha.14", + "@ldo/subscribable-dataset": "^1.0.0-alpha.14", "@rdfjs/data-model": "^1.2.0", "buffer": "^6.0.3", "readable-stream": "^4.3.0" } }, "node_modules/@ldo/rdf-utils": { - "version": "1.0.0-alpha.11", - "resolved": "https://registry.npmjs.org/@ldo/rdf-utils/-/rdf-utils-1.0.0-alpha.11.tgz", - "integrity": "sha512-OJZoiAU3CIuFfq4YShP1PoAWyaz2HWHeae1PoZ7p7ABnu7WIbOV+qORieiVSciWx8n4xee3mm2svWmNdTE3nkQ==", + "version": "1.0.0-alpha.14", + "resolved": "https://registry.npmjs.org/@ldo/rdf-utils/-/rdf-utils-1.0.0-alpha.14.tgz", + "integrity": "sha512-WBOpn8H5n9CQ6i+vt5jNOZwS7kxituOlt1YHbf404OgbWA87H2QeEO7CBuyiwExnIC7XT8MJ3Dr+m4G+PyIxfA==", "license": "MIT", "dependencies": { "@rdfjs/data-model": "^1.2.0", @@ -1202,28 +1202,28 @@ } }, "node_modules/@ldo/react": { - "version": "1.0.0-alpha.11", - "resolved": "https://registry.npmjs.org/@ldo/react/-/react-1.0.0-alpha.11.tgz", - "integrity": "sha512-5yeO6t3bhjIT+Lfe/ioY4MsF3CdaiZT+B/akJ6TXzJOslwJTbEZ7caloN7IAkFQX8TCCY3FzIBWvSE5+lS5AZA==", + "version": "1.0.0-alpha.14", + "resolved": "https://registry.npmjs.org/@ldo/react/-/react-1.0.0-alpha.14.tgz", + "integrity": "sha512-C6j04Pn65b2kZ/gBmO/5ND4ayEF7l/AAb7ArpPgWoQMu0QEUCb+0gMNGf7O6+QxWvIteezJCwPX8ELBDmvRb/g==", "license": "MIT", "dependencies": { - "@ldo/connected": "^1.0.0-alpha.11", - "@ldo/jsonld-dataset-proxy": "^1.0.0-alpha.11", - "@ldo/ldo": "^1.0.0-alpha.11", - "@ldo/rdf-utils": "^1.0.0-alpha.11", - "@ldo/subscribable-dataset": "^1.0.0-alpha.11", + "@ldo/connected": "^1.0.0-alpha.14", + "@ldo/jsonld-dataset-proxy": "^1.0.0-alpha.14", + "@ldo/ldo": "^1.0.0-alpha.14", + "@ldo/rdf-utils": "^1.0.0-alpha.14", + "@ldo/subscribable-dataset": "^1.0.0-alpha.14", "@rdfjs/data-model": "^1.2.0", "cross-fetch": "^3.1.6" } }, "node_modules/@ldo/schema-converter-shex": { - "version": "1.0.0-alpha.11", - "resolved": "https://registry.npmjs.org/@ldo/schema-converter-shex/-/schema-converter-shex-1.0.0-alpha.11.tgz", - "integrity": "sha512-ebBBrTCf5inZpv/UmCYrMLlDeRnCcSn06bixyFPhBF8NvG4ZOL8hc7WVnQenumeP13RFsJNlQmiHC2JIKm6k8w==", + "version": "1.0.0-alpha.14", + "resolved": "https://registry.npmjs.org/@ldo/schema-converter-shex/-/schema-converter-shex-1.0.0-alpha.14.tgz", + "integrity": "sha512-UKoSkI1jrP67HX5qgdJwH34YE32o/c3svyQ8UniZ8CU5YJOHOGx91Or4S3x4nXkVGjLtAmcYGskBn16P0Z8MxA==", "dev": true, "license": "MIT", "dependencies": { - "@ldo/traverser-shexj": "^1.0.0-alpha.11", + "@ldo/traverser-shexj": "^1.0.0-alpha.14", "dts-dom": "~3.6.0", "jsonld2graphobject": "^0.0.5" } @@ -1251,50 +1251,57 @@ "uuid": "^8.3.2" } }, - "node_modules/@ldo/subscribable-dataset": { - "version": "1.0.0-alpha.11", - "resolved": "https://registry.npmjs.org/@ldo/subscribable-dataset/-/subscribable-dataset-1.0.0-alpha.11.tgz", - "integrity": "sha512-cnV2aTSkCIHaji89IxaKJ3c8BJj8NB/1nroLD2r+yVMFqFOnvxL1EaSkHy5DJOY64n6aUj/YAo0wg7VxKIrQjg==", + "node_modules/@ldo/schema-converter-shex/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, "license": "MIT", - "dependencies": { - "@ldo/dataset": "^1.0.0-alpha.11", - "@ldo/rdf-utils": "^1.0.0-alpha.11", - "uuid": "^11.1.0" + "bin": { + "uuid": "dist/bin/uuid" } }, - "node_modules/@ldo/subscribable-dataset/node_modules/uuid": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz", - "integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==", - "funding": [ - "https://github.com/sponsors/broofa", - "https://github.com/sponsors/ctavan" - ], + "node_modules/@ldo/subscribable-dataset": { + "version": "1.0.0-alpha.14", + "resolved": "https://registry.npmjs.org/@ldo/subscribable-dataset/-/subscribable-dataset-1.0.0-alpha.14.tgz", + "integrity": "sha512-EqXAfz/9giUjNNukJ2+Q3p8UC/OXrIA2YdRd80Bhs82BFpNn3mTIAuy43kreZ0CM1dOMiPDSxCH8WWsviETekg==", "license": "MIT", - "bin": { - "uuid": "dist/esm/bin/uuid" + "dependencies": { + "@ldo/dataset": "^1.0.0-alpha.14", + "@ldo/rdf-utils": "^1.0.0-alpha.14", + "uuid": "^11.1.0" } }, "node_modules/@ldo/traverser-shexj": { - "version": "1.0.0-alpha.11", - "resolved": "https://registry.npmjs.org/@ldo/traverser-shexj/-/traverser-shexj-1.0.0-alpha.11.tgz", - "integrity": "sha512-b+q6xFewYy9lBglKabJmNflddqhFRIMRdsJJZSF3gL7gFfor8udvfRTKvWSu0aEt3uC+/wT+T0vKIxKTEkmYBA==", + "version": "1.0.0-alpha.14", + "resolved": "https://registry.npmjs.org/@ldo/traverser-shexj/-/traverser-shexj-1.0.0-alpha.14.tgz", + "integrity": "sha512-2Y/1LFbyRMJnBDWlDh7jrhh41sVGYNy9q1rkXXQ0OeWBjUEgCeSZhtYayOr1oqtVsL6mDxUmMgVAK3MOnO1Ldw==", "dev": true, "license": "MIT", "dependencies": { - "@ldo/type-traverser": "^1.0.0-alpha.11" + "@ldo/type-traverser": "^1.0.0-alpha.14" } }, "node_modules/@ldo/type-traverser": { - "version": "1.0.0-alpha.11", - "resolved": "https://registry.npmjs.org/@ldo/type-traverser/-/type-traverser-1.0.0-alpha.11.tgz", - "integrity": "sha512-hfn3u47LZzBeboAM6ai3oKD4aoiIYowbELr+y+YGKF1yD1AU9mbxi/xscvt4E/XJkUX993HFfvjZ1BVfZFCN0Q==", + "version": "1.0.0-alpha.14", + "resolved": "https://registry.npmjs.org/@ldo/type-traverser/-/type-traverser-1.0.0-alpha.14.tgz", + "integrity": "sha512-rwpGynZm+pcnOPLV7o7FEhh25gNDQKpwrlHC51/UrrHjK7zIvIs4K6+OkVmsuwsJxcicIdUEmNZv7TJQvy3FMw==", "dev": true, "license": "MIT", "dependencies": { "uuid": "^8.3.2" } }, + "node_modules/@ldo/type-traverser/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -4151,6 +4158,15 @@ "@types/node": "*" } }, + "node_modules/jsonld2graphobject/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", @@ -5864,12 +5880,16 @@ "license": "MIT" }, "node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz", + "integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], "license": "MIT", "bin": { - "uuid": "dist/bin/uuid" + "uuid": "dist/esm/bin/uuid" } }, "node_modules/vite": { diff --git a/ng-sdk-js/example-webapp-react-socialquery/package.json b/ng-sdk-js/example-webapp-react-socialquery/package.json index f0604dc..f2f0728 100644 --- a/ng-sdk-js/example-webapp-react-socialquery/package.json +++ b/ng-sdk-js/example-webapp-react-socialquery/package.json @@ -8,20 +8,20 @@ "build": "tsc --noEmit && vite build", "lint": "eslint .", "preview": "vite preview", - "build:ldo": "../../../ldo/packages/cli/dist/index.js build --input src/.shapes --output src/.ldo" + "build:ldo": "ldo build --input src/.shapes --output src/.ldo" }, "dependencies": { "@heroicons/react": "^2.2.0", - "@ldo/connected-nextgraph": "^1.0.0-alpha.11", - "@ldo/ldo": "^1.0.0-alpha.11", - "@ldo/react": "^1.0.0-alpha.11", + "@ldo/connected-nextgraph": "^1.0.0-alpha.14", + "@ldo/ldo": "^1.0.0-alpha.14", + "@ldo/react": "^1.0.0-alpha.14", "nextgraphweb": "^0.1.1-alpha.4", "react": "^19.0.0", "react-dom": "^19.0.0" }, "devDependencies": { "@eslint/js": "^9.22.0", - "@ldo/cli": "^1.0.0-alpha.11", + "@ldo/cli": "^1.0.0-alpha.14", "@types/jsonld": "^1.5.15", "@types/react": "^19.0.10", "@types/react-dom": "^19.0.4", diff --git a/ng-sdk-js/example-webapp-react-socialquery/src/Contact.tsx b/ng-sdk-js/example-webapp-react-socialquery/src/Contact.tsx index dda0478..6a8eb86 100644 --- a/ng-sdk-js/example-webapp-react-socialquery/src/Contact.tsx +++ b/ng-sdk-js/example-webapp-react-socialquery/src/Contact.tsx @@ -1,13 +1,13 @@ import { default as React, FunctionComponent } from "react"; import { useNextGraphAuth } from "./reactMethods"; import { SocialContactShapeType } from "./.ldo/contact.shapeTypes.ts"; -import { useSubscribeToResource, useResource, useSubject } from "./reactMethods.ts"; +import { useSubscribeToResource, useResource, useSubject, useLdo } from "./reactMethods.ts"; import { StarIcon } from '@heroicons/react/24/solid' import { StarIcon as StarIconOutline, NoSymbolIcon } from '@heroicons/react/24/outline' export const Contact: FunctionComponent = ({nuri}) => { const { session } = useNextGraphAuth(); - + const { createData, commitData, changeData } = useLdo(); useResource(session.sessionId && nuri ? nuri : undefined, { subscribe: true }); let contact = useSubject(SocialContactShapeType, session.sessionId && nuri ? nuri.substring(0,53) : undefined); @@ -37,47 +37,88 @@ export const Contact: FunctionComponent = ({nuri}) => { "Automerge", ] - const [skills, setSkills] = React.useState([ - 0, - 0, - 5, - 3, - 1, - 2, - 4, - 0, - 0, - ]) + const [skills, setSkills] = React.useState([ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]); React.useEffect(() => { - console.log(contact.hasRating?.entries()) + //contact.hasRating?.map((r)=> {if (r.skill) console.log(r.rated,r.skill["@id"].substring(24))}); let nextSkills = skills.map((s) => { return 0; }); contact.hasRating?.map((r) => { - nextSkills[ksp_mapping.indexOf(r.skill["@id"].substring(28))] = r.rated +1; + nextSkills[ksp_mapping.indexOf(r.skill["@id"].substring(24))] = r.rated +1; }); setSkills(nextSkills); }, [contact]) if (!session.sessionId || !nuri) return <>; - function rate(skill: number, rating: number) { - console.log("rate", skill, rating); - - const nextSkills = skills.map((s, i) => { - if (i === skill) { - if (s == rating) { - s = s - 1; - } else { - s = rating; - } - return s; - } else { - return s; + async function rate(skill: number, rating: number) { + const nextSkills = [...skills]; + const old = skills[skill]; + + if (old == 0) { + if (rating == 0) return;//should happen + // we create a new rating + nextSkills[skill] = rating; + try { + await session.ng.sparql_update(session.sessionId, `PREFIX xskills: + PREFIX ksp: + PREFIX xsd: + INSERT { + <> xskills:hasRating [ + a xskills:Rating ; + xskills:rated "${rating-1}"^^xsd:integer ; + xskills:skill ksp:${ksp_mapping[skill]} + ]. + } WHERE {}`, nuri); + } catch (e) { + console.error(e) + } + } else { + if (old == rating) { + nextSkills[skill] = rating - 1; + } else { + nextSkills[skill] = rating; + } + if (nextSkills[skill] == 0) { + // we remove the rating + try { const s = `PREFIX xskills: + PREFIX ksp: + PREFIX xsd: + DELETE { + <> xskills:hasRating ?rating. + ?rating a xskills:Rating . + ?rating xskills:skill ksp:${ksp_mapping[skill]} . + ?rating xskills:rated "${old-1}"^^xsd:integer. + } WHERE { <> xskills:hasRating ?rating . + ?rating a xskills:Rating . + ?rating xskills:skill ksp:${ksp_mapping[skill]} + }`; + await session.ng.sparql_update(session.sessionId, s, nuri); + } catch (e) { + console.error(e) } - }); - setSkills(nextSkills); + } else { + // we update the rating + try { + await session.ng.sparql_update(session.sessionId, `PREFIX xskills: + PREFIX ksp: + PREFIX xsd: + DELETE { + ?rating xskills:rated "${old-1}"^^xsd:integer. + } INSERT { + ?rating xskills:rated "${nextSkills[skill]-1}"^^xsd:integer. + } + WHERE { <> xskills:hasRating ?rating . + ?rating a xskills:Rating . + ?rating xskills:skill ksp:${ksp_mapping[skill]} + }`, nuri); + } catch (e) { + console.error(e) + } + } + } + setSkills(nextSkills); } return <> @@ -89,14 +130,12 @@ export const Contact: FunctionComponent = ({nuri}) => {
{contact.hasEmail} - {JSON.stringify(contact.hasRating?.entries())}
{ skills.map( (skill,s) =>
- {/* */} { [...Array(5)].map( (e,i) => { diff --git a/ng-sdk-js/example-webapp-react/package.json b/ng-sdk-js/example-webapp-react/package.json index 49024b9..ed663e8 100644 --- a/ng-sdk-js/example-webapp-react/package.json +++ b/ng-sdk-js/example-webapp-react/package.json @@ -11,16 +11,16 @@ "build:ldo": "ldo build --input src/.shapes --output src/.ldo" }, "dependencies": { - "@ldo/connected-nextgraph": "^1.0.0-alpha.11", - "@ldo/ldo": "^1.0.0-alpha.11", - "@ldo/react": "^1.0.0-alpha.11", + "@ldo/connected-nextgraph": "^1.0.0-alpha.14", + "@ldo/ldo": "^1.0.0-alpha.14", + "@ldo/react": "^1.0.0-alpha.14", "nextgraphweb": "^0.1.1-alpha.4", "react": "^19.0.0", "react-dom": "^19.0.0" }, "devDependencies": { "@eslint/js": "^9.22.0", - "@ldo/cli": "^1.0.0-alpha.11", + "@ldo/cli": "^1.0.0-alpha.14", "@types/jsonld": "^1.5.15", "@types/react": "^19.0.10", "@types/react-dom": "^19.0.4",