124 lines
6.6 KiB
Dart
124 lines
6.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_box_transform/flutter_box_transform.dart';
|
|
import 'package:oc_front/core/sections/header/header.dart';
|
|
import 'package:oc_front/main.dart';
|
|
import 'package:oc_front/models/workflow.dart';
|
|
import 'package:oc_front/widgets/sheduler_items/schedule.dart';
|
|
|
|
// ignore: must_be_immutable
|
|
class SchedulerItemWidget extends StatefulWidget {
|
|
Map<String, List<WorkflowExecution>> data;
|
|
bool enabled = true;
|
|
DateTime focusedDay;
|
|
double width = 0;
|
|
ScheduleWidgetState? parent;
|
|
Map<String, GlobalKey> keys = {};
|
|
SchedulerItemWidget ({ super.key, required this.data, required this.focusedDay,
|
|
this.enabled = true, required this.parent, this.width = 0});
|
|
@override SchedulerItemWidgetState createState() => SchedulerItemWidgetState();
|
|
}
|
|
class SchedulerItemWidgetState extends State<SchedulerItemWidget> {
|
|
List<Color> colors = [Colors.blue, Colors.orange, redColor, Colors.green, redColor];
|
|
List<String> titles = ["SCHEDULED", "RUNNING", "FAILURE", "SUCCESS", "MISSED"];
|
|
|
|
@override Widget build(BuildContext context) {
|
|
List<Widget> children = [];
|
|
for (var element in widget.data.keys.toList()..sort((a, b) => DateTime.parse(a).compareTo(DateTime.parse(b)))) {
|
|
List<Widget> widgets = [];
|
|
for (var ev in widget.data[element] ?? ([] as List<WorkflowExecution>)) {
|
|
widget.keys[ev.executionData!] = GlobalKey();
|
|
var d2 = DateTime.parse(ev.executionData!).toLocal();
|
|
DateTime? d3;
|
|
try { d3 = DateTime.parse(ev.endDate!).toLocal();
|
|
} catch (e) { /* */ }
|
|
widgets.add(InkWell(
|
|
onTap: () => widget.parent?.setState(() {
|
|
selected = selected != element || ev.executionData != selectedReal ? element : null;
|
|
selectedReal = selected == null ? null : ev.executionData;
|
|
if (selectedReal == null) {
|
|
widget.parent!.widget.isDayPlanner = true;
|
|
}
|
|
}),
|
|
child: Container( key: widget.keys[ev.executionData!],
|
|
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 50),
|
|
decoration: BoxDecoration(
|
|
border: selectedReal == ev.executionData ?
|
|
Border.all(color: lightColor, width: 2) : Border(top: BorderSide(color: midColor)),
|
|
),
|
|
child: Row(children: [
|
|
Container( width: 110,
|
|
decoration: BoxDecoration(
|
|
color: colors[(ev.status ?? 1) - 1],
|
|
borderRadius: BorderRadius.circular(4),
|
|
),
|
|
padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 5),
|
|
child: Text(titles[(ev.status ?? 1) - 1],
|
|
overflow: TextOverflow.ellipsis, textAlign: TextAlign.center,
|
|
style: const TextStyle( color: Colors.white))
|
|
),
|
|
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 - 340) / 2,
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(left: 17),
|
|
child: Container( padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
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: 17),
|
|
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))))
|
|
])
|
|
)));
|
|
}
|
|
var date = DateTime.parse(element);
|
|
children.add(Container(
|
|
decoration: BoxDecoration(
|
|
border: Border(bottom: BorderSide(color: Colors.grey.shade300)),
|
|
),
|
|
child: Column( children: [ ExpansionTile(
|
|
enabled: widget.enabled,
|
|
shape: const ContinuousRectangleBorder(side : BorderSide(color: Colors.grey)),
|
|
iconColor: Colors.grey,
|
|
initiallyExpanded: true,
|
|
title: SizedBox(
|
|
child : Row( children: [
|
|
const Padding(padding: EdgeInsets.only(right: 10),
|
|
child: Icon(Icons.view_day, color: Colors.grey)),
|
|
Flexible(
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(right: 5),
|
|
child: Text("${date.day > 9 ? date.day : "0${date.day}"}-${date.month > 9 ? date.month : "0${date.month}"}-${date.year}".toUpperCase(), overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(color: Colors.black, fontWeight: FontWeight.w500))))
|
|
])
|
|
),
|
|
collapsedIconColor: Colors.grey,
|
|
children: widgets,
|
|
)])));
|
|
}
|
|
Future.delayed( const Duration(milliseconds: 100), () {
|
|
if (selectedReal != null) {
|
|
widget.keys[selectedReal!]?.currentContext?.findRenderObject()?.showOnScreen();
|
|
}
|
|
});
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: children.isNotEmpty ? Colors.transparent : midColor,
|
|
border: Border( right: BorderSide( color: children.isNotEmpty ? Colors.transparent : Colors.white) ),
|
|
),
|
|
alignment: children.isNotEmpty ? Alignment.topLeft : Alignment.center,
|
|
width: children.isNotEmpty ? getMainWidth(context) : null,
|
|
height: getMainHeight(context) - 50,
|
|
child: children.isNotEmpty ? SingleChildScrollView( child: Column( children: children)) : const Text(
|
|
"NO DATA FOUND", style: TextStyle(color: Colors.grey, fontSize: 30))
|
|
);
|
|
}
|
|
} |