history pane in Tauri + fixes GUI

pull/37/head
Niko PLP 3 months ago
parent f7ee5457ef
commit c956cfcb35
  1. 2
      ng-app/package.json
  2. 26
      ng-app/src-tauri/src/lib.rs
  3. 5
      ng-app/src/api.ts
  4. 3
      ng-app/src/apps/SparqlQueryEditor.svelte
  5. 3
      ng-app/src/apps/SparqlUpdateEditor.svelte
  6. 3
      ng-app/src/lib/FullLayout.svelte
  7. 2
      ng-app/src/lib/Login.svelte
  8. 3
      ng-app/src/lib/panes/History.svelte
  9. 3
      ng-app/src/locales/en.json
  10. 37
      ng-app/src/routes/WalletLogin.svelte
  11. 8
      ng-app/vite.config.ts
  12. 6
      ng-repo/src/repo.rs
  13. 2
      ng-sdk-js/src/lib.rs
  14. 45
      pnpm-lock.yaml

@ -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",

@ -402,9 +402,30 @@ async fn doc_fetch_repo_subscribe(repo_o: String) -> Result<AppRequest, String>
Ok(request)
}
#[tauri::command(rename_all = "snake_case")]
async fn branch_history(session_id: u64, nuri: String) -> Result<AppHistoryJs, String> {
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<String>,
) -> Result<Value, String> {
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");

@ -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,7 +246,7 @@ 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)

@ -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,6 +43,7 @@
};
onMount(()=>{
reset_in_memory();
if (!$in_memory_discrete){
$in_memory_discrete = "SELECT ?subject ?predicate ?object WHERE {\n ?subject ?predicate ?object .\n} LIMIT 10";
}

@ -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 <did:ng:test> <test:predicate> \"An example value\".\r}";
}

@ -251,7 +251,10 @@
});
active_session.subscribe((as) => { if(!as) {
console.log($location);
if ($location!="/user") {
$redirect_after_login = $location;
}
push("#/");
} })

@ -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")}
</span>

@ -50,6 +50,7 @@
let unsub = () => {};
onMount(async ()=>{
setTimeout(async()=> {
const graphContainer = document.getElementById("graph-container");
gitgraph = createGitgraph(graphContainer, {
template: templateExtend(TemplateName.Metro, {
@ -78,6 +79,7 @@
};}));
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)) {
@ -97,6 +99,7 @@
}
});
get(branch).history.start();
},1);
});
onDestroy( ()=>{

@ -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",

@ -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 {
if (importing) {
let in_memory = !event.detail.trusted;
//console.log("IMPORTING", in_memory, event.detail.wallet, wallet);
let client = await ng.wallet_import(
@ -169,16 +168,16 @@
window.wallet_channel.postMessage(new_in_mem, location.href);
}
}
} 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);
// { wallet,
@ -221,7 +220,7 @@
</script>
<div bind:this={top}>
<CenteredLayout displayFooter={!wallet}>
<CenteredLayout displayFooter={!wallet && !selected}>
{#if error}
<div class=" max-w-6xl lg:px-8 mx-auto px-4 text-red-800">
<ExclamationTriangle class="animate-bounce mt-10 h-16 w-16 mx-auto" />
@ -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 @@
</a>
</div>
</div>
<!-- {:else if step == "security"}{:else if step == "qrcode"}{:else if step == "cloud"} -->
{:else if step == "loggedin"}
{@html $t("pages.wallet_login.logged_in")}...{/if}
<div class=" max-w-6xl lg:px-8 mx-auto px-4 text-green-800">
{@html $t("pages.wallet_login.logged_in")}...
<svg
class="my-10 h-16 w-16 mx-auto"
fill="none"
stroke="currentColor"
stroke-width="1.5"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M9 12.75L11.25 15 15 9.75M21 12c0 1.268-.63 2.39-1.593 3.068a3.745 3.745 0 01-1.043 3.296 3.745 3.745 0 01-3.296 1.043A3.745 3.745 0 0112 21c-1.268 0-2.39-.63-3.068-1.593a3.746 3.746 0 01-3.296-1.043 3.745 3.745 0 01-1.043-3.296A3.745 3.745 0 013 12c0-1.268.63-2.39 1.593-3.068a3.745 3.745 0 011.043-3.296 3.746 3.746 0 013.296-1.043A3.746 3.746 0 0112 3c1.268 0 2.39.63 3.068 1.593a3.746 3.746 0 013.296 1.043 3.746 3.746 0 011.043 3.296A3.745 3.745 0 0121 12z"
/>
</svg>
</div>
{/if}
</CenteredLayout>
</div>

@ -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,

@ -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);

@ -430,7 +430,7 @@ pub async fn branch_history(session_id: JsValue, nuri: String) -> Result<JsValue
.map_err(|e: NgError| e.to_string())?;
let AppResponse::V0(res) = res;
log_debug!("{:?}", res);
//log_debug!("{:?}", res);
match res {
AppResponseV0::History(s) => Ok(serde_wasm_bindgen::to_value(&s.to_js()).unwrap()),
_ => Err("invalid response".to_string()),

@ -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:

Loading…
Cancel
Save