From 6952a71ff2e0074238d9c4526c8d33e97b9b0f6c Mon Sep 17 00:00:00 2001 From: Erik Gassler Date: Tue, 30 Jan 2024 18:12:23 -0600 Subject: [PATCH] WebUI updated with support for left panel Navigation pinning --- Cargo.lock | 18 +++-- Docs/README.md | 2 +- webapp/Cargo.toml | 2 +- webapp/index.html | 2 - webapp/js/webui.js | 118 ---------------------------- webapp/root_files/service-worker.js | 2 +- webapp/src/main.rs | 1 + webapp/src/nav_menu.rs | 2 +- 8 files changed, 15 insertions(+), 132 deletions(-) delete mode 100644 webapp/js/webui.js diff --git a/Cargo.lock b/Cargo.lock index 7e5a400f..64246f9c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -987,7 +987,8 @@ dependencies = [ [[package]] name = "markdown" version = "1.0.0-alpha.16" -source = "git+https://github.com/wooorm/markdown-rs#60db8e5896be05d23137a6bdb806e63519171f9e" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0f0025e8c0d89b84d6dc63e859475e40e8e82ab1a08be0a93ad5731513a508" dependencies = [ "unicode-id", ] @@ -1674,9 +1675,9 @@ checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" [[package]] name = "value-bag" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cdbaf5e132e593e9fc1de6a15bbec912395b11fb9719e061cf64f804524c503" +checksum = "126e423afe2dd9ac52142e7e9d5ce4135d7e13776c529d27fd6bc49f19e3280b" [[package]] name = "version_check" @@ -1785,7 +1786,7 @@ dependencies = [ [[package]] name = "webapp" -version = "0.7.7" +version = "0.7.12" dependencies = [ "webui", "yew", @@ -1793,8 +1794,8 @@ dependencies = [ [[package]] name = "webui" -version = "0.7.7" -source = "git+https://github.com/StoicDreams/RustWebUI?branch=main#aa3c9cd744fd96a367e9cd1a3c9cc2624a423aa7" +version = "0.7.12" +source = "git+https://github.com/StoicDreams/RustWebUI?branch=main#1bd1b309d1cab1dfacd9d3f70def97da594c7ef1" dependencies = [ "async-std", "chrono", @@ -1821,8 +1822,9 @@ dependencies = [ [[package]] name = "webui_procs" -version = "0.7.7" -source = "git+https://github.com/StoicDreams/RustWebUI?branch=main#aa3c9cd744fd96a367e9cd1a3c9cc2624a423aa7" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baaded386ebd91bd415e431178cb392958aff65e2fdc4c8c42748a02e074262e" [[package]] name = "winapi" diff --git a/Docs/README.md b/Docs/README.md index f48b6da3..45aa95c3 100644 --- a/Docs/README.md +++ b/Docs/README.md @@ -1,6 +1,6 @@ # Task Story -[WebUI Version: 0.7.7](https://github.com/StoicDreams/RustWebUI) +[WebUI Version: 0.7.12](https://github.com/StoicDreams/RustWebUI) Simple task management tool focused around Continuous Agile Software Engineering practices and methodologies. diff --git a/webapp/Cargo.toml b/webapp/Cargo.toml index 93dd1c52..9b25a418 100644 --- a/webapp/Cargo.toml +++ b/webapp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "webapp" -version = "0.7.7" #syncwebui +version = "0.7.12" #syncwebui edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/webapp/index.html b/webapp/index.html index 7617e2d3..a02b86b1 100644 --- a/webapp/index.html +++ b/webapp/index.html @@ -16,7 +16,6 @@ - @@ -36,7 +35,6 @@ - diff --git a/webapp/js/webui.js b/webapp/js/webui.js deleted file mode 100644 index a1ea5e47..00000000 --- a/webapp/js/webui.js +++ /dev/null @@ -1,118 +0,0 @@ -(function webuiSetup() { - "use strict" - function getEl(sel, mswait) { - return new Promise((resolve, reject) => { - let el = null; - const start = Date.now(); - (function check() { - el = document.querySelector(sel); - if (el) { - resolve(el); - return; - } - const c = Date.now(); - if (c - start > mswait) { - resolve(null); - return; - } - setTimeout(check, 10); - })(); - }); - } - function getMatchByKey(target, key) { - let el = target; - let i = 0; - while (el && i++ < 10) { - if (el[key]) { return el; } - el = el.parentNode; - } - return undefined; - } - function handleNav(target) { - if (!target.parentNode) { - // WebUI Already removed from DOM - return true; - } - let anchor = getMatchByKey(target, 'href'); - if (!anchor) { return false; } - let href = anchor.getAttribute('href'); - href = href.substr(0, location.origin.length).toLowerCase() === location.origin.toLowerCase() ? href.substr(location.origin.length) : href; - if (href[0] === '#') { - location.hash = href; - return true; - } - // Disabling local navigation which will be handled by PWA webasembly processing - if (href[0] === '/') { - return true; - } - return false; - } - const styles = document.createElement('style'); - function set_body_class(winWidth) { - // Flag general width by class - let w = winWidth > 3800 ? 'w-4k' - : winWidth > 3400 ? 'w-wqhd' - : winWidth > 2500 ? 'w-qhd' - : winWidth > 1900 ? 'w-fhd' - : winWidth > 1500 ? 'w-hdp' - : winWidth > 1300 ? 'w-hd' - : winWidth > 500 ? 'w-tab' - : 'w-mob' - ; - document.body.className = `${w}`; - } - async function applyDynamicStyleRules() { - let w = window; - let h = await getEl('#app > header', 1) || { clientHeight: 0 }; - let m = await getEl('#app > main', 1) || { clientHeight: 0, clientWidth: 0 }; - let f = await getEl('#app > footer', 1) || { clientHeight: 0 }; - styles.innerHTML = ` -:root { - --window-width: ${w.innerWidth}px; - --window-height: ${w.innerHeight}px; - --main-width: ${m.clientWidth}px; - --main-height: ${m.clientHeight}px; - --header-height: ${h.clientHeight}px; - --footer-height: ${f.clientHeight}px; -} -`; - set_body_class(w.innerWidth); - } - function handlResize(ev) { - applyDynamicStyleRules(); - } - function setupWatchers() { - styles.setAttribute('type', 'text/css'); - document.head.appendChild(styles); - window.addEventListener('resize', handlResize); - applyDynamicStyleRules(); - } - getEl('#app', 30000).then(el => { - el.addEventListener('click', ev => { - if (!ev.target) { return false; } - if (handleNav(ev.target)) { - ev.preventDefault(); - ev.stopPropagation(); - return false; - } - return true; - }); - setupWatchers(); - setTimeout(() => { - el.className = 'page transition in'; - setTimeout(() => { - el.className = ''; - }, 300); - }, 200); - }); - (function checkHighlighting(){ - if (window.hljs) { - document.querySelectorAll('pre code:not([data-hl])').forEach((el) => { - el.setAttribute('data-hl', true); - window.hljs.highlightElement(el); - }); - } - setTimeout(checkHighlighting, 100); - })(); -})(); - diff --git a/webapp/root_files/service-worker.js b/webapp/root_files/service-worker.js index e267b983..72008802 100644 --- a/webapp/root_files/service-worker.js +++ b/webapp/root_files/service-worker.js @@ -11,7 +11,7 @@ function get_uuid() { }); } } -const currentVersion = location.host.substring(0, 9) === 'localhost' ? `${get_uuid()}` : 'webui_0.7.7'; +const currentVersion = location.host.substring(0, 9) === 'localhost' ? `${get_uuid()}` : 'webui_0.7.12'; const cacheNamePrefix = 'offline-cache-'; const cacheName = `${cacheNamePrefix}${currentVersion}`; const offlineAssetsInclude = [/\.wasm/, /\.html/, /\.js$/, /\.json$/, /\.css$/, /\.woff$/, /\.png$/, /\.jpe?g$/, /\.gif$/, /\.ico$/]; diff --git a/webapp/src/main.rs b/webapp/src/main.rs index c9bc6a40..a6bea6fe 100644 --- a/webapp/src/main.rs +++ b/webapp/src/main.rs @@ -1,3 +1,4 @@ +#![allow(unused)] // TODO: Remove me when needing to check for dead code / unused methods/variables. mod components; mod nav_menu; mod pages; diff --git a/webapp/src/nav_menu.rs b/webapp/src/nav_menu.rs index 05eec27f..0dec63bf 100644 --- a/webapp/src/nav_menu.rs +++ b/webapp/src/nav_menu.rs @@ -74,7 +74,7 @@ pub(crate) fn get_nav_routing() -> Vec { fn nav_menu_render(_contexts: Contexts) -> Html { html! { <> - +