This commit is contained in:
mr
2025-02-17 09:35:56 +01:00
parent 313ef43e9c
commit 3d6b4bf3b3
7 changed files with 137 additions and 14 deletions

View File

@@ -0,0 +1,58 @@
import 'package:flutter/material.dart';
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
import 'package:oc_front/models/resources/resources.dart';
import 'package:oc_front/widgets/inputs/sub_text_input.dart';
// ignore: must_be_immutable
class CredentialsFormsWidget extends StatefulWidget {
int instanceID = 0;
Dashboard dash;
AbstractItem item;
String elementID;
CredentialsFormsWidget({ super.key, required this.item, required this.dash, required this.elementID });
@override CredentialsFormsWidgetState createState() => CredentialsFormsWidgetState();
}
class CredentialsFormsWidgetState extends State<CredentialsFormsWidget> {
@override Widget build(BuildContext context) {
List<Widget> widgets = [];
var instance = widget.item.getSelectedInstance();
if (instance != null && instance.credential != null) {
var creds = instance.credential!;
widgets.add(Container( margin: EdgeInsets.only(bottom: 15),
width: 200, decoration: BoxDecoration( border: Border(bottom: BorderSide(color: Colors.grey))),
));
widgets.add(Container(
padding: const EdgeInsets.only(bottom: 10),
width: 180,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("<CREDENTIALS>", style: const TextStyle(fontSize: 13, fontWeight: FontWeight.bold), textAlign: TextAlign.center),
SubTextInputWidget(subkey: "login", width: 180, empty: false, change: (value) {
creds.password = value;
for (var el in widget.dash.elements) {
if (el.id == widget.elementID) {
el.element = widget.item;
break;
}
}
widget.dash.saveDash(widget.dash.id, context);
}, initialValue: creds.login),
SubTextInputWidget(subkey: "password", width: 180, empty: false, change: (value) {
creds.password = value;
for (var el in widget.dash.elements) {
if (el.id == widget.elementID) {
el.element = widget.item;
break;
}
}
widget.dash.saveDash(widget.dash.id, context);
}, initialValue: creds.password, readOnly: false,),
],)
));
widgets.add(Container( padding: EdgeInsets.only(bottom: 15), width: 200 ));
}
return Column(children: widgets);
}
}

View File

@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:oc_front/models/workflow.dart';
import 'package:oc_front/models/resources/resources.dart';
import 'package:oc_front/core/services/perms_service.dart';
import 'package:oc_front/widgets/forms/credentials_forms.dart';
import 'package:oc_front/widgets/forms/sub_keys_forms.dart';
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
import 'package:oc_front/widgets/inputs/sub_text_input.dart';
@@ -77,6 +78,7 @@ class ResourceFormsWidgetState extends State<ResourceFormsWidget> {
}
}
instancesCat.add(ContainerFormsWidget(dash: widget.dash, item: widget.item, elementID: widget.elementID));
instancesCat.add(CredentialsFormsWidget(dash: widget.dash, item: widget.item, elementID: widget.elementID));
if (instancesCat.isNotEmpty) {
instancesCat.add(Container(
width: 200, decoration: BoxDecoration( border: Border(bottom: BorderSide(color: Colors.grey))),

View File

@@ -1,6 +1,7 @@
import 'package:cron/cron.dart';
import 'package:oc_front/core/services/specialized_services/workflow_execution_service.dart';
import 'package:oc_front/core/services/specialized_services/workflow_scheduler_service.dart';
import 'package:oc_front/main.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart' as intl;
@@ -33,13 +34,15 @@ class SchedulerFormsWidget extends StatefulWidget {
String? errorEndDate;
String? errorCron;
Function validate = () {};
final WorkflowExecutionService _service = WorkflowExecutionService();
final SchedulerService _schedulerService = SchedulerService();
final WorkflowExecutionService _executionService = WorkflowExecutionService();
SchedulerFormsWidget ({ super.key, required this.item, });
@override SchedulerFormsWidgetState createState() => SchedulerFormsWidgetState();
}
class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
CheckService check = CheckService();
void save(List<GlobalKey<FormFieldState>> formKeys) {
print("save");
widget.error = null;
widget.errorEndDate = null;
widget.errorCron = null;
@@ -81,7 +84,7 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
}
}
Duration durationBefore = widget.schedule.start!.difference(DateTime.now().toUtc()) + Duration(seconds: 5);
widget._service.schedule(context, widget.item.id ?? "", widget.schedule.serialize(), {}).then((value) {
widget._schedulerService.schedule(context, widget.item.id ?? "", widget.schedule.serialize(), {}).then((value) {
setState(() { widget.valid = true; });
Future.delayed(durationBefore, () {
try {
@@ -131,7 +134,7 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
@override Widget build(BuildContext context) {
if (widget.shouldSearch && widget.item.name != "") {
widget.shouldSearch = false;
widget._service.search(null, [widget.item.name], {}).then((value) {
widget._executionService.search(null, [widget.item.name], {}).then((value) {
if (value.data != null) {
try {
setState(() {
@@ -480,13 +483,14 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
Container(
width: 200,
height: 20,
decoration: const BoxDecoration(border: Border(bottom: BorderSide(color: Colors.grey, width: 1))),
decoration: BoxDecoration(border: Border(bottom: BorderSide(color:
PermsService.getPerm(Perms.WORKFLOW_BOOKING)? Colors.grey : Colors.transparent, width: 1))),
),
const SizedBox(
width: 200,
height: 10,
),
Tooltip( message: "check booking", child: InkWell( mouseCursor: SystemMouseCursors.click,
PermsService.getPerm(Perms.WORKFLOW_BOOKING)? Tooltip( message: "check booking", child: InkWell( mouseCursor: SystemMouseCursors.click,
onTap: () { PermsService.getPerm(Perms.WORKFLOW_BOOKING) ? checkBooking(formKeys, null) : null;
}, child: Container( margin: const EdgeInsets.only(bottom: 5, left: 10, right: 10),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(5),
@@ -497,17 +501,17 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
child: Icon( Icons.verified_outlined,
color: widget.booking == null ? Colors.black : (widget.booking == true ? Colors.green : redColor)),
))
),
Tooltip( message: "book", child: InkWell( mouseCursor: SystemMouseCursors.click,
): Container(),
PermsService.getPerm(Perms.WORKFLOW_BOOKING) ? Tooltip( message: "book", child: InkWell( mouseCursor: SystemMouseCursors.click,
onTap: () {
PermsService.getPerm(Perms.WORKFLOW_BOOKING) && PermsService.getPerm(Perms.WORKFLOW_EDIT) ? setState(() { save(formKeys); }) : null;
setState(() { save(formKeys); });
}, child: Container( margin: const EdgeInsets.only(top: 5, bottom: 10, left: 10, right: 10),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(5),
border: Border.all(color: dash.error != null ? Colors.red : ( PermsService.getPerm(Perms.WORKFLOW_BOOKING) ?(widget.valid ? Colors.green : Colors.black) : Colors.grey ))),
width: 200, height: 30,
child: Icon(Icons.schedule_send, color: dash.error != null ? Colors.red : (widget.valid ? Colors.green : Colors.black)),
))
),
) : Container(),
Column( children: [
Container(
height: 15, width: 200,