Style Dashboard by rules
This commit is contained in:
parent
7fea931b63
commit
e73ca6b532
@ -87,15 +87,15 @@ final WorflowService _service = WorflowService();
|
|||||||
if (objAbs.topic == "compute" ) {
|
if (objAbs.topic == "compute" ) {
|
||||||
var compute = objAbs as ComputeItem;
|
var compute = objAbs as ComputeItem;
|
||||||
if (compute.technology == 0) {
|
if (compute.technology == 0) {
|
||||||
return Icon(FontAwesomeIcons.docker, size: 18);
|
return Icon(FontAwesomeIcons.docker, size: 16);
|
||||||
} else if (compute.technology == 1) {
|
} else if (compute.technology == 1) {
|
||||||
return Icon(FontAwesomeIcons.lifeRing, size: 18);
|
return Icon(FontAwesomeIcons.lifeRing, size: 16);
|
||||||
} else if (compute.technology == 2) {
|
} else if (compute.technology == 2) {
|
||||||
return Icon(FontAwesomeIcons.cubes, size: 18);
|
return Icon(FontAwesomeIcons.cubes, size: 16);
|
||||||
} else if (compute.technology == 3) {
|
} else if (compute.technology == 3) {
|
||||||
return Icon(FontAwesomeIcons.hardDrive, size: 18);
|
return Icon(FontAwesomeIcons.hardDrive, size: 16);
|
||||||
} else if (compute.technology == 4) {
|
} else if (compute.technology == 4) {
|
||||||
return Icon(FontAwesomeIcons.v, size: 18);
|
return Icon(FontAwesomeIcons.v, size: 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -105,15 +105,15 @@ final WorflowService _service = WorflowService();
|
|||||||
var objAbs = obj as AbstractItem?;
|
var objAbs = obj as AbstractItem?;
|
||||||
if (objAbs == null) { return null; }
|
if (objAbs == null) { return null; }
|
||||||
if (objAbs.topic == "processing" ) {
|
if (objAbs.topic == "processing" ) {
|
||||||
return Icon(FontAwesomeIcons.gear) ;
|
return Icon(FontAwesomeIcons.gear, size: 16);
|
||||||
} else if (objAbs.topic == "data" ) {
|
} else if (objAbs.topic == "data" ) {
|
||||||
return Icon(FontAwesomeIcons.file);
|
return Icon(FontAwesomeIcons.file, size: 16);
|
||||||
} else if (objAbs.topic == "storage" ) {
|
} else if (objAbs.topic == "storage" ) {
|
||||||
return Icon(FontAwesomeIcons.database);
|
return Icon(FontAwesomeIcons.database, size: 16);
|
||||||
} else if (objAbs.topic == "compute" ) {
|
} else if (objAbs.topic == "compute" ) {
|
||||||
return Icon(FontAwesomeIcons.microchip);
|
return Icon(FontAwesomeIcons.microchip, size: 16);
|
||||||
} else if (objAbs.topic == "workflows" ) {
|
} else if (objAbs.topic == "workflows" ) {
|
||||||
return Icon(FontAwesomeIcons.diagramProject);
|
return Icon(FontAwesomeIcons.diagramProject, size: 16);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -290,6 +290,32 @@ final WorflowService _service = WorflowService();
|
|||||||
dash.infoItemWidget = getForms;
|
dash.infoItemWidget = getForms;
|
||||||
dash.infoWidget = getDashInfoForms;
|
dash.infoWidget = getDashInfoForms;
|
||||||
dash.widthOffset = 50;
|
dash.widthOffset = 50;
|
||||||
|
dash.arrowStyleRules = [
|
||||||
|
(dash) {
|
||||||
|
for (var arrow in dash.arrows) {
|
||||||
|
var from = dash.elements.firstWhere((element) => arrow.fromID.contains(element.id)).element;
|
||||||
|
var to = dash.elements.firstWhere((element) => arrow.toID.contains(element.id)).element;
|
||||||
|
if ((from is ProcessingItem && to is ComputeItem) || (to is ProcessingItem && from is ComputeItem)) {
|
||||||
|
arrow.params.color = Colors.orange;
|
||||||
|
arrow.params.dashSpace = 2;
|
||||||
|
arrow.params.dashWidth = 2;
|
||||||
|
} else if ((from is ProcessingItem && to is StorageItem) || (to is ProcessingItem && from is StorageItem)) {
|
||||||
|
arrow.params.color = redColor;
|
||||||
|
arrow.params.dashSpace = 2;
|
||||||
|
arrow.params.dashWidth = 2;
|
||||||
|
} else if ((from is ProcessingItem && to is DataItem) || (to is ProcessingItem && from is DataItem)) {
|
||||||
|
arrow.params.color = Colors.blue;
|
||||||
|
arrow.params.dashSpace = 2;
|
||||||
|
arrow.params.dashWidth = 2;
|
||||||
|
} else {
|
||||||
|
arrow.params.color = Colors.black;
|
||||||
|
arrow.params.dashSpace = 0;
|
||||||
|
arrow.params.dashWidth = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dash.arrows;
|
||||||
|
}
|
||||||
|
];
|
||||||
dash.saveRules = [
|
dash.saveRules = [
|
||||||
(dash) {
|
(dash) {
|
||||||
dash.error = null;
|
dash.error = null;
|
||||||
|
@ -115,11 +115,11 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
|
|||||||
if (end.isBefore(DateTime.now())) {
|
if (end.isBefore(DateTime.now())) {
|
||||||
// get difference between now and start
|
// get difference between now and start
|
||||||
delayed = end.difference(DateTime.now());
|
delayed = end.difference(DateTime.now());
|
||||||
}
|
|
||||||
Future.delayed(delayed, () {
|
Future.delayed(delayed, () {
|
||||||
WorkflowFactory.key.currentState?.setState(() { });
|
WorkflowFactory.key.currentState?.setState(() { });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
List<GlobalKey<FormFieldState>> formKeys = [GlobalKey<FormFieldState>(), GlobalKey<FormFieldState>(), GlobalKey<FormFieldState>(), GlobalKey<FormFieldState>()];
|
List<GlobalKey<FormFieldState>> formKeys = [GlobalKey<FormFieldState>(), GlobalKey<FormFieldState>(), GlobalKey<FormFieldState>(), GlobalKey<FormFieldState>()];
|
||||||
var shallow = ShallowTextInputWidget(
|
var shallow = ShallowTextInputWidget(
|
||||||
width: 200 - 1, readOnly: readOnly,
|
width: 200 - 1, readOnly: readOnly,
|
||||||
|
@ -61,6 +61,7 @@ class Dashboard extends ChangeNotifier {
|
|||||||
double widthOffset = 0;
|
double widthOffset = 0;
|
||||||
double heightOffset = 0;
|
double heightOffset = 0;
|
||||||
List<bool Function(Dashboard)> saveRules = [];
|
List<bool Function(Dashboard)> saveRules = [];
|
||||||
|
List<List<ArrowPainter> Function(Dashboard)> arrowStyleRules = [];
|
||||||
|
|
||||||
String? error;
|
String? error;
|
||||||
|
|
||||||
@ -152,7 +153,9 @@ class Dashboard extends ChangeNotifier {
|
|||||||
map['dashboardSizeWidth'] as double? ?? 0,
|
map['dashboardSizeWidth'] as double? ?? 0,
|
||||||
map['dashboardSizeHeight'] as double? ?? 0,
|
map['dashboardSizeHeight'] as double? ?? 0,
|
||||||
);
|
);
|
||||||
|
for (var f in d.arrowStyleRules) {
|
||||||
|
d.arrows = f(d);
|
||||||
|
}
|
||||||
if (map['gridBackgroundParams'] != null) {
|
if (map['gridBackgroundParams'] != null) {
|
||||||
d.gridBackgroundParams = GridBackgroundParams.fromMap(
|
d.gridBackgroundParams = GridBackgroundParams.fromMap(
|
||||||
map['gridBackgroundParams'] as Map<String, dynamic>,
|
map['gridBackgroundParams'] as Map<String, dynamic>,
|
||||||
@ -179,6 +182,9 @@ class Dashboard extends ChangeNotifier {
|
|||||||
(x) => ArrowPainter.fromMap(x as Map<String, dynamic>),
|
(x) => ArrowPainter.fromMap(x as Map<String, dynamic>),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
for (var f in arrowStyleRules) {
|
||||||
|
arrows = f(this);
|
||||||
|
}
|
||||||
elements = List<FlowElement>.from(
|
elements = List<FlowElement>.from(
|
||||||
(map['elements'] as List<dynamic>).map<FlowElement>(
|
(map['elements'] as List<dynamic>).map<FlowElement>(
|
||||||
(x) => FlowElement.fromMap(this, x as Map<String, dynamic>),
|
(x) => FlowElement.fromMap(this, x as Map<String, dynamic>),
|
||||||
@ -244,6 +250,9 @@ class Dashboard extends ChangeNotifier {
|
|||||||
for(var el in elements) {
|
for(var el in elements) {
|
||||||
graph['elements'][el.id] = el.serialize();
|
graph['elements'][el.id] = el.serialize();
|
||||||
}
|
}
|
||||||
|
for (var f in arrowStyleRules) {
|
||||||
|
arrows = f(this);
|
||||||
|
}
|
||||||
graph['arrows'] = arrows.map((e) => e.serialize()).toList();
|
graph['arrows'] = arrows.map((e) => e.serialize()).toList();
|
||||||
d["id"]=id;
|
d["id"]=id;
|
||||||
d["name"]=name;
|
d["name"]=name;
|
||||||
@ -322,12 +331,18 @@ class Dashboard extends ChangeNotifier {
|
|||||||
|
|
||||||
void addArrows(ArrowPainter f) {
|
void addArrows(ArrowPainter f) {
|
||||||
arrows.add(f);
|
arrows.add(f);
|
||||||
|
for (var f in arrowStyleRules) {
|
||||||
|
arrows = f(this);
|
||||||
|
}
|
||||||
addChange = true;
|
addChange = true;
|
||||||
saveDash(id);
|
saveDash(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeArrows(bool Function(ArrowPainter) f) {
|
void removeArrows(bool Function(ArrowPainter) f) {
|
||||||
arrows.removeWhere((element) => f(element));
|
arrows.removeWhere((element) => f(element));
|
||||||
|
for (var f in arrowStyleRules) {
|
||||||
|
arrows = f(this);
|
||||||
|
}
|
||||||
saveDash(id);
|
saveDash(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,7 +352,7 @@ class DrawArrowState extends State<DrawArrow> {
|
|||||||
if ( widget.flow.widget.dashboard.arrows.where(
|
if ( widget.flow.widget.dashboard.arrows.where(
|
||||||
(element) => element.fromID == "${widget.srcElement.id}_${widget.index}").isEmpty) {
|
(element) => element.fromID == "${widget.srcElement.id}_${widget.index}").isEmpty) {
|
||||||
widget.flow.widget.dashboard.addArrows(painter);
|
widget.flow.widget.dashboard.addArrows(painter);
|
||||||
widget.flow.widget.dashboard.save!(widget.flow.widget.dashboard.id);
|
widget.flow.widget.dashboard.saveDash(widget.flow.widget.dashboard.id);
|
||||||
} else {
|
} else {
|
||||||
var i = widget.flow.widget.dashboard.arrows.indexWhere(
|
var i = widget.flow.widget.dashboard.arrows.indexWhere(
|
||||||
(element) => element.fromID == "${widget.srcElement.id}_${widget.index}");
|
(element) => element.fromID == "${widget.srcElement.id}_${widget.index}");
|
||||||
|
Loading…
Reference in New Issue
Block a user