Shared WS

This commit is contained in:
mr
2024-08-27 15:38:21 +02:00
parent 36a70db69f
commit 6ba32a7dfa
19 changed files with 479 additions and 87 deletions

View File

@@ -1,4 +1,6 @@
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/pages/workflow.dart';
@@ -6,7 +8,8 @@ Map<String, Map<String, AbstractItem>> proxyWfItem = {};
class ProxyFormsWidget extends StatefulWidget {
AbstractItem item;
ProxyFormsWidget ({ super.key, required this.item });
Dashboard dash;
ProxyFormsWidget ({ super.key, required this.item, required this.dash });
@override ProxyFormsWidgetState createState() => ProxyFormsWidgetState();
}
class ProxyFormsWidgetState extends State<ProxyFormsWidget> {
@@ -18,7 +21,7 @@ class ProxyFormsWidgetState extends State<ProxyFormsWidget> {
children.add(
Tooltip( message: child,
child: Container( margin: EdgeInsets.only(top: children.isEmpty ? 0 : 15),
width: 160, height: 30,
width: 200, height: 30,
child: TextFormField( textAlign: TextAlign.start,
initialValue: widget.item.model?.model?[child]?.value,
onChanged: (value) {
@@ -48,8 +51,80 @@ class ProxyFormsWidgetState extends State<ProxyFormsWidget> {
)))
);
}
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),
),
)))
);
}
return Column( children: [
Container( padding: const EdgeInsets.all(10), width: 200, height: 60, margin: const EdgeInsets.only(bottom: 15),
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),

View File

@@ -1,10 +1,12 @@
import 'package:alert_banner/exports.dart';
import 'package:cron/cron.dart';
import 'package:flutter/widgets.dart';
import 'package:intl/intl.dart' as intl;
import 'package:flutter/material.dart';
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
import 'package:flutter_advanced_switch/flutter_advanced_switch.dart';
import 'package:datetime_picker_formfield/datetime_picker_formfield.dart';
import 'package:oc_front/core/models/shared_workspace_local.dart';
import 'package:oc_front/core/services/specialized_services/check_service.dart';
import 'package:oc_front/pages/workflow.dart';
import 'package:oc_front/widgets/dialog/alert.dart';
@@ -44,13 +46,15 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
List<GlobalKey<FormFieldState>> formKeys = [GlobalKey<FormFieldState>(), GlobalKey<FormFieldState>(),
GlobalKey<FormFieldState>(), GlobalKey<FormFieldState>()];
return Column( children: [
Container( padding: const EdgeInsets.all(10), width: 200, height: 60,
Container( padding: const EdgeInsets.all(10), width: 250, height: 60,
decoration: const BoxDecoration(border: Border(bottom: BorderSide(color: Colors.grey, width: 1))),
child: const Column( mainAxisAlignment: MainAxisAlignment.center, children: [
Text("WORKFLOW INFO", style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold), textAlign: TextAlign.center),
Text("<general>", style: TextStyle(fontSize: 12), textAlign: TextAlign.center),
])),
Container(height: 20),
Container(height: 20,
width: 250,
),
AdvancedSwitch(
width: 140,
initialValue: widget.item.scheduler["mode"] == 1,
@@ -131,11 +135,10 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
lastDate: DateTime(2100)
);
if (date != null) {
var n = TimeOfDay.now();
TimeOfDay? time = n;
TimeOfDay? time;
var count = 0;
while(((time?.hour ?? 0) + ((time?.minute ?? 0) / 100)) <= (n.hour + ((n.minute + 1) / 100)) ) {
if (count > 0 && time != null) {
while(date!.microsecondsSinceEpoch <= (DateTime.now().microsecondsSinceEpoch) || time == null) {
if (count > 0) {
showAlertBanner( context, () {},
const AlertAlertBannerChild(
text: "must be at least 1 minute from now to let system check info"),// <-- Put any widget here you want!
@@ -161,9 +164,9 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
);
if (time == null) { return DateTime.now().add( const Duration(minutes: 1)); }
count++;
date = DateTime(date.year, date.month, date.day, time.hour, time.minute);
widget.item.scheduler["start"] = date.toUtc().toIso8601String();
}
date = date.add(Duration(hours: time?.hour ?? 0, minutes: time?.minute ?? 0));
widget.item.scheduler["start"] = date.toUtc().toIso8601String();
widget.item.save!(widget.item.id);
}
return date;
@@ -228,13 +231,15 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
);
if (date != null) {
// ignore: use_build_context_synchronously
var n = TimeOfDay.now();
TimeOfDay? time = TimeOfDay(hour: date.hour, minute: date.minute);
date = DateTime(date.year, date.month, date.day, date.hour, date.minute);
TimeOfDay? time;
var count = 0;
while(((time?.hour ?? 0) + (time?.minute ?? 0 / 100)) <= (n.hour + ((n.minute + 1) / 100)) ) {
if (count > 0 && time != null) {
while(date!.microsecondsSinceEpoch <= (DateTime.now().microsecondsSinceEpoch)
|| time == null
|| (date.microsecondsSinceEpoch) <= (DateTime.parse(widget.item.scheduler["start"] ?? DateTime.now().toIso8601String()).microsecondsSinceEpoch)) {
if (count > 0) {
showAlertBanner( context, () {},
const AlertAlertBannerChild(text: "must be at least 1 minute from now to let system check info"),// <-- Put any widget here you want!
const AlertAlertBannerChild(text: "must be at least 1 minute from now to let system check info && upper starting date"),// <-- Put any widget here you want!
alertBannerLocation: AlertBannerLocation.bottom,);
}
time = await showTimePicker(context: context,
@@ -257,9 +262,9 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
);
if (time == null) { return null; }
count++;
date = DateTime(date.year, date.month, date.day, time.hour, time.minute);
widget.item.scheduler["end"] = date.toUtc().toIso8601String();
}
date = date.add(Duration(hours: time?.hour ?? 0, minutes: time?.minute ?? 0));
widget.item.scheduler["end"] = date.toUtc().toIso8601String();
widget.item.save!(widget.item.id);
}
return date;
@@ -326,7 +331,11 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
contentPadding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
),
))),
const Divider(color: Colors.grey),
Container(
width: 250,
height: 20,
decoration: const BoxDecoration(border: Border(bottom: BorderSide(color: Colors.black, width: 1))),
),
Tooltip( message: "check booking",
child: InkWell( mouseCursor: SystemMouseCursors.click,
onTap: () {
@@ -361,7 +370,7 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
}, child: Container( margin: const EdgeInsets.all(10),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(5),
border: Border.all(color: widget.booking == null && !dash.scheduleActive ? Colors.grey : (widget.booking == true || dash.scheduleActive ? Colors.green : Colors.red), width: 1)),
width: 140, height: 30,
width: 200, height: 30,
child: Icon(
Icons.verified_outlined,
color: widget.booking == null && !dash.scheduleActive ? Colors.grey : (widget.booking == true || dash.scheduleActive ? Colors.green : Colors.red)),
@@ -389,12 +398,31 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
setState(() { });
}, child: Container( margin: const EdgeInsets.all(10),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(5),
border: Border.all(color: dash.scheduleActive ? Colors.green : Colors.black, width: 1)),
width: 140, height: 30,
border: Border.all(color: dash.scheduleActive ? Colors.green : Colors.black)),
width: 200, height: 30,
child: Icon(
dash.scheduleActive ? Icons.cancel_schedule_send : Icons.schedule_send, color: dash.scheduleActive ? Colors.green : Colors.black),
))
),
widget.item.info["shared"] != null && (widget.item.info["shared"] as List<dynamic>).isNotEmpty ? Column( children: [
Container(
height: 20,
width: 250,
decoration: const BoxDecoration(border: Border(top: BorderSide(color: Colors.black))),
),
Container( alignment: Alignment.center, padding: const EdgeInsets.symmetric(horizontal: 20),
child: Text( textAlign: TextAlign.center,
style: const TextStyle(fontSize: 14, color: Colors.black, fontWeight: FontWeight.bold),
"Workflow is shared in ${(widget.item.info["shared"] as List<dynamic>).length} workspace(s)")),
...(widget.item.info["shared"] as List<dynamic>).where( (e) => SharedWorkspaceLocal.getSharedWorkspace(e) != null
).map((e) {
return Container( alignment: Alignment.center, padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 5),
child: Row( children: [
const Padding(padding: EdgeInsets.only(right: 10), child: Icon(Icons.work, color: Colors.grey, size: 15)),
Text(style: const TextStyle(fontSize: 12, color: Colors.grey),
"Workspace: ${SharedWorkspaceLocal.getSharedWorkspace(e)!.name}") ]));
},)
]) : Container()
]);
}
}