mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Align frontend device types with backend canonical list
Replaces the old frontend-only `router` type and adds the full set used by the backend: network_appliance, home_security, home_appliance, watch, pc, gaming_console. Adds an `apiName` getter to map camelCase enum values to the snake_case strings the API expects. Updates the unknown device icon to a question mark. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
23b8858259
commit
e28eb349ba
@@ -24,8 +24,8 @@
|
|||||||
- [x] Use date filter from backend API for device events list
|
- [x] Use date filter from backend API for device events list
|
||||||
- [x] Use favicon in web frontend
|
- [x] Use favicon in web frontend
|
||||||
- [x] Style app title like favicon (font Barlow Condensed in a pill format with "primary" background)
|
- [x] Style app title like favicon (font Barlow Condensed in a pill format with "primary" background)
|
||||||
- [ ] Update the device type management to consider the following list: phone, laptop, tablet, server, tv, printer, network_appliance (router, switch, firewall, etc.), home_security (camera, doorbell, etc.), home_appliance (fridge, dish washer, washer, dryer, etc.), watch, pc, gaming_console, unknown (use when a vendor cannot be clearly identified with any of the device types or a device is of a vendor not in the vendors json file)
|
- [x] Update the device type management to consider the following list: phone, laptop, tablet, server, tv, printer, network_appliance (router, switch, firewall, etc.), home_security (camera, doorbell, etc.), home_appliance (fridge, dish washer, washer, dryer, etc.), watch, pc, gaming_console, unknown (use when a vendor cannot be clearly identified with any of the device types or a device is of a vendor not in the vendors json file)
|
||||||
- [ ] Change the unkown device icon (maybe just a question mark)
|
- [x] Change the unkown device icon (maybe just a question mark)
|
||||||
- [ ] Scan process monitor and summary page
|
- [ ] Scan process monitor and summary page
|
||||||
- [ ] Is the scan process running
|
- [ ] Is the scan process running
|
||||||
- [ ] Last run (when, how long did it take, how many devices did it found)
|
- [ ] Last run (when, how long did it take, how many devices did it found)
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ Future<void> showRegisterDeviceDialog(
|
|||||||
await BackendAPI.instance.registerDevice(
|
await BackendAPI.instance.registerDevice(
|
||||||
device.macAddress,
|
device.macAddress,
|
||||||
owner,
|
owner,
|
||||||
deviceType.name,
|
deviceType.apiName,
|
||||||
);
|
);
|
||||||
if (!context.mounted) return;
|
if (!context.mounted) return;
|
||||||
UISnackbars.showSuccess(context, 'Device registered');
|
UISnackbars.showSuccess(context, 'Device registered');
|
||||||
|
|||||||
@@ -5,9 +5,14 @@ enum DeviceType {
|
|||||||
laptop,
|
laptop,
|
||||||
tablet,
|
tablet,
|
||||||
server,
|
server,
|
||||||
router,
|
|
||||||
tv,
|
tv,
|
||||||
printer,
|
printer,
|
||||||
|
networkAppliance,
|
||||||
|
homeSecurity,
|
||||||
|
homeAppliance,
|
||||||
|
watch,
|
||||||
|
pc,
|
||||||
|
gamingConsole,
|
||||||
unknown;
|
unknown;
|
||||||
|
|
||||||
IconData get icon => switch (this) {
|
IconData get icon => switch (this) {
|
||||||
@@ -15,23 +20,50 @@ enum DeviceType {
|
|||||||
laptop => Icons.laptop,
|
laptop => Icons.laptop,
|
||||||
tablet => Icons.tablet_android,
|
tablet => Icons.tablet_android,
|
||||||
server => Icons.dns,
|
server => Icons.dns,
|
||||||
router => Icons.router,
|
|
||||||
tv => Icons.tv,
|
tv => Icons.tv,
|
||||||
printer => Icons.print,
|
printer => Icons.print,
|
||||||
unknown => Icons.device_unknown,
|
networkAppliance => Icons.device_hub,
|
||||||
|
homeSecurity => Icons.security,
|
||||||
|
homeAppliance => Icons.kitchen,
|
||||||
|
watch => Icons.watch,
|
||||||
|
pc => Icons.computer,
|
||||||
|
gamingConsole => Icons.sports_esports,
|
||||||
|
unknown => Icons.question_mark,
|
||||||
};
|
};
|
||||||
|
|
||||||
String get label =>
|
String get label => switch (this) {
|
||||||
this == unknown ? 'Unknown' : name[0].toUpperCase() + name.substring(1);
|
tv => 'TV',
|
||||||
|
pc => 'PC',
|
||||||
|
_ =>
|
||||||
|
name
|
||||||
|
.replaceAllMapped(RegExp(r'[A-Z]'), (m) => ' ${m.group(0)}')
|
||||||
|
.trim()
|
||||||
|
.split(' ')
|
||||||
|
.map((w) => w[0].toUpperCase() + w.substring(1))
|
||||||
|
.join(' '),
|
||||||
|
};
|
||||||
|
|
||||||
|
String get apiName => switch (this) {
|
||||||
|
networkAppliance => 'network_appliance',
|
||||||
|
homeSecurity => 'home_security',
|
||||||
|
homeAppliance => 'home_appliance',
|
||||||
|
gamingConsole => 'gaming_console',
|
||||||
|
_ => name,
|
||||||
|
};
|
||||||
|
|
||||||
static DeviceType fromString(String value) => switch (value.toLowerCase()) {
|
static DeviceType fromString(String value) => switch (value.toLowerCase()) {
|
||||||
'phone' => phone,
|
'phone' => phone,
|
||||||
'laptop' => laptop,
|
'laptop' => laptop,
|
||||||
'tablet' => tablet,
|
'tablet' => tablet,
|
||||||
'server' => server,
|
'server' => server,
|
||||||
'router' => router,
|
|
||||||
'tv' => tv,
|
'tv' => tv,
|
||||||
'printer' => printer,
|
'printer' => printer,
|
||||||
|
'network_appliance' => networkAppliance,
|
||||||
|
'home_security' => homeSecurity,
|
||||||
|
'home_appliance' => homeAppliance,
|
||||||
|
'watch' => watch,
|
||||||
|
'pc' => pc,
|
||||||
|
'gaming_console' => gamingConsole,
|
||||||
_ => unknown,
|
_ => unknown,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class BackendAPI {
|
|||||||
if (owner != null && owner.isNotEmpty) params['owner'] = owner;
|
if (owner != null && owner.isNotEmpty) params['owner'] = owner;
|
||||||
if (deviceType != null) {
|
if (deviceType != null) {
|
||||||
params['device_type'] =
|
params['device_type'] =
|
||||||
deviceType == DeviceType.unknown ? '' : deviceType.name;
|
deviceType == DeviceType.unknown ? '' : deviceType.apiName;
|
||||||
}
|
}
|
||||||
|
|
||||||
final response = await _dio.get('/devices', queryParameters: params);
|
final response = await _dio.get('/devices', queryParameters: params);
|
||||||
|
|||||||
Reference in New Issue
Block a user