Set correct active class on the navigation menu
This commit is contained in:
		
							parent
							
								
									85e466698f
								
							
						
					
					
						commit
						7aec01deed
					
				|  | @ -76,7 +76,7 @@ func WireGuardClients() echo.HandlerFunc { | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		return c.Render(http.StatusOK, "clients.html", map[string]interface{}{ | 		return c.Render(http.StatusOK, "clients.html", map[string]interface{}{ | ||||||
| 			"name":           "Khanh", | 			"baseData":       model.BaseData{""}, | ||||||
| 			"clientDataList": clientDataList, | 			"clientDataList": clientDataList, | ||||||
| 		}) | 		}) | ||||||
| 	} | 	} | ||||||
|  | @ -149,7 +149,6 @@ func RemoveClient() echo.HandlerFunc { | ||||||
| // WireGuardServer handler
 | // WireGuardServer handler
 | ||||||
| func WireGuardServer() echo.HandlerFunc { | func WireGuardServer() echo.HandlerFunc { | ||||||
| 	return func(c echo.Context) error { | 	return func(c echo.Context) error { | ||||||
| 
 |  | ||||||
| 		// initialize database directory
 | 		// initialize database directory
 | ||||||
| 		dir := "./db" | 		dir := "./db" | ||||||
| 		db, err := scribble.New(dir, nil) | 		db, err := scribble.New(dir, nil) | ||||||
|  | @ -168,7 +167,7 @@ func WireGuardServer() echo.HandlerFunc { | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		return c.Render(http.StatusOK, "server.html", map[string]interface{}{ | 		return c.Render(http.StatusOK, "server.html", map[string]interface{}{ | ||||||
| 			"name":            "Khanh", | 			"baseData":        model.BaseData{"wg-server"}, | ||||||
| 			"serverInterface": serverInterface, | 			"serverInterface": serverInterface, | ||||||
| 			"serverKeyPair":   serverKeyPair, | 			"serverKeyPair":   serverKeyPair, | ||||||
| 		}) | 		}) | ||||||
|  | @ -248,7 +247,7 @@ func GlobalSettings() echo.HandlerFunc { | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		return c.Render(http.StatusOK, "global_settings.html", map[string]interface{}{ | 		return c.Render(http.StatusOK, "global_settings.html", map[string]interface{}{ | ||||||
| 			"name":           "Khanh", | 			"baseData":       model.BaseData{"global-settings"}, | ||||||
| 			"globalSettings": globalSettings, | 			"globalSettings": globalSettings, | ||||||
| 		}) | 		}) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -5,3 +5,8 @@ type Interface struct { | ||||||
| 	Name      string `json:"name"` | 	Name      string `json:"name"` | ||||||
| 	IPAddress string `json:"ip_address"` | 	IPAddress string `json:"ip_address"` | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | // BaseData struct to pass value to the base template
 | ||||||
|  | type BaseData struct { | ||||||
|  | 	Active string | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -86,7 +86,7 @@ | ||||||
|                 <nav class="mt-2"> |                 <nav class="mt-2"> | ||||||
|                     <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false"> |                     <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false"> | ||||||
|                         <li class="nav-item"> |                         <li class="nav-item"> | ||||||
|                             <a href="/" class="nav-link active"> |                             <a href="/" class="nav-link {{if eq .baseData.Active "" }}active{{end}}"> | ||||||
|                                 <i class="nav-icon fas fa-user-secret"></i> |                                 <i class="nav-icon fas fa-user-secret"></i> | ||||||
|                                 <p> |                                 <p> | ||||||
|                                     Wireguard Clients |                                     Wireguard Clients | ||||||
|  | @ -94,7 +94,7 @@ | ||||||
|                             </a> |                             </a> | ||||||
|                         </li> |                         </li> | ||||||
|                         <li class="nav-item"> |                         <li class="nav-item"> | ||||||
|                             <a href="/wg-server" class="nav-link"> |                             <a href="/wg-server" class="nav-link {{if eq .baseData.Active "wg-server" }}active{{end}}"> | ||||||
|                                 <i class="nav-icon fas fa-server"></i> |                                 <i class="nav-icon fas fa-server"></i> | ||||||
|                                 <p> |                                 <p> | ||||||
|                                     Wireguard Server |                                     Wireguard Server | ||||||
|  | @ -102,7 +102,7 @@ | ||||||
|                             </a> |                             </a> | ||||||
|                         </li> |                         </li> | ||||||
|                         <li class="nav-item"> |                         <li class="nav-item"> | ||||||
|                             <a href="/global-settings" class="nav-link"> |                             <a href="/global-settings" class="nav-link {{if eq .baseData.Active "global-settings" }}active{{end}}"> | ||||||
|                                 <i class="nav-icon fas fa-cog"></i> |                                 <i class="nav-icon fas fa-cog"></i> | ||||||
|                                 <p> |                                 <p> | ||||||
|                                     Global Settings |                                     Global Settings | ||||||
|  |  | ||||||
|  | @ -3,7 +3,7 @@ Wireguard Clients | ||||||
| {{end}} | {{end}} | ||||||
| 
 | 
 | ||||||
| {{define "username"}} | {{define "username"}} | ||||||
| {{index . "name"}} | Admin | ||||||
| {{end}} | {{end}} | ||||||
| 
 | 
 | ||||||
| {{define "page_title"}} | {{define "page_title"}} | ||||||
|  |  | ||||||
|  | @ -3,7 +3,7 @@ Global Settings | ||||||
| {{end}} | {{end}} | ||||||
| 
 | 
 | ||||||
| {{define "username"}} | {{define "username"}} | ||||||
| {{index . "name"}} | Admin | ||||||
| {{end}} | {{end}} | ||||||
| 
 | 
 | ||||||
| {{define "page_title"}} | {{define "page_title"}} | ||||||
|  |  | ||||||
|  | @ -3,7 +3,7 @@ Wireguard Server | ||||||
| {{end}} | {{end}} | ||||||
| 
 | 
 | ||||||
| {{define "username"}} | {{define "username"}} | ||||||
| {{index . "name"}} | Admin | ||||||
| {{end}} | {{end}} | ||||||
| 
 | 
 | ||||||
| {{define "page_title"}} | {{define "page_title"}} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue