Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
alex committed May 13, 2022
1 parent 4177b63 commit f07fc15
Show file tree
Hide file tree
Showing 21 changed files with 806 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app/Http/Controllers/AuthController.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func ViewUsersLogin(c *gin.Context) {
case template == "html":

//HTML template
c.HTML(http.StatusOK, "login.html", gin.H{"csrf": csrf.GetToken(c)})
c.HTML(http.StatusOK, "admin_auth_login.html", gin.H{"csrf": csrf.GetToken(c)})

default:

Expand Down Expand Up @@ -250,7 +250,7 @@ func ViewUsersRegistration(c *gin.Context) {
case template == "html":

//HTML template
c.HTML(http.StatusOK, "register.html", gin.H{"csrf": csrf.GetToken(c)})
c.HTML(http.StatusOK, "admin_auth_register.html", gin.H{"csrf": csrf.GetToken(c)})

default:

Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/CasbinRoleController.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func ViewCasbinRole(c *gin.Context) {
case template == "html":

//HTML template
c.HTML(http.StatusOK, "casbin_role.html", gin.H{"session_id": sessionID, "session_name": sessionName, "list": model})
c.HTML(http.StatusOK, "admin_views_casbin_role.html", gin.H{"session_id": sessionID, "session_name": sessionName, "list": model})

default:

Expand Down Expand Up @@ -149,7 +149,7 @@ func AddCasbinRole(c *gin.Context) {
case template == "html":

//HTML template
c.HTML(http.StatusOK, "casbin_role_add.html", gin.H{"csrf": csrf.GetToken(c), "session_id": sessionID, "session_name": sessionName})
c.HTML(http.StatusOK, "admin_views_casbin_role_add.html", gin.H{"csrf": csrf.GetToken(c), "session_id": sessionID, "session_name": sessionName})

default:

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/HomeController.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func ViewHome(c *gin.Context) {
case template == "html":

//HTML template
c.HTML(http.StatusOK, "home.html", gin.H{"session_id": sessionID, "session_name": sessionName})
c.HTML(http.StatusOK, "admin_views_home.html", gin.H{"session_id": sessionID, "session_name": sessionName})
default:

//VUE template
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/ResPassController.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func ViewRes_passListPrev(c *gin.Context) { // Get model if exist
case template == "html":

//HTML template
c.HTML(http.StatusOK, "forgot_password_new.html", gin.H{"csrf": csrf.GetToken(c), "url": model.Url})
c.HTML(http.StatusOK, "admin_auth_forgot_password_new.html", gin.H{"csrf": csrf.GetToken(c), "url": model.Url})

default:

Expand Down Expand Up @@ -219,7 +219,7 @@ func ViewForgotPassword(c *gin.Context) { // Get model if exist
case template == "html":

//HTML template
c.HTML(http.StatusOK, "forgot_password.html", gin.H{"csrf": csrf.GetToken(c)})
c.HTML(http.StatusOK, "admin_auth_forgot_password.html", gin.H{"csrf": csrf.GetToken(c)})

default:

Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/UserController.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func ViewUsersList(c *gin.Context) {
case template == "html":

//HTML template
c.HTML(http.StatusOK, "users_list.html", gin.H{"csrf": csrf.GetToken(c), "session_id": sessionID, "session_name": sessionName, "list": model})
c.HTML(http.StatusOK, "admin_views_users_list.html", gin.H{"csrf": csrf.GetToken(c), "session_id": sessionID, "session_name": sessionName, "list": model})

default:

Expand Down Expand Up @@ -260,7 +260,7 @@ func ViewUsersListPrev(c *gin.Context) { // Get model if exist
case template == "html":

//HTML template
c.HTML(http.StatusOK, "users_list_prev.html", gin.H{"csrf": csrf.GetToken(c), "session_id": sessionID, "session_name": sessionName, "id": model.ID, "name": model.Name,
c.HTML(http.StatusOK, "admin_views_users_list_prev.html", gin.H{"csrf": csrf.GetToken(c), "session_id": sessionID, "session_name": sessionName, "id": model.ID, "name": model.Name,
"email": model.Email, "role": model.Role})

default:
Expand Down Expand Up @@ -310,7 +310,7 @@ func ViewAddUsers(c *gin.Context) { // Get model if exist
case template == "html":

//HTML template
c.HTML(http.StatusOK, "users_add.html", gin.H{"csrf": csrf.GetToken(c), "session_id": sessionID, "session_name": sessionName})
c.HTML(http.StatusOK, "admin_views_users_add.html", gin.H{"csrf": csrf.GetToken(c), "session_id": sessionID, "session_name": sessionName})

default:

Expand Down
7 changes: 6 additions & 1 deletion app/Http/Controllers/WelcomeController.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"net/http"
"os"

"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
)
Expand Down Expand Up @@ -38,8 +39,12 @@ func GetWelcome(c *gin.Context) {

case template == "html":

session := sessions.Default(c)

sessionID := session.Get("user_id")

//HTML template
c.HTML(http.StatusOK, "welcome.html", gin.H{"title": "Larago"})
c.HTML(http.StatusOK, "public_welcome.html", gin.H{"title": "Larago", "session_id": sessionID})

default:

Expand Down
137 changes: 137 additions & 0 deletions resources/views/_admin_app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
{{ define "admin_app" }}
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="/favicon.ico">

<link href="/public/css/app.css" rel="stylesheet">
<!-- Scripts -->
<script src="/public/js/app.js" defer></script>
<title>larago</title>
</head>

<div class="leading-normal tracking-normal" id="main-body">
<div class="flex flex-wrap">



<div class="w-1/2 md:w-1/3 lg:w-64 fixed md:top-0 md:left-0 h-screen lg:block bg-gray-100 border-r z-30 flex hidden" id="main-nav">

<div class="w-full h-20 border-b flex px-4 items-center mb-8">
<p class="font-semibold text-3xl text-blue-400 pl-4">LGO-ADMIN</p>
</div>

<div class="mb-4 px-4">
<p class="pl-4 text-sm font-semibold mb-1">MAIN</p>
<div class="w-full flex items-center text-blue-400 h-10 pl-4 bg-gray-200 hover:bg-gray-200 rounded-lg cursor-pointer">
<svg class="h-6 w-6 fill-current mr-2" viewBox="0 0 20 20">
<path d="M18.121,9.88l-7.832-7.836c-0.155-0.158-0.428-0.155-0.584,0L1.842,9.913c-0.262,0.263-0.073,0.705,0.292,0.705h2.069v7.042c0,0.227,0.187,0.414,0.414,0.414h3.725c0.228,0,0.414-0.188,0.414-0.414v-3.313h2.483v3.313c0,0.227,0.187,0.414,0.413,0.414h3.726c0.229,0,0.414-0.188,0.414-0.414v-7.042h2.068h0.004C18.331,10.617,18.389,10.146,18.121,9.88 M14.963,17.245h-2.896v-3.313c0-0.229-0.186-0.415-0.414-0.415H8.342c-0.228,0-0.414,0.187-0.414,0.415v3.313H5.032v-6.628h9.931V17.245z M3.133,9.79l6.864-6.868l6.867,6.868H3.133z"></path>
</svg>
<span class="text-gray-700"><a href="/home">Dashboard</a></span>
</div>
</div>

<div class="mb-4 px-4">
<p class="pl-4 text-sm font-semibold mb-1">USERS</p>
<div class="w-full flex items-center text-blue-400 h-10 pl-4 hover:bg-gray-200 rounded-lg cursor-pointer">
<svg class="h-6 w-6 fill-current mr-2" viewBox="0 0 20 20">
<path d="M14.613,10c0,0.23-0.188,0.419-0.419,0.419H10.42v3.774c0,0.23-0.189,0.42-0.42,0.42s-0.419-0.189-0.419-0.42v-3.774H5.806c-0.23,0-0.419-0.189-0.419-0.419s0.189-0.419,0.419-0.419h3.775V5.806c0-0.23,0.189-0.419,0.419-0.419s0.42,0.189,0.42,0.419v3.775h3.774C14.425,9.581,14.613,9.77,14.613,10 M17.969,10c0,4.401-3.567,7.969-7.969,7.969c-4.402,0-7.969-3.567-7.969-7.969c0-4.402,3.567-7.969,7.969-7.969C14.401,2.031,17.969,5.598,17.969,10 M17.13,10c0-3.932-3.198-7.13-7.13-7.13S2.87,6.068,2.87,10c0,3.933,3.198,7.13,7.13,7.13S17.13,13.933,17.13,10"></path>
</svg>
<span class="text-gray-700"><a href="/users/add">Add User</a></span>
</div>
<div class="w-full flex items-center text-blue-400 h-10 pl-4 hover:bg-gray-200 rounded-lg cursor-pointer">
<svg class="h-6 w-6 fill-current mr-2" viewBox="0 0 20 20">
<path d="M15.396,2.292H4.604c-0.212,0-0.385,0.174-0.385,0.386v14.646c0,0.212,0.173,0.385,0.385,0.385h10.792c0.211,0,0.385-0.173,0.385-0.385V2.677C15.781,2.465,15.607,2.292,15.396,2.292 M15.01,16.938H4.99v-2.698h1.609c0.156,0.449,0.586,0.771,1.089,0.771c0.638,0,1.156-0.519,1.156-1.156s-0.519-1.156-1.156-1.156c-0.503,0-0.933,0.321-1.089,0.771H4.99v-3.083h1.609c0.156,0.449,0.586,0.771,1.089,0.771c0.638,0,1.156-0.518,1.156-1.156c0-0.638-0.519-1.156-1.156-1.156c-0.503,0-0.933,0.322-1.089,0.771H4.99V6.531h1.609C6.755,6.98,7.185,7.302,7.688,7.302c0.638,0,1.156-0.519,1.156-1.156c0-0.638-0.519-1.156-1.156-1.156c-0.503,0-0.933,0.322-1.089,0.771H4.99V3.062h10.02V16.938z M7.302,13.854c0-0.212,0.173-0.386,0.385-0.386s0.385,0.174,0.385,0.386s-0.173,0.385-0.385,0.385S7.302,14.066,7.302,13.854 M7.302,10c0-0.212,0.173-0.385,0.385-0.385S8.073,9.788,8.073,10s-0.173,0.385-0.385,0.385S7.302,10.212,7.302,10 M7.302,6.146c0-0.212,0.173-0.386,0.385-0.386s0.385,0.174,0.385,0.386S7.899,6.531,7.688,6.531S7.302,6.358,7.302,6.146"></path>
</svg>
<span class="text-gray-700"><a href="/users/list">View Users</a></span>
</div>
</div>

<div class="mb-4 px-4">
<p class="pl-4 text-sm font-semibold mb-1">USERS (CASBIN) ROLE</p>
<div class="w-full flex items-center text-blue-400 h-10 pl-4 hover:bg-gray-200 rounded-lg cursor-pointer">
<svg class="h-6 w-6 fill-current mr-2" viewBox="0 0 20 20">
<path d="M14.613,10c0,0.23-0.188,0.419-0.419,0.419H10.42v3.774c0,0.23-0.189,0.42-0.42,0.42s-0.419-0.189-0.419-0.42v-3.774H5.806c-0.23,0-0.419-0.189-0.419-0.419s0.189-0.419,0.419-0.419h3.775V5.806c0-0.23,0.189-0.419,0.419-0.419s0.42,0.189,0.42,0.419v3.775h3.774C14.425,9.581,14.613,9.77,14.613,10 M17.969,10c0,4.401-3.567,7.969-7.969,7.969c-4.402,0-7.969-3.567-7.969-7.969c0-4.402,3.567-7.969,7.969-7.969C14.401,2.031,17.969,5.598,17.969,10 M17.13,10c0-3.932-3.198-7.13-7.13-7.13S2.87,6.068,2.87,10c0,3.933,3.198,7.13,7.13,7.13S17.13,13.933,17.13,10"></path>
</svg>
<span class="text-gray-700"><a href="/role/add">Add Role</a></span>
</div>
<div class="w-full flex items-center text-blue-400 h-10 pl-4 hover:bg-gray-200 rounded-lg cursor-pointer">
<svg class="h-6 w-6 fill-current mr-2" viewBox="0 0 20 20">
<path d="M15.396,2.292H4.604c-0.212,0-0.385,0.174-0.385,0.386v14.646c0,0.212,0.173,0.385,0.385,0.385h10.792c0.211,0,0.385-0.173,0.385-0.385V2.677C15.781,2.465,15.607,2.292,15.396,2.292 M15.01,16.938H4.99v-2.698h1.609c0.156,0.449,0.586,0.771,1.089,0.771c0.638,0,1.156-0.519,1.156-1.156s-0.519-1.156-1.156-1.156c-0.503,0-0.933,0.321-1.089,0.771H4.99v-3.083h1.609c0.156,0.449,0.586,0.771,1.089,0.771c0.638,0,1.156-0.518,1.156-1.156c0-0.638-0.519-1.156-1.156-1.156c-0.503,0-0.933,0.322-1.089,0.771H4.99V6.531h1.609C6.755,6.98,7.185,7.302,7.688,7.302c0.638,0,1.156-0.519,1.156-1.156c0-0.638-0.519-1.156-1.156-1.156c-0.503,0-0.933,0.322-1.089,0.771H4.99V3.062h10.02V16.938z M7.302,13.854c0-0.212,0.173-0.386,0.385-0.386s0.385,0.174,0.385,0.386s-0.173,0.385-0.385,0.385S7.302,14.066,7.302,13.854 M7.302,10c0-0.212,0.173-0.385,0.385-0.385S8.073,9.788,8.073,10s-0.173,0.385-0.385,0.385S7.302,10.212,7.302,10 M7.302,6.146c0-0.212,0.173-0.386,0.385-0.386s0.385,0.174,0.385,0.386S7.899,6.531,7.688,6.531S7.302,6.358,7.302,6.146"></path>
</svg>
<span class="text-gray-700"><a href="/role/list">View Roles</a></span>
</div>
</div>

</div>


<div class="w-full bg-gray-100 pl-0 lg:pl-64 min-h-screen" id="main-content">

<div class="sticky top-0 z-40">
<div class="w-full h-20 px-6 bg-gray-100 border-b flex items-center justify-between">

<!-- left navbar -->
<div class="flex">

<!-- mobile hamburger -->
<div class="inline-block lg:hidden flex items-center mr-4">
<button class="hover:text-blue-500 hover:border-white focus:outline-none navbar-burger" id="NavbarBtnAdminSidebar" onclick="toggleSidebar();">
<svg class="h-5 w-5" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><title>Menu</title><path d="M0 3h20v2H0V3zm0 6h20v2H0V9zm0 6h20v2H0v-2z"/></svg>
</button>
</div>

<!-- search bar -->
<!--<div class="relative text-gray-600">
<input type="search" name="serch" placeholder="Search products..." class="bg-white h-10 w-full xl:w-64 px-5 rounded-lg border text-sm focus:outline-none">
<button type="submit" class="absolute right-0 top-0 mt-3 mr-4">
<svg class="h-4 w-4 fill-current" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" viewBox="0 0 56.966 56.966" style="enable-background:new 0 0 56.966 56.966;" xml:space="preserve" width="512px" height="512px">
<path d="M55.146,51.887L41.588,37.786c3.486-4.144,5.396-9.358,5.396-14.786c0-12.682-10.318-23-23-23s-23,10.318-23,23 s10.318,23,23,23c4.761,0,9.298-1.436,13.177-4.162l13.661,14.208c0.571,0.593,1.339,0.92,2.162,0.92 c0.779,0,1.518-0.297,2.079-0.837C56.255,54.982,56.293,53.08,55.146,51.887z M23.984,6c9.374,0,17,7.626,17,17s-7.626,17-17,17 s-17-7.626-17-17S14.61,6,23.984,6z"/>
</svg>
</button>
</div>-->
</div>

<!-- right navbar -->
<div class="flex items-center relative">
<!-- <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24" class="fill-current mr-3 hover:text-blue-500"><path d="M0 0h24v24H0z" fill="none"/><path d="M12 22c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2zm6-6v-5c0-3.07-1.63-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.64 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2zm-2 1H8v-6c0-2.48 1.51-4.5 4-4.5s4 2.02 4 4.5v6z"/></svg>-->
<img src="https://secure.gravatar.com/avatar/fcd7f525e95b845d5db709638cb16c5e?s=64&d=mm&r=g" id="NavbarBtnMenuAdmin" class="w-12 h-12 rounded-full shadow-lg" onclick="dropDownAdmin();" />
</div>

</div>

<!-- dropdown menu -->
<div class="absolute bg-gray-100 border border-t-0 shadow-xl text-gray-700 rounded-b-lg w-48 right-0 mr-6 flex hidden" id="NavbarMenuAdmin">
<a href="/" class="block px-4 py-2 hover:bg-gray-200" aria-current="page">Website</a>
<a href="/auth/signout" class="block px-4 py-2 hover:bg-gray-200" >Logout</a>
</div>
<!-- dropdown menu end -->

</div>

<script>

function dropDownAdmin() {
var btn = document.getElementById('NavbarBtnMenuAdmin');
var nav = document.getElementById('NavbarMenuAdmin');

btn.classList.toggle('open');
nav.classList.toggle('flex');
nav.classList.toggle('hidden');
};

function toggleSidebar() {
var btn = document.getElementById('NavbarBtnAdminSidebar');
var nav = document.getElementById('main-nav');

btn.classList.toggle('open');
nav.classList.toggle('flex');
nav.classList.toggle('hidden');
}

</script>

{{end}}
14 changes: 14 additions & 0 deletions resources/views/_admin_footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

{{ define "admin_footer" }}
<div class="w-full border-t-2 px-8 py-6 lg:flex justify-between items-center">
<p class="mb-2 lg:mb-0">© Larago 2022</p>

<div class="flex">
<a href="https://github.com/larago-go/larago" class="mr-6 hover:text-gray-900">GitHub</a>
</div>
</div>
</div>
</div>
</div>
</html>
{{end}}
Loading

0 comments on commit f07fc15

Please sign in to comment.