From 09a0e83a2137c3672b9ca3c181fe9c77575a04ce Mon Sep 17 00:00:00 2001 From: Niko PLP <niko@nextgraph.org> Date: Wed, 14 Aug 2024 15:50:08 +0300 Subject: [PATCH] fix sparql update on tauri. had wrong base --- CHANGELOG.md | 12 ++++++++ RELEASE-NOTE.md | 0 ng-app/src-tauri/src/lib.rs | 18 +++++++++--- ng-app/src/apps/ContainerView.svelte | 5 ++-- ng-app/src/locales/en.json | 4 +-- ng-app/src/routes/WalletInfo.svelte | 41 ++++++++++++++-------------- ng-verifier/src/request_processor.rs | 2 +- 7 files changed, 53 insertions(+), 29 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 RELEASE-NOTE.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..471db74 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.1.0-preview.7] + +### Added + +- diff --git a/RELEASE-NOTE.md b/RELEASE-NOTE.md new file mode 100644 index 0000000..e69de29 diff --git a/ng-app/src-tauri/src/lib.rs b/ng-app/src-tauri/src/lib.rs index a269452..3d0db86 100644 --- a/ng-app/src-tauri/src/lib.rs +++ b/ng-app/src-tauri/src/lib.rs @@ -552,13 +552,23 @@ async fn branch_history(session_id: u64, nuri: String) -> Result<AppHistoryJs, S } #[tauri::command(rename_all = "snake_case")] -async fn sparql_update(session_id: u64, sparql: String, nuri: String) -> Result<(), String> { - let nuriv0 = NuriV0::new_from(&nuri).map_err(|e| e.to_string())?; +async fn sparql_update( + session_id: u64, + sparql: String, + nuri: Option<String>, +) -> Result<(), String> { + let (nuri, base) = if let Some(n) = nuri { + let nuri = NuriV0::new_from(&n).map_err(|e| e.to_string())?; + let b = nuri.repo(); + (nuri, Some(b)) + } else { + (NuriV0::new_private_store_target(), None) + }; let request = AppRequest::V0(AppRequestV0 { command: AppRequestCommandV0::new_write_query(), - nuri: nuriv0, - payload: Some(AppRequestPayload::new_sparql_query(sparql, Some(nuri))), + nuri, + payload: Some(AppRequestPayload::new_sparql_query(sparql, base)), session_id, }); diff --git a/ng-app/src/apps/ContainerView.svelte b/ng-app/src/apps/ContainerView.svelte index f244318..d006393 100644 --- a/ng-app/src/apps/ContainerView.svelte +++ b/ng-app/src/apps/ContainerView.svelte @@ -18,7 +18,7 @@ import{ PencilSquare } from "svelte-heros-v2"; import { t } from "svelte-i18n"; import { - in_memory_discrete, open_viewer, set_viewer, set_editor, set_view_or_edit, cur_tab_branch_class, cur_tab_doc_can_edit + in_memory_discrete, open_viewer, set_viewer, set_editor, set_view_or_edit, cur_tab_branch_class, cur_tab_doc_can_edit, cur_tab } from "../tab"; import { openModalCreate @@ -29,7 +29,8 @@ let ret = []; for (const g of graph) { if (g.substring(57,90) === "http://www.w3.org/ns/ldp#contains") { - let nuri = g.substring(93,193); + let nuri = g.substring(93,146); + nuri = nuri + ":" + $cur_tab.store.overlay; let hash = nuri.substring(9,16); ret.push({nuri,hash}); } diff --git a/ng-app/src/locales/en.json b/ng-app/src/locales/en.json index a5f4b76..37c0d96 100644 --- a/ng-app/src/locales/en.json +++ b/ng-app/src/locales/en.json @@ -260,7 +260,6 @@ }, "wallet_info": { "title": "Wallet", - "scan_qr": "Scan QR to export", "download": "Download Wallet File", "download_failed": "Download Failed:<br/>{error}", "download_in_progress": "Download in progress...", @@ -502,7 +501,7 @@ "gen.button": "Generate QR-Code", "gen.description": "To import your wallet from another device, you have to generate a QR-Code here on this device, and then scan it with your other device (the one where your wallet is located for now).<br/>If your other device does not have a camera, then you have to use another method for importing your wallet here.", "offline_advice": "If you do not have internet on this device, you can use the \"Import a Wallet file\" method instead.", - "gen.letsgo": "Ready? On your other device, you first have to be logged-in (wallet is opened) and then you go to<br /><span class=\"path\">User Panel > Wallet > Scan QR to export</span>.<br />Then on this present device, click below on the<br/><span class=\"path\">Generate QR-Code</span> button.", + "gen.letsgo": "Ready? On your other device, you first have to be logged-in (wallet is opened) and then you go to<br /><span class=\"path\">User Panel > Wallet > Export by scanning a QR-code</span>.<br />Then on this present device, click below on the<br/><span class=\"path\">Generate QR-Code</span> button.", "gen.generated": "Scan this QR-Code from the other device.<br/>You have 5 minutes to do so.", "success_btn": "Continue to Login" }, @@ -601,6 +600,7 @@ "NotARendezVous": "You scanned an invalid QR-Code.", "camera_unavailable": "Camera is unavailable.", "ServerAlreadyRunningInOtherProcess": "App is already running on this device. Check it and close it.", + "WsError": "WebSocket error", "cannot_load_this_file": "Cannot load this file", "graph_not_found": "Graph not found", "no_wasm_on_old_safari": "Your Safari browser is too old (version before 14.1). As a result we cannot load Automerge, needed for this document. Please upgrade your macOS or iOS system" diff --git a/ng-app/src/routes/WalletInfo.svelte b/ng-app/src/routes/WalletInfo.svelte index 65e2965..885e9e9 100644 --- a/ng-app/src/routes/WalletInfo.svelte +++ b/ng-app/src/routes/WalletInfo.svelte @@ -172,7 +172,7 @@ }; async function remove_wallet_confirmed() { - if (!active_wallet) return; + if (!$active_wallet) return; // TODO: Wait for implementation // await ng.wallet_remove($active_wallet.id); close_active_wallet(); @@ -198,6 +198,7 @@ <SidebarGroup ulClass="space-y-2" class="text-left" role="menu"> <li> <h2 class="text-xl mb-6">{$t("pages.wallet_info.title")}</h2> + <span class="break-all">ID: {$active_wallet?.id}</span> </li> <!-- Go Back --> @@ -250,6 +251,25 @@ <span class="ml-3">{$t("pages.wallet_info.gen_qr.title")}</span> </li> + <!-- Copy Wallet TextCode --> + <li + tabindex="0" + role="menuitem" + class="text-left flex items-center p-2 text-base font-normal text-gray-900 clickable rounded-lg dark:text-white hover:bg-gray-200 dark:hover:bg-gray-700" + on:keypress={open_textcode_menu} + on:click={open_textcode_menu} + > + <div> + <Link + tabindex="-1" + class="w-7 h-7 text-black transition duration-75 dark:text-white group-hover:text-gray-900 dark:group-hover:text-white" + /> + </div> + <span class="ml-3" + >{$t("pages.wallet_info.create_text_code")}</span + > + </li> + <!-- Download Wallet --> {#if !downloading} <li @@ -336,25 +356,6 @@ </li> {/if} - <!-- Copy Wallet TextCode --> - <li - tabindex="0" - role="menuitem" - class="text-left flex items-center p-2 text-base font-normal text-gray-900 clickable rounded-lg dark:text-white hover:bg-gray-200 dark:hover:bg-gray-700" - on:keypress={open_textcode_menu} - on:click={open_textcode_menu} - > - <div> - <Link - tabindex="-1" - class="w-7 h-7 text-black transition duration-75 dark:text-white group-hover:text-gray-900 dark:group-hover:text-white" - /> - </div> - <span class="ml-3" - >{$t("pages.wallet_info.create_text_code")}</span - > - </li> - <!-- Remove Wallet --> <li tabindex="0" diff --git a/ng-verifier/src/request_processor.rs b/ng-verifier/src/request_processor.rs index 226db1e..463bfa9 100644 --- a/ng-verifier/src/request_processor.rs +++ b/ng-verifier/src/request_processor.rs @@ -267,7 +267,7 @@ impl Verifier { // adding an ldp:contains triple to the store main branch let overlay_id = doc_create.store.outer_overlay(); - let nuri = NuriV0::repo_graph_name(&repo_id, &overlay_id); + let nuri = NuriV0::repo_id(&repo_id); let store_nuri = NuriV0::from_store_repo(&doc_create.store); let store_nuri_string = NuriV0::repo_id(doc_create.store.repo_id()); let query = format!("INSERT DATA {{ <{store_nuri_string}> <http://www.w3.org/ns/ldp#contains> <{nuri}>. }}");