Compare commits

..

4 Commits

8 changed files with 292 additions and 0 deletions

View File

@ -2,6 +2,7 @@ from core import template
page = {
'public' :'pages/public',
'dashboard' :'pages/dashboard',
'email' :'pages/email'
}

View File

@ -86,5 +86,56 @@ menu = {
"roles":[1,2,3]
}
]
},
"dashboard": {
"navbar": [
{
"name":"Home",
"target":"_self",
"href":"/",
"notification":0,
"roles":[0,1,2,3]
}
],
"profile": [
{
"name" :"Profile",
"href" :"/dashboard/profile",
"target":"_self",
"roles":[1,2]
},
{
"name" :"Settings",
"href" :"/dashboard/settings",
"target":"_self",
"roles":[1,2]
},
{
"name" :"Logout",
"href" :"/logout",
"target":"_self",
"roles":[1,2,3]
}
],
"sidebar": [
{
"name":"Dashboard",
"target":"_self",
"href":"/dashboard",
"roles":[1,2]
},
{
"name":"Roles",
"target":"_self",
"href":"/dashboard/roles",
"roles":[1]
},
{
"name":"Users",
"target":"_self",
"href":"/dashboard/users",
"roles":[1,2]
}
]
}
}

View File

@ -0,0 +1,48 @@
from mako.template import Template
from config import globalvar
from scripts import loggorilla
import procedure.validation as procedure_validation
class dashboard:
def __init__(self):
pass
def html(self, params):
APIADDR = "/dashboard"
loggorilla.prcss(APIADDR, "Define page parameters")
active_page = "Dashboard"
allowed_roles = [0,1,2,3]
loggorilla.prcss(APIADDR, "Account validation")
user_validation = procedure_validation.validation().account(APIADDR, allowed_roles)
user = user_validation['data']
return Template(params["mako"]["website"]['index']).render(
title = globalvar.title,
navbar = Template(params["mako"]["website"]['navbar']).render(
title = globalvar.title,
menu = globalvar.menu['dashboard']['navbar'],
profile = {
"picture" : "https://ditaajipratama.net/img/no-profile-donut.png",
"name" : user['profile']['username'],
"menu" : globalvar.menu['dashboard']['profile']
},
user_roles = user['profile']['roles'],
active_page = active_page
),
sidebar = Template(params["mako"]["website"]['sidebar']).render(
menu = globalvar.menu['dashboard']['sidebar'],
user_roles = user['profile']['roles'],
active_page = active_page
),
footer = Template(params["mako"]["website"]['footer']).render(
copyright = globalvar.copyright,
),
container = Template(params["mako"]["website"]['container']).render(
greeting = f"Welcome to your new web application! This placeholder page is here to let you know that your web framework is successfully set up and ready to go. Now, it's time to start building your project. Dive into the documentation to explore the features and capabilities at your disposal.",
user = user
)
)

View File

@ -0,0 +1,47 @@
from mako.template import Template
from config import globalvar
from scripts import loggorilla
import procedure.validation as procedure_validation
class roles:
def __init__(self):
pass
def html(self, params):
APIADDR = "/dashboard/roles"
loggorilla.prcss(APIADDR, "Define page parameters")
active_page = "Roles"
allowed_roles = [1]
loggorilla.prcss(APIADDR, "Account validation")
user_validation = procedure_validation.validation().account(APIADDR, allowed_roles)
user = user_validation['data']
return Template(params["mako"]["website"]['index']).render(
title = globalvar.title,
navbar = Template(params["mako"]["website"]['navbar']).render(
title = globalvar.title,
menu = globalvar.menu['dashboard']['navbar'],
profile = {
"picture" : "https://ditaajipratama.net/img/no-profile-donut.png",
"name" : user['profile']['username'],
"menu" : globalvar.menu['dashboard']['profile']
},
user_roles = user['profile']['roles'],
active_page = active_page
),
sidebar = Template(params["mako"]["website"]['sidebar']).render(
menu = globalvar.menu['dashboard']['sidebar'],
user_roles = user['profile']['roles'],
active_page = active_page
),
footer = Template(params["mako"]["website"]['footer']).render(
copyright = globalvar.copyright,
),
container = Template(params["mako"]["website"]['container']).render(
token = user['token']
)
)

