diff --git a/lib/core/services/perms_service.dart b/lib/core/services/perms_service.dart index 48e4213..011e7c5 100644 --- a/lib/core/services/perms_service.dart +++ b/lib/core/services/perms_service.dart @@ -42,51 +42,42 @@ Map perms = { class PermsService { static final Map _perms = { - Perms.SEARCH_INTERNAL: true, - Perms.SEARCH_EXTERNAL: true, - Perms.WORKSPACE_SHARE: true, - Perms.WORKSPACE_UNSHARE: true, - Perms.WORKFLOW_CREATE: true, - Perms.WORKFLOW_EDIT: true, - Perms.WORKFLOW_DELETE: true, - Perms.WORKFLOW_BOOKING: true, - Perms.WORKFLOW_SHARE: true, - Perms.WORKFLOW_UNSHARE: true, - Perms.PEER_SHARE: true, - Perms.PEER_UNSHARE: true, - Perms.COLLABORATIVE_AREA_CREATE: true, - Perms.COLLABORATIVE_AREA_EDIT: true, - Perms.COLLABORATIVE_AREA_DELETE: true, + Perms.SEARCH_INTERNAL: false, + Perms.SEARCH_EXTERNAL: false, + Perms.WORKSPACE_SHARE: false, + Perms.WORKSPACE_UNSHARE: false, + Perms.WORKFLOW_CREATE: false, + Perms.WORKFLOW_EDIT: false, + Perms.WORKFLOW_DELETE: false, + Perms.WORKFLOW_BOOKING: false, + Perms.WORKFLOW_SHARE: false, + Perms.WORKFLOW_UNSHARE: false, + Perms.PEER_SHARE: false, + Perms.PEER_UNSHARE: false, + Perms.COLLABORATIVE_AREA_CREATE: false, + Perms.COLLABORATIVE_AREA_EDIT: false, + Perms.COLLABORATIVE_AREA_DELETE: false, }; static final PermsService _instance = PermsService._internal(); factory PermsService() => _instance; PermsService._internal(); /* should decode claims such as in oc-auth */ static Future init(String token ) async { -/* var claims = token.split(".").last; + var claims = token.split(".").last; var decoded = base64.decode(claims); String foo = utf8.decode(decoded); - var what = json.decode(foo); try { + var what = json.decode(foo); what = what["session"]["access_token"] as Map; - for (var w in perms.values) { - - if (what.keys.contains(w)) { - print("CONTAINS"); + for (var w in perms.keys) { + if (what.keys.contains(perms[w])) { + _perms[w] = true; } else { - for (var y in what.keys) { - print("${w}, ${y} ${what.keys.contains(w)}"); - } + _perms[w] = false; } } - } catch (e) { - print("THERE"); - }*/ - - _perms.forEach((key, value) { - _perms[key] = true; - }); + } catch (e) {/**/} } static void clear() { diff --git a/lib/core/services/specialized_services/workflow_execution_service.dart b/lib/core/services/specialized_services/workflow_execution_service.dart index 28ba243..9b7ef51 100644 --- a/lib/core/services/specialized_services/workflow_execution_service.dart +++ b/lib/core/services/specialized_services/workflow_execution_service.dart @@ -11,7 +11,6 @@ class WorkflowExecutionService extends AbstractService { @override String subPath = "/"; @override Future> search(BuildContext? context, List words, Map params) { - print("${subPath}search/${words.join("/")}"); return service.get("${subPath}search/${words.join("/")}", false, context); } diff --git a/lib/pages/scheduler.dart b/lib/pages/scheduler.dart index 1e2701d..7c1b8ae 100644 --- a/lib/pages/scheduler.dart +++ b/lib/pages/scheduler.dart @@ -25,10 +25,7 @@ class SchedulerPageWidget extends StatefulWidget { static void search(BuildContext context) { } static Widget factory() { return SchedulerPageWidget(); } } -class SchedulerPageWidgetState extends State { - List colors = [Colors.blue, Colors.orange, redColor, Colors.green, redColor]; - List titles = ["SCHEDULED", "RUNNING", "FAILURE", "SUCCESS", "FORGOTTEN"]; - +class SchedulerPageWidgetState extends State { @override Widget build(BuildContext context) { GlobalKey k = GlobalKey(); return Column( children: [ diff --git a/lib/pages/workflow.dart b/lib/pages/workflow.dart index ef7875d..5a8f04f 100644 --- a/lib/pages/workflow.dart +++ b/lib/pages/workflow.dart @@ -290,6 +290,38 @@ final WorflowService _service = WorflowService(); dash.infoItemWidget = getForms; dash.infoWidget = getDashInfoForms; dash.widthOffset = 50; + dash.saveRules = [ + (dash) { + dash.error = null; + if (dash.scheduleActive) { + if (dash.elements.isEmpty || dash.elements.where((element) => element.element is ProcessingItem).isEmpty) { + dash.error = "You need at least one processing element"; + dash.scheduleActive = false; + } + var processings = dash.elements.where((element) => element.element is ProcessingItem).map((e) => e.element as ProcessingItem); + var computes = dash.elements.where((element) => element.element is ComputeItem).map((e) => e.element as ComputeItem); + if (processings.length != computes.length) { + dash.error = "You need the same number of processing and compute elements"; + dash.scheduleActive = false; + } + for (var p in processings) { + var links = dash.arrows.where((element) => element.fromID.contains(p.getID()) || element.toID.contains(p.getID())); + try { + computes.firstWhere( (e) => links.first.toID.contains(e.getID()) || links.first.fromID.contains(e.getID()) ); + } catch (e) { + dash.error = "You need to link each processing element to a compute element"; + dash.scheduleActive = false; + } + } + if (dash.error != null) { + print(dash.error); + setState(() {}); + } + return dash.scheduleActive; + } + return true; + } + ]; return FlowChart( key: dash.flutterChartKey, itemLeftBottomBadges: getBottomLeftBadge, diff --git a/lib/widgets/forms/processing_forms.dart b/lib/widgets/forms/processing_forms.dart index addc194..65b9793 100644 --- a/lib/widgets/forms/processing_forms.dart +++ b/lib/widgets/forms/processing_forms.dart @@ -73,7 +73,7 @@ class ProcessingFormsWidgetState extends State { widget.item.model ?? Model(); Future.delayed(const Duration(seconds: 2), () { if (widget.item.getVariable([child, st], widget.item.serialize()) == value) { - dash.save!(dash.id); + dash.saveDash(dash.id); } }); var el = dash.getElement(widget.elementID); diff --git a/lib/widgets/forms/scheduler_forms.dart b/lib/widgets/forms/scheduler_forms.dart index d80350c..668a963 100644 --- a/lib/widgets/forms/scheduler_forms.dart +++ b/lib/widgets/forms/scheduler_forms.dart @@ -48,7 +48,7 @@ class SchedulerFormsWidgetState extends State { dash.scheduler["end"] = now.add(const Duration(minutes: 1)).toUtc().toIso8601String(); } } - widget.item.save!(widget.item.id); + widget.item.saveDash(widget.item.id); } void checkBooking(List> formKeys, void Function(List> )? f){ if (widget.item.scheduler["start"] == null) { @@ -93,12 +93,18 @@ class SchedulerFormsWidgetState extends State { bool readOnly = !PermsService.getPerm(Perms.WORKFLOW_EDIT); DateTime? start; DateTime? end; + + Duration delayed = const Duration(minutes: 5); if (widget.item.scheduler["start"] != null) { start = DateTime.parse(widget.item.scheduler["start"]!); if (start.isBefore(DateTime.now()) && !dash.scheduleActive) { start = DateTime.now().add(const Duration(minutes: 5)); widget.item.scheduler["start"] = start.toUtc().toIso8601String(); } + if (start.isBefore(DateTime.now())) { + // get difference between now and start + delayed = start.difference(DateTime.now()); + } } if (widget.item.scheduler["end"] != null) { end = DateTime.parse(widget.item.scheduler["end"]!); @@ -106,6 +112,13 @@ class SchedulerFormsWidgetState extends State { end = DateTime.now().add(const Duration(minutes: 5)); widget.item.scheduler["end"] = end.toUtc().toIso8601String(); } + if (end.isBefore(DateTime.now())) { + // get difference between now and start + delayed = end.difference(DateTime.now()); + } + Future.delayed(delayed, () { + WorkflowFactory.key.currentState?.setState(() { }); + }); } List> formKeys = [GlobalKey(), GlobalKey(), GlobalKey(), GlobalKey()]; var shallow = ShallowTextInputWidget( @@ -160,7 +173,7 @@ class SchedulerFormsWidgetState extends State { onChanged: (value) { Future.delayed(const Duration(seconds: 100), () { if (widget.item.scheduler["name"] == value) { - widget.item.save!(widget.item.id); + widget.item.saveDash(widget.item.id); } }); widget.item.scheduler["name"] = value; @@ -183,11 +196,11 @@ class SchedulerFormsWidgetState extends State { labelText: "executions name*", hintStyle: TextStyle(fontSize: 10), labelStyle: TextStyle(fontSize: 10), - focusedErrorBorder: OutlineInputBorder(borderSide: BorderSide(color: widget.error != null ? Colors.red : Colors.black)), - errorBorder: OutlineInputBorder(borderSide: BorderSide(color: widget.error != null ? Colors.red : Colors.black)), - focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: widget.error != null ? Colors.red : Colors.black)), - enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: widget.error != null ? Colors.red : Colors.grey)), - border: OutlineInputBorder(borderSide: BorderSide(color: widget.error != null ? Colors.red : Colors.grey)), + focusedErrorBorder: OutlineInputBorder(borderSide: BorderSide(color: widget.item.error != null || widget.error != null ? Colors.red : Colors.black)), + errorBorder: OutlineInputBorder(borderSide: BorderSide(color: widget.item.error != null || widget.error != null ? Colors.red : Colors.black)), + focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: widget.item.error != null || widget.error != null ? Colors.red : Colors.black)), + enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: widget.item.error != null || widget.error != null ? Colors.red : Colors.grey)), + border: OutlineInputBorder(borderSide: BorderSide(color: widget.item.error != null || widget.error != null ? Colors.red : Colors.grey)), contentPadding: EdgeInsets.symmetric(horizontal: 10, vertical: 5), ), ))), @@ -254,7 +267,7 @@ class SchedulerFormsWidgetState extends State { date = DateTime(date.year, date.month, date.day, time.hour, time.minute); widget.item.scheduler["start"] = date.toUtc().toIso8601String(); } - widget.item.save!(widget.item.id); + widget.item.saveDash(widget.item.id); } return date; }, @@ -359,7 +372,7 @@ class SchedulerFormsWidgetState extends State { date = DateTime(date.year, date.month, date.day, time.hour, time.minute); widget.item.scheduler["end"] = date.toUtc().toIso8601String(); } - widget.item.save!(widget.item.id); + widget.item.saveDash(widget.item.id); } return date; }, @@ -392,7 +405,7 @@ class SchedulerFormsWidgetState extends State { onChanged: (value) { Future.delayed(const Duration(seconds: 100), () { if (widget.item.scheduler["cron"] == value) { - widget.item.save!(widget.item.id); + widget.item.saveDash(widget.item.id); } }); widget.item.scheduler["cron"] = value; diff --git a/lib/widgets/forms/sub_expose_forms.dart b/lib/widgets/forms/sub_expose_forms.dart index c7f23c5..19cffb4 100644 --- a/lib/widgets/forms/sub_expose_forms.dart +++ b/lib/widgets/forms/sub_expose_forms.dart @@ -29,7 +29,7 @@ class SubExposeFormsWidgetState extends State { widget.item.port = int.parse(value); Future.delayed(const Duration(seconds: 2), () { if (widget.item.port == int.parse(value) && int.parse(value) != 0) { - widget.dash.save!(widget.dash.id); + widget.dash.saveDash(widget.dash.id); } }); } catch (e) { widget.item.port = null; } @@ -44,7 +44,7 @@ class SubExposeFormsWidgetState extends State { widget.item.PAT = int.parse(value); Future.delayed(const Duration(seconds: 2), () { if (widget.item.PAT == int.parse(value) && int.parse(value) != 0) { - widget.dash.save!(widget.dash.id); + widget.dash.saveDash(widget.dash.id); } }); } catch (e) { widget.item.PAT = null; } @@ -57,7 +57,7 @@ class SubExposeFormsWidgetState extends State { try { widget.item.path = value; Future.delayed(const Duration(seconds: 2), () { - if (widget.item.path == value) { widget.dash.save!(widget.dash.id); } + if (widget.item.path == value) { widget.dash.saveDash(widget.dash.id); } }); } catch (e) { widget.item.path = null; } var el = widget.dash.getElement(widget.elementID); diff --git a/lib/widgets/forms/sub_keys_forms.dart b/lib/widgets/forms/sub_keys_forms.dart index 05ff15c..20e7ab2 100644 --- a/lib/widgets/forms/sub_keys_forms.dart +++ b/lib/widgets/forms/sub_keys_forms.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_flow_chart/flutter_flow_chart.dart'; import 'package:oc_front/models/workflow.dart'; import 'package:oc_front/widgets/inputs/sub_text_input.dart'; @@ -46,7 +45,7 @@ class SubKeysMapFormsWidgetState extends State { } } if (save) { - widget.dash.save!(widget.dash.id); + widget.dash.saveDash(widget.dash.id); } if (children.isEmpty) { return Container(); diff --git a/lib/widgets/forms/sub_map_forms.dart b/lib/widgets/forms/sub_map_forms.dart index 129ca14..134e345 100644 --- a/lib/widgets/forms/sub_map_forms.dart +++ b/lib/widgets/forms/sub_map_forms.dart @@ -52,7 +52,7 @@ class SubMapFormsWidgetState extends State { setState(() { widget.forms[i].key = value; Future.delayed(const Duration(seconds: 2), () { - widget.dash.save!(widget.dash.id); + widget.dash.saveDash(widget.dash.id); }); var el = widget.dash.getElement(widget.elementID); widget.item = widget.item.deserialize(widget.item.setVariable(l, toMap(), widget.item.serialize())) as dynamic; @@ -63,7 +63,7 @@ class SubMapFormsWidgetState extends State { SubTextInputWidget(subkey: "value", initialValue: widget.forms[i].value, width: 77.5, empty: widget.empty, readOnly: widget.readOnly, change: (value) { Future.delayed(const Duration(seconds: 2), () { - widget.dash.save!(widget.dash.id); + widget.dash.saveDash(widget.dash.id); }); widget.forms[i].value = value; var el = widget.dash.getElement(widget.elementID); @@ -99,7 +99,7 @@ class SubMapFormsWidgetState extends State { widget.item.setVariable(l, toMap(), widget.item.serialize())) as dynamic; var el = widget.dash.getElement(widget.elementID); el!.element = widget.item as dynamic; - setState(() { widget.dash.save!(widget.dash.id); }); + setState(() { widget.dash.saveDash(widget.dash.id); }); }, child: Container( margin: const EdgeInsets.only(left: 5, top: 10), decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), border: Border.all(color: Colors.grey, width: 1)), diff --git a/lib/widgets/sheduler_items/schedule.dart b/lib/widgets/sheduler_items/schedule.dart index e8631b3..4f15d27 100644 --- a/lib/widgets/sheduler_items/schedule.dart +++ b/lib/widgets/sheduler_items/schedule.dart @@ -31,7 +31,6 @@ class ScheduleWidgetState extends State { String search = ""; String? level; List colors = [Colors.blue, Colors.orange, redColor, Colors.green, redColor]; - List titles = ["SCHEDULED", "RUNNING", "FAILURE", "SUCCESS", "MISSED"]; DateTime getFocusedDay() { if (selected != null) { return DateTime.parse(selected!); } diff --git a/library/flutter_flow_chart/lib/src/dashboard.dart b/library/flutter_flow_chart/lib/src/dashboard.dart index 1bb4a8f..b01edab 100755 --- a/library/flutter_flow_chart/lib/src/dashboard.dart +++ b/library/flutter_flow_chart/lib/src/dashboard.dart @@ -28,8 +28,10 @@ class Dashboard extends ChangeNotifier { GlobalKey chartMenuKey = GlobalKey(); GlobalKey chartKey = GlobalKey(); GlobalKey flutterChartKey = GlobalKey(); + List> tempHistory = []; List> history = []; + Map scheduler = {}; Map info = {}; bool scheduleActive = false; @@ -58,7 +60,10 @@ class Dashboard extends ChangeNotifier { /// This is used to move the dashboard on the screen double widthOffset = 0; double heightOffset = 0; - /// + List saveRules = []; + + String? error; + Dashboard({ this.id, this.widthOffset = 0, @@ -104,7 +109,20 @@ class Dashboard extends ChangeNotifier { tempHistory = []; history = []; } - + Future saveDash(String? id) async { + shouldSave = true; + for (var element in saveRules) { + if (element(this)) { + shouldSave = true; + } else { + shouldSave = false; + break; + } + } + if (save != null && shouldSave) { + save!(id); + } + } Future Function(String cat)? load; /// @@ -305,23 +323,17 @@ class Dashboard extends ChangeNotifier { void addArrows(ArrowPainter f) { arrows.add(f); addChange = true; - if (save != null) { - save!(id); - } + saveDash(id); } void removeArrows(bool Function(ArrowPainter) f) { arrows.removeWhere((element) => f(element)); - if (save != null) { - save!(id); - } + saveDash(id); } void removeElements(bool Function(FlowElement) f) { elements.removeWhere((element) => f(element)); - if (save != null) { - save!(id); - } + saveDash(id); } void clear() { @@ -388,9 +400,7 @@ class Dashboard extends ChangeNotifier { bool notify = true, }) { element.isResizing = resizable; - if (save != null) { - save!(id); - } + saveDash(id); if (notify) notifyListeners(); } @@ -409,9 +419,7 @@ class Dashboard extends ChangeNotifier { element.setScale(1, gridBackgroundParams.scale); elements.add(element); addChange = true; - if (save != null) { - save!(id); - } + saveDash(id); if (notify) { notifyListeners(); } @@ -534,9 +542,7 @@ class Dashboard extends ChangeNotifier { void removeAllElements({bool notify = true}) { elements.clear(); if (notify) notifyListeners(); - if (save != null) { - save!(id); - } + saveDash(id); } /// remove the [handler] connection of [element] @@ -579,9 +585,7 @@ class Dashboard extends ChangeNotifier { } } if (notify) notifyListeners(); - if (save != null) { - save!(id); - } + saveDash(id); } /// dissect an element connection @@ -674,9 +678,7 @@ class Dashboard extends ChangeNotifier { void removeElementConnections(FlowElement element, {bool notify = true}) { element.next.clear(); if (notify) notifyListeners(); - if (save != null) { - save!(id); - } + saveDash(id); } /// remove all the elements with [id] from the dashboard @@ -697,9 +699,7 @@ class Dashboard extends ChangeNotifier { }); } if (notify) notifyListeners(); - if (save != null) { - save!(id); - } + saveDash(id); } /// remove element @@ -720,9 +720,7 @@ class Dashboard extends ChangeNotifier { ); } if (notify) notifyListeners(); - if (save != null) { - save!(id); - } + saveDash(id); return found; } diff --git a/library/flutter_flow_chart/lib/src/flow_chart_selected_menu.dart b/library/flutter_flow_chart/lib/src/flow_chart_selected_menu.dart index 77b8fbf..c77edd0 100644 --- a/library/flutter_flow_chart/lib/src/flow_chart_selected_menu.dart +++ b/library/flutter_flow_chart/lib/src/flow_chart_selected_menu.dart @@ -86,94 +86,89 @@ class FlowChartSelectedMenuState extends State { Text("STYLE ${widget.dashboard.elementSelected.isNotEmpty ? "ELEMENT" : "ARROW"}", style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold), textAlign: TextAlign.center), Text("<${widget.dashboard.arrowsSelected.isEmpty && widget.dashboard.elementSelected.isEmpty ? "general" : "selected"}>", style: TextStyle(fontSize: 12), textAlign: TextAlign.center), ])), - Container( width: 200, height: widget.height - 60, child: SingleChildScrollView( child: Column( children: [ + SizedBox( width: 200, height: widget.height - 60, child: SingleChildScrollView( child: Column( children: [ widget.dashboard.elementSelected.isNotEmpty ? Container() : Container( padding: EdgeInsets.symmetric(horizontal: 10, vertical: 20), decoration: BoxDecoration(border: Border(bottom: BorderSide(color: Colors.grey, width: 1))), child: Column( children: [ Row( children: [ - InkWell( mouseCursor: SystemMouseCursors.click, child: Container( - child: Padding( padding: EdgeInsets.only(left: 10, right: 10), - child: PopupMenuButton( - tooltip: "line defaults", - constraints: BoxConstraints(maxWidth: 100), - child: Row( children: [ - MySeparator( - width: 35, - dashWidth: widget.dashboard.defaultDashWidth, - dashSpace: widget.dashboard.defaultDashSpace, - color: Colors.black - ), - SizedBox(height: 25, width: 10), - Icon(Icons.arrow_drop_down, size: 10, color: Colors.black) ]), - initialValue: null, - onSelected: (ArrowDash value) { - if (widget.dashboard.elementSelected.isEmpty) { - for(var sel in widget.dashboard.arrowsSelected) { - sel.params.dashSpace = spaceArrowDash(value); - sel.params.dashWidth = widthArrowDash(value); - } - widget.dashboard.chartKey.currentState?.setState(() { }); + InkWell( mouseCursor: SystemMouseCursors.click, + child: Padding( padding: EdgeInsets.only(left: 10, right: 10), + child: PopupMenuButton( + tooltip: "line defaults", + constraints: BoxConstraints(maxWidth: 100), + initialValue: null, + onSelected: (ArrowDash value) { + if (widget.dashboard.elementSelected.isEmpty) { + for(var sel in widget.dashboard.arrowsSelected) { + sel.params.dashSpace = spaceArrowDash(value); + sel.params.dashWidth = widthArrowDash(value); } - widget.dashboard.defaultDashSpace = spaceArrowDash(value); - widget.dashboard.defaultDashWidth = widthArrowDash(value); - setState(() {}); - }, - itemBuilder: (BuildContext context) => >[ - PopupMenuItem( - value: ArrowDash.line, - child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.line), - dashSpace: spaceArrowDash(ArrowDash.line),) - ]), - ), - PopupMenuItem( - value: ArrowDash.largeDash, - child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.largeDash), dashSpace: spaceArrowDash(ArrowDash.largeDash),) - ]), - ), - PopupMenuItem( - value: ArrowDash.mediumDash, - child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.mediumDash), dashSpace: spaceArrowDash(ArrowDash.mediumDash),) - ]), - ), - PopupMenuItem( - value: ArrowDash.smallDash, - child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.smallDash), dashSpace: spaceArrowDash(ArrowDash.smallDash),) - ]), - ), - PopupMenuItem( - value: ArrowDash.heavyDotted, - child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.heavyDotted), dashSpace: spaceArrowDash(ArrowDash.heavyDotted),) - ]), - ), - PopupMenuItem( - value: ArrowDash.mediumDotted, - child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.mediumDotted), dashSpace: spaceArrowDash(ArrowDash.mediumDotted),) - ]), - ), - PopupMenuItem( - value: ArrowDash.lightDotted, - child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.lightDotted), dashSpace: spaceArrowDash(ArrowDash.lightDotted),) - ]), - ), - ] + widget.dashboard.chartKey.currentState?.setState(() { }); + } + widget.dashboard.defaultDashSpace = spaceArrowDash(value); + widget.dashboard.defaultDashWidth = widthArrowDash(value); + setState(() {}); + }, + itemBuilder: (BuildContext context) => >[ + PopupMenuItem( + value: ArrowDash.line, + child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ + MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.line), + dashSpace: spaceArrowDash(ArrowDash.line),) + ]), ), - ) + PopupMenuItem( + value: ArrowDash.largeDash, + child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ + MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.largeDash), dashSpace: spaceArrowDash(ArrowDash.largeDash),) + ]), + ), + PopupMenuItem( + value: ArrowDash.mediumDash, + child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ + MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.mediumDash), dashSpace: spaceArrowDash(ArrowDash.mediumDash),) + ]), + ), + PopupMenuItem( + value: ArrowDash.smallDash, + child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ + MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.smallDash), dashSpace: spaceArrowDash(ArrowDash.smallDash),) + ]), + ), + PopupMenuItem( + value: ArrowDash.heavyDotted, + child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ + MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.heavyDotted), dashSpace: spaceArrowDash(ArrowDash.heavyDotted),) + ]), + ), + PopupMenuItem( + value: ArrowDash.mediumDotted, + child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ + MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.mediumDotted), dashSpace: spaceArrowDash(ArrowDash.mediumDotted),) + ]), + ), + PopupMenuItem( + value: ArrowDash.lightDotted, + child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ + MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.lightDotted), dashSpace: spaceArrowDash(ArrowDash.lightDotted),) + ]), + ), + ], + child: Row( children: [ + MySeparator( + width: 35, + dashWidth: widget.dashboard.defaultDashWidth, + dashSpace: widget.dashboard.defaultDashSpace, + color: Colors.black + ), + SizedBox(height: 25, width: 10), + Icon(Icons.arrow_drop_down, size: 10, color: Colors.black) ]) + ), ) ), PopupMenuButton( tooltip: "color picker", constraints: BoxConstraints(maxWidth: 664), - child: Row( children: [ - Container(width: 15, height: 15, color: widget.dashboard.defaultColor), - Container(height: 25, width: 5), - Icon(Icons.arrow_drop_down, size: 10, color: Colors.black) ]), initialValue: null, onSelected: (void value) {}, itemBuilder: (BuildContext context) => >[ @@ -186,7 +181,11 @@ class FlowChartSelectedMenuState extends State { setState(() { widget.dashboard.defaultColor = value; }); },), ), - ] + ], + child: Row( children: [ + Container(width: 15, height: 15, color: widget.dashboard.defaultColor), + SizedBox(height: 25, width: 5), + Icon(Icons.arrow_drop_down, size: 10, color: Colors.black) ]) ), Tooltip( message: "stroke width", child: Container( @@ -228,50 +227,49 @@ class FlowChartSelectedMenuState extends State { ))) ]), Row(children: [ - InkWell( mouseCursor: SystemMouseCursors.click, child: Container( - child: Padding( padding: EdgeInsets.only(left: 10, top: 10, right: 10), - child: PopupMenuButton( - child: - Row( children: [ Icon(widget.dashboard.defaultArrowStyle == ArrowStyle.segmented ? Icons.turn_slight_left : widget.dashboard.defaultArrowStyle == ArrowStyle.curve ? Icons.roundabout_left : Icons.turn_sharp_left_outlined - , color: Colors.black), - Icon(Icons.arrow_drop_down, size: 10, color: Colors.black) ]), - initialValue: null, - onSelected: (ArrowStyle value) { - if (widget.dashboard.elementSelected.isEmpty) { - for(var sel in widget.dashboard.arrowsSelected) { sel.params.style = value; } - widget.dashboard.chartKey.currentState?.setState(() { }); - } - widget.dashboard.defaultArrowStyle = value; - setState(() {}); - }, - tooltip: "line styles", - itemBuilder: (BuildContext context) => >[ - PopupMenuItem( - value: ArrowStyle.segmented, - child: Row( children: [ - Icon(Icons.turn_slight_left), - Padding( padding: EdgeInsets.only(left: 10), - child: Text('straight', textAlign: TextAlign.center,)) - ]), - ), - PopupMenuItem( - value: ArrowStyle.curve, - child: Row( children: [ - Icon(Icons.roundabout_left), - Padding( padding: EdgeInsets.only(left: 10), - child: Text('curved', textAlign: TextAlign.center,)) - ]), - ), - PopupMenuItem( - value: ArrowStyle.rectangular, - child: Row( children: [ - Icon(Icons.turn_sharp_left_outlined), - Padding( padding: EdgeInsets.only(left: 10), - child: Text('rectangular', textAlign: TextAlign.center,)) - ]), - ), - ] - ) + InkWell( mouseCursor: SystemMouseCursors.click, child: Padding( + padding: EdgeInsets.only(left: 10, top: 10, right: 10), + child: PopupMenuButton( + initialValue: null, + onSelected: (ArrowStyle value) { + if (widget.dashboard.elementSelected.isEmpty) { + for(var sel in widget.dashboard.arrowsSelected) { sel.params.style = value; } + widget.dashboard.chartKey.currentState?.setState(() { }); + } + widget.dashboard.defaultArrowStyle = value; + setState(() {}); + }, + tooltip: "line styles", + itemBuilder: (BuildContext context) => >[ + PopupMenuItem( + value: ArrowStyle.segmented, + child: Row( children: [ + Icon(Icons.turn_slight_left), + Padding( padding: EdgeInsets.only(left: 10), + child: Text('straight', textAlign: TextAlign.center,)) + ]), + ), + PopupMenuItem( + value: ArrowStyle.curve, + child: Row( children: [ + Icon(Icons.roundabout_left), + Padding( padding: EdgeInsets.only(left: 10), + child: Text('curved', textAlign: TextAlign.center,)) + ]), + ), + PopupMenuItem( + value: ArrowStyle.rectangular, + child: Row( children: [ + Icon(Icons.turn_sharp_left_outlined), + Padding( padding: EdgeInsets.only(left: 10), + child: Text('rectangular', textAlign: TextAlign.center,)) + ]), + ), + ], + child: + Row( children: [ Icon(widget.dashboard.defaultArrowStyle == ArrowStyle.segmented ? Icons.turn_slight_left : widget.dashboard.defaultArrowStyle == ArrowStyle.curve ? Icons.roundabout_left : Icons.turn_sharp_left_outlined + , color: Colors.black), + Icon(Icons.arrow_drop_down, size: 10, color: Colors.black) ]) ) ) ), @@ -352,60 +350,57 @@ class FlowChartSelectedMenuState extends State { ))) ]), ])), - widget.dashboard.elementSelected.isNotEmpty && widget.dashboard.elementSelected.length == 1 ? Container( - // TODO : TEST OMG - ) : Container(), - widget.dashboard.elementSelected.isNotEmpty ? Container() : Container( padding: EdgeInsets.only(left: 10, right: 10, bottom: 20, top: 15), + widget.dashboard.elementSelected.isNotEmpty ? Container() : + Container( padding: EdgeInsets.only(left: 10, right: 10, bottom: 20, top: 15), decoration: BoxDecoration(border: Border(bottom: BorderSide(color: Colors.grey, width: 1))), child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children : [ - InkWell( mouseCursor: SystemMouseCursors.click, child: Container( - child: Padding( padding: EdgeInsets.symmetric(horizontal: 10), - child: PopupMenuButton( - child: - Row( children: [ - Icon(widget.dashboard.defaultArrowDirection == ArrowDirection.forward ? Icons.arrow_forward : widget.dashboard.defaultArrowDirection == ArrowDirection.backward ? Icons.arrow_back : Icons.sync_alt_outlined, color: Colors.black), - Padding( padding: EdgeInsets.symmetric(horizontal: 10), - child: Text(widget.dashboard.defaultArrowDirection == ArrowDirection.forward ? 'forward' : widget.dashboard.defaultArrowDirection == ArrowDirection.backward ? 'backward' : 'bidirectionnal')), - Icon(Icons.arrow_drop_down, size: 10, color: Colors.black) ]), - initialValue: null, - onSelected: (ArrowDirection value) { - if (widget.dashboard.elementSelected.isEmpty) { - for(var sel in widget.dashboard.arrowsSelected) { sel.params.direction = value; } - widget.dashboard.chartKey.currentState?.setState(() { }); - } - widget.dashboard.defaultArrowDirection = value; - setState(() {}); - }, - tooltip: widget.dashboard.defaultArrowDirection == ArrowDirection.forward ? 'forward' : widget.dashboard.defaultArrowDirection == ArrowDirection.backward ? 'backward' : 'bidirectionnal', - itemBuilder: (BuildContext context) => >[ - PopupMenuItem( - value: ArrowDirection.forward, - child: Row( children: [ - Icon(Icons.arrow_forward), - Padding( padding: EdgeInsets.only(left: 10), - child: Text('forward', textAlign: TextAlign.center,)) - ]), - ), - PopupMenuItem( - value: ArrowDirection.backward, - child: Row( children: [ - Icon(Icons.arrow_back), - Padding( padding: EdgeInsets.only(left: 10), - child: Text('curved', textAlign: TextAlign.center,)) - ]), - ), - PopupMenuItem( - value: ArrowDirection.bidirectionnal, - child: Row( children: [ - Icon(Icons.sync_alt_outlined), - Padding( padding: EdgeInsets.only(left: 10), - child: Text('bidirectionnal', textAlign: TextAlign.center,)) - ]), - ), - ] - ),) - ) + InkWell( mouseCursor: SystemMouseCursors.click, + child: Padding( padding: EdgeInsets.symmetric(horizontal: 10), + child: PopupMenuButton( + initialValue: null, + onSelected: (ArrowDirection value) { + if (widget.dashboard.elementSelected.isEmpty) { + for(var sel in widget.dashboard.arrowsSelected) { sel.params.direction = value; } + widget.dashboard.chartKey.currentState?.setState(() { }); + } + widget.dashboard.defaultArrowDirection = value; + setState(() {}); + }, + tooltip: widget.dashboard.defaultArrowDirection == ArrowDirection.forward ? 'forward' : widget.dashboard.defaultArrowDirection == ArrowDirection.backward ? 'backward' : 'bidirectionnal', + itemBuilder: (BuildContext context) => >[ + PopupMenuItem( + value: ArrowDirection.forward, + child: Row( children: [ + Icon(Icons.arrow_forward), + Padding( padding: EdgeInsets.only(left: 10), + child: Text('forward', textAlign: TextAlign.center,)) + ]), + ), + PopupMenuItem( + value: ArrowDirection.backward, + child: Row( children: [ + Icon(Icons.arrow_back), + Padding( padding: EdgeInsets.only(left: 10), + child: Text('curved', textAlign: TextAlign.center,)) + ]), + ), + PopupMenuItem( + value: ArrowDirection.bidirectionnal, + child: Row( children: [ + Icon(Icons.sync_alt_outlined), + Padding( padding: EdgeInsets.only(left: 10), + child: Text('bidirectionnal', textAlign: TextAlign.center,)) + ]), + ), + ], + child: + Row( children: [ + Icon(widget.dashboard.defaultArrowDirection == ArrowDirection.forward ? Icons.arrow_forward : widget.dashboard.defaultArrowDirection == ArrowDirection.backward ? Icons.arrow_back : Icons.sync_alt_outlined, color: Colors.black), + Padding( padding: EdgeInsets.symmetric(horizontal: 10), + child: Text(widget.dashboard.defaultArrowDirection == ArrowDirection.forward ? 'forward' : widget.dashboard.defaultArrowDirection == ArrowDirection.backward ? 'backward' : 'bidirectionnal')), + Icon(Icons.arrow_drop_down, size: 10, color: Colors.black) ]) + ),) ), ]), Row(children: [ @@ -560,46 +555,51 @@ class FlowChartSelectedMenuState extends State { } return Column( children: [ Container( // SHORTCUT - width: 200, - height: 50, - decoration: BoxDecoration(color: widget.dashboard.midDashColor, border: Border(bottom: BorderSide(color: Colors.grey, width: 1))), - child: Row( children: [ - Tooltip( - message: "dashboard information", - child: InkWell( onTap: () => setState(() {widget.isDashboardInfo = true; }), - mouseCursor: SystemMouseCursors.click, - child: Container( alignment: Alignment.center, - padding: EdgeInsets.symmetric(vertical: 10), - color: widget.isDashboardInfo ? Colors.grey : widget.dashboard.midDashColor, - width: 200 / 2, child: Icon(Icons.info, color: Colors.white)) - ) - ), - Tooltip( - message: "element style", - child: InkWell( onTap: () => setState(() {widget.isDashboardInfo = false; }), - mouseCursor: SystemMouseCursors.click, - child: Container( alignment: Alignment.center, - padding: EdgeInsets.symmetric(vertical: 10), - color: !widget.isDashboardInfo ? Colors.grey : widget.dashboard.midDashColor, - width: 200 / 2, child: Icon(Icons.format_paint, color: Colors.white)), - )) - ])), + width: 200, height: 50, + decoration: BoxDecoration(color: widget.dashboard.midDashColor, + border: Border(bottom: BorderSide(color: Colors.grey, width: 1))), + child: Row( children: [ + Tooltip( message: "dashboard information", + child: InkWell( onTap: () => setState(() {widget.isDashboardInfo = true; }), + mouseCursor: SystemMouseCursors.click, + child: Container( alignment: Alignment.center, + padding: EdgeInsets.symmetric(vertical: 10), + color: widget.isDashboardInfo ? Colors.grey : widget.dashboard.midDashColor, + width: 200 / 2, child: Icon(Icons.info, color: Colors.white)) + ) + ), + Tooltip( + message: "element style", + child: InkWell( onTap: () => setState(() {widget.isDashboardInfo = false; }), + mouseCursor: SystemMouseCursors.click, + child: Container( alignment: Alignment.center, + padding: EdgeInsets.symmetric(vertical: 10), + color: !widget.isDashboardInfo ? Colors.grey : widget.dashboard.midDashColor, + width: 200 / 2, child: Icon(Icons.format_paint, color: Colors.white)), + ) + ) + ] + ) + ), + widget.dashboard.error != null ? Container( width: 200, color: Colors.red, padding: EdgeInsets.all(10), + child: Center( child: Text(widget.dashboard.error!, + style: TextStyle(color: Colors.white, fontSize: 15), textAlign: TextAlign.center))) : Container(), w ]); } } +// ignore: must_be_immutable class MySeparator extends StatelessWidget { double width = 1; double dashWidth = 10; double dashSpace = 10; - MySeparator({Key? key, this.width = 1, this.dashSpace = 10, this.dashWidth = 10, - this.height = 1, this.color = Colors.black}) - : super(key: key); + MySeparator({super.key, this.width = 1, this.dashSpace = 10, this.dashWidth = 10, + this.height = 1, this.color = Colors.black}); final double height; final Color color; @override Widget build(BuildContext context) { - return Container( width: width, child: dashSpace == 0 ? + return SizedBox( width: width, child: dashSpace == 0 ? Divider( thickness: 2, color: color ) : DottedLine( dashLength: dashWidth,