From 59089703783fb8e2a743598f32493b423b15408d Mon Sep 17 00:00:00 2001
From: stopyz <stopyz@gmail.com>
Date: Mon, 26 Jun 2023 23:10:33 +0200
Subject: [PATCH] Dashboard App for ACF

---
 app/acf-util/welcome-html.lsp   | 34 +++++++++++++++++++++------------
 app/template-html.lsp           |  5 ++++-
 css/dashboard-pages/welcome.css | 18 ++++++++++++++---
 3 files changed, 41 insertions(+), 16 deletions(-)

diff --git a/app/acf-util/welcome-html.lsp b/app/acf-util/welcome-html.lsp
index 140eb37..f841384 100644
--- a/app/acf-util/welcome-html.lsp
+++ b/app/acf-util/welcome-html.lsp
@@ -20,7 +20,7 @@ if session.userinfo and session.userinfo.userid and viewlibrary and viewlibrary.
 end
 
 -- CHECK SYS RELEASE VERSION
-	local check_sysver = string.match(sys.value.version.value, "v%d+.%d+.%d+")
+	local check_sysver = string.match(sys.value.version.value, "%d+.%d+.%d+")
 	local major_sysver = string.match(check_sysver, "%d+") -- Parse Major for Upgrade
 	local minor_sysver = string.gsub(string.match(check_sysver, "%p%d+"), "%D", "") -- Parse Minor for Update
 	local patch_sysver = string.gsub(string.match(check_sysver, ".[^.]*$"), "%D", "") -- Parse Patch for Update
@@ -32,12 +32,12 @@ end
 	local minor_distver = string.gsub(string.match(actual_distver, "%p%d+"), "%D", "") -- Parse Minor for Update
 	local patch_distver = string.gsub(string.match(actual_distver, ".[^.]*$"), "%D", "") -- Parse Patch for Fix
 	if major_sysver == major_distver and minor_sysver == minor_distver and patch_sysver == patch_distver then
-		chkres = "<a class='version-link version-ok' href='https://www.alpinelinux.org/releases/' title='🟩 Up to Date' target='_blank'><span class='version-check-ok'>Alpine Linux <span class='version-letter'>" .. check_sysver .. "</span></span></a> | up to date "
+		chkres = "<a id='alpine-version-link' class='version-link version-ok' href='https://www.alpinelinux.org/releases/' title='🟩 Up to Date' target='_blank'><span class='version-check-ok'>Alpine Linux | <span class='version-letter'>" .. check_sysver .. "</span></span></a> up to date "
 	else
-		chkres = "<a class='version-link version-update' href='https://www.alpinelinux.org/releases/' title='🟧 Update Needed' target='_blank'><span class='version-check-update'>Alpine Linux <span class='version-letter'>" .. check_sysver .. "</span></span></a> | update needed "
+		chkres = "<a id='alpine-version-link' class='version-link version-update' href='https://www.alpinelinux.org/releases/' title='🟧 Update Needed' target='_blank'><span class='version-check-update'>Alpine Linux | <span class='version-letter'>" .. check_sysver .. "</span></span></a>update needed "
 	end
 	if major_sysver ~= major_distver then
-		chkres = "<a class='version-link version-upgrade' href='https://www.alpinelinux.org/releases/' title='🟥 Upgrade Needed' target='_blank'><span class='version-check-upgrade'>Alpine Linux <span class='version-letter'>" .. check_sysver .. "</span></span></a> | upgrade required "
+		chkres = "<a id='alpine-version-link' class='version-link version-upgrade' href='https://www.alpinelinux.org/releases/' title='🟥 Upgrade Needed' target='_blank'><span class='version-check-upgrade'>Alpine Linux | <span class='version-letter'>" .. check_sysver .. "</span></span></a>upgrade required "
 	end
 	
 -- GET DIST VERSION CHANGES
@@ -53,11 +53,11 @@ end
 	local up_seconds = string.format("%02d", math.floor(((up_time % (3600 * 24)) % 3600) % 60))
 	
 -- REPLACE O.E.M DEFAULT STRING
-	function oem_parse(str)		
-		return (string.gsub(str, "To be filled by O.E.M." or "Not Specified" , "Standard PC")) 
-	end	
+	function oem_parse(str)
+		return (string.gsub(str, "To be filled by O.E.M." or "Not Specified", "Standard PC")) 
+	end		
 	function version_parse(str)
-		return (string.gsub(str, "To be filled by O.E.M." or "Not Specified" , "Unknow")) 
+		return (string.gsub(str, "To be filled by O.E.M." or "Not Specified", "Unknow")) 
 	end
 	
 		-- Table of colors
@@ -208,13 +208,23 @@ end
 				</span>
 			<p class="dashboard-infos dash-info-board">
 				<span class="data-title">Board : </span>