View File

@ -0,0 +1,47 @@
from mako.template import Template
from config import globalvar
from scripts import loggorilla
import procedure.validation as procedure_validation
class users:
def __init__(self):
pass
def html(self, params):
APIADDR = "/dashboard/users"
loggorilla.prcss(APIADDR, "Define page parameters")
active_page = "Users"
allowed_roles = [1,2]
loggorilla.prcss(APIADDR, "Account validation")
user_validation = procedure_validation.validation().account(APIADDR, allowed_roles)
user = user_validation['data']
return Template(params["mako"]["website"]['index']).render(
title = globalvar.title,
navbar = Template(params["mako"]["website"]['navbar']).render(
title = globalvar.title,
menu = globalvar.menu['dashboard']['navbar'],
profile = {
"picture" : "https://ditaajipratama.net/img/no-profile-donut.png",
"name" : user['profile']['username'],
"menu" : globalvar.menu['dashboard']['profile']
},
user_roles = user['profile']['roles'],
active_page = active_page
),
sidebar = Template(params["mako"]["website"]['sidebar']).render(
menu = globalvar.menu['dashboard']['sidebar'],
user_roles = user['profile']['roles'],
active_page = active_page
),
footer = Template(params["mako"]["website"]['footer']).render(
copyright = globalvar.copyright,
),
container = Template(params["mako"]["website"]['container']).render(
token = user['token']
)
)

View File

@ -0,0 +1,25 @@
<h1>Here is Dashboard!</h1>
% if 4 in user['profile']['roles']:
<!-- Debug Section -->
<div class="container mb-5">
<div class="row">
<div class="col">
<div class="card">
<div class="card-body">
<h1>Debug Section</h1>
<p>Only tester that can see this section</p>
<p>
<b>Username:</b> ${user['profile']['username']} <br>
<b>Email:</b> ${user['profile']['email']} <br>
<b>Phone:</b> ${user['profile']['phone']} <br>
<b>Roles:</b> ${str(user['profile']['roles'])} <br>
</p>
</div>
</div>
</div>
</div>
</div>
% endif

View File

@ -0,0 +1,42 @@
<div class="row">
<div class="col">
<h1 class="h3">Roles</h1>
<input type="hidden" id="form-token" value="${token}">
<div class="table-responsive">
<table class="table table-sm table-bordered table-striped" id="table-roles" width="100%" cellspacing="0">
<thead class="table-primary">
<tr>
<th>ID</th>
<th>Name</th>
<th>Users</th>
<th>Action</th>
</tr>
<tr>
<th>
<input class="form-control form-control-sm" placeholder="ID" id="form-add-id">
</th>
<th>
<input class="form-control form-control-sm" placeholder="Name" id="form-add-name">
</th>
<th></th>
<th>
<button class="btn btn-primary btn-sm" type="button" onclick="submitAdd()">
<span class="fa fa-plus"></span> Add
</button>
</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<!-- End table-responsive -->
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="https://cdn.datatables.net/1.13.5/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.5/js/dataTables.bootstrap5.min.js"></script>
<script type="text/javascript" src="/js/carrack.js"></script>
<script type="text/javascript" src="/js/dashboard/roles.js"></script>
</div>
<!-- End col -->
</div>
<!-- End row -->

View File

@ -0,0 +1,31 @@
<div class="row">
<div class="col">
<h1 class="h3">Users</h1>
<input type="hidden" id="form-token" value="${token}">
<div class="table-responsive">
<table class="table table-sm table-bordered table-striped" id="table-users" width="100%" cellspacing="0">
<thead class="table-primary">
<tr>
<th>ID</th>
<th>Username</th>
<th>Email</th>
<th>Phone</th>
<th>Roles</th>
<th>Verification</th>
<th>Action</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<!-- End table-responsive -->
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="https://cdn.datatables.net/1.13.5/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.5/js/dataTables.bootstrap5.min.js"></script>
<script type="text/javascript" src="/js/carrack.js"></script>
<script type="text/javascript" src="/js/dashboard/users.js"></script>
</div>
<!-- End col -->
</div>
<!-- End row -->