Fix jwt-token
This commit is contained in:
@@ -545,15 +545,21 @@ const DeviceModal = ({ device, onClose, onSave }) => {
|
||||
|
||||
try {
|
||||
if (device) {
|
||||
// Update existing device
|
||||
await api.put(`/devices/${device.id}`, formData);
|
||||
// Update existing device - exclude read-only fields
|
||||
const updateData = {
|
||||
name: formData.name,
|
||||
location_description: formData.location_description,
|
||||
notes: formData.notes
|
||||
};
|
||||
await api.put(`/devices/${device.id}`, updateData);
|
||||
} else {
|
||||
// Create new device
|
||||
// Create new device - include all fields
|
||||
await api.post('/devices', formData);
|
||||
}
|
||||
onSave();
|
||||
} catch (error) {
|
||||
console.error('Error saving device:', error);
|
||||
alert('Error saving device: ' + (error.response?.data?.message || error.message));
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
@@ -614,28 +620,40 @@ const DeviceModal = ({ device, onClose, onSave }) => {
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<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>
|
||||
<input
|
||||
type="number"
|
||||
step="any"
|
||||
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}
|
||||
onChange={handleChange}
|
||||
disabled={!!device}
|
||||
readOnly={!!device}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<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>
|
||||
<input
|
||||
type="number"
|
||||
step="any"
|
||||
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}
|
||||
onChange={handleChange}
|
||||
disabled={!!device}
|
||||
readOnly={!!device}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -655,16 +673,22 @@ const DeviceModal = ({ device, onClose, onSave }) => {
|
||||
|
||||
<div>
|
||||
<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>
|
||||
<input
|
||||
type="number"
|
||||
name="heartbeat_interval"
|
||||
min="60"
|
||||
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}
|
||||
onChange={handleChange}
|
||||
disabled={!!device}
|
||||
readOnly={!!device}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user