Compare commits

..

No commits in common. "e73ca6b532662123d7dbee9e883323549e911ca8" and "2ceab090fde7e6294ebec751d3f98520a9c8c995" have entirely different histories.

13 changed files with 300 additions and 369 deletions

View File

@ -42,42 +42,51 @@ Map<Perms, String> perms = {
class PermsService {
static final Map<Perms, bool> _perms = {
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,
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,
};
static final PermsService _instance = PermsService._internal();
factory PermsService() => _instance;
PermsService._internal();
/* should decode claims such as in oc-auth */
static Future<void> 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<String, dynamic>;
for (var w in perms.keys) {
if (what.keys.contains(perms[w])) {
_perms[w] = true;
for (var w in perms.values) {
if (what.keys.contains(w)) {
print("CONTAINS");
} else {
_perms[w] = false;
for (var y in what.keys) {
print("${w}, ${y} ${what.keys.contains(w)}");
}
}
}
} catch (e) {/**/}
} catch (e) {
print("THERE");
}*/
_perms.forEach((key, value) {
_perms[key] = true;
});
}
static void clear() {

View File

@ -11,6 +11,7 @@ class WorkflowExecutionService extends AbstractService<WorkflowExecutions> {
@override String subPath = "/";
@override Future<APIResponse<WorkflowExecutions>> search(BuildContext? context, List<String> words, Map<String, dynamic> params) {
print("${subPath}search/${words.join("/")}");
return service.get("${subPath}search/${words.join("/")}", false, context);
}

View File

@ -25,7 +25,10 @@ class SchedulerPageWidget extends StatefulWidget {
static void search(BuildContext context) { }
static Widget factory() { return SchedulerPageWidget(); }
}
class SchedulerPageWidgetState extends State<SchedulerPageWidget> {
class SchedulerPageWidgetState extends State<SchedulerPageWidget> {
List<Color> colors = [Colors.blue, Colors.orange, redColor, Colors.green, redColor];
List<String> titles = ["SCHEDULED", "RUNNING", "FAILURE", "SUCCESS", "FORGOTTEN"];
@override Widget build(BuildContext context) {
GlobalKey<ScheduleWidgetState> k = GlobalKey<ScheduleWidgetState>();
return Column( children: [

View File

@ -87,15 +87,15 @@ final WorflowService _service = WorflowService();
if (objAbs.topic == "compute" ) {
var compute = objAbs as ComputeItem;
if (compute.technology == 0) {
return Icon(FontAwesomeIcons.docker, size: 16);
return Icon(FontAwesomeIcons.docker, size: 18);
} else if (compute.technology == 1) {
return Icon(FontAwesomeIcons.lifeRing, size: 16);
return Icon(FontAwesomeIcons.lifeRing, size: 18);
} else if (compute.technology == 2) {
return Icon(FontAwesomeIcons.cubes, size: 16);
return Icon(FontAwesomeIcons.cubes, size: 18);
} else if (compute.technology == 3) {
return Icon(FontAwesomeIcons.hardDrive, size: 16);
return Icon(FontAwesomeIcons.hardDrive, size: 18);
} else if (compute.technology == 4) {
return Icon(FontAwesomeIcons.v, size: 16);
return Icon(FontAwesomeIcons.v, size: 18);
}
}
return null;
@ -105,15 +105,15 @@ final WorflowService _service = WorflowService();
var objAbs = obj as AbstractItem?;
if (objAbs == null) { return null; }
if (objAbs.topic == "processing" ) {
return Icon(FontAwesomeIcons.gear, size: 16);
return Icon(FontAwesomeIcons.gear) ;
} else if (objAbs.topic == "data" ) {
return Icon(FontAwesomeIcons.file, size: 16);
return Icon(FontAwesomeIcons.file);
} else if (objAbs.topic == "storage" ) {
return Icon(FontAwesomeIcons.database, size: 16);
return Icon(FontAwesomeIcons.database);
} else if (objAbs.topic == "compute" ) {
return Icon(FontAwesomeIcons.microchip, size: 16);
return Icon(FontAwesomeIcons.microchip);
} else if (objAbs.topic == "workflows" ) {
return Icon(FontAwesomeIcons.diagramProject, size: 16);
return Icon(FontAwesomeIcons.diagramProject);
}
return null;
}
@ -290,64 +290,6 @@ final WorflowService _service = WorflowService();
dash.infoItemWidget = getForms;
dash.infoWidget = getDashInfoForms;
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) {
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<AbstractItem>(
key: dash.flutterChartKey,
itemLeftBottomBadges: getBottomLeftBadge,

View File

@ -73,7 +73,7 @@ class ProcessingFormsWidgetState extends State<ProcessingFormsWidget> {
widget.item.model ?? Model();
Future.delayed(const Duration(seconds: 2), () {
if (widget.item.getVariable([child, st], widget.item.serialize()) == value) {
dash.saveDash(dash.id);
dash.save!(dash.id);
}
});
var el = dash.getElement(widget.elementID);

View File

@ -48,7 +48,7 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
dash.scheduler["end"] = now.add(const Duration(minutes: 1)).toUtc().toIso8601String();
}
}
widget.item.saveDash(widget.item.id);
widget.item.save!(widget.item.id);
}
void checkBooking(List<GlobalKey<FormFieldState>> formKeys, void Function(List<GlobalKey<FormFieldState>> )? f){
if (widget.item.scheduler["start"] == null) {
@ -93,18 +93,12 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
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"]!);
@ -112,13 +106,6 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
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<GlobalKey<FormFieldState>> formKeys = [GlobalKey<FormFieldState>(), GlobalKey<FormFieldState>(), GlobalKey<FormFieldState>(), GlobalKey<FormFieldState>()];
var shallow = ShallowTextInputWidget(
@ -173,7 +160,7 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
onChanged: (value) {
Future.delayed(const Duration(seconds: 100), () {
if (widget.item.scheduler["name"] == value) {
widget.item.saveDash(widget.item.id);
widget.item.save!(widget.item.id);
}
});
widget.item.scheduler["name"] = value;
@ -196,11 +183,11 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
labelText: "executions name*",
hintStyle: TextStyle(fontSize: 10),
labelStyle: TextStyle(fontSize: 10),
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)),
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)),
contentPadding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
),
))),
@ -267,7 +254,7 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
date = DateTime(date.year, date.month, date.day, time.hour, time.minute);
widget.item.scheduler["start"] = date.toUtc().toIso8601String();
}
widget.item.saveDash(widget.item.id);
widget.item.save!(widget.item.id);
}
return date;
},
@ -372,7 +359,7 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
date = DateTime(date.year, date.month, date.day, time.hour, time.minute);
widget.item.scheduler["end"] = date.toUtc().toIso8601String();
}
widget.item.saveDash(widget.item.id);
widget.item.save!(widget.item.id);
}
return date;
},
@ -405,7 +392,7 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
onChanged: (value) {
Future.delayed(const Duration(seconds: 100), () {
if (widget.item.scheduler["cron"] == value) {
widget.item.saveDash(widget.item.id);
widget.item.save!(widget.item.id);
}
});
widget.item.scheduler["cron"] = value;

View File

@ -29,7 +29,7 @@ class SubExposeFormsWidgetState extends State<SubExposeFormsWidget> {
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.saveDash(widget.dash.id);
widget.dash.save!(widget.dash.id);
}
});
} catch (e) { widget.item.port = null; }
@ -44,7 +44,7 @@ class SubExposeFormsWidgetState extends State<SubExposeFormsWidget> {
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.saveDash(widget.dash.id);
widget.dash.save!(widget.dash.id);
}
});
} catch (e) { widget.item.PAT = null; }
@ -57,7 +57,7 @@ class SubExposeFormsWidgetState extends State<SubExposeFormsWidget> {
try {
widget.item.path = value;
Future.delayed(const Duration(seconds: 2), () {
if (widget.item.path == value) { widget.dash.saveDash(widget.dash.id); }
if (widget.item.path == value) { widget.dash.save!(widget.dash.id); }
});
} catch (e) { widget.item.path = null; }
var el = widget.dash.getElement(widget.elementID);

View File

@ -1,5 +1,6 @@
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';
@ -45,7 +46,7 @@ class SubKeysMapFormsWidgetState extends State<SubKeysMapFormsWidget> {
}
}
if (save) {
widget.dash.saveDash(widget.dash.id);
widget.dash.save!(widget.dash.id);
}
if (children.isEmpty) {
return Container();

View File

@ -52,7 +52,7 @@ class SubMapFormsWidgetState extends State<SubMapFormsWidget> {
setState(() {
widget.forms[i].key = value;
Future.delayed(const Duration(seconds: 2), () {
widget.dash.saveDash(widget.dash.id);
widget.dash.save!(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<SubMapFormsWidget> {
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.saveDash(widget.dash.id);
widget.dash.save!(widget.dash.id);
});
widget.forms[i].value = value;
var el = widget.dash.getElement(widget.elementID);
@ -99,7 +99,7 @@ class SubMapFormsWidgetState extends State<SubMapFormsWidget> {
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.saveDash(widget.dash.id); });
setState(() { widget.dash.save!(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)),

View File

@ -31,6 +31,7 @@ class ScheduleWidgetState extends State<ScheduleWidget> {
String search = "";
String? level;
List<Color> colors = [Colors.blue, Colors.orange, redColor, Colors.green, redColor];
List<String> titles = ["SCHEDULED", "RUNNING", "FAILURE", "SUCCESS", "MISSED"];
DateTime getFocusedDay() {
if (selected != null) { return DateTime.parse(selected!); }

View File

@ -28,10 +28,8 @@ class Dashboard extends ChangeNotifier {
GlobalKey<FlowChartMenuState> chartMenuKey = GlobalKey<FlowChartMenuState>();
GlobalKey<ChartWidgetState> chartKey = GlobalKey<ChartWidgetState>();
GlobalKey<FlowChartState> flutterChartKey = GlobalKey<FlowChartState>();
List<Map<String, dynamic>> tempHistory = [];
List<Map<String, dynamic>> history = [];
Map<String, dynamic> scheduler = {};
Map<String, dynamic> info = {};
bool scheduleActive = false;
@ -60,11 +58,7 @@ class Dashboard extends ChangeNotifier {
/// This is used to move the dashboard on the screen
double widthOffset = 0;
double heightOffset = 0;
List<bool Function(Dashboard)> saveRules = [];
List<List<ArrowPainter> Function(Dashboard)> arrowStyleRules = [];
String? error;
///
Dashboard({
this.id,
this.widthOffset = 0,
@ -110,20 +104,7 @@ class Dashboard extends ChangeNotifier {
tempHistory = [];
history = [];
}
Future<void> 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<void> Function(String cat)? load;
///
@ -153,9 +134,7 @@ class Dashboard extends ChangeNotifier {
map['dashboardSizeWidth'] as double? ?? 0,
map['dashboardSizeHeight'] as double? ?? 0,
);
for (var f in d.arrowStyleRules) {
d.arrows = f(d);
}
if (map['gridBackgroundParams'] != null) {
d.gridBackgroundParams = GridBackgroundParams.fromMap(
map['gridBackgroundParams'] as Map<String, dynamic>,
@ -182,9 +161,6 @@ class Dashboard extends ChangeNotifier {
(x) => ArrowPainter.fromMap(x as Map<String, dynamic>),
),
);
for (var f in arrowStyleRules) {
arrows = f(this);
}
elements = List<FlowElement>.from(
(map['elements'] as List<dynamic>).map<FlowElement>(
(x) => FlowElement.fromMap(this, x as Map<String, dynamic>),
@ -250,9 +226,6 @@ class Dashboard extends ChangeNotifier {
for(var el in elements) {
graph['elements'][el.id] = el.serialize();
}
for (var f in arrowStyleRules) {
arrows = f(this);
}
graph['arrows'] = arrows.map((e) => e.serialize()).toList();
d["id"]=id;
d["name"]=name;
@ -331,24 +304,24 @@ class Dashboard extends ChangeNotifier {
void addArrows(ArrowPainter f) {
arrows.add(f);
for (var f in arrowStyleRules) {
arrows = f(this);
}
addChange = true;
saveDash(id);
if (save != null) {
save!(id);
}
}
void removeArrows(bool Function(ArrowPainter) f) {
arrows.removeWhere((element) => f(element));
for (var f in arrowStyleRules) {
arrows = f(this);
if (save != null) {
save!(id);
}
saveDash(id);
}
void removeElements(bool Function(FlowElement<FlowData>) f) {
elements.removeWhere((element) => f(element));
saveDash(id);
if (save != null) {
save!(id);
}
}
void clear() {
@ -415,7 +388,9 @@ class Dashboard extends ChangeNotifier {
bool notify = true,
}) {
element.isResizing = resizable;
saveDash(id);
if (save != null) {
save!(id);
}
if (notify) notifyListeners();
}
@ -434,7 +409,9 @@ class Dashboard extends ChangeNotifier {
element.setScale(1, gridBackgroundParams.scale);
elements.add(element);
addChange = true;
saveDash(id);
if (save != null) {
save!(id);
}
if (notify) {
notifyListeners();
}
@ -557,7 +534,9 @@ class Dashboard extends ChangeNotifier {
void removeAllElements({bool notify = true}) {
elements.clear();
if (notify) notifyListeners();
saveDash(id);
if (save != null) {
save!(id);
}
}
/// remove the [handler] connection of [element]
@ -600,7 +579,9 @@ class Dashboard extends ChangeNotifier {
}
}
if (notify) notifyListeners();
saveDash(id);
if (save != null) {
save!(id);
}
}
/// dissect an element connection
@ -693,7 +674,9 @@ class Dashboard extends ChangeNotifier {
void removeElementConnections(FlowElement element, {bool notify = true}) {
element.next.clear();
if (notify) notifyListeners();
saveDash(id);
if (save != null) {
save!(id);
}
}
/// remove all the elements with [id] from the dashboard
@ -714,7 +697,9 @@ class Dashboard extends ChangeNotifier {
});
}
if (notify) notifyListeners();
saveDash(id);
if (save != null) {
save!(id);
}
}
/// remove element
@ -735,7 +720,9 @@ class Dashboard extends ChangeNotifier {
);
}
if (notify) notifyListeners();
saveDash(id);
if (save != null) {
save!(id);
}
return found;
}

View File

@ -86,89 +86,94 @@ class FlowChartSelectedMenuState extends State<FlowChartSelectedMenu> {
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),
])),
SizedBox( width: 200, height: widget.height - 60, child: SingleChildScrollView( child: Column( children: [
Container( 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: Padding( padding: EdgeInsets.only(left: 10, right: 10),
child: PopupMenuButton<ArrowDash>(
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);
InkWell( mouseCursor: SystemMouseCursors.click, child: Container(
child: Padding( padding: EdgeInsets.only(left: 10, right: 10),
child: PopupMenuButton<ArrowDash>(
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(() { });
}
widget.dashboard.chartKey.currentState?.setState(() { });
}
widget.dashboard.defaultDashSpace = spaceArrowDash(value);
widget.dashboard.defaultDashWidth = widthArrowDash(value);
setState(() {});
},
itemBuilder: (BuildContext context) => <PopupMenuEntry<ArrowDash>>[
PopupMenuItem<ArrowDash>(
value: ArrowDash.line,
child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [
MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.line),
dashSpace: spaceArrowDash(ArrowDash.line),)
]),
widget.dashboard.defaultDashSpace = spaceArrowDash(value);
widget.dashboard.defaultDashWidth = widthArrowDash(value);
setState(() {});
},
itemBuilder: (BuildContext context) => <PopupMenuEntry<ArrowDash>>[
PopupMenuItem<ArrowDash>(
value: ArrowDash.line,
child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [
MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.line),
dashSpace: spaceArrowDash(ArrowDash.line),)
]),
),
PopupMenuItem<ArrowDash>(
value: ArrowDash.largeDash,
child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [
MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.largeDash), dashSpace: spaceArrowDash(ArrowDash.largeDash),)
]),
),
PopupMenuItem<ArrowDash>(
value: ArrowDash.mediumDash,
child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [
MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.mediumDash), dashSpace: spaceArrowDash(ArrowDash.mediumDash),)
]),
),
PopupMenuItem<ArrowDash>(
value: ArrowDash.smallDash,
child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [
MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.smallDash), dashSpace: spaceArrowDash(ArrowDash.smallDash),)
]),
),
PopupMenuItem<ArrowDash>(
value: ArrowDash.heavyDotted,
child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [
MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.heavyDotted), dashSpace: spaceArrowDash(ArrowDash.heavyDotted),)
]),
),
PopupMenuItem<ArrowDash>(
value: ArrowDash.mediumDotted,
child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [
MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.mediumDotted), dashSpace: spaceArrowDash(ArrowDash.mediumDotted),)
]),
),
PopupMenuItem<ArrowDash>(
value: ArrowDash.lightDotted,
child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [
MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.lightDotted), dashSpace: spaceArrowDash(ArrowDash.lightDotted),)
]),
),
]
),
PopupMenuItem<ArrowDash>(
value: ArrowDash.largeDash,
child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [
MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.largeDash), dashSpace: spaceArrowDash(ArrowDash.largeDash),)
]),
),
PopupMenuItem<ArrowDash>(
value: ArrowDash.mediumDash,
child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [
MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.mediumDash), dashSpace: spaceArrowDash(ArrowDash.mediumDash),)
]),
),
PopupMenuItem<ArrowDash>(
value: ArrowDash.smallDash,
child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [
MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.smallDash), dashSpace: spaceArrowDash(ArrowDash.smallDash),)
]),
),
PopupMenuItem<ArrowDash>(
value: ArrowDash.heavyDotted,
child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [
MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.heavyDotted), dashSpace: spaceArrowDash(ArrowDash.heavyDotted),)
]),
),
PopupMenuItem<ArrowDash>(
value: ArrowDash.mediumDotted,
child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [
MySeparator(width: 25, dashWidth: widthArrowDash(ArrowDash.mediumDotted), dashSpace: spaceArrowDash(ArrowDash.mediumDotted),)
]),
),
PopupMenuItem<ArrowDash>(
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<void>(
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) => <PopupMenuEntry<void>>[
@ -181,11 +186,7 @@ class FlowChartSelectedMenuState extends State<FlowChartSelectedMenu> {
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(
@ -227,49 +228,50 @@ class FlowChartSelectedMenuState extends State<FlowChartSelectedMenu> {
)))
]),
Row(children: [
InkWell( mouseCursor: SystemMouseCursors.click, child: Padding(
padding: EdgeInsets.only(left: 10, top: 10, right: 10),
child: PopupMenuButton<ArrowStyle>(
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) => <PopupMenuEntry<ArrowStyle>>[
PopupMenuItem<ArrowStyle>(
value: ArrowStyle.segmented,
child: Row( children: [
Icon(Icons.turn_slight_left),
Padding( padding: EdgeInsets.only(left: 10),
child: Text('straight', textAlign: TextAlign.center,))
]),
),
PopupMenuItem<ArrowStyle>(
value: ArrowStyle.curve,
child: Row( children: [
Icon(Icons.roundabout_left),
Padding( padding: EdgeInsets.only(left: 10),
child: Text('curved', textAlign: TextAlign.center,))
]),
),
PopupMenuItem<ArrowStyle>(
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) ])
InkWell( mouseCursor: SystemMouseCursors.click, child: Container(
child: Padding( padding: EdgeInsets.only(left: 10, top: 10, right: 10),
child: PopupMenuButton<ArrowStyle>(
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) => <PopupMenuEntry<ArrowStyle>>[
PopupMenuItem<ArrowStyle>(
value: ArrowStyle.segmented,
child: Row( children: [
Icon(Icons.turn_slight_left),
Padding( padding: EdgeInsets.only(left: 10),
child: Text('straight', textAlign: TextAlign.center,))
]),
),
PopupMenuItem<ArrowStyle>(
value: ArrowStyle.curve,
child: Row( children: [
Icon(Icons.roundabout_left),
Padding( padding: EdgeInsets.only(left: 10),
child: Text('curved', textAlign: TextAlign.center,))
]),
),
PopupMenuItem<ArrowStyle>(
value: ArrowStyle.rectangular,
child: Row( children: [
Icon(Icons.turn_sharp_left_outlined),
Padding( padding: EdgeInsets.only(left: 10),
child: Text('rectangular', textAlign: TextAlign.center,))
]),
),
]
)
)
)
),
@ -350,57 +352,60 @@ class FlowChartSelectedMenuState extends State<FlowChartSelectedMenu> {
)))
]),
])),
widget.dashboard.elementSelected.isNotEmpty ? Container() :
Container( padding: EdgeInsets.only(left: 10, right: 10, bottom: 20, top: 15),
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),
decoration: BoxDecoration(border: Border(bottom: BorderSide(color: Colors.grey, width: 1))),
child: Column( children: [
Row( mainAxisAlignment: MainAxisAlignment.center, children : [
InkWell( mouseCursor: SystemMouseCursors.click,
child: Padding( padding: EdgeInsets.symmetric(horizontal: 10),
child: PopupMenuButton<ArrowDirection>(
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) => <PopupMenuEntry<ArrowDirection>>[
PopupMenuItem<ArrowDirection>(
value: ArrowDirection.forward,
child: Row( children: [
Icon(Icons.arrow_forward),
Padding( padding: EdgeInsets.only(left: 10),
child: Text('forward', textAlign: TextAlign.center,))
]),
),
PopupMenuItem<ArrowDirection>(
value: ArrowDirection.backward,
child: Row( children: [
Icon(Icons.arrow_back),
Padding( padding: EdgeInsets.only(left: 10),
child: Text('curved', textAlign: TextAlign.center,))
]),
),
PopupMenuItem<ArrowDirection>(
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) ])
),)
InkWell( mouseCursor: SystemMouseCursors.click, child: Container(
child: Padding( padding: EdgeInsets.symmetric(horizontal: 10),
child: PopupMenuButton<ArrowDirection>(
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) => <PopupMenuEntry<ArrowDirection>>[
PopupMenuItem<ArrowDirection>(
value: ArrowDirection.forward,
child: Row( children: [
Icon(Icons.arrow_forward),
Padding( padding: EdgeInsets.only(left: 10),
child: Text('forward', textAlign: TextAlign.center,))
]),
),
PopupMenuItem<ArrowDirection>(
value: ArrowDirection.backward,
child: Row( children: [
Icon(Icons.arrow_back),
Padding( padding: EdgeInsets.only(left: 10),
child: Text('curved', textAlign: TextAlign.center,))
]),
),
PopupMenuItem<ArrowDirection>(
value: ArrowDirection.bidirectionnal,
child: Row( children: [
Icon(Icons.sync_alt_outlined),
Padding( padding: EdgeInsets.only(left: 10),
child: Text('bidirectionnal', textAlign: TextAlign.center,))
]),
),
]
),)
)
),
]),
Row(children: [
@ -555,51 +560,46 @@ class FlowChartSelectedMenuState extends State<FlowChartSelectedMenu> {
}
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)),
)
)
]
)
),
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(),
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)),
))
])),
w
]);
}
}
// ignore: must_be_immutable
class MySeparator extends StatelessWidget {
double width = 1; double dashWidth = 10; double dashSpace = 10;
MySeparator({super.key, this.width = 1, this.dashSpace = 10, this.dashWidth = 10,
this.height = 1, this.color = Colors.black});
MySeparator({Key? key, this.width = 1, this.dashSpace = 10, this.dashWidth = 10,
this.height = 1, this.color = Colors.black})
: super(key: key);
final double height;
final Color color;
@override
Widget build(BuildContext context) {
return SizedBox( width: width, child: dashSpace == 0 ?
return Container( width: width, child: dashSpace == 0 ?
Divider( thickness: 2, color: color )
: DottedLine(
dashLength: dashWidth,

View File

@ -352,7 +352,7 @@ class DrawArrowState extends State<DrawArrow> {
if ( widget.flow.widget.dashboard.arrows.where(
(element) => element.fromID == "${widget.srcElement.id}_${widget.index}").isEmpty) {
widget.flow.widget.dashboard.addArrows(painter);
widget.flow.widget.dashboard.saveDash(widget.flow.widget.dashboard.id);
widget.flow.widget.dashboard.save!(widget.flow.widget.dashboard.id);
} else {
var i = widget.flow.widget.dashboard.arrows.indexWhere(
(element) => element.fromID == "${widget.srcElement.id}_${widget.index}");