Skip to content

Commit c8951a1

Browse files
Merge branch 'main' into store_data_hotfix
2 parents 5073b83 + f5eca27 commit c8951a1

25 files changed

+1282
-555
lines changed

app/forms.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ class DeviceForm(forms.ModelForm):
55
class Meta:
66
model = Device
77
fields = [
8-
'id',
98
'name',
109
'type',
1110
'is_authorized',
@@ -16,7 +15,6 @@ class Meta:
1615
'api_token'
1716
]
1817
labels = {
19-
'id': 'ID',
2018
'name': 'Nome',
2119
'type': 'Tipo',
2220
'is_authorized': 'Autorizado',
@@ -27,27 +25,24 @@ class Meta:
2725
'api_token': 'Token da API',
2826
}
2927
widgets = {
30-
'id': forms.TextInput(attrs={'placeholder': 'Digite o ID', 'class': 'form-control'}),
31-
'name': forms.TextInput(attrs={'placeholder': 'Digite o nome', 'class': 'form-control'}),
32-
'type': forms.Select(choices=[
33-
('1', 'Água'),
34-
('2', 'Energia')
35-
], attrs={'class': 'form-control'}),
36-
'mac_address': forms.TextInput(attrs={'placeholder': 'Digite o endereço MAC', 'class': 'form-control'}),
37-
'section': forms.TextInput(attrs={'placeholder': 'Digite a seção', 'class': 'form-control'}),
38-
'location': forms.TextInput(attrs={'placeholder': 'Digite a localização', 'class': 'form-control'}),
39-
'ip_address': forms.TextInput(attrs={'placeholder': 'Digite o endereço IP', 'class': 'form-control'}),
40-
'api_token': forms.TextInput(attrs={'placeholder': 'Digite o token da API', 'class': 'form-control'}),
28+
'name': forms.TextInput(attrs={'class': 'form-control'}),
29+
'type': forms.Select(attrs={'class': 'form-control'}),
30+
'is_authorized': forms.Select(attrs={'class': 'form-control'}),
31+
'mac_address': forms.TextInput(attrs={'class': 'form-control'}),
32+
'section': forms.TextInput(attrs={'class': 'form-control'}),
33+
'location': forms.TextInput(attrs={'class': 'form-control'}),
34+
'ip_address': forms.TextInput(attrs={'class': 'form-control'}),
35+
'api_token': forms.TextInput(attrs={'class': 'form-control'}),
4136
}
4237

4338
def __init__(self, *args, **kwargs):
4439
super(DeviceForm, self).__init__(*args, **kwargs)
45-
self.fields['id'].required = True
4640
self.fields['name'].required = True
4741
self.fields['type'].required = True
48-
self.fields['is_authorized'].required = False
42+
self.fields['is_authorized'].required = True
4943
self.fields['section'].required = True
5044
self.fields['location'].required = True
5145
self.fields['ip_address'].required = False
5246
self.fields['mac_address'].required = False
5347
self.fields['api_token'].required = False
48+

app/templates/admin_dashboard.html

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8">
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
{% load static %}
7-
<link rel="stylesheet" href="{% static 'css/style.css' %}">
8-
<title>Admin Dashboard</title>
9-
<link rel="stylesheet" href="{% static 'css/adminDashboard.css' %}">
10-
</head>
11-
<body>
12-
<div class="dashboard">
13-
<h1>Admin Dashboard</h1>
14-
<ul>
15-
<li><a href="{% url 'Register' %}">Register a User</a></li>
16-
<li><a href="{% url 'ListMembers' %}">View Members</a></li>
17-
<li><a href="{% url 'UpdateUser' request.user.id %}">Update Your Account</a></li>
18-
<li> <a href="{% url 'Logout' %}">Logout</a></li>
19-
</ul>
20-
</div>
21-
</body>
22-
</html>
1+
{% extends 'sidebar.html' %}
2+
3+
{% load static %}
4+
5+
{% block title %}Morea | Admin{% endblock %}

app/templates/device_create.html

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,51 @@
1-
{% extends 'layout.html' %}
1+
{% extends 'sidebar.html' %}
22

33
{% load static %}
44

5-
{% block title %}Morea | Cadastro de Dispositivo{% endblock %}
5+
{% block title %}Morea | Gerenciamento de Dispositivos{% endblock %}
66

77
{% block stylesCustom %}
8-
<link rel="stylesheet" href="{% static 'css/device_form.css' %}" />
8+
<link rel="stylesheet" href="{% static 'css/device_form.css' %}" />
99
{% endblock %}
1010

