test
This commit is contained in:
@@ -2,7 +2,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
abstract class AbstractFactory {
|
||||
GlobalKey getKey();
|
||||
Widget factory(GoRouterState state, List<String> args);
|
||||
bool searchFill();
|
||||
void search(BuildContext context);
|
||||
void search(BuildContext context, bool special);
|
||||
void clear();
|
||||
}
|
||||
@@ -1,38 +1,41 @@
|
||||
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/main.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/inputs/shallow_dropdown_input.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_text_input.dart';
|
||||
|
||||
class CatalogFactory implements AbstractFactory {
|
||||
static List<AbstractItem> items = [];
|
||||
@override GlobalKey getKey() { return key; }
|
||||
static GlobalKey<CatalogPageWidgetState> key = GlobalKey<CatalogPageWidgetState>();
|
||||
@override bool searchFill() { return CatalogFactory.items.isEmpty; }
|
||||
@override void clear() {
|
||||
mainKey?.currentState?.setState(() {
|
||||
HeaderConstants.headerKey.currentState?.setState(() {});
|
||||
HeaderConstants.headerWidget?.setState(() {});
|
||||
key.currentState?.widget.items = [];
|
||||
});
|
||||
}
|
||||
@override bool searchFill() { return key.currentState?.widget.items.isEmpty ?? true; }
|
||||
@override Widget factory(GoRouterState state, List<String> args) { return CatalogPageWidget(); }
|
||||
@override void search(BuildContext context) {
|
||||
@override void search(BuildContext context, bool special) {
|
||||
if (special) { return; }
|
||||
CatalogFactory.key.currentState?.widget.search.search(context, [ SearchConstants.get()! ], {}).then((value) {
|
||||
if (value.data == null) { return; }
|
||||
CatalogFactory.items = [ ...value.data!.workflows,
|
||||
...value.data!.processings, ...value.data!.datas, ...value.data!.storages, ...value.data!.datacenters,];
|
||||
searchWidgetKey.currentState?.setState(() {});
|
||||
CatalogFactory.key.currentState?.setState(() {});
|
||||
key.currentState?.widget.items = [ ...value.data!.workflows,
|
||||
...value.data!.processings, ...value.data!.datas, ...value.data!.storages, ...value.data!.computes,];
|
||||
HeaderConstants.headerKey.currentState?.setState(() {});
|
||||
HeaderConstants.headerWidget?.setState(() {});
|
||||
CatalogFactory.key.currentState?.setState(() {}); // ignore: invalid_use_of_protected_member
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class CatalogPageWidget extends StatefulWidget {
|
||||
double? itemWidth;
|
||||
List<AbstractItem> items = [];
|
||||
final ResourceService search = ResourceService();
|
||||
CatalogPageWidget ({
|
||||
this.itemWidth,
|
||||
@@ -41,76 +44,45 @@ class CatalogPageWidget extends StatefulWidget {
|
||||
}
|
||||
class CatalogPageWidgetState extends State<CatalogPageWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
if (widget.items.isEmpty) { return Container(); }
|
||||
return Column( children : [
|
||||
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(
|
||||
SizedBox(
|
||||
width: getMainWidth(context),
|
||||
height: getMainHeight(context),
|
||||
child: SingleChildScrollView( child: CatalogWidget(items: CatalogFactory.key.currentState?.widget.items, itemWidth: widget.itemWidth) )),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
PermsService.getPerm(Perms.WORKSPACE_SHARE) ? ShallowDropdownInputWidget(
|
||||
iconLoad: Icons.share_rounded,
|
||||
tooltipLoad: 'share',
|
||||
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(
|
||||
hintColor: midColor,
|
||||
type: CollaborativeAreaType.workspace,
|
||||
all: () async => CollaborativeAreaLocal.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(
|
||||
width: (getMainWidth(context) / 3),
|
||||
canLoad: (String? change) => CollaborativeAreaLocal.workspaces[change] == null
|
||||
|| !CollaborativeAreaLocal.workspaces[change]!.workspaces.map(
|
||||
(e) => e.id ).contains(WorkspaceLocal.current),
|
||||
canRemove: (String? change) => SharedWorkspaceLocal.workspaces[change] == null
|
||||
|| SharedWorkspaceLocal.workspaces[change]!.workspaces.map(
|
||||
canRemove: (String? change) => CollaborativeAreaLocal.workspaces[change] == null
|
||||
|| CollaborativeAreaLocal.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);
|
||||
CollaborativeAreaLocal.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: SingleChildScrollView( child: CatalogWidget(items: CatalogFactory.items, itemWidth: widget.itemWidth) )),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
CollaborativeAreaLocal.init(context, false);
|
||||
}) : Container(width: (getMainWidth(context) / 3), height: 50,
|
||||
color: const Color.fromRGBO(38, 166, 154, 1)),
|
||||
*/
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:oc_front/core/models/workspace_local.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/pages/abstract_page.dart';
|
||||
import 'package:oc_front/pages/catalog.dart';
|
||||
@@ -9,19 +10,21 @@ import 'package:oc_front/widgets/items/item_row.dart';
|
||||
|
||||
class CatalogItemFactory implements AbstractFactory {
|
||||
static GlobalKey<CatalogItemPageWidgetState> key = GlobalKey<CatalogItemPageWidgetState>();
|
||||
@override void clear() { }
|
||||
@override GlobalKey getKey() { return key; }
|
||||
@override bool searchFill() { return false; }
|
||||
@override Widget factory(GoRouterState state, List<String> args) {
|
||||
var id = state.pathParameters[args.first];
|
||||
try {
|
||||
var item = CatalogFactory.items.firstWhere( (element) => element.id == id );
|
||||
return CatalogItemPageWidget(item : item);
|
||||
var item = CatalogFactory.key.currentState?.widget.items.firstWhere( (element) => element.id == id );
|
||||
return CatalogItemPageWidget(item : item!);
|
||||
} catch (e) {
|
||||
var item = WorkspaceLocal.getItem(id ?? "", false);
|
||||
if (item != null) { return CatalogItemPageWidget(item : item as AbstractItem); }
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
@override void search(BuildContext context) { }
|
||||
@override void search(BuildContext context, bool special) { }
|
||||
}
|
||||
|
||||
class CatalogItemPageWidget extends StatefulWidget {
|
||||
@@ -32,7 +35,7 @@ class CatalogItemPageWidget extends StatefulWidget {
|
||||
class CatalogItemPageWidgetState extends State<CatalogItemPageWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
return Column( children: [
|
||||
ItemRowWidget(contextWidth: MediaQuery.of(context).size.width, item: widget.item, readOnly: true,),
|
||||
ItemRowWidget(contextWidth: getMainWidth(context), item: widget.item, readOnly: true,),
|
||||
ItemWidget(item: widget.item,),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -3,19 +3,21 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:oc_front/pages/abstract_page.dart';
|
||||
|
||||
class DatacenterFactory implements AbstractFactory {
|
||||
static GlobalKey<DataCenterPageWidgetState> key = GlobalKey<DataCenterPageWidgetState>();
|
||||
@override GlobalKey getKey() { return key; }
|
||||
@override void clear() { }
|
||||
static GlobalKey<ComputePageWidgetState> key = GlobalKey<ComputePageWidgetState>();
|
||||
@override bool searchFill() { return false; }
|
||||
@override Widget factory(GoRouterState state, List<String> args) { return DataCenterPageWidget(); }
|
||||
@override void search(BuildContext context) { }
|
||||
@override Widget factory(GoRouterState state, List<String> args) { return ComputePageWidget(); }
|
||||
@override void search(BuildContext context, bool special) { }
|
||||
}
|
||||
|
||||
class DataCenterPageWidget extends StatefulWidget {
|
||||
DataCenterPageWidget () : super(key: DatacenterFactory.key);
|
||||
@override DataCenterPageWidgetState createState() => DataCenterPageWidgetState();
|
||||
class ComputePageWidget extends StatefulWidget {
|
||||
ComputePageWidget () : super(key: DatacenterFactory.key);
|
||||
@override ComputePageWidgetState createState() => ComputePageWidgetState();
|
||||
|
||||
static Widget factory() { return DataCenterPageWidget(); }
|
||||
static Widget factory() { return ComputePageWidget(); }
|
||||
}
|
||||
class DataCenterPageWidgetState extends State<DataCenterPageWidget> {
|
||||
class ComputePageWidgetState extends State<ComputePageWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
return Column( children: []);
|
||||
}
|
||||
|
||||
@@ -5,10 +5,12 @@ import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:oc_front/pages/abstract_page.dart';
|
||||
|
||||
class MapFactory implements AbstractFactory {
|
||||
@override GlobalKey getKey() { return key; }
|
||||
@override void clear() { }
|
||||
static GlobalKey<MapPageWidgetState> key = GlobalKey<MapPageWidgetState>();
|
||||
@override bool searchFill() { return false; }
|
||||
@override Widget factory(GoRouterState state, List<String> args) { return MapPageWidget(); }
|
||||
@override void search(BuildContext context) { }
|
||||
@override void search(BuildContext context, bool special) { }
|
||||
}
|
||||
|
||||
class MapPageWidget extends StatefulWidget {
|
||||
|
||||
@@ -4,15 +4,18 @@ 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';
|
||||
|
||||
class SchedulerFactory implements AbstractFactory {
|
||||
@override GlobalKey getKey() { return key; }
|
||||
@override void clear() { }
|
||||
static GlobalKey<SchedulerPageWidgetState> key = GlobalKey<SchedulerPageWidgetState>();
|
||||
@override bool searchFill() { return false; }
|
||||
@override Widget factory(GoRouterState state, List<String> args) { return SchedulerPageWidget(); }
|
||||
@override void search(BuildContext context) { }
|
||||
@override void search(BuildContext context, bool special) { }
|
||||
}
|
||||
|
||||
class SchedulerPageWidget extends StatefulWidget {
|
||||
@@ -26,7 +29,7 @@ class SchedulerPageWidget extends StatefulWidget {
|
||||
static Widget factory() { return SchedulerPageWidget(); }
|
||||
}
|
||||
class SchedulerPageWidgetState extends State<SchedulerPageWidget> {
|
||||
List<Color> colors = [Colors.blue, Colors.orange, Colors.red, Colors.green];
|
||||
List<Color> colors = [Colors.blue, Colors.orange, redColor, Colors.green];
|
||||
List<String> titles = ["SCHEDULED", "RUNNING", "FAILURE", "SUCCESS"];
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
@@ -92,8 +95,8 @@ class SchedulerPageWidgetState extends State<SchedulerPageWidget> {
|
||||
}
|
||||
}
|
||||
return Column( children: [
|
||||
Container( color: const Color.fromRGBO(38, 166, 154, 1),
|
||||
height: 50, width: MediaQuery.of(context).size.width,
|
||||
Container( color: lightColor,
|
||||
height: 50, width: getMainWidth(context),
|
||||
child: Padding(padding: const EdgeInsets.symmetric(horizontal: 50),
|
||||
child: Row( children: [
|
||||
Padding(padding: const EdgeInsets.only(right: 30),
|
||||
@@ -107,7 +110,7 @@ class SchedulerPageWidgetState extends State<SchedulerPageWidget> {
|
||||
),
|
||||
),
|
||||
Container(padding: const EdgeInsets.only(left: 20),
|
||||
width: MediaQuery.of(context).size.width / 5,
|
||||
width: getMainWidth(context) / 5,
|
||||
height: 30,
|
||||
child: DateTimeField(
|
||||
validator: (value) {
|
||||
@@ -122,7 +125,7 @@ class SchedulerPageWidgetState extends State<SchedulerPageWidget> {
|
||||
cardTheme: CardTheme(elevation: 0, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(0))),
|
||||
dialogTheme: DialogTheme(elevation: 0, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(0))),
|
||||
colorScheme: ColorScheme.light(
|
||||
background: Colors.grey.shade300,
|
||||
background: midColor,
|
||||
tertiary: Colors.grey,
|
||||
secondary: Colors.grey,
|
||||
primary: Colors.black),
|
||||
@@ -165,7 +168,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, right: 20),
|
||||
width: MediaQuery.of(context).size.width / 5,
|
||||
width: getMainWidth(context) / 5,
|
||||
height: 30,
|
||||
child: DateTimeField(
|
||||
validator: (value) {
|
||||
@@ -180,7 +183,7 @@ class SchedulerPageWidgetState extends State<SchedulerPageWidget> {
|
||||
cardTheme: CardTheme(elevation: 0, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(0))),
|
||||
dialogTheme: DialogTheme(elevation: 0, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(0))),
|
||||
colorScheme: ColorScheme.light(
|
||||
background: Colors.grey.shade300,
|
||||
background: midColor,
|
||||
tertiary: Colors.grey,
|
||||
secondary: Colors.grey,
|
||||
primary: Colors.black),
|
||||
|
||||
@@ -5,10 +5,12 @@ 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/perms_service.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/main.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/models/shared.dart';
|
||||
import 'package:oc_front/pages/abstract_page.dart';
|
||||
@@ -18,17 +20,19 @@ 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 }
|
||||
enum CollaborativeAreaType { global, collaborative_area, workspace, workflow, peer, resource }
|
||||
|
||||
class SharedFactory implements AbstractFactory {
|
||||
@override GlobalKey getKey() { return key; }
|
||||
@override void clear() { }
|
||||
static GlobalKey<SharedPageWidgetState> key = GlobalKey<SharedPageWidgetState>();
|
||||
@override bool searchFill() { return false; }
|
||||
@override Widget factory(GoRouterState state, List<String> args) { return SharedPageWidget(); }
|
||||
@override void search(BuildContext context) { }
|
||||
@override void search(BuildContext context, bool special) { }
|
||||
}
|
||||
|
||||
class SharedPageWidget extends StatefulWidget {
|
||||
SharedWorkspaceType type = SharedWorkspaceType.global;
|
||||
CollaborativeAreaType type = CollaborativeAreaType.global;
|
||||
SharedPageWidget(): super(key: SharedFactory.key);
|
||||
@override SharedPageWidgetState createState() => SharedPageWidgetState();
|
||||
static void search(BuildContext context) { }
|
||||
@@ -36,15 +40,15 @@ class SharedPageWidget extends StatefulWidget {
|
||||
}
|
||||
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";
|
||||
Widget getMenuItem(CollaborativeAreaType workspaceType, IconData icon) {
|
||||
var s = workspaceType == CollaborativeAreaType.global ? "dashboard" : workspaceType == CollaborativeAreaType.workspace ? "shared workspaces" : workspaceType == CollaborativeAreaType.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,
|
||||
color: widget.type == workspaceType ? darkColor : Colors.transparent,
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child : Icon(icon,
|
||||
color: widget.type == workspaceType ? Colors.white : Colors.white, size: 20))));
|
||||
@@ -52,9 +56,9 @@ class SharedPageWidgetState extends State<SharedPageWidget> {
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
GlobalKey<ShallowTextInputWidgetState> key = GlobalKey<ShallowTextInputWidgetState>();
|
||||
if (SharedWorkspaceLocal.current == null) {
|
||||
if (CollaborativeAreaLocal.current == null) {
|
||||
Future.delayed( const Duration(microseconds: 100), () {
|
||||
HeaderConstants.setTitle("Choose a Shared Workspace");
|
||||
HeaderConstants.setTitle("Choose a Collaborative Area");
|
||||
HeaderConstants.setDescription("select a shared workspace to continue");
|
||||
});
|
||||
Future.delayed( const Duration(milliseconds: 100), () {
|
||||
@@ -67,78 +71,90 @@ class SharedPageWidgetState extends State<SharedPageWidget> {
|
||||
shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(0)),
|
||||
title: ShallowCreationDialogWidget(
|
||||
formKey: key,
|
||||
canClose: () => SharedWorkspaceLocal.current != null,
|
||||
canClose: () => CollaborativeAreaLocal.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 ?? "");
|
||||
CollaborativeAreaLocal.current = p0;
|
||||
HeaderConstants.setTitle("Collaborative Area <${CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current]?.name ?? ""}>");
|
||||
HeaderConstants.setDescription(CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.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,
|
||||
type: CollaborativeAreaType.collaborative_area,
|
||||
width: getMainWidth(context) <= 540 ? getMainWidth(context) - 140 : 400,
|
||||
attr: "description",
|
||||
color: Colors.black,
|
||||
hintColor: Colors.grey,
|
||||
filled: Colors.grey.shade300,
|
||||
hint: "enter collaborative area description...",
|
||||
filled: midColor,
|
||||
)
|
||||
],
|
||||
create: (p0) async => await SharedService().post(context, p0, {}).then((value) {
|
||||
create: PermsService.getPerm(Perms.COLLABORATIVE_AREA_CREATE) ? (p0) async => await SharedService().post(context, p0, {}).then((value) {
|
||||
if (value.data != null) {
|
||||
SharedWorkspaceLocal.current = value.data!.id;
|
||||
CollaborativeAreaLocal.current = value.data!.id;
|
||||
}
|
||||
SharedWorkspaceLocal.init(context, true);
|
||||
CollaborativeAreaLocal.init(context, true);
|
||||
|
||||
HeaderConstants.setTitle("Shared Workspace <${SharedWorkspaceLocal.workspaces[SharedWorkspaceLocal.current]?.name ?? ""}>");
|
||||
HeaderConstants.setDescription(SharedWorkspaceLocal.workspaces[SharedWorkspaceLocal.current]?.description ?? "");
|
||||
HeaderConstants.setTitle("Collaborative Area <${CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current]?.name ?? ""}>");
|
||||
HeaderConstants.setDescription(CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current]?.description ?? "");
|
||||
Future.delayed(const Duration(seconds: 1), () => SharedFactory.key.currentState?.setState(() {}));
|
||||
}),
|
||||
type: SharedWorkspaceType.shared_workspace,
|
||||
all: () async => SharedWorkspaceLocal.workspaces.values.map(
|
||||
}) : null,
|
||||
type: CollaborativeAreaType.collaborative_area,
|
||||
all: () async => CollaborativeAreaLocal.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 ?? "");
|
||||
HeaderConstants.setTitle("Collaborative Area <${CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current]?.name ?? ""}>");
|
||||
HeaderConstants.setDescription(CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current]?.description ?? "");
|
||||
});
|
||||
}
|
||||
Widget w = WorkspaceSharedPageWidget(type: widget.type);
|
||||
List<Widget> addMenu = [];
|
||||
SharedWorkspace? current = SharedWorkspaceLocal.workspaces[SharedWorkspaceLocal.current ?? ""];
|
||||
if (widget.type == SharedWorkspaceType.workspace) {
|
||||
CollaborativeArea? current = CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current ?? ""];
|
||||
if (widget.type == CollaborativeAreaType.workspace) {
|
||||
addMenu.add( Row( mainAxisAlignment: MainAxisAlignment.end,
|
||||
children : [ ShallowDropdownInputWidget(
|
||||
children : [ Container( padding: EdgeInsets.only(left: 20), decoration: BoxDecoration(
|
||||
border: Border(left: BorderSide(color: Colors.white))
|
||||
), child: ShallowDropdownInputWidget(
|
||||
tooltipLoad: "share",
|
||||
tooltipRemove: "unshare",
|
||||
iconLoad: Icons.share,
|
||||
type: widget.type,
|
||||
filled: lightColor,
|
||||
hintColor: midColor,
|
||||
color: Colors.white,
|
||||
prefixIcon: Icon(Icons.shopping_cart, color: Colors.white),
|
||||
current: WorkspaceLocal.current,
|
||||
all: () async => WorkspaceLocal.getWorkspacesShallow(),
|
||||
width: MediaQuery.of(context).size.width / 3,
|
||||
width: getMainWidth(context) / 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);
|
||||
await service.addWorkspace(context, CollaborativeAreaLocal.current ?? "", val);
|
||||
CollaborativeAreaLocal.init(context, false);
|
||||
},
|
||||
remove: (String val) async {
|
||||
await service.removeWorkspace(context, SharedWorkspaceLocal.current ?? "", val);
|
||||
SharedWorkspaceLocal.init(context, false);
|
||||
})
|
||||
await service.removeWorkspace(context, CollaborativeAreaLocal.current ?? "", val);
|
||||
CollaborativeAreaLocal.init(context, false);
|
||||
}))
|
||||
]));
|
||||
}
|
||||
if (widget.type == SharedWorkspaceType.workflow) {
|
||||
if (widget.type == CollaborativeAreaType.workflow) {
|
||||
addMenu.add( Row( mainAxisAlignment: MainAxisAlignment.end,
|
||||
children : [ ShallowDropdownInputWidget(
|
||||
children : [ Container( padding: EdgeInsets.only(left: 20), decoration: BoxDecoration(
|
||||
border: Border(left: BorderSide(color: Colors.white))
|
||||
), child: ShallowDropdownInputWidget(
|
||||
tooltipLoad: "share",
|
||||
tooltipRemove: "unshare",
|
||||
iconLoad: Icons.share,
|
||||
filled: lightColor,
|
||||
hintColor: midColor,
|
||||
color: Colors.white,
|
||||
type: widget.type, all: () async {
|
||||
List<Shallow> shals = [];
|
||||
await WorflowService().all(context).then((value) {
|
||||
@@ -148,22 +164,28 @@ class SharedPageWidgetState extends State<SharedPageWidget> {
|
||||
});
|
||||
return shals;
|
||||
},
|
||||
width: MediaQuery.of(context).size.width / 3,
|
||||
width: getMainWidth(context) / 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);
|
||||
await service.addWorkflow(context, CollaborativeAreaLocal.current ?? "", change);
|
||||
},
|
||||
remove: (String change) async {
|
||||
await service.removeWorkflow(context, SharedWorkspaceLocal.current ?? "", change);
|
||||
})
|
||||
await service.removeWorkflow(context, CollaborativeAreaLocal.current ?? "", change);
|
||||
}))
|
||||
]));
|
||||
}
|
||||
if (widget.type == SharedWorkspaceType.peer) {
|
||||
if (widget.type == CollaborativeAreaType.peer) {
|
||||
addMenu.add( Row( mainAxisAlignment: MainAxisAlignment.end,
|
||||
children : [ ShallowDropdownInputWidget(
|
||||
children : [
|
||||
Container( padding: EdgeInsets.only(left: 20), decoration: BoxDecoration(
|
||||
border: Border(left: BorderSide(color: Colors.white))
|
||||
), child: ShallowDropdownInputWidget(
|
||||
tooltipLoad: "add",
|
||||
iconLoad: Icons.add,
|
||||
filled: lightColor,
|
||||
hintColor: midColor,
|
||||
color: Colors.white,
|
||||
type: widget.type, all: () async {
|
||||
List<Shallow> shals = [];
|
||||
await PeerService().all(context).then((value) {
|
||||
@@ -173,22 +195,22 @@ class SharedPageWidgetState extends State<SharedPageWidget> {
|
||||
});
|
||||
return shals;
|
||||
},
|
||||
width: MediaQuery.of(context).size.width / 3,
|
||||
width: getMainWidth(context) / 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);
|
||||
await service.addPeer(context, CollaborativeAreaLocal.current ?? "", change);
|
||||
},
|
||||
remove: (String change) async {
|
||||
await service.removePeer(context, SharedWorkspaceLocal.current ?? "", change);
|
||||
})
|
||||
await service.removePeer(context, CollaborativeAreaLocal.current ?? "", change);
|
||||
}))
|
||||
]));
|
||||
}
|
||||
return Column( children: [
|
||||
Container(
|
||||
height: 50,
|
||||
color: const Color.fromRGBO(38, 166, 154, 1),
|
||||
width: MediaQuery.of(context).size.width,
|
||||
color: lightColor,
|
||||
width: getMainWidth(context),
|
||||
padding: const EdgeInsets.only(left: 50),
|
||||
child: Stack( alignment: Alignment.centerLeft, children: [
|
||||
Tooltip( message: "open file", child: Padding( padding: const EdgeInsets.only(right: 15),
|
||||
@@ -204,37 +226,37 @@ class SharedPageWidgetState extends State<SharedPageWidget> {
|
||||
shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(0)),
|
||||
title: ShallowCreationDialogWidget(
|
||||
formKey: key,
|
||||
canClose: () => SharedWorkspaceLocal.current != null,
|
||||
canClose: () => CollaborativeAreaLocal.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 ?? "");
|
||||
CollaborativeAreaLocal.current = p0;
|
||||
HeaderConstants.setTitle("Collaborative Area <${CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current]?.name ?? ""}>");
|
||||
HeaderConstants.setDescription(CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.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,
|
||||
type: CollaborativeAreaType.collaborative_area,
|
||||
width: getMainWidth(context) <= 540 ? getMainWidth(context) - 140 : 400,
|
||||
attr: "description",
|
||||
color: Colors.black,
|
||||
hintColor: Colors.grey,
|
||||
filled: Colors.grey.shade300,
|
||||
filled: midColor,
|
||||
)
|
||||
],
|
||||
create: (p0) async => await SharedService().post(context, p0, {}).then( (e) {
|
||||
create: PermsService.getPerm(Perms.COLLABORATIVE_AREA_CREATE) ? (p0) async => await SharedService().post(context, p0, {}).then( (e) {
|
||||
if (e.data != null) {
|
||||
SharedWorkspaceLocal.current = e.data!.id;
|
||||
CollaborativeAreaLocal.current = e.data!.id;
|
||||
}
|
||||
SharedWorkspaceLocal.init(context, true);
|
||||
CollaborativeAreaLocal.init(context, true);
|
||||
|
||||
HeaderConstants.setTitle("Shared Workspace <${SharedWorkspaceLocal.workspaces[SharedWorkspaceLocal.current]?.name ?? ""}>");
|
||||
HeaderConstants.setDescription(SharedWorkspaceLocal.workspaces[SharedWorkspaceLocal.current]?.description ?? "");
|
||||
HeaderConstants.setTitle("Collaborative Area <${CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current]?.name ?? ""}>");
|
||||
HeaderConstants.setDescription(CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current]?.description ?? "");
|
||||
Future.delayed(const Duration(seconds: 1), () => SharedFactory.key.currentState?.setState(() {}));
|
||||
}),
|
||||
type: SharedWorkspaceType.shared_workspace,
|
||||
all: () async => SharedWorkspaceLocal.workspaces.values.map(
|
||||
}) : null,
|
||||
type: CollaborativeAreaType.collaborative_area,
|
||||
all: () async => CollaborativeAreaLocal.workspaces.values.map(
|
||||
(e) => Shallow(id: e.id ?? "", name: e.name ?? "") ).toList(),
|
||||
));
|
||||
});
|
||||
@@ -245,21 +267,24 @@ class SharedPageWidgetState extends State<SharedPageWidget> {
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
color: Colors.black,
|
||||
height: MediaQuery.of(context).size.height - HeaderConstants.height - 50,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black,
|
||||
border: Border(left: BorderSide(color: lightColor))
|
||||
),
|
||||
height: getMainHeight(context) - 50,
|
||||
width: 50,
|
||||
child: Column(
|
||||
children: [
|
||||
getMenuItem(SharedWorkspaceType.global, Icons.dashboard),
|
||||
getMenuItem(SharedWorkspaceType.workspace, Icons.workspaces),
|
||||
getMenuItem(SharedWorkspaceType.workflow, Icons.rebase_edit),
|
||||
getMenuItem(SharedWorkspaceType.peer, Icons.group),
|
||||
getMenuItem(CollaborativeAreaType.global, Icons.dashboard),
|
||||
getMenuItem(CollaborativeAreaType.workspace, Icons.workspaces),
|
||||
getMenuItem(CollaborativeAreaType.workflow, Icons.rebase_edit),
|
||||
getMenuItem(CollaborativeAreaType.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,
|
||||
height: getMainHeight(context) - 50,
|
||||
width: getMainWidth(context) -50,
|
||||
color: widget.type == CollaborativeAreaType.workflow || widget.type == CollaborativeAreaType.peer ? midColor : Colors.white,
|
||||
child: SingleChildScrollView( child: w ))
|
||||
]
|
||||
) ]
|
||||
@@ -268,40 +293,40 @@ class SharedPageWidgetState extends State<SharedPageWidget> {
|
||||
}
|
||||
|
||||
class WorkspaceSharedPageWidget extends StatefulWidget {
|
||||
SharedWorkspaceType type = SharedWorkspaceType.global;
|
||||
CollaborativeAreaType type = CollaborativeAreaType.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) {
|
||||
if (CollaborativeAreaLocal.current == null) {
|
||||
return Container();
|
||||
}
|
||||
var space = SharedWorkspaceLocal.workspaces[SharedWorkspaceLocal.current ?? ""]!;
|
||||
var space = CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current ?? ""]!;
|
||||
List<Widget> items = [];
|
||||
List<ShallowData> data = [];
|
||||
if (widget.type == SharedWorkspaceType.global) {
|
||||
} else if (widget.type == SharedWorkspaceType.workspace) {
|
||||
if (widget.type == CollaborativeAreaType.global) {
|
||||
} else if (widget.type == CollaborativeAreaType.workspace) {
|
||||
data = space.workspaces;
|
||||
} else if (widget.type == SharedWorkspaceType.workflow) {
|
||||
} else if (widget.type == CollaborativeAreaType.workflow) {
|
||||
data = space.workflows;
|
||||
} else if (widget.type == SharedWorkspaceType.peer) {
|
||||
} else if (widget.type == CollaborativeAreaType.peer) {
|
||||
data = space.peers;
|
||||
}
|
||||
var current = SharedWorkspaceLocal.workspaces[SharedWorkspaceLocal.current];
|
||||
var current = CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current];
|
||||
for (var w in data) {
|
||||
if (widget.type == SharedWorkspaceType.workspace) {
|
||||
if (widget.type == CollaborativeAreaType.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) {
|
||||
} else if (widget.type == CollaborativeAreaType.workflow || widget.type == CollaborativeAreaType.peer) {
|
||||
List<IconData> badges = [];
|
||||
if (widget.type == SharedWorkspaceType.peer && w.getID() == current?.creatorID) {
|
||||
if (widget.type == CollaborativeAreaType.peer && w.getID() == current?.creatorID) {
|
||||
badges.add(Icons.star);
|
||||
}
|
||||
items.add(ShallowItemRowWidget(
|
||||
item: w, badges: badges,
|
||||
edit: widget.type == SharedWorkspaceType.workflow ? (String? change) {
|
||||
edit: widget.type == CollaborativeAreaType.workflow ? (String? change) {
|
||||
if (change != null) {
|
||||
WorkspaceLocal.changeWorkspaceByName(change.split("~")[1]);
|
||||
}
|
||||
@@ -309,27 +334,27 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
} : null,
|
||||
delete: (String? change) async {
|
||||
if (change == null) { return; }
|
||||
if (widget.type == SharedWorkspaceType.peer) {
|
||||
await SharedService().removePeer(context, SharedWorkspaceLocal.current ?? "", change);
|
||||
if (widget.type == CollaborativeAreaType.peer) {
|
||||
await SharedService().removePeer(context, CollaborativeAreaLocal.current ?? "", change);
|
||||
} else {
|
||||
await SharedService().removePeer(context, SharedWorkspaceLocal.current ?? "", change);
|
||||
await SharedService().removePeer(context, CollaborativeAreaLocal.current ?? "", change);
|
||||
}
|
||||
},
|
||||
icon: widget.type == SharedWorkspaceType.workflow ? Icons.work_history_rounded : Icons.person,
|
||||
icon: widget.type == CollaborativeAreaType.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,
|
||||
color: midColor,
|
||||
height: getMainHeight(context) - 50,
|
||||
width: getMainWidth(context) - 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) {
|
||||
if (widget.type == CollaborativeAreaType.workflow || widget.type == CollaborativeAreaType.peer) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(50),
|
||||
child: Stack( alignment: Alignment.topLeft, children : items));
|
||||
@@ -349,10 +374,10 @@ class WorkspaceSharedItemPageWidgetState extends State<WorkspaceSharedItemPageWi
|
||||
@override Widget build(BuildContext context) {
|
||||
return Column( children: [
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width - 50,
|
||||
width: getMainWidth(context) - 50,
|
||||
height: 50,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
decoration: BoxDecoration(color: Colors.grey.shade300),
|
||||
decoration: BoxDecoration(color: midColor),
|
||||
child: Stack(
|
||||
alignment: Alignment.centerLeft,
|
||||
children: [
|
||||
@@ -369,7 +394,7 @@ class WorkspaceSharedItemPageWidgetState extends State<WorkspaceSharedItemPageWi
|
||||
})))
|
||||
])
|
||||
),
|
||||
widget.open ? CatalogWidget(itemWidth: MediaQuery.of(context).size.width - 50,
|
||||
widget.open ? CatalogWidget(itemWidth: getMainWidth(context) - 50,
|
||||
items: WorkspaceLocal.byWorkspace(widget.id)) : Container()
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.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/perms_service.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/workflow_service.dart';
|
||||
import 'package:oc_front/main.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/pages/shared.dart';
|
||||
import 'package:oc_front/widgets/dialog/shallow_creation.dart';
|
||||
import 'package:oc_front/widgets/forms/compute_forms.dart';
|
||||
import 'package:oc_front/widgets/forms/data_forms.dart';
|
||||
import 'package:oc_front/widgets/forms/processing_forms.dart';
|
||||
import 'package:oc_front/widgets/forms/scheduler_forms.dart';
|
||||
@@ -21,6 +22,8 @@ import 'package:oc_front/widgets/inputs/shallow_dropdown_input.dart';
|
||||
|
||||
Dashboard dash = Dashboard(name: "");
|
||||
class WorkflowFactory implements AbstractFactory {
|
||||
@override GlobalKey getKey() { return key; }
|
||||
@override void clear() { }
|
||||
static GlobalKey<WorkflowPageWidgetState> key = GlobalKey<WorkflowPageWidgetState>();
|
||||
@override bool searchFill() { return false; }
|
||||
@override Widget factory(GoRouterState state, List<String> args) {
|
||||
@@ -29,7 +32,7 @@ class WorkflowFactory implements AbstractFactory {
|
||||
} catch (e) { }
|
||||
return WorkflowPageWidget(id: id);
|
||||
}
|
||||
@override void search(BuildContext context) { }
|
||||
@override void search(BuildContext context, bool special) { }
|
||||
}
|
||||
bool getAll = true;
|
||||
|
||||
@@ -45,7 +48,7 @@ final WorflowService _service = WorflowService();
|
||||
Widget itemBuild(Object item) {
|
||||
var e = item as AbstractItem;
|
||||
return Tooltip( message: item.name ?? "",
|
||||
child: e.logo != null ? Image.network(e.logo ?? "", fit: BoxFit.fill)
|
||||
child: e.logo != null ? Image.network(e.logo ?? "", fit: BoxFit.fill)
|
||||
: Image.network('https://get-picto.com/wp-content/uploads/2024/01/logo-instagram-png.webp',
|
||||
fit: BoxFit.fill));
|
||||
}
|
||||
@@ -63,6 +66,8 @@ final WorflowService _service = WorflowService();
|
||||
res = [DataFormsWidget(item: objAbs as DataItem)];
|
||||
} else if ( objAbs.topic == "storage" ) {
|
||||
res = [StorageFormsWidget(item: objAbs as StorageItem)];
|
||||
} else if ( objAbs.topic == "compute" ) {
|
||||
res = [ComputeFormsWidget(item: objAbs as ComputeItem)];
|
||||
}
|
||||
return [ Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
@@ -77,6 +82,43 @@ final WorflowService _service = WorflowService();
|
||||
]) ];
|
||||
}
|
||||
|
||||
Widget? getTopRight(FlowData? obj) {
|
||||
var objAbs = obj as AbstractItem?;
|
||||
if (objAbs == null) { return null; }
|
||||
if (objAbs.topic == "compute" ) {
|
||||
var compute = objAbs as ComputeItem;
|
||||
if (compute.technology == 0) {
|
||||
return Icon(FontAwesomeIcons.docker, size: 18);
|
||||
} else if (compute.technology == 1) {
|
||||
return Icon(FontAwesomeIcons.lifeRing, size: 18);
|
||||
} else if (compute.technology == 2) {
|
||||
return Icon(FontAwesomeIcons.cubes, size: 18);
|
||||
} else if (compute.technology == 3) {
|
||||
return Icon(FontAwesomeIcons.hardDrive, size: 18);
|
||||
} else if (compute.technology == 4) {
|
||||
return Icon(FontAwesomeIcons.v, size: 18);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Widget? getBottomLeftBadge(FlowData? obj) {
|
||||
var objAbs = obj as AbstractItem?;
|
||||
if (objAbs == null) { return null; }
|
||||
if (objAbs.topic == "processing" ) {
|
||||
return Icon(FontAwesomeIcons.gear) ;
|
||||
} else if (objAbs.topic == "data" ) {
|
||||
return Icon(FontAwesomeIcons.file);
|
||||
} else if (objAbs.topic == "storage" ) {
|
||||
return Icon(FontAwesomeIcons.database);
|
||||
} else if (objAbs.topic == "compute" ) {
|
||||
return Icon(FontAwesomeIcons.microchip);
|
||||
} else if (objAbs.topic == "workflows" ) {
|
||||
return Icon(FontAwesomeIcons.diagramProject);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Widget> getDashInfoForms() {
|
||||
return [
|
||||
SchedulerFormsWidget(item: dash),
|
||||
@@ -93,8 +135,10 @@ final WorflowService _service = WorflowService();
|
||||
} else {
|
||||
name = selected;
|
||||
}
|
||||
await _service.get(context, dash.id ?? "").then((value) {
|
||||
await _service.get(context, dash.id ?? "").then((value) async {
|
||||
if (value.data != null) {
|
||||
await WorkspaceLocal.init(context, false);
|
||||
WorkspaceLocal.changeWorkspaceByName("${value.data?.name ?? ""}_workspace");
|
||||
dash.clear();
|
||||
dash.deserialize(value.data!.toDashboard());
|
||||
Future.delayed(const Duration(seconds: 1), () {
|
||||
@@ -107,10 +151,11 @@ final WorflowService _service = WorflowService();
|
||||
}
|
||||
|
||||
Future<void> saveDash(String? id) async {
|
||||
if (id == null || !dash.isOpened || !dash.shouldSave) { return; }
|
||||
if (id == null || !dash.isOpened || !dash.shouldSave
|
||||
|| !PermsService.getPerm(Perms.WORKFLOW_EDIT)) { 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(
|
||||
var compute = WorkspaceLocal.byTopic("compute", true).where(
|
||||
(element) => dash.elements.map( (e) => e.element?.getID()).contains(element.id) );
|
||||
var storage = WorkspaceLocal.byTopic("storage", true).where(
|
||||
(element) => dash.elements.map( (e) => e.element?.getID()).contains(element.id) );
|
||||
@@ -122,7 +167,7 @@ final WorflowService _service = WorflowService();
|
||||
name: dash.name,
|
||||
graph: Graph(),
|
||||
data: datas.map((e) => e.id).toSet().toList(),
|
||||
datacenter: dataCenter.map((e) => e.id).toSet().toList(),
|
||||
compute: compute.map((e) => e.id).toSet().toList(),
|
||||
storage: storage.map((e) => e.id).toSet().toList(),
|
||||
processing: computing.map((e) => e.id).toSet().toList(),
|
||||
workflows: workflows.map((e) => e.id).toSet().toList(),
|
||||
@@ -143,10 +188,11 @@ final WorflowService _service = WorflowService();
|
||||
}
|
||||
updateW.graph?.zoom = dash.getZoomFactor();
|
||||
dash.addToHistory();
|
||||
await _service.put(context, id, updateW.serialize(), {}).then( (e) {
|
||||
await _service.put(context, id, updateW.serialize(), {}).then( (e) async {
|
||||
if (dash.addChange) {
|
||||
dash.addChange = false;
|
||||
WorkspaceLocal.init(context, false);
|
||||
await WorkspaceLocal.init(context, false);
|
||||
WorkspaceLocal.changeWorkspaceByName("${dash.name}_workspace");
|
||||
dash.selectedLeftMenuKey.currentState?.setState(() { });
|
||||
}
|
||||
});
|
||||
@@ -157,7 +203,7 @@ final WorflowService _service = WorflowService();
|
||||
if (d == null) { return null; }
|
||||
d.model = ResourceModel().deserialize(data["resource_model"]);
|
||||
if (d.topic == "data") { return d as DataItem; }
|
||||
if (d.topic == "datacenter") { return d as DataCenterItem; }
|
||||
if (d.topic == "compute") { return d as ComputeItem; }
|
||||
if (d.topic == "storage") { return d as StorageItem; }
|
||||
if (d.topic == "processing") {
|
||||
d = d as ProcessingItem;
|
||||
@@ -171,48 +217,28 @@ final WorflowService _service = WorflowService();
|
||||
}
|
||||
|
||||
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 ShallowDropdownInputWidget(
|
||||
current: WorkspaceLocal.current,
|
||||
width: quart > 80 ? quart : 80,
|
||||
all: () async => WorkspaceLocal.getWorkspacesShallow(),
|
||||
type: SharedWorkspaceType.workspace,
|
||||
change: (String? change) {
|
||||
WorkspaceLocal.changeWorkspace(change.toString());
|
||||
}
|
||||
);
|
||||
return Container( padding: EdgeInsets.only(left: 50),
|
||||
decoration: BoxDecoration( border: Border( left: BorderSide( color: Colors.white ))),
|
||||
child: ShallowDropdownInputWidget(
|
||||
filled: lightColor,
|
||||
hintColor: Colors.grey.shade200,
|
||||
color: Colors.white,
|
||||
prefixIcon: Padding( padding: EdgeInsets.only(right: 10), child: Icon(Icons.shopping_cart, color: Colors.grey.shade200)),
|
||||
current: WorkspaceLocal.current,
|
||||
width: 300,
|
||||
all: () async => WorkspaceLocal.getWorkspacesShallow(),
|
||||
type: CollaborativeAreaType.workspace,
|
||||
change: (String? change) {
|
||||
WorkspaceLocal.changeWorkspace(change.toString());
|
||||
},
|
||||
canLoad: (p0) => true,
|
||||
load: (p0) async {
|
||||
dash.isInfo = !dash.isInfo;
|
||||
dash.flutterChartKey.currentState?.setState(() { });
|
||||
},
|
||||
tooltipLoad: "open workspace manager",
|
||||
iconLoad: dash.isInfo ? Icons.remove_red_eye_outlined : Icons.remove_red_eye,
|
||||
));
|
||||
}
|
||||
Widget onDashboardAlertOpened(BuildContext context, Dashboard dash) {
|
||||
return ShallowCreationDialogWidget(
|
||||
@@ -221,28 +247,28 @@ final WorflowService _service = WorflowService();
|
||||
load: (p0) async {
|
||||
dash.isOpened = true;
|
||||
if (dash.load != null) {
|
||||
WorkspaceLocal.changeWorkspaceByName(p0.split("~")[1]);
|
||||
WorkspaceLocal.changeWorkspaceByName(p0.split("~")[1]);
|
||||
await dash.load!(p0);
|
||||
}
|
||||
dash.notifyListeners();
|
||||
},
|
||||
create: (p0) async => await _service.post(context, p0, {}).then( (value) {
|
||||
create: PermsService.getPerm(Perms.WORKFLOW_CREATE) ? (p0) async => await _service.post(context, p0, {}).then( (value) async {
|
||||
dash.clear();
|
||||
dash.id = value.data?.getID() ?? "";
|
||||
dash.name = value.data?.getName() ?? "";
|
||||
dash.notifyListeners();
|
||||
WorkspaceLocal.init(context, true);
|
||||
await WorkspaceLocal.init(context, true);
|
||||
dash.isOpened = true;
|
||||
Future.delayed(const Duration(seconds: 1), () {
|
||||
dash.load!("${dash.id}~${dash.name}");
|
||||
});
|
||||
}
|
||||
),
|
||||
) : null,
|
||||
maptoDropdown: (e) => DropdownMenuItem<String>(
|
||||
value: "${e.id}~${e.name}",
|
||||
child: Text(e.name),
|
||||
),
|
||||
type: SharedWorkspaceType.workflow,
|
||||
type: CollaborativeAreaType.workflow,
|
||||
all: () async {
|
||||
List<Shallow> res = [];
|
||||
await _service.all(context).then(
|
||||
@@ -259,24 +285,28 @@ final WorflowService _service = WorflowService();
|
||||
@override Widget build(BuildContext context) {
|
||||
dash.load = loadDash;
|
||||
dash.save = saveDash;
|
||||
dash.dashColor = lightColor;
|
||||
dash.midDashColor = midColor;
|
||||
dash.transformToData = transformToData;
|
||||
dash.infoItemWidget = getForms;
|
||||
dash.infoWidget = getDashInfoForms;
|
||||
var quart = MediaQuery.of(context).size.width / 6;
|
||||
dash.widthOffset = 50;
|
||||
return FlowChart<AbstractItem>(
|
||||
key: dash.flutterChartKey,
|
||||
itemLeftBottomBadges: getBottomLeftBadge,
|
||||
itemrightTopBadges: getTopRight,
|
||||
onDashboardAlertOpened: onDashboardAlertOpened,
|
||||
dashboard: dash,
|
||||
current: widget.id,
|
||||
itemWidget: itemBuild,
|
||||
menuWidget: onDashboardMenu,
|
||||
categories: const ["processing", "data", "datacenter", "storage", "workflows"],
|
||||
categories: const ["processing", "data", "compute", "storage", "workflows"],
|
||||
draggableItemBuilder: (cat) => WorkspaceLocal.byTopic(cat, false),
|
||||
itemWidgetTooltip: itemTooltipBuild,
|
||||
innerMenuWidth: quart > 80 ? quart : 80,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height - HeaderConstants.height,
|
||||
innerMenuWidth: 350,
|
||||
width: getMainWidth(context),
|
||||
height: getMainHeight(context),
|
||||
onNewConnection: (p1, p2) { },
|
||||
menuExtension: menuExtension,
|
||||
onDashboardTapped: (context, position) { },
|
||||
onScaleUpdate: (newScale) { },
|
||||
onDashboardSecondaryTapped: (context, position) { },
|
||||
|
||||
Reference in New Issue
Block a user