Add owner and device type filters to device list

Owner filter uses a server-side substring match (LIKE '%VALUE%');
device type filter matches the stored value exactly, sending an
empty string for unknown/unclassified devices. Both filters combine
with the existing registration status chip via AND logic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
rzuasti
2026-05-27 19:46:19 -04:00
co-authored by Claude Sonnet 4.6
parent bf74cbb38e
commit e7d075ec29
3 changed files with 135 additions and 30 deletions
+11 -1
View File
@@ -5,6 +5,7 @@ import 'package:encrypter/encrypter/xor.dart';
import 'package:flutter/foundation.dart';
import 'package:frontend/utils/pref_utils.dart';
import '../model/device.dart';
import '../model/device_type.dart';
import '../model/notification.dart';
class BackendAPI {
@@ -90,11 +91,20 @@ class BackendAPI {
return Device.fromJson(response.data as Map<String, dynamic>);
}
Future<List<Device>> listDevices({bool? isRegistered}) async {
Future<List<Device>> listDevices({
bool? isRegistered,
String? owner,
DeviceType? deviceType,
}) async {
debugPrint('About to call /devices');
final params = <String, dynamic>{};
if (isRegistered != null) params['is_registered'] = isRegistered;
if (owner != null && owner.isNotEmpty) params['owner'] = owner;
if (deviceType != null) {
params['device_type'] =
deviceType == DeviceType.unknown ? '' : deviceType.name;
}
final response = await _dio.get('/devices', queryParameters: params);