New local front deployment + new args

This commit is contained in:
mr
2024-10-15 11:28:29 +02:00
parent dacda3b3a6
commit 685badc59a
32 changed files with 952 additions and 325 deletions

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:oc_front/models/search.dart';
import 'package:oc_front/widgets/forms/web_reference_forms.dart';
class DataFormsWidget extends StatefulWidget {
DataItem item;
@@ -10,64 +11,9 @@ class DataFormsWidget extends StatefulWidget {
}
class DataFormsWidgetState extends State<DataFormsWidget> {
@override Widget build(BuildContext context) {
print(widget.item.serialize());
return Column( children: [
Tooltip( message: "protocols",
child: Container(
margin: const EdgeInsets.only(left: 10),
width: 45, height: 25,
child: TextFormField( textAlign: TextAlign.center,
initialValue: widget.item.protocols.join(","),
onChanged: (value) {
widget.item.protocols = value.split(",");
},
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
fillColor: Colors.white,
filled: true,
labelText: "protocols",
labelStyle: TextStyle(fontSize: 10),
border: OutlineInputBorder(),
contentPadding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
),
))),
Tooltip( message: "datatype",
child: Container(
margin: const EdgeInsets.only(left: 10),
width: 45, height: 25,
child: TextFormField( textAlign: TextAlign.center,
initialValue: widget.item.dataType,
onChanged: (value) {
widget.item.dataType = value;
},
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
fillColor: Colors.white,
filled: true,
labelText: "datatype",
labelStyle: TextStyle(fontSize: 10),
border: OutlineInputBorder(),
contentPadding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
),
))),
Tooltip( message: "example",
child: Container(
margin: const EdgeInsets.only(left: 10),
width: 45, height: 25,
child: TextFormField( textAlign: TextAlign.center,
initialValue: widget.item.exemple,
onChanged: (value) {
widget.item.exemple = value;
},
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
fillColor: Colors.white,
filled: true,
labelText: "example",
labelStyle: TextStyle(fontSize: 10),
border: OutlineInputBorder(),
contentPadding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
),
)))
WebReferenceFormsWidget(item: widget.item),
]);
}
}

View File

