Autoload yay
This commit is contained in:
@@ -32,49 +32,7 @@ class ComputePageWidgetState extends State<ComputePageWidget> {
|
||||
List<String> titles = ["SCHEDULED", "RUNNING", "FAILURE", "SUCCESS", "MISSED"];
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
return FutureBuilder(
|
||||
future: widget._service.search(context, [
|
||||
"${widget.start.year}-${widget.start.month > 9 ? widget.start.month : "0${widget.start.month}"}-${widget.start.day > 9 ? widget.start.day : "0${widget.start.day}"}",
|
||||
"${widget.end.year}-${widget.end.month > 9 ? widget.end.month : "0${widget.end.month}"}-${widget.end.day > 9 ? widget.end.day : "0${widget.end.day}"}"], {}),
|
||||
builder: (ctx, as) {
|
||||
Map<String, List<WorkflowExecution>> data = {};
|
||||
if (as.hasData && as.data!.data != null) {
|
||||
for (var element in as.data!.data!.executions) {
|
||||
if (element.executionData == null) { continue; }
|
||||
DateTime dateTime = DateTime.parse(element.executionData!);
|
||||
DateTime date = DateTime(dateTime.year, dateTime.month, dateTime.day);
|
||||
var str = "${date.toIso8601String()}Z";
|
||||
if (data[str] == null) { data[str] = []; }
|
||||
data[str]!.add(element);
|
||||
data[str]!.sort((a, b) => DateTime.parse(a.executionData!).compareTo(DateTime.parse(b.executionData!)));
|
||||
}
|
||||
}
|
||||
GlobalKey<ScheduleWidgetState> k = GlobalKey<ScheduleWidgetState>();
|
||||
for (var da in data.keys) {
|
||||
for (var exec in data[da]!) {
|
||||
String start = "";
|
||||
String end = "";
|
||||
try {
|
||||
if (exec.endDate != null && exec.endDate != "") {
|
||||
var startD = DateTime.parse(exec.executionData!);
|
||||
var endD = DateTime.parse(exec.endDate!);
|
||||
var diff = endD.difference(startD);
|
||||
if (diff.inDays < 30) {
|
||||
var rest = ((30 - diff.inDays) ~/ 2) - 1;
|
||||
start = (startD.subtract(Duration(days: rest)).microsecondsSinceEpoch).toString();
|
||||
end = (endD.add(Duration(days: rest)).microsecondsSinceEpoch).toString();
|
||||
} else {
|
||||
start = (startD.microsecondsSinceEpoch).toString();
|
||||
end = (startD.add( const Duration(days: 29)).microsecondsSinceEpoch).toString();
|
||||
}
|
||||
} else {
|
||||
start = (DateTime.parse(exec.executionData!).subtract( const Duration(days: 14)).microsecondsSinceEpoch).toString();
|
||||
end = (DateTime.parse(exec.executionData!).add( const Duration(days: 14)).microsecondsSinceEpoch).toString();
|
||||
}
|
||||
} catch(e) { /* */ }
|
||||
k.currentState?.setState(() { k.currentState?.widget.loading = true; });
|
||||
}
|
||||
}
|
||||
return Column( children: [
|
||||
Container( color: lightColor,
|
||||
height: 50, width: getMainWidth(context),
|
||||
@@ -211,8 +169,7 @@ class ComputePageWidgetState extends State<ComputePageWidget> {
|
||||
)
|
||||
]))
|
||||
),
|
||||
ScheduleWidget( key: k, data: data, start: widget.start, end : widget.end, isList: widget.isList, isBox: false)
|
||||
ScheduleWidget( service: widget._service, key: k, start: widget.start, end : widget.end, isList: widget.isList, isBox: false)
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,8 @@ import 'package:datetime_picker_formfield/datetime_picker_formfield.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart' as intl;
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/logs_service.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/workflow_execution_service.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:oc_front/models/workflow.dart';
|
||||
import 'package:oc_front/pages/abstract_page.dart';
|
||||
import 'package:oc_front/widgets/sheduler_items/schedule.dart';
|
||||
|
||||
@@ -29,70 +27,10 @@ class SchedulerPageWidget extends StatefulWidget {
|
||||
}
|
||||
class SchedulerPageWidgetState extends State<SchedulerPageWidget> {
|
||||
List<Color> colors = [Colors.blue, Colors.orange, redColor, Colors.green, redColor];
|
||||
List<String> titles = ["SCHEDULED", "RUNNING", "FAILURE", "SUCCESS", "MISSED"];
|
||||
List<String> titles = ["SCHEDULED", "RUNNING", "FAILURE", "SUCCESS", "FORGOTTEN"];
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
return FutureBuilder(
|
||||
future: widget._service.search(context, [
|
||||
"${widget.start.year}-${widget.start.month > 9 ? widget.start.month : "0${widget.start.month}"}-${widget.start.day > 9 ? widget.start.day : "0${widget.start.day}"}",
|
||||
"${widget.end.year}-${widget.end.month > 9 ? widget.end.month : "0${widget.end.month}"}-${widget.end.day > 9 ? widget.end.day : "0${widget.end.day}"}"], {}),
|
||||
builder: (ctx, as) {
|
||||
Map<String, List<WorkflowExecution>> data = {};
|
||||
if (as.hasData && as.data!.data != null) {
|
||||
for (var element in as.data!.data!.executions) {
|
||||
if (element.executionData == null) { continue; }
|
||||
DateTime dateTime = DateTime.parse(element.executionData!);
|
||||
DateTime date = DateTime(dateTime.year, dateTime.month, dateTime.day);
|
||||
var str = "${date.toIso8601String()}Z";
|
||||
if (data[str] == null) { data[str] = []; }
|
||||
data[str]!.add(element);
|
||||
data[str]!.sort((a, b) => DateTime.parse(a.executionData!).compareTo(DateTime.parse(b.executionData!)));
|
||||
}
|
||||
}
|
||||
GlobalKey<ScheduleWidgetState> k = GlobalKey<ScheduleWidgetState>();
|
||||
for (var da in data.keys) {
|
||||
for (var exec in data[da]!) {
|
||||
String start = "";
|
||||
String end = "";
|
||||
try {
|
||||
if (exec.endDate != null && exec.endDate != "") {
|
||||
var startD = DateTime.parse(exec.executionData!);
|
||||
var endD = DateTime.parse(exec.endDate!);
|
||||
var diff = endD.difference(startD);
|
||||
if (diff.inDays < 30) {
|
||||
var rest = ((30 - diff.inDays) ~/ 2) - 1;
|
||||
start = (startD.subtract(Duration(days: rest)).microsecondsSinceEpoch).toString();
|
||||
end = (endD.add(Duration(days: rest)).microsecondsSinceEpoch).toString();
|
||||
} else {
|
||||
start = (startD.microsecondsSinceEpoch).toString();
|
||||
end = (startD.add( const Duration(days: 29)).microsecondsSinceEpoch).toString();
|
||||
}
|
||||
} else {
|
||||
start = (DateTime.parse(exec.executionData!).subtract( const Duration(days: 14)).microsecondsSinceEpoch).toString();
|
||||
end = (DateTime.parse(exec.executionData!).add( const Duration(days: 14)).microsecondsSinceEpoch).toString();
|
||||
}
|
||||
} catch(e) { /* */ }
|
||||
k.currentState?.setState(() { k.currentState?.widget.loading = true; });
|
||||
LogsService().search(context, [], {
|
||||
"workflow_execution_id": exec.id,
|
||||
"start": start,
|
||||
"end": end
|
||||
}).then((value) {
|
||||
if (value.data != null) {
|
||||
var d = value.data!;
|
||||
for( var r in d.result) {
|
||||
for (var element in r.logs) {
|
||||
element.level = r.level;
|
||||
exec.logs ??= [];
|
||||
exec.logs!.add(element);
|
||||
}
|
||||
exec.logs?.sort((a, b) => a.timestamp!.compareTo(b.timestamp!));
|
||||
}
|
||||
}
|
||||
k.currentState?.setState(() { k.currentState?.widget.loading = false; });
|
||||
});
|
||||
}
|
||||
}
|
||||
return Column( children: [
|
||||
Container( color: lightColor,
|
||||
height: 50, width: getMainWidth(context),
|
||||
@@ -229,8 +167,7 @@ class SchedulerPageWidgetState extends State<SchedulerPageWidget> {
|
||||
)
|
||||
]))
|
||||
),
|
||||
ScheduleWidget( key: k, data: data, start: widget.start, end : widget.end, isList: widget.isList, )
|
||||
ScheduleWidget( service: widget._service, key: k, start: widget.start, end : widget.end, isList: widget.isList, )
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
List<Widget> items = [];
|
||||
for (var w in data) {
|
||||
List<Widget> badges = [];
|
||||
if (widget.type == CollaborativeAreaType.peer && w.getID(
|
||||
if (w is Peer && w.getID(
|
||||
) == CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current ?? ""]?.rule?.creator) {
|
||||
badges.add(Padding( padding: const EdgeInsets.only(left: 5), child: Icon(Icons.star, color: Colors.orange.shade300 )));
|
||||
} else if (widget.type == CollaborativeAreaType.workspace) {
|
||||
|
||||
Reference in New Issue
Block a user