mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
Implemented side tree to devices and rountines screen
This commit is contained in:
84
lib/pages/routines/models/device_functions.dart
Normal file
84
lib/pages/routines/models/device_functions.dart
Normal file
@ -0,0 +1,84 @@
|
||||
abstract class DeviceFunction<T> {
|
||||
final String deviceId;
|
||||
final String deviceName;
|
||||
final String code;
|
||||
final String operationName;
|
||||
final String icon;
|
||||
|
||||
DeviceFunction({
|
||||
required this.deviceId,
|
||||
required this.deviceName,
|
||||
required this.code,
|
||||
required this.operationName,
|
||||
required this.icon,
|
||||
});
|
||||
}
|
||||
|
||||
class DeviceFunctionData {
|
||||
final String entityId;
|
||||
final String actionExecutor;
|
||||
final String functionCode;
|
||||
final String operationName;
|
||||
final dynamic value;
|
||||
final String? condition;
|
||||
final String? valueDescription;
|
||||
|
||||
DeviceFunctionData({
|
||||
required this.entityId,
|
||||
this.actionExecutor = 'device_issue',
|
||||
required this.functionCode,
|
||||
required this.operationName,
|
||||
required this.value,
|
||||
this.condition,
|
||||
this.valueDescription,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'entityId': entityId,
|
||||
'actionExecutor': actionExecutor,
|
||||
'function': functionCode,
|
||||
'operationName': operationName,
|
||||
'value': value,
|
||||
if (condition != null) 'condition': condition,
|
||||
if (valueDescription != null) 'valueDescription': valueDescription,
|
||||
};
|
||||
}
|
||||
|
||||
factory DeviceFunctionData.fromJson(Map<String, dynamic> json) {
|
||||
return DeviceFunctionData(
|
||||
entityId: json['entityId'],
|
||||
actionExecutor: json['actionExecutor'] ?? 'function',
|
||||
functionCode: json['function'],
|
||||
operationName: json['operationName'],
|
||||
value: json['value'],
|
||||
condition: json['condition'],
|
||||
valueDescription: json['valueDescription'],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is DeviceFunctionData &&
|
||||
other.entityId == entityId &&
|
||||
other.actionExecutor == actionExecutor &&
|
||||
other.functionCode == functionCode &&
|
||||
other.operationName == operationName &&
|
||||
other.value == value &&
|
||||
other.condition == condition &&
|
||||
other.valueDescription == valueDescription;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return entityId.hashCode ^
|
||||
actionExecutor.hashCode ^
|
||||
functionCode.hashCode ^
|
||||
operationName.hashCode ^
|
||||
value.hashCode ^
|
||||
condition.hashCode ^
|
||||
valueDescription.hashCode;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user