@@ -1,136 +1,142 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
import 'package:oc_front/models/search.dart';
import 'package:oc_front/models/workflow.dart';
import 'package:oc_front/pages/workflow.dart';
import 'package:oc_front/widgets/forms/sub_keys_forms.dart';
import 'package:oc_front/widgets/forms/sub_expose_forms.dart';
import 'package:oc_front/widgets/forms/sub_map_forms.dart';
import 'package:oc_front/widgets/inputs/sub_text_input.dart';
Map<String, Map<String, AbstractItem>> proxyWfItem = {};
// ADD EXPOSE
class ProcessingFormsWidget extends StatefulWidget {
AbstractItem item;
String elementID;
ProcessingItem item;
Dashboard dash;
ProcessingFormsWidget ({ super.key, required this.item, required this.dash });
ProcessingFormsWidget ({ super.key, required this.item, required this.dash, required this.elementID });
@override ProcessingFormsWidgetState createState() => ProcessingFormsWidgetState();
}
class ProcessingFormsWidgetState extends State<ProcessingFormsWidget> {
Widget getInputAndOutputVariableForms() {
var inList = widget.dash.GetArrowByElementID(widget.elementID, true);
var outList = widget.dash.GetArrowByElementID(widget.elementID, false);
List<Widget> res = [];
List<GraphItem> inItems = [];
List<GraphItem> outItems = [];
for (var inItem in inList) {
var element = widget.dash.getElement(inItem.fromID.substring(0,36));
if (element == null) { continue; }
var g = GraphItem();
g.fromDashboard(element.serialize());
inItems.add(g);
}
for (var outItem in outList) {
var element = widget.dash.getElement(outItem.toID.substring(0,36));
if (element == null) { continue; }
var g = GraphItem();
g.fromDashboard(element.serialize());
outItems.add(g);
}
if (inItems.isNotEmpty) {
res.add(SubKeysMapFormsWidget(dash: widget.dash, isInput: true, item: widget.item, elementID: widget.elementID,
categoryKey: "container", varKey: "env", graphItems: inItems));
}
if (outItems.isNotEmpty) {
res.add(SubKeysMapFormsWidget(dash: widget.dash, isInput: false, item: widget.item, elementID: widget.elementID,
categoryKey: "container", varKey: "env", graphItems: outItems));
}
return Column( children: res );
}
@override Widget build(BuildContext context) {
List<Widget> children = [];
List<Widget> categories = [];
var l = widget.item.model?.model?.keys ?? [];
for (var child in l) {
if (widget.item.model!.model![child]!.type != "string") { continue; }
children.add(
Tooltip( message: child,
child: Container( margin: EdgeInsets.only(top: children.isEmpty ? 0 : 15),
width: 200, height: 30,
child: TextFormField( textAlign: TextAlign.start,
initialValue: widget.item.model?.model?[child]?.value,
onChanged: (value) {
widget.item.model ?? Model();
Future.delayed(const Duration(seconds: 2), () {
if (widget.item.model!.model?[child]?.value == value) {
dash.save!(dash.id);
}
});
widget.item.model?.model?[child]?.value = value;
},
style: const TextStyle(fontSize: 12),
decoration: InputDecoration(
hintText: "enter $child...",
fillColor: Colors.white,
filled: true,
labelText: child,
alignLabelWithHint: false,
errorStyle: const TextStyle(fontSize: 0),
hintStyle: const TextStyle(fontSize: 10),
labelStyle: const TextStyle(fontSize: 10),
floatingLabelBehavior: FloatingLabelBehavior.always,
enabledBorder: const OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
border: const OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
contentPadding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
),
)))
);
var sub = widget.item.model!.model![child]!;
List<Widget> children = [];
for (var st in sub.keys) {
if (sub[st]!.type?.contains("map") ?? false) {
children.add(
SubMapFormsWidget(dash: dash, empty: children.isEmpty, item: widget.item,
elementID: widget.elementID, categoryKey: child, varKey: st)
);
} else if (sub[st]!.type == "string") {
children.add(SubTextInputWidget(subkey: st, initialValue: widget.item.getVariable([child, st], widget.item.serialize()),
width: 200, empty: children.isEmpty, change: (value) {
widget.item.model ?? Model();
Future.delayed(const Duration(seconds: 2), () {
if (widget.item.getVariable([child, st], widget.item.serialize()) == value) {
dash.save!(dash.id);
}
});
var el = dash.getElement(widget.elementID);
widget.item = widget.item.deserialize(widget.item.setVariable([child, st], value, widget.item.serialize())) as dynamic;
el!.element = widget.item as dynamic;
})
);
}
}
categories.add(Container(
padding: const EdgeInsets.all(10),
width: 250,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("<${child.toUpperCase()}>", style: const TextStyle(fontSize: 13, fontWeight: FontWeight.bold), textAlign: TextAlign.center),
Padding(padding: const EdgeInsets.only(bottom: 10), child: SubTextInputWidget(subkey: "image", width: 200, empty: false, change: (value) {},
initialValue: widget.item.container?.image, readOnly: true,)),
...children,
getInputAndOutputVariableForms(),
],)
));
}
if (widget.dash.scheduler["mode"] != null && widget.dash.scheduler["mode"] == 1) {
children.add(
Tooltip( message: "hostname",
child: Container( margin: EdgeInsets.only(top: children.isEmpty ? 0 : 15),
width: 200, height: 30,
child: TextFormField( textAlign: TextAlign.start,
onChanged: (value) {
widget.item.model ?? Model();
Future.delayed(const Duration(seconds: 2), () {
if (widget.item.model!.model?["hostname"]?.value == value) {
dash.save!(dash.id);
}
});
widget.item.model?.model?["hostname"]?.value = value;
},
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
hintText: "enter hostname...",
fillColor: Colors.white,
filled: true,
labelText: "hostname",
alignLabelWithHint: false,
errorStyle: TextStyle(fontSize: 0),
hintStyle: TextStyle(fontSize: 10),
labelStyle: TextStyle(fontSize: 10),
floatingLabelBehavior: FloatingLabelBehavior.always,
enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
border: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
contentPadding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
),
)))
);
children.add(
Tooltip( message: "port",
child: Container( margin: EdgeInsets.only(top: children.isEmpty ? 0 : 15),
width: 200, height: 50,
child: TextFormField( textAlign: TextAlign.start,
onChanged: (value) {
widget.item.model ?? Model();
Future.delayed(const Duration(seconds: 2), () {
if (widget.item.model!.model?["port"]?.value == value) {
dash.save!(dash.id);
}
});
try {
widget.item.model?.model?["port"]?.value = int.parse(value);
} catch (e) { /**/ }
},
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly
], // Only numbers can be entered
maxLength: 4,
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
hintText: "enter port...",
fillColor: Colors.white,
filled: true,
labelText: "port",
alignLabelWithHint: false,
errorStyle: TextStyle(fontSize: 0),
hintStyle: TextStyle(fontSize: 10),
labelStyle: TextStyle(fontSize: 10),
floatingLabelBehavior: FloatingLabelBehavior.always,
enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
border: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
contentPadding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
),
)))
);
// EXPOSE
categories.add(Container(
padding: const EdgeInsets.all(10),
width: 250,
decoration: const BoxDecoration(border: Border(top: BorderSide(color: Colors.grey, width: 1))),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Padding(padding: EdgeInsets.only(bottom: 5), child: Text("<EXPOSE>",
style: TextStyle(fontSize: 13, fontWeight: FontWeight.bold), textAlign: TextAlign.center)),
Row( children: [
InkWell( onTap: () {
widget.item.expose.add(Expose());
var el = dash.getElement(widget.elementID);
el!.element = widget.item as dynamic;
setState(() {});
}, child:
Container( margin: const EdgeInsets.only(left: 15, top: 5),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), border: Border.all(color: Colors.grey, width: 1)),
width: 150, height: 30,
child: const Row( mainAxisAlignment: MainAxisAlignment.center,
children: [ Padding( padding: EdgeInsets.only(right: 5), child: Icon(Icons.add)), Text("add exposure")]),
)
),
InkWell( onTap: () {
if (widget.item.expose.isEmpty) { return; }
widget.item.expose = widget.item.expose.sublist(0, widget.item.expose.length - 1);
var el = dash.getElement(widget.elementID);
el!.element = widget.item as dynamic;
setState(() {});
}, child:
Container( margin: const EdgeInsets.only(left: 5, right: 10, top: 5),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), border: Border.all(color: Colors.grey, width: 1)),
width: 45, height: 30,
child: const Row( mainAxisAlignment: MainAxisAlignment.center,
children: [ Icon(Icons.delete, color: Colors.black) ]),
)
)
]),
],)
));
for (var expose in widget.item.expose) {
categories.add(SubExposeFormsWidget( width: 200, dash: dash, empty: categories.isEmpty,
item: expose, elementID: widget.elementID));
}
return Column( children: [
Container( padding: const EdgeInsets.all(10), width: 250, height: 60, margin: const EdgeInsets.only(bottom: 15),
decoration: const BoxDecoration(border: Border(bottom: BorderSide(color: Colors.grey, width: 1))),
child: const Column( mainAxisAlignment: MainAxisAlignment.center, children: [
Text("ELEMENT INFO", style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold), textAlign: TextAlign.center),
Text("<general>", style: TextStyle(fontSize: 12), textAlign: TextAlign.center),
])),
...children
]);
return SizedBox( height: MediaQuery.of(context).size.height - 330, child: SingleChildScrollView( child: Column(
children: categories )) );
}
}

