Latest Front with debug

This commit is contained in:
mr
2024-08-30 12:52:32 +02:00
parent 8beddba367
commit 0b294a782c
42 changed files with 1367 additions and 925 deletions

View File

@@ -17,7 +17,10 @@ class LoginWidgetState extends State<LoginWidget> {
child: Icon(Icons.person_search, size: 80, color: Colors.grey,))),
const Center(child: Text("WELCOME ON OPENCLOUD", style: TextStyle(fontSize: 25, fontWeight: FontWeight.w600,
color: Color.fromRGBO(38, 166, 154, 1)),)),
Padding(padding: const EdgeInsets.symmetric(vertical: 20), child: Divider(color: Colors.grey.shade300,),),
Container(
padding: const EdgeInsets.symmetric(vertical: 20),
decoration: BoxDecoration(border: Border(bottom: BorderSide(color: Colors.black))),
),
Container( margin: const EdgeInsets.only(bottom: 10), child: Center(child: Row( mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(

View File

@@ -1,207 +0,0 @@
import 'package:flutter/material.dart';
import 'package:oc_front/models/response.dart';
import 'package:oc_front/core/services/router.dart';
import 'package:oc_front/core/services/specialized_services/shared_service.dart';
class NewBoxSharedWidget extends StatefulWidget {
String? _selected;
SharedService service = SharedService();
final TextEditingController _ctrl = TextEditingController();
final TextEditingController _ctrlDescr = TextEditingController();
NewBoxSharedWidget ({ super.key, });
@override NewBoxSharedWidgetState createState() => NewBoxSharedWidgetState();
}
class NewBoxSharedWidgetState extends State<NewBoxSharedWidget> {
GlobalKey<FormFieldState> key = GlobalKey<FormFieldState>();
GlobalKey<FormFieldState> key2 = GlobalKey<FormFieldState>();
@override Widget build(BuildContext context) {
return Container(
color: Colors.white,
padding: const EdgeInsets.only( top: 0, bottom: 20, left: 20, right: 20),
child: Column(
children: [
Container(
alignment: Alignment.centerRight,
height: 50,
child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [
const Padding(padding: EdgeInsets.symmetric(horizontal: 10), child:
Text("load or create a new shared workspace", style: TextStyle(color: Colors.grey, fontSize: 15)
)),
Padding ( padding: const EdgeInsets.symmetric(horizontal: 10), child:
Tooltip( message: "back", child: InkWell(
mouseCursor: SystemMouseCursors.click,
onTap: () {
AppRouter.catalog.go(context, {});
},
child: const Icon(Icons.arrow_back, color: Colors.black))),
),
Row ( mainAxisAlignment: MainAxisAlignment.end, children: [
Tooltip( message: "close", child: InkWell(
mouseCursor: SystemMouseCursors.click,
onTap: () { Navigator.pop(context); },
child: const Icon(Icons.close, color: Colors.black))),
]),
],),
),
FutureBuilder<APIResponse<RawData>>(
future: widget.service.all(context),
builder: (context, snapshot) {
List<DropdownMenuItem> items = [];
if (snapshot.data != null && snapshot.data!.data != null) {
for (var item in snapshot.data!.data!.values) {
items.add(DropdownMenuItem<String>(
value: item["id"].toString(),
child: Text(item["name"].toString()),
));
}
}
if (widget._selected != null
&& !items.where((element) => element.value == widget._selected).isNotEmpty) {
items.add(DropdownMenuItem<String>(
value: widget._selected.toString(),
child: Text(widget._selected.toString()),
));
}
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children : [
SizedBox( width: MediaQuery.of(context).size.width <= 540 ? MediaQuery.of(context).size.width - 140 : 400, height: 50,
child: DropdownButtonFormField(
value: widget._selected,
isExpanded: true,
hint: const Text("load shared workspace...", style: TextStyle(color: Colors.grey, fontSize: 15)),
decoration: InputDecoration(
filled: true,
focusedBorder: const OutlineInputBorder( borderRadius: BorderRadius.zero,
borderSide: BorderSide(color: Color.fromARGB(38, 166, 154, 1), width: 0),
),
fillColor: Colors.grey.shade300,
contentPadding: const EdgeInsets.only(left: 30, right: 30, top: 10, bottom: 30),
enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.zero,
borderSide: BorderSide(color: Colors.grey.shade300, width: 0),
),
border: OutlineInputBorder( borderRadius: BorderRadius.zero,
borderSide: BorderSide(color: Colors.grey.shade300, width: 0)),
),
items: items,
onChanged: (value) {
setState(() {
widget._selected = value.toString();
});
})),
Tooltip(
message: 'empty selection',
child: InkWell(
mouseCursor: widget._selected == null || widget._selected!.isEmpty ? MouseCursor.defer : SystemMouseCursors.click,
onTap: () {
if (widget._selected == null || widget._selected!.isEmpty) { return; }
setState(() { widget._selected = null; });
},
child: Container(
width: 50, height: 50,
decoration: const BoxDecoration( color: Colors.black,
border: Border(right: BorderSide(color: Colors.white))),
child: Icon(Icons.refresh, color: widget._selected == null || widget._selected!.isEmpty ? Colors.grey : Colors.white),
)
)
),
Tooltip(
message: 'load shared workspace selected',
child: InkWell(
mouseCursor: widget._selected == null || widget._selected!.isEmpty
? MouseCursor.defer : SystemMouseCursors.click,
onTap: () async {
},
child: Container(
width: 50, height: 50,
color: Colors.black,
child: Icon(Icons.open_in_browser_outlined,
color: widget._selected == null || widget._selected!.isEmpty ? Colors.grey : Colors.white),
)
)
)
]);}),
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
margin: const EdgeInsets.only(top: 10),
width: MediaQuery.of(context).size.width <= 540 ? MediaQuery.of(context).size.width - 90 : 450,
height: 50,
child: TextFormField( key: key,
expands: true,
maxLines: null,
minLines: null,
cursorColor: const Color.fromARGB(38, 166, 154, 1),
controller: widget._ctrl,
onChanged: (value) { widget._ctrl.text = value; },
validator: (value) => value == null || value.isEmpty ? "name is required" : null,
decoration: InputDecoration(
hintText: "name a new shared workspace...",
fillColor: Colors.grey.shade300,
filled: true,
errorStyle: const TextStyle(fontSize: 0),
contentPadding: const EdgeInsets.only(left: 30, right: 30, top: 15, bottom: 5),
hintStyle: const TextStyle(
color: Colors.black,
fontSize: 14,
fontWeight: FontWeight.w300
),
border: InputBorder.none
)
)
),
Tooltip(
message: 'add',
child:InkWell(
mouseCursor: widget._ctrl.value.text.isEmpty ? MouseCursor.defer : SystemMouseCursors.click,
onTap: () async {
if (key.currentState!.validate() && key2.currentState!.validate()) {
await widget.service.post(context, {
"name" :widget._ctrl.value.text,
"description" : widget._ctrlDescr.value.text }, {});
}
},
child: Container(
margin: const EdgeInsets.only(top: 10),
width: 50,
height: 50,
color: Colors.black,
child: Icon(Icons.add, color: widget._ctrl.value.text.isEmpty ? Colors.grey : Colors.white)
)
)
)
]),
Container(
margin: const EdgeInsets.only(top: 10),
width: MediaQuery.of(context).size.width <= 540 ? MediaQuery.of(context).size.width - 40 : 500,
height: 50,
child: TextFormField( key: key2,
expands: true,
maxLines: null,
minLines: null,
cursorColor: const Color.fromARGB(38, 166, 154, 1),
controller: widget._ctrlDescr,
onChanged: (value) { widget._ctrlDescr.text = value; },
validator: (value) => value == null || value.isEmpty ? "name is required" : null,
decoration: InputDecoration(
hintText: "description of a new shared workspace...",
fillColor: Colors.grey.shade300,
filled: true,
errorStyle: const TextStyle(fontSize: 0),
contentPadding: const EdgeInsets.only(left: 30, right: 30, top: 15, bottom: 5),
hintStyle: const TextStyle(
color: Colors.black,
fontSize: 14,
fontWeight: FontWeight.w300
),
border: InputBorder.none
)
)
),
]
)
);
}
}

