mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
SP-1509 attatch space uuid to analytics device dropdown on energy management tab.
This commit is contained in:
@ -23,17 +23,18 @@ class AnalyticsDevice {
|
|||||||
return AnalyticsDevice(
|
return AnalyticsDevice(
|
||||||
uuid: json['uuid'] as String,
|
uuid: json['uuid'] as String,
|
||||||
name: json['name'] as String,
|
name: json['name'] as String,
|
||||||
createdAt: json['createdAt'] != null ? DateTime.parse(json['createdAt'] as String) : null,
|
createdAt: json['createdAt'] != null
|
||||||
updatedAt: json['updatedAt'] != null ? DateTime.parse(json['updatedAt'] as String) : null,
|
? DateTime.parse(json['createdAt'] as String)
|
||||||
|
: null,
|
||||||
|
updatedAt: json['updatedAt'] != null
|
||||||
|
? DateTime.parse(json['updatedAt'] as String)
|
||||||
|
: null,
|
||||||
deviceTuyaUuid: json['deviceTuyaUuid'] as String?,
|
deviceTuyaUuid: json['deviceTuyaUuid'] as String?,
|
||||||
isActive: json['isActive'] as bool?,
|
isActive: json['isActive'] as bool?,
|
||||||
productDevice: json['productDevice'] != null
|
productDevice: json['productDevice'] != null
|
||||||
? ProductDevice.fromJson(json['productDevice'] as Map<String, dynamic>)
|
? ProductDevice.fromJson(json['productDevice'] as Map<String, dynamic>)
|
||||||
: null,
|
: null,
|
||||||
spaceUuid: (json['spaces'] as List<dynamic>?)
|
spaceUuid: json['spaceUuid'] as String?,
|
||||||
?.map((e) => e['uuid'])
|
|
||||||
.firstOrNull
|
|
||||||
?.toString(),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,8 +61,12 @@ class ProductDevice {
|
|||||||
factory ProductDevice.fromJson(Map<String, dynamic> json) {
|
factory ProductDevice.fromJson(Map<String, dynamic> json) {
|
||||||
return ProductDevice(
|
return ProductDevice(
|
||||||
uuid: json['uuid'] as String?,
|
uuid: json['uuid'] as String?,
|
||||||
createdAt: json['createdAt'] != null ? DateTime.parse(json['createdAt'] as String) : null,
|
createdAt: json['createdAt'] != null
|
||||||
updatedAt: json['updatedAt'] != null ? DateTime.parse(json['updatedAt'] as String) : null,
|
? DateTime.parse(json['createdAt'] as String)
|
||||||
|
: null,
|
||||||
|
updatedAt: json['updatedAt'] != null
|
||||||
|
? DateTime.parse(json['updatedAt'] as String)
|
||||||
|
: null,
|
||||||
catName: json['catName'] as String?,
|
catName: json['catName'] as String?,
|
||||||
prodId: json['prodId'] as String?,
|
prodId: json['prodId'] as String?,
|
||||||
name: json['name'] as String?,
|
name: json['name'] as String?,
|
||||||
|
@ -41,7 +41,7 @@ class EnergyConsumptionPerDeviceDevicesList extends StatelessWidget {
|
|||||||
.color;
|
.color;
|
||||||
|
|
||||||
return Tooltip(
|
return Tooltip(
|
||||||
message: '${device.name}\n${device.productDevice?.uuid ?? ''}',
|
message: '${device.name}\n${device.spaceUuid ?? ''}',
|
||||||
child: ChartInformativeCell(title: Text(device.name), color: deviceColor),
|
child: ChartInformativeCell(title: Text(device.name), color: deviceColor),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ class PowerClampEnergyDataWidget extends StatelessWidget {
|
|||||||
AnalyticsErrorWidget(state.errorMessage),
|
AnalyticsErrorWidget(state.errorMessage),
|
||||||
AnalyticsSidebarHeader(
|
AnalyticsSidebarHeader(
|
||||||
title: 'Smart Power Clamp',
|
title: 'Smart Power Clamp',
|
||||||
showSpaceUuid: true,
|
showSpaceUuidInDevicesDropdown: true,
|
||||||
onChanged: (device) {
|
onChanged: (device) {
|
||||||
FetchEnergyManagementDataHelper.loadEnergyConsumptionByPhases(
|
FetchEnergyManagementDataHelper.loadEnergyConsumptionByPhases(
|
||||||
context,
|
context,
|
||||||
|
@ -10,13 +10,13 @@ import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
|||||||
class AnalyticsSidebarHeader extends StatelessWidget {
|
class AnalyticsSidebarHeader extends StatelessWidget {
|
||||||
const AnalyticsSidebarHeader({
|
const AnalyticsSidebarHeader({
|
||||||
required this.title,
|
required this.title,
|
||||||
this.showSpaceUuid = false,
|
this.showSpaceUuidInDevicesDropdown = false,
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
final bool showSpaceUuid;
|
final bool showSpaceUuidInDevicesDropdown;
|
||||||
final void Function(AnalyticsDevice device)? onChanged;
|
final void Function(AnalyticsDevice device)? onChanged;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -49,6 +49,7 @@ class AnalyticsSidebarHeader extends StatelessWidget {
|
|||||||
alignment: AlignmentDirectional.centerEnd,
|
alignment: AlignmentDirectional.centerEnd,
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.scaleDown,
|
||||||
child: AnalyticsDeviceDropdown(
|
child: AnalyticsDeviceDropdown(
|
||||||
|
showSpaceUuid: showSpaceUuidInDevicesDropdown,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
context.read<AnalyticsDevicesBloc>().add(
|
context.read<AnalyticsDevicesBloc>().add(
|
||||||
SelectAnalyticsDeviceEvent(value),
|
SelectAnalyticsDeviceEvent(value),
|
||||||
|
Reference in New Issue
Block a user