View File

@@ -24,6 +24,61 @@ class SchedulerFormsWidget extends StatefulWidget {
}
class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
CheckService check = CheckService();
void save(List<GlobalKey<FormFieldState>> formKeys) {
dash.scheduleActive = !dash.scheduleActive;
for (var k in formKeys) {
if (k.currentState != null) {
if (!k.currentState!.validate()) {
dash.scheduleActive = !dash.scheduleActive;
return;
} else { k.currentState!.save();}
}
}
DateTime now = DateTime.now().add(const Duration(minutes: 1));
if (dash.scheduler["start"] == null || DateTime.parse(dash.scheduler["start"]!).isBefore(now)) {
dash.scheduler["start"] = now.toUtc().toIso8601String();
if (dash.scheduler["end"] != null) {
dash.scheduler["end"] = now.add(const Duration(minutes: 1)).toUtc().toIso8601String();
}
}
print(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) {
DateTime now = DateTime.now().add(const Duration(minutes: 5));
widget.item.scheduler["start"] = now.toUtc().toIso8601String();
}
var s = DateTime.parse(widget.item.scheduler["start"]).toUtc().toIso8601String();
var e = "";
if (widget.item.scheduler["end"] == null) {
e = DateTime.parse(widget.item.scheduler["start"]).add(const Duration(seconds: 5)).toUtc().toIso8601String();
} else {
e = DateTime.parse(widget.item.scheduler["end"]).toUtc().toIso8601String();
}
check.search(context, [widget.item.id ?? "", s.substring(0, 19), e.substring(0, 19)], {}).then(
(v) {
if (v.data == null) { return; }
widget.booking = v.data!.is_available;
print(v.data!.is_available);
if (v.data!.is_available) {
print(f);
if (f != null) { f(formKeys);
} else {
showAlertBanner( context, () {},
const InfoAlertBannerChild(text: "no booking found at this date"),// <-- Put any widget here you want!
alertBannerLocation: AlertBannerLocation.bottom,);
}
} else {
showAlertBanner( context, () {},
const AlertAlertBannerChild(text: "booking found at this date"),// <-- Put any widget here you want!
alertBannerLocation: AlertBannerLocation.bottom,);
}
setState(() {});
}
);
}
@override Widget build(BuildContext context) {
try {
if (widget.item.scheduler["mode"] == null) { widget.item.scheduler["mode"] = 1; }
@@ -87,7 +142,7 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
width: 140,
initialValue: widget.item.scheduler["mode"] == 1,
activeColor: Colors.green, inactiveColor: Colors.green,
activeChild: const Text("service", style: TextStyle(color: Colors.white)),
activeChild: const Text("simple task", style: TextStyle(color: Colors.white)),
inactiveChild: const Text("cron task", style: TextStyle(color: Colors.white)),
borderRadius: const BorderRadius.all(Radius.circular(15)), height: 30.0, disabledOpacity: 0.5,
onChanged: (value) {
@@ -372,34 +427,7 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
Tooltip( message: "check booking",
child: InkWell( mouseCursor: SystemMouseCursors.click,
onTap: () {
if (dash.scheduleActive) { return; }
if (dash.scheduler["start"] == null ) {
DateTime now = DateTime.now().add(const Duration(minutes: 5));
dash.scheduler["start"] = now.toUtc().toIso8601String();
}
var s = DateTime.parse(dash.scheduler["start"]).toUtc().toIso8601String();
var e = "";
if (dash.scheduler["end"] == null) {
e = DateTime.parse(dash.scheduler["start"]).add(const Duration(seconds: 5)).toUtc().toIso8601String();
} else {
e = DateTime.parse(dash.scheduler["end"]).toUtc().toIso8601String();
}
check.search(context, [widget.item.id ?? "", s.substring(0, 19), e.substring(0, 19)], {}).then(
(v) {
if (v.data == null) { return; }
widget.booking = v.data!.is_available;
if (v.data!.is_available) {
showAlertBanner( context, () {},
const InfoAlertBannerChild(text: "no booking found at this date"),// <-- Put any widget here you want!
alertBannerLocation: AlertBannerLocation.bottom,);
} else {
showAlertBanner( context, () {},
const AlertAlertBannerChild(text: "booking found at this date"),// <-- Put any widget here you want!
alertBannerLocation: AlertBannerLocation.bottom,);
}
setState(() {});
}
);
checkBooking(formKeys, null);
}, child: Container( margin: const EdgeInsets.only(bottom: 5),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(5),
border: Border.all(color: widget.booking == null && !dash.scheduleActive ? Colors.black : (widget.booking == true || dash.scheduleActive ? Colors.green : Colors.red), width: 1)),
@@ -412,23 +440,7 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
Tooltip( message: dash.scheduleActive ? "unbook" : "book",
child: InkWell( mouseCursor: SystemMouseCursors.click,
onTap: () {
dash.scheduleActive = !dash.scheduleActive;
for (var k in formKeys) {
if (k.currentState != null) {
if (!k.currentState!.validate()) {
return;
} else { k.currentState!.save();}
}
}
DateTime now = DateTime.now().add(const Duration(minutes: 1));
if (dash.scheduler["start"] == null || DateTime.parse(dash.scheduler["start"]!).isBefore(now)) {
dash.scheduler["start"] = now.toUtc().toIso8601String();
if (dash.scheduler["end"] != null) {
dash.scheduler["end"] = now.add(const Duration(minutes: 1)).toUtc().toIso8601String();
}
}
widget.item.save!(widget.item.id);
setState(() { });
dash.scheduleActive ? setState(() { save(formKeys); }) : checkBooking(formKeys, save);
}, child: Container( margin: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(5),
border: Border.all(color: dash.scheduleActive ? Colors.green : Colors.black)),

View File

@@ -0,0 +1,18 @@
import 'package:flutter/material.dart';
import 'package:oc_front/models/search.dart';
import 'package:oc_front/widgets/forms/web_reference_forms.dart';
class StorageFormsWidget extends StatefulWidget {
StorageItem item;
String purpose = "";
Function validate = () {};
StorageFormsWidget ({ super.key, required this.item });
@override StorageFormsWidgetState createState() => StorageFormsWidgetState();
}
class StorageFormsWidgetState extends State<StorageFormsWidget> {
@override Widget build(BuildContext context) {
return Column( children: [
WebReferenceFormsWidget(item: widget.item),
]);
}
}

View File

@@ -0,0 +1,63 @@
import 'package:flutter/material.dart';
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
import 'package:oc_front/models/search.dart';
import 'package:oc_front/widgets/inputs/sub_text_input.dart';
class SubExposeFormsWidget extends StatefulWidget {
Expose item;
Dashboard dash;
String elementID = "";
double width = 200;
bool empty = false;
SubExposeFormsWidget ({ super.key, required this.dash,
this.empty = false, required this.item, required this.elementID, required this.width });
@override SubExposeFormsWidgetState createState() => SubExposeFormsWidgetState();
}
class SubExposeFormsWidgetState extends State<SubExposeFormsWidget> {
@override Widget build(BuildContext context) {
return Column( children : [
Container( margin: const EdgeInsets.only(left: 10, right: 10, top: 5),
decoration: BoxDecoration(border: Border.all(color: Colors.grey, width: 1)),
width: 250
),
SubTextInputWidget(subkey: "reference port", initialValue: widget.item.port != null ? '${widget.item.port}' : null,
width: widget.width, empty: widget.empty, change: (value) {
try {
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);
}
});
} catch (e) { widget.item.port = null; }
var el = widget.dash.getElement(widget.elementID);
el!.element = widget.item as dynamic;
}),
SubTextInputWidget(subkey: "PAT", initialValue: widget.item.PAT != null ? '${widget.item.PAT}' : null,
width: widget.width, empty: widget.empty, change: (value) {
try {
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);
}
});
} catch (e) { widget.item.PAT = null; }
var el = widget.dash.getElement(widget.elementID);
el!.element = widget.item as dynamic;
}),
SubTextInputWidget(subkey: "reverse path", initialValue: widget.item.PAT != null ? '${widget.item.PAT}' : null,
width: widget.width, empty: widget.empty, change: (value) {
try {
widget.item.path = value;
Future.delayed(const Duration(seconds: 2), () {
if (widget.item.path == value) { widget.dash.save!(widget.dash.id); }
});
} catch (e) { widget.item.path = null; }
var el = widget.dash.getElement(widget.elementID);
el!.element = widget.item as dynamic;
}),
]);
}
}