View File

@@ -1,199 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
import 'package:oc_front/core/models/workspace_local.dart';
import 'package:oc_front/core/services/router.dart';
import 'package:oc_front/core/services/specialized_services/abstract_service.dart';
import 'package:oc_front/models/abstract.dart';
import 'package:oc_front/models/response.dart';
abstract class New {
String name = "";
}
class NewBoxWidget<T extends SerializerDeserializer<dynamic>> extends StatefulWidget {
String? _selected;
Dashboard dash;
final TextEditingController _ctrl = TextEditingController();
AbstractService<T> service;
Function validate = () {};
NewBoxWidget ({ super.key, required this.service, required this.dash, this.getItems });
@override NewBoxWidgetState<T> createState() => NewBoxWidgetState<T>();
List<DropdownMenuItem> Function(APIResponse<T>? data)? getItems;
}
class NewBoxWidgetState<T extends SerializerDeserializer<dynamic>> extends State<NewBoxWidget> {
@override Widget build(BuildContext context) {
widget._ctrl.value = TextEditingValue(text: widget.dash.defaultName);
return Container(
color: Colors.white,
padding: const EdgeInsets.only( top: 0, bottom: 20, left: 20, right: 20),
child: Column(
children: [
Container(
alignment: Alignment.centerRight,
height: 50,
child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [
Padding(padding: const EdgeInsets.symmetric(horizontal: 10), child:
Text("load or create a new workflow", style: const TextStyle(color: Colors.grey, fontSize: 15)
)),
Padding ( padding: const EdgeInsets.symmetric(horizontal: 10), child:
Tooltip( message: "back", child: InkWell(
mouseCursor: SystemMouseCursors.click,
onTap: () {
AppRouter.catalog.go(context, {});
},
child: const Icon(Icons.arrow_back, color: Colors.black))),
),
widget.dash.isOpened ? Row ( mainAxisAlignment: MainAxisAlignment.end, children: [
Tooltip( message: "close", child: InkWell(
mouseCursor: SystemMouseCursors.click,
onTap: () { Navigator.pop(context); },
child: const Icon(Icons.close, color: Colors.black))),
]) : Container(),
],),
),
FutureBuilder<APIResponse<RawData>>(
future: (widget.service as AbstractService<T>).all(context),
builder: (context, snapshot) {
List<DropdownMenuItem> items = widget.getItems != null ? widget.getItems!(snapshot.data) : [];
if (widget._selected != null
&& !items.where((element) => element.value == widget._selected).isNotEmpty) {
items.add(DropdownMenuItem<String>(
value: widget._selected.toString(),
child: Text(widget._selected.toString()),
));
}
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children : [
SizedBox( width: MediaQuery.of(context).size.width <= 540 ? MediaQuery.of(context).size.width - 140 : 400, height: 50,
child: DropdownButtonFormField(
value: widget._selected,
isExpanded: true,
hint: const Text("load workflow...", style: TextStyle(color: Colors.grey, fontSize: 15)),
decoration: InputDecoration(
filled: true,
focusedBorder: const OutlineInputBorder( borderRadius: BorderRadius.zero,
borderSide: BorderSide(color: Color.fromARGB(38, 166, 154, 1), width: 0),
),
fillColor: Colors.grey.shade300,
contentPadding: const EdgeInsets.only(left: 30, right: 30, top: 10, bottom: 30),
enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.zero,
borderSide: BorderSide(color: Colors.grey.shade300, width: 0),
),
border: OutlineInputBorder( borderRadius: BorderRadius.zero,
borderSide: BorderSide(color: Colors.grey.shade300, width: 0)),
),
items: items,
onChanged: (value) {
setState(() {
widget._selected = value.toString();
});
})),
Tooltip(
message: 'empty selection',
child: InkWell(
mouseCursor: widget._selected == null || widget._selected!.isEmpty ? MouseCursor.defer : SystemMouseCursors.click,
onTap: () {
if (widget._selected == null || widget._selected!.isEmpty) { return; }
setState(() { widget._selected = null; });
},
child: Container(
width: 50, height: 50,
decoration: const BoxDecoration( color: Colors.black,
border: Border(right: BorderSide(color: Colors.white))),
child: Icon(Icons.refresh, color: widget._selected == null || widget._selected!.isEmpty ? Colors.grey : Colors.white),
)
)
),
Tooltip(
message: 'load workflow selected',
child: InkWell(
mouseCursor: widget._selected == null || widget._selected!.isEmpty
? MouseCursor.defer : SystemMouseCursors.click,
onTap: () async {
if (widget._selected == null || widget._selected!.isEmpty) { return; }
widget.dash.isOpened = true;
if (widget._selected != null && widget.dash.load != null) {
WorkspaceLocal.changeWorkspaceByName(widget._selected!.split("~")[1]);
await widget.dash.load!(widget._selected ?? "");
}
widget.dash.notifyListeners();
Navigator.pop(context);
},
child: Container(
width: 50, height: 50,
color: Colors.black,
child: Icon(Icons.open_in_browser_outlined,
color: widget._selected == null || widget._selected!.isEmpty ? Colors.grey : Colors.white),
)
)
)
]);}),
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
margin: const EdgeInsets.only(top: 10),
width: MediaQuery.of(context).size.width <= 540 ? MediaQuery.of(context).size.width - 90 : 450,
height: 50,
child: TextFormField(
expands: true,
maxLines: null,
minLines: null,
cursorColor: const Color.fromARGB(38, 166, 154, 1),
controller: widget._ctrl,
onChanged: (value) {},
validator: (value) => value == null || value.isEmpty ? "name is required" : null,
decoration: InputDecoration(
hintText: "name a new workflow...",
fillColor: Colors.grey.shade300,
filled: true,
contentPadding: const EdgeInsets.only(left: 30, right: 30, top: 15, bottom: 5),
hintStyle: const TextStyle(
color: Colors.black,
fontSize: 14,
fontWeight: FontWeight.w300
),
border: InputBorder.none
)
)
),
Tooltip(
message: 'add',
child:InkWell(
mouseCursor: widget._ctrl.value.text.isEmpty ? MouseCursor.defer : SystemMouseCursors.click,
onTap: () async {
if (widget._ctrl.value.text.isNotEmpty) {
await widget.service.post(context, { "name" : widget._ctrl.value.text }, {}).then(
(value) {
widget._selected = widget._ctrl.value.text;
widget._ctrl.value = const TextEditingValue(text: "");
widget.dash.id = value.data?.serialize()["id"];
widget.dash.name = widget._selected ?? "";
widget.dash.notifyListeners();
WorkspaceLocal.init(context, true);
widget.dash.isOpened = true;
// ignore: use_build_context_synchronously
Navigator.pop(context);
}
);
}
},
child: Container(
margin: const EdgeInsets.only(top: 10),
width: 50,
height: 50,
color: Colors.black,
child: Icon(Icons.add, color: widget._ctrl.value.text.isEmpty ? Colors.grey : Colors.white)
)
)
)
])
]
)
);
}
}

