mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Add permanent device deletion and refine frontend UI/snackbars
Backend:
- Add db::devices::delete to erase a device and its events atomically
- Expose DELETE /api/devices/{mac}/permanently, wired to OpenAPI
- Cover the new db method and endpoint with tests
Frontend:
- Delete action for not-registered devices (detail screen + list row)
and an opt-in "permanently delete" checkbox in the Forget dialog
- Navigate to the devices list after deleting from the detail screen
- Refine button emphasis to M3: single filled primary, error-colored
text buttons for destructive actions, Test demoted to filled-tonal
- Flash the backend-config Test button red on a failed connection test
- Render snackbars through a top-level ScaffoldMessenger host so they
show above dialogs; keep the built-in SnackBar (with an Overlay host)
Docs:
- CLAUDE.md: rustfmt edition 2024, don't revert formatter-only changes,
prefer built-in Flutter components, follow existing patterns + M3
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
2541d0989c
commit
587e097291
@@ -4,6 +4,7 @@ import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../model/device.dart';
|
||||
import '../model/device_type.dart';
|
||||
import '../routes.dart';
|
||||
import '../utils/friendly_date_formatter.dart';
|
||||
import '../utils/oott_api.dart';
|
||||
import '../widgets/status_badge.dart';
|
||||
@@ -220,41 +221,57 @@ class _DeviceActions extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
final destructiveStyle = TextButton.styleFrom(
|
||||
foregroundColor: colorScheme.error,
|
||||
);
|
||||
|
||||
if (device.isRegistered) {
|
||||
return Wrap(
|
||||
spacing: 12,
|
||||
runSpacing: 12,
|
||||
return Row(
|
||||
children: [
|
||||
FilledButton.icon(
|
||||
onPressed: () => showEditDeviceDialog(context, device, onAction),
|
||||
icon: const Icon(Icons.edit),
|
||||
label: const Text('Edit'),
|
||||
),
|
||||
OutlinedButton.icon(
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: colorScheme.error,
|
||||
side: BorderSide(color: colorScheme.error),
|
||||
const Spacer(),
|
||||
TextButton.icon(
|
||||
style: destructiveStyle,
|
||||
onPressed: () => confirmForgetDevice(
|
||||
context,
|
||||
device,
|
||||
onAction,
|
||||
onDeleted: () => context.go(Routes.devices),
|
||||
),
|
||||
onPressed: () => confirmForgetDevice(context, device, onAction),
|
||||
icon: const Icon(Icons.link_off),
|
||||
label: const Text('Forget Device'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return Wrap(
|
||||
spacing: 12,
|
||||
runSpacing: 12,
|
||||
return Row(
|
||||
children: [
|
||||
FilledButton.icon(
|
||||
onPressed: () => showRegisterDeviceDialog(context, device, onAction),
|
||||
icon: const Icon(Icons.how_to_reg),
|
||||
label: const Text('Register Device'),
|
||||
),
|
||||
OutlinedButton.icon(
|
||||
const SizedBox(width: Insets.md),
|
||||
TextButton.icon(
|
||||
onPressed: () => showDeviceIdentificationDialog(context, device),
|
||||
icon: const Icon(Icons.help_outline),
|
||||
label: const Text('How to identify this device'),
|
||||
label: const Text('How to identify'),
|
||||
),
|
||||
const Spacer(),
|
||||
TextButton.icon(
|
||||
style: destructiveStyle,
|
||||
onPressed: () => confirmDeleteDevice(
|
||||
context,
|
||||
device,
|
||||
onAction,
|
||||
onDeleted: () => context.go(Routes.devices),
|
||||
),
|
||||
icon: const Icon(Icons.delete_outline),
|
||||
label: const Text('Delete'),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user