2018-10-27 17:28:47 +03:00
|
|
|
part of '../main.dart';
|
|
|
|
|
|
|
|
class HACard {
|
2018-11-15 19:08:47 +02:00
|
|
|
List<EntityWrapper> entities = [];
|
2018-11-25 20:44:19 +02:00
|
|
|
List<HACard> childCards = [];
|
2018-11-25 18:09:06 +02:00
|
|
|
EntityWrapper linkedEntityWrapper;
|
2018-10-27 17:28:47 +03:00
|
|
|
String name;
|
|
|
|
String id;
|
|
|
|
String type;
|
2018-11-15 19:08:47 +02:00
|
|
|
bool showName;
|
|
|
|
bool showState;
|
2018-12-07 22:04:14 +02:00
|
|
|
bool showEmpty;
|
2018-11-14 19:52:17 +02:00
|
|
|
int columnsCount;
|
2018-12-07 22:04:14 +02:00
|
|
|
List stateFilter;
|
2019-01-29 15:00:15 +02:00
|
|
|
List states;
|
2019-08-26 17:03:28 +03:00
|
|
|
List conditions;
|
2019-01-23 23:34:45 +02:00
|
|
|
String content;
|
2019-09-07 15:47:09 +03:00
|
|
|
String unit;
|
|
|
|
int min;
|
|
|
|
int max;
|
|
|
|
Map severity;
|
2018-10-27 17:28:47 +03:00
|
|
|
|
|
|
|
HACard({
|
|
|
|
this.name,
|
|
|
|
this.id,
|
2018-11-25 18:09:06 +02:00
|
|
|
this.linkedEntityWrapper,
|
2018-11-14 19:52:17 +02:00
|
|
|
this.columnsCount: 4,
|
2018-11-15 19:08:47 +02:00
|
|
|
this.showName: true,
|
|
|
|
this.showState: true,
|
2018-12-07 22:04:14 +02:00
|
|
|
this.stateFilter: const [],
|
|
|
|
this.showEmpty: true,
|
2019-01-23 23:34:45 +02:00
|
|
|
this.content,
|
2019-01-29 15:00:15 +02:00
|
|
|
this.states,
|
2019-08-27 20:05:33 +03:00
|
|
|
this.conditions: const [],
|
2019-09-07 15:47:09 +03:00
|
|
|
this.unit,
|
|
|
|
this.min,
|
|
|
|
this.max,
|
|
|
|
this.severity,
|
2018-10-27 17:28:47 +03:00
|
|
|
@required this.type
|
2019-09-04 23:42:19 +03:00
|
|
|
}) {
|
|
|
|
if (this.columnsCount <= 0) {
|
|
|
|
this.columnsCount = 4;
|
|
|
|
}
|
|
|
|
}
|
2018-10-27 17:28:47 +03:00
|
|
|
|
2018-12-07 22:04:14 +02:00
|
|
|
List<EntityWrapper> getEntitiesToShow() {
|
|
|
|
return entities.where((entityWrapper) {
|
2019-10-09 20:45:46 +03:00
|
|
|
if (!ConnectionManager().useLovelace && entityWrapper.entity.isHidden) {
|
2018-12-07 22:04:14 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (stateFilter.isNotEmpty) {
|
|
|
|
return stateFilter.contains(entityWrapper.entity.state);
|
2018-10-27 17:28:47 +03:00
|
|
|
}
|
2018-12-07 22:04:14 +02:00
|
|
|
return true;
|
|
|
|
}).toList();
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return CardWidget(
|
|
|
|
card: this,
|
|
|
|
);
|
2018-10-27 17:28:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|