View File

@@ -0,0 +1,96 @@
import 'package:flutter/material.dart';
import 'package:oc_front/models/response.dart';
import 'package:oc_front/core/services/router.dart';
import 'package:oc_front/pages/shared.dart';
import 'package:oc_front/widgets/inputs/shallow_dropdown_input.dart';
import 'package:oc_front/widgets/inputs/shallow_text_input.dart';
class ShallowCreationDialogWidget extends StatefulWidget {
GlobalKey<ShallowTextInputWidgetState>? formKey;
BuildContext context;
bool Function()? canClose;
SharedWorkspaceType type = SharedWorkspaceType.workspace;
Future<List<Shallow>> Function()? all;
Future<void> Function(String)? load;
Future<void> Function(Map<String,dynamic>)? create;
bool Function(String?)? canLoad;
DropdownMenuItem Function(Shallow)? maptoDropdown;
List<ShallowTextInputWidget> form = [];
ShallowCreationDialogWidget ({ super.key, required this.type, required this.all, this.load, this.formKey,
required this.create, this.form = const [], this.maptoDropdown, required this.context, this.canClose }) ;
@override ShallowCreationDialogState createState() => ShallowCreationDialogState();
}
class ShallowCreationDialogState extends State<ShallowCreationDialogWidget> {
GlobalKey<FormFieldState> key = GlobalKey<FormFieldState>();
GlobalKey<FormFieldState> key2 = GlobalKey<FormFieldState>();
@override Widget build(BuildContext context) {
var t = widget.type == SharedWorkspaceType.workspace ? "workspace" : (widget.type == SharedWorkspaceType.workflow ? "workflow" : (widget.type == SharedWorkspaceType.shared_workspace ? "shared workspace" :"peer"));
return Container(
color: Colors.white,
padding: const EdgeInsets.only( top: 0, bottom: 20, left: 20, right: 20),
child: Column(
children: [
Container(
alignment: Alignment.centerRight,
height: 50,
child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [
Padding(padding: const EdgeInsets.symmetric(horizontal: 10), child:
Text("load or create a new $t", style: const TextStyle(color: Colors.grey, fontSize: 15)
)),
Padding ( padding: const EdgeInsets.symmetric(horizontal: 10), child:
Tooltip( message: "back", child: InkWell(
mouseCursor: SystemMouseCursors.click,
onTap: () {
AppRouter.catalog.go(context, {});
},
child: const Icon(Icons.arrow_back, color: Colors.black))),
),
widget.canClose != null && !widget.canClose!() ? Container() : Row ( mainAxisAlignment: MainAxisAlignment.end, children: [
Tooltip( message: "close", child: InkWell(
mouseCursor: SystemMouseCursors.click,
onTap: () { Navigator.pop(context); },
child: const Icon(Icons.close, color: Colors.black))),
]),
],),
),
ShallowDropdownInputWidget(
all: widget.all,
type: widget.type,
width: MediaQuery.of(context).size.width <= 540 ? MediaQuery.of(context).size.width - 140 : 400,
load: (e) async {
await widget.load!(e);
Navigator.pop(widget.context);
},
iconLoad: Icons.open_in_browser_outlined,
iconRemove: Icons.refresh,
maptoDropdown: widget.maptoDropdown,
canLoad: (p0) => p0 != null && p0.isNotEmpty,
canRemove: (p0) => p0 != null && p0.isNotEmpty,
tooltipRemove: "refresh selection",
deletion: true,
color: Colors.black,
hintColor: Colors.grey,
filled: Colors.grey.shade300,
),
Container( height: 10),
ShallowTextInputWidget(
key: widget.formKey,
type: widget.type,
width: MediaQuery.of(context).size.width <= 540 ? MediaQuery.of(context).size.width - 140 : 400,
load: (e) async {
await widget.create!(e);
Navigator.pop(widget.context);
},
forms: widget.form,
canLoad: (p0) => p0 != null && p0.isNotEmpty,
color: Colors.black,
hintColor: Colors.grey,
filled: Colors.grey.shade300,
),
...widget.form.map( (e) => Container( margin: const EdgeInsets.only(top: 10), child: e)),
]
)
);
}
}