diff --git a/lib/pages/device_managment/all_devices/bloc/device_managment_bloc.dart b/lib/pages/device_managment/all_devices/bloc/device_managment_bloc.dart index cb5b427f..628e2d5f 100644 --- a/lib/pages/device_managment/all_devices/bloc/device_managment_bloc.dart +++ b/lib/pages/device_managment/all_devices/bloc/device_managment_bloc.dart @@ -6,7 +6,8 @@ import 'package:syncrow_web/services/devices_mang_api.dart'; part 'device_managment_event.dart'; part 'device_managment_state.dart'; -class DeviceManagementBloc extends Bloc { +class DeviceManagementBloc + extends Bloc { int _selectedIndex = 0; List _devices = []; int _onlineCount = 0; @@ -29,7 +30,8 @@ class DeviceManagementBloc extends Bloc(_onUpdateSelection); } - Future _onFetchDevices(FetchDevices event, Emitter emit) async { + Future _onFetchDevices( + FetchDevices event, Emitter emit) async { emit(DeviceManagementLoading()); try { final devices = await DevicesManagementApi().fetchDevices(); @@ -51,7 +53,8 @@ class DeviceManagementBloc extends Bloc emit) async { + void _onFilterDevices( + FilterDevices event, Emitter emit) async { if (_devices.isNotEmpty) { _filteredDevices = List.from(_devices.where((device) { switch (event.filter) { @@ -82,7 +85,8 @@ class DeviceManagementBloc extends Bloc _onResetFilters(ResetFilters event, Emitter emit) async { + Future _onResetFilters( + ResetFilters event, Emitter emit) async { currentProductName = ''; _selectedDevices.clear(); _filteredDevices = List.from(_devices); @@ -98,7 +102,8 @@ class DeviceManagementBloc extends Bloc emit) { + void _onResetSelectedDevices( + ResetSelectedDevices event, Emitter emit) { _selectedDevices.clear(); if (state is DeviceManagementLoaded) { @@ -124,12 +129,14 @@ class DeviceManagementBloc extends Bloc emit) { + void _onSelectedFilterChanged( + SelectedFilterChanged event, Emitter emit) { _selectedIndex = event.selectedIndex; add(FilterDevices(_getFilterFromIndex(_selectedIndex))); } - void _onSelectDevice(SelectDevice event, Emitter emit) { + void _onSelectDevice( + SelectDevice event, Emitter emit) { final selectedUuid = event.selectedDevice.uuid; if (_selectedDevices.any((device) => device.uuid == selectedUuid)) { @@ -140,7 +147,8 @@ class DeviceManagementBloc extends Bloc clonedSelectedDevices = List.from(_selectedDevices); - bool isControlButtonEnabled = _checkIfControlButtonEnabled(clonedSelectedDevices); + bool isControlButtonEnabled = + _checkIfControlButtonEnabled(clonedSelectedDevices); if (state is DeviceManagementLoaded) { emit(DeviceManagementLoaded( @@ -149,7 +157,8 @@ class DeviceManagementBloc extends Bloc emit) { + void _onUpdateSelection( + UpdateSelection event, Emitter emit) { List selectedDevices = []; List devicesToSelectFrom = []; @@ -208,7 +219,8 @@ class DeviceManagementBloc extends Bloc selectedDevices) { if (selectedDevices.length > 1) { - final productTypes = selectedDevices.map((device) => device.productType).toSet(); + final productTypes = + selectedDevices.map((device) => device.productType).toSet(); return productTypes.length == 1; } else if (selectedDevices.length == 1) { return true; @@ -219,8 +231,10 @@ class DeviceManagementBloc extends Bloc device.online == true).length; _offlineCount = _devices.where((device) => device.online == false).length; - _lowBatteryCount = - _devices.where((device) => device.batteryLevel != null && device.batteryLevel! < 20).length; + _lowBatteryCount = _devices + .where((device) => + device.batteryLevel != null && device.batteryLevel! < 20) + .length; } String _getFilterFromIndex(int index) { @@ -236,7 +250,8 @@ class DeviceManagementBloc extends Bloc emit) { + void _onSearchDevices( + SearchDevices event, Emitter emit) { if ((event.community == null || event.community!.isEmpty) && (event.unitName == null || event.unitName!.isEmpty) && (event.productName == null || event.productName!.isEmpty)) { @@ -265,19 +280,32 @@ class DeviceManagementBloc extends Bloc with HelperRe children: [ _buildSearchField("Community", communityController, 200), const SizedBox(width: 20), - _buildSearchField("Unit Name", unitNameController, 200), + _buildSearchField("Space Name", unitNameController, 200), const SizedBox(width: 20), _buildSearchField("Device Name / Product Name", productNameController, 300), const SizedBox(width: 20), @@ -48,7 +48,7 @@ class _DeviceSearchFiltersState extends State with HelperRe communityController, 200, ), - _buildSearchField("Unit Name", unitNameController, 200), + _buildSearchField("Space Name", unitNameController, 200), _buildSearchField( "Device Name / Product Name", productNameController, diff --git a/lib/pages/device_managment/shared/device_control_dialog.dart b/lib/pages/device_managment/shared/device_control_dialog.dart index 14878a46..660e654b 100644 --- a/lib/pages/device_managment/shared/device_control_dialog.dart +++ b/lib/pages/device_managment/shared/device_control_dialog.dart @@ -94,7 +94,7 @@ class DeviceControlDialog extends StatelessWidget with RouteControlsBasedCode { ]), TableRow( children: [ - _buildInfoRow('Unit Name:', device.unit?.name ?? 'N/A'), + _buildInfoRow('Space Name:', device.unit?.name ?? 'N/A'), _buildInfoRow('Room:', device.room?.name ?? 'N/A'), ], ), diff --git a/lib/pages/visitor_password/view/add_device_dialog.dart b/lib/pages/visitor_password/view/add_device_dialog.dart index 5a4a4785..ebc41292 100644 --- a/lib/pages/visitor_password/view/add_device_dialog.dart +++ b/lib/pages/visitor_password/view/add_device_dialog.dart @@ -111,7 +111,7 @@ class AddDeviceDialog extends StatelessWidget { child: CustomWebTextField( controller: visitorBloc.unitNameController, isRequired: false, - textFieldName: 'Unit Name', + textFieldName: 'Space Name', description: '', ), ), @@ -185,7 +185,7 @@ class AddDeviceDialog extends StatelessWidget { 'Device Name', 'Device ID', 'Access Type', - 'Unit Name', + 'Space Name', 'Status' ], data: state.data.map((item) {