mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-16 10:06:19 +00:00
formatted all files.
This commit is contained in:
@ -22,7 +22,8 @@ class SosDeviceBloc extends Bloc<SosDeviceEvent, SosDeviceState> {
|
||||
|
||||
late SosStatusModel deviceStatus;
|
||||
|
||||
FutureOr<void> _getDeviceStatus(GetDeviceStatus event, Emitter<SosDeviceState> emit) async {
|
||||
FutureOr<void> _getDeviceStatus(
|
||||
GetDeviceStatus event, Emitter<SosDeviceState> emit) async {
|
||||
emit(SosDeviceLoadingState());
|
||||
try {
|
||||
final status = await DevicesManagementApi().getDeviceStatus(event.uuid);
|
||||
@ -33,7 +34,8 @@ class SosDeviceBloc extends Bloc<SosDeviceEvent, SosDeviceState> {
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _getBatchStatus(GetBatchStatus event, Emitter<SosDeviceState> emit) async {
|
||||
FutureOr<void> _getBatchStatus(
|
||||
GetBatchStatus event, Emitter<SosDeviceState> emit) async {
|
||||
emit(SosDeviceLoadingState());
|
||||
try {
|
||||
final status = await DevicesManagementApi().getBatchStatus(event.uuids);
|
||||
@ -44,25 +46,31 @@ class SosDeviceBloc extends Bloc<SosDeviceEvent, SosDeviceState> {
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _getDeviceRecords(GetDeviceRecords event, Emitter<SosDeviceState> emit) async {
|
||||
FutureOr<void> _getDeviceRecords(
|
||||
GetDeviceRecords event, Emitter<SosDeviceState> emit) async {
|
||||
emit(SosReportLoadingState());
|
||||
try {
|
||||
final from = DateTime.now().subtract(const Duration(days: 30)).millisecondsSinceEpoch;
|
||||
final from = DateTime.now()
|
||||
.subtract(const Duration(days: 30))
|
||||
.millisecondsSinceEpoch;
|
||||
final to = DateTime.now().millisecondsSinceEpoch;
|
||||
final DeviceReport records =
|
||||
await DevicesManagementApi.getDeviceReportsByDate(event.uuid, 'sos', from.toString(), to.toString());
|
||||
final records = await DevicesManagementApi.getDeviceReportsByDate(
|
||||
event.uuid, 'sos', from.toString(), to.toString());
|
||||
emit(SosReportLoadedState(records));
|
||||
} catch (e) {
|
||||
emit(SosReportErrorState(e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _getDeviceAutomationRecords(GetDeviceAutomationRecords event, Emitter<SosDeviceState> emit) async {
|
||||
FutureOr<void> _getDeviceAutomationRecords(
|
||||
GetDeviceAutomationRecords event, Emitter<SosDeviceState> emit) async {
|
||||
emit(SosAutomationReportLoadingState());
|
||||
try {
|
||||
final from = DateTime.now().subtract(const Duration(days: 30)).millisecondsSinceEpoch;
|
||||
final from = DateTime.now()
|
||||
.subtract(const Duration(days: 30))
|
||||
.millisecondsSinceEpoch;
|
||||
final to = DateTime.now().millisecondsSinceEpoch;
|
||||
final DeviceReport records = await DevicesManagementApi.getDeviceReportsByDate(
|
||||
final records = await DevicesManagementApi.getDeviceReportsByDate(
|
||||
event.uuid, 'sos_automation', from.toString(), to.toString());
|
||||
emit(SosAutomationReportLoadedState(records));
|
||||
} catch (e) {
|
||||
@ -70,14 +78,17 @@ class SosDeviceBloc extends Bloc<SosDeviceEvent, SosDeviceState> {
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _backToSosStatusView(BackToSosStatusView event, Emitter<SosDeviceState> emit) {
|
||||
FutureOr<void> _backToSosStatusView(
|
||||
BackToSosStatusView event, Emitter<SosDeviceState> emit) {
|
||||
emit(SosDeviceLoadedState(deviceStatus));
|
||||
}
|
||||
|
||||
FutureOr<void> _sosFactoryReset(SosFactoryReset event, Emitter<SosDeviceState> emit) async {
|
||||
FutureOr<void> _sosFactoryReset(
|
||||
SosFactoryReset event, Emitter<SosDeviceState> emit) async {
|
||||
emit(SosDeviceLoadingState());
|
||||
try {
|
||||
final response = await DevicesManagementApi().factoryReset(event.factoryReset, event.deviceId);
|
||||
final response = await DevicesManagementApi()
|
||||
.factoryReset(event.factoryReset, event.deviceId);
|
||||
if (response) {
|
||||
emit(SosDeviceLoadedState(deviceStatus));
|
||||
} else {
|
||||
|
@ -15,7 +15,7 @@ class SosStatusModel {
|
||||
late int batteryLevel;
|
||||
late String sosStatus;
|
||||
|
||||
for (var status in statuses) {
|
||||
for (final status in statuses) {
|
||||
switch (status.code) {
|
||||
case 'battery_percentage':
|
||||
batteryLevel = status.value;
|
||||
|
@ -6,13 +6,12 @@ import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_mo
|
||||
import 'package:syncrow_web/pages/device_managment/shared/icon_name_status_container.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/shared/table/report_table.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/sos/bloc/sos_device_bloc.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/sos/models/sos_status_model.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/sos/widgets/sos_notification_dialog.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||
|
||||
import '../models/sos_status_model.dart';
|
||||
|
||||
class SosDeviceControlsView extends StatelessWidget
|
||||
with HelperResponsiveLayout {
|
||||
const SosDeviceControlsView({
|
||||
@ -56,9 +55,9 @@ class SosDeviceControlsView extends StatelessWidget
|
||||
} else if (state is SosDeviceErrorState) {
|
||||
return const Center(child: Text('Error fetching status'));
|
||||
} else if (state is SosAutomationReportErrorState) {
|
||||
return Center(child: Text('Error: ${state.message.toString()}'));
|
||||
return Center(child: Text('Error: ${state.message}'));
|
||||
} else if (state is SosReportErrorState) {
|
||||
return Center(child: Text('Error: ${state.message.toString()}'));
|
||||
return Center(child: Text('Error: ${state.message}'));
|
||||
}
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
},
|
||||
|
@ -52,7 +52,7 @@ class _NotificationDialogState extends State<SosNotificationDialog> {
|
||||
),
|
||||
),
|
||||
child: IconButton(
|
||||
padding: EdgeInsets.all(1),
|
||||
padding: const EdgeInsets.all(1),
|
||||
icon: const Icon(
|
||||
Icons.close,
|
||||
color: Colors.grey,
|
||||
|
Reference in New Issue
Block a user