|
|
|
|
@@ -1,7 +1,9 @@
|
|
|
|
|
import 'dart:async';
|
|
|
|
|
import 'dart:math';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
|
import 'package:intl/intl.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';
|
|
|
|
|
@@ -12,7 +14,9 @@ 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/search.dart';
|
|
|
|
|
import 'package:oc_front/models/shared.dart';
|
|
|
|
|
import 'package:oc_front/models/workflow.dart';
|
|
|
|
|
import 'package:oc_front/pages/abstract_page.dart';
|
|
|
|
|
import 'package:oc_front/widgets/catalog.dart';
|
|
|
|
|
import 'package:oc_front/widgets/dialog/shallow_creation.dart';
|
|
|
|
|
@@ -24,7 +28,6 @@ enum CollaborativeAreaType { global, collaborative_area, workspace, workflow, pe
|
|
|
|
|
|
|
|
|
|
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(); }
|
|
|
|
|
@@ -134,14 +137,16 @@ class SharedPageWidgetState extends State<SharedPageWidget> {
|
|
|
|
|
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 {
|
|
|
|
|
load: PermsService.getPerm(Perms.WORKSPACE_SHARE) ? (String val) async {
|
|
|
|
|
await service.addWorkspace(context, CollaborativeAreaLocal.current ?? "", val);
|
|
|
|
|
CollaborativeAreaLocal.init(context, false);
|
|
|
|
|
},
|
|
|
|
|
remove: (String val) async {
|
|
|
|
|
await CollaborativeAreaLocal.init(context, false);
|
|
|
|
|
setState(() {});
|
|
|
|
|
} : null,
|
|
|
|
|
remove: PermsService.getPerm(Perms.WORKSPACE_UNSHARE) ? (String val) async {
|
|
|
|
|
await service.removeWorkspace(context, CollaborativeAreaLocal.current ?? "", val);
|
|
|
|
|
CollaborativeAreaLocal.init(context, false);
|
|
|
|
|
}))
|
|
|
|
|
await CollaborativeAreaLocal.init(context, false);
|
|
|
|
|
setState(() {});
|
|
|
|
|
} : null))
|
|
|
|
|
]));
|
|
|
|
|
}
|
|
|
|
|
if (widget.type == CollaborativeAreaType.workflow) {
|
|
|
|
|
@@ -167,12 +172,16 @@ class SharedPageWidgetState extends State<SharedPageWidget> {
|
|
|
|
|
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 {
|
|
|
|
|
load: PermsService.getPerm(Perms.WORKFLOW_SHARE) ? (String change) async {
|
|
|
|
|
await service.addWorkflow(context, CollaborativeAreaLocal.current ?? "", change);
|
|
|
|
|
},
|
|
|
|
|
remove: (String change) async {
|
|
|
|
|
await CollaborativeAreaLocal.init(context, false);
|
|
|
|
|
setState(() {});
|
|
|
|
|
} : null,
|
|
|
|
|
remove: PermsService.getPerm(Perms.WORKFLOW_UNSHARE) ? (String change) async {
|
|
|
|
|
await service.removeWorkflow(context, CollaborativeAreaLocal.current ?? "", change);
|
|
|
|
|
}))
|
|
|
|
|
await CollaborativeAreaLocal.init(context, false);
|
|
|
|
|
setState(() {});
|
|
|
|
|
} : null))
|
|
|
|
|
]));
|
|
|
|
|
}
|
|
|
|
|
if (widget.type == CollaborativeAreaType.peer) {
|
|
|
|
|
@@ -198,14 +207,19 @@ class SharedPageWidgetState extends State<SharedPageWidget> {
|
|
|
|
|
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 {
|
|
|
|
|
load: PermsService.getPerm(Perms.PEER_SHARE) ? (String change) async {
|
|
|
|
|
await service.addPeer(context, CollaborativeAreaLocal.current ?? "", change);
|
|
|
|
|
},
|
|
|
|
|
remove: (String change) async {
|
|
|
|
|
await CollaborativeAreaLocal.init(context, false);
|
|
|
|
|
setState(() {});
|
|
|
|
|
} : null,
|
|
|
|
|
remove: PermsService.getPerm(Perms.PEER_UNSHARE) ? (String change) async {
|
|
|
|
|
await service.removePeer(context, CollaborativeAreaLocal.current ?? "", change);
|
|
|
|
|
}))
|
|
|
|
|
await CollaborativeAreaLocal.init(context, false);
|
|
|
|
|
setState(() {});
|
|
|
|
|
} : null))
|
|
|
|
|
]));
|
|
|
|
|
}
|
|
|
|
|
print(w);
|
|
|
|
|
return Column( children: [
|
|
|
|
|
Container(
|
|
|
|
|
height: 50,
|
|
|
|
|
@@ -245,15 +259,12 @@ class SharedPageWidgetState extends State<SharedPageWidget> {
|
|
|
|
|
filled: midColor,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
create: PermsService.getPerm(Perms.COLLABORATIVE_AREA_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) async {
|
|
|
|
|
if (e.data != null) {
|
|
|
|
|
CollaborativeAreaLocal.current = e.data!.id;
|
|
|
|
|
}
|
|
|
|
|
CollaborativeAreaLocal.init(context, true);
|
|
|
|
|
|
|
|
|
|
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(() {}));
|
|
|
|
|
await CollaborativeAreaLocal.init(context, true);
|
|
|
|
|
setState(() {});
|
|
|
|
|
}) : null,
|
|
|
|
|
type: CollaborativeAreaType.collaborative_area,
|
|
|
|
|
all: () async => CollaborativeAreaLocal.workspaces.values.map(
|
|
|
|
|
@@ -284,7 +295,8 @@ class SharedPageWidgetState extends State<SharedPageWidget> {
|
|
|
|
|
Container(
|
|
|
|
|
height: getMainHeight(context) - 50,
|
|
|
|
|
width: getMainWidth(context) -50,
|
|
|
|
|
color: widget.type == CollaborativeAreaType.workflow || widget.type == CollaborativeAreaType.peer ? midColor : Colors.white,
|
|
|
|
|
color: widget.type == CollaborativeAreaType.workflow || widget.type == CollaborativeAreaType.peer
|
|
|
|
|
|| widget.type == CollaborativeAreaType.global ? midColor : Colors.white,
|
|
|
|
|
child: SingleChildScrollView( child: w ))
|
|
|
|
|
]
|
|
|
|
|
) ]
|
|
|
|
|
@@ -299,53 +311,265 @@ class WorkspaceSharedPageWidget extends StatefulWidget {
|
|
|
|
|
}
|
|
|
|
|
class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
|
|
|
|
|
|
|
|
|
@override Widget build(BuildContext context) {
|
|
|
|
|
if (CollaborativeAreaLocal.current == null) {
|
|
|
|
|
return Container();
|
|
|
|
|
}
|
|
|
|
|
var space = CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current ?? ""]!;
|
|
|
|
|
List<Widget> getCardWorkspaceItems(Map<String, List<AbstractItem>> data) {
|
|
|
|
|
List<Widget> items = [];
|
|
|
|
|
for (var w1 in data.keys) {
|
|
|
|
|
for (var w in data[w1]!) {
|
|
|
|
|
List<Widget> badges = [];
|
|
|
|
|
List<Widget> bbadges = [];
|
|
|
|
|
badges.add(Container( margin: const EdgeInsets.only(left: 5), padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
|
|
|
|
decoration: BoxDecoration( borderRadius: BorderRadius.circular(4),
|
|
|
|
|
color: isData(w.topic) ? Colors.blue : isComputing(w.topic) ? Colors.green :
|
|
|
|
|
isCompute(w.topic) ? Colors.orange : isStorage(w.topic) ? redColor : Colors.grey ),
|
|
|
|
|
child:Text(w.topic, style: TextStyle( color: Colors.white, fontSize: 11) )));
|
|
|
|
|
bbadges.add(Container( margin: const EdgeInsets.only(left: 5),
|
|
|
|
|
decoration: BoxDecoration( color: Colors.grey, borderRadius: BorderRadius.circular(4) ),
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5), child: Text(w1, style: TextStyle( color: Colors.white, fontSize: 11) )));
|
|
|
|
|
items.add(ShallowItemFlowDataRowWidget(
|
|
|
|
|
color: Colors.grey.shade200,
|
|
|
|
|
item: w, badges: badges, bottomBadges: bbadges,
|
|
|
|
|
icon: Icons.shopping_cart,
|
|
|
|
|
contextWidth: 200
|
|
|
|
|
));
|
|
|
|
|
}}
|
|
|
|
|
return items;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Widget> getCardItems(List<ShallowData> data) {
|
|
|
|
|
List<Widget> items = [];
|
|
|
|
|
List<ShallowData> data = [];
|
|
|
|
|
if (widget.type == CollaborativeAreaType.global) {
|
|
|
|
|
} else if (widget.type == CollaborativeAreaType.workspace) {
|
|
|
|
|
data = space.workspaces;
|
|
|
|
|
} else if (widget.type == CollaborativeAreaType.workflow) {
|
|
|
|
|
data = space.workflows;
|
|
|
|
|
} else if (widget.type == CollaborativeAreaType.peer) {
|
|
|
|
|
data = space.peers;
|
|
|
|
|
}
|
|
|
|
|
var current = CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current];
|
|
|
|
|
for (var w in data) {
|
|
|
|
|
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 == CollaborativeAreaType.workflow || widget.type == CollaborativeAreaType.peer) {
|
|
|
|
|
List<IconData> badges = [];
|
|
|
|
|
if (widget.type == CollaborativeAreaType.peer && w.getID() == current?.creatorID) {
|
|
|
|
|
badges.add(Icons.star);
|
|
|
|
|
}
|
|
|
|
|
items.add(ShallowItemRowWidget(
|
|
|
|
|
item: w, badges: badges,
|
|
|
|
|
edit: widget.type == CollaborativeAreaType.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 == CollaborativeAreaType.peer) {
|
|
|
|
|
await SharedService().removePeer(context, CollaborativeAreaLocal.current ?? "", change);
|
|
|
|
|
} else {
|
|
|
|
|
await SharedService().removePeer(context, CollaborativeAreaLocal.current ?? "", change);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
icon: widget.type == CollaborativeAreaType.workflow ? Icons.work_history_rounded : Icons.person,
|
|
|
|
|
contextWidth: 200)
|
|
|
|
|
List<Widget> badges = [];
|
|
|
|
|
if (widget.type == CollaborativeAreaType.peer && w.getID(
|
|
|
|
|
) == CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current ?? ""]?.rule?.creator) {
|
|
|
|
|
badges.add(Padding( padding: const EdgeInsets.only(left: 5), child: Icon(Icons.star, color: Colors.orange.shade300 )));
|
|
|
|
|
} else if (widget.type == CollaborativeAreaType.workspace) {
|
|
|
|
|
badges.add(Container( margin: const EdgeInsets.only(left: 5), padding: EdgeInsets.all(5), color: Colors.grey.shade200,
|
|
|
|
|
child: Icon(Icons.star, color: Colors.orange.shade300,)));
|
|
|
|
|
}
|
|
|
|
|
items.add(ShallowItemRowWidget(
|
|
|
|
|
color: Colors.grey.shade200,
|
|
|
|
|
item: w, badges: badges,
|
|
|
|
|
delete: w is Peer && PermsService.getPerm(Perms.PEER_UNSHARE) ? (String? change) async {
|
|
|
|
|
await SharedService().removePeer(context, CollaborativeAreaLocal.current ?? "", change ?? "");
|
|
|
|
|
await CollaborativeAreaLocal.init(context, false);
|
|
|
|
|
setState(() {});
|
|
|
|
|
} : (w is Workflow && PermsService.getPerm(Perms.WORKSPACE_UNSHARE)) ? (String? change) async {
|
|
|
|
|
await SharedService().removeWorkflow(context, CollaborativeAreaLocal.current ?? "", change ?? "");
|
|
|
|
|
await CollaborativeAreaLocal.init(context, false);
|
|
|
|
|
setState(() {});
|
|
|
|
|
} : null,
|
|
|
|
|
icon: w is Workflow ? Icons.work_history_rounded : Icons.person,
|
|
|
|
|
contextWidth: 200
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
return items;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override Widget build(BuildContext context) {
|
|
|
|
|
var space = CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current ?? ""];
|
|
|
|
|
if (widget.type == CollaborativeAreaType.global) {
|
|
|
|
|
if (space == null) {
|
|
|
|
|
return Container(
|
|
|
|
|
color: midColor,
|
|
|
|
|
height: getMainHeight(context) - 50,
|
|
|
|
|
width: getMainWidth(context) - 50,
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
padding: const EdgeInsets.all(50)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (items.isEmpty) {
|
|
|
|
|
final DateFormat formatter = DateFormat('dd-MM-yyyy');
|
|
|
|
|
Peer? creator;
|
|
|
|
|
SharedService service = SharedService();
|
|
|
|
|
try { creator = space.peers.firstWhere( (e) => (space.rule?.creator ?? "") == e.id);
|
|
|
|
|
} catch (e) { }
|
|
|
|
|
Map<String, List<AbstractItem>> datas = {};
|
|
|
|
|
for (var w in space.workspaces) {
|
|
|
|
|
datas[w.getName()] =<AbstractItem> [
|
|
|
|
|
...w.computes,
|
|
|
|
|
...w.datas,
|
|
|
|
|
...w.processings,
|
|
|
|
|
...w.storages,
|
|
|
|
|
...w.workflows
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
return Padding( padding: EdgeInsets.all(30),
|
|
|
|
|
child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [
|
|
|
|
|
Row( mainAxisAlignment: MainAxisAlignment.center, children: [
|
|
|
|
|
Text((CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current]?.name ?? "").toUpperCase(),
|
|
|
|
|
style: TextStyle(color: Colors.grey, fontSize: 25, fontWeight: FontWeight.bold), textAlign: TextAlign.center,
|
|
|
|
|
softWrap: true, overflow: TextOverflow.ellipsis,),
|
|
|
|
|
]),
|
|
|
|
|
Container(
|
|
|
|
|
width: getMainWidth(context) - 50,
|
|
|
|
|
margin: EdgeInsets.symmetric(vertical: 20),
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 50),
|
|
|
|
|
child: Text(space.description ?? "",
|
|
|
|
|
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w400, color: Colors.grey))
|
|
|
|
|
), // TODO
|
|
|
|
|
Text("COLLABORATIVE AREA ACCESS RULES", textAlign: TextAlign.start,
|
|
|
|
|
style: TextStyle(color: darkColor, fontSize: 20, fontWeight: FontWeight.bold), overflow: TextOverflow.clip),
|
|
|
|
|
Container(
|
|
|
|
|
width: getMainWidth(context) - 50,
|
|
|
|
|
margin: EdgeInsets.symmetric(vertical: 20),
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 50),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Row(children: [ Text("Share mode : "), Text( space.rule?.shareMode ?? "closed", style: TextStyle( fontWeight: FontWeight.bold ) )],),
|
|
|
|
|
Row(children: [ Text("Created : "), Text( formatter.format(space.rule?.createdAt ?? DateTime.now()), style: TextStyle( fontWeight: FontWeight.bold )) ],),
|
|
|
|
|
creator != null ? Row(children: [ Text("Area master : "), Text( creator.getName(), style: TextStyle( fontWeight: FontWeight.bold ) ) ],)
|
|
|
|
|
: Container(),
|
|
|
|
|
Row(children: [ Text("User count : "), Text( "${space.peers.length}", style: TextStyle( fontWeight: FontWeight.bold )) ],),
|
|
|
|
|
Row(children: [ Text("Users profile : "), Text( space.rule?.exploitedBy ?? "any", style: TextStyle( fontWeight: FontWeight.bold ) ) ],),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
Row( children: [
|
|
|
|
|
Text("COLLABORATIVE AREA PEERS", textAlign: TextAlign.start,
|
|
|
|
|
style: TextStyle(color: darkColor, fontSize: 20, fontWeight: FontWeight.bold), overflow: TextOverflow.clip),
|
|
|
|
|
PermsService.getPerm(Perms.PEER_SHARE) ? Container(
|
|
|
|
|
margin: EdgeInsets.only(left: 20), padding: EdgeInsets.only(left: 15),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
border: Border(left: BorderSide(color: Colors.grey))
|
|
|
|
|
), child:ShallowDropdownInputWidget(
|
|
|
|
|
tooltipLoad: "add peer",
|
|
|
|
|
hint: "add peer",
|
|
|
|
|
iconLoad: Icons.add,
|
|
|
|
|
type: widget.type,
|
|
|
|
|
filled: midColor,
|
|
|
|
|
hintColor: Colors.grey,
|
|
|
|
|
color: Colors.black,
|
|
|
|
|
prefixIcon: Icon(Icons.person, color: Colors.grey),
|
|
|
|
|
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"])).where( (e) => !space.peers.map( (e) => e.id ).contains(e.id)).toList();
|
|
|
|
|
}
|
|
|
|
|
setState(() {});
|
|
|
|
|
});
|
|
|
|
|
return shals;
|
|
|
|
|
},
|
|
|
|
|
width: getMainWidth(context) / 3,
|
|
|
|
|
canLoad: (String? change) => !space.peers.map( (e) => e.id ).contains(change),
|
|
|
|
|
load: (String val) async {
|
|
|
|
|
await service.addPeer(context, CollaborativeAreaLocal.current ?? "", val);
|
|
|
|
|
await CollaborativeAreaLocal.init(context, false);
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
) ) : Container()]),
|
|
|
|
|
Container(
|
|
|
|
|
width: getMainWidth(context) - 50,
|
|
|
|
|
margin: EdgeInsets.symmetric(vertical: 20),
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 50),
|
|
|
|
|
child: Wrap( alignment: WrapAlignment.center, children: getCardItems(space.peers)),
|
|
|
|
|
),
|
|
|
|
|
Row( children: [
|
|
|
|
|
Text("WORKSPACES / RESOURCES", textAlign: TextAlign.start,
|
|
|
|
|
style: TextStyle(color: darkColor, fontSize: 20, fontWeight: FontWeight.bold), overflow: TextOverflow.clip),
|
|
|
|
|
PermsService.getPerm(Perms.WORKSPACE_SHARE) ? Container(
|
|
|
|
|
margin: EdgeInsets.only(left: 20), padding: EdgeInsets.only(left: 15),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
border: Border(left: BorderSide(color: Colors.grey))
|
|
|
|
|
), child: ShallowDropdownInputWidget(
|
|
|
|
|
tooltipLoad: "add workspace",
|
|
|
|
|
hint: "add workspace",
|
|
|
|
|
iconLoad: Icons.add,
|
|
|
|
|
type: widget.type,
|
|
|
|
|
filled: midColor,
|
|
|
|
|
hintColor: Colors.grey,
|
|
|
|
|
color: Colors.black,
|
|
|
|
|
prefixIcon: Icon(Icons.shopping_cart, color: Colors.grey),
|
|
|
|
|
all: () async => WorkspaceLocal.getWorkspacesShallow().where( (e) => !space.workspaces.map( (e) => e.id ).contains(e.id)).toList(),
|
|
|
|
|
width: getMainWidth(context) / 3,
|
|
|
|
|
canLoad: (String? change) => !space.workspaces.map( (e) => e.id ).contains(change),
|
|
|
|
|
load: (String val) async {
|
|
|
|
|
await service.addWorkspace(context, CollaborativeAreaLocal.current ?? "", val);
|
|
|
|
|
await CollaborativeAreaLocal.init(context, false);
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
)) : Container() ]),
|
|
|
|
|
Container(
|
|
|
|
|
width: getMainWidth(context) - 50,
|
|
|
|
|
margin: EdgeInsets.symmetric(vertical: 20),
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 50),
|
|
|
|
|
child: Wrap( alignment: WrapAlignment.center, children: getCardWorkspaceItems(datas))
|
|
|
|
|
),
|
|
|
|
|
Row( children: [
|
|
|
|
|
Text("WORKFLOWS", textAlign: TextAlign.start,
|
|
|
|
|
style: TextStyle(color: darkColor, fontSize: 20, fontWeight: FontWeight.bold), overflow: TextOverflow.clip),
|
|
|
|
|
PermsService.getPerm(Perms.WORKFLOW_SHARE) ? Container(
|
|
|
|
|
margin: EdgeInsets.only(left: 20), padding: EdgeInsets.only(left: 15),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
border: Border(left: BorderSide(color: Colors.grey))
|
|
|
|
|
), child:ShallowDropdownInputWidget(
|
|
|
|
|
tooltipLoad: "add workflow",
|
|
|
|
|
hint: "add workflow",
|
|
|
|
|
iconLoad: Icons.add,
|
|
|
|
|
type: widget.type,
|
|
|
|
|
filled: midColor,
|
|
|
|
|
hintColor: Colors.grey,
|
|
|
|
|
color: Colors.black,
|
|
|
|
|
prefixIcon: Icon(Icons.rebase_edit, color: Colors.grey),
|
|
|
|
|
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"])).where( (e) => !space.workflows.map( (e) => e.id ).contains(e.id)).toList();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return shals;
|
|
|
|
|
},
|
|
|
|
|
width: getMainWidth(context) / 3,
|
|
|
|
|
canLoad: (String? change) => !space.workflows.map( (e) => e.id ).contains(change),
|
|
|
|
|
load: (String val) async {
|
|
|
|
|
await service.addWorkflow(context, CollaborativeAreaLocal.current ?? "", val);
|
|
|
|
|
await CollaborativeAreaLocal.init(context, false);
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
)) : Container()]),
|
|
|
|
|
Container(
|
|
|
|
|
width: getMainWidth(context) - 50,
|
|
|
|
|
margin: EdgeInsets.symmetric(vertical: 20),
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 50),
|
|
|
|
|
child: Wrap( alignment: WrapAlignment.center, children: getCardItems(space.workflows))
|
|
|
|
|
),
|
|
|
|
|
],)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if (CollaborativeAreaLocal.current == null) {
|
|
|
|
|
return Container(
|
|
|
|
|
color: midColor,
|
|
|
|
|
height: getMainHeight(context) - 50,
|
|
|
|
|
width: getMainWidth(context) - 50,
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
padding: const EdgeInsets.all(50)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
List<Widget> items = [];
|
|
|
|
|
List<ShallowData> data = [];
|
|
|
|
|
if (widget.type == CollaborativeAreaType.workspace) {
|
|
|
|
|
data = space?.workspaces ?? [];
|
|
|
|
|
} else if (widget.type == CollaborativeAreaType.workflow) {
|
|
|
|
|
data = space?.workflows ?? [];
|
|
|
|
|
} else if (widget.type == CollaborativeAreaType.peer) {
|
|
|
|
|
data = space?.peers ?? [];
|
|
|
|
|
}
|
|
|
|
|
if (widget.type == CollaborativeAreaType.workspace) {
|
|
|
|
|
for (var w in data) {
|
|
|
|
|
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 {
|
|
|
|
|
items = getCardItems(data);
|
|
|
|
|
}
|
|
|
|
|
if (items.isEmpty) {
|
|
|
|
|
return Container(
|
|
|
|
|
color: midColor,
|
|
|
|
|
height: getMainHeight(context) - 50,
|
|
|
|
|
@@ -377,18 +601,18 @@ class WorkspaceSharedItemPageWidgetState extends State<WorkspaceSharedItemPageWi
|
|
|
|
|
width: getMainWidth(context) - 50,
|
|
|
|
|
height: 50,
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
|
|
|
decoration: BoxDecoration(color: midColor),
|
|
|
|
|
decoration: BoxDecoration(color: midColor, border: Border(bottom: BorderSide(color: Colors.white))),
|
|
|
|
|
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)),
|
|
|
|
|
const Padding(padding: EdgeInsets.only(right: 20), child: Icon(Icons.shopping_cart_outlined, size: 18, color: Colors.grey)),
|
|
|
|
|
Text(widget.name,
|
|
|
|
|
style: const TextStyle(fontSize: 15, color: Colors.white, fontWeight: FontWeight.w600)),
|
|
|
|
|
style: const TextStyle(fontSize: 15, color: Colors.grey, 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),
|
|
|
|
|
Positioned( right: 0, top: 5, child: IconButton( icon: Icon(widget.open ? Icons.arrow_drop_up : Icons.arrow_drop_down, color: Colors.grey),
|
|
|
|
|
onPressed: () => setState(() {
|
|
|
|
|
widget.open = !widget.open;
|
|
|
|
|
})))
|
|
|
|
|
|