mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
fixed report table
This commit is contained in:
@ -82,7 +82,7 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
|
||||
const SizedBox(height: 20),
|
||||
Expanded(
|
||||
child: DynamicTable(
|
||||
uuidIndex: 0,
|
||||
uuidIndex: 1,
|
||||
isEmpty: filteredData.isEmpty,
|
||||
withCheckBox: false,
|
||||
size: MediaQuery.of(context).size,
|
||||
|
@ -6,6 +6,8 @@ import 'package:syncrow_web/pages/device_managment/shared/table/table_header.dar
|
||||
|
||||
class ReportsTable extends StatelessWidget {
|
||||
final DeviceReport report;
|
||||
final String? thirdColumnTitle;
|
||||
final String? thirdColumnDescription;
|
||||
final Function(int index) onRowTap;
|
||||
final VoidCallback onClose;
|
||||
|
||||
@ -14,6 +16,8 @@ class ReportsTable extends StatelessWidget {
|
||||
required this.report,
|
||||
required this.onRowTap,
|
||||
required this.onClose,
|
||||
this.thirdColumnTitle,
|
||||
this.thirdColumnDescription,
|
||||
});
|
||||
|
||||
@override
|
||||
@ -32,33 +36,34 @@ class ReportsTable extends StatelessWidget {
|
||||
children: [
|
||||
TableRow(
|
||||
decoration: BoxDecoration(color: Colors.grey.shade200),
|
||||
children: const [
|
||||
TableHeader(title: 'Date'),
|
||||
TableHeader(title: 'Time'),
|
||||
TableHeader(title: 'Status'),
|
||||
children: [
|
||||
const TableHeader(title: 'Date'),
|
||||
const TableHeader(title: 'Time'),
|
||||
TableHeader(title: thirdColumnTitle ?? 'Status'),
|
||||
],
|
||||
),
|
||||
...report.data!.asMap().entries.map((entry) {
|
||||
int index = entry.key;
|
||||
DeviceEvent data = entry.value;
|
||||
if (report.data != null)
|
||||
...report.data!.asMap().entries.map((entry) {
|
||||
int index = entry.key;
|
||||
DeviceEvent data = entry.value;
|
||||
|
||||
// Parse eventTime into Date and Time
|
||||
DateTime eventDateTime =
|
||||
DateTime.fromMillisecondsSinceEpoch(data.eventTime!);
|
||||
String date = DateFormat('dd/MM/yyyy').format(eventDateTime);
|
||||
String time = DateFormat('HH:mm').format(eventDateTime);
|
||||
// Parse eventTime into Date and Time
|
||||
DateTime eventDateTime =
|
||||
DateTime.fromMillisecondsSinceEpoch(data.eventTime!);
|
||||
String date = DateFormat('dd/MM/yyyy').format(eventDateTime);
|
||||
String time = DateFormat('HH:mm').format(eventDateTime);
|
||||
|
||||
return TableRow(
|
||||
children: [
|
||||
TableCellWidget(value: date),
|
||||
TableCellWidget(value: time),
|
||||
TableCellWidget(
|
||||
value: data.value!,
|
||||
onTap: () => onRowTap(index),
|
||||
),
|
||||
],
|
||||
);
|
||||
}).toList(),
|
||||
return TableRow(
|
||||
children: [
|
||||
TableCellWidget(value: date),
|
||||
TableCellWidget(value: time),
|
||||
TableCellWidget(
|
||||
value: '${data.value!} $thirdColumnDescription',
|
||||
onTap: () => onRowTap(index),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -25,16 +25,21 @@ class WallSensorControls extends StatelessWidget with HelperResponsiveLayout {
|
||||
final isLarge = isLargeScreenSize(context);
|
||||
final isMedium = isMediumScreenSize(context);
|
||||
return BlocProvider(
|
||||
create: (context) => WallSensorBloc(deviceId: device.uuid!)..add(WallSensorInitialEvent()),
|
||||
create: (context) =>
|
||||
WallSensorBloc(deviceId: device.uuid!)..add(WallSensorInitialEvent()),
|
||||
child: BlocBuilder<WallSensorBloc, WallSensorState>(
|
||||
builder: (context, state) {
|
||||
if (state is WallSensorLoadingInitialState || state is DeviceReportsLoadingState) {
|
||||
if (state is WallSensorLoadingInitialState ||
|
||||
state is DeviceReportsLoadingState) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
} else if (state is WallSensorUpdateState) {
|
||||
return _buildGridView(context, state.wallSensorModel, isExtraLarge, isLarge, isMedium);
|
||||
return _buildGridView(context, state.wallSensorModel, isExtraLarge,
|
||||
isLarge, isMedium);
|
||||
} else if (state is DeviceReportsState) {
|
||||
return ReportsTable(
|
||||
report: state.deviceReport,
|
||||
thirdColumnTitle: "Value",
|
||||
thirdColumnDescription: "Lux",
|
||||
onRowTap: (index) {},
|
||||
onClose: () {
|
||||
context.read<WallSensorBloc>().add(BackToGridViewEvent());
|
||||
@ -49,7 +54,8 @@ class WallSensorControls extends StatelessWidget with HelperResponsiveLayout {
|
||||
);
|
||||
} else if (state is DeviceReportsFailedState) {
|
||||
final model = context.read<WallSensorBloc>().deviceStatus;
|
||||
return _buildGridView(context, model, isExtraLarge, isLarge, isMedium);
|
||||
return _buildGridView(
|
||||
context, model, isExtraLarge, isLarge, isMedium);
|
||||
}
|
||||
return const Center(child: Text('Error fetching status'));
|
||||
},
|
||||
@ -57,8 +63,8 @@ class WallSensorControls extends StatelessWidget with HelperResponsiveLayout {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildGridView(
|
||||
BuildContext context, WallSensorModel model, bool isExtraLarge, bool isLarge, bool isMedium) {
|
||||
Widget _buildGridView(BuildContext context, WallSensorModel model,
|
||||
bool isExtraLarge, bool isLarge, bool isMedium) {
|
||||
return GridView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 50),
|
||||
shrinkWrap: true,
|
||||
@ -127,10 +133,11 @@ class WallSensorControls extends StatelessWidget with HelperResponsiveLayout {
|
||||
maxValue: 10000,
|
||||
steps: 1,
|
||||
description: 'hr',
|
||||
action: (int value) => context.read<WallSensorBloc>().add(WallSensorChangeValueEvent(
|
||||
code: 'no_one_time',
|
||||
value: value,
|
||||
))),
|
||||
action: (int value) =>
|
||||
context.read<WallSensorBloc>().add(WallSensorChangeValueEvent(
|
||||
code: 'no_one_time',
|
||||
value: value,
|
||||
))),
|
||||
PresenceUpdateData(
|
||||
value: model.farDetection.toDouble(),
|
||||
title: 'Far Detection:',
|
||||
@ -147,9 +154,8 @@ class WallSensorControls extends StatelessWidget with HelperResponsiveLayout {
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
context
|
||||
.read<WallSensorBloc>()
|
||||
.add(GetDeviceReportsEvent(code: 'illuminance_value', deviceUuid: device.uuid!));
|
||||
context.read<WallSensorBloc>().add(GetDeviceReportsEvent(
|
||||
code: 'illuminance_value', deviceUuid: device.uuid!));
|
||||
},
|
||||
child: const PresenceStaticWidget(
|
||||
icon: Assets.illuminanceRecordIcon,
|
||||
@ -158,9 +164,8 @@ class WallSensorControls extends StatelessWidget with HelperResponsiveLayout {
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
context
|
||||
.read<WallSensorBloc>()
|
||||
.add(GetDeviceReportsEvent(code: 'presence_state', deviceUuid: device.uuid!));
|
||||
context.read<WallSensorBloc>().add(GetDeviceReportsEvent(
|
||||
code: 'presence_state', deviceUuid: device.uuid!));
|
||||
},
|
||||
child: const PresenceStaticWidget(
|
||||
icon: Assets.presenceRecordIcon,
|
||||
|
@ -74,19 +74,16 @@ class WebAppBar extends StatelessWidget with HelperResponsiveLayout {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
title!,
|
||||
if (centerBody != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 80),
|
||||
child: centerBody!,
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
title!,
|
||||
if (centerBody != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 80),
|
||||
child: centerBody!,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
|
Reference in New Issue
Block a user