Skip to content

Commit

Permalink
Merge pull request #16 from user-cube/Frontend
Browse files Browse the repository at this point in the history
Frontend
  • Loading branch information
user-cube authored Apr 28, 2020
2 parents cb9f215 + 36b4820 commit 20a3fab
Show file tree
Hide file tree
Showing 13 changed files with 358 additions and 88 deletions.
1 change: 1 addition & 0 deletions Frontend/Frontend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
'django.contrib.messages',
'django.contrib.staticfiles',
'app.apps.AppConfig',
'datetimepicker',
]

MIDDLEWARE = [
Expand Down
10 changes: 8 additions & 2 deletions Frontend/Frontend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

from app.views import profile, home, checkTests, checkTestInfo, editProfile, updateProfile, \
createUser, userCreation, validateUser, saveUser, rankUp, listUsers, editUser, processUser, \
searchUser, networkStatus, processNode, searchTest, calendar, registerTest, checkTestInfoAdmin, checkTestsAdmin, searchTestAdmin
searchUser, networkStatus, processNode, searchTest, calendar, registerTest, checkTestInfoAdmin, \
checkTestsAdmin, searchTestAdmin, createAcessPoint, processAP, registerTestSave



urlpatterns = [
path('admin/', admin.site.urls),
Expand All @@ -46,6 +49,9 @@
path('create/user/validate/save/', saveUser, name="savepassword"),
path('network/status/', networkStatus, name="networkstatus"),
path('network/status/<int:nodeID>', processNode, name="nodestatus"),
path('network/create/AP', createAcessPoint, name="createap"),
path('network/create/AP/save', processAP, name="saveap"),
path('calendar/', calendar, name='calendar'),
path('calendar/test', registerTest, name='registertest')
path('calendar/test', registerTest, name='registertest'),
path('calendar/test/save', registerTestSave, name='registertestsave')
]
4 changes: 4 additions & 0 deletions Frontend/app/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from django import forms



38 changes: 6 additions & 32 deletions Frontend/app/templates/calendar/calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,21 @@
<div class="container">
<br>
<br>

<a href="{% url 'registertest' %}" class="btn btn-success">
<span class="glyphicon glyphicon-thumbs-up"></span>Register Test</a>

<div id="calendar"></div>
<div id="evoCalendar"></div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="{% static 'evo-calendar/js/evo-calendar.js' %}"></script>

<script>
// initialize your calendar, once the page's DOM is ready
myEvents = [
2,
{ name: "New Year", date: "Wed Jan 01 2020 00:00:00 GMT-0800 (Pacific Standard Time)", type: "holiday", everyYear: true },
3,
{ name: "Valentine's Day", date: "Fri Feb 14 2020 00:00:00 GMT-0800 (Pacific Standard Time)", type: "holiday", everyYear: true },
4,
{ name: "Birthday", date: "February/3/2020", type: "birthday" },
5,
{ name: "Author's Birthday", date: "February/15/2020", type: "birthday", everyYear: true },
6,
{ name: "Holiday", date: "February/15/2020", type: "event" },
7
]
$('#calendar').evoCalendar({


$('#evoCalendar').evoCalendar({
theme: 'Royal Navy',
settingName: myEvents,
calendarEvents: [
{
id: 'kNybja6',
name: 'Mom\'s Birthday',
date: 'May 27, 1965',
type: 'birthday',
everyYear: true // optional
},
{
id: 'asDf87L',
name: 'Graduation Day!',
date: 'April 26, 2020',
type: 'event'
}],
calendarEvents: {% autoescape off %} {{ database }}
{% endautoescape %}
})
</script>
</div>
Expand Down
32 changes: 11 additions & 21 deletions Frontend/app/templates/calendar/registerTest.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{% extends 'structure/layout.html' %}
{% block headers %}
{% endblock %}


{% block content %}

{% if messages %}
{% for message in messages %}
{% if message.tags %}
<script>alert("{{ message }}")</script> {% endif %}
{% endfor %}
{% endif %}

<div class="row">
<div class="col-lg-10 ">
<form class="form-horizontal" method="post" action="{% url 'registertest' %}"
Expand All @@ -15,29 +20,23 @@
<div class="col-lg-6">
<div class="input-group">
<input id="name" name="name" type="text"
placeholder="Nome" class="form-control input-lg" value="{{ name }}">
placeholder="Nome" class="form-control input-lg" value="{{ name }}" required>
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-6">
<label>Start Date of the Test</label>
<div class="input-group-prepend">
<button type="button" id="toggle_start" class="input-group-text">
<i class="fa fa-calendar"></i>
</button>
<input type="text" id="start_time" class="form-control" placeholder="05/16/2018 12:31">
<input type="datetime-local" id="start_time" class="form-control" placeholder="05/16/2018 12:31" required>
</div>
</div>
</div>
<div class="form-group">
<label class="col-lg-4" for="NumTests">End Date of the Test</label>
<div class="col-lg-6">
<div class="input-group-prepend">
<button type="button" id="toggle_start" class="input-group-text">
<i class="fa fa-calendar"></i>
</button>
<input type="text" id="end_time" class="form-control" placeholder="05/16/2018 12:31">
<input type="datetime-local" id="end_time" class="form-control" placeholder="05/16/2018 12:31" required>
</div>
</div>
</div>
Expand All @@ -50,13 +49,4 @@
</form>
</div>
</div>

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$( "#start_time" ).datetimepicker();
} );
</script>

{% endblock %}
93 changes: 93 additions & 0 deletions Frontend/app/templates/network/create/AP.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{% extends 'structure/layout.html' %}

{% block content %}
<div class="row">
<div class="col-lg-10 ">
<form class="form-horizontal" method="post" action="{% url 'saveap' %}"
enctype="multipart/form-data">
{% csrf_token %}
<br>
<div class="form-group">
<label class="col-lg-4" for="Name">AP SSID</label>
<div class="col-lg-6">
<div class="input-group-prepend">
<input id="APSSID" name="APSSID" type="text"
placeholder="AP SSID" class="form-control input-lg" required>
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-6">
<label class="col-lg-4" for="APPW">AP Password</label>
<div class="input-group-prepend">
<input id="APPW" name="APPW" type="password"
placeholder="AP Password" class="form-control input-lg" required>
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-6">
<label class="col-lg-4" for="APPW">Channel</label>
<div class="input-group-prepend">
<input id="Channel" name="Channel" type="number"
placeholder="AP Channel" class="form-control input-lg" required>
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-6">
<label class="col-lg-4" for="RangeStart">Range Start</label>
<div class="input-group-prepend">
<input id="RangeStart" name="RangeStart" type="text"
placeholder="AP Range Start" class="form-control input-lg" required>
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-6">
<label class="col-lg-4" for="RangeEnd">Range End</label>
<div class="input-group-prepend">
<input id="RangeEnd" name="RangeEnd" type="text"
placeholder="AP Range End" class="form-control input-lg" required>
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-6">
<label class="col-lg-4" for="hw_mode">HW Mode</label>
<div class="input-group-prepend">
<select id="hw_mode" name="hw_mode" required>
<option value="g">G</option>
<option value="a">A</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-6">
<label class="col-lg-4" for="DFGateway">DF Gateway</label>
<div class="input-group-prepend">
<input id="DFGateway" name="DFGateway" type="text"
placeholder="AP Default Gateway" class="form-control input-lg" required>
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-6">
<label class="col-lg-4" for="Netmask">Netmask</label>
<div class="input-group-prepend">
<input id="Netmask" name="Netmask" type="text"
placeholder="AP Netmask" class="form-control input-lg" required>
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label"></label>
<div class="col-md-4">
<input type="submit" value="Add Test" class="btn btn-success"/>
</div>
</div>
</form>
</div>
</div>
{% endblock %}
48 changes: 42 additions & 6 deletions Frontend/app/templates/network/nodeInfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
{% endblock %}

{% block content %}
{% if messages %}
{% for message in messages %}
{% if message.tags %}
<script>alert("{{ message }}")</script> {% endif %}
{% endfor %}
{% endif %}

<div class="container">
<h1>{{ hostname }} - Information</h1>
<hr>
Expand All @@ -27,11 +34,16 @@ <h1>{{ hostname }} - Information</h1>
<td>Netmask</td>
<td>Peer</td>
<td>MAC</td>
<td> {% if i.ip == '127.0.0.1' %} {% else %}
<a href="http://localhost:8888/?hostname={{ i.ip }}&username={{ username }}&password={{ password }}"
target="_blank"
rel="noopener noreferrer"
class="btn btn-success">Abrir Terminal</a>{% endif %}
<td>{% if access == 1 %}
{% if i.ip == '127.0.0.1' %} {% else %}
{% if role == 1 %}
<a href="http://localhost:8888/?hostname={{ i.ip }}&username={{ username }}&password={{ password }}"
target="_blank"
rel="noopener noreferrer"
class="btn btn-success">Abrir Terminal</a>
{% else %} {% endif %}
{% endif %}
{% endif %}
</td>
</tr>
</thead>
Expand All @@ -51,6 +63,30 @@ <h1>{{ hostname }} - Information</h1>
</tbody>
</table>
{% endfor %}

{% if ongoing == 1 %}
{% if access == 1 %}
{% if isAdmin == 1 %}
<h5><strong>OBS:</strong> there is on ongoing test. you can interact with this node using your admin
permissions.</h5>
{% endif %}
{% else %}
{% if role == 0 %}
<h5><strong>OBS:</strong> there is on ongoing test! you can't interact with this node because you
are a beginner.</h5>
{% endif %}
{% endif %}
{% else %}
{% if isAdmin == 1 %}
<h5><strong>OBS:</strong> there is on ongoing test you can interact with this node using your admin
permissions.</h5>
{% else %}
<h5><strong>OBS:</strong> there is no on ongoing test!
</h5>
<h5>To interact with this node please <a href="{% url 'calendar' %}">book an experience.</a></h5>
{% endif %}
{% endif %}
{% if access == 1 %}
<a class="btn btn-primary" href="{% url 'createap' %}">Create Access Point</a>
{% endif %}
</div>
{% endblock %}
14 changes: 8 additions & 6 deletions Frontend/app/templates/structure/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@
{% if request.resolver_match.url_name == 'search' %} class="nav-item active"
{% else %} class="nav-item" {% endif %}>
{% if request.user.is_authenticated %}
<li {% if request.resolver_match.url_name == '#' %}
class="nav-item active"
{% else %}
<li {% if request.resolver_match.url_name == 'networkstatus' %}
class="nav-item active" {% endif %}
{% if request.resolver_match.url_name == 'nodestatus' %} class="nav-item active"
{% else %}
class="nav-item"
{% endif %}>
<a class="nav-link" href="#">Config Test</a>
{% endif %}>
<a class="nav-link" href="{% url 'networkstatus' %}">Network Status</a>
</li>
<li {% if request.resolver_match.url_name == 'calendar' %}
class="nav-item active"
Expand Down Expand Up @@ -109,7 +110,8 @@
class="nav-item active" {% endif %}
{% if request.resolver_match.url_name == 'checkTestInfo' %}
class="nav-item active" {% endif %}
{% if request.resolver_match.url_name == 'checkTestInfoAdmin' %} class="nav-item active"
{% if request.resolver_match.url_name == 'checkTestInfoAdmin' %}
class="nav-item active"
{% else %}
class="nav-item"
{% endif %}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
<option value="1">Name</option>
<option value="0">Email</option>
</select>

<input type="submit" class="btn btn-primary"/>
<input type="submit" value="Search" class="btn btn-primary"/>
</div>
</form>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<option value="1">Name</option>
<option value="0">Date</option>
</select>
<input type="submit" class="btn btn-primary"/>
<input type="submit" value="Search" class="btn btn-primary"/>
</div>
</form>
</div>
Expand Down
3 changes: 2 additions & 1 deletion Frontend/app/tools/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def checkToken(self, token):
try:
decoded = jwtManager.decode(message=token, key=public_key)
return decoded['email']
except:
except Exception as e:
print(e)
return None

def userToken(self, email):
Expand Down
Loading

0 comments on commit 20a3fab

Please sign in to comment.