-					<%= oem_parse(sys.value.boardVendor.value) %> |
-						<%= oem_parse(sys.value.boardName.value) %> | 
-							<%=  version_parse(string.gsub(sys.value.boardVersion.value, "^", "ver : ")) %>
+			<%
+			-- EXEMPLE TO PARSE KNOW MOBO MODELS
+			if string.match(sys.value.boardName.value, "EMB%-H81B") then
+				print ("<span>" .. string.gsub(sys.value.boardVendor.value, "To be filled by O.E.M." or "Not Specified", "AAEON") .. "</span>")
+				print (" | <span>" .. sys.value.boardName.value .. "</span> | ")
+				print ("<span>" .. string.gsub(sys.value.boardVersion.value, "To be filled by O.E.M." or "Not Specified" or "Unknow", "Rev : 2.00") .. "</span>")
+			-- ELSE REWRITE ALL OTHERS
+			else
+				print ("<span>" .. oem_parse(sys.value.boardVendor.value) .. "</span>")
+				print (" | <span>" .. oem_parse(sys.value.boardName.value) .. "</span> | ")
+				print ("<span>" .. version_parse(string.gsub(sys.value.boardVersion.value, "^", "Rev : ")) .. "</span>")
+			end
+			%>
 			</p>
 			<p class="dashboard-infos dash-info-bios">
 				<span class="data-title">BIOS : </span>
-					<%= sys.value.biosVersion.value %> | 
+					<span id="version">v. </span><%= sys.value.biosVersion.value %> | 
 						<%= sys.value.biosVendor.value %> - 
 							<%= sys.value.biosDate.value %>
 			</p>
diff --git a/app/template-html.lsp b/app/template-html.lsp
index 645664d..bf80e5f 100644
--- a/app/template-html.lsp
+++ b/app/template-html.lsp
@@ -71,10 +71,13 @@ end
 		<![endif]-->
 		<!-- UNPKG JS CDN FOR LATEST CHART.JS -->
 		<script type="application/javascript" src="https://unpkg.com/chart.js@latest/dist/chart.umd.js"></script>
+		<script type="application/javascript" src="https://cdn.jsdelivr.net/npm/luxon@latest"></script>
+		<script type="application/javascript" src="https://cdn.jsdelivr.net/npm/chartjs-adapter-luxon@latest/dist/chartjs-adapter-luxon.umd.min.js"></script>
+		<script type="application/javascript" src="https://cdn.jsdelivr.net/npm/chartjs-plugin-streaming@latest"></script>
 		<!-- UNPKG JS CDN FOR LATEST HIGHLIGHT.JS -->
 		<script type="application/javascript" src="https://unpkg.com/@highlightjs/cdn-assets@latest/highlight.min.js"></script>
 		<!-- INITIALIZE HIGHLIGHT.JS -->
-		<script type="application/javascript" async defer>hljs.highlightAll()</script>
+		<script type="application/javascript" defer>hljs.highlightAll()</script>
 		<!-- UNPKG JS CDN FOR LATEST JQUERY -->
 		<script type="application/javascript" src="https://unpkg.com/jquery"></script>
 		<script type="text/javascript" src="<%= html.html_escape(pageinfo.wwwprefix..pageinfo.skin.."/"..posix.basename(pageinfo.skin)..".js") %>"></script>
diff --git a/css/dashboard-pages/welcome.css b/css/dashboard-pages/welcome.css
index bb1fc1b..1ac8ce4 100644
--- a/css/dashboard-pages/welcome.css
+++ b/css/dashboard-pages/welcome.css
@@ -285,6 +285,10 @@
 	font-size: 0.65rem;
 }
 
+#alpine-version-link {
+    margin: 0 0.25rem 0 0;
+}
+
 .check-version a {
     font-weight: normal;
 }
@@ -302,7 +306,7 @@
     display: inline-block;
     position: relative;
     top: 0.025rem;
-    margin: 0 0.25rem 0 0.15rem;
+    margin: 0 0.25rem;
     color: inherit;
     font-size: 0.7rem;
 }
@@ -319,7 +323,7 @@
     display: inline-block;
     position: relative;
     top: 0.025rem;
-    margin: 0 0.25rem 0 0.15rem;
+    margin: 0 0.25rem;
     color: inherit;
     font-size: 0.7rem;
 }
@@ -336,7 +340,7 @@
     display: inline-block;
     position: relative;
     top: 0.025rem;
-    margin: 0 0.25rem 0 0.15rem;
+    margin: 0 0.25rem;
     color: inherit;
     font-size: 0.7rem;
 }
@@ -414,6 +418,14 @@
     background-image: url(../../img/icons/intel-inside-dash.png);
 }
 
+.dashboard-infos.dash-info-bios {
+    text-transform: capitalize !important;
+}
+
+#version {
+    text-transform: lowercase !important;
+}
+
 /*span.data-title.value-title.value-mem-total {
     color: #16597a;
 }
-- 
GitLab