1111
{% block content %}
1212
<div class="container">
13-
<h1>Cadastro de Dispositivo</h1>
14-
<form method="POST">
15-
{% csrf_token %}
16-
{% for field in form %}
13+
<div class="home__content">
14+
<h1 class="textWhatMorea">Cadastro de Dispositivo</h1>
15+
<form method="POST">
16+
{% csrf_token %}
17+
{% for field in form %}
1718
<div class="form-group">
18-
{{ field.label_tag }}
19+
<label for="{{ field.id_for_label }}">{{ field.label }}</label>
20+
{% if field.name == 'type' %}
21+
<select name="type" id="type" class="form-control">
22+
<option value="">Tipo</option>
23+
<option value="1" {% if field.value == '1' %}selected{% endif %}>Água</option>
24+
<option value="2" {% if field.value == '2' %}selected{% endif %}>Energia</option>
25+
<option value="3" {% if field.value == '3' %}selected{% endif %}>Gás</option>
26+
</select>
27+
{% elif field.name == 'is_authorized' %}
28+
<select name="is_authorized" id="is_authorized" class="form-control">
29+
<option value="">Status</option>
30+
<option value="0" {% if field.value == '0' %}selected{% endif %}>Pendente</option>
31+
<option value="1" {% if field.value == '1' %}selected{% endif %}>Não Autorizado</option>
32+
<option value="2" {% if field.value == '2' %}selected{% endif %}>Autorizado</option>
33+
</select>
34+
{% else %}
1935
{{ field }}
36+
{% endif %}
2037
{% if field.errors %}
21-
<div class="error">{{ field.errors }}</div>
38+
<ul class="errors">
39+
{% for error in field.errors %}
40+
<li>{{ error }} <button type="button" class="close-error">x</button></li>
41+
{% endfor %}
42+
</ul>
2243
{% endif %}
2344
</div>
24-
{% endfor %}
25-
<button type="submit">Salvar</button>
26-
</form>
45+
{% endfor %}
46+
<input type="submit" class="buttonMore" value="Cadastrar">
47+
</form>
48+
</div>
2749
</div>
50+
<script src="{% static 'js/error.js' %}"></script>
2851
{% endblock %}

app/templates/device_detail.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
{% extends 'layout.html' %}
1+
{% extends 'sidebar.html' %}
22

33
{% load static %}
44

5-
{% block title %}Morea | Detalhes do Dispositivo{% endblock %}
5+
{% block title %}Morea | Gerenciamento de Dispositivos{% endblock %}
66
{% block stylesCustom %}
7-
<link rel="stylesheet" href="{% static 'css/device_detail.css' %}" />
7+
<link rel="stylesheet" href="{% static 'css/device_detail.css' %}" />
88
{% endblock %}
99

1010
{% block content %}
@@ -41,3 +41,4 @@ <h1>Detalhes do Dispositivo</h1>
4141
</ul>
4242
</div>
4343
{% endblock %}
44+

app/templates/device_list.html

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,51 @@
1-
{% extends 'layout.html' %}
1+
{% extends 'sidebar.html' %}
22

33
{% load static %}
44

5-
{% block title %}Morea | Lista de Dispositivos{% endblock %}
5+
{% block title %}Morea | Gerenciamento de Dispositivos{% endblock %}
66

77
{% block stylesCustom %}
8+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
89
<link rel="stylesheet" href="{% static 'css/device_list.css' %}" />
910
{% endblock %}
1011

1112
{% block content %}
1213
<div class="container">
1314
<h1>Dispositivos Cadastrados</h1>
14-
15-
<form method="GET">
16-
<label for="filter_type">Filtrar por tipo:</label>
17-
<select name="filter_type" id="filter_type">
18-
<option value="">Todos</option>
19-
<option value="1" {% if filter_type == '1' %}selected{% endif %}>Água</option>
20-
<option value="2" {% if filter_type == '2' %}selected{% endif %}>Energia</option>
21-
</select>
22-
<br>
23-
<label for="filter_location">Filtrar por localização:</label>
24-
<select name="filter_location" id="filter_location">
25-
<option value="">Todas</option>
26-
{% for location in locations %}
27-
<option value="{{ location }}" {% if filter_location == location %}selected{% endif %}>{{ location }}</option>
28-
{% endfor %}
29-
</select>
30-
<br>
31-
<label for="filter_section">Filtrar por seção:</label>
32-
<select name="filter_section" id="filter_section">
33-
<option value="">Todas</option>
34-
{% for section in sections %}
35-
<option value="{{ section }}" {% if filter_section == section %}selected{% endif %}>{{ section }}</option>
36-
{% endfor %}
37-
</select>
38-
<br>
39-
<label for="filter_authorized">Filtrar por status de autorização:</label>
40-
<select name="filter_authorized" id="filter_authorized">
41-
<option value="">Todos</option>
42-
<option value="true" {% if filter_authorized == 'true' %}selected{% endif %}>Autorizado</option>
43-
<option value="false" {% if filter_authorized == 'false' %}selected{% endif %}>Não Autorizado</option>
44-
</select>
45-
<br>
15+
<form class="filter-form" method="GET">
16+
<div class="form-group">
17+
<select name="filter_type" id="filter_type">
18+
<option value="">Tipo</option>
19+
<option value="1" {% if filter_type == '1' %}selected{% endif %}>Água</option>
20+
<option value="2" {% if filter_type == '2' %}selected{% endif %}>Energia</option>
21+
<option value="3" {% if filter_type == '3' %}selected{% endif %}>Gás</option>
22+
</select>
23+
</div>
24+
<div class="form-group">
25+
<select name="filter_location" id="filter_location">
26+
<option value="">Localização</option>
27+
{% for location in locations %}
28+
<option value="{{ location }}" {% if filter_location == location %}selected{% endif %}>{{ location }}
29+
</option>
30+
{% endfor %}
31+
</select>
32+
</div>
33+
<div class="form-group">
34+
<select name="filter_section" id="filter_section">
35+
<option value="">Seção</option>
36+
{% for section in sections %}
37+
<option value="{{ section }}" {% if filter_section == section %}selected{% endif %}>{{ section }}</option>
38+
{% endfor %}
39+
</select>
40+
</div>
41+
<div class="form-group">
42+
<select name="filter_authorized" id="filter_authorized">
43+
<option value="">Status</option>
44+
<option value="0" {% if filter_authorized == '0' %}selected{% endif %}>Pendente</option>
45+
<option value="1" {% if filter_authorized == '1' %}selected{% endif %}>Não Autorizado</option>
46+
<option value="2" {% if filter_authorized == '2' %}selected{% endif %}>Autorizado</option>
47+
</select>
48+
</div>
4649
<button type="submit">Filtrar</button>
4750
</form>
4851

