Fix jwt-token
This commit is contained in:
@@ -545,15 +545,21 @@ const DeviceModal = ({ device, onClose, onSave }) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (device) {
|
if (device) {
|
||||||
// Update existing device
|
// Update existing device - exclude read-only fields
|
||||||
await api.put(`/devices/${device.id}`, formData);
|
const updateData = {
|
||||||
|
name: formData.name,
|
||||||
|
location_description: formData.location_description,
|
||||||
|
notes: formData.notes
|
||||||
|
};
|
||||||
|
await api.put(`/devices/${device.id}`, updateData);
|
||||||
} else {
|
} else {
|
||||||
// Create new device
|
// Create new device - include all fields
|
||||||
await api.post('/devices', formData);
|
await api.post('/devices', formData);
|
||||||
}
|
}
|
||||||
onSave();
|
onSave();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error saving device:', error);
|
console.error('Error saving device:', error);
|
||||||
|
alert('Error saving device: ' + (error.response?.data?.message || error.message));
|
||||||
} finally {
|
} finally {
|
||||||
setSaving(false);
|
setSaving(false);
|
||||||
}
|
}
|
||||||
@@ -614,28 +620,40 @@ const DeviceModal = ({ device, onClose, onSave }) => {
|
|||||||
<div className="grid grid-cols-2 gap-4">
|
<div className="grid grid-cols-2 gap-4">
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||||
Latitude
|
Latitude {device && <span className="text-xs text-gray-500">(read-only)</span>}
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
step="any"
|
step="any"
|
||||||
name="geo_lat"
|
name="geo_lat"
|
||||||
className="w-full border border-gray-300 rounded-md px-3 py-2 focus:ring-primary-500 focus:border-primary-500"
|
className={`w-full border border-gray-300 rounded-md px-3 py-2 ${
|
||||||
|
device
|
||||||
|
? 'bg-gray-100 cursor-not-allowed'
|
||||||
|
: 'focus:ring-primary-500 focus:border-primary-500'
|
||||||
|
}`}
|
||||||
value={formData.geo_lat}
|
value={formData.geo_lat}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
disabled={!!device}
|
||||||
|
readOnly={!!device}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||||
Longitude
|
Longitude {device && <span className="text-xs text-gray-500">(read-only)</span>}
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
step="any"
|
step="any"
|
||||||
name="geo_lon"
|
name="geo_lon"
|
||||||
className="w-full border border-gray-300 rounded-md px-3 py-2 focus:ring-primary-500 focus:border-primary-500"
|
className={`w-full border border-gray-300 rounded-md px-3 py-2 ${
|
||||||
|
device
|
||||||
|
? 'bg-gray-100 cursor-not-allowed'
|
||||||
|
: 'focus:ring-primary-500 focus:border-primary-500'
|
||||||
|
}`}
|
||||||
value={formData.geo_lon}
|
value={formData.geo_lon}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
disabled={!!device}
|
||||||
|
readOnly={!!device}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -655,16 +673,22 @@ const DeviceModal = ({ device, onClose, onSave }) => {
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||||
Heartbeat Interval (seconds)
|
Heartbeat Interval (seconds) {device && <span className="text-xs text-gray-500">(read-only)</span>}
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
name="heartbeat_interval"
|
name="heartbeat_interval"
|
||||||
min="60"
|
min="60"
|
||||||
max="3600"
|
max="3600"
|
||||||
className="w-full border border-gray-300 rounded-md px-3 py-2 focus:ring-primary-500 focus:border-primary-500"
|
className={`w-full border border-gray-300 rounded-md px-3 py-2 ${
|
||||||
|
device
|
||||||
|
? 'bg-gray-100 cursor-not-allowed'
|
||||||
|
: 'focus:ring-primary-500 focus:border-primary-500'
|
||||||
|
}`}
|
||||||
value={formData.heartbeat_interval}
|
value={formData.heartbeat_interval}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
disabled={!!device}
|
||||||
|
readOnly={!!device}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user