View File

@@ -0,0 +1,61 @@
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';
class SubKeysMapFormsWidget extends StatefulWidget {
FlowData item;
Dashboard dash;
String varKey = "";
bool empty = false;
bool isInput = true;
String elementID = "";
String categoryKey = "";
List<GraphItem> graphItems = [];
SubKeysMapFormsWidget({ super.key, required this.dash, required this.isInput,
this.empty = false, required this.item, required this.elementID, required this.graphItems,
required this.categoryKey, required this.varKey });
@override SubKeysMapFormsWidgetState createState() => SubKeysMapFormsWidgetState();
}
class SubKeysMapFormsWidgetState extends State<SubKeysMapFormsWidget> {
@override Widget build(BuildContext context) {
List<Widget> children = [];
bool save = false;
for (var graphItem in widget.graphItems) {
int count = 0;
var el = graphItem.getElement();
if (el == null || el.model == null) { continue; }
for ( var r in el.model!.refs.keys) {
var env = widget.item.getVariable(["container", "env"], widget.item.serialize());
if (env == null && env is Map<String, dynamic>) { continue; }
var n = "${el.topic.toUpperCase()}_${el.getName().toUpperCase().replaceAll(" ", "_")}_${r.toUpperCase()}_$count";
if (env[n] == null) {
save = true;
}
env[n]= "{{ ${ widget.isInput ? "in" : "out" }_${graphItem.id}_$r }}";
widget.item.setVariable(["container", "env"], env, el.serialize());
children.add( Padding(padding: const EdgeInsets.only(bottom: 10),
child: SubTextInputWidget(subkey: n, width: 200, empty: false, change: (value) {}, initialValue: n, readOnly: true, noLabel: true)));
count++;
}
}
if (save) {
widget.dash.save!(widget.dash.id);
}
if (children.isEmpty) {
return Container();
}
return Column( children : [
Container(width: 250, padding: const EdgeInsets.only(top: 10, bottom: 10),
decoration: const BoxDecoration(border: Border(bottom: BorderSide(color: Colors.grey, width: 1)))),
Padding( padding: const EdgeInsets.only(top: 10),
child: Text("<${widget.isInput ? "INPUT ENV VARIABLE" : "OUTPUT ENV VARIABLE"}>", style: const TextStyle(fontSize: 13, fontWeight: FontWeight.bold),
textAlign: TextAlign.center)),
Column( children: children),
]);
}
}