@@ -53,7 +56,8 @@ <h1>Dispositivos Cadastrados</h1>
5356
<th>Seção/Localização</th>
5457
<th>Endereço IP</th>
5558
<th>Endereço MAC</th>
56-
<th>Ações</th>
59+
<th>Ver mais</th>
60+
<th>Atualizar</th>
5761
</tr>
5862
</thead>
5963
<tbody>
@@ -64,15 +68,15 @@ <h1>Dispositivos Cadastrados</h1>
6468
<td>{{ device.ip_address }}</td>
6569
<td>{{ device.mac_address }}</td>
6670
<td>
67-
{% if device.is_authorized %}
68-
<a href="{% url 'device_detail' device.id %}">Ver mais</a>
69-
{% else %}
70-
<a href="{% url 'edit_device' device.id %}">Editar</a>
71-
{% endif %}
71+
<a href="{% url 'device_detail' device.id %}"><i class="fas fa-info-circle"></i></a>
7272
</td>
73+
<td>
74+
<a href="{% url 'edit_device' device.id %}"><i class="fas fa-edit"></i></a>
75+
</td>
76+
7377
</tr>
7478
{% endfor %}
7579
</tbody>
7680
</table>
7781
</div>
78-
{% endblock %}
82+
{% endblock %}

app/templates/edit_device.html

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,51 @@
1-
{% extends 'layout.html' %}
1+
{% extends 'sidebar.html' %}
22

33
{% load static %}
44

5-
{% block title %}Morea | Editar Dispositivo{% endblock %}
5+
{% block title %}Morea | Gerenciamento de Dispositivos{% endblock %}
66

77
{% block stylesCustom %}
88
<link rel="stylesheet" href="{% static 'css/edit_device.css' %}" />
99
{% endblock %}
1010

1111
{% block content %}
1212
<div class="container">
13-
<h1>Editar Dispositivo</h1>
14-
13+
<div class="home__content">
14+
<h1>Atualizar Dispositivo</h1>
1515
<form method="POST">
16-
{% csrf_token %}
17-
{{ form.as_p }}
18-
<button type="submit">Salvar</button>
16+
{% csrf_token %}
17+
{% for field in form %}
18+
<div class="form-group">
19+
<label for="{{ field.id_for_label }}">{{ field.label }}</label>
20+
{% if field.name == 'type' %}
21+
<select name="type" id="type" class="form-control">
22+
<option value="">Tipo</option>
23+
<option value="1" {% if field.value == '1' %}selected{% endif %}>Água</option>
24+
<option value="2" {% if field.value == '2' %}selected{% endif %}>Energia</option>
25+
<option value="3" {% if field.value == '3' %}selected{% endif %}>Gás</option>
26+
</select>
27+
{% elif field.name == 'is_authorized' %}
28+
<select name="is_authorized" id="is_authorized" class="form-control">
29+
<option value="">Status</option>
30+
<option value="0" {% if field.value == '0' %}selected{% endif %}>Pendente</option>
31+
<option value="1" {% if field.value == '1' %}selected{% endif %}>Não Autorizado</option>
32+
<option value="2" {% if field.value == '2' %}selected{% endif %}>Autorizado</option>
33+
</select>
34+
{% else %}
35+
{{ field }}
36+
{% endif %}
37+
{% if field.errors %}
38+
<ul class="errors">
39+
{% for error in field.errors %}
40+
<li>{{ error }} <button type="button" class="close-error">x</button></li>
41+
{% endfor %}
42+
</ul>
43+
{% endif %}
44+
</div>
45+
{% endfor %}
46+
<button type="submit" class="buttonMore">Atualizar</button>
1947
</form>
20-
21-
<a href="{% url 'device_list' %}">Voltar para lista de dispositivos</a>
48+
</div>
2249
</div>
50+
<script src="{% static 'js/error.js' %}"></script>
2351
{% endblock %}

0 commit comments

Comments
 (0)