mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
Merge pull request #146 from SyncrowIOT/Fix-Factory-Reset-Model
Refactor FactoryResetModel and MainDoorSensorBatchView
This commit is contained in:
@ -19,6 +19,7 @@ class FactoryResetModel {
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'devicesUuid': devicesUuid,
|
||||
'operationType': operationType,
|
||||
};
|
||||
}
|
||||
|
||||
@ -33,6 +34,7 @@ class FactoryResetModel {
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'devicesUuid': devicesUuid,
|
||||
'operationType': operationType,
|
||||
};
|
||||
}
|
||||
|
||||
@ -56,3 +58,4 @@ class FactoryResetModel {
|
||||
@override
|
||||
int get hashCode => devicesUuid.hashCode;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_re
|
||||
import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_bloc.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_event.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart';
|
||||
// import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart';
|
||||
|
||||
class MainDoorSensorBatchView extends StatelessWidget {
|
||||
const MainDoorSensorBatchView({super.key, required this.devicesIds});
|
||||
@ -13,35 +12,31 @@ class MainDoorSensorBatchView extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// SizedBox(
|
||||
// width: 170,
|
||||
// height: 140,
|
||||
// child: FirmwareUpdateWidget(
|
||||
// deviceId: devicesIds.first,
|
||||
// version: 12,
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(
|
||||
// width: 12,
|
||||
// ),
|
||||
SizedBox(
|
||||
width: 170,
|
||||
height: 140,
|
||||
child: FactoryResetWidget(
|
||||
callFactoryReset: () {
|
||||
BlocProvider.of<MainDoorSensorBloc>(context).add(
|
||||
MainDoorSensorFactoryReset(
|
||||
deviceId: devicesIds.first,
|
||||
factoryReset: FactoryResetModel(devicesUuid: devicesIds),
|
||||
return BlocProvider(
|
||||
create: (context) => MainDoorSensorBloc(),
|
||||
child: Builder(
|
||||
builder: (innerContext) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 170,
|
||||
height: 140,
|
||||
child: FactoryResetWidget(
|
||||
callFactoryReset: () {
|
||||
BlocProvider.of<MainDoorSensorBloc>(innerContext).add(
|
||||
MainDoorSensorFactoryReset(
|
||||
deviceId: devicesIds.first,
|
||||
factoryReset: FactoryResetModel(devicesUuid: devicesIds),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -321,13 +321,14 @@ class DevicesManagementApi {
|
||||
Future<bool> factoryReset(FactoryResetModel factoryReset, String uuid) async {
|
||||
try {
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.factoryReset.replaceAll('{deviceUuid}', uuid),
|
||||
path: ApiEndpoints.factoryReset,
|
||||
body: factoryReset.toMap(),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
return json['success'] ?? false;
|
||||
},
|
||||
);
|
||||
|
||||
return response;
|
||||
} catch (e) {
|
||||
debugPrint('Error fetching $e');
|
||||
|
Reference in New Issue
Block a user