View File

@@ -0,0 +1,113 @@
import 'package:flutter/material.dart';
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
import 'package:oc_front/widgets/inputs/sub_text_input.dart';
class MapForm {
String key = "";
String value = "";
MapForm({ required this.key, required this.value });
}
class SubMapFormsWidget extends StatefulWidget {
String categoryKey = "";
String varKey = "";
String elementID = "";
FlowData item;
Dashboard dash;
bool empty = false;
List<MapForm> forms = [];
SubMapFormsWidget ({ super.key, required this.dash,
this.empty = false, required this.item, required this.elementID,
required this.categoryKey, required this.varKey });
@override SubMapFormsWidgetState createState() => SubMapFormsWidgetState();
}
class SubMapFormsWidgetState extends State<SubMapFormsWidget> {
Map<String, dynamic> toMap() {
Map<String, dynamic> m = {};
for (var form in widget.forms) {
m[form.key] = form.value;
}
return m;
}
@override Widget build(BuildContext context) {
Map<String, dynamic>? m = widget.item.getVariable([widget.categoryKey, widget.varKey], widget.item.serialize());
var l = [widget.categoryKey, widget.varKey];
List<Widget> children = [];
List<String> empty = [];
widget.forms = [];
var i = 0;
for (var key in (m?.keys.toList() ?? empty)) {
if (((m![key] as String?)?.contains('{{') ?? false)) {
continue;
}
widget.forms.add(MapForm(key: key, value: m[key]));
children.add(Padding( padding: const EdgeInsets.symmetric(horizontal: 15), child: Row( children: [
SubTextInputWidget(subkey: "key", initialValue: key, width: 91, empty: widget.empty,
change: (value) {
setState(() {
widget.forms[i].key = value;
Future.delayed(const Duration(seconds: 2), () {
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;
el!.element = widget.item as dynamic;
});
}),
const Padding(padding: EdgeInsets.only(left: 5, right: 5, top: 15), child: Text("=", textAlign: TextAlign.center,)),
SubTextInputWidget(subkey: "value", initialValue: widget.forms[i].value, width: 90.8, empty: widget.empty,
change: (value) {
Future.delayed(const Duration(seconds: 2), () {
widget.dash.save!(widget.dash.id);
});
widget.forms[i].value = value;
var el = widget.dash.getElement(widget.elementID);
widget.item = widget.item.deserialize(
widget.item.setVariable(l, toMap(), widget.item.serialize())) as dynamic;
el!.element = widget.item as dynamic;
}),
])));
i++;
}
return Column( children : [
Container(width: 250, padding: const EdgeInsets.only(top: 10),
decoration: const BoxDecoration(border: Border(bottom: BorderSide(color: Colors.grey, width: 1))),),
Row( children: [
InkWell( onTap: () {
widget.forms.add(MapForm(key: "", value: ""));
var el = widget.dash.getElement(widget.elementID);
widget.item = widget.item.deserialize(
widget.item.setVariable(l, toMap(), widget.item.serialize())) as dynamic;
el!.element = widget.item as dynamic;
setState(() {});
}, child: Container( margin: const EdgeInsets.only(left: 15, top: 10),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), border: Border.all(color: Colors.grey, width: 1)),
width: 150, height: 30,
child: Row( mainAxisAlignment: MainAxisAlignment.center,
children: [ const Padding( padding: EdgeInsets.only(right: 5), child: Icon(Icons.add)), Text("add ${widget.varKey} vars")]),
),
),
InkWell( onTap: () {
if (widget.forms.isEmpty) { return;}
widget.forms.sublist(0, widget.forms.length - 1);
widget.item = widget.item.deserialize(
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); });
}, child:
Container( margin: const EdgeInsets.only(left: 5, right: 10, top: 10),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), border: Border.all(color: Colors.grey, width: 1)),
width: 45, height: 30,
child: const Row( mainAxisAlignment: MainAxisAlignment.center,
children: [ Icon( Icons.delete, color: Colors.black ) ]),
)
),
]),
...children
]);
}
}

