Fusion debug

This commit is contained in:
mr 2025-02-18 15:05:19 +01:00
parent 6b6da966b6
commit 6991283dd4
10 changed files with 70 additions and 102 deletions

File diff suppressed because one or more lines are too long

View File

@ -105,8 +105,7 @@ class APIService<T extends SerializerDeserializer> {
BuildContext? context, Options? options) async {
var err = "";
try {
var type = localStorage.getItem('tokenType') ?? "bearer";
_dio.options.headers["Authorization"] = "${type[0].toUpperCase() + type.substring(1)} ${localStorage.getItem('accessToken') ?? ""}";
_dio.options.headers["Authorization"] = "Bearer ${localStorage.getItem('accessToken') ?? ""}";
_dio.interceptors.clear();
var response = await _request(url, method, body, options);
if (response.statusCode != null && response.statusCode! < 400) {
@ -145,9 +144,8 @@ class APIService<T extends SerializerDeserializer> {
var err = "";
if (url != "") {
try {
var type = localStorage.getItem('tokenType') ?? "bearer";
_dio.options.headers["Authorization"] =
"${type[0].toUpperCase() + type.substring(1)} ${localStorage.getItem('accessToken') ?? ""}";
"Bearer ${localStorage.getItem('accessToken') ?? ""}";
_dio.interceptors.clear();
var response = await _request(url, method, body, null);
if (response.statusCode != null && response.statusCode! < 400) {

View File

@ -1,5 +1,4 @@
import 'package:localstorage/localstorage.dart';
import 'package:oc_front/core/conf/conf_reader.dart';
import 'package:oc_front/core/services/api_service.dart';
import 'package:oc_front/core/services/perms_service.dart';
import 'package:oc_front/main.dart';
@ -9,7 +8,7 @@ class AuthService {
static var isAuth = const bool.fromEnvironment('AUTH_MODE', defaultValue: false);
static const _clientID = String.fromEnvironment('CLIENT_ID', defaultValue: 'test-client');
static APIService<SimpleData> service = APIService(
baseURL: AppConfig().get('AUTH_HOST', defaultValue: 'http://localhost:8080/auth'),
baseURL: const String.fromEnvironment('AUTH_HOST', defaultValue: 'http://localhost:8080/auth'),
);
static Future<void> init() async {

View File

@ -1,53 +0,0 @@
import 'package:flutter/widgets.dart';
import 'package:oc_front/core/services/api_service.dart';
import 'package:oc_front/core/services/specialized_services/abstract_service.dart';
import 'package:oc_front/models/response.dart';
import 'package:oc_front/models/workflow.dart';
class CheckService extends AbstractService<Check> {
@override
late final APIService<Check> service;
@override
String subPath = "/check/";
CheckService() {
service = APIService<Check>(
baseURL: super
.conf
.get('CHECK_HOST', defaultValue: 'http://localhost:8080/check'));
}
Future<APIResponse<Check>> search(
BuildContext? context, List<String> words, Map<String, dynamic> params) {
return service.get("$subPath${words.join("/")}", true, context);
}
@override
Future<APIResponse<RawData>> all(BuildContext? context) {
throw UnimplementedError();
}
@override
Future<APIResponse<Check>> get(BuildContext? context, String id) {
throw UnimplementedError();
}
@override
Future<APIResponse<Check>> post(BuildContext? context,
Map<String, dynamic> body, Map<String, String> params) {
throw UnimplementedError();
}
@override
Future<APIResponse<Check>> put(BuildContext? context, String id,
Map<String, dynamic> body, Map<String, String> params) {
throw UnimplementedError();
}
@override
Future<APIResponse<Check>> delete(
BuildContext? context, String id, Map<String, String> params) {
throw UnimplementedError();
}
}

View File

@ -4,25 +4,25 @@ import 'package:oc_front/core/services/specialized_services/abstract_service.dar
import 'package:oc_front/models/response.dart';
import 'package:oc_front/models/workflow.dart';
class SchedulerService extends AbstractService<WorkflowExecution> {
@override APIService<WorkflowExecution> service = APIService<WorkflowExecution>(
class SchedulerService extends AbstractService<WorkflowExecutions> {
@override APIService<WorkflowExecutions> service = APIService<WorkflowExecutions>(
baseURL: const String.fromEnvironment('SCHEDULER_HOST', defaultValue: 'http://localhost:8080/scheduler')
);
@override String subPath = "/";
Future<APIResponse<WorkflowExecution>> schedule(BuildContext? context, String id, Map<String, dynamic> body, Map<String, dynamic> params) {
print("$subPath$id");
Future<APIResponse<WorkflowExecutions>> schedule(BuildContext? context, String id, Map<String, dynamic> body, Map<String, dynamic> params) {
print(body);
return service.post("$subPath$id", body, context);
}
@override Future<APIResponse<WorkflowExecution>> search(BuildContext? context, List<String> words, Map<String, dynamic> params) {
@override Future<APIResponse<WorkflowExecutions>> search(BuildContext? context, List<String> words, Map<String, dynamic> params) {
return throw UnimplementedError();
}
@override Future<APIResponse<WorkflowExecution>> post(BuildContext? context, Map<String, dynamic> body, Map<String, String> params) {
@override Future<APIResponse<WorkflowExecutions>> post(BuildContext? context, Map<String, dynamic> body, Map<String, String> params) {
return throw UnimplementedError();
}
@override Future<APIResponse<WorkflowExecution>> put(BuildContext? context, String id, Map<String, dynamic> body, Map<String, String> params) {
@override Future<APIResponse<WorkflowExecutions>> put(BuildContext? context, String id, Map<String, dynamic> body, Map<String, String> params) {
return throw UnimplementedError();
}
}

View File

@ -1,8 +1,11 @@
import 'package:flutter/material.dart';
import 'package:oc_front/core/services/api_service.dart';
import 'package:oc_front/core/services/specialized_services/abstract_service.dart';
import 'package:oc_front/models/response.dart';
import 'package:oc_front/models/workflow.dart';
class WorflowService extends AbstractService<Workflow> {
late final APIService<Check> serviceCheck;
@override
late final APIService<Workflow> service;
@override
@ -12,5 +15,13 @@ class WorflowService extends AbstractService<Workflow> {
service = APIService<Workflow>(
baseURL: super.conf.get('WORKFLOW_HOST',
defaultValue: 'http://localhost:8080/workflow'));
serviceCheck = APIService<Check>(
baseURL: super.conf.get('WORKFLOW_HOST',
defaultValue: 'http://localhost:8080/workflow'));
}
Future<APIResponse<Check>> check(
BuildContext? context, List<String> words, Map<String, dynamic> params) {
return serviceCheck.get("${subPath}check/${words.join("/")}", true, context);
}
}

View File

@ -42,7 +42,7 @@ class MapPageWidgetState extends State<MapPageWidget> {
return FutureBuilder(future: widget._service.all(context), builder: (BuildContext context, AsyncSnapshot snapshot) {
Map<String, Map<AbstractItem, LatLng>> coordinates = {};
List<Marker> markerCoordinates = [];
if (snapshot.data != null&& snapshot.data!.data != null && snapshot.data!.data!.values.isNotEmpty) {
if (snapshot.data != null&& snapshot.data!.data != null) {
for (var element in snapshot.data!.data!.values) {
if (element["type"] == "storage") {
StorageItem resource = StorageItem().deserialize(element);

View File

@ -18,7 +18,6 @@ import 'package:flutter_flow_chart/flutter_flow_chart.dart';
import 'package:oc_front/widgets/inputs/shallow_text_input.dart';
import 'package:oc_front/core/models/shared_workspace_local.dart';
import 'package:datetime_picker_formfield/datetime_picker_formfield.dart';
import 'package:oc_front/core/services/specialized_services/check_service.dart';
import 'package:oc_front/core/services/specialized_services/workflow_service.dart';
// ignore: must_be_immutable
@ -40,9 +39,8 @@ class SchedulerFormsWidget extends StatefulWidget {
@override SchedulerFormsWidgetState createState() => SchedulerFormsWidgetState();
}
class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
CheckService check = CheckService();
WorflowService check = WorflowService();
void save(List<GlobalKey<FormFieldState>> formKeys) {
print("save");
widget.error = null;
widget.errorEndDate = null;
widget.errorCron = null;
@ -63,6 +61,7 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
dash.error = "You need to link each processing element to a compute element";
}
}
print("qdjqksdn ${dash.error}");
if (dash.error != null) {
showAlertBanner( context, () {}, AlertAlertBannerChild(text: dash.error.toString()),// <-- Put any widget here you want!
alertBannerLocation: AlertBannerLocation.bottom,);
@ -72,6 +71,7 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
for (var k in formKeys) {
if (k.currentState != null) {
if (!k.currentState!.validate()) {
print("bwak");
return;
} else { k.currentState!.save();}
}
@ -84,7 +84,14 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
}
}
Duration durationBefore = widget.schedule.start!.difference(DateTime.now().toUtc()) + Duration(seconds: 5);
widget._schedulerService.schedule(context, widget.item.id ?? "", widget.schedule.serialize(), {}).then((value) {
print("qdjqksdn ${widget.item.id}");
widget._schedulerService.schedule(context, widget.item.id ?? "", widget.schedule.serialize(), {}).catchError( (e) {
print("THERE2");
setState(() {
widget.error = e.toString();
});
}).then((value) {
print("THERE");
setState(() { widget.valid = true; });
Future.delayed(durationBefore, () {
try {
@ -110,7 +117,7 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
} else {
e = widget.schedule.end!.toUtc().toIso8601String();
}
check.search(context, [widget.item.id ?? "", s.substring(0, 19), e.substring(0, 19)], {}).then(
check.check(context, [widget.item.id ?? "", s.substring(0, 19), e.substring(0, 19)], {}).then(
(v) {
if (v.data == null) { return; }
widget.booking = v.data!.isAvailable;
@ -494,12 +501,11 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
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),
border: Border.all(color: widget.booking == null ? (
PermsService.getPerm(Perms.WORKFLOW_BOOKING) && PermsService.getPerm(Perms.WORKFLOW_EDIT) ? Colors.black : Colors.grey) : (
border: Border.all(color: widget.booking == null ? Colors.black : (
widget.booking == true ? Colors.green : redColor), width: 1)),
width: 200, height: 30,
child: Icon( Icons.verified_outlined,
color: widget.booking == null ? Colors.black : (widget.booking == true ? Colors.green : redColor)),
color: widget.booking == null ? Colors.black : (widget.booking == true ? Colors.green : redColor)),
))
): Container(),
PermsService.getPerm(Perms.WORKFLOW_BOOKING) ? Tooltip( message: "book", child: InkWell( mouseCursor: SystemMouseCursors.click,
@ -507,7 +513,7 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
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 ))),
border: Border.all(color: dash.error != null ? Colors.red : (widget.valid ? Colors.green : Colors.black) )),
width: 200, height: 30,
child: Icon(Icons.schedule_send, color: dash.error != null ? Colors.red : (widget.valid ? Colors.green : Colors.black)),
))

View File

@ -313,27 +313,34 @@ class FlowChartState<T extends FlowData> extends State<FlowChart> {
@override
Widget build(BuildContext context) {
if (!widget.dashboard.isOpened && widget.onDashboardAlertOpened != null ) {
if (widget.dashboard.id != null) {
widget.dashboard.isOpened = true;
Future.delayed(Duration(milliseconds: 100), () => widget.dashboard.load!(widget.dashboard.id!) );
Future.delayed(const Duration(milliseconds: 100), () => widget.dashboard.load!(widget.dashboard.id!) );
} else {
Future.delayed(Duration(milliseconds: 100), () {
if (!widget.dashboard.inDialog) {
widget.dashboard.inDialog = true;
showDialog(
barrierDismissible: false,
context: context, builder: (context) {
return AlertDialog(
titlePadding: EdgeInsets.zero,
insetPadding: EdgeInsets.zero,
backgroundColor: Colors.white,
shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(0)),
title: widget.onDashboardAlertOpened!(context, widget.dashboard));
});
}
});
try {
Future.delayed(const Duration(milliseconds: 100), () {
if (!widget.dashboard.inDialog) {
widget.dashboard.inDialog = true;
showDialog(
barrierDismissible: false,
context: context, builder: (context) {
return AlertDialog(
titlePadding: EdgeInsets.zero,
insetPadding: EdgeInsets.zero,
backgroundColor: Colors.white,
shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(0)),
title: widget.onDashboardAlertOpened!(context, widget.dashboard));
});
}
});
} catch (e) {
widget.dashboard.id = null;
widget.dashboard.name = "";
widget.dashboard.isOpened = false;
}
}
} else {
widget.dashboard.isOpened = true;
@ -816,9 +823,9 @@ class ChartWidgetState<T extends FlowData> extends State<ChartWidget> {
for (int i = 0; i < widget.dashboard.elements.length; i++)
ElementWidget<T>(
key: UniqueKey(),
bottomLeftBadge: widget.flowChart.widget.itemLeftBottomBadges != null ?
bottomLeftBadge: widget.flowChart.widget.itemLeftBottomBadges != null && widget.dashboard.elements[i].element != null ?
widget.flowChart.widget.itemLeftBottomBadges!(widget.dashboard.elements[i].element as T) : null,
topRightBadge: widget.flowChart.widget.itemrightTopBadges != null ?
topRightBadge: widget.flowChart.widget.itemrightTopBadges != null && widget.dashboard.elements[i].element != null ?
widget.flowChart.widget.itemrightTopBadges!(widget.dashboard.elements[i].element as T) : null,
dashboard: widget.dashboard,
element: widget.dashboard.elements.elementAt(i),

View File

@ -23,19 +23,19 @@ class FlowChartMenuState extends State<FlowChartMenu> {
return Row( mainAxisAlignment: MainAxisAlignment.end, children : [ Container( // SHORTCUT
width: widget.width,
height: 50,
padding: EdgeInsets.only(left: 20),
padding: const EdgeInsets.only(left: 20),
color: widget.dashboard.dashColor,
child: Row( children : [ Expanded(flex: 2, child: Row( children: [
widget.chart.widget.flowChart.widget.onDashboardAlertOpened == null ? Container() : Container(
decoration: BoxDecoration(
decoration: const BoxDecoration(
border: Border(right: BorderSide(color: Colors.white, width: 1))
),
child: Row( children: [
Tooltip( message: "open file", child:Container( child:
Padding( padding: EdgeInsets.only(right: 15),
Tooltip( message: "open file", child: Padding( padding: const EdgeInsets.only(right: 15),
child: InkWell( mouseCursor: SystemMouseCursors.click,
onTap: () {
widget.dashboard.name = "graph_${DateTime.now().toString().replaceAll(" ", "_").substring(0, DateTime.now().toString().length - 7)}";
widget.dashboard.id = null;
widget.dashboard.name = "";
widget.dashboard.isOpened = true;
if (!widget.dashboard.inDialog) {
widget.dashboard.inDialog = true;
@ -52,7 +52,7 @@ class FlowChartMenuState extends State<FlowChartMenu> {
});
}
},
child: Icon(Icons.folder, color: Colors.white))))),
child: Icon(Icons.folder, color: Colors.white)))),
])),
InkWell( mouseCursor: SystemMouseCursors.click, child: Container(
decoration: BoxDecoration(