diff --git a/ng-app/package.json b/ng-app/package.json index eab6288..e0fcff2 100644 --- a/ng-app/package.json +++ b/ng-app/package.json @@ -23,7 +23,7 @@ "@codemirror/lint": "^6.8.1", "@codemirror/search": "^6.5.6", "@codemirror/state": "^6.4.1", - "@codemirror/view": "^6.28.6", + "@codemirror/view": "^6.29.1", "@popperjs/core": "^2.11.8", "@tauri-apps/api": "2.0.0-alpha.8", "@tauri-apps/plugin-barcode-scanner": "2.0.0-alpha.0", diff --git a/ng-app/src-tauri/src/lib.rs b/ng-app/src-tauri/src/lib.rs index 0c34dcc..50472df 100644 --- a/ng-app/src-tauri/src/lib.rs +++ b/ng-app/src-tauri/src/lib.rs @@ -402,9 +402,30 @@ async fn doc_fetch_repo_subscribe(repo_o: String) -> Result Ok(request) } +#[tauri::command(rename_all = "snake_case")] +async fn branch_history(session_id: u64, nuri: String) -> Result { + let request = AppRequest::V0(AppRequestV0 { + command: AppRequestCommandV0::new_history(), + nuri: NuriV0::new_from(&nuri).map_err(|e| e.to_string())?, + payload: None, + session_id, + }); + + let res = nextgraph::local_broker::app_request(request) + .await + .map_err(|e: NgError| e.to_string())?; + + let AppResponse::V0(res) = res; + //log_debug!("{:?}", res); + match res { + AppResponseV0::History(s) => Ok(s.to_js()), + _ => Err("invalid response".to_string()), + } +} + #[tauri::command(rename_all = "snake_case")] async fn sparql_update(session_id: u64, sparql: String, nuri: String) -> Result<(), String> { - let nuri = NuriV0::new_from(&nuri).map_err(|_| "Deserialization error of Nuri".to_string())?; + let nuri = NuriV0::new_from(&nuri).map_err(|e| e.to_string())?; let request = AppRequest::V0(AppRequestV0 { command: AppRequestCommandV0::new_write_query(), @@ -430,7 +451,7 @@ async fn sparql_query( nuri: Option, ) -> Result { let nuri = if nuri.is_some() { - NuriV0::new_from(&nuri.unwrap()).map_err(|_| "Deserialization error of Nuri".to_string())? + NuriV0::new_from(&nuri.unwrap()).map_err(|e| e.to_string())? } else { NuriV0::new_entire_user_site() }; @@ -709,6 +730,7 @@ impl AppBuilder { get_device_name, sparql_query, sparql_update, + branch_history, ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); diff --git a/ng-app/src/api.ts b/ng-app/src/api.ts index 4178292..cd7b595 100644 --- a/ng-app/src/api.ts +++ b/ng-app/src/api.ts @@ -45,6 +45,7 @@ const mapping = { "get_device_name": [], "doc_fetch_private_subscribe": [], "doc_fetch_repo_subscribe": ["repo_o"], + "branch_history": ["session_id", "nuri"], } @@ -189,7 +190,7 @@ const handler = { await tauri.invoke("app_request_stream",{stream_id, request}); } catch (e) { unlisten(); - tauri.invoke("cancel_stream", {stream_id}); + await tauri.invoke("cancel_stream", {stream_id}); throw e; } return () => { @@ -245,13 +246,13 @@ const handler = { arg.wallet = {V0:{id:arg.wallet.V0.id, sig:arg.wallet.V0.sig, content:{}}}; Object.assign(arg.wallet.V0.content,old_content); arg.wallet.V0.content.security_img = img; - return tauri.invoke(path[0],arg); + return await tauri.invoke(path[0],arg); } else { let arg = {}; args.map((el,ix) => arg[mapping[path[0]][ix]]=el) return await tauri.invoke(path[0],arg) } - }catch (e) { + } catch (e) { let error; try { error = JSON.parse(e); diff --git a/ng-app/src/apps/SparqlQueryEditor.svelte b/ng-app/src/apps/SparqlQueryEditor.svelte index f0e5440..b93d870 100644 --- a/ng-app/src/apps/SparqlQueryEditor.svelte +++ b/ng-app/src/apps/SparqlQueryEditor.svelte @@ -18,7 +18,7 @@ reset_toasts } from "../store"; import { - in_memory_discrete, open_viewer, set_viewer + in_memory_discrete, open_viewer, set_viewer, reset_in_memory } from "../tab"; import{ Sun, RocketLaunch } from "svelte-heros-v2"; import { t } from "svelte-i18n"; @@ -43,9 +43,10 @@ }; onMount(()=>{ - if (!$in_memory_discrete){ - $in_memory_discrete = "SELECT ?subject ?predicate ?object WHERE {\n ?subject ?predicate ?object .\n} LIMIT 10"; - } + reset_in_memory(); + if (!$in_memory_discrete){ + $in_memory_discrete = "SELECT ?subject ?predicate ?object WHERE {\n ?subject ?predicate ?object .\n} LIMIT 10"; + } }); let union = false; const run = async () => { diff --git a/ng-app/src/apps/SparqlUpdateEditor.svelte b/ng-app/src/apps/SparqlUpdateEditor.svelte index b062982..9954f36 100644 --- a/ng-app/src/apps/SparqlUpdateEditor.svelte +++ b/ng-app/src/apps/SparqlUpdateEditor.svelte @@ -18,7 +18,7 @@ reset_toasts, } from "../store"; import { - in_memory_discrete, open_viewer + in_memory_discrete, open_viewer, reset_in_memory } from "../tab"; import{ Sun, RocketLaunch } from "svelte-heros-v2"; import { t } from "svelte-i18n"; @@ -30,6 +30,7 @@ import { sparql } from "@codemirror/legacy-modes/mode/sparql"; import {basicSetup} from "codemirror" onMount(()=>{ + reset_in_memory(); if (!$in_memory_discrete){ $in_memory_discrete = "INSERT DATA { \n \"An example value\".\r}"; } diff --git a/ng-app/src/lib/FullLayout.svelte b/ng-app/src/lib/FullLayout.svelte index 73c3dc7..0fedf96 100644 --- a/ng-app/src/lib/FullLayout.svelte +++ b/ng-app/src/lib/FullLayout.svelte @@ -251,7 +251,10 @@ }); active_session.subscribe((as) => { if(!as) { - $redirect_after_login = $location; + console.log($location); + if ($location!="/user") { + $redirect_after_login = $location; + } push("#/"); } }) diff --git a/ng-app/src/lib/Login.svelte b/ng-app/src/lib/Login.svelte index 97fa3d5..dcbb460 100644 --- a/ng-app/src/lib/Login.svelte +++ b/ng-app/src/lib/Login.svelte @@ -452,7 +452,7 @@ on:keypress={start_with_mnemonic} role="link" tabindex="0" - class="mt-1 text-lg px-5 py-2.5 text-center inline-flex items-center mb-10 underline cursor-pointer" + class="mt-1 text-lg px-5 py-2.5 text-center inline-flex items-center underline cursor-pointer" > {$t("pages.login.open_with_mnemonic")} diff --git a/ng-app/src/lib/panes/History.svelte b/ng-app/src/lib/panes/History.svelte index b15e24f..8cb0903 100644 --- a/ng-app/src/lib/panes/History.svelte +++ b/ng-app/src/lib/panes/History.svelte @@ -50,53 +50,56 @@ let unsub = () => {}; onMount(async ()=>{ - const graphContainer = document.getElementById("graph-container"); - gitgraph = createGitgraph(graphContainer, { - template: templateExtend(TemplateName.Metro, { - branch: { label: { display: false } }, - commit: { message: { displayAuthor: false, displayHash: false } }, - }), - }); - let res = await ng.branch_history($active_session.session_id, "did:ng:"+$cur_tab.branch.nuri); - // for (const h of res.history) { - // console.log(h[0], h[1]); - // } - //console.log(res.swimlane_state); - history = [...res.history].reverse(); + setTimeout(async()=> { + const graphContainer = document.getElementById("graph-container"); + gitgraph = createGitgraph(graphContainer, { + template: templateExtend(TemplateName.Metro, { + branch: { label: { display: false } }, + commit: { message: { displayAuthor: false, displayHash: false } }, + }), + }); + let res = await ng.branch_history($active_session.session_id, "did:ng:"+$cur_tab.branch.nuri); + // for (const h of res.history) { + // console.log(h[0], h[1]); + // } + //console.log(res.swimlane_state); + history = [...res.history].reverse(); - gitgraph.swimlanes(res.swimlane_state.map((s)=> s || false)); - gitgraph.import(res.history.map((h)=>{return { - hash:h[0], - branch:h[1].branch, - author:h[1].author, - parents:h[1].past, - x:h[1].x, - y:h[1].y, - subject:h[1].timestamp, - onClick:()=>openCommit(h[0]), - onMessageClick:()=>openCommit(h[0]) - };})); + gitgraph.swimlanes(res.swimlane_state.map((s)=> s || false)); + gitgraph.import(res.history.map((h)=>{return { + hash:h[0], + branch:h[1].branch, + author:h[1].author, + parents:h[1].past, + x:h[1].x, + y:h[1].y, + subject:h[1].timestamp, + onClick:()=>openCommit(h[0]), + onMessageClick:()=>openCommit(h[0]) + };})); - let branch = branch_subscribe($cur_tab.branch.nuri,false); - unsub = branch.subscribe((b) => { - //console.log("subscription callbak",b.history.commits); - if (Array.isArray(b.history.commits)) { - for (var h; h = b.history.commits.pop(); ) { - //console.log(h); - history.unshift(h); - history = history; - gitgraph.commit({ - hash: h[0], - author:h[1].author, - parents:h[1].past, - subject:h[1].timestamp, - onClick:()=>openCommit(h[0]), - onMessageClick:()=>openCommit(h[0]) - }); + let branch = branch_subscribe($cur_tab.branch.nuri,false); + unsub(); + unsub = branch.subscribe((b) => { + //console.log("subscription callbak",b.history.commits); + if (Array.isArray(b.history.commits)) { + for (var h; h = b.history.commits.pop(); ) { + //console.log(h); + history.unshift(h); + history = history; + gitgraph.commit({ + hash: h[0], + author:h[1].author, + parents:h[1].past, + subject:h[1].timestamp, + onClick:()=>openCommit(h[0]), + onMessageClick:()=>openCommit(h[0]) + }); + } } - } - }); - get(branch).history.start(); + }); + get(branch).history.start(); + },1); }); onDestroy( ()=>{ diff --git a/ng-app/src/locales/en.json b/ng-app/src/locales/en.json index b10a5a0..19bffc9 100644 --- a/ng-app/src/locales/en.json +++ b/ng-app/src/locales/en.json @@ -549,7 +549,8 @@ "ConnectionError": "Could not connect to the server.", "IncompatibleQrCode": "You scanned a NextGraph QR-Code that is of the wrong type.", "NotARendezVous": "You scanned an invalid QR-Code.", - "camera_unavailable": "Camera is unavailable." + "camera_unavailable": "Camera is unavailable.", + "ServerAlreadyRunningInOtherProcess": "App is already running on this device. Check it and close it." }, "connectivity": { "stopped": "Stopped", diff --git a/ng-app/src/routes/WalletLogin.svelte b/ng-app/src/routes/WalletLogin.svelte index 9076faf..70ee83d 100644 --- a/ng-app/src/routes/WalletLogin.svelte +++ b/ng-app/src/routes/WalletLogin.svelte @@ -114,7 +114,6 @@ } else { push("#/"); } - } function start_login_from_import() { @@ -134,8 +133,8 @@ console.error(event.detail); } async function gotWallet(event) { - if (importing) { - try { + try { + if (importing) { let in_memory = !event.detail.trusted; //console.log("IMPORTING", in_memory, event.detail.wallet, wallet); let client = await ng.wallet_import( @@ -169,15 +168,15 @@ window.wallet_channel.postMessage(new_in_mem, location.href); } } - } catch (e) { + } else { + let client = await ng.wallet_was_opened(event.detail.wallet); + event.detail.wallet.V0.client = client; + } + } catch (e) { + if (importing) {wallet = undefined;} importing = false; - wallet = undefined; error = e; return; - } - } else { - let client = await ng.wallet_was_opened(event.detail.wallet); - event.detail.wallet.V0.client = client; } //await tick(); active_wallet.set(event.detail); @@ -221,7 +220,7 @@
- + {#if error}
@@ -235,7 +234,6 @@ on:click={() => { importing = false; error = undefined; - wallet = undefined; }} class="text-white bg-primary-700 hover:bg-primary-700/90 focus:ring-4 focus:ring-primary-700/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-700/55 mb-2" > @@ -427,9 +425,26 @@
- {:else if step == "loggedin"} - {@html $t("pages.wallet_login.logged_in")}...{/if} +
+ {@html $t("pages.wallet_login.logged_in")}... + +
+ {/if} diff --git a/ng-app/vite.config.ts b/ng-app/vite.config.ts index 8eeb94c..a3930d9 100644 --- a/ng-app/vite.config.ts +++ b/ng-app/vite.config.ts @@ -68,10 +68,10 @@ export default defineConfig(async () => { port: process.env.NG_APP_WEB ? 1421 : 1420, host: '0.0.0.0', strictPort: true, - fs: { - // Allow serving files from one level up to the project root - allow: ['..'], - }, + // fs: { + // // Allow serving files from one level up to the project root + // allow: ['..'], + // }, hmr: { protocol: 'ws', host, diff --git a/ng-repo/src/repo.rs b/ng-repo/src/repo.rs index cfaf258..497d58f 100644 --- a/ng-repo/src/repo.rs +++ b/ng-repo/src/repo.rs @@ -205,9 +205,9 @@ impl Repo { } else { let commit_type = cobj.get_type().unwrap(); let acks = cobj.acks(); - for a in acks.iter() { - log_debug!("ACKS of {} {}", id.to_string(), a.id.to_string()); - } + // for a in acks.iter() { + // log_debug!("ACKS of {} {}", id.to_string(), a.id.to_string()); + // } let (past, real_acks, next_future) = match commit_type { CommitType::SyncSignature => { assert_eq!(acks.len(), 1); diff --git a/ng-sdk-js/src/lib.rs b/ng-sdk-js/src/lib.rs index d2ce93f..9b18a10 100644 --- a/ng-sdk-js/src/lib.rs +++ b/ng-sdk-js/src/lib.rs @@ -430,7 +430,7 @@ pub async fn branch_history(session_id: JsValue, nuri: String) -> Result Ok(serde_wasm_bindgen::to_value(&s.to_js()).unwrap()), _ => Err("invalid response".to_string()), diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 99604f7..9e09bd4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,8 +4,27 @@ importers: .: specifiers: + '@codemirror/autocomplete': ^6.17.0 + '@codemirror/commands': ^6.6.0 + '@codemirror/language': ^6.10.2 + '@codemirror/legacy-modes': ^6.4.0 + '@codemirror/lint': ^6.8.1 + '@codemirror/search': ^6.5.6 + '@codemirror/state': ^6.4.1 + '@codemirror/view': ^6.28.6 + codemirror: ^6.0.1 prettier: ^3.3.2 prettier-plugin-svelte: ^3.2.5 + dependencies: + '@codemirror/autocomplete': 6.17.0_77urojsfbrmvdrcps23icldzhi + '@codemirror/commands': 6.6.0 + '@codemirror/language': 6.10.2 + '@codemirror/legacy-modes': 6.4.0 + '@codemirror/lint': 6.8.1 + '@codemirror/search': 6.5.6 + '@codemirror/state': 6.4.1 + '@codemirror/view': 6.29.1 + codemirror: 6.0.1 devDependencies: prettier: 3.3.2 prettier-plugin-svelte: 3.2.5_prettier@3.3.2 @@ -19,7 +38,7 @@ importers: '@codemirror/lint': ^6.8.1 '@codemirror/search': ^6.5.6 '@codemirror/state': ^6.4.1 - '@codemirror/view': ^6.28.6 + '@codemirror/view': ^6.29.1 '@popperjs/core': ^2.11.8 '@sveltejs/vite-plugin-svelte': ^2.0.0 '@tauri-apps/api': 2.0.0-alpha.8 @@ -63,14 +82,14 @@ importers: vite-plugin-top-level-await: ^1.3.1 vite-plugin-wasm: ^3.2.2 dependencies: - '@codemirror/autocomplete': 6.17.0_d2gatnekun5qqgvovsxsi7nnwi + '@codemirror/autocomplete': 6.17.0_77urojsfbrmvdrcps23icldzhi '@codemirror/commands': 6.6.0 '@codemirror/language': 6.10.2 '@codemirror/legacy-modes': 6.4.0 '@codemirror/lint': 6.8.1 '@codemirror/search': 6.5.6 '@codemirror/state': 6.4.1 - '@codemirror/view': 6.28.6 + '@codemirror/view': 6.29.1 '@popperjs/core': 2.11.8 '@tauri-apps/api': 2.0.0-alpha.8 '@tauri-apps/plugin-barcode-scanner': 2.0.0-alpha.0 @@ -154,7 +173,7 @@ packages: engines: {node: '>=10'} dev: true - /@codemirror/autocomplete/6.17.0_d2gatnekun5qqgvovsxsi7nnwi: + /@codemirror/autocomplete/6.17.0_77urojsfbrmvdrcps23icldzhi: resolution: {integrity: sha512-fdfj6e6ZxZf8yrkMHUSJJir7OJkHkZKaOZGzLWIYp2PZ3jd+d+UjG8zVPqJF6d3bKxkhvXTPan/UZ1t7Bqm0gA==} peerDependencies: '@codemirror/language': ^6.0.0 @@ -163,7 +182,7 @@ packages: dependencies: '@codemirror/language': 6.10.2 '@codemirror/state': 6.4.1 - '@codemirror/view': 6.28.6 + '@codemirror/view': 6.29.1 '@lezer/common': 1.2.1 dev: false @@ -172,7 +191,7 @@ packages: dependencies: '@codemirror/language': 6.10.2 '@codemirror/state': 6.4.1 - '@codemirror/view': 6.28.6 + '@codemirror/view': 6.29.1 '@lezer/common': 1.2.1 dev: false @@ -180,7 +199,7 @@ packages: resolution: {integrity: sha512-kgbTYTo0Au6dCSc/TFy7fK3fpJmgHDv1sG1KNQKJXVi+xBTEeBPY/M30YXiU6mMXeH+YIDLsbrT4ZwNRdtF+SA==} dependencies: '@codemirror/state': 6.4.1 - '@codemirror/view': 6.28.6 + '@codemirror/view': 6.29.1 '@lezer/common': 1.2.1 '@lezer/highlight': 1.2.0 '@lezer/lr': 1.4.1 @@ -197,7 +216,7 @@ packages: resolution: {integrity: sha512-IZ0Y7S4/bpaunwggW2jYqwLuHj0QtESf5xcROewY6+lDNwZ/NzvR4t+vpYgg9m7V8UXLPYqG+lu3DF470E5Oxg==} dependencies: '@codemirror/state': 6.4.1 - '@codemirror/view': 6.28.6 + '@codemirror/view': 6.29.1 crelt: 1.0.6 dev: false @@ -205,7 +224,7 @@ packages: resolution: {integrity: sha512-rpMgcsh7o0GuCDUXKPvww+muLA1pDJaFrpq/CCHtpQJYz8xopu4D1hPcKRoDD0YlF8gZaqTNIRa4VRBWyhyy7Q==} dependencies: '@codemirror/state': 6.4.1 - '@codemirror/view': 6.28.6 + '@codemirror/view': 6.29.1 crelt: 1.0.6 dev: false @@ -213,8 +232,8 @@ packages: resolution: {integrity: sha512-QkEyUiLhsJoZkbumGZlswmAhA7CBU02Wrz7zvH4SrcifbsqwlXShVXg65f3v/ts57W3dqyamEriMhij1Z3Zz4A==} dev: false - /@codemirror/view/6.28.6: - resolution: {integrity: sha512-bhwB1AZ6zU4M3dNKm8Aa2BXwj5mWDqE9IWpqxYKJoLCnx+AcwcMuLO01tLWgc1mx4vT1IVYVqx86YoqUsATrqQ==} + /@codemirror/view/6.29.1: + resolution: {integrity: sha512-7r+DlO/QFwPqKp73uq5mmrS4TuLPUVotbNOKYzN3OLP5ScrOVXcm4g13/48b6ZXGhdmzMinzFYqH0vo+qihIkQ==} dependencies: '@codemirror/state': 6.4.1 style-mod: 4.1.2 @@ -1160,13 +1179,13 @@ packages: /codemirror/6.0.1: resolution: {integrity: sha512-J8j+nZ+CdWmIeFIGXEFbFPtpiYacFMDR8GlHK3IyHQJMCaVRfGx9NT+Hxivv1ckLWPvNdZqndbr/7lVhrf/Svg==} dependencies: - '@codemirror/autocomplete': 6.17.0_d2gatnekun5qqgvovsxsi7nnwi + '@codemirror/autocomplete': 6.17.0_77urojsfbrmvdrcps23icldzhi '@codemirror/commands': 6.6.0 '@codemirror/language': 6.10.2 '@codemirror/lint': 6.8.1 '@codemirror/search': 6.5.6 '@codemirror/state': 6.4.1 - '@codemirror/view': 6.28.6 + '@codemirror/view': 6.29.1 dev: false /commander/4.1.1: