From 0104e8fc107cb46323e5ca63fd596bad9f6c09b7 Mon Sep 17 00:00:00 2001
From: stopyz <stopyz@gmail.com>
Date: Fri, 30 Jun 2023 02:37:13 +0200
Subject: [PATCH] Dashboard App for ACF

---
 README.md                      |  1 -
 app/acf-util/welcome-html.lsp  |  6 +--
 app/template-html.lsp          | 67 +++++++++++++++++++++++-----------
 css/dashboard-main/content.css |  1 -
 css/dashboard-main/nav.css     |  2 +
 5 files changed, 51 insertions(+), 26 deletions(-)

diff --git a/README.md b/README.md
index cf3169a..1046acb 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,4 @@
 <br>
-<br>
 <div align="center">
  <img src="https://github.com/trinity-labs/trinity-skin/assets/45216746/f8b4b03a-1371-4abb-bf4a-fd9e2a1c7446" width="30%">
 </div>
diff --git a/app/acf-util/welcome-html.lsp b/app/acf-util/welcome-html.lsp
index a304b54..769f7df 100644
--- a/app/acf-util/welcome-html.lsp
+++ b/app/acf-util/welcome-html.lsp
@@ -383,7 +383,7 @@ $(function memChart() {
 			<div id="chartNetwork"> </div>
 			<canvas id="networkChart" class="data-chart block-chart"></canvas>
 		</div>
-<div id="demo"></div>
+<!--<div id="demo"></div>-->
 
 <!-- Dashboard Main Block - NETWORK CHART.JS -->
 <script type="application/javascript" src="https://cdn.jsdelivr.net/npm/luxon@latest"></script>
@@ -472,8 +472,8 @@ $(function networkChart() {
 						chart.data.datasets.forEach(dataset => {
 							dataset.data.push({
 							x: Date.now(),
-							y: setInterval(JSON.stringify(lastdata.value.eth0), 1000)
-							});
+							y: 0// setInterval(JSON.stringify(lastdata.value.eth0), 1000)
+							})
 						})
 					}
 				}
diff --git a/app/template-html.lsp b/app/template-html.lsp
index 5820829..6483887 100644
--- a/app/template-html.lsp
+++ b/app/template-html.lsp
@@ -85,28 +85,53 @@ end
 			});
 
 			$(document).ready(function() {
-			document.querySelector('input[type="text"]').setAttribute('placeholder', 'test');
-			document.querySelector('#userid input').setAttribute('required','required');
-			document.querySelector('#password input').setAttribute('required','required');
-			document.querySelector('#userid input').setAttribute('placeholder','🔒 User ID');
-			document.querySelector('#password input').setAttribute('placeholder','🔑 Password');
-			document.querySelector('#userid input').setAttribute('autocomplete','username');
-			document.querySelector('#password input').setAttribute('autocomplete','current-password');
-			});
+				// Login page input placeholder
+				if(window.location.href === "https://" + window.location.hostname + "<%= html.html_escape(pageinfo.wwwprefix).."/cgi-bin/acf/acf-util/logon/logon" %>"){
+					document.querySelector('#userid input').setAttribute('required','required');
+					document.querySelector('#password input').setAttribute('required','required');
+					document.querySelector('#userid input').setAttribute('placeholder','🔒 User ID');
+					document.querySelector('#password input').setAttribute('placeholder','🔑 Password');
+					document.querySelector('#userid input').setAttribute('autocomplete','username');
+					document.querySelector('#password input').setAttribute('autocomplete','current-password');
+			};
+			// Save collapse menu state 
+				var updated = window.localStorage.getItem('nav', updated);	
+				
+			if (window.localStorage.getItem('nav') === 'active') {
+				nav.style.display = "block";
+				content.style.width = "80%";
+			} else {
+				content.style.width = "100%";
+			
+			};
 			
-			function toogleMenu() {
-					var nav = document.getElementById("nav");
-					var content = document.getElementById("content");
-					var icon = document.getElementById("toogle-link");
-				if (nav.style.display === "block") {
-					nav.style.display = "none";
-					content.style.width = "100%";
-					icon.addClass = "active";
-				} else {
-					nav.style.display = "block";
-					content.style.width = "80%";
-				}
+			if (updated === '') {
+				window.localStorage.setItem('nav', 'active');
+				$("#nav").toggleClass("active");
+			} else {
+				window.localStorage.getItem('nav', updated);
+				$("#nav").toggleClass(updated);
+			}
+			});
+	
+			// Toogle collapse menu
+			function toogleMenu() {  
+				var updated = window.localStorage.getItem('nav', updated);
+				$("#nav").toggleClass("active");
+			if (window.localStorage.getItem('nav') === 'active') {
+				updated = 'not_active';
+				nav.style.display = "none";
+				content.style.width = "100%";
+				$("#nav").toggleClass("not_active");
+			} else {
+				updated = 'active';
+				$("#nav").removeClass("not_active");
+				nav.style.display = "block";
+				content.style.width = "80%";
+				
 			}
+			window.localStorage.setItem('nav', updated);
+		};
 		</script>
 </head>
 		<% end -- pageinfo.skinned %>
@@ -155,7 +180,7 @@ end
 </header>	<!-- header -->
 			
 			
-<div id="nav" style="display: block;">
+<div id="nav" style="display: none;">
 				<%
 					local class
 					local tabs
diff --git a/css/dashboard-main/content.css b/css/dashboard-main/content.css
index 115cdc1..08ea58f 100644
--- a/css/dashboard-main/content.css
+++ b/css/dashboard-main/content.css
@@ -9,7 +9,6 @@
 
 #content {
     float: right;
-    width: 80%;
     padding: 0.25rem 0 5rem 0;
 }
 
diff --git a/css/dashboard-main/nav.css b/css/dashboard-main/nav.css
index ed40a75..a331a8a 100644
--- a/css/dashboard-main/nav.css
+++ b/css/dashboard-main/nav.css
@@ -18,6 +18,8 @@
     overflow-x: hidden;
 }
 
+/* Colapse Menu */
+
 #nav ul {
 	display:block;
 }
-- 
GitLab