-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplantas.html
173 lines (158 loc) · 7.89 KB
/
plantas.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<!doctype html>
<html lang="es">
<head>
<title>Panel de control - Plantas - Rincón Botánico</title>
<link rel="shortcut icon" href="./img/Logo.ico">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-iYQeCzEYFbKjA/T2uDLTpkwGzCiq6soy8tYaI1GyVh/UjpbCx/TYkiZhlZB6+fzT" crossorigin="anonymous">
<link rel="stylesheet" href="css/estilos.css">
<script>
document.addEventListener('DOMContentLoaded', function () {
const userRole = sessionStorage.getItem('userRole');
if (userRole === 'readonly') {
document.querySelector('.btn-success').style.display = 'none';
document.querySelectorAll('.btn-warning, .btn-danger').forEach(button => {
button.style.display = 'none';
});
}
});
</script>
</head>
<body>
<header class="header">
<nav class="navbar navbar-expand-lg navbar-dark navbar-custom">
<div class="container-fluid">
<a class="navbar-brand" href="index.html" target="_blank">
Rincón Botánico
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button"
data-bs-toggle="dropdown" aria-expanded="false">
Panel de Control
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="usuarios.html">Usuarios</a></li>
<li><a class="dropdown-item" href="plantas.html">Plantas</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<!-- Mostrar usuario y rol -->
<div class="user-info">
<div>
<p>Usuario: </p>
<p>Rol: </p>
</div>
<div>
<p class="username" id="username"> ${usuarioValido.usuario}</p>
<p class="userrole" id="userrole">Rol: ${storedUserRole}</p>
</div>
</div>
</header>
<main>
<div id="app" class="container">
<h1>Panel de Control de Plantas</h1>
<br>
<a v-if="userRole !== 'readonly'" class="btn btn-success" href="planta_nuevo.html">Nuevo</a>
<br><br>
<div v-if="error">
<p>Lo sentimos , ........</p>
</div>
<div v-else>
<section v-if="cargando">
<div class="spinner-border"></div>
<p>Cargando .....</p>
</section>
<section v-else>
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">Id</th>
<th scope="col">Nombre</th>
<th scope="col">Categoría</th>
<th scope="col">Ubicación</th>
<th scope="col">Sustrato</th>
<th scope="col">Riego</th>
<th scope="col">Floración</th>
<th scope="col">Tamaño</th>
<th scope="col">Descripción</th>
<th scope="col">Imagen</th>
<th scope="col">Acciones</th>
</tr>
</thead>
<tbody>
<tr class="" v-for="planta in plantas">
<td scope="row">{{planta.id}}</td>
<td>{{planta.nombre}}</td>
<td>{{planta.categoria}}</td>
<td>{{planta.ubicacion}}</td>
<td>{{planta.sustrato}}</td>
<td>{{planta.riego}}</td>
<td>{{planta.floracion}}</td>
<td>{{planta.tamano}}</td>
<td>{{planta.descripcion}}</td>
<td>
<img width="60" :src="planta.imagen" :alt="planta.nombre">
</td>
<td>
<a v-if="userRole !== 'readonly'" class="btn btn-warning"
:href="'planta_update.html?id='+ planta.id">Editar</a>
<button v-if="userRole !== 'readonly' "type="button" class="btn btn-danger"
v-on:click="eliminar(planta.id)">Eliminar</button>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</div>
</div>∫
</main>
<footer class="footer">
<!-- place footer here -->
</footer>
<script>
// Mostrar datos del usuario desde sessionStorage
document.getElementById('username').textContent = sessionStorage.getItem('username');
document.getElementById('userrole').textContent = sessionStorage.getItem('userRole');
</script>
<script>
document.addEventListener('DOMContentLoaded', function () {
const userRole = sessionStorage.getItem('userRole');
if (userRole === 'readonly') {
// Deshabilitar todas las opciones de edición
const editButtons = document.querySelectorAll('.edit-button');
editButtons.forEach(button => button.disabled = true);
const deleteButtons = document.querySelectorAll('.delete-button');
deleteButtons.forEach(button => button.disabled = true);
const addButton = document.getElementById('add-button');
if (addButton) {
addButton.disabled = true;
}
}
});
</script>
<!--Link de Bootstrap-->
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"
integrity="sha384-oBqDVmMz9ATKxIep9tiCxS/Z9fNfEXiDAYTujMAeBAsjFuCZSmKbSSUnQlmh/jp3"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"
integrity="sha384-7VPbUDkoPSGFnVtYi0QogXtr74QeVeeIs99Qfg5YCF+TidwNdjvaKZX19NZ/e6oz"
crossorigin="anonymous"></script>
<script src="./js/main.js"></script>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script><!--Link de VUE-->
<script src="./js/plantas.js"></script>
</body>
</html>