Latest Front with debug
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
abstract class AbstractFactory {
|
||||
Widget factory(GoRouterState state, List<String> args);
|
||||
bool searchFill();
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:oc_front/core/models/shared_workspace_local.dart';
|
||||
import 'package:oc_front/core/models/workspace_local.dart';
|
||||
import 'package:oc_front/core/sections/header/header.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/resource_service.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/shared_service.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/workspace_service.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/pages/shared.dart';
|
||||
import 'package:oc_front/widgets/catalog.dart';
|
||||
import 'package:oc_front/pages/abstract_page.dart';
|
||||
import 'package:oc_front/core/sections/header/search.dart';
|
||||
import 'package:oc_front/widgets/menu_clipper/workspace_menu.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_dropdown_input.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_text_input.dart';
|
||||
|
||||
class CatalogFactory implements AbstractFactory {
|
||||
static List<AbstractItem> items = [];
|
||||
@@ -25,18 +32,84 @@ class CatalogFactory implements AbstractFactory {
|
||||
}
|
||||
|
||||
class CatalogPageWidget extends StatefulWidget {
|
||||
double? itemWidth;
|
||||
final ResourceService search = ResourceService();
|
||||
CatalogPageWidget (): super(key: CatalogFactory.key);
|
||||
CatalogPageWidget ({
|
||||
this.itemWidth,
|
||||
}): super(key: CatalogFactory.key);
|
||||
@override CatalogPageWidgetState createState() => CatalogPageWidgetState();
|
||||
}
|
||||
class CatalogPageWidgetState extends State<CatalogPageWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
return Column( children : [
|
||||
CatalogFactory.items.isEmpty ? Container() : MenuWorkspaceWidget(),
|
||||
CatalogFactory.items.isEmpty ? Container() :
|
||||
Row( children: [
|
||||
ShallowDropdownInputWidget(
|
||||
current: WorkspaceLocal.current,
|
||||
width: MediaQuery.of(context).size.width / 3,
|
||||
all: () async => WorkspaceLocal.getWorkspacesShallow(),
|
||||
type: SharedWorkspaceType.workspace,
|
||||
change: (String? change) {
|
||||
WorkspaceLocal.changeWorkspace(change.toString());
|
||||
},
|
||||
color: Colors.white,
|
||||
filled: const Color.fromRGBO(38, 166, 154, 1),
|
||||
hintColor: Colors.grey.shade300,
|
||||
canRemove: (String? remove) => remove != null,
|
||||
remove: (String? remove) async {
|
||||
if (remove == null) { return; }
|
||||
WorkspaceLocal.deleteWorkspace(remove);
|
||||
},
|
||||
),
|
||||
ShallowTextInputWidget(
|
||||
width: MediaQuery.of(context).size.width / 3,
|
||||
type: SharedWorkspaceType.workspace,
|
||||
color: Colors.white,
|
||||
filled: const Color.fromRGBO(38, 166, 154, 1),
|
||||
hintColor: Colors.grey.shade300,
|
||||
canRemove: (p0) => p0 != null,
|
||||
remove: (p0) async {
|
||||
await WorkspaceService().delete(context, p0, {}).then( (e) => WorkspaceLocal.deleteWorkspace(p0));
|
||||
},
|
||||
canLoad: (String? remove) => remove != null,
|
||||
load: (Map<String?, dynamic> add) async {
|
||||
if (add["name"] == null) { return; }
|
||||
WorkspaceLocal.createWorkspace(add["name"], context);
|
||||
},
|
||||
),
|
||||
ShallowDropdownInputWidget(
|
||||
iconLoad: Icons.share_rounded,
|
||||
tooltipLoad: 'share',
|
||||
tooltipRemove: 'unshare',
|
||||
color: Colors.white,
|
||||
filled: const Color.fromRGBO(38, 166, 154, 1),
|
||||
hintColor: Colors.grey.shade300,
|
||||
type: SharedWorkspaceType.workspace,
|
||||
all: () async => SharedWorkspaceLocal.workspaces.values.map(
|
||||
(e) => Shallow(id: e.id ?? "", name: e.name ?? "") ).toList(),
|
||||
current: WorkspaceLocal.workspaces[WorkspaceLocal.current]?.shared,
|
||||
width: (MediaQuery.of(context).size.width / 3),
|
||||
canLoad: (String? change) => SharedWorkspaceLocal.workspaces[change] == null
|
||||
|| !SharedWorkspaceLocal.workspaces[change]!.workspaces.map(
|
||||
(e) => e.id ).contains(WorkspaceLocal.current),
|
||||
canRemove: (String? change) => SharedWorkspaceLocal.workspaces[change] == null
|
||||
|| SharedWorkspaceLocal.workspaces[change]!.workspaces.map(
|
||||
(e) => e.id ).contains(WorkspaceLocal.current),
|
||||
load: (String val) async {
|
||||
await SharedService().addWorkspace(context, val, WorkspaceLocal.current ?? "");
|
||||
// ignore: use_build_context_synchronously
|
||||
SharedWorkspaceLocal.init(context, false);
|
||||
},
|
||||
remove: (String val) async {
|
||||
await SharedService().removeWorkspace(context, val, WorkspaceLocal.current ?? "");
|
||||
// ignore: use_build_context_synchronously
|
||||
SharedWorkspaceLocal.init(context, false);
|
||||
})
|
||||
]),
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: CatalogFactory.items.isEmpty ? 0 : MediaQuery.of(context).size.height - HeaderConstants.height - 50,
|
||||
child: CatalogWidget(items: CatalogFactory.items) )
|
||||
child: SingleChildScrollView( child: CatalogWidget(items: CatalogFactory.items, itemWidth: widget.itemWidth) )),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ class SchedulerPageWidgetState extends State<SchedulerPageWidget> {
|
||||
"${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; }
|
||||
@@ -165,7 +164,7 @@ class SchedulerPageWidgetState extends State<SchedulerPageWidget> {
|
||||
),
|
||||
Container(padding: const EdgeInsets.only(left: 20),
|
||||
child: const Text("TO", style: TextStyle(color: Colors.white, fontSize: 15, fontWeight: FontWeight.w500))),
|
||||
Container( padding: const EdgeInsets.only(left: 20),
|
||||
Container( padding: const EdgeInsets.only(left: 20, right: 20),
|
||||
width: MediaQuery.of(context).size.width / 5,
|
||||
height: 30,
|
||||
child: DateTimeField(
|
||||
@@ -219,6 +218,12 @@ class SchedulerPageWidgetState extends State<SchedulerPageWidget> {
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
),
|
||||
)
|
||||
),
|
||||
Tooltip( message: "refresh scheduler",
|
||||
child: InkWell(
|
||||
onTap: () => setState(() {}),
|
||||
child: const Icon(Icons.refresh, color: Colors.white,),
|
||||
),
|
||||
)
|
||||
]))
|
||||
),
|
||||
|
||||
@@ -1,9 +1,24 @@
|
||||
import 'package:alert_banner/exports.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:oc_front/core/models/shared_workspace_local.dart';
|
||||
import 'package:oc_front/core/models/workspace_local.dart';
|
||||
import 'package:oc_front/core/sections/header/header.dart';
|
||||
import 'package:oc_front/core/services/router.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/peer_service.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/shared_service.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/workflow_service.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/models/shared.dart';
|
||||
import 'package:oc_front/pages/abstract_page.dart';
|
||||
import 'package:oc_front/widgets/dialog/new_shared_workspace.dart';
|
||||
import 'package:oc_front/widgets/catalog.dart';
|
||||
import 'package:oc_front/widgets/dialog/shallow_creation.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_text_input.dart';
|
||||
import 'package:oc_front/widgets/items/shallow_item_row.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_dropdown_input.dart';
|
||||
|
||||
enum SharedWorkspaceType { global, shared_workspace, workspace, workflow, peer, resource }
|
||||
|
||||
class SharedFactory implements AbstractFactory {
|
||||
static GlobalKey<SharedPageWidgetState> key = GlobalKey<SharedPageWidgetState>();
|
||||
@@ -13,51 +28,349 @@ class SharedFactory implements AbstractFactory {
|
||||
}
|
||||
|
||||
class SharedPageWidget extends StatefulWidget {
|
||||
SharedWorkspaceType type = SharedWorkspaceType.global;
|
||||
SharedPageWidget(): super(key: SharedFactory.key);
|
||||
@override SharedPageWidgetState createState() => SharedPageWidgetState();
|
||||
static void search(BuildContext context) { }
|
||||
static Widget factory() { return SharedPageWidget(); }
|
||||
}
|
||||
class SharedPageWidgetState extends State<SharedPageWidget> {
|
||||
SharedService service = SharedService();
|
||||
Widget getMenuItem(SharedWorkspaceType workspaceType, IconData icon) {
|
||||
var s = workspaceType == SharedWorkspaceType.global ? "dashboard" : workspaceType == SharedWorkspaceType.workspace ? "shared workspaces" : workspaceType == SharedWorkspaceType.workflow ? "shared workflows" : "peers engaged";
|
||||
return Tooltip( message: s,
|
||||
child: InkWell( mouseCursor: SystemMouseCursors.click,
|
||||
onTap: () => setState(() {
|
||||
widget.type = workspaceType;
|
||||
}),
|
||||
child: Container( width: 50, height: 50,
|
||||
color: widget.type == workspaceType ? Color.fromRGBO(38, 166, 154, 1) : Colors.transparent,
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child : Icon(icon,
|
||||
color: widget.type == workspaceType ? Colors.white : Colors.white, size: 20))));
|
||||
}
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
Future.delayed( const Duration(milliseconds: 100), () {
|
||||
showDialog(context: context, builder: (BuildContext ctx) => AlertDialog(
|
||||
titlePadding: EdgeInsets.zero,
|
||||
insetPadding: EdgeInsets.zero,
|
||||
backgroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(0)),
|
||||
title:NewBoxSharedWidget()));
|
||||
});
|
||||
return Expanded(
|
||||
child : Column( children: [
|
||||
GlobalKey<ShallowTextInputWidgetState> key = GlobalKey<ShallowTextInputWidgetState>();
|
||||
if (SharedWorkspaceLocal.current == null) {
|
||||
Future.delayed( const Duration(microseconds: 100), () {
|
||||
HeaderConstants.setTitle("Choose a Shared Workspace");
|
||||
HeaderConstants.setDescription("select a shared workspace to continue");
|
||||
});
|
||||
Future.delayed( const Duration(milliseconds: 100), () {
|
||||
showDialog(
|
||||
barrierDismissible: false,
|
||||
context: context, builder: (BuildContext ctx) => AlertDialog(
|
||||
titlePadding: EdgeInsets.zero,
|
||||
insetPadding: EdgeInsets.zero,
|
||||
backgroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(0)),
|
||||
title: ShallowCreationDialogWidget(
|
||||
formKey: key,
|
||||
canClose: () => SharedWorkspaceLocal.current != null,
|
||||
context: context,
|
||||
load: (p0) async {
|
||||
SharedWorkspaceLocal.current = p0;
|
||||
HeaderConstants.setTitle("Shared Workspace <${SharedWorkspaceLocal.workspaces[SharedWorkspaceLocal.current]?.name ?? ""}>");
|
||||
HeaderConstants.setDescription(SharedWorkspaceLocal.workspaces[SharedWorkspaceLocal.current]?.description ?? "");
|
||||
Future.delayed(const Duration(seconds: 1), () => SharedFactory.key.currentState?.setState(() {}));
|
||||
},
|
||||
form: [
|
||||
ShallowTextInputWidget(
|
||||
change :(p0) => key.currentState?.setState(() {}),
|
||||
canLoad: (po) => po != null && po.isNotEmpty,
|
||||
type: SharedWorkspaceType.shared_workspace,
|
||||
width: MediaQuery.of(context).size.width <= 540 ? MediaQuery.of(context).size.width - 140 : 400,
|
||||
attr: "description",
|
||||
color: Colors.black,
|
||||
hintColor: Colors.grey,
|
||||
filled: Colors.grey.shade300,
|
||||
)
|
||||
],
|
||||
create: (p0) async => await SharedService().post(context, p0, {}).then((value) {
|
||||
if (value.data != null) {
|
||||
SharedWorkspaceLocal.current = value.data!.id;
|
||||
}
|
||||
SharedWorkspaceLocal.init(context, true);
|
||||
|
||||
HeaderConstants.setTitle("Shared Workspace <${SharedWorkspaceLocal.workspaces[SharedWorkspaceLocal.current]?.name ?? ""}>");
|
||||
HeaderConstants.setDescription(SharedWorkspaceLocal.workspaces[SharedWorkspaceLocal.current]?.description ?? "");
|
||||
Future.delayed(const Duration(seconds: 1), () => SharedFactory.key.currentState?.setState(() {}));
|
||||
}),
|
||||
type: SharedWorkspaceType.shared_workspace,
|
||||
all: () async => SharedWorkspaceLocal.workspaces.values.map(
|
||||
(e) => Shallow(id: e.id ?? "", name: e.name ?? "") ).toList(),
|
||||
)));
|
||||
});
|
||||
} else {
|
||||
Future.delayed( const Duration(milliseconds: 100), () {
|
||||
HeaderConstants.setTitle("Shared Workspace <${SharedWorkspaceLocal.workspaces[SharedWorkspaceLocal.current]?.name ?? ""}>");
|
||||
HeaderConstants.setDescription(SharedWorkspaceLocal.workspaces[SharedWorkspaceLocal.current]?.description ?? "");
|
||||
});
|
||||
}
|
||||
Widget w = WorkspaceSharedPageWidget(type: widget.type);
|
||||
List<Widget> addMenu = [];
|
||||
SharedWorkspace? current = SharedWorkspaceLocal.workspaces[SharedWorkspaceLocal.current ?? ""];
|
||||
if (widget.type == SharedWorkspaceType.workspace) {
|
||||
addMenu.add( Row( mainAxisAlignment: MainAxisAlignment.end,
|
||||
children : [ ShallowDropdownInputWidget(
|
||||
tooltipLoad: "share",
|
||||
tooltipRemove: "unshare",
|
||||
iconLoad: Icons.share,
|
||||
type: widget.type,
|
||||
current: WorkspaceLocal.current,
|
||||
all: () async => WorkspaceLocal.getWorkspacesShallow(),
|
||||
width: MediaQuery.of(context).size.width / 3,
|
||||
canLoad: (String? change) => current == null || !current.workspaces.map( (e) => e.id ).contains(change),
|
||||
canRemove: (String? change) => current == null || current.workspaces.map( (e) => e.id ).contains(change),
|
||||
load: (String val) async {
|
||||
await service.addWorkspace(context, SharedWorkspaceLocal.current ?? "", val);
|
||||
SharedWorkspaceLocal.init(context, false);
|
||||
},
|
||||
remove: (String val) async {
|
||||
await service.removeWorkspace(context, SharedWorkspaceLocal.current ?? "", val);
|
||||
SharedWorkspaceLocal.init(context, false);
|
||||
})
|
||||
]));
|
||||
}
|
||||
if (widget.type == SharedWorkspaceType.workflow) {
|
||||
addMenu.add( Row( mainAxisAlignment: MainAxisAlignment.end,
|
||||
children : [ ShallowDropdownInputWidget(
|
||||
tooltipLoad: "share",
|
||||
tooltipRemove: "unshare",
|
||||
iconLoad: Icons.share,
|
||||
type: widget.type, all: () async {
|
||||
List<Shallow> shals = [];
|
||||
await WorflowService().all(context).then((value) {
|
||||
if (value.data != null) {
|
||||
shals = value.data!.values.map((e) => Shallow(id: e["id"], name: e["name"])).toList();
|
||||
}
|
||||
});
|
||||
return shals;
|
||||
},
|
||||
width: MediaQuery.of(context).size.width / 3,
|
||||
canLoad: (String? change) => current == null || !current.workflows.map( (e) => e.id ).contains(change),
|
||||
canRemove: (String? change) => current == null || current.workflows.map( (e) => e.id ).contains(change),
|
||||
load: (String change) async {
|
||||
await service.addWorkflow(context, SharedWorkspaceLocal.current ?? "", change);
|
||||
},
|
||||
remove: (String change) async {
|
||||
await service.removeWorkflow(context, SharedWorkspaceLocal.current ?? "", change);
|
||||
})
|
||||
]));
|
||||
}
|
||||
if (widget.type == SharedWorkspaceType.peer) {
|
||||
addMenu.add( Row( mainAxisAlignment: MainAxisAlignment.end,
|
||||
children : [ ShallowDropdownInputWidget(
|
||||
tooltipLoad: "add",
|
||||
iconLoad: Icons.add,
|
||||
type: widget.type, all: () async {
|
||||
List<Shallow> shals = [];
|
||||
await PeerService().all(context).then((value) {
|
||||
if (value.data != null) {
|
||||
shals = value.data!.values.map((e) => Shallow(id: e["id"], name: e["name"])).toList();
|
||||
}
|
||||
});
|
||||
return shals;
|
||||
},
|
||||
width: MediaQuery.of(context).size.width / 3,
|
||||
canLoad: (String? change) => current == null || !current.peers.map( (e) => e.id ).contains(change),
|
||||
canRemove: (String? change) => current == null || current.peers.map( (e) => e.id ).contains(change),
|
||||
load: (String change) async {
|
||||
await service.addPeer(context, SharedWorkspaceLocal.current ?? "", change);
|
||||
},
|
||||
remove: (String change) async {
|
||||
await service.removePeer(context, SharedWorkspaceLocal.current ?? "", change);
|
||||
})
|
||||
]));
|
||||
}
|
||||
return Column( children: [
|
||||
Container(
|
||||
height: 50,
|
||||
color: const Color.fromRGBO(38, 166, 154, 1),
|
||||
width: MediaQuery.of(context).size.width,
|
||||
),
|
||||
padding: const EdgeInsets.only(left: 50),
|
||||
child: Stack( alignment: Alignment.centerLeft, children: [
|
||||
Tooltip( message: "open file", child: Padding( padding: const EdgeInsets.only(right: 15),
|
||||
child: InkWell( mouseCursor: SystemMouseCursors.click,
|
||||
onTap: () {
|
||||
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: ShallowCreationDialogWidget(
|
||||
formKey: key,
|
||||
canClose: () => SharedWorkspaceLocal.current != null,
|
||||
context: context,
|
||||
load: (p0) async {
|
||||
SharedWorkspaceLocal.current = p0;
|
||||
HeaderConstants.setTitle("Shared Workspace <${SharedWorkspaceLocal.workspaces[SharedWorkspaceLocal.current]?.name ?? ""}>");
|
||||
HeaderConstants.setDescription(SharedWorkspaceLocal.workspaces[SharedWorkspaceLocal.current]?.description ?? "");
|
||||
Future.delayed(const Duration(seconds: 1), () => SharedFactory.key.currentState?.setState(() {}));
|
||||
},
|
||||
form: [
|
||||
ShallowTextInputWidget(
|
||||
change :(p0) => key.currentState?.setState(() {}),
|
||||
type: SharedWorkspaceType.shared_workspace,
|
||||
width: MediaQuery.of(context).size.width <= 540 ? MediaQuery.of(context).size.width - 140 : 400,
|
||||
attr: "description",
|
||||
color: Colors.black,
|
||||
hintColor: Colors.grey,
|
||||
filled: Colors.grey.shade300,
|
||||
)
|
||||
],
|
||||
create: (p0) async => await SharedService().post(context, p0, {}).then( (e) {
|
||||
if (e.data != null) {
|
||||
SharedWorkspaceLocal.current = e.data!.id;
|
||||
}
|
||||
SharedWorkspaceLocal.init(context, true);
|
||||
|
||||
HeaderConstants.setTitle("Shared Workspace <${SharedWorkspaceLocal.workspaces[SharedWorkspaceLocal.current]?.name ?? ""}>");
|
||||
HeaderConstants.setDescription(SharedWorkspaceLocal.workspaces[SharedWorkspaceLocal.current]?.description ?? "");
|
||||
Future.delayed(const Duration(seconds: 1), () => SharedFactory.key.currentState?.setState(() {}));
|
||||
}),
|
||||
type: SharedWorkspaceType.shared_workspace,
|
||||
all: () async => SharedWorkspaceLocal.workspaces.values.map(
|
||||
(e) => Shallow(id: e.id ?? "", name: e.name ?? "") ).toList(),
|
||||
));
|
||||
});
|
||||
},
|
||||
child: const Icon(Icons.folder_open, color: Colors.white)))),
|
||||
Positioned( right: 0, child: Row( children: addMenu))
|
||||
])),
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
color: Colors.grey,
|
||||
color: Colors.black,
|
||||
height: MediaQuery.of(context).size.height - HeaderConstants.height - 50,
|
||||
width: 50,
|
||||
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 10),
|
||||
child: const Column(
|
||||
child: Column(
|
||||
children: [
|
||||
Tooltip( message: "dashboard",
|
||||
child: InkWell( mouseCursor: SystemMouseCursors.click,
|
||||
child: Padding( padding: EdgeInsets.symmetric(vertical: 10), child : Icon(Icons.dashboard, color: Colors.white, size: 20)))),
|
||||
Tooltip( message: "shared workspaces",
|
||||
child: InkWell( mouseCursor: SystemMouseCursors.click,
|
||||
child: Padding( padding: EdgeInsets.symmetric(vertical: 10), child : Icon(Icons.workspaces, color: Colors.white, size: 20)))),
|
||||
Tooltip( message: "shared workflows",
|
||||
child: InkWell( mouseCursor: SystemMouseCursors.click,
|
||||
child: Padding( padding: EdgeInsets.symmetric(vertical: 10), child : Icon(Icons.rebase_edit, color: Colors.white, size: 20)))),
|
||||
getMenuItem(SharedWorkspaceType.global, Icons.dashboard),
|
||||
getMenuItem(SharedWorkspaceType.workspace, Icons.workspaces),
|
||||
getMenuItem(SharedWorkspaceType.workflow, Icons.rebase_edit),
|
||||
getMenuItem(SharedWorkspaceType.peer, Icons.group),
|
||||
])
|
||||
),
|
||||
Container(
|
||||
height: MediaQuery.of(context).size.height - HeaderConstants.height - 50,
|
||||
width: MediaQuery.of(context).size.width -50,
|
||||
color: widget.type == SharedWorkspaceType.workflow || widget.type == SharedWorkspaceType.peer ? Colors.grey.shade300 : Colors.white,
|
||||
child: SingleChildScrollView( child: w ))
|
||||
]
|
||||
) ])
|
||||
) ]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class WorkspaceSharedPageWidget extends StatefulWidget {
|
||||
SharedWorkspaceType type = SharedWorkspaceType.global;
|
||||
WorkspaceSharedPageWidget({ required this.type }): super(key: null);
|
||||
@override WorkspaceSharedPageWidgetState createState() => WorkspaceSharedPageWidgetState();
|
||||
}
|
||||
class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
if (SharedWorkspaceLocal.current == null) {
|
||||
return Container();
|
||||
}
|
||||
var space = SharedWorkspaceLocal.workspaces[SharedWorkspaceLocal.current ?? ""]!;
|
||||
List<Widget> items = [];
|
||||
List<ShallowData> data = [];
|
||||
if (widget.type == SharedWorkspaceType.global) {
|
||||
} else if (widget.type == SharedWorkspaceType.workspace) {
|
||||
data = space.workspaces;
|
||||
} else if (widget.type == SharedWorkspaceType.workflow) {
|
||||
data = space.workflows;
|
||||
} else if (widget.type == SharedWorkspaceType.peer) {
|
||||
data = space.peers;
|
||||
}
|
||||
var current = SharedWorkspaceLocal.workspaces[SharedWorkspaceLocal.current];
|
||||
for (var w in data) {
|
||||
if (widget.type == SharedWorkspaceType.workspace) {
|
||||
if (WorkspaceLocal.workspaces[w.getID()] == null) { continue; }
|
||||
items.add(WorkspaceSharedItemPageWidget(name: "Workspace <${WorkspaceLocal.workspaces[w.getID()]!.name}>", id: w.getID()));
|
||||
} else if (widget.type == SharedWorkspaceType.workflow || widget.type == SharedWorkspaceType.peer) {
|
||||
List<IconData> badges = [];
|
||||
if (widget.type == SharedWorkspaceType.peer && w.getID() == current?.creatorID) {
|
||||
badges.add(Icons.star);
|
||||
}
|
||||
items.add(ShallowItemRowWidget(
|
||||
item: w, badges: badges,
|
||||
edit: widget.type == SharedWorkspaceType.workflow ? (String? change) {
|
||||
if (change != null) {
|
||||
WorkspaceLocal.changeWorkspaceByName(change.split("~")[1]);
|
||||
}
|
||||
Future.delayed(const Duration(seconds: 1), () => AppRouter.workflowIDItem.go(context, { "id": change ?? "" }));
|
||||
} : null,
|
||||
delete: (String? change) async {
|
||||
if (change == null) { return; }
|
||||
if (widget.type == SharedWorkspaceType.peer) {
|
||||
await SharedService().removePeer(context, SharedWorkspaceLocal.current ?? "", change);
|
||||
} else {
|
||||
await SharedService().removePeer(context, SharedWorkspaceLocal.current ?? "", change);
|
||||
}
|
||||
},
|
||||
icon: widget.type == SharedWorkspaceType.workflow ? Icons.work_history_rounded : Icons.person,
|
||||
contextWidth: 200)
|
||||
);
|
||||
}
|
||||
}
|
||||
if (items.isEmpty) {
|
||||
return Container(
|
||||
color: Colors.grey.shade300,
|
||||
height: MediaQuery.of(context).size.height - HeaderConstants.height - 50,
|
||||
width: MediaQuery.of(context).size.width - 50,
|
||||
alignment: Alignment.center,
|
||||
padding: const EdgeInsets.all(50),
|
||||
child: Text("NO ITEMS SHARED", style: const TextStyle(fontSize: 25, fontWeight: FontWeight.w600, color: Colors.white)));
|
||||
}
|
||||
if (widget.type == SharedWorkspaceType.workflow || widget.type == SharedWorkspaceType.peer) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(50),
|
||||
child: Stack( alignment: Alignment.topLeft, children : items));
|
||||
}
|
||||
return Column( mainAxisAlignment: MainAxisAlignment.start, children : items);
|
||||
}
|
||||
}
|
||||
|
||||
class WorkspaceSharedItemPageWidget extends StatefulWidget {
|
||||
bool open = true;
|
||||
String id = "";
|
||||
String name = "";
|
||||
WorkspaceSharedItemPageWidget({ this.name = "", this.id = "" }): super(key: null);
|
||||
@override WorkspaceSharedItemPageWidgetState createState() => WorkspaceSharedItemPageWidgetState();
|
||||
}
|
||||
class WorkspaceSharedItemPageWidgetState extends State<WorkspaceSharedItemPageWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
return Column( children: [
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width - 50,
|
||||
height: 50,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
decoration: BoxDecoration(color: Colors.grey.shade300),
|
||||
child: Stack(
|
||||
alignment: Alignment.centerLeft,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Padding(padding: EdgeInsets.only(right: 20), child: Icon(Icons.shopping_cart_outlined, size: 18, color: Colors.white)),
|
||||
Text(widget.name,
|
||||
style: const TextStyle(fontSize: 15, color: Colors.white, fontWeight: FontWeight.w600)),
|
||||
]
|
||||
),
|
||||
Positioned( right: 0, top: 5, child: IconButton( icon: Icon(widget.open ? Icons.arrow_drop_up : Icons.arrow_drop_down, color: Colors.white),
|
||||
onPressed: () => setState(() {
|
||||
widget.open = !widget.open;
|
||||
})))
|
||||
])
|
||||
),
|
||||
widget.open ? CatalogWidget(itemWidth: MediaQuery.of(context).size.width - 50,
|
||||
items: WorkspaceLocal.byWorkspace(widget.id)) : Container()
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,40 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:oc_front/core/models/shared_workspace_local.dart';
|
||||
import 'package:oc_front/core/models/workspace_local.dart';
|
||||
import 'package:oc_front/core/sections/header/header.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/shared_service.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/workflow_service.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/models/workflow.dart';
|
||||
import 'package:oc_front/pages/abstract_page.dart';
|
||||
import 'package:oc_front/widgets/dialog/new_workflow.dart';
|
||||
import 'package:oc_front/widgets/forms/proxy_forms.dart';
|
||||
import 'package:oc_front/pages/shared.dart';
|
||||
import 'package:oc_front/widgets/dialog/shallow_creation.dart';
|
||||
import 'package:oc_front/widgets/forms/processing_forms.dart';
|
||||
import 'package:oc_front/widgets/forms/scheduler_forms.dart';
|
||||
import 'package:oc_front/widgets/items/item_row.dart';
|
||||
import 'package:oc_front/widgets/menu_clipper/shared_workspace_menu.dart';
|
||||
import 'package:oc_front/widgets/menu_clipper/workspace_menu.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_dropdown_input.dart';
|
||||
|
||||
Dashboard dash = Dashboard(
|
||||
name: "workflow_${DateTime.now().toString().replaceAll(" ", "_").substring(0, DateTime.now().toString().length - 7)}");
|
||||
class WorkflowFactory implements AbstractFactory {
|
||||
static GlobalKey<WorkflowPageWidgetState> key = GlobalKey<WorkflowPageWidgetState>();
|
||||
@override bool searchFill() { return false; }
|
||||
@override Widget factory(GoRouterState state, List<String> args) { return WorkflowPageWidget(); }
|
||||
@override Widget factory(GoRouterState state, List<String> args) {
|
||||
String? id;
|
||||
try { id = state.pathParameters[args.first];
|
||||
} catch (e) { }
|
||||
return WorkflowPageWidget(id: id);
|
||||
}
|
||||
@override void search(BuildContext context) { }
|
||||
}
|
||||
bool getAll = true;
|
||||
|
||||
class WorkflowPageWidget extends StatefulWidget {
|
||||
WorkflowPageWidget () : super(key: WorkflowFactory.key);
|
||||
String? id;
|
||||
WorkflowPageWidget ({ this.id }) : super(key: WorkflowFactory.key);
|
||||
@override WorkflowPageWidgetState createState() => WorkflowPageWidgetState();
|
||||
static void search(BuildContext context) { }
|
||||
static Widget factory() { return WorkflowPageWidget(); }
|
||||
@@ -42,23 +50,11 @@ final WorflowService _service = WorflowService();
|
||||
}
|
||||
Widget itemTooltipBuild(Object item) {
|
||||
var e = item as AbstractItem;
|
||||
return Container(color: Colors.white, child: ItemRowWidget(low: true, contextWidth: 300, item: e));
|
||||
}
|
||||
List<DropdownMenuItem> getItems(Object? data) {
|
||||
data = data as APIResponse<RawData>?;
|
||||
if (data != null && data.data != null && data.data!.values.isNotEmpty) {
|
||||
return data.data!.values.map((dynamic value) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: "${value["id"] ?? ""}~${value["name"] ?? ""}",
|
||||
child: Text(value["name"]?.toString() ?? ""),
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
return [];
|
||||
return Container(color: Colors.white, child: ItemRowWidget(low: true, contextWidth: 290, item: e));
|
||||
}
|
||||
List<Widget> getForms(FlowData? obj) {
|
||||
return obj == null ? [] : [
|
||||
ProxyFormsWidget(item: obj as AbstractItem, dash: dash),
|
||||
ProcessingFormsWidget(item: obj as AbstractItem, dash: dash),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -69,6 +65,7 @@ final WorflowService _service = WorflowService();
|
||||
}
|
||||
|
||||
Future<void> loadDash(String selected) async {
|
||||
dash.shouldSave = false;
|
||||
if (selected.split("~").length > 1) {
|
||||
dash.name = selected.split("~")[1];
|
||||
dash.id = selected.split("~")[0];
|
||||
@@ -77,13 +74,15 @@ final WorflowService _service = WorflowService();
|
||||
}
|
||||
await _service.get(context, dash.id ?? "").then((value) {
|
||||
if (value.data != null) {
|
||||
dash.clear();
|
||||
dash.deserialize(value.data!.toDashboard());
|
||||
Future.delayed(const Duration(seconds: 1), () => dash.shouldSave = true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> saveDash(String? id) async {
|
||||
if (id == null || !dash.isOpened) { return; }
|
||||
if (id == null || !dash.isOpened || !dash.shouldSave) { return; }
|
||||
var datas = WorkspaceLocal.byTopic("data", true).where(
|
||||
(element) => dash.elements.map( (e) => e.element?.getID()).contains(element.id) );
|
||||
var dataCenter = WorkspaceLocal.byTopic("datacenter", true).where(
|
||||
@@ -106,11 +105,27 @@ final WorflowService _service = WorflowService();
|
||||
updateW.fromDashboard(dash.serialize());
|
||||
for (var item in (updateW.graph?.items.values ?? [] as List<GraphItem>)) {
|
||||
if (item.position == null) { continue; }
|
||||
item.position?.x = (item.position?.x ?? 0) + 52.5;
|
||||
item.position?.y = (item.position?.y ?? 0) + 52.5;
|
||||
item.position?.x = (item.position?.x ?? 0) + (item.width! / 2) + 7.5;
|
||||
item.position?.y = (item.position?.y ?? 0) + (item.height! / 2) + 7.5;
|
||||
for (var i in (updateW.graph?.links ?? [] as List<GraphLink>).where((element) => id == element.source?.id)) {
|
||||
i.source?.x = (i.source?.x ?? 0) + (item.width! / 2) + 7;
|
||||
i.source?.y = (i.source?.y ?? 0) + (item.width! / 2) + 7;
|
||||
}
|
||||
for (var i in (updateW.graph?.links ?? [] as List<GraphLink>).where((element) => id == element.destination?.id)) {
|
||||
i.destination?.x = (i.destination?.x ?? 0) + (item.width! / 2) + 7.5;
|
||||
i.destination?.y = (i.destination?.y ?? 0) + (item.width! / 2) + 7.5;
|
||||
}
|
||||
}
|
||||
updateW.graph?.zoom = dash.getZoomFactor();
|
||||
await _service.put(context, id, updateW.serialize(), {});
|
||||
print("SAVE DASH");
|
||||
dash.addToHistory();
|
||||
await _service.put(context, id, updateW.serialize(), {}).then( (e) {
|
||||
if (dash.addChange) {
|
||||
dash.addChange = false;
|
||||
WorkspaceLocal.init(context, false);
|
||||
dash.selectedLeftMenuKey.currentState?.setState(() { });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
FlowData? transformToData(Map<String, dynamic> data) {
|
||||
@@ -125,24 +140,88 @@ final WorflowService _service = WorflowService();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Widget onDashboardMenu(Dashboard dash) {
|
||||
return ShallowDropdownInputWidget(
|
||||
iconLoad: Icons.share,
|
||||
tooltipLoad: 'share',
|
||||
tooltipRemove: 'unshare',
|
||||
filled: const Color.fromRGBO(38,166, 154, 1),
|
||||
color: Colors.white,
|
||||
hintColor: Colors.grey.shade300,
|
||||
type: SharedWorkspaceType.workflow,
|
||||
all: () async => SharedWorkspaceLocal.workspaces.values.map(
|
||||
(e) => Shallow(id: e.id ?? "", name: e.name ?? "") ).toList(),
|
||||
current: WorkspaceLocal.workspaces[WorkspaceLocal.current]?.shared,
|
||||
width: (MediaQuery.of(context).size.width / 3),
|
||||
canLoad: (String? change) {
|
||||
return SharedWorkspaceLocal.workspaces[change] == null
|
||||
|| !SharedWorkspaceLocal.workspaces[change]!.workflows.map( (e) => e.id
|
||||
).contains(dash.id);
|
||||
},
|
||||
canRemove: (String? change) => SharedWorkspaceLocal.workspaces[change] == null
|
||||
|| SharedWorkspaceLocal.workspaces[change]!.workflows.map( (e) => e.id
|
||||
).contains(dash.id),
|
||||
load: (String val) async {
|
||||
await SharedService().addWorkflow(context, val, dash.id ?? "");
|
||||
SharedWorkspaceLocal.init(context, false);
|
||||
dash.selectedMenuKey.currentState?.setState(() { });
|
||||
},
|
||||
remove: (String val) async {
|
||||
await SharedService().removeWorkflow(context, val, dash.id ?? "");
|
||||
SharedWorkspaceLocal.init(context, false);
|
||||
dash.selectedMenuKey.currentState?.setState(() { });
|
||||
});
|
||||
}
|
||||
Widget menuExtension() {
|
||||
var quart = MediaQuery.of(context).size.width / 6;
|
||||
return MenuWorkspaceWidget(simpliest: true, width: quart > 80 ? quart : 80,
|
||||
onWorkspaceChange: () {
|
||||
dash.selectedLeftMenuKey.currentState?.setState(() { });
|
||||
});
|
||||
return ShallowDropdownInputWidget(
|
||||
current: WorkspaceLocal.current,
|
||||
width: quart > 80 ? quart : 80,
|
||||
all: () async => WorkspaceLocal.getWorkspacesShallow(),
|
||||
type: SharedWorkspaceType.workspace,
|
||||
change: (String? change) {
|
||||
WorkspaceLocal.changeWorkspace(change.toString());
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Widget onDashboardMenu(Dashboard dash) {
|
||||
return SharedMenuWorkspaceWidget(width: MediaQuery.of(context).size.width / 2.5, contextID: dash.id ?? "",
|
||||
excluded: dash.info["shared"] ?? [],
|
||||
topMargin: 0, inner: true, type: SharedMenuWorkspaceType.workflow);
|
||||
}
|
||||
|
||||
Widget onDashboardAlertOpened(BuildContext context, Dashboard dash) {
|
||||
return NewBoxWidget<Workflow>(service: _service, dash: dash,
|
||||
getItems: getItems);
|
||||
return ShallowCreationDialogWidget(
|
||||
canClose: () => dash.isOpened,
|
||||
context: context,
|
||||
load: (p0) async {
|
||||
dash.isOpened = true;
|
||||
if (dash.load != null) {
|
||||
WorkspaceLocal.changeWorkspaceByName(p0.split("~")[1]);
|
||||
await dash.load!(p0);
|
||||
}
|
||||
dash.notifyListeners();
|
||||
},
|
||||
create: (p0) async => await _service.post(context, p0, {}).then( (value) {
|
||||
dash.clear();
|
||||
dash.id = value.data?.getID() ?? "";
|
||||
dash.name = value.data?.getName() ?? "";
|
||||
dash.notifyListeners();
|
||||
WorkspaceLocal.init(context, true);
|
||||
dash.isOpened = true;
|
||||
}
|
||||
),
|
||||
maptoDropdown: (e) => DropdownMenuItem<String>(
|
||||
value: "${e.id}~${e.name}",
|
||||
child: Text(e.name),
|
||||
),
|
||||
type: SharedWorkspaceType.workflow,
|
||||
all: () async {
|
||||
List<Shallow> res = [];
|
||||
await _service.all(context).then(
|
||||
(e) {
|
||||
if (e.data != null) {
|
||||
res = e.data!.values.map((e) => Shallow(id: e["id"] ?? "", name: e["name"] ?? "")).toList();
|
||||
}
|
||||
}
|
||||
);
|
||||
return res;
|
||||
}
|
||||
);
|
||||
}
|
||||
@override Widget build(BuildContext context) {
|
||||
dash.load = loadDash;
|
||||
@@ -151,20 +230,22 @@ final WorflowService _service = WorflowService();
|
||||
dash.infoItemWidget = getForms;
|
||||
dash.infoWidget = getDashInfoForms;
|
||||
var quart = MediaQuery.of(context).size.width / 6;
|
||||
dash.defaultName = "workflow_${DateTime.now().toString().replaceAll(" ", "_").substring(0, DateTime.now().toString().length - 7)}";
|
||||
dash.defaultName = "workflow_${DateTime.now().toString().replaceAll(" ", "_"
|
||||
).substring(0, DateTime.now().toString().length - 7)}";
|
||||
return FlowChart<AbstractItem>(
|
||||
onDashboardAlertOpened: onDashboardAlertOpened,
|
||||
dashboard: dash,
|
||||
current: widget.id,
|
||||
itemWidget: itemBuild,
|
||||
menuWidget: onDashboardMenu,
|
||||
categories: const ["processing", "data", "datacenter", "storage", "workflows"],
|
||||
draggableItemBuilder: (cat) => WorkspaceLocal.byTopic(cat, false),
|
||||
itemWidgetTooltip: itemTooltipBuild,
|
||||
innerMenuWidth: quart > 80 ? quart : 80,
|
||||
menuExtension: MediaQuery.of(context).size.width > 600 ? menuExtension : null,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height - HeaderConstants.height,
|
||||
onNewConnection: (p1, p2) { },
|
||||
menuExtension: menuExtension,
|
||||
onDashboardTapped: (context, position) { },
|
||||
onScaleUpdate: (newScale) { },
|
||||
onDashboardSecondaryTapped: (context, position) { },
|
||||
|
||||
Reference in New Issue
Block a user