Uniformizar layout das páginas
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
|
import PageLayout from '../components/PageLayout';
|
||||||
|
|
||||||
const Dashboard = () => {
|
const Dashboard = () => {
|
||||||
// Estados para armazenar os dados do dashboard
|
// Estados para armazenar os dados do dashboard
|
||||||
@@ -34,8 +35,7 @@ const Dashboard = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="max-w-3xl mx-auto p-5">
|
<PageLayout title="Visão Geral">
|
||||||
<h1 className="text-2xl font-bold mb-5">Visão Geral</h1>
|
|
||||||
|
|
||||||
{/* Cards com informações resumidas */}
|
{/* Cards com informações resumidas */}
|
||||||
<div className="flex flex-wrap gap-4 mb-6">
|
<div className="flex flex-wrap gap-4 mb-6">
|
||||||
@@ -89,7 +89,7 @@ const Dashboard = () => {
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</PageLayout>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// src/pages/Security.jsx
|
// src/pages/Security.jsx
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
import PageLayout from '../components/PageLayout';
|
||||||
|
|
||||||
const Security = () => {
|
const Security = () => {
|
||||||
// Estado para armazenar se MFA está habilitado e os métodos de autenticação
|
// Estado para armazenar se MFA está habilitado e os métodos de autenticação
|
||||||
@@ -31,8 +32,7 @@ const Security = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="max-w-xl mx-auto p-5 bg-white rounded shadow">
|
<PageLayout title="Segurança">
|
||||||
<h1 className="text-2xl font-bold mb-5 text-center">Segurança</h1>
|
|
||||||
|
|
||||||
{/* Métodos de Autorização */}
|
{/* Métodos de Autorização */}
|
||||||
<div className="mb-5">
|
<div className="mb-5">
|
||||||
@@ -94,7 +94,7 @@ const Security = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</PageLayout>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
|
import PageLayout from '../components/PageLayout';
|
||||||
|
|
||||||
const Settings = () => {
|
const Settings = () => {
|
||||||
// Estados para armazenar os valores dos sliders e caixas de entrada
|
// Estados para armazenar os valores dos sliders e caixas de entrada
|
||||||
@@ -7,6 +8,8 @@ const Settings = () => {
|
|||||||
const [energyLimit, setEnergyLimit] = useState(0);
|
const [energyLimit, setEnergyLimit] = useState(0);
|
||||||
const [chargingTimeLimit, setChargingTimeLimit] = useState(0);
|
const [chargingTimeLimit, setChargingTimeLimit] = useState(0);
|
||||||
const [temperatureLimit, setTemperatureLimit] = useState(60);
|
const [temperatureLimit, setTemperatureLimit] = useState(60);
|
||||||
|
const [msg, setMsg] = useState('');
|
||||||
|
const [error, setError] = useState('');
|
||||||
|
|
||||||
// Função para preencher os campos com os dados do servidor
|
// Função para preencher os campos com os dados do servidor
|
||||||
const fetchSettings = async () => {
|
const fetchSettings = async () => {
|
||||||
@@ -34,7 +37,8 @@ const Settings = () => {
|
|||||||
const handleChargingTimeLimitChange = (e) => setChargingTimeLimit(e.target.value);
|
const handleChargingTimeLimitChange = (e) => setChargingTimeLimit(e.target.value);
|
||||||
const handleTemperatureLimitChange = (e) => setTemperatureLimit(e.target.value);
|
const handleTemperatureLimitChange = (e) => setTemperatureLimit(e.target.value);
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
const settingsData = {
|
const settingsData = {
|
||||||
currentLimit,
|
currentLimit,
|
||||||
powerLimit,
|
powerLimit,
|
||||||
@@ -43,70 +47,91 @@ const Settings = () => {
|
|||||||
temperatureLimit,
|
temperatureLimit,
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await fetch('/api/v1/config/settings', {
|
try {
|
||||||
method: 'POST',
|
const response = await fetch('/api/v1/config/settings', {
|
||||||
headers: {
|
method: 'POST',
|
||||||
'Content-Type': 'application/json',
|
headers: {
|
||||||
},
|
'Content-Type': 'application/json',
|
||||||
body: JSON.stringify(settingsData),
|
},
|
||||||
});
|
body: JSON.stringify(settingsData),
|
||||||
|
});
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
alert('Configurações de energia atualizadas com sucesso!');
|
setMsg('Configurações de energia atualizadas com sucesso!');
|
||||||
} else {
|
} else {
|
||||||
alert('Erro ao atualizar configurações');
|
setError('Erro ao atualizar configurações');
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
setError('Erro ao atualizar configurações');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<PageLayout title="Definições de Energia">
|
||||||
<label>
|
{msg && <div className="p-2 mb-2 bg-green-600 text-white rounded">{msg}</div>}
|
||||||
Current Limit:
|
{error && <div className="p-2 mb-2 bg-red-600 text-white rounded">{error}</div>}
|
||||||
<input
|
|
||||||
type="number"
|
<form className="flex flex-col gap-4" onSubmit={handleSubmit}>
|
||||||
value={currentLimit}
|
<div>
|
||||||
onChange={handleCurrentLimitChange}
|
<label className="block mb-1" htmlFor="currentLimit">Limite de Corrente (A):</label>
|
||||||
/>
|
<input
|
||||||
</label>
|
id="currentLimit"
|
||||||
<br />
|
type="number"
|
||||||
<label>
|
className="border border-gray-300 rounded px-3 py-2 w-full"
|
||||||
Power Limit:
|
value={currentLimit}
|
||||||
<input
|
onChange={handleCurrentLimitChange}
|
||||||
type="number"
|
/>
|
||||||
value={powerLimit}
|
</div>
|
||||||
onChange={handlePowerLimitChange}
|
|
||||||
/>
|
<div>
|
||||||
</label>
|
<label className="block mb-1" htmlFor="powerLimit">Limite de Potência (W):</label>
|
||||||
<br />
|
<input
|
||||||
<label>
|
id="powerLimit"
|
||||||
Energy Limit:
|
type="number"
|
||||||
<input
|
className="border border-gray-300 rounded px-3 py-2 w-full"
|
||||||
type="number"
|
value={powerLimit}
|
||||||
value={energyLimit}
|
onChange={handlePowerLimitChange}
|
||||||
onChange={handleEnergyLimitChange}
|
/>
|
||||||
/>
|
</div>
|
||||||
</label>
|
|
||||||
<br />
|
<div>
|
||||||
<label>
|
<label className="block mb-1" htmlFor="energyLimit">Limite de Energia (kWh):</label>
|
||||||
Charging Time Limit:
|
<input
|
||||||
<input
|
id="energyLimit"
|
||||||
type="number"
|
type="number"
|
||||||
value={chargingTimeLimit}
|
className="border border-gray-300 rounded px-3 py-2 w-full"
|
||||||
onChange={handleChargingTimeLimitChange}
|
value={energyLimit}
|
||||||
/>
|
onChange={handleEnergyLimitChange}
|
||||||
</label>
|
/>
|
||||||
<br />
|
</div>
|
||||||
<label>
|
|
||||||
Temperature Limit:
|
<div>
|
||||||
<input
|
<label className="block mb-1" htmlFor="chargingTimeLimit">Tempo Máximo de Carregamento (min):</label>
|
||||||
type="number"
|
<input
|
||||||
value={temperatureLimit}
|
id="chargingTimeLimit"
|
||||||
onChange={handleTemperatureLimitChange}
|
type="number"
|
||||||
/>
|
className="border border-gray-300 rounded px-3 py-2 w-full"
|
||||||
</label>
|
value={chargingTimeLimit}
|
||||||
<br />
|
onChange={handleChargingTimeLimitChange}
|
||||||
<button onClick={handleSubmit}>Save Settings</button>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label className="block mb-1" htmlFor="temperatureLimit">Temperatura Máxima (°C):</label>
|
||||||
|
<input
|
||||||
|
id="temperatureLimit"
|
||||||
|
type="number"
|
||||||
|
className="border border-gray-300 rounded px-3 py-2 w-full"
|
||||||
|
value={temperatureLimit}
|
||||||
|
onChange={handleTemperatureLimitChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<button className="bg-green-600 text-white px-4 py-2 rounded hover:bg-green-700" type="submit">Guardar</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</PageLayout>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user