mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
added device spaces model
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_space_model.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/room.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/unit.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
@ -64,6 +65,7 @@ class AllDevicesModel {
|
||||
String? uuid;
|
||||
int? batteryLevel;
|
||||
String? productName;
|
||||
List<DeviceSpaceModel>? spaces;
|
||||
|
||||
AllDevicesModel({
|
||||
this.room,
|
||||
@ -92,6 +94,7 @@ class AllDevicesModel {
|
||||
this.uuid,
|
||||
this.batteryLevel,
|
||||
this.productName,
|
||||
this.spaces,
|
||||
});
|
||||
AllDevicesModel.fromJson(Map<String, dynamic> json) {
|
||||
room = (json['room'] != null && (json['room'] is Map))
|
||||
@ -124,6 +127,11 @@ class AllDevicesModel {
|
||||
uuid = json['uuid']?.toString();
|
||||
batteryLevel = int.tryParse(json['battery']?.toString() ?? '');
|
||||
productName = json['productName']?.toString();
|
||||
if (json['spaces'] != null && json['spaces'] is List) {
|
||||
spaces = (json['spaces'] as List)
|
||||
.map((space) => DeviceSpaceModel.fromJson(space))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
String _getDefaultIcon(String? productType) {
|
||||
@ -186,6 +194,9 @@ class AllDevicesModel {
|
||||
data['uuid'] = uuid;
|
||||
data['battery'] = batteryLevel;
|
||||
data['productName'] = productName;
|
||||
if (spaces != null) {
|
||||
data['spaces'] = spaces!.map((space) => space.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user