View File

@@ -0,0 +1,23 @@
import 'package:flutter/material.dart';
import 'package:oc_front/widgets/inputs/sub_text_input.dart';
class WebReferenceFormsWidget extends StatefulWidget {
dynamic item;
WebReferenceFormsWidget ({ super.key, required this.item });
@override WebReferenceFormsWidgetState createState() => WebReferenceFormsWidgetState();
}
class WebReferenceFormsWidgetState extends State<WebReferenceFormsWidget> {
@override Widget build(BuildContext context) {
return Column( children: [
SubTextInputWidget(subkey: "path", width: 200, empty: false, change: (value) {
widget.item.protocols = value.split(",");
}, initialValue: widget.item.path, readOnly: true,),
SubTextInputWidget(subkey: "protocol", width: 200, empty: false, change: (value) {
widget.item.protocols = value.split(",");
}, initialValue: widget.item.protocol, readOnly: true,),
SubTextInputWidget(subkey: "type", width: 200, empty: false, change: (value) {
widget.item.protocols = value.split(",");
}, initialValue: widget.item.type, readOnly: true,),
]);
}
}

View File

@@ -0,0 +1,40 @@
import 'package:flutter/material.dart';
class SubDropdownInputWidget extends StatefulWidget {
String subkey;
double width;
bool empty;
List<DropdownMenuItem<String>> dropdownMenuEntries = [];
void Function(String?)? change = (value) {};
SubDropdownInputWidget ({ Key? key, required this.dropdownMenuEntries,
required this.subkey, required this.width, required this.empty, required this.change }): super(key: key);
@override SubDropdownInputWidgetState createState() => SubDropdownInputWidgetState();
}
class SubDropdownInputWidgetState extends State<SubDropdownInputWidget> {
@override Widget build(BuildContext context) {
return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Tooltip( message: widget.subkey,
child: Container( margin: EdgeInsets.only(top: widget.empty ? 0 : 15),
width: widget.width, height: 30,
child: DropdownButtonFormField(
items: widget.dropdownMenuEntries,
onChanged: widget.change,
style: const TextStyle(fontSize: 12),
decoration: InputDecoration(
hintText: "select ${widget.subkey}...",
fillColor: Colors.white,
filled: true,
labelText: widget.subkey,
alignLabelWithHint: false,
errorStyle: const TextStyle(fontSize: 0),
hintStyle: const TextStyle(fontSize: 10),
labelStyle: const TextStyle(fontSize: 10),
floatingLabelBehavior: FloatingLabelBehavior.always,
enabledBorder: const OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
border: const OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
contentPadding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
),
))),
]);
}
}

View File

