flow updates
This commit is contained in:
parent
6fb2d62a05
commit
cc78c3e1be
1 changed files with 28 additions and 12 deletions
|
@ -232,20 +232,25 @@ class _FlowInfoPageState extends State<FlowInfoPage> {
|
|||
}
|
||||
}
|
||||
|
||||
class CreateFlowPage extends StatelessWidget {
|
||||
class CreateFlowPage extends StatefulWidget {
|
||||
final API.FlowInfo info;
|
||||
final Function refresh;
|
||||
|
||||
const CreateFlowPage(this.info, this.refresh, {super.key});
|
||||
|
||||
@override
|
||||
State<CreateFlowPage> createState() => _CreateFlowPageState();
|
||||
}
|
||||
|
||||
class _CreateFlowPageState extends State<CreateFlowPage> {
|
||||
List<API.Transaction> depends = [];
|
||||
|
||||
CreateFlowPage(this.info, this.refresh, {super.key});
|
||||
|
||||
void _create(BuildContext context) {
|
||||
// todo : input handling
|
||||
API
|
||||
.API()
|
||||
.startFlow(info.id, input: depends.map((x) => x.uuid).toList())
|
||||
.startFlow(widget.info.id, input: depends.map((x) => x.uuid).toList())
|
||||
.then((flowID) {
|
||||
refresh();
|
||||
widget.refresh();
|
||||
API.API().getFlow(flowID).then((flow) {
|
||||
Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(builder: (context) => ActiveFlowPage(flow)));
|
||||
|
@ -261,7 +266,9 @@ class CreateFlowPage extends StatelessWidget {
|
|||
builder: (context) {
|
||||
return TransactionSelectPage(transactions, onSelect: (t) {
|
||||
if (!depends.contains(t)) {
|
||||
depends.add(t);
|
||||
setState(() {
|
||||
depends.add(t);
|
||||
});
|
||||
}
|
||||
}, exclude: depends);
|
||||
},
|
||||
|
@ -271,7 +278,7 @@ class CreateFlowPage extends StatelessWidget {
|
|||
|
||||
Widget buildInputSelection(BuildContext context) {
|
||||
return Column(
|
||||
children: info.depends.map((x) {
|
||||
children: widget.info.depends.map((x) {
|
||||
return ElevatedButton(
|
||||
onPressed: () {
|
||||
selectDependItems(context, x);
|
||||
|
@ -283,7 +290,7 @@ class CreateFlowPage extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text("Create new ${info.name} Flow")),
|
||||
appBar: AppBar(title: Text("Create new ${widget.info.name} Flow")),
|
||||
body: Column(
|
||||
children: [
|
||||
buildInputSelection(context),
|
||||
|
@ -344,15 +351,24 @@ class TransactionSelectPage extends StatelessWidget {
|
|||
}
|
||||
|
||||
class ActiveFlowPage extends StatelessWidget {
|
||||
late API.Flow flow;
|
||||
final API.Flow flow;
|
||||
|
||||
ActiveFlowPage(this.flow);
|
||||
const ActiveFlowPage(this.flow, {super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Column(
|
||||
children: [],
|
||||
children: [
|
||||
Text("ID: ${flow.id}"),
|
||||
Text("Started since: ${tsFormat(flow.started)}"),
|
||||
...flow.input!.map((x) => Text("Input: $x")).toList(),
|
||||
if (flow.done != null) ...[
|
||||
Text("Ended: ${tsFormat(flow.done!.ended)}"),
|
||||
if (flow.done!.next != null) Text("Next: ${flow.done!.next!}"),
|
||||
...flow.done!.produced!.map((x) => Text("Produced: $x")).toList(),
|
||||
]
|
||||
],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue