From 0224e1f137ec43c11bd45a4f9f70a25f2ef0a048 Mon Sep 17 00:00:00 2001
From: ned3y2k 
Date: Sun, 20 Mar 2022 18:03:27 +0900
Subject: [PATCH 1/2] Implements Wake On Lan and management features (#164)
---
 custom/js/wake_on_lan_hosts.js     | 196 +++++++++++++++++++++++++++++
 go.mod                             |   3 +-
 go.sum                             |  33 +++--
 handler/routes_wake_on_lan.go      | 171 +++++++++++++++++++++++++
 main.go                            |   7 +-
 model/wake_on_lan_host.go          |  24 ++++
 router/router.go                   |   6 +
 store/jsondb/jsondb.go             |   4 +
 store/jsondb/jsondb_wake_on_lan.go |  78 ++++++++++++
 store/store.go                     |   5 +
 templates/base.html                |   9 ++
 templates/wake_on_lan_hosts.html   | 123 ++++++++++++++++++
 12 files changed, 638 insertions(+), 21 deletions(-)
 create mode 100644 custom/js/wake_on_lan_hosts.js
 create mode 100644 handler/routes_wake_on_lan.go
 create mode 100644 model/wake_on_lan_host.go
 create mode 100644 store/jsondb/jsondb_wake_on_lan.go
 create mode 100644 templates/wake_on_lan_hosts.html
diff --git a/custom/js/wake_on_lan_hosts.js b/custom/js/wake_on_lan_hosts.js
new file mode 100644
index 0000000..074f6b8
--- /dev/null
+++ b/custom/js/wake_on_lan_hosts.js
@@ -0,0 +1,196 @@
+const wake_on_lan_new_template = '\n' +
+    '\t
\n' +
+    '\t\t
\n' +
+    '\t\t\t
\n' +
+    '\t\t\t\t\n' +
+    '\t\t\t\t\n' +
+    '\t\t\t\t\n' +
+    '\t\t\t
\n' +
+    '\t\t\t
\n' +
+    '\t\t\t
 {{ .Name }}\n' +
+    '\t\t\t
 {{ .MacAddress }}\n' +
+    '\t\t\t
 Unused\n' +
+    '\t\t
\n' +
+    '\t
\n' +
+    '
                             
                         
+                        
+                            
+                                
+
+                                
+                                    Wake On Lan Hosts
+                                
+                            
+                        
                     
                 
                 
diff --git a/templates/wake_on_lan_hosts.html b/templates/wake_on_lan_hosts.html
new file mode 100644
index 0000000..dd1e3eb
--- /dev/null
+++ b/templates/wake_on_lan_hosts.html
@@ -0,0 +1,123 @@
+{{define "title"}}
+    Wake On Lan Hosts
+{{end}}
+
+{{define "top_css"}}
+{{end}}
+
+{{define "username"}}
+    {{ .username }}
+{{end}}
+
+{{define "page_title"}}
+    Wake On Lan Hosts
+{{end}}
+
+{{define "page_content"}}
+
+    
+
+    
+
+    
+        
+            {{ if .error }}
+                
{{.error}}
+            {{ end}}
+
+            
+                {{ range $idx, $host := .hosts }}
+                    {{- /*gotype: github.com/ngoduykhanh/wireguard-ui/model.WakeOnLanHost*/ -}}
+                    
+                        
+                            
+                                
+                                    
+                                    
+                                    
+                                
+                                
+                                
 {{ .Name }}
+                                
 {{ .MacAddress }}
+                                
+                                    
+                                        {{ if .LatestUsed }}
+                                            {{ .LatestUsed }}
+                                        {{ else }}
+                                            Unused
+                                        {{ end }}
+                                    
+                                
+                            
+                        
+                    
+                {{ end }}
+            
+        
                                 
                                       
-                                    
+                                        data-clientname="${obj.Client.name}" ${obj.QRCode != "" ? '' : ' disabled'}>QR code
                                 
                                       
-                                    
                                 
-                                
        
-                                    
                                  ${obj.Client.name}
diff --git a/templates/base.html b/templates/base.html
index 5d3fe92..a161891 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -76,9 +76,7 @@
         
 
                             
-                                
+                                
                                 
                             
                             
-                                
-                                
+                                
+                                
                             
                             
                             
-                                Public and Preshared Keys
+                                Public and Preshared Keys
+                                    
+                                    
+                                
                                 
                                     
-                                    
+