@@ -0,0 +1,62 @@
import 'package:alert_banner/exports.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:oc_front/widgets/dialog/alert.dart';
class SubTextInputWidget extends StatefulWidget {
String subkey;
String? initialValue;
double width;
bool empty;
bool noLabel;
bool readOnly = false;
void Function(String) change = (value) {};
SubTextInputWidget ({ Key? key,
required this.subkey, this.readOnly = false, this.noLabel = false,
this.initialValue, required this.width, required this.empty, required this.change }):
super(key: key);
@override SubTextInputWidgetState createState() => SubTextInputWidgetState();
}
class SubTextInputWidgetState extends State<SubTextInputWidget> {
@override Widget build(BuildContext context) {
if (widget.readOnly && widget.initialValue == null) {
return Container();
}
return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Tooltip( message: widget.subkey,
child: Container( margin: EdgeInsets.only(top: widget.empty ? 0 : 15),
width: widget.width - (widget.readOnly ? 40 : 0), height: 30,
child: TextFormField( textAlign: TextAlign.start,
enabled: !widget.readOnly,
readOnly: widget.readOnly,
initialValue: widget.initialValue,
onChanged: widget.change,
style: const TextStyle(fontSize: 12),
decoration: InputDecoration(
hintText: "enter ${widget.subkey}...",
fillColor: Colors.white,
filled: true,
labelText: widget.noLabel ? "" : widget.subkey,
alignLabelWithHint: false,
errorStyle: const TextStyle(fontSize: 0),
hintStyle: const TextStyle(fontSize: 10),
labelStyle: const TextStyle(fontSize: 10),
floatingLabelBehavior: FloatingLabelBehavior.always,
enabledBorder: const OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
border: const OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
contentPadding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
),
))),
widget.readOnly ? InkWell( onTap: () {
Clipboard.setData(ClipboardData(text: widget.initialValue!));
showAlertBanner(context, () {}, const InfoAlertBannerChild(text: "successfully add to clipboard"), // <-- Put any widget here you want!
alertBannerLocation: AlertBannerLocation.bottom,);
}, child: Container( margin: EdgeInsets.only(left: 5, top: widget.empty ? 0 : 15),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), border: Border.all(color: Colors.grey, width: 1)),
width: 35, height: 30,
child: const Row( mainAxisAlignment: MainAxisAlignment.center,
children: [ Icon(Icons.copy, color: Colors.black, size: 15,) ]),
)) : Container()
]);
}
}

View File

@@ -10,15 +10,15 @@ class DataItemWidget extends StatefulWidget {
class DataItemWidgetState extends State<DataItemWidget> {
@override Widget build(BuildContext context) {
return Wrap( children: [
Padding(padding: EdgeInsets.symmetric(vertical: 20, horizontal: 100),
child: Text("type : ${widget.item.dataType ?? "unknown type"}",
style: TextStyle(fontSize: 15, fontWeight: FontWeight.w600))),
Padding(padding: EdgeInsets.symmetric(horizontal: 100, vertical: 20),
Padding(padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 100),
child: Text("type : ${widget.item.type ?? "unknown type"}",
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w600))),
Padding(padding: const EdgeInsets.symmetric(horizontal: 100, vertical: 20),
child: Text("protocol : ${widget.item.protocols.isEmpty ? "no protocol founded" : widget.item.protocols.join(",")}",
style: TextStyle(fontSize: 15, fontWeight: FontWeight.w600))),
Padding(padding: EdgeInsets.symmetric(horizontal: 100, vertical: 20),
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w600))),
Padding(padding: const EdgeInsets.symmetric(horizontal: 100, vertical: 20),
child: Text("ex : ${widget.item.exemple ?? "no example"}",
style: TextStyle(fontSize: 15, fontWeight: FontWeight.w600))),
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w600))),
]);
}
}

View File

