Major Change Inputs & Co
This commit is contained in:
@@ -1,33 +1,32 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
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/models/shared.dart';
|
||||
import 'package:oc_front/models/workflow.dart';
|
||||
import 'package:oc_front/widgets/catalog.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/pages/abstract_page.dart';
|
||||
import 'package:oc_front/models/resources/resources.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/widgets/items/shallow_item_row.dart';
|
||||
import 'package:oc_front/widgets/dialog/shallow_creation.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_text_input.dart';
|
||||
import 'package:oc_front/core/models/shared_workspace_local.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_dropdown_input.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/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';
|
||||
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 CollaborativeAreaType { global, collaborative_area, workspace, workflow, peer, resource }
|
||||
|
||||
class SharedFactory implements AbstractFactory {
|
||||
@override GlobalKey getKey() { return key; }
|
||||
@override String? getSearch() { return ""; }
|
||||
@override void back(BuildContext context) { }
|
||||
static GlobalKey<SharedPageWidgetState> key = GlobalKey<SharedPageWidgetState>();
|
||||
@override bool searchFill() { return false; }
|
||||
@override Widget factory(GoRouterState state, List<String> args) { return SharedPageWidget(); }
|
||||
@@ -36,6 +35,7 @@ class SharedFactory implements AbstractFactory {
|
||||
|
||||
class SharedPageWidget extends StatefulWidget {
|
||||
CollaborativeAreaType type = CollaborativeAreaType.global;
|
||||
bool showDialog = false;
|
||||
SharedPageWidget(): super(key: SharedFactory.key);
|
||||
@override SharedPageWidgetState createState() => SharedPageWidgetState();
|
||||
static void search(BuildContext context) { }
|
||||
@@ -56,7 +56,6 @@ class SharedPageWidgetState extends State<SharedPageWidget> {
|
||||
child : Icon(icon,
|
||||
color: widget.type == workspaceType ? Colors.white : Colors.white, size: 20))));
|
||||
}
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
GlobalKey<ShallowTextInputWidgetState> key = GlobalKey<ShallowTextInputWidgetState>();
|
||||
if (CollaborativeAreaLocal.current == null) {
|
||||
@@ -64,52 +63,59 @@ class SharedPageWidgetState extends State<SharedPageWidget> {
|
||||
HeaderConstants.setTitle("Choose a Collaborative Area");
|
||||
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: () => CollaborativeAreaLocal.current != null,
|
||||
context: context,
|
||||
load: (p0) async {
|
||||
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: CollaborativeAreaType.collaborative_area,
|
||||
width: getMainWidth(context) <= 540 ? getMainWidth(context) - 140 : 400,
|
||||
attr: "description",
|
||||
color: Colors.black,
|
||||
hintColor: Colors.grey,
|
||||
hint: "enter collaborative area description...",
|
||||
filled: midColor,
|
||||
)
|
||||
],
|
||||
create: PermsService.getPerm(Perms.COLLABORATIVE_AREA_CREATE) ? (p0) async => await SharedService().post(context, p0, {}).then((value) {
|
||||
if (value.data != null) {
|
||||
CollaborativeAreaLocal.current = value.data!.id;
|
||||
}
|
||||
CollaborativeAreaLocal.init(context, true);
|
||||
if (!widget.showDialog) {
|
||||
Future.delayed( const Duration(milliseconds: 100), () {
|
||||
widget.showDialog = true;
|
||||
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: () => CollaborativeAreaLocal.current != null,
|
||||
context: context,
|
||||
load: (p0) async {
|
||||
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(() { widget.showDialog = false; }));
|
||||
},
|
||||
form: [
|
||||
ShallowTextInputWidget(
|
||||
change :(p0) => key.currentState?.setState(() {}),
|
||||
canLoad: (po) => po != null && po.isNotEmpty,
|
||||
type: CollaborativeAreaType.collaborative_area,
|
||||
width: getMainWidth(context) <= 540 ? getMainWidth(context) - 140 : 400,
|
||||
attr: "description",
|
||||
color: Colors.black,
|
||||
hintColor: Colors.grey,
|
||||
hint: "enter collaborative area description...",
|
||||
filled: midColor,
|
||||
)
|
||||
],
|
||||
create: PermsService.getPerm(Perms.COLLABORATIVE_AREA_CREATE) ? (p0) async => await SharedService().post(context, p0, {}).then((value) {
|
||||
if (value.data != null) {
|
||||
CollaborativeAreaLocal.current = value.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(() {}));
|
||||
}) : null,
|
||||
type: CollaborativeAreaType.collaborative_area,
|
||||
all: () async => CollaborativeAreaLocal.workspaces.values.map(
|
||||
(e) => Shallow(id: e.id ?? "", name: e.name ?? "") ).toList(),
|
||||
)));
|
||||
});
|
||||
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(() { widget.showDialog = false; }));
|
||||
}) : null,
|
||||
type: CollaborativeAreaType.collaborative_area,
|
||||
all: () async {
|
||||
await CollaborativeAreaLocal.init(context, true);
|
||||
return CollaborativeAreaLocal.workspaces.values.map(
|
||||
(e) => Shallow(id: e.id ?? "", name: e.name ?? "") ).toList();
|
||||
}
|
||||
)));
|
||||
});
|
||||
}
|
||||
} else {
|
||||
Future.delayed( const Duration(milliseconds: 100), () {
|
||||
HeaderConstants.setTitle("Collaborative Area <${CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current]?.name ?? ""}>");
|
||||
@@ -119,107 +125,7 @@ class SharedPageWidgetState extends State<SharedPageWidget> {
|
||||
Widget w = WorkspaceSharedPageWidget(type: widget.type);
|
||||
List<Widget> addMenu = [];
|
||||
CollaborativeArea? current = CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current ?? ""];
|
||||
if (widget.type == CollaborativeAreaType.workspace) {
|
||||
addMenu.add( Row( mainAxisAlignment: MainAxisAlignment.end,
|
||||
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: 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: PermsService.getPerm(Perms.WORKSPACE_SHARE) ? (String val) async {
|
||||
await service.addWorkspace(context, CollaborativeAreaLocal.current ?? "", val);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
setState(() {});
|
||||
} : null,
|
||||
remove: PermsService.getPerm(Perms.WORKSPACE_UNSHARE) ? (String val) async {
|
||||
await service.removeWorkspace(context, CollaborativeAreaLocal.current ?? "", val);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
setState(() {});
|
||||
} : null))
|
||||
]));
|
||||
}
|
||||
if (widget.type == CollaborativeAreaType.workflow) {
|
||||
addMenu.add( Row( mainAxisAlignment: MainAxisAlignment.end,
|
||||
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) {
|
||||
if (value.data != null) {
|
||||
shals = value.data!.values.map((e) => Shallow(id: e["id"], name: e["name"])).toList();
|
||||
}
|
||||
});
|
||||
return shals;
|
||||
},
|
||||
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: PermsService.getPerm(Perms.WORKFLOW_SHARE) ? (String change) async {
|
||||
await service.addWorkflow(context, CollaborativeAreaLocal.current ?? "", change);
|
||||
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) {
|
||||
addMenu.add( Row( mainAxisAlignment: MainAxisAlignment.end,
|
||||
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) {
|
||||
if (value.data != null) {
|
||||
shals = value.data!.values.map((e) => Shallow(id: e["id"], name: e["name"])).toList();
|
||||
}
|
||||
});
|
||||
return shals;
|
||||
},
|
||||
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: PermsService.getPerm(Perms.PEER_SHARE) ? (String change) async {
|
||||
await service.addPeer(context, CollaborativeAreaLocal.current ?? "", change);
|
||||
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);
|
||||
addMenu.add(getDropdown(widget.type, current, this, context, false));
|
||||
return Column( children: [
|
||||
Container(
|
||||
height: 50,
|
||||
@@ -318,9 +224,10 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
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 ),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
color: getColor(w.topic)
|
||||
),
|
||||
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) ),
|
||||
@@ -337,10 +244,16 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
|
||||
List<Widget> getCardItems(List<ShallowData> data) {
|
||||
List<Widget> items = [];
|
||||
for (var w in data) {
|
||||
List<ShallowData> neoData = [];
|
||||
for (var d in data) {
|
||||
try { neoData.firstWhere( (e) => e.getID() == d.getID());
|
||||
} catch (e) { neoData.add(d); }
|
||||
}
|
||||
for (var w in neoData) {
|
||||
List<Widget> badges = [];
|
||||
if (w is Peer && w.getID(
|
||||
) == CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current ?? ""]?.rule?.creator) {
|
||||
if (w is Peer && (
|
||||
w.getID() != CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current ?? ""]?.rule?.creator
|
||||
|| w.getID() != CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current ?? ""]?.creatorID)) {
|
||||
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,
|
||||
@@ -349,11 +262,13 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
items.add(ShallowItemRowWidget(
|
||||
color: Colors.grey.shade200,
|
||||
item: w, badges: badges,
|
||||
delete: w is Peer && PermsService.getPerm(Perms.PEER_UNSHARE) && w.getID() != CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current ?? ""]?.rule?.creator ? (String? change) async {
|
||||
delete: w is Peer ? (PermsService.getPerm(Perms.PEER_UNSHARE) && (
|
||||
w.getID() != CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current ?? ""]?.rule?.creator
|
||||
&& w.getID() != CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current ?? ""]?.creatorID) ? (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 {
|
||||
} : null) : (w is Workflow && PermsService.getPerm(Perms.WORKSPACE_UNSHARE)) ? (String? change) async {
|
||||
await SharedService().removeWorkflow(context, CollaborativeAreaLocal.current ?? "", change ?? "");
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
setState(() {});
|
||||
@@ -381,7 +296,7 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
Peer? creator;
|
||||
SharedService service = SharedService();
|
||||
try { creator = space.peers.firstWhere( (e) => (space.rule?.creator ?? "") == e.id);
|
||||
} catch (e) { }
|
||||
} catch (e) { /**/ }
|
||||
Map<String, List<AbstractItem>> datas = {};
|
||||
for (var w in space.workspaces) {
|
||||
datas[w.getName()] =<AbstractItem> [
|
||||
@@ -406,9 +321,9 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
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),
|
||||
),
|
||||
Padding( padding: EdgeInsets.only(left: 30), child: 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),
|
||||
@@ -427,39 +342,14 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
),
|
||||
|
||||
Row( children: [
|
||||
Text("COLLABORATIVE AREA PEERS", textAlign: TextAlign.start,
|
||||
style: TextStyle(color: darkColor, fontSize: 20, fontWeight: FontWeight.bold), overflow: TextOverflow.clip),
|
||||
Padding( padding: EdgeInsets.only(left: 30), child: 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) => true,
|
||||
load: (String val) async {
|
||||
await service.addPeer(context, CollaborativeAreaLocal.current ?? "", val);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
setState(() {});
|
||||
},
|
||||
) ) : Container()]),
|
||||
), child: getDropdown(CollaborativeAreaType.peer, CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current], this, context, true)
|
||||
) : Container()]),
|
||||
Container(
|
||||
width: getMainWidth(context) - 50,
|
||||
margin: EdgeInsets.symmetric(vertical: 20),
|
||||
@@ -467,8 +357,8 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 50),
|
||||
child: Wrap( alignment: WrapAlignment.center, children: getCardItems(space.peers)),
|
||||
),
|
||||
space.rules.isNotEmpty ? Text("RULES", textAlign: TextAlign.start,
|
||||
style: TextStyle(color: darkColor, fontSize: 20, fontWeight: FontWeight.bold), overflow: TextOverflow.clip) : Container(),
|
||||
space.rules.isNotEmpty ? Padding( padding: EdgeInsets.only(left: 30), child: Text("RULES", textAlign: TextAlign.start,
|
||||
style: TextStyle(color: darkColor, fontSize: 20, fontWeight: FontWeight.bold), overflow: TextOverflow.clip)) : Container(),
|
||||
space.rules.isNotEmpty ? Container(
|
||||
width: getMainWidth(context) - 50,
|
||||
margin: EdgeInsets.symmetric(vertical: 20),
|
||||
@@ -483,30 +373,13 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
}).toList() )
|
||||
) : Container(),
|
||||
Row( children: [
|
||||
Text("WORKSPACES / RESOURCES", textAlign: TextAlign.start,
|
||||
style: TextStyle(color: darkColor, fontSize: 20, fontWeight: FontWeight.bold), overflow: TextOverflow.clip),
|
||||
Padding( padding: EdgeInsets.only(left: 30), child: 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) => true,
|
||||
load: (String val) async {
|
||||
await service.addWorkspace(context, CollaborativeAreaLocal.current ?? "", val);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
setState(() {});
|
||||
},
|
||||
)) : Container() ]),
|
||||
), child: getDropdown(CollaborativeAreaType.workspace, CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current], this, context, true)) : Container() ]),
|
||||
Container(
|
||||
width: getMainWidth(context) - 50,
|
||||
margin: EdgeInsets.symmetric(vertical: 20),
|
||||
@@ -515,38 +388,13 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
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),
|
||||
Padding( padding: EdgeInsets.only(left: 30), child: 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) => true,
|
||||
load: (String val) async {
|
||||
await service.addWorkflow(context, CollaborativeAreaLocal.current ?? "", val);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
setState(() {});
|
||||
},
|
||||
)) : Container()]),
|
||||
), child: getDropdown(CollaborativeAreaType.workflow, CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current], this, context, true)) : Container()]),
|
||||
Container(
|
||||
width: getMainWidth(context) - 50,
|
||||
margin: EdgeInsets.symmetric(vertical: 20),
|
||||
@@ -557,6 +405,7 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
],)
|
||||
);
|
||||
}
|
||||
|
||||
if (CollaborativeAreaLocal.current == null) {
|
||||
return Container(
|
||||
color: midColor,
|
||||
@@ -576,11 +425,14 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
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()));
|
||||
}
|
||||
List<ShallowData> neoData = [];
|
||||
for (var d in data) {
|
||||
try { neoData.firstWhere( (e) => e.getID() == d.getID());
|
||||
} catch (e) { neoData.add(d); }
|
||||
}
|
||||
for (var w in neoData) {
|
||||
if (WorkspaceLocal.workspaces[w.getID()] == null) { continue; }
|
||||
items.add(WorkspaceSharedItemPageWidget(name: "Workspace <${WorkspaceLocal.workspaces[w.getID()]!.name}>", id: w.getID()));
|
||||
}
|
||||
} else {
|
||||
items = getCardItems(data);
|
||||
@@ -603,6 +455,7 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class WorkspaceSharedItemPageWidget extends StatefulWidget {
|
||||
bool open = true;
|
||||
String id = "";
|
||||
@@ -638,4 +491,130 @@ class WorkspaceSharedItemPageWidgetState extends State<WorkspaceSharedItemPageWi
|
||||
items: WorkspaceLocal.byWorkspace(widget.id)) : Container()
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Widget getDropdown(CollaborativeAreaType type, CollaborativeArea? current, State<dynamic> state, BuildContext context, bool mainPage ) {
|
||||
if (type == CollaborativeAreaType.workspace) {
|
||||
return Row( mainAxisAlignment: MainAxisAlignment.end,
|
||||
children : [ Container( padding: EdgeInsets.only(left: mainPage ? 0 : 20), decoration: BoxDecoration(
|
||||
border: mainPage ? null : Border(left: BorderSide(color: Colors.white))
|
||||
), child: ShallowDropdownInputWidget(
|
||||
tooltipLoad: "share",
|
||||
tooltipRemove: "unshare",
|
||||
iconLoad: Icons.share,
|
||||
type: type,
|
||||
filled: mainPage ? Colors.white : lightColor,
|
||||
hintColor: mainPage ? Colors.grey : midColor,
|
||||
color: mainPage ? Colors.black : Colors.white,
|
||||
prefixIcon: Icon(Icons.shopping_cart, color: Colors.white),
|
||||
current: WorkspaceLocal.current,
|
||||
all: () async => WorkspaceLocal.getWorkspacesShallow(),
|
||||
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: PermsService.getPerm(Perms.WORKSPACE_SHARE) ? (String val) async {
|
||||
await SharedService().addWorkspace(context, CollaborativeAreaLocal.current ?? "", val);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
state.setState(() {});
|
||||
if (mainPage) {
|
||||
SharedFactory.key.currentState?.setState(() {});
|
||||
}
|
||||
} : null,
|
||||
remove: PermsService.getPerm(Perms.WORKSPACE_UNSHARE) ? (String val) async {
|
||||
await SharedService().removeWorkspace(context, CollaborativeAreaLocal.current ?? "", val);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
state.setState(() {});
|
||||
if (mainPage) {
|
||||
SharedFactory.key.currentState?.setState(() {});
|
||||
}
|
||||
} : null))
|
||||
]);
|
||||
}
|
||||
if (type == CollaborativeAreaType.workflow) {
|
||||
return Row( mainAxisAlignment: MainAxisAlignment.end,
|
||||
children : [ Container( padding: EdgeInsets.only(left: mainPage ? 0 : 20), decoration: BoxDecoration(
|
||||
border: mainPage ? null : Border(left: BorderSide(color: Colors.white))
|
||||
), child: ShallowDropdownInputWidget(
|
||||
tooltipLoad: "share",
|
||||
tooltipRemove: "unshare",
|
||||
iconLoad: Icons.share,
|
||||
filled: mainPage ? Colors.white : lightColor,
|
||||
hintColor: mainPage ? Colors.grey : midColor,
|
||||
color: mainPage ? Colors.black : Colors.white,
|
||||
type: 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: 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: PermsService.getPerm(Perms.WORKFLOW_SHARE) ? (String change) async {
|
||||
await SharedService().addWorkflow(context, CollaborativeAreaLocal.current ?? "", change);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
state.setState(() {});
|
||||
if (mainPage) {
|
||||
SharedFactory.key.currentState?.setState(() {});
|
||||
}
|
||||
} : null,
|
||||
remove: PermsService.getPerm(Perms.WORKFLOW_UNSHARE) ? (String change) async {
|
||||
await SharedService().removeWorkflow(context, CollaborativeAreaLocal.current ?? "", change);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
state.setState(() {});
|
||||
if (mainPage) {
|
||||
SharedFactory.key.currentState?.setState(() {});
|
||||
}
|
||||
} : null))
|
||||
]);
|
||||
}
|
||||
if (type == CollaborativeAreaType.peer) {
|
||||
return Row( mainAxisAlignment: MainAxisAlignment.end,
|
||||
children : [
|
||||
Container( padding: EdgeInsets.only(left: mainPage ? 0 : 20), decoration: BoxDecoration(
|
||||
border: mainPage ? null : Border(left: BorderSide(color : Colors.white))
|
||||
), child: ShallowDropdownInputWidget(
|
||||
tooltipLoad: "add",
|
||||
iconLoad: Icons.add,
|
||||
filled: mainPage ? Colors.white : lightColor,
|
||||
hintColor: mainPage ? Colors.grey : midColor,
|
||||
color: mainPage ? Colors.black : Colors.white,
|
||||
type: type, all: () async {
|
||||
List<Shallow> shals = [];
|
||||
await PeerService().all(context).then((value) {
|
||||
if (value.data != null) {
|
||||
shals = value.data!.values.where( (e) {
|
||||
print("e: $e ${e["id"]} ${current?.creatorID}");
|
||||
return e["id"] != current?.creatorID;
|
||||
}
|
||||
).map((e) => Shallow(id: e["id"], name: e["name"])).toList();
|
||||
}
|
||||
});
|
||||
return shals;
|
||||
},
|
||||
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: PermsService.getPerm(Perms.PEER_SHARE) ? (String change) async {
|
||||
await SharedService().addPeer(context, CollaborativeAreaLocal.current ?? "", change);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
state.setState(() {});
|
||||
if (mainPage) {
|
||||
SharedFactory.key.currentState?.setState(() {});
|
||||
}
|
||||
} : null,
|
||||
remove: PermsService.getPerm(Perms.PEER_UNSHARE) ? (String change) async {
|
||||
await SharedService().removePeer(context, CollaborativeAreaLocal.current ?? "", change);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
state.setState(() {});
|
||||
if (mainPage) {
|
||||
SharedFactory.key.currentState?.setState(() {});
|
||||
}
|
||||
} : null))
|
||||
]);
|
||||
}
|
||||
return Container();
|
||||
}
|
||||
Reference in New Issue
Block a user