@@ -58,7 +58,7 @@ class ScheduleWidgetState extends State<ScheduleWidget> {
borderRadius: BorderRadius.circular(4),
),
),
SizedBox( width: (menuSize - 140),
SizedBox( width: (menuSize - 160),
child: Padding(
padding: const EdgeInsets.only(left: 20),
child: Text(wf.name?.toUpperCase() ?? "", overflow: TextOverflow.ellipsis,
@@ -67,7 +67,7 @@ class ScheduleWidgetState extends State<ScheduleWidget> {
SizedBox(
child: Padding(
padding: const EdgeInsets.only(left: 20),
child: Text("${d2.hour > 9 ? d2.hour : "0${d2.hour}"}:${d2.minute > 9 ? d2.minute : "0${d2.minute}"}", overflow: TextOverflow.ellipsis,
child: Text("${d2.hour > 9 ? d2.hour : "0${d2.hour}"}:${d2.minute > 9 ? d2.minute : "0${d2.minute}"}:${d2.second > 9 ? d2.second : "0${d2.second}"}", overflow: TextOverflow.ellipsis,
style: const TextStyle(fontSize: 15,
color: Colors.grey, fontWeight: FontWeight.w500))))
])

View File

@@ -40,7 +40,7 @@ class SchedulerCalendarWidgetState extends State<SchedulerCalendarWidget> {
lastDay: widget.end,
focusedDay: widget.focusedDay,
calendarStyle: const CalendarStyle(
markersMaxCount: 3,
markersMaxCount: 2,
markersAnchor: 0,
markersAlignment: Alignment.topCenter
),
@@ -75,7 +75,7 @@ class SchedulerCalendarWidgetState extends State<SchedulerCalendarWidget> {
}
}),
child: Container(
margin: const EdgeInsets.only(bottom: 2.5, top: 25),
margin: const EdgeInsets.only(bottom: 2.5),
padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 2),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
@@ -87,7 +87,7 @@ class SchedulerCalendarWidgetState extends State<SchedulerCalendarWidget> {
return Column(mainAxisAlignment: MainAxisAlignment.center, children: children);
},
defaultBuilder: (context, date, events) => Container(
alignment: Alignment.center,
alignment: !isEvent(widget.data, date) ? Alignment.center : Alignment.topCenter,
margin:const EdgeInsets.all(2.0),
decoration: BoxDecoration(
border: Border.all(color: Colors.grey.shade300),
@@ -96,7 +96,8 @@ class SchedulerCalendarWidgetState extends State<SchedulerCalendarWidget> {
child: !isEvent(widget.data, date) ? Text(
date.day.toString(),
style: const TextStyle(color: Colors.grey),
) : Column( children: [ Container( padding: const EdgeInsets.symmetric(vertical: 5), child: Text(
) : Column(
children: [ Container( padding: const EdgeInsets.symmetric(vertical: 5), child: Text(
date.day.toString(),
style: const TextStyle(color: Colors.grey),
)) ])
@@ -115,7 +116,7 @@ class SchedulerCalendarWidgetState extends State<SchedulerCalendarWidget> {
),
),
selectedBuilder: (context, date, events) => Container(
alignment: Alignment.center,
alignment: !isEvent(widget.data, date) ? Alignment.center : Alignment.topCenter,
margin: const EdgeInsets.all(2.0),
decoration: BoxDecoration(
border: Border.all(color: const Color.fromRGBO(38, 166, 154, 1), width: 2),
@@ -131,7 +132,7 @@ class SchedulerCalendarWidgetState extends State<SchedulerCalendarWidget> {
),
todayBuilder: (context, date, events) => Container(
margin: const EdgeInsets.all(2.0),
alignment: Alignment.center,
alignment: !isEvent(widget.data, date) ? Alignment.center : Alignment.topCenter,
decoration: BoxDecoration(
color: const Color.fromRGBO(38, 166, 154, .5),
shape: BoxShape.rectangle,
@@ -157,7 +158,7 @@ class SchedulerCalendarWidgetState extends State<SchedulerCalendarWidget> {
eventLoader: (day) {
return widget.data[day.toIso8601String()] != null ? widget.data[day.toIso8601String()]!.map((e) {
DateTime dateTime = DateTime.parse(e.executionData!);
return Event("[${dateTime.hour > 9 ? dateTime.hour : "0${dateTime.hour}"}:${dateTime.minute > 9 ? dateTime.minute : "0${dateTime.minute}"}] ${e.name}",
return Event("[${dateTime.hour > 9 ? dateTime.hour : "0${dateTime.hour}"}:${dateTime.minute > 9 ? dateTime.minute : "0${dateTime.minute}"}:${dateTime.second > 9 ? dateTime.second : "0${dateTime.second}"}] ${e.name}",
colors[(e.status ?? 1) - 1], e.executionData );
}).toList() : [];
},

View File

@@ -56,24 +56,24 @@ class SchedulerItemWidgetState extends State<SchedulerItemWidget> {
overflow: TextOverflow.ellipsis, textAlign: TextAlign.center,
style: const TextStyle( color: Colors.white))
),
SizedBox( width: (widget.width - 312) / 2,
SizedBox( width: (widget.width - 330) / 2,
child: Padding(
padding: const EdgeInsets.only(left: 20),
child: Text(ev.name?.toUpperCase() ?? "", overflow: TextOverflow.ellipsis,
style: const TextStyle(color: Colors.black, fontWeight: FontWeight.w500)),
)),
SizedBox( width: (widget.width - 312) / 2,
SizedBox( width: (widget.width - 340) / 2,
child: Padding(
padding: const EdgeInsets.only(left: 20),
child: Container( padding: const EdgeInsets.symmetric(horizontal: 20),
child: Text(d3 != null ? "killed at ${d3.day}/${d3.month}/${d3.year} ${d3.hour}:${d3.minute}"
child: Text(d3 != null ? "killed at ${d3.day}/${d3.month}/${d3.year} ${d3.hour}:${d3.minute}:${d3.second}"
: "infinite run till process end", overflow: TextOverflow.ellipsis,
style: const TextStyle( fontSize: 12, color: Colors.grey, fontWeight: FontWeight.w500))),
)),
SizedBox(
child: Padding(
padding: const EdgeInsets.only(left: 20),
child: Text("${d2.hour > 9 ? d2.hour : "0${d2.hour}"}:${d2.minute > 9 ? d2.minute : "0${d2.minute}"}", overflow: TextOverflow.ellipsis,
child: Text("${d2.hour > 9 ? d2.hour : "0${d2.hour}"}:${d2.minute > 9 ? d2.minute : "0${d2.minute}"}:${d2.second > 9 ? d2.second : "0${d2.second}"}", overflow: TextOverflow.ellipsis,
style: const TextStyle(fontSize: 25,
color: Colors.grey, fontWeight: FontWeight.w500))))
])
@@ -111,7 +111,7 @@ class SchedulerItemWidgetState extends State<SchedulerItemWidget> {
});
return Container(
alignment: children.isNotEmpty ? Alignment.topLeft : Alignment.center,
color: children.isNotEmpty ? Colors.transparent : Colors.grey.shade300,
color: children.isNotEmpty ? Colors.transparent : Colors.white,
width: children.isNotEmpty ? MediaQuery.of(context).size.width : null,
height: MediaQuery.of(context).size.height - HeaderConstants.height - 50,
child: children.isNotEmpty ? SingleChildScrollView( child: Column( children: children)) : const Text("NO DATA FOUND", style: TextStyle(color: Colors.grey, fontSize: 30))