test
This commit is contained in:
@@ -13,35 +13,35 @@ class WorkSpaceItem {
|
||||
WorkSpaceItem({this.id, this.name});
|
||||
}
|
||||
|
||||
class SharedWorkspaceLocal {
|
||||
class CollaborativeAreaLocal {
|
||||
static String? current;
|
||||
static Map<String, SharedWorkspace> workspaces = {};
|
||||
static Map<String, CollaborativeArea> workspaces = {};
|
||||
static final SharedService _service = SharedService();
|
||||
|
||||
static void init(BuildContext context, bool changeCurrent) {
|
||||
_service.all(context).then((value) {
|
||||
_service.all(context).then((value) {
|
||||
if (value.data != null && value.data!.values.isNotEmpty ) {
|
||||
var vals = value.data!.values;
|
||||
for (var element in vals) {
|
||||
var ws = SharedWorkspace().deserialize(element);
|
||||
var ws = CollaborativeArea().deserialize(element);
|
||||
if (ws.id == null) { continue; }
|
||||
workspaces[ws.id!] = ws;
|
||||
}
|
||||
}
|
||||
});
|
||||
}).catchError((e) => print(e));
|
||||
}
|
||||
|
||||
static SharedWorkspace? getSharedWorkspace(String id) {
|
||||
static CollaborativeArea? getCollaborativeArea(String id) {
|
||||
return workspaces[id];
|
||||
}
|
||||
|
||||
static Future<void> deleteSharedWorkspace(String id) async {
|
||||
static Future<void> deleteCollaborativeArea(String id) async {
|
||||
if (workspaces.containsKey(id) && workspaces.length == 1) { return; }
|
||||
workspaces.remove(id);
|
||||
await _service.delete(null, id, {});
|
||||
}
|
||||
|
||||
static Future<void> createSharedWorkspace(String name, BuildContext? context) async {
|
||||
static Future<void> createCollaborativeArea(String name, BuildContext? context) async {
|
||||
Workspace n = Workspace(name: name);
|
||||
await _service.post(context, n.serialize(), {}).then((value) {
|
||||
if (value.data != null) {
|
||||
@@ -67,7 +67,7 @@ class SharedWorkspaceLocal {
|
||||
WorkflowFactory.key.currentState?.setState(() {});
|
||||
}
|
||||
|
||||
static List<WorkSpaceItem> getSharedWorkspacesIDS() {
|
||||
static List<WorkSpaceItem> getCollaborativeAreasIDS() {
|
||||
List<WorkSpaceItem> res = [];
|
||||
for (var element in workspaces.entries) {
|
||||
res.add(WorkSpaceItem(id: element.key, name: element.value.name));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
|
||||
import 'package:oc_front/core/sections/end_drawer.dart';
|
||||
import 'package:oc_front/core/sections/header/header.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/models/workspace.dart';
|
||||
@@ -21,28 +22,28 @@ class WorkspaceLocal {
|
||||
static final WorkspaceService _service = WorkspaceService();
|
||||
static List<AbstractItem> items = [];
|
||||
|
||||
static void init(BuildContext context, bool changeCurrent) {
|
||||
_service.all(context).then((value) {
|
||||
if (value.data != null && value.data!.values.isNotEmpty ) {
|
||||
var vals = value.data!.values;
|
||||
for (var element in vals) {
|
||||
var ws = Workspace().deserialize(element);
|
||||
if (ws.id == null) { continue; }
|
||||
workspaces[ws.id!] = ws;
|
||||
if (current == null) {
|
||||
current ??= ws.id;
|
||||
workspaces[current!] = ws;
|
||||
_service.put(context, ws.id!, { "active" : true }, {});
|
||||
}
|
||||
if (ws.active == true && changeCurrent) {
|
||||
current = ws.id;
|
||||
}
|
||||
fill();
|
||||
static Future<void> init(BuildContext context, bool changeCurrent) async {
|
||||
var value = await _service.all(context);
|
||||
if (value.data != null && value.data!.values.isNotEmpty ) {
|
||||
var vals = value.data!.values;
|
||||
for (var element in vals) {
|
||||
var ws = Workspace().deserialize(element);
|
||||
if (ws.id == null) { continue; }
|
||||
workspaces[ws.id!] = ws;
|
||||
if (current == null) {
|
||||
current ??= ws.id;
|
||||
workspaces[current!] = ws;
|
||||
_service.put(context, ws.id!, { "active" : true }, {});
|
||||
}
|
||||
} else {
|
||||
WorkspaceLocal.createWorkspace("main", null);
|
||||
if (ws.active == true && changeCurrent) {
|
||||
current = ws.id;
|
||||
}
|
||||
fill();
|
||||
HeaderConstants.headerKey.currentState?.setState(() {});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
await WorkspaceLocal.createWorkspace("default workspace", null);
|
||||
}
|
||||
}
|
||||
|
||||
static void fill() {
|
||||
@@ -55,7 +56,7 @@ class WorkspaceLocal {
|
||||
for (var element in workspaces[current]!.processings) {
|
||||
if (WorkspaceLocal.hasItemByID(element.getID())) { continue; }
|
||||
items.add(element); }
|
||||
for (var element in workspaces[current]!.datacenters) {
|
||||
for (var element in workspaces[current]!.computes) {
|
||||
if (WorkspaceLocal.hasItemByID(element.getID())) { continue; }
|
||||
items.add(element);
|
||||
}
|
||||
@@ -74,6 +75,13 @@ class WorkspaceLocal {
|
||||
return workspaces[current];
|
||||
}
|
||||
|
||||
static bool hasWorkspace(String workspaceName) {
|
||||
for (var element in workspaces.values) {
|
||||
if (element.name == workspaceName) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static Future<void> deleteWorkspace(String id) async {
|
||||
if (workspaces.containsKey(id) && workspaces.length == 1) { return; }
|
||||
workspaces.remove(id);
|
||||
@@ -89,28 +97,36 @@ class WorkspaceLocal {
|
||||
current = value.data!.id;
|
||||
fill();
|
||||
endDrawerKey.currentState?.setState(() {});
|
||||
CatalogFactory.key.currentState?.setState(() {});
|
||||
CatalogItemFactory.key.currentState?.setState(() {});
|
||||
WorkflowFactory.key.currentState?.setState(() {});
|
||||
CatalogFactory.key.currentState?.setState(() {});
|
||||
CatalogItemFactory.key.currentState?.setState(() {});
|
||||
WorkflowFactory.key.currentState?.setState(() {});
|
||||
HeaderConstants.headerKey.currentState?.setState(() {});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static void changeWorkspaceByName(String name) {
|
||||
var id = workspaces.entries.firstWhere((element) => element.value.name == "${name}_workspace").key;
|
||||
changeWorkspace(id);
|
||||
try {
|
||||
var id = workspaces.entries.firstWhere((element) => element.value.name == "${name}_workspace").key;
|
||||
changeWorkspace(id);
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
static void changeWorkspace(String id) {
|
||||
_service.put(null, id, { "active" : true }, {});
|
||||
current = id;
|
||||
fill();
|
||||
HeaderConstants.headerKey.currentState?.setState(() {});
|
||||
endDrawerKey.currentState?.setState(() {});
|
||||
CatalogFactory.key.currentState?.setState(() {});
|
||||
CatalogItemFactory.key.currentState?.setState(() {});
|
||||
WorkflowFactory.key.currentState?.setState(() {});
|
||||
}
|
||||
|
||||
static String getWorkspaceName(String id) {
|
||||
return workspaces[id]?.name ?? "";
|
||||
}
|
||||
|
||||
static List<WorkSpaceItem> getWorkspacesIDS() {
|
||||
List<WorkSpaceItem> res = [];
|
||||
for (var element in workspaces.entries) {
|
||||
@@ -131,7 +147,7 @@ class WorkspaceLocal {
|
||||
List<AbstractItem<FlowData>> d = [];
|
||||
var w = workspaces[id]!;
|
||||
d = [ ...d, ...w.datas.where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
d = [ ...d, ...w.datacenters.where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
d = [ ...d, ...w.computes.where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
d = [ ...d, ...w.processings.where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
d = [ ...d, ...w.storages.where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
d = [ ...d, ...w.workflows.where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
@@ -143,7 +159,7 @@ class WorkspaceLocal {
|
||||
List<AbstractItem<FlowData>> d = [];
|
||||
for (var w in workspaces.values) {
|
||||
d = [ ...d, ...w.datas.where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
d = [ ...d, ...w.datacenters.where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
d = [ ...d, ...w.computes.where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
d = [ ...d, ...w.processings.where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
d = [ ...d, ...w.storages.where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
d = [ ...d, ...w.workflows.where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
@@ -158,7 +174,7 @@ class WorkspaceLocal {
|
||||
List<AbstractItem<FlowData>> d = [];
|
||||
for (var w in workspaces.values) {
|
||||
d = [ ...d, ...w.datas.where((element) => element.id.toString() == id).where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
d = [ ...d, ...w.datacenters.where((element) => element.id.toString() == id).where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
d = [ ...d, ...w.computes.where((element) => element.id.toString() == id).where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
d = [ ...d, ...w.processings.where((element) => element.id.toString() == id).where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
d = [ ...d, ...w.storages.where((element) => element.id.toString() == id).where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
d = [ ...d, ...w.workflows.where((element) => element.id.toString() == id).where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
@@ -174,7 +190,7 @@ class WorkspaceLocal {
|
||||
items.add(item);
|
||||
if (item.topic == "data") { workspaces[current]!.datas.add(item as DataItem); }
|
||||
if (item.topic == "processing") { workspaces[current]!.processings.add(item as ProcessingItem); }
|
||||
if (item.topic == "datacenter") { workspaces[current]!.datacenters.add(item as DataCenterItem); }
|
||||
if (item.topic == "compute") { workspaces[current]!.computes.add(item as ComputeItem); }
|
||||
if (item.topic == "storage") { workspaces[current]!.storages.add(item as StorageItem); }
|
||||
if (item.topic == "workflow") { workspaces[current]!.workflows.add(item as WorkflowItem); }
|
||||
try { _service.put(null, workspaces[current]!.id!, workspaces[current]!.serialize(), {});
|
||||
@@ -186,7 +202,7 @@ class WorkspaceLocal {
|
||||
items = items.where((element) => element.name != item.name).toList();
|
||||
if (item.topic == "data") { workspaces[current]!.datas.removeWhere( (e) => e.id == item.id); }
|
||||
if (item.topic == "processing") { workspaces[current]!.processings.removeWhere( (e) => e.id == item.id); }
|
||||
if (item.topic == "datacenter") { workspaces[current]!.datacenters.removeWhere( (e) => e.id == item.id); }
|
||||
if (item.topic == "compute") { workspaces[current]!.computes.removeWhere( (e) => e.id == item.id); }
|
||||
if (item.topic == "storage") { workspaces[current]!.storages.removeWhere( (e) => e.id == item.id); }
|
||||
if (item.topic == "workflow") { workspaces[current]!.workflows.removeWhere( (e) => e.id == item.id); }
|
||||
try { _service.put(null, workspaces[current]!.id!, workspaces[current]!.serialize(), {});
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/core/models/shared_workspace_local.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/catalog.dart';
|
||||
import 'package:oc_front/core/models/workspace_local.dart';
|
||||
import 'package:oc_front/pages/shared.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_text_input.dart';
|
||||
import 'package:oc_front/widgets/items/item_row.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_dropdown_input.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/workspace_service.dart';
|
||||
|
||||
GlobalKey<EndDrawerWidgetState> endDrawerKey = GlobalKey<EndDrawerWidgetState>();
|
||||
class EndDrawerWidget extends StatefulWidget {
|
||||
@@ -24,12 +23,12 @@ class EndDrawerWidgetState extends State<EndDrawerWidget> {
|
||||
Container(
|
||||
color: Colors.white,
|
||||
width: 400,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
height: getHeight(context),
|
||||
child: Column( children: [
|
||||
Container(
|
||||
width: 400,
|
||||
height: 50,
|
||||
decoration: const BoxDecoration(color: Color.fromRGBO(38, 166, 154, 1)),
|
||||
decoration: BoxDecoration(color: lightColor ),
|
||||
child: const Center(
|
||||
child: Row( mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
@@ -41,53 +40,61 @@ class EndDrawerWidgetState extends State<EndDrawerWidget> {
|
||||
),
|
||||
ShallowDropdownInputWidget(
|
||||
current: WorkspaceLocal.current,
|
||||
filled: Colors.grey.shade200,
|
||||
filled: Colors.white,
|
||||
width: 400,
|
||||
all: () async => WorkspaceLocal.getWorkspacesShallow(),
|
||||
canRemove: (p0) => p0 != null,
|
||||
remove: (p0) async {
|
||||
await WorkspaceService().delete(context, p0, {}).then( (e) => WorkspaceLocal.deleteWorkspace(p0));
|
||||
},
|
||||
type: SharedWorkspaceType.workspace,
|
||||
type: CollaborativeAreaType.workspace,
|
||||
change: (String? change) {
|
||||
WorkspaceLocal.changeWorkspace(change.toString());
|
||||
}
|
||||
),
|
||||
Container(
|
||||
width: 400,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border(bottom: BorderSide(color: midColor), top: BorderSide(color: midColor)),
|
||||
),
|
||||
child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
Padding(padding: EdgeInsets.only(right: 5), child: Icon(Icons.share, size: 12, color: Colors.grey)),
|
||||
Text( (WorkspaceLocal.workspaces[WorkspaceLocal.current]?.shared) == null ?
|
||||
"actually not shared" : "share with ${WorkspaceLocal.workspaces[WorkspaceLocal.current]!.shared!}",
|
||||
style: TextStyle( fontSize: 14, color: Colors.grey ),),
|
||||
]),
|
||||
),
|
||||
Column( children: [
|
||||
itemRows.isEmpty ? Container( height: MediaQuery.of(context).size.height - 100,
|
||||
color: Colors.grey.shade300,
|
||||
child: const Center(child: Text("WORKSPACE IS EMPTY",
|
||||
style: TextStyle(fontSize: 25, fontWeight: FontWeight.w600, color: Colors.white))))
|
||||
: Container( height: MediaQuery.of(context).size.height - 100, child: SingleChildScrollView(
|
||||
itemRows.isEmpty ? Container( height: getHeight(context) - 140,
|
||||
color: Colors.white,
|
||||
child: Center(child: Text("WORKSPACE IS EMPTY",
|
||||
style: TextStyle(fontSize: 25, fontWeight: FontWeight.w600, color: midColor))))
|
||||
: Container( height: getHeight(context) - 140, child: SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
child: Column( children: [ ...itemRows, Container(height: 50)])
|
||||
)),
|
||||
])
|
||||
])
|
||||
),
|
||||
itemRows.isEmpty ? Container() : Positioned( bottom: 0, left: 0,
|
||||
child: ShallowDropdownInputWidget(
|
||||
type: SharedWorkspaceType.workspace,
|
||||
all: () async => SharedWorkspaceLocal.workspaces.values.map(
|
||||
(e) => Shallow(id: e.id ?? "", name: e.name ?? "") ).toList(),
|
||||
current: WorkspaceLocal.workspaces[WorkspaceLocal.current]?.shared,
|
||||
width: 400,
|
||||
filled: Colors.grey.shade300,
|
||||
hintColor: Colors.grey,
|
||||
color: Colors.black,
|
||||
canLoad: (String? change) => SharedWorkspaceLocal.workspaces[change] == null
|
||||
|| !SharedWorkspaceLocal.workspaces[change]!.workspaces.map( (e) => e.id ).contains(WorkspaceLocal.current),
|
||||
canRemove: (String? change) => SharedWorkspaceLocal.workspaces[change] == null
|
||||
|| SharedWorkspaceLocal.workspaces[change]!.workspaces.map( (e) => e.id ).contains(WorkspaceLocal.current),
|
||||
load: (String val) async {
|
||||
await SharedService().addWorkspace(context, val, WorkspaceLocal.current ?? "");
|
||||
SharedWorkspaceLocal.init(context, false);
|
||||
},
|
||||
remove: (String val) async {
|
||||
await SharedService().removeWorkspace(context, val, WorkspaceLocal.current ?? "");
|
||||
SharedWorkspaceLocal.init(context, false);
|
||||
})
|
||||
)
|
||||
Positioned( bottom: 0, left: 0,
|
||||
child: Tooltip( message: "create workspace", child: ShallowTextInputWidget(
|
||||
width: 400,
|
||||
tooltipLoad: "create workspace",
|
||||
iconLoad: Icons.create_new_folder_sharp,
|
||||
type: CollaborativeAreaType.workspace,
|
||||
color: Colors.white,
|
||||
filled: midColor,
|
||||
hint: "enter workspace name",
|
||||
hintColor: Colors.grey,
|
||||
canLoad: (String? remove) => remove != null,
|
||||
load: (Map<String?, dynamic> add) async {
|
||||
if (add["name"] == null) { return; }
|
||||
WorkspaceLocal.createWorkspace(add["name"], context);
|
||||
},
|
||||
),
|
||||
))
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
49
lib/core/sections/header/default.dart
Normal file
49
lib/core/sections/header/default.dart
Normal file
@@ -0,0 +1,49 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.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/main.dart';
|
||||
import 'package:oc_front/pages/shared.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_text_input.dart';
|
||||
|
||||
class DefaultWidget extends StatefulWidget{
|
||||
const DefaultWidget (): super(key: null);
|
||||
@override DefaultWidgetState createState() => DefaultWidgetState();
|
||||
}
|
||||
class DefaultWidgetState extends State<DefaultWidget> {
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: getMainWidth(context),
|
||||
height: getHeight(context) - 50,
|
||||
color: midColor,
|
||||
padding: EdgeInsets.only(top: 50),
|
||||
child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: getMainHeight(context) < 600 ? MainAxisAlignment.center : MainAxisAlignment.start,
|
||||
children: [ getMainHeight(context) < 600 ? Container() : Container(
|
||||
margin: EdgeInsets.only(left: 40),
|
||||
child: SvgPicture.asset("assets/images/logo.svg", width: 300, height: (getMainHeight(context) / (1.8) ), semanticsLabel: 'OpenCloud Logo')
|
||||
),
|
||||
ShallowTextInputWidget(
|
||||
alignment: MainAxisAlignment.center,
|
||||
width: getMainWidth(context) / 1.5,
|
||||
type: CollaborativeAreaType.workspace,
|
||||
hint: "search in resources...",
|
||||
iconLoad: PermsService.getPerm(Perms.SEARCH_INTERNAL) ? Icons.search : null,
|
||||
iconRemove: PermsService.getPerm(Perms.SEARCH_EXTERNAL) ? Icons.screen_search_desktop_outlined : null,
|
||||
tooltipLoad: PermsService.getPerm(Perms.SEARCH_INTERNAL) ? "search" : null,
|
||||
tooltipRemove: PermsService.getPerm(Perms.SEARCH_EXTERNAL) ? "distributed search" : null,
|
||||
canLoad: PermsService.getPerm(Perms.SEARCH_INTERNAL) ? (String? str) => str != null && str.isNotEmpty : null,
|
||||
canRemove: PermsService.getPerm(Perms.SEARCH_EXTERNAL) ? (String? str) => str != null && str.isNotEmpty : null,
|
||||
change: (value) => SearchConstants.set(value),
|
||||
loadStr: PermsService.getPerm(Perms.SEARCH_INTERNAL) ? (String val) async {
|
||||
AppRouter.currentRoute.factory.search(context, false);
|
||||
} : null,
|
||||
remove: PermsService.getPerm(Perms.SEARCH_EXTERNAL) ? (String val) async {
|
||||
AppRouter.currentRoute.factory.search(context, true);
|
||||
} : null,
|
||||
)
|
||||
])
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,27 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/core/models/workspace_local.dart';
|
||||
import 'package:oc_front/core/sections/header/default.dart';
|
||||
import 'package:oc_front/core/sections/header/menu.dart';
|
||||
import 'package:oc_front/core/sections/header/search.dart';
|
||||
import 'package:oc_front/core/services/perms_service.dart';
|
||||
import 'package:oc_front/core/services/router.dart';
|
||||
import 'package:oc_front/widgets/menus/clipper_menu.dart';
|
||||
import 'package:oc_front/main.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 SearchConstants {
|
||||
static final Map<String, String?> _searchHost = {};
|
||||
static String? get() { return _searchHost[AppRouter.currentRoute.route]; }
|
||||
static void set(String? search) { _searchHost[AppRouter.currentRoute.route] = search; }
|
||||
static void remove() { _searchHost.remove(AppRouter.currentRoute.route); }
|
||||
static void clear() { _searchHost.clear(); }
|
||||
}
|
||||
|
||||
class HeaderConstants {
|
||||
static GlobalKey<HeaderMenuWidgetState> headerKey = GlobalKey<HeaderMenuWidgetState>();
|
||||
static final List<RouterItem> noHeader = [
|
||||
AppRouter.scheduler,
|
||||
AppRouter.shared,
|
||||
AppRouter.workflowItem,
|
||||
AppRouter.workflowIDItem,
|
||||
];
|
||||
@@ -14,6 +30,11 @@ class HeaderConstants {
|
||||
static String? title;
|
||||
static String? description;
|
||||
|
||||
static getKey() {
|
||||
headerKey = GlobalKey<HeaderMenuWidgetState>();
|
||||
return headerKey;
|
||||
}
|
||||
|
||||
static setTitle(String? v) {
|
||||
title = v;
|
||||
HeaderConstants.headerWidget?.setState(() {});
|
||||
@@ -36,11 +57,65 @@ class HeaderWidget extends StatefulWidget {
|
||||
class HeaderWidgetState extends State<HeaderWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
HeaderConstants.headerWidget = this;
|
||||
headerMenuKey.currentState?.closeMenu();
|
||||
HeaderConstants.height = HeaderConstants.isNoHeader(AppRouter.currentRoute.route) ? 50 : 200;
|
||||
if (HeaderConstants.isNoHeader(AppRouter.currentRoute.route)) {
|
||||
return Container();
|
||||
}
|
||||
if (AppRouter.currentRoute.factory.searchFill()) {
|
||||
return DefaultWidget();
|
||||
}
|
||||
HeaderConstants.height = HeaderConstants.isNoHeader(AppRouter.currentRoute.route) || AppRouter.currentRoute.factory.searchFill() ? 50 : 100;
|
||||
return Column( children: [
|
||||
const HeaderMenuWidget(),
|
||||
HeaderConstants.isNoHeader(AppRouter.currentRoute.route) ? Container() : SearchWidget()
|
||||
AppRouter.currentRoute.factory.searchFill() ? Container() : Container(
|
||||
height: 50, width: getMainWidth(context),
|
||||
decoration: BoxDecoration(
|
||||
color: midColor,
|
||||
border: Border(bottom: BorderSide(color: Colors.white, width: 1),)
|
||||
),
|
||||
child: Row(crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
ShallowTextInputWidget(
|
||||
filled: midColor,
|
||||
width: getMainWidth(context) - 451,
|
||||
type: CollaborativeAreaType.workspace,
|
||||
hint: "search in resources...",
|
||||
iconLoad: PermsService.getPerm(Perms.SEARCH_INTERNAL) ? Icons.search : null,
|
||||
iconRemove: PermsService.getPerm(Perms.SEARCH_EXTERNAL) ? Icons.screen_search_desktop_outlined : null,
|
||||
tooltipLoad: PermsService.getPerm(Perms.SEARCH_INTERNAL) ? "search" : null,
|
||||
tooltipRemove: PermsService.getPerm(Perms.SEARCH_EXTERNAL) ? "distributed search" : null,
|
||||
canLoad: PermsService.getPerm(Perms.SEARCH_INTERNAL) ? (String? str) => str != null && str.isNotEmpty : null,
|
||||
canRemove: PermsService.getPerm(Perms.SEARCH_EXTERNAL) ? (String? str) => str != null && str.isNotEmpty : null,
|
||||
change: (value) => SearchConstants.set(value),
|
||||
loadStr: PermsService.getPerm(Perms.SEARCH_INTERNAL) ? (String val) async {
|
||||
AppRouter.currentRoute.factory.search(context, false);
|
||||
} : null,
|
||||
remove: PermsService.getPerm(Perms.SEARCH_EXTERNAL) ? (String val) async {
|
||||
AppRouter.currentRoute.factory.search(context, true);
|
||||
} : null,
|
||||
),
|
||||
Container( padding: EdgeInsets.only(left: 50),
|
||||
decoration: BoxDecoration( border: Border( left: BorderSide( color: Colors.white ))),
|
||||
child: ShallowDropdownInputWidget(
|
||||
prefixIcon: Padding( padding: EdgeInsets.only(right: 10), child: Icon(Icons.shopping_cart, color: Colors.grey)),
|
||||
current: WorkspaceLocal.current,
|
||||
width: 350,
|
||||
all: () async => WorkspaceLocal.getWorkspacesShallow(),
|
||||
type: CollaborativeAreaType.workspace,
|
||||
change: (String? change) {
|
||||
WorkspaceLocal.changeWorkspace(change.toString());
|
||||
},
|
||||
canLoad: (p0) => true,
|
||||
load: (p0) async {
|
||||
scaffoldKey.currentState?.openEndDrawer();
|
||||
},
|
||||
tooltipLoad: "open workspace manager",
|
||||
iconLoad: Icons.remove_red_eye,
|
||||
color: Colors.black,
|
||||
filled: midColor,
|
||||
hintColor: Colors.grey,
|
||||
))
|
||||
])
|
||||
),
|
||||
],);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,51 +1,54 @@
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:oc_front/core/sections/header/header.dart';
|
||||
import 'package:oc_front/core/services/auth.service.dart';
|
||||
import 'package:oc_front/core/services/router.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/widgets/menus/clipper_menu.dart';
|
||||
import 'package:oc_front/widgets/dialog/login.dart';
|
||||
|
||||
class HeaderMenuWidget extends StatefulWidget{
|
||||
const HeaderMenuWidget ({ super.key });
|
||||
HeaderMenuWidget (): super(key: HeaderConstants.getKey());
|
||||
@override HeaderMenuWidgetState createState() => HeaderMenuWidgetState();
|
||||
}
|
||||
class HeaderMenuWidgetState extends State<HeaderMenuWidget> {
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
width: getWidth(context),
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
border: Border(bottom: BorderSide(color: Colors.grey.shade300))
|
||||
color: Colors.white,
|
||||
border: Border(bottom: BorderSide(color: midColor))
|
||||
),
|
||||
child: Padding(padding: const EdgeInsets.only(top: 5, bottom: 5, left: 50, right: 50),
|
||||
child: Stack(children: [
|
||||
Row(crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
child: Stack(children: [
|
||||
AppRouter.currentRoute.factory.searchFill() ? Container() : Positioned( top: 0, left: 30, child: InkWell( onTap: () {
|
||||
AppRouter.currentRoute = AppRouter.zones.first;
|
||||
AppRouter.currentRoute.factory.clear();
|
||||
AppRouter.zones.first.go(context, {});
|
||||
},
|
||||
child: SvgPicture.asset("assets/images/icon.svg", width: 70, height: 70, semanticsLabel: 'OpenCloud Logo'))),
|
||||
Padding( padding: const EdgeInsets.only(left: 50),
|
||||
child: Row(crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Tooltip( message: "workspace/cart", child: Padding(padding: const EdgeInsets.only(left: 10),
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.shopping_cart_outlined),
|
||||
onPressed: () {
|
||||
headerMenuKey.currentState?.closeMenu();
|
||||
scaffoldKey.currentState?.openEndDrawer();
|
||||
},
|
||||
)
|
||||
Center(child: Text("hello \"${AuthService.getUsername() ?? ""}\"", style: const TextStyle(color: Colors.grey, fontSize: 15))),
|
||||
Padding(padding: const EdgeInsets.only(top: 5, bottom: 5, right: 50, left: 20),
|
||||
child: Row(crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Tooltip( message: "logout", child: Padding(padding: const EdgeInsets.only(left: 10),
|
||||
child: IconButton(
|
||||
icon: const Icon(FontAwesomeIcons.powerOff),
|
||||
onPressed: () async {
|
||||
await AuthService.logout();
|
||||
mainKey?.currentState?.setState(() {});
|
||||
},
|
||||
)
|
||||
)),
|
||||
Tooltip( message: "login", child: Padding(padding: const EdgeInsets.only(left: 10),
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.login_outlined),
|
||||
onPressed: () { showDialog(context: context, builder: (context) =>
|
||||
LoginWidget()); },
|
||||
)
|
||||
)),
|
||||
Tooltip( message: "navigation", child: Padding(padding: const EdgeInsets.only(left: 10),
|
||||
child: ClipperMenuWidget(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
iconColor: Colors.white,
|
||||
)
|
||||
))
|
||||
]
|
||||
)
|
||||
))
|
||||
])
|
||||
)
|
||||
)])
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:oc_front/core/sections/header/header.dart';
|
||||
import 'package:oc_front/core/services/router.dart';
|
||||
import 'package:oc_front/pages/shared.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_text_input.dart';
|
||||
|
||||
class SearchConstants {
|
||||
static final Map<String, String?> _searchHost = {};
|
||||
static String? get() { return _searchHost[AppRouter.currentRoute.route]; }
|
||||
static void set(String? search) { _searchHost[AppRouter.currentRoute.route] = search; }
|
||||
static void remove() { _searchHost.remove(AppRouter.currentRoute.route); }
|
||||
static void clear() { _searchHost.clear(); }
|
||||
}
|
||||
|
||||
GlobalKey<SearchWidgetState> searchWidgetKey = GlobalKey<SearchWidgetState>();
|
||||
class SearchWidget extends StatefulWidget {
|
||||
SearchWidget (): super(key: GlobalKey<SearchWidgetState>());
|
||||
@override SearchWidgetState createState() => SearchWidgetState();
|
||||
}
|
||||
class SearchWidgetState extends State<SearchWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
searchWidgetKey = widget.key as GlobalKey<SearchWidgetState>;
|
||||
List<Widget> widgets = [
|
||||
...(MediaQuery.of(context).size.width > 600 || AppRouter.currentRoute.factory.searchFill()
|
||||
? [InkWell(
|
||||
mouseCursor: SystemMouseCursors.click,
|
||||
onTap: () => AppRouter.zones.first.go(context, {}),
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(top: 20, left: AppRouter.currentRoute.factory.searchFill() ? 40 : 0),
|
||||
child: SvgPicture.asset(
|
||||
width: 300,
|
||||
height: AppRouter.currentRoute.factory.searchFill() ?
|
||||
((MediaQuery.of(context).size.height - 50) / 2) : 150,
|
||||
"assets/images/logo.svg",
|
||||
semanticsLabel: 'OpenCloud Logo'
|
||||
)
|
||||
)
|
||||
)] : []),
|
||||
AppRouter.currentRoute.description != null
|
||||
|| (AppRouter.currentRoute.route.contains("shared") && HeaderConstants.title != null) ?
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(HeaderConstants.title ?? AppRouter.currentRoute.description!, style: const TextStyle(
|
||||
color: Color.fromRGBO(38, 166, 154, 1),
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w600
|
||||
)),
|
||||
Row(children: [
|
||||
...(HeaderConstants.description == null && (AppRouter.currentRoute.help == null || AppRouter.currentRoute.help!.isEmpty) ? []
|
||||
: [ const Padding( padding: EdgeInsets.only(right: 10),
|
||||
child: Icon(Icons.help_outline, color: Colors.grey, size: 20)),
|
||||
Text(HeaderConstants.description ?? AppRouter.currentRoute.help ?? "", style: const TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400
|
||||
)) ])
|
||||
],)
|
||||
|
||||
],
|
||||
)
|
||||
: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [ ShallowTextInputWidget(
|
||||
width: MediaQuery.of(context).size.width - 400 > 0 ? MediaQuery.of(context).size.width - 300 - 100 : 200,
|
||||
type: SharedWorkspaceType.workspace,
|
||||
hint: "search in resources...",
|
||||
iconLoad: Icons.search,
|
||||
iconRemove: Icons.screen_search_desktop_outlined,
|
||||
tooltipLoad: "search",
|
||||
tooltipRemove: "distributed search",
|
||||
canLoad: (String? str) => str != null && str.isNotEmpty,
|
||||
canRemove: (String? str) => str != null && str.isNotEmpty,
|
||||
change: (value) => SearchConstants.set(value),
|
||||
loadStr: (String val) async {
|
||||
AppRouter.currentRoute.factory.search(context);
|
||||
},
|
||||
remove: (String val) async {
|
||||
AppRouter.currentRoute.factory.search(context);
|
||||
},
|
||||
) ]),
|
||||
];
|
||||
return Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: AppRouter.currentRoute.factory.searchFill() ? (MediaQuery.of(context).size.height - 50) : 150,
|
||||
color: Colors.grey.shade300,
|
||||
child: AppRouter.currentRoute.factory.searchFill() ? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: widgets)
|
||||
: Row( mainAxisAlignment: MediaQuery.of(context).size.width < 600
|
||||
? MainAxisAlignment.center : MainAxisAlignment.start, children: widgets)
|
||||
);
|
||||
}
|
||||
}
|
||||
20
lib/core/sections/left_menu.dart
Normal file
20
lib/core/sections/left_menu.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/core/services/router.dart';
|
||||
|
||||
class LeftMenuWidget extends StatefulWidget {
|
||||
const LeftMenuWidget({Key? key}): super(key: key);
|
||||
@override LeftMenuWidgetState createState() => LeftMenuWidgetState();
|
||||
}
|
||||
|
||||
class LeftMenuWidgetState extends State<LeftMenuWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
var routes = AppRouter.zones.where( (e) => e.label != null && e.icon != null).toList();
|
||||
List<Widget> widgets = routes.map( (e) => Opacity( opacity: AppRouter.currentRoute.route == e.route ? 1 : .5,
|
||||
child: Tooltip( message: e.label, child: SizedBox( width: 50, height: 50, child: InkWell(
|
||||
onTap: () { e.go(context, {}); },
|
||||
child: Center( child: Icon(e.icon, color:Colors.white) ),
|
||||
),
|
||||
)))).toList();
|
||||
return Column( children: widgets);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import 'dart:io';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:alert_banner/exports.dart';
|
||||
import 'package:localstorage/localstorage.dart';
|
||||
import 'package:oc_front/models/abstract.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/widgets/dialog/alert.dart';
|
||||
@@ -11,16 +12,14 @@ import 'package:oc_front/core/services/html.dart' if (kIsWeb) 'dart:html' as htt
|
||||
class APIService<T extends SerializerDeserializer> {
|
||||
static bool forceRequest = false;
|
||||
static Map<String, APIResponse<dynamic>> cache = <String, APIResponse<dynamic>>{};
|
||||
static String auth = "";
|
||||
Dio _dio = Dio(
|
||||
BaseOptions(
|
||||
baseUrl: const String.fromEnvironment('HOST', defaultValue: 'http://localhost:8080'), // you can keep this blank
|
||||
headers: { 'Content-Type': 'application/json; charset=UTF-8' },
|
||||
),
|
||||
)..interceptors.add(LogInterceptor( requestHeader: true, ),);
|
||||
)..interceptors.add(LogInterceptor( requestHeader: true, ));
|
||||
|
||||
APIService({ required String baseURL }) {
|
||||
print("BASE URL " + baseURL);
|
||||
APIService({ required String baseURL}) {
|
||||
_dio = Dio(
|
||||
BaseOptions(
|
||||
baseUrl: baseURL, // you can keep this blank
|
||||
@@ -52,7 +51,6 @@ class APIService<T extends SerializerDeserializer> {
|
||||
Future _mainDownload(String url, String method, bool isFilter, String? extend, String savePath, bool isWeb, BuildContext context) async {
|
||||
try {
|
||||
downloadProgressNotifier.value = 0;
|
||||
// dio.options.headers["authorization"] = auth;
|
||||
if (isWeb) {
|
||||
_dio.get("$url${extend ?? ""}").then((value) {
|
||||
var url = http.Url.createObjectUrlFromBlob(http.Blob([value.data]));
|
||||
@@ -76,9 +74,9 @@ class APIService<T extends SerializerDeserializer> {
|
||||
BuildContext? context, Options? options) async {
|
||||
var err = "";
|
||||
try {
|
||||
_dio.options.headers["authorization"] = auth;
|
||||
var type = localStorage.getItem('tokenType') ?? "bearer";
|
||||
_dio.options.headers["Authorization"] = "${type[0].toUpperCase() + type.substring(1)} ${localStorage.getItem('accessToken') ?? ""}";
|
||||
_dio.interceptors.clear();
|
||||
print(url);
|
||||
var response = await _request(url, method, body, options);
|
||||
if (response.statusCode != null && response.statusCode! < 400) {
|
||||
if (method == "delete") { cache.remove(url); return APIResponse<T>(); }
|
||||
@@ -112,9 +110,9 @@ class APIService<T extends SerializerDeserializer> {
|
||||
var err = "";
|
||||
if (url != "") {
|
||||
try {
|
||||
_dio.options.headers["authorization"] = auth;
|
||||
var type = localStorage.getItem('tokenType') ?? "bearer";
|
||||
_dio.options.headers["Authorization"] = "${type[0].toUpperCase() + type.substring(1)} ${localStorage.getItem('accessToken') ?? ""}";
|
||||
_dio.interceptors.clear();
|
||||
|
||||
var response = await _request(url, method, body, null);
|
||||
if (response.statusCode != null && response.statusCode! < 400) {
|
||||
if (method == "delete") { cache.remove(url); return APIResponse<RawData>(); }
|
||||
@@ -126,7 +124,6 @@ class APIService<T extends SerializerDeserializer> {
|
||||
} catch(e, s) { print(e); print(s);
|
||||
err = "${e.toString()} ${const String.fromEnvironment('HOST', defaultValue: 'http://localhost:8080')}"; }
|
||||
} else { err = "no url"; }
|
||||
// if (err.contains("token") && err.contains("expired")) { AuthService().unAuthenticate(); }
|
||||
throw Exception(err);
|
||||
}
|
||||
|
||||
|
||||
82
lib/core/services/auth.service.dart
Normal file
82
lib/core/services/auth.service.dart
Normal file
@@ -0,0 +1,82 @@
|
||||
|
||||
import 'package:localstorage/localstorage.dart';
|
||||
import 'package:oc_front/core/sections/header/header.dart';
|
||||
import 'package:oc_front/core/services/api_service.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
class AuthService {
|
||||
static APIService<SimpleData> service = APIService(
|
||||
baseURL: const String.fromEnvironment('AUTH_HOST', defaultValue: 'http://localhost:8080/auth'),
|
||||
);
|
||||
static Future<void> init() async {
|
||||
bool ok = await introspect().catchError( (e) => false );
|
||||
if (ok) {
|
||||
var now = DateTime.now();
|
||||
var expires = DateTime.parse(localStorage.getItem('expiresIn') ?? DateTime.now().toIso8601String());
|
||||
var duration = expires.difference(now);
|
||||
refresh(localStorage.getItem('accessToken') ?? "", localStorage.getItem('username') ?? "", duration);
|
||||
} else {
|
||||
localStorage.setItem('accessToken', '');
|
||||
localStorage.setItem('username', '');
|
||||
localStorage.setItem('expiresIn', '');
|
||||
}
|
||||
}
|
||||
|
||||
static bool isConnected() {
|
||||
return (localStorage.getItem('accessToken') ?? "") != "";
|
||||
}
|
||||
|
||||
static String? getUsername() {
|
||||
return localStorage.getItem('username');
|
||||
}
|
||||
|
||||
static Future<void> login(String username, String password) async {
|
||||
var token = await service.post("/ldap/login", <String, dynamic> {
|
||||
"username": username,
|
||||
"password": password
|
||||
}, null);
|
||||
if (token.code == 200 && token.data != null) {
|
||||
localStorage.setItem('accessToken', token.data?.value['access_token']);
|
||||
localStorage.setItem('tokenType', token.data?.value['token_type']);
|
||||
localStorage.setItem('username', username);
|
||||
localStorage.setItem('expiresIn',
|
||||
DateTime.now().add(Duration(seconds: token.data?.value['expires_in'])).toIso8601String());
|
||||
HeaderConstants.headerKey.currentState?.setState(() {});
|
||||
refresh(token.data?.value['access_token'] ?? "", username, Duration(seconds: token.data?.value['expires_in']));
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> logout() async {
|
||||
var token = await service.delete("/ldap/logout", null);
|
||||
if (token.code == 200 && token.data != null) {
|
||||
localStorage.setItem('accessToken', '');
|
||||
localStorage.setItem('username', '');
|
||||
localStorage.setItem('expiresIn', '');
|
||||
}
|
||||
}
|
||||
|
||||
static Future<bool> introspect() async {
|
||||
if (!isConnected()) {
|
||||
return false;
|
||||
}
|
||||
var isIntrospected = await service.get("/introspect", true, null);
|
||||
return isIntrospected.code == 200;
|
||||
}
|
||||
|
||||
static Future<void> refresh(String accessToken, String username, Duration duration) async {
|
||||
print("REFRESH ${duration}");
|
||||
Future.delayed(duration, () {
|
||||
service.post("/refresh", <String, dynamic> {
|
||||
"access_token": accessToken,
|
||||
"username": username
|
||||
}, null).then((token) {
|
||||
print("REFRESH ${token.data}");
|
||||
if (token.code == 200 && token.data != null) {
|
||||
localStorage.setItem('accessToken', token.data?.value['access_token']);
|
||||
localStorage.setItem('username', username);
|
||||
localStorage.setItem('expiresIn',
|
||||
DateTime.now().add(Duration(seconds: token.data?.value['expires_in']) - Duration(seconds: 10)).toIso8601String());
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
56
lib/core/services/perms_service.dart
Normal file
56
lib/core/services/perms_service.dart
Normal file
@@ -0,0 +1,56 @@
|
||||
enum Perms {
|
||||
SEARCH_INTERNAL,// ignore: constant_identifier_names
|
||||
SEARCH_EXTERNAL, // ignore: constant_identifier_names
|
||||
|
||||
WORKSPACE_SHARE,// ignore: constant_identifier_names
|
||||
|
||||
WORKFLOW_CREATE, // ignore: constant_identifier_names
|
||||
WORKFLOW_EDIT, // ignore: constant_identifier_names
|
||||
WORKFLOW_DELETE, // ignore: constant_identifier_names
|
||||
WORKFLOW_BOOKING, // ignore: constant_identifier_names
|
||||
WORKFLOW_SHARE, // ignore: constant_identifier_names
|
||||
|
||||
COLLABORATIVE_AREA_CREATE, // ignore: constant_identifier_names
|
||||
COLLABORATIVE_AREA_EDIT, // ignore: constant_identifier_names
|
||||
COLLABORATIVE_AREA_DELETE, // ignore: constant_identifier_names
|
||||
}
|
||||
|
||||
Map<Perms, String> perms = {
|
||||
Perms.SEARCH_INTERNAL: 'Search Internal',
|
||||
Perms.SEARCH_EXTERNAL: 'Search External',
|
||||
Perms.WORKSPACE_SHARE: 'Workspace Share',
|
||||
Perms.WORKFLOW_CREATE: 'Workflow Create',
|
||||
Perms.WORKFLOW_EDIT: 'Workflow Edit',
|
||||
Perms.WORKFLOW_DELETE: 'Workflow Delete',
|
||||
Perms.WORKFLOW_BOOKING: 'Workflow Booking',
|
||||
Perms.WORKFLOW_SHARE: 'Workflow Share',
|
||||
};
|
||||
|
||||
class PermsService {
|
||||
static const Map<Perms, bool> _perms = {
|
||||
Perms.SEARCH_INTERNAL: true,
|
||||
Perms.SEARCH_EXTERNAL: true,
|
||||
Perms.WORKSPACE_SHARE: true,
|
||||
Perms.WORKFLOW_CREATE: true,
|
||||
Perms.WORKFLOW_EDIT: true,
|
||||
Perms.WORKFLOW_DELETE: true,
|
||||
Perms.WORKFLOW_BOOKING: true,
|
||||
Perms.WORKFLOW_SHARE: true,
|
||||
|
||||
Perms.COLLABORATIVE_AREA_CREATE: true,
|
||||
Perms.COLLABORATIVE_AREA_EDIT: false,
|
||||
Perms.COLLABORATIVE_AREA_DELETE: false,
|
||||
};
|
||||
static final PermsService _instance = PermsService._internal();
|
||||
factory PermsService() => _instance;
|
||||
PermsService._internal();
|
||||
|
||||
static bool getPerm(Perms perm) {
|
||||
return _perms[perm] ?? false;
|
||||
}
|
||||
|
||||
static void setPerm(Perms perm, bool value) {
|
||||
_perms[perm] = value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -53,22 +53,25 @@ class RouterItem {
|
||||
}
|
||||
|
||||
class AppRouter {
|
||||
static const String home = "catalog";
|
||||
static String home = "catalog";
|
||||
static final RouterItem workflowItem = RouterItem(icon: Icons.rebase_edit, label: "workflow manager", route: "workflow",
|
||||
factory: WorkflowFactory());
|
||||
static final RouterItem workflowIDItem = RouterItem(description: "", help: "", route: "workflow/:id", factory: WorkflowFactory(), args: ["id"]);
|
||||
static final RouterItem catalogItem = RouterItem(description: "", help: "", route: "catalog/:id", factory: CatalogItemFactory(), args: ["id"]);
|
||||
static final RouterItem catalog= RouterItem(icon: Icons.book_outlined, label: "catalog searcher", route: home, factory: CatalogFactory());
|
||||
static final RouterItem catalog= RouterItem(icon: Icons.book_outlined, label: "catalog searcher", route: "catalog", factory: CatalogFactory());
|
||||
static final RouterItem scheduler = RouterItem(icon: Icons.schedule, label: "scheduled tasks", route: "scheduler", factory: SchedulerFactory());
|
||||
static final RouterItem shared = RouterItem(icon: Icons.share_rounded, label: "collaborative area", route: "shared", factory: SharedFactory());
|
||||
|
||||
|
||||
static List<RouterItem> zones = [
|
||||
catalog,
|
||||
workflowItem,
|
||||
RouterItem(icon: Icons.schedule, label: "scheduled tasks", route: "scheduler", factory: SchedulerFactory()),
|
||||
RouterItem(icon: Icons.dns_outlined, label: "my datacenter", route: "datacenter",
|
||||
description: "Manage & monitor your datacenter.", help: "not implemented for now",
|
||||
scheduler,
|
||||
RouterItem(icon: Icons.dns_outlined, label: "my compute", route: "compute",
|
||||
description: "Manage & monitor your compute.", help: "not implemented for now",
|
||||
factory: DatacenterFactory()),
|
||||
RouterItem(icon: Icons.public_outlined, label: "localisations", route: "map", factory: MapFactory()),
|
||||
RouterItem(icon: Icons.share_rounded, label: "collaborative area", route: "shared", factory: SharedFactory()),
|
||||
shared,
|
||||
workflowIDItem,
|
||||
catalogItem,
|
||||
];
|
||||
|
||||
@@ -4,33 +4,33 @@ import 'package:oc_front/core/services/specialized_services/abstract_service.dar
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/models/shared.dart';
|
||||
|
||||
class SharedService extends AbstractService<SharedWorkspace> {
|
||||
@override APIService<SharedWorkspace> service = APIService<SharedWorkspace>(
|
||||
class SharedService extends AbstractService<CollaborativeArea> {
|
||||
@override APIService<CollaborativeArea> service = APIService<CollaborativeArea>(
|
||||
baseURL: const String.fromEnvironment('COLLABORATIVE_AREA_HOST', defaultValue: 'http://localhost:8080/shared')
|
||||
);
|
||||
@override String subPath = "/collaborative_area/";
|
||||
|
||||
Future<APIResponse<SharedWorkspace>> addWorkspace(BuildContext? context, String id, String id2) {
|
||||
Future<APIResponse<CollaborativeArea>> addWorkspace(BuildContext? context, String id, String id2) {
|
||||
return service.post("$subPath$id/workspace/$id2", {}, context);
|
||||
}
|
||||
|
||||
Future<APIResponse<SharedWorkspace>> addWorkflow(BuildContext? context, String id, String id2) {
|
||||
Future<APIResponse<CollaborativeArea>> addWorkflow(BuildContext? context, String id, String id2) {
|
||||
return service.post("$subPath$id/workflow/$id2", {}, context);
|
||||
}
|
||||
|
||||
Future<APIResponse<SharedWorkspace>> addPeer(BuildContext? context, String id, String id2) {
|
||||
Future<APIResponse<CollaborativeArea>> addPeer(BuildContext? context, String id, String id2) {
|
||||
return service.post("$subPath$id/peer/$id2", {}, context);
|
||||
}
|
||||
|
||||
Future<APIResponse<SharedWorkspace>> removeWorkspace(BuildContext? context, String id, String id2) {
|
||||
Future<APIResponse<CollaborativeArea>> removeWorkspace(BuildContext? context, String id, String id2) {
|
||||
return service.delete("$subPath$id/workspace/$id2", context);
|
||||
}
|
||||
|
||||
Future<APIResponse<SharedWorkspace>> removeWorkflow(BuildContext? context, String id, String id2) {
|
||||
Future<APIResponse<CollaborativeArea>> removeWorkflow(BuildContext? context, String id, String id2) {
|
||||
return service.delete("$subPath$id/workflow/$id2", context);
|
||||
}
|
||||
|
||||
Future<APIResponse<SharedWorkspace>> removePeer(BuildContext? context, String id, String id2) {
|
||||
Future<APIResponse<CollaborativeArea>> removePeer(BuildContext? context, String id, String id2) {
|
||||
return service.delete("$subPath$id/peer/$id2", context);
|
||||
}
|
||||
}
|
||||
144
lib/main.dart
144
lib/main.dart
@@ -1,33 +1,39 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:localstorage/localstorage.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/sections/header/menu.dart';
|
||||
import 'package:oc_front/core/sections/left_menu.dart';
|
||||
import 'package:oc_front/core/services/auth.service.dart';
|
||||
import 'package:oc_front/core/services/router.dart';
|
||||
import 'package:oc_front/core/sections/end_drawer.dart';
|
||||
import 'package:oc_front/core/sections/header/header.dart';
|
||||
import 'package:desktop_window/desktop_window.dart' if (kIsWeb) '';
|
||||
import 'package:oc_front/widgets/dialog/login.dart';
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
void main() {
|
||||
// Run `LinuxWebViewPlugin.initialize()` first before creating a WebView.
|
||||
await initLocalStorage();
|
||||
runApp(const MyApp());
|
||||
}
|
||||
GlobalKey<MainPageState>? mainKey;
|
||||
GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
// This widget is the root of your application.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!kIsWeb) { DesktopWindow.setMinWindowSize(const Size(400, 400)); }
|
||||
return MaterialApp.router(
|
||||
routerConfig: GoRouter( routes: AppRouter.routes ),
|
||||
);
|
||||
AuthService.init();
|
||||
return MaterialApp.router( routerConfig: GoRouter( routes: AppRouter.routes ) );
|
||||
}
|
||||
}
|
||||
// ignore: must_be_immutable
|
||||
class MainPage extends StatefulWidget {
|
||||
Widget page;
|
||||
MainPage({super.key, required this.page});
|
||||
Widget? page;
|
||||
MainPage({Key? key, required this.page}) : super(key: GlobalKey<MainPageState>());
|
||||
|
||||
// This widget is the home page of your application. It is stateful, meaning
|
||||
// that it has a State object (defined below) that contains fields that affect
|
||||
@@ -39,10 +45,40 @@ class MainPage extends StatefulWidget {
|
||||
// always marked "final".
|
||||
|
||||
@override
|
||||
State<MainPage> createState() => _MainPageState();
|
||||
State<MainPage> createState() => MainPageState();
|
||||
}
|
||||
|
||||
class _MainPageState extends State<MainPage> {
|
||||
var darkColor = Color.fromRGBO(26, 83, 92, 1);
|
||||
var lightColor = Color.fromRGBO(78, 205, 196, 1);
|
||||
var darkMidColor = Color.fromRGBO(44, 83, 100, 1);
|
||||
var midColor = Colors.grey.shade300;
|
||||
var redColor = Color.fromRGBO(255, 107, 107, 1);
|
||||
|
||||
double getWidth(BuildContext context) {
|
||||
return MediaQuery.of(context).size.width <= 800 ? 800 : MediaQuery.of(context).size.width;
|
||||
}
|
||||
|
||||
double getHeight(BuildContext context) {
|
||||
return MediaQuery.of(context).size.height <= 400 ? 400 : MediaQuery.of(context).size.height;
|
||||
}
|
||||
|
||||
double getMainHeight(BuildContext context) {
|
||||
return getHeight(context) - HeaderConstants.height;
|
||||
}
|
||||
double getMainWidth(BuildContext context) {
|
||||
return getWidth(context) - 50;
|
||||
}
|
||||
|
||||
class MainPageState extends State<MainPage> {
|
||||
bool isCtrl = false;
|
||||
final FocusNode node = FocusNode();
|
||||
@override
|
||||
void initState() {
|
||||
mainKey = widget.key as GlobalKey<MainPageState>?;
|
||||
node.requestFocus();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// This method is rerun every time setState is called, for instance as done
|
||||
@@ -51,32 +87,62 @@ class _MainPageState extends State<MainPage> {
|
||||
// The Flutter framework has been optimized to make rerunning build methods
|
||||
// fast, so that you can just rebuild anything that needs updating rather
|
||||
// than having to individually change instances of widgets.
|
||||
WorkspaceLocal.init(context, false);
|
||||
SharedWorkspaceLocal.init(context, false);
|
||||
scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
return Scaffold(
|
||||
key: scaffoldKey,
|
||||
endDrawer: EndDrawerWidget(),
|
||||
body: Column(
|
||||
// Column is also a layout widget. It takes a list of children and
|
||||
// arranges them vertically. By default, it sizes itself to fit its
|
||||
// children horizontally, and tries to be as tall as its parent.
|
||||
//
|
||||
// Column has various properties to control how it sizes itself and
|
||||
// how it positions its children. Here we use mainAxisAlignment to
|
||||
// center the children vertically; the main axis here is the vertical
|
||||
// axis because Columns are vertical (the cross axis would be
|
||||
// horizontal).
|
||||
//
|
||||
// TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
|
||||
// action in the IDE, or press "p" in the console), to see the
|
||||
// wireframe for each widget.
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
HeaderWidget(),
|
||||
widget.page // CatalogPageWidget(),
|
||||
],
|
||||
),
|
||||
);
|
||||
isCtrl = false;
|
||||
return FutureBuilder(future: AuthService.init(),
|
||||
builder: (e, s) {
|
||||
WorkspaceLocal.init(context, false);
|
||||
CollaborativeAreaLocal.init(context, false);
|
||||
if (!AuthService.isConnected()) {
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
showDialog(
|
||||
barrierDismissible: false,
|
||||
context: context, builder: (context) {
|
||||
return AlertDialog(
|
||||
insetPadding: EdgeInsets.zero,
|
||||
backgroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(0)),
|
||||
title: LoginWidget());
|
||||
});
|
||||
});
|
||||
}
|
||||
HeaderConstants.height = HeaderConstants.isNoHeader(AppRouter.currentRoute.route) || AppRouter.currentRoute.factory.searchFill() ? 50 : 100;
|
||||
return Scaffold( key: scaffoldKey, endDrawer: EndDrawerWidget(), body:
|
||||
SingleChildScrollView(
|
||||
controller: ScrollController(),
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: SingleChildScrollView(
|
||||
child: Column( children: [
|
||||
HeaderMenuWidget(),
|
||||
Row( children : [
|
||||
Container( padding: const EdgeInsets.symmetric(vertical: 30),
|
||||
decoration: BoxDecoration( color: darkColor),
|
||||
width: 50, height: getHeight(context) - 50,
|
||||
child: SingleChildScrollView( child: LeftMenuWidget() )),
|
||||
SizedBox( width: getMainWidth(context), height: getHeight(context) - 50,
|
||||
child: KeyboardListener(
|
||||
focusNode: node,
|
||||
onKeyEvent: (event) async {
|
||||
if ( event.logicalKey == LogicalKeyboardKey.controlLeft ) {
|
||||
isCtrl = (event is KeyDownEvent);
|
||||
node.requestFocus();
|
||||
} else if( (event is KeyDownEvent) && event.logicalKey == LogicalKeyboardKey.enter) {
|
||||
AppRouter.currentRoute.factory.search(context, isCtrl);
|
||||
node.requestFocus();
|
||||
}
|
||||
},
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
HeaderWidget(),
|
||||
widget.page ?? Container() // CatalogPageWidget(),
|
||||
],
|
||||
),
|
||||
)),
|
||||
])
|
||||
])
|
||||
)
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ Map<Type, SerializerDeserializer> refs = <Type, SerializerDeserializer> {
|
||||
Search: Search(),
|
||||
Workspace: Workspace(),
|
||||
DataItem: DataItem(),
|
||||
DataCenterItem: DataCenterItem(),
|
||||
ComputeItem: ComputeItem(),
|
||||
StorageItem: StorageItem(),
|
||||
ProcessingItem: ProcessingItem(),
|
||||
Workflow: Workflow(),
|
||||
@@ -18,7 +18,8 @@ Map<Type, SerializerDeserializer> refs = <Type, SerializerDeserializer> {
|
||||
WorkflowExecutions: WorkflowExecutions(),
|
||||
LogsResult: LogsResult(),
|
||||
Check: Check(),
|
||||
SharedWorkspace: SharedWorkspace(),
|
||||
CollaborativeArea: CollaborativeArea(),
|
||||
SimpleData: SimpleData(),
|
||||
};
|
||||
|
||||
class APIResponse<T extends SerializerDeserializer> {
|
||||
@@ -40,7 +41,11 @@ class APIResponse<T extends SerializerDeserializer> {
|
||||
|
||||
APIResponse<T> deserialize(dynamic j) {
|
||||
dynamic data;
|
||||
try { data = j["data"];
|
||||
try {
|
||||
if (j["data"] == null) { data = j; }
|
||||
else {
|
||||
data = j["data"];
|
||||
}
|
||||
} catch (e) { data = j; }
|
||||
try {
|
||||
return APIResponse<T>(
|
||||
@@ -52,6 +57,15 @@ class APIResponse<T extends SerializerDeserializer> {
|
||||
}
|
||||
}
|
||||
|
||||
class SimpleData extends SerializerDeserializer<SimpleData> {
|
||||
SimpleData({ this.value });
|
||||
dynamic value;
|
||||
@override deserialize(dynamic json) {
|
||||
return SimpleData(value: json);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => { };
|
||||
}
|
||||
|
||||
class RawData extends SerializerDeserializer<RawData> {
|
||||
RawData({ this.values = const []});
|
||||
List<dynamic> values = [];
|
||||
|
||||
@@ -6,31 +6,31 @@ import 'package:oc_front/models/abstract.dart';
|
||||
|
||||
const List<ProcessingItem> _emptyComputing = [];
|
||||
const List<DataItem> _emptyData = [];
|
||||
const List<DataCenterItem> _emptyDataCenter = [];
|
||||
const List<ComputeItem> _emptyCompute = [];
|
||||
const List<StorageItem> _emptyStorage = [];
|
||||
class Search extends SerializerDeserializer<Search> {
|
||||
Search({
|
||||
this.computing = _emptyComputing,
|
||||
this.datacenter = _emptyDataCenter,
|
||||
this.compute = _emptyCompute,
|
||||
this.data = _emptyData,
|
||||
this.storage = _emptyStorage,
|
||||
});
|
||||
List<ProcessingItem> computing;
|
||||
List<DataCenterItem> datacenter;
|
||||
List<ComputeItem> compute;
|
||||
List<DataItem> data;
|
||||
List<StorageItem> storage;
|
||||
@override deserialize(dynamic json) {
|
||||
json = json as Map<String, dynamic>;
|
||||
return Search(
|
||||
computing: json.containsKey("processing") ? fromListJson(json["processing"], ProcessingItem()) : [],
|
||||
datacenter: json.containsKey("datacenter") ? fromListJson(json["datacenter"], DataCenterItem()) : [],
|
||||
compute: json.containsKey("compute") ? fromListJson(json["compute"], ComputeItem()) : [],
|
||||
data: json.containsKey("data") ? fromListJson(json["data"], DataItem()) : [],
|
||||
storage: json.containsKey("storage") ? fromListJson(json["storage"], StorageItem()) : [],
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"processing": toListJson<ProcessingItem>(computing),
|
||||
"datacenter": toListJson<DataCenterItem>(datacenter),
|
||||
"compute": toListJson<ComputeItem>(compute),
|
||||
"data": toListJson<DataItem>(data),
|
||||
"storage": toListJson<StorageItem>(storage),
|
||||
};
|
||||
@@ -41,14 +41,14 @@ class Resource implements SerializerDeserializer<Resource> {
|
||||
List<DataItem> datas = [];
|
||||
List<ProcessingItem> processings = [];
|
||||
List<StorageItem> storages = [];
|
||||
List<DataCenterItem> datacenters = [];
|
||||
List<ComputeItem> computes = [];
|
||||
List<WorkflowItem> workflows = [];
|
||||
|
||||
Resource({
|
||||
this.datas = const [],
|
||||
this.processings = const [],
|
||||
this.storages = const [],
|
||||
this.datacenters = const [],
|
||||
this.computes = const [],
|
||||
this.workflows = const [],
|
||||
});
|
||||
|
||||
@@ -56,7 +56,7 @@ class Resource implements SerializerDeserializer<Resource> {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return Resource(); }
|
||||
return Resource(
|
||||
datacenters: json.containsKey("datacenter_resource") ? fromListJson(json["datacenter_resource"], DataCenterItem()) : [],
|
||||
computes: json.containsKey("compute_resource") ? fromListJson(json["compute_resource"], ComputeItem()) : [],
|
||||
datas: json.containsKey("data_resource") ? fromListJson(json["data_resource"], DataItem()) : [],
|
||||
processings: json.containsKey("processing_resource") ? fromListJson(json["processing_resource"], ProcessingItem()) : [],
|
||||
storages: json.containsKey("storage_resource") ? fromListJson(json["storage_resource"], StorageItem()) : [],
|
||||
@@ -66,7 +66,7 @@ class Resource implements SerializerDeserializer<Resource> {
|
||||
|
||||
@override Map<String, dynamic> serialize() {
|
||||
return {
|
||||
"datacenter_resource": toListJson<DataCenterItem>(datacenters),
|
||||
"compute_resource": toListJson<ComputeItem>(computes),
|
||||
"data_resource": toListJson<DataItem>(datas),
|
||||
"processing_resource": toListJson<ProcessingItem>(processings),
|
||||
"storage_resource": toListJson<StorageItem>(storages),
|
||||
@@ -198,7 +198,7 @@ class ResourceModel extends SerializerDeserializer<ResourceModel> {
|
||||
Type? getTopicType(String topic) {
|
||||
if (topic == "processing") { return ProcessingItem; }
|
||||
else if (topic == "data") { return DataItem; }
|
||||
else if (topic == "datacenter") { return DataCenterItem; }
|
||||
else if (topic == "compute") { return ComputeItem; }
|
||||
else if (topic == "storage") { return StorageItem; }
|
||||
else if (topic == "workflow") { return WorkflowItem; }
|
||||
else { return null; }
|
||||
@@ -208,7 +208,7 @@ String getTopic(Type type) {
|
||||
if (type == AbstractItem) { return "resource"; }
|
||||
if (type == ProcessingItem) { return "processing"; }
|
||||
if (type == DataItem) { return "data"; }
|
||||
if (type == DataCenterItem) { return "datacenter"; }
|
||||
if (type == ComputeItem) { return "compute"; }
|
||||
if (type == StorageItem) { return "storage"; }
|
||||
if (type == WorkflowItem) { return "workflow"; }
|
||||
return "";
|
||||
@@ -216,7 +216,7 @@ String getTopic(Type type) {
|
||||
|
||||
bool isComputing(String topic) => topic == "processing";
|
||||
bool isData(String topic) => topic == "data";
|
||||
bool isDataCenter(String topic) => topic == "datacenter";
|
||||
bool isCompute(String topic) => topic == "compute";
|
||||
bool isStorage(String topic) => topic == "storage";
|
||||
bool isWorkflow(String topic) => topic == "workflow";
|
||||
|
||||
@@ -710,8 +710,8 @@ class DataItem extends SerializerDeserializer<DataItem> implements AbstractItem<
|
||||
};
|
||||
}
|
||||
|
||||
class DataCenterItem extends SerializerDeserializer<DataCenterItem> implements AbstractItem<DataCenterItem> {
|
||||
DataCenterItem({
|
||||
class ComputeItem extends SerializerDeserializer<ComputeItem> implements AbstractItem<ComputeItem> {
|
||||
ComputeItem({
|
||||
this.id,
|
||||
this.name,
|
||||
this.logo,
|
||||
@@ -728,6 +728,11 @@ class DataCenterItem extends SerializerDeserializer<DataCenterItem> implements A
|
||||
this.cpus = const [],
|
||||
this.gpus = const [],
|
||||
this.ram,
|
||||
this.technology,
|
||||
this.access,
|
||||
this.architecture,
|
||||
this.localisation,
|
||||
this.isService = false,
|
||||
});
|
||||
@override String? id;
|
||||
@override String? name;
|
||||
@@ -735,7 +740,7 @@ class DataCenterItem extends SerializerDeserializer<DataCenterItem> implements A
|
||||
@override String? source;
|
||||
@override String? ownerLogo;
|
||||
@override String? owner;
|
||||
@override String topic = "datacenter";
|
||||
@override String topic = "compute";
|
||||
@override double? price;
|
||||
@override String? licence;
|
||||
@override List<dynamic> inputs;
|
||||
@@ -743,9 +748,14 @@ class DataCenterItem extends SerializerDeserializer<DataCenterItem> implements A
|
||||
@override String? description;
|
||||
@override String? shortDescription;
|
||||
@override ResourceModel? model;
|
||||
bool isService = false;
|
||||
String? architecture;
|
||||
int? access;
|
||||
String? localisation;
|
||||
// Special Attributes
|
||||
List<CPU> cpus = [];
|
||||
List<GPU> gpus = [];
|
||||
int? technology;
|
||||
RAM? ram;
|
||||
@override String getID() {
|
||||
return id ?? "";
|
||||
@@ -763,20 +773,42 @@ class DataCenterItem extends SerializerDeserializer<DataCenterItem> implements A
|
||||
double? getHeight() {
|
||||
return height;
|
||||
}
|
||||
String getTechnology() {
|
||||
if (technology == 0) { return "docker"; }
|
||||
if (technology == 1) { return "kubernetes"; }
|
||||
if (technology == 2) { return "slurm"; }
|
||||
if (technology == 3) { return "hardware"; }
|
||||
if (technology == 4) { return "condor"; }
|
||||
return "";
|
||||
}
|
||||
String getAccess() {
|
||||
if (access == 0) { return "ssh"; }
|
||||
if (access == 1) { return "ssh kube api"; }
|
||||
if (access == 2) { return "ssh slurm"; }
|
||||
if (access == 3) { return "ssh docker"; }
|
||||
if (access == 4) { return "opencloud"; }
|
||||
if (access == 5) { return "vpn"; }
|
||||
return "";
|
||||
}
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return DataCenterItem(); }
|
||||
|
||||
var w = DataCenterItem(
|
||||
} catch (e) { return ComputeItem(); }
|
||||
var w = ComputeItem(
|
||||
isService: json.containsKey("is_service") ? json["is_service"] : false,
|
||||
id: json.containsKey("id") ? json["id"] : null,
|
||||
name: json.containsKey("name") ? json["name"] : null,
|
||||
logo: json.containsKey("logo") ? json["logo"] : null,
|
||||
technology: json.containsKey("technology") ? json["technology"] : null,
|
||||
owner: json.containsKey("owner") ? json["owner"] : null,
|
||||
ownerLogo: json.containsKey("owner_logo") ? json["owner_logo"] : null,
|
||||
price: json.containsKey("price") ? json["price"]?.toDouble() : null,
|
||||
licence: json.containsKey("licence") ? json["licence"] : null,
|
||||
description: json.containsKey("description") ? json["description"] : null,
|
||||
shortDescription: json.containsKey("short_description") ? json["short_description"] : null,
|
||||
access: json.containsKey("access") ? json["access"] : null,
|
||||
architecture: json.containsKey("architecture") ? json["architecture"] : null,
|
||||
localisation: json.containsKey("localisation") ? json["localisation"] : null,
|
||||
inputs: json["inputs"] ?? [],
|
||||
outputs: json["outputs"] ?? [],
|
||||
source: json.containsKey("source") ? json["source"] : null,
|
||||
@@ -785,6 +817,7 @@ class DataCenterItem extends SerializerDeserializer<DataCenterItem> implements A
|
||||
gpus: json.containsKey("gpus") ? fromListJson(json["gpus"], GPU()) : [],
|
||||
ram: json.containsKey("ram") ? RAM().deserialize(json["ram"]) : null,
|
||||
);
|
||||
print(w.technology);
|
||||
if (w.logo != null) {
|
||||
//
|
||||
var image = Image.network(w.logo!);
|
||||
@@ -829,12 +862,17 @@ class DataCenterItem extends SerializerDeserializer<DataCenterItem> implements A
|
||||
"owner": owner,
|
||||
"owner_logo": ownerLogo,
|
||||
"price": price,
|
||||
"is_service": isService,
|
||||
"licence": licence,
|
||||
"access": access,
|
||||
"architecture": architecture,
|
||||
"localisation": localisation,
|
||||
"description": description,
|
||||
"short_description": shortDescription,
|
||||
"inputs": inputs,
|
||||
"outputs": outputs,
|
||||
"source": source,
|
||||
"technology": technology,
|
||||
"resource_model": model?.serialize(),
|
||||
"cpus": toListJson<CPU>(cpus),
|
||||
"gpus": toListJson<GPU>(gpus),
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/models/workflow.dart';
|
||||
import 'package:oc_front/models/workspace.dart';
|
||||
|
||||
class SharedWorkspace extends SerializerDeserializer<SharedWorkspace> {
|
||||
class CollaborativeArea extends SerializerDeserializer<CollaborativeArea> {
|
||||
String? id;
|
||||
String? name;
|
||||
String? description;
|
||||
@@ -15,7 +15,7 @@ class SharedWorkspace extends SerializerDeserializer<SharedWorkspace> {
|
||||
List<Peer> peers = [];
|
||||
List<Rule> rules = [];
|
||||
|
||||
SharedWorkspace(
|
||||
CollaborativeArea(
|
||||
{this.id,
|
||||
this.name,
|
||||
this.description,
|
||||
@@ -30,8 +30,8 @@ class SharedWorkspace extends SerializerDeserializer<SharedWorkspace> {
|
||||
@override
|
||||
deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return SharedWorkspace(); }
|
||||
return SharedWorkspace(
|
||||
} catch (e) { return CollaborativeArea(); }
|
||||
return CollaborativeArea(
|
||||
id: json.containsKey("id") ? json["id"] : null,
|
||||
name: json.containsKey("name") ? json["name"] : null,
|
||||
description: json.containsKey("description") ? json["description"] : null,
|
||||
|
||||
@@ -103,7 +103,7 @@ class Workflow extends SerializerDeserializer<Workflow> implements ShallowData
|
||||
String? id;
|
||||
String? name;
|
||||
List<dynamic> data;
|
||||
List<dynamic> datacenter;
|
||||
List<dynamic> compute;
|
||||
List<dynamic> storage;
|
||||
List<dynamic> processing;
|
||||
List<dynamic> workflows;
|
||||
@@ -116,7 +116,7 @@ class Workflow extends SerializerDeserializer<Workflow> implements ShallowData
|
||||
this.id,
|
||||
this.name = "",
|
||||
this.data = const [],
|
||||
this.datacenter = const [],
|
||||
this.compute = const [],
|
||||
this.storage = const [],
|
||||
this.processing = const [],
|
||||
this.workflows = const [],
|
||||
@@ -138,7 +138,7 @@ class Workflow extends SerializerDeserializer<Workflow> implements ShallowData
|
||||
name: json.containsKey("name") ? json["name"] : "",
|
||||
workflows: json.containsKey("workflows") ? json["workflows"] : [],
|
||||
processing: json.containsKey("processings") ? json["processings"] : [],
|
||||
datacenter: json.containsKey("datacenters") ? json["datacenters"] : [],
|
||||
compute: json.containsKey("computes") ? json["computes"] : [],
|
||||
data: json.containsKey("datas") ? json["datas"] : [],
|
||||
scheduleActive: json.containsKey("schedule_active") ? json["schedule_active"] : false,
|
||||
storage: json.containsKey("storages") ? json["storages"] : [],
|
||||
@@ -152,7 +152,7 @@ class Workflow extends SerializerDeserializer<Workflow> implements ShallowData
|
||||
"id": id,
|
||||
"name": name,
|
||||
"datas": data,
|
||||
"datacenters" : datacenter,
|
||||
"computes" : compute,
|
||||
"storages": storage,
|
||||
"processings": processing,
|
||||
"workflows": workflows,
|
||||
@@ -497,7 +497,7 @@ class GraphItem extends SerializerDeserializer<GraphItem> {
|
||||
DataItem? data;
|
||||
ProcessingItem? processing;
|
||||
StorageItem? storage;
|
||||
DataCenterItem? datacenter;
|
||||
ComputeItem? compute;
|
||||
WorkflowItem? workflow;
|
||||
|
||||
GraphItem({
|
||||
@@ -508,7 +508,7 @@ class GraphItem extends SerializerDeserializer<GraphItem> {
|
||||
this.data,
|
||||
this.processing,
|
||||
this.storage,
|
||||
this.datacenter,
|
||||
this.compute,
|
||||
this.workflow,
|
||||
});
|
||||
|
||||
@@ -516,7 +516,7 @@ class GraphItem extends SerializerDeserializer<GraphItem> {
|
||||
if (data != null) { return data!; }
|
||||
if (processing != null) { return processing!; }
|
||||
if (storage != null) { return storage!; }
|
||||
if (datacenter != null) { return datacenter!; }
|
||||
if (compute != null) { return compute!; }
|
||||
if (workflow != null) { return workflow!; }
|
||||
return null;
|
||||
}
|
||||
@@ -542,21 +542,21 @@ class GraphItem extends SerializerDeserializer<GraphItem> {
|
||||
processing!.expose.removeWhere((element) => element.port == null || element.port == 0 || (element.PAT == 0 && element.path == ""));
|
||||
|
||||
}
|
||||
} else if (abs.topic == "datacenter") {
|
||||
datacenter = DataCenterItem().deserialize(abs.serialize());
|
||||
} else if (abs.topic == "compute") {
|
||||
compute = ComputeItem().deserialize(abs.serialize());
|
||||
} else if (abs.topic == "storage") {
|
||||
storage = StorageItem().deserialize(abs.serialize());
|
||||
} else if (abs.topic == "workflow") {
|
||||
workflow = WorkflowItem().deserialize(abs.serialize());
|
||||
} else {
|
||||
datacenter = null;
|
||||
compute = null;
|
||||
data = null;
|
||||
processing = null;
|
||||
storage = null;
|
||||
workflow = null;
|
||||
}
|
||||
} else {
|
||||
datacenter = null;
|
||||
compute = null;
|
||||
data = null;
|
||||
processing = null;
|
||||
storage = null;
|
||||
@@ -566,7 +566,7 @@ class GraphItem extends SerializerDeserializer<GraphItem> {
|
||||
|
||||
Map<String, dynamic> toDashboard() {
|
||||
Map<String, dynamic> element = {};
|
||||
for(var el in [data, processing, storage, datacenter, workflow]) {
|
||||
for(var el in [data, processing, storage, compute, workflow]) {
|
||||
if (el != null && el.getID() != "") {
|
||||
element = el.serialize();
|
||||
break;
|
||||
@@ -593,7 +593,7 @@ class GraphItem extends SerializerDeserializer<GraphItem> {
|
||||
data: json.containsKey("data") ? DataItem().deserialize(json["data"]) : null,
|
||||
processing: json.containsKey("processing") ? ProcessingItem().deserialize(json["processing"]) : null,
|
||||
storage: json.containsKey("storage") ? StorageItem().deserialize(json["storage"]) : null,
|
||||
datacenter: json.containsKey("datacenter") ? DataCenterItem().deserialize(json["datacenter"]) : null,
|
||||
compute: json.containsKey("compute") ? ComputeItem().deserialize(json["compute"]) : null,
|
||||
workflow: json.containsKey("workflow") ? WorkflowItem().deserialize(json["workflow"]) : null,
|
||||
);
|
||||
}
|
||||
@@ -605,7 +605,7 @@ class GraphItem extends SerializerDeserializer<GraphItem> {
|
||||
"data": data?.serialize(),
|
||||
"processing": processing?.serialize(),
|
||||
"storage": storage?.serialize(),
|
||||
"datacenter": datacenter?.serialize(),
|
||||
"compute": compute?.serialize(),
|
||||
"workflow": workflow?.serialize(),
|
||||
"position": position?.serialize(),
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ class Workspace extends SerializerDeserializer<Workspace> implements ShallowData
|
||||
String? name;
|
||||
bool? active;
|
||||
List<DataItem> datas;
|
||||
List<DataCenterItem> datacenters;
|
||||
List<ComputeItem> computes;
|
||||
List<StorageItem> storages;
|
||||
List<ProcessingItem> processings;
|
||||
List<WorkflowItem> workflows;
|
||||
@@ -20,7 +20,7 @@ class Workspace extends SerializerDeserializer<Workspace> implements ShallowData
|
||||
this.active = false,
|
||||
this.workflows = const [],
|
||||
this.datas = const [],
|
||||
this.datacenters = const [],
|
||||
this.computes = const [],
|
||||
this.storages = const [],
|
||||
this.processings = const [],
|
||||
this.shared,
|
||||
@@ -39,7 +39,7 @@ class Workspace extends SerializerDeserializer<Workspace> implements ShallowData
|
||||
active: json.containsKey("active") ? json["active"] : false,
|
||||
processings: json.containsKey("processing_resources") ? fromListJson(json["processing_resources"], ProcessingItem()) : [],
|
||||
storages: json.containsKey("storage_resources") ? fromListJson(json["storage_resources"], StorageItem()) : [],
|
||||
datacenters: json.containsKey("datacenter_resources") ? fromListJson(json["datacenter_resources"], DataCenterItem()) : [],
|
||||
computes: json.containsKey("compute_resources") ? fromListJson(json["compute_resources"], ComputeItem()) : [],
|
||||
datas: json.containsKey("data_resources") ? fromListJson(json["data_resources"], DataItem()) : [],
|
||||
workflows: json.containsKey("workflow_resources") ? fromListJson(json["workflow_resources"], WorkflowItem()) : []
|
||||
);
|
||||
@@ -49,7 +49,7 @@ class Workspace extends SerializerDeserializer<Workspace> implements ShallowData
|
||||
"name": name,
|
||||
"processings": processings.map((e) => e.id).toList(),
|
||||
"storages": storages.map((e) => e.id).toList(),
|
||||
"datacenters": datacenters.map((e) => e.id).toList(),
|
||||
"computes": computes.map((e) => e.id).toList(),
|
||||
"datas": datas.map((e) => e.id).toList(),
|
||||
"workflows": workflows.map((e) => e.id).toList(),
|
||||
};
|
||||
|
||||
@@ -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) { },
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.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/widgets/items/item_row.dart';
|
||||
|
||||
@@ -15,7 +16,7 @@ class CatalogWidgetState extends State<CatalogWidget> {
|
||||
var items = widget.items ?? WorkspaceLocal.items;
|
||||
List<ItemRowWidget> itemRows = items.map((e) => ItemRowWidget(
|
||||
readOnly: widget.readOnly,
|
||||
contextWidth: widget.itemWidth ?? MediaQuery.of(context).size.width, item: e)).toList();
|
||||
contextWidth: widget.itemWidth ?? getMainWidth(context), item: e)).toList();
|
||||
return Column( children: itemRows);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
|
||||
class InfoAlertBannerChild extends StatelessWidget {
|
||||
final String text;
|
||||
@@ -9,7 +10,7 @@ class InfoAlertBannerChild extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * 0.8),
|
||||
constraints: BoxConstraints(maxWidth: getMainWidth(context) * 0.8),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.greenAccent,
|
||||
borderRadius: BorderRadius.all(Radius.circular(5)),
|
||||
@@ -38,9 +39,9 @@ class AlertAlertBannerChild extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * 0.8),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.redAccent,
|
||||
constraints: BoxConstraints(maxWidth: getMainWidth(context) * 0.8),
|
||||
decoration: BoxDecoration(
|
||||
color: redColor,
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(5),
|
||||
),
|
||||
|
||||
@@ -1,74 +1,105 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:oc_front/core/services/auth.service.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
|
||||
class LoginWidget extends StatefulWidget {
|
||||
LoginWidget ({ Key? key }): super(key: key);
|
||||
@override LoginWidgetState createState() => LoginWidgetState();
|
||||
}
|
||||
class LoginWidgetState extends State<LoginWidget> {
|
||||
TextEditingController usernameCtrl = TextEditingController();
|
||||
TextEditingController passwordCtrl = TextEditingController();
|
||||
|
||||
String? error;
|
||||
bool loading = false;
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
backgroundColor: Colors.white,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(0))),
|
||||
content: Padding(padding: const EdgeInsets.all(20), child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
const Center(child: Padding( padding: EdgeInsets.only(bottom: 10),
|
||||
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)),)),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||
decoration: BoxDecoration(border: Border(bottom: BorderSide(color: Colors.black))),
|
||||
),
|
||||
return Padding(padding: const EdgeInsets.all(50), child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
const Center(child: Icon(Icons.person_search, size: 150, color: Colors.grey,)),
|
||||
Center(child: Padding( padding: const EdgeInsets.only(top: 5, bottom: 20),
|
||||
child: Text("WELCOME ON OPENCLOUD", style: TextStyle(fontSize: 25, fontWeight: FontWeight.w600,
|
||||
color: lightColor ) ))),
|
||||
Container( margin: const EdgeInsets.only(bottom: 10), child: Center(child: Row( mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width / 3,
|
||||
width: getMainWidth(context) / 3,
|
||||
alignment : Alignment.center,
|
||||
child: TextField(
|
||||
controller: usernameCtrl,
|
||||
onChanged: (v) => setState(() {}),
|
||||
decoration: InputDecoration(
|
||||
enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey.shade300), borderRadius: BorderRadius.zero),
|
||||
border: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey.shade300), borderRadius: BorderRadius.zero),
|
||||
focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey.shade300), borderRadius: BorderRadius.zero),
|
||||
enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: midColor), borderRadius: BorderRadius.zero),
|
||||
border: OutlineInputBorder(borderSide: BorderSide(color: midColor), borderRadius: BorderRadius.zero),
|
||||
focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: midColor), borderRadius: BorderRadius.zero),
|
||||
hintText: "username...",
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
fillColor: Colors.grey.shade300,
|
||||
fillColor: midColor,
|
||||
filled: true,
|
||||
hintStyle: const TextStyle(fontSize: 12.5, color: Colors.grey)),
|
||||
style: const TextStyle(fontSize: 12.5, color: Colors.grey)),),
|
||||
style: const TextStyle(fontSize: 12.5, color: Colors.black)),),
|
||||
Container(width: 50, height: 50, color: Colors.black, child: const Icon(Icons.person, color: Colors.white))
|
||||
]))),
|
||||
Container( margin: const EdgeInsets.only(bottom: 20), child: Center(child: Row( mainAxisAlignment: MainAxisAlignment.center,
|
||||
Center(child: Row( mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width / 3,
|
||||
width: getMainWidth(context) / 3,
|
||||
alignment : Alignment.center,
|
||||
child: TextField(
|
||||
controller: passwordCtrl,
|
||||
obscureText: true,
|
||||
onChanged: (value) {
|
||||
setState(() {});
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey.shade300), borderRadius: BorderRadius.zero),
|
||||
enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey.shade300), borderRadius: BorderRadius.zero),
|
||||
border: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey.shade300), borderRadius: BorderRadius.zero),
|
||||
focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: midColor), borderRadius: BorderRadius.zero),
|
||||
enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: midColor), borderRadius: BorderRadius.zero),
|
||||
border: OutlineInputBorder(borderSide: BorderSide(color: midColor), borderRadius: BorderRadius.zero),
|
||||
hintText: "password...",
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
fillColor: Colors.grey.shade300,
|
||||
fillColor: midColor,
|
||||
filled: true,
|
||||
hintStyle: const TextStyle(fontSize: 12.5, color: Colors.grey)),
|
||||
style: const TextStyle(fontSize: 12.5, color: Colors.grey)),),
|
||||
style: const TextStyle(fontSize: 12.5, color: Colors.black)),),
|
||||
Container(width: 50, height: 50, color: Colors.black, child: const Icon(Icons.password, color: Colors.white))
|
||||
]))),
|
||||
Row( mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
Padding( padding: const EdgeInsets.only(right: 10), child:
|
||||
InkWell(onTap: () { context.pop(); },
|
||||
mouseCursor: SystemMouseCursors.click,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(top: 20),
|
||||
width: MediaQuery.of(context).size.width / 3,
|
||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||
color: const Color.fromRGBO(38, 166, 154, 1),
|
||||
child: const Center( child: Text("LOGIN", style: TextStyle(color: Colors.white, fontSize: 15),))))),
|
||||
])
|
||||
],)));
|
||||
])),
|
||||
Column( children: [
|
||||
Center( child: Padding( padding: EdgeInsets.only(bottom: 10, top: error == null ? 27 : 10), child:
|
||||
error == null ? Container() : Text(error ?? "", style: TextStyle(color: redColor, fontSize: 12.5)))),
|
||||
Row( mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
Padding( padding: const EdgeInsets.only(right: 10, bottom: 30), child:
|
||||
InkWell(onTap: () async {
|
||||
if (usernameCtrl.text == "" || passwordCtrl.text == "") { return; }
|
||||
error = null;
|
||||
setState(() {
|
||||
loading = true;
|
||||
});
|
||||
await AuthService.login(usernameCtrl.text, passwordCtrl.text).catchError( (e) {
|
||||
setState(() {
|
||||
loading = false;
|
||||
error = "Invalid username or password";
|
||||
});
|
||||
});
|
||||
|
||||
if (error == null) {
|
||||
// ignore: use_build_context_synchronously
|
||||
setState(() {
|
||||
loading = true;
|
||||
});
|
||||
context.pop();
|
||||
}
|
||||
},
|
||||
mouseCursor: SystemMouseCursors.click,
|
||||
child: Container(
|
||||
width: getMainWidth(context) / 3,
|
||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||
color: usernameCtrl.text == "" || passwordCtrl.text == "" ? Colors.grey : lightColor,
|
||||
child: Center( child: loading ? SpinKitWave(color: Colors.white, size: 20) : Text("LOGIN", style: TextStyle(
|
||||
color: usernameCtrl.text == "" || passwordCtrl.text == "" ? midColor :Colors.white,
|
||||
fontSize: 15) ))))),
|
||||
])
|
||||
]),
|
||||
],));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/core/services/router.dart';
|
||||
import 'package:oc_front/pages/shared.dart';
|
||||
@@ -9,7 +10,7 @@ class ShallowCreationDialogWidget extends StatefulWidget {
|
||||
GlobalKey<ShallowTextInputWidgetState>? formKey;
|
||||
BuildContext context;
|
||||
bool Function()? canClose;
|
||||
SharedWorkspaceType type = SharedWorkspaceType.workspace;
|
||||
CollaborativeAreaType type = CollaborativeAreaType.workspace;
|
||||
Future<List<Shallow>> Function()? all;
|
||||
Future<void> Function(String)? load;
|
||||
Future<void> Function(Map<String,dynamic>)? create;
|
||||
@@ -25,7 +26,7 @@ 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"));
|
||||
var t = widget.type == CollaborativeAreaType.workspace ? "workspace" : (widget.type == CollaborativeAreaType.workflow ? "workflow" : (widget.type == CollaborativeAreaType.collaborative_area ? "collaborative area" :"peer"));
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
padding: const EdgeInsets.only( top: 0, bottom: 20, left: 20, right: 20),
|
||||
@@ -57,7 +58,8 @@ class ShallowCreationDialogState extends State<ShallowCreationDialogWidget> {
|
||||
ShallowDropdownInputWidget(
|
||||
all: widget.all,
|
||||
type: widget.type,
|
||||
width: MediaQuery.of(context).size.width <= 540 ? MediaQuery.of(context).size.width - 140 : 400,
|
||||
hint: "select a $t",
|
||||
width: getMainWidth(context) <= 540 ? getMainWidth(context) - 140 : 400,
|
||||
load: (e) async {
|
||||
await widget.load!(e);
|
||||
Navigator.pop(widget.context);
|
||||
@@ -71,13 +73,14 @@ class ShallowCreationDialogState extends State<ShallowCreationDialogWidget> {
|
||||
deletion: true,
|
||||
color: Colors.black,
|
||||
hintColor: Colors.grey,
|
||||
filled: Colors.grey.shade300,
|
||||
filled: midColor,
|
||||
),
|
||||
Container( height: 10),
|
||||
ShallowTextInputWidget(
|
||||
widget.create != null ? ShallowTextInputWidget(
|
||||
key: widget.formKey,
|
||||
type: widget.type,
|
||||
width: MediaQuery.of(context).size.width <= 540 ? MediaQuery.of(context).size.width - 140 : 400,
|
||||
hint: "create a new $t",
|
||||
width: getMainWidth(context) <= 540 ? getMainWidth(context) - 140 : 400,
|
||||
load: (e) async {
|
||||
await widget.create!(e);
|
||||
Navigator.pop(widget.context);
|
||||
@@ -86,9 +89,9 @@ class ShallowCreationDialogState extends State<ShallowCreationDialogWidget> {
|
||||
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)),
|
||||
filled: midColor,
|
||||
) : Container(),
|
||||
...(widget.create != null ? widget.form.map( (e) => Container( margin: const EdgeInsets.only(top: 10), child: e)) : []),
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
22
lib/widgets/forms/compute_forms.dart
Normal file
22
lib/widgets/forms/compute_forms.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/widgets/inputs/sub_text_input.dart';
|
||||
|
||||
class ComputeFormsWidget extends StatefulWidget {
|
||||
dynamic item;
|
||||
ComputeFormsWidget ({ super.key, required this.item });
|
||||
@override ComputeFormsWidgetState createState() => ComputeFormsWidgetState();
|
||||
}
|
||||
class ComputeFormsWidgetState extends State<ComputeFormsWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
return Column( children: [
|
||||
SubTextInputWidget(subkey: "technology", width: 180, empty: false, change: (value) {
|
||||
}, initialValue: widget.item.getTechnology(), readOnly: true,),
|
||||
SubTextInputWidget(subkey: "architecture", width: 180, empty: false, change: (value) {
|
||||
}, initialValue: widget.item.architecture, readOnly: true,),
|
||||
SubTextInputWidget(subkey: "access", width: 180, empty: false, change: (value) {
|
||||
}, initialValue: widget.item.getAccess(), readOnly: true,),
|
||||
SubTextInputWidget(subkey: "localisation", width: 180, empty: false, change: (value) {
|
||||
}, initialValue: widget.item.localisation, readOnly: true,),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ class DataFormsWidget extends StatefulWidget {
|
||||
}
|
||||
class DataFormsWidgetState extends State<DataFormsWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
print(widget.item.serialize());
|
||||
return Column( children: [
|
||||
WebReferenceFormsWidget(item: widget.item),
|
||||
]);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
|
||||
import 'package:oc_front/core/services/perms_service.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/models/workflow.dart';
|
||||
import 'package:oc_front/pages/workflow.dart';
|
||||
@@ -18,7 +20,7 @@ class ProcessingFormsWidget extends StatefulWidget {
|
||||
@override ProcessingFormsWidgetState createState() => ProcessingFormsWidgetState();
|
||||
}
|
||||
class ProcessingFormsWidgetState extends State<ProcessingFormsWidget> {
|
||||
Widget getInputAndOutputVariableForms() {
|
||||
Widget getInputAndOutputVariableForms(bool readOnly) {
|
||||
var inList = widget.dash.GetArrowByElementID(widget.elementID, true);
|
||||
var outList = widget.dash.GetArrowByElementID(widget.elementID, false);
|
||||
List<Widget> res = [];
|
||||
@@ -40,16 +42,17 @@ class ProcessingFormsWidgetState extends State<ProcessingFormsWidget> {
|
||||
}
|
||||
if (inItems.isNotEmpty) {
|
||||
res.add(SubKeysMapFormsWidget(dash: widget.dash, isInput: true, item: widget.item, elementID: widget.elementID,
|
||||
categoryKey: "container", varKey: "env", graphItems: inItems));
|
||||
categoryKey: "container", varKey: "env", graphItems: inItems, readOnly: readOnly));
|
||||
}
|
||||
if (outItems.isNotEmpty) {
|
||||
res.add(SubKeysMapFormsWidget(dash: widget.dash, isInput: false, item: widget.item, elementID: widget.elementID,
|
||||
categoryKey: "container", varKey: "env", graphItems: outItems));
|
||||
categoryKey: "container", varKey: "env", graphItems: outItems, readOnly: readOnly));
|
||||
}
|
||||
return Column( children: res );
|
||||
}
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
bool readOnly = !PermsService.getPerm(Perms.WORKFLOW_EDIT);
|
||||
List<Widget> categories = [];
|
||||
var l = widget.item.model?.model?.keys ?? [];
|
||||
for (var child in l) {
|
||||
@@ -59,11 +62,14 @@ class ProcessingFormsWidgetState extends State<ProcessingFormsWidget> {
|
||||
if (sub[st]!.type?.contains("map") ?? false) {
|
||||
children.add(
|
||||
SubMapFormsWidget(dash: dash, empty: children.isEmpty, item: widget.item,
|
||||
readOnly: readOnly,
|
||||
elementID: widget.elementID, categoryKey: child, varKey: st)
|
||||
);
|
||||
} else if (sub[st]!.type == "string") {
|
||||
children.add(SubTextInputWidget(subkey: st, initialValue: widget.item.getVariable([child, st], widget.item.serialize()),
|
||||
width: 200, empty: children.isEmpty, change: (value) {
|
||||
children.add(SubTextInputWidget(subkey: st,
|
||||
readOnly: readOnly,
|
||||
initialValue: widget.item.getVariable([child, st], widget.item.serialize()),
|
||||
width: 180, empty: children.isEmpty, change: (value) {
|
||||
widget.item.model ?? Model();
|
||||
Future.delayed(const Duration(seconds: 2), () {
|
||||
if (widget.item.getVariable([child, st], widget.item.serialize()) == value) {
|
||||
@@ -78,41 +84,40 @@ class ProcessingFormsWidgetState extends State<ProcessingFormsWidget> {
|
||||
}
|
||||
}
|
||||
categories.add(Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
width: 250,
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
width: 180,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text("<${child.toUpperCase()}>", style: const TextStyle(fontSize: 13, fontWeight: FontWeight.bold), textAlign: TextAlign.center),
|
||||
Padding(padding: const EdgeInsets.only(bottom: 10), child: SubTextInputWidget(subkey: "image", width: 200, empty: false, change: (value) {},
|
||||
Padding(padding: const EdgeInsets.only(bottom: 10), child: SubTextInputWidget(subkey: "image", width: 180, empty: false, change: (value) {},
|
||||
initialValue: widget.item.container?.image, readOnly: true,)),
|
||||
...children,
|
||||
getInputAndOutputVariableForms(),
|
||||
getInputAndOutputVariableForms(readOnly),
|
||||
],)
|
||||
));
|
||||
}
|
||||
// EXPOSE
|
||||
categories.add(Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
width: 250,
|
||||
decoration: const BoxDecoration(border: Border(top: BorderSide(color: Colors.grey, width: 1))),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
width: 180,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Padding(padding: EdgeInsets.only(bottom: 5), child: Text("<EXPOSE>",
|
||||
style: TextStyle(fontSize: 13, fontWeight: FontWeight.bold), textAlign: TextAlign.center)),
|
||||
Row( children: [
|
||||
readOnly ? Container() : Row( children: [
|
||||
InkWell( onTap: () {
|
||||
widget.item.expose.add(Expose());
|
||||
var el = dash.getElement(widget.elementID);
|
||||
el!.element = widget.item as dynamic;
|
||||
setState(() {});
|
||||
}, child:
|
||||
Container( margin: const EdgeInsets.only(left: 15, top: 5),
|
||||
Container( margin: const EdgeInsets.only(top: 5),
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), border: Border.all(color: Colors.grey, width: 1)),
|
||||
width: 150, height: 30,
|
||||
width: 125, height: 30,
|
||||
child: const Row( mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [ Padding( padding: EdgeInsets.only(right: 5), child: Icon(Icons.add)), Text("add exposure")]),
|
||||
children: [ Padding( padding: EdgeInsets.only(right: 5), child: Icon(Icons.add)), Text("add expose")]),
|
||||
)
|
||||
),
|
||||
InkWell( onTap: () {
|
||||
@@ -122,7 +127,7 @@ class ProcessingFormsWidgetState extends State<ProcessingFormsWidget> {
|
||||
el!.element = widget.item as dynamic;
|
||||
setState(() {});
|
||||
}, child:
|
||||
Container( margin: const EdgeInsets.only(left: 5, right: 10, top: 5),
|
||||
Container( margin: const EdgeInsets.only(left: 5, top: 5),
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), border: Border.all(color: Colors.grey, width: 1)),
|
||||
width: 45, height: 30,
|
||||
child: const Row( mainAxisAlignment: MainAxisAlignment.center,
|
||||
@@ -133,10 +138,10 @@ class ProcessingFormsWidgetState extends State<ProcessingFormsWidget> {
|
||||
],)
|
||||
));
|
||||
for (var expose in widget.item.expose) {
|
||||
categories.add(SubExposeFormsWidget( width: 200, dash: dash, empty: categories.isEmpty,
|
||||
categories.add(SubExposeFormsWidget( readOnly: readOnly, width: 180, dash: dash, empty: categories.isEmpty,
|
||||
item: expose, elementID: widget.elementID));
|
||||
}
|
||||
return SizedBox( height: MediaQuery.of(context).size.height - 330, child: SingleChildScrollView( child: Column(
|
||||
return SizedBox( height: getHeight(context) - 330, child: SingleChildScrollView( child: Column(
|
||||
children: categories )) );
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,12 @@ import 'package:cron/cron.dart';
|
||||
import 'package:intl/intl.dart' as intl;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
|
||||
import 'package:flutter_advanced_switch/flutter_advanced_switch.dart';
|
||||
import 'package:datetime_picker_formfield/datetime_picker_formfield.dart';
|
||||
import 'package:oc_front/core/models/shared_workspace_local.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/core/services/specialized_services/check_service.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:oc_front/pages/shared.dart';
|
||||
import 'package:oc_front/pages/workflow.dart';
|
||||
import 'package:oc_front/widgets/dialog/alert.dart';
|
||||
@@ -18,6 +18,9 @@ class SchedulerFormsWidget extends StatefulWidget {
|
||||
Dashboard item;
|
||||
String purpose = "";
|
||||
bool? booking;
|
||||
String? error;
|
||||
String? errorEndDate;
|
||||
String? errorCron;
|
||||
Function validate = () {};
|
||||
SchedulerFormsWidget ({ super.key, required this.item, });
|
||||
@override SchedulerFormsWidgetState createState() => SchedulerFormsWidgetState();
|
||||
@@ -26,9 +29,12 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
|
||||
CheckService check = CheckService();
|
||||
void save(List<GlobalKey<FormFieldState>> formKeys) {
|
||||
dash.scheduleActive = !dash.scheduleActive;
|
||||
widget.error = null;
|
||||
widget.errorEndDate = null;
|
||||
widget.errorCron = null;
|
||||
for (var k in formKeys) {
|
||||
if (k.currentState != null) {
|
||||
if (!k.currentState!.validate()) {
|
||||
if (!k.currentState!.validate() && dash.scheduleActive) {
|
||||
dash.scheduleActive = !dash.scheduleActive;
|
||||
return;
|
||||
} else { k.currentState!.save();}
|
||||
@@ -41,7 +47,6 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
|
||||
dash.scheduler["end"] = now.add(const Duration(minutes: 1)).toUtc().toIso8601String();
|
||||
}
|
||||
}
|
||||
print(widget.item.id);
|
||||
widget.item.save!(widget.item.id);
|
||||
}
|
||||
void checkBooking(List<GlobalKey<FormFieldState>> formKeys, void Function(List<GlobalKey<FormFieldState>> )? f){
|
||||
@@ -60,9 +65,7 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
|
||||
(v) {
|
||||
if (v.data == null) { return; }
|
||||
widget.booking = v.data!.is_available;
|
||||
print(v.data!.is_available);
|
||||
if (v.data!.is_available) {
|
||||
print(f);
|
||||
if (f != null) { f(formKeys);
|
||||
} else {
|
||||
showAlertBanner( context, () {},
|
||||
@@ -80,11 +83,13 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
|
||||
}
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
bool isService = true;
|
||||
try {
|
||||
if (widget.item.scheduler["mode"] == null) { widget.item.scheduler["mode"] = 1; }
|
||||
widget.item.elements.firstWhere((element) => (element.element?.serialize()["is_service"] ?? false) == true);
|
||||
} catch (e) {
|
||||
widget.item.scheduler = { "mode": 1 };
|
||||
isService = false;
|
||||
}
|
||||
bool readOnly = !PermsService.getPerm(Perms.WORKFLOW_EDIT);
|
||||
DateTime? start;
|
||||
DateTime? end;
|
||||
if (widget.item.scheduler["start"] != null) {
|
||||
@@ -101,14 +106,13 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
|
||||
widget.item.scheduler["end"] = end.toUtc().toIso8601String();
|
||||
}
|
||||
}
|
||||
List<GlobalKey<FormFieldState>> formKeys = [GlobalKey<FormFieldState>(), GlobalKey<FormFieldState>(),
|
||||
GlobalKey<FormFieldState>(), GlobalKey<FormFieldState>()];
|
||||
List<GlobalKey<FormFieldState>> formKeys = [GlobalKey<FormFieldState>(), GlobalKey<FormFieldState>(), GlobalKey<FormFieldState>(), GlobalKey<FormFieldState>()];
|
||||
var shallow = ShallowTextInputWidget(
|
||||
width: 250 - 1,
|
||||
width: 200 - 1, readOnly: readOnly,
|
||||
current: widget.item.name,
|
||||
type: SharedWorkspaceType.workflow,
|
||||
canRemove: (p0) => p0 != null && p0.isNotEmpty,
|
||||
remove: (p0) async {
|
||||
type: CollaborativeAreaType.workflow,
|
||||
canRemove: PermsService.getPerm(Perms.WORKFLOW_DELETE) ? (p0) => p0 != null && p0.isNotEmpty : null,
|
||||
remove: PermsService.getPerm(Perms.WORKFLOW_DELETE) ? (p0) async {
|
||||
await WorflowService().delete(context, widget.item.id ?? "", {}).then((value) {
|
||||
dash.id = null;
|
||||
dash.name = "";
|
||||
@@ -116,7 +120,7 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
|
||||
dash.clear();
|
||||
dash.chartKey.currentState?.widget.flowChart.setState(() { });
|
||||
});
|
||||
},
|
||||
} : null,
|
||||
);
|
||||
shallow.change =(p0) => Future.delayed( const Duration(seconds: 2), () async {
|
||||
if (shallow.compare == p0) {
|
||||
@@ -126,7 +130,7 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
|
||||
}
|
||||
});
|
||||
return Column( children: [
|
||||
Container( padding: const EdgeInsets.all(10), width: 250, height: 60,
|
||||
Container( padding: const EdgeInsets.all(10), width: 200, height: 60,
|
||||
decoration: const BoxDecoration(border: Border(bottom: BorderSide(color: Colors.grey, width: 1))),
|
||||
child: const Column( mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
Text("WORKFLOW INFO", style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold), textAlign: TextAlign.center),
|
||||
@@ -134,32 +138,17 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
|
||||
])),
|
||||
widget.item.name == "" ? Container() : Container(
|
||||
decoration: BoxDecoration( border: Border(
|
||||
left: BorderSide(color: Colors.grey.shade300, width: 1),
|
||||
left: BorderSide(color: midColor, width: 1),
|
||||
bottom: const BorderSide(color: Colors.grey))),
|
||||
child: shallow ),
|
||||
const SizedBox(height: 20, width: 250 ),
|
||||
AdvancedSwitch(
|
||||
width: 140,
|
||||
initialValue: widget.item.scheduler["mode"] == 1,
|
||||
activeColor: Colors.green, inactiveColor: Colors.green,
|
||||
activeChild: const Text("simple task", style: TextStyle(color: Colors.white)),
|
||||
inactiveChild: const Text("cron task", style: TextStyle(color: Colors.white)),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(15)), height: 30.0, disabledOpacity: 0.5,
|
||||
onChanged: (value) {
|
||||
Future.delayed(const Duration(milliseconds: 100), () =>
|
||||
setState(() {
|
||||
widget.item.scheduler["mode"] = value == true ? 1 : 0;
|
||||
if ((widget.item.scheduler["mode"] == 1 )) { widget.item.scheduler.remove("cron"); }
|
||||
widget.item.save!(widget.item.id);
|
||||
}));
|
||||
},),
|
||||
Container(height: 5),
|
||||
Tooltip( message: "event name",
|
||||
const SizedBox(height: 20, width: 200 ),
|
||||
isService ? Text("Warning a processing is a service, if no end execution it will run forever.") : Container(),
|
||||
Tooltip( message: "executions name",
|
||||
child: Container( height: 40, margin: const EdgeInsets.only(top: 5),
|
||||
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 20),
|
||||
child: TextFormField( key: formKeys[0],
|
||||
initialValue: "${widget.item.scheduler["mode"] == 1 ? "" : "cron_"}${widget.item.scheduler["name"] ?? "${widget.item.name}_event"}",
|
||||
enabled: !dash.scheduleActive,
|
||||
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
|
||||
child: TextFormField( key: formKeys[0], readOnly: readOnly,
|
||||
initialValue: "${widget.item.scheduler["name"] ?? "${widget.item.name}_executions"}",
|
||||
enabled: !dash.scheduleActive && !readOnly,
|
||||
onChanged: (value) {
|
||||
Future.delayed(const Duration(seconds: 100), () {
|
||||
if (widget.item.scheduler["name"] == value) {
|
||||
@@ -169,30 +158,36 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
|
||||
widget.item.scheduler["name"] = value;
|
||||
},
|
||||
onSaved: (value) {
|
||||
widget.item.scheduler["name"] = value ?? "${widget.item.scheduler["mode"] == 1 ? "" : "cron_"}${widget.item.scheduler["name"] ?? "${widget.item.name}_event"}";
|
||||
widget.item.scheduler["name"] = value ?? "${widget.item.scheduler["name"] ?? "${widget.item.name}_executions"}";
|
||||
},
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
setState(() { widget.error = 'missing name'; });
|
||||
}
|
||||
return value == null || value.isEmpty ? "not empty" : null;
|
||||
},
|
||||
validator: (value) => value == null || value.isEmpty ? "not empty" : null,
|
||||
style: const TextStyle(fontSize: 12),
|
||||
decoration: const InputDecoration(
|
||||
decoration: InputDecoration(
|
||||
floatingLabelBehavior: FloatingLabelBehavior.always,
|
||||
fillColor: Colors.white,
|
||||
filled: true,
|
||||
hintText: "enter event name...",
|
||||
labelText: "event name*",
|
||||
errorStyle: TextStyle(fontSize: 0),
|
||||
hintText: "enter executions name...",
|
||||
labelText: "executions name*",
|
||||
hintStyle: TextStyle(fontSize: 10),
|
||||
labelStyle: TextStyle(fontSize: 10),
|
||||
error: null,
|
||||
enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
|
||||
border: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
|
||||
focusedErrorBorder: OutlineInputBorder(borderSide: BorderSide(color: widget.error != null ? Colors.red : Colors.black)),
|
||||
errorBorder: OutlineInputBorder(borderSide: BorderSide(color: widget.error != null ? Colors.red : Colors.black)),
|
||||
focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: widget.error != null ? Colors.red : Colors.black)),
|
||||
enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: widget.error != null ? Colors.red : Colors.grey)),
|
||||
border: OutlineInputBorder(borderSide: BorderSide(color: widget.error != null ? Colors.red : Colors.grey)),
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
),
|
||||
))),
|
||||
Tooltip( message: "start event",
|
||||
Tooltip( message: "start executions",
|
||||
child: Container( height: 40, margin: const EdgeInsets.only(top: 5),
|
||||
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 20),
|
||||
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
|
||||
child: DateTimeField( key: formKeys[1],
|
||||
enabled: !dash.scheduleActive,
|
||||
enabled: !dash.scheduleActive && !readOnly,
|
||||
resetIcon: null,
|
||||
onShowPicker: (context, currentValue) async {
|
||||
var date = await showDatePicker(
|
||||
@@ -202,7 +197,7 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
|
||||
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),
|
||||
@@ -236,7 +231,7 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
|
||||
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),
|
||||
@@ -258,16 +253,17 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
|
||||
format: intl.DateFormat('y-M-dd HH:mm:ss'),
|
||||
initialValue: start?.toLocal() ?? DateTime.now(),
|
||||
onChanged: (value) { },
|
||||
validator: (value) => value == null ? "not empty" : null,
|
||||
validator: (value) {
|
||||
return value == null ? "not empty" : null;
|
||||
},
|
||||
style: const TextStyle(fontSize: 12),
|
||||
decoration: const InputDecoration(
|
||||
floatingLabelBehavior: FloatingLabelBehavior.always,
|
||||
fillColor: Colors.white,
|
||||
filled: true,
|
||||
alignLabelWithHint: false,
|
||||
hintText: "enter start event...",
|
||||
labelText: "start event*",
|
||||
errorStyle: TextStyle(fontSize: 0),
|
||||
hintText: "enter start executions...",
|
||||
labelText: "start executions*",
|
||||
hintStyle: TextStyle(fontSize: 10),
|
||||
labelStyle: TextStyle(fontSize: 10),
|
||||
enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
|
||||
@@ -275,13 +271,18 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
),
|
||||
))),
|
||||
Tooltip( message: "end event",
|
||||
Tooltip( message: "end executions",
|
||||
child: Container( height: 40, margin: const EdgeInsets.only(top: 5),
|
||||
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 20),
|
||||
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
|
||||
child: DateTimeField( key: formKeys[2],
|
||||
enabled: !dash.scheduleActive,
|
||||
enabled: !dash.scheduleActive && !readOnly,
|
||||
validator: (value) {
|
||||
return value == null && !(widget.item.scheduler["mode"] == 1 ) ? "not empty" : null;
|
||||
if (value == null && widget.item.scheduler["cron"] != null && widget.item.scheduler["cron"].isNotEmpty) {
|
||||
setState(() {
|
||||
widget.errorEndDate = 'missing start date';
|
||||
});
|
||||
}
|
||||
return value == null && widget.item.scheduler["cron"] != null && widget.item.scheduler["cron"].isNotEmpty ? "not empty" : null;
|
||||
},
|
||||
onChanged: (value) {
|
||||
if (value == null) {
|
||||
@@ -297,7 +298,7 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
|
||||
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),
|
||||
@@ -321,11 +322,12 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
|
||||
while(date!.microsecondsSinceEpoch <= (DateTime.now().microsecondsSinceEpoch)
|
||||
|| time == null
|
||||
|| (date.microsecondsSinceEpoch) <= (DateTime.parse(widget.item.scheduler["start"] ?? DateTime.now().toIso8601String()).microsecondsSinceEpoch)) {
|
||||
if (count > 0) {
|
||||
showAlertBanner( context, () {},
|
||||
if (count > 0) {
|
||||
showAlertBanner( context, () {}, // ignore: use_build_context_synchronously
|
||||
const AlertAlertBannerChild(text: "must be at least 1 minute from now to let system check info && upper starting date"),// <-- Put any widget here you want!
|
||||
alertBannerLocation: AlertBannerLocation.bottom,);
|
||||
}
|
||||
// ignore: use_build_context_synchronously
|
||||
time = await showTimePicker(context: context,
|
||||
initialTime: TimeOfDay(hour: date.hour, minute: date.minute),
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
@@ -334,7 +336,7 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
|
||||
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),
|
||||
@@ -361,21 +363,23 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
|
||||
floatingLabelBehavior: FloatingLabelBehavior.always,
|
||||
filled: true,
|
||||
alignLabelWithHint: false,
|
||||
hintText: "enter end event...",
|
||||
labelText: "end event${!(widget.item.scheduler["mode"] == 1) ? "*" : ""}",
|
||||
errorStyle: const TextStyle(fontSize: 0),
|
||||
hintText: "enter end executions...",
|
||||
labelText: "end executions",
|
||||
hintStyle: const TextStyle(fontSize: 10),
|
||||
labelStyle: const TextStyle(fontSize: 10),
|
||||
enabledBorder: const OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
|
||||
border: const OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
|
||||
focusedErrorBorder: OutlineInputBorder(borderSide: BorderSide(color: widget.errorEndDate != null ? Colors.red : Colors.black)),
|
||||
errorBorder: OutlineInputBorder(borderSide: BorderSide(color: widget.errorEndDate != null ? Colors.red : Colors.black)),
|
||||
focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: widget.errorEndDate != null ? Colors.red : Colors.black)),
|
||||
enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: widget.errorEndDate != null ? Colors.red : Colors.grey)),
|
||||
border: OutlineInputBorder(borderSide: BorderSide(color: widget.errorEndDate != null ? Colors.red : Colors.grey)),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
),
|
||||
))),
|
||||
widget.item.scheduler["mode"] == 1 ? Container() : Tooltip( message: "schedule",
|
||||
Tooltip( message: "cron command",
|
||||
child: Container( height: 40, margin: const EdgeInsets.only(top: 5),
|
||||
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 20),
|
||||
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
|
||||
child: TextFormField( key: formKeys[3],
|
||||
enabled: !dash.scheduleActive,
|
||||
enabled: !dash.scheduleActive && !readOnly,
|
||||
initialValue: widget.item.scheduler["cron"],
|
||||
onChanged: (value) {
|
||||
Future.delayed(const Duration(seconds: 100), () {
|
||||
@@ -392,58 +396,67 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
|
||||
},
|
||||
validator: (value) {
|
||||
var cron = Cron();
|
||||
try {
|
||||
cron.schedule(Schedule.parse(value ?? ""), () {});
|
||||
} catch (e) {
|
||||
return "invalid cron";
|
||||
if (value != null && value.isNotEmpty) {
|
||||
try {
|
||||
cron.schedule(Schedule.parse(value), () {});
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
widget.errorCron = e.toString();
|
||||
});
|
||||
return "invalid cron";
|
||||
}
|
||||
}
|
||||
return value == null || value.isEmpty ? "not empty" : null;
|
||||
return null;
|
||||
},
|
||||
style: const TextStyle(fontSize: 12),
|
||||
decoration: const InputDecoration(
|
||||
decoration: InputDecoration(
|
||||
floatingLabelBehavior: FloatingLabelBehavior.always,
|
||||
fillColor: Colors.white,
|
||||
filled: true,
|
||||
hintText: "enter schedule...",
|
||||
labelText: "schedule*",
|
||||
errorStyle: TextStyle(fontSize: 0),
|
||||
hintText: "enter cron command...",
|
||||
labelText: "cron",
|
||||
errorStyle: TextStyle(height: 0),
|
||||
hintStyle: TextStyle(fontSize: 10),
|
||||
labelStyle: TextStyle(fontSize: 10),
|
||||
error: null,
|
||||
enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
|
||||
border: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
|
||||
focusedErrorBorder: OutlineInputBorder(borderSide: BorderSide(color: widget.errorCron != null ? Colors.red : Colors.black)),
|
||||
errorBorder: OutlineInputBorder(borderSide: BorderSide(color: widget.errorCron != null ? Colors.red : Colors.black)),
|
||||
focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: widget.errorCron != null ? Colors.red : Colors.black)),
|
||||
enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: widget.errorCron != null ? Colors.red : Colors.grey)),
|
||||
border: OutlineInputBorder(borderSide: BorderSide(color: widget.errorCron != null ? Colors.red : Colors.grey)),
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
),
|
||||
))),
|
||||
Container(
|
||||
width: 250,
|
||||
width: 200,
|
||||
height: 20,
|
||||
decoration: const BoxDecoration(border: Border(bottom: BorderSide(color: Colors.grey, width: 1))),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 250,
|
||||
width: 200,
|
||||
height: 10,
|
||||
),
|
||||
Tooltip( message: "check booking",
|
||||
child: InkWell( mouseCursor: SystemMouseCursors.click,
|
||||
onTap: () {
|
||||
checkBooking(formKeys, null);
|
||||
}, child: Container( margin: const EdgeInsets.only(bottom: 5),
|
||||
PermsService.getPerm(Perms.WORKFLOW_BOOKING) ? checkBooking(formKeys, null) : null;
|
||||
}, child: Container( margin: const EdgeInsets.only(bottom: 5, left: 10, right: 10),
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(5),
|
||||
border: Border.all(color: widget.booking == null && !dash.scheduleActive ? Colors.black : (widget.booking == true || dash.scheduleActive ? Colors.green : Colors.red), width: 1)),
|
||||
border: Border.all(color: widget.booking == null && !dash.scheduleActive ? (
|
||||
PermsService.getPerm(Perms.WORKFLOW_BOOKING) && PermsService.getPerm(Perms.WORKFLOW_EDIT) ? Colors.black : Colors.grey) : (
|
||||
widget.booking == true || dash.scheduleActive ? Colors.green : redColor), width: 1)),
|
||||
width: 200, height: 30,
|
||||
child: Icon(
|
||||
Icons.verified_outlined,
|
||||
color: widget.booking == null && !dash.scheduleActive ? Colors.black : (widget.booking == true || dash.scheduleActive ? Colors.green : Colors.red)),
|
||||
color: widget.booking == null && !dash.scheduleActive ? Colors.black : (widget.booking == true || dash.scheduleActive ? Colors.green : redColor)),
|
||||
))
|
||||
),
|
||||
Tooltip( message: dash.scheduleActive ? "unbook" : "book",
|
||||
child: InkWell( mouseCursor: SystemMouseCursors.click,
|
||||
onTap: () {
|
||||
dash.scheduleActive ? setState(() { save(formKeys); }) : checkBooking(formKeys, save);
|
||||
PermsService.getPerm(Perms.WORKFLOW_BOOKING) && PermsService.getPerm(Perms.WORKFLOW_EDIT) ? (dash.scheduleActive ? setState(() { save(formKeys); }) : checkBooking(formKeys, save)) : null;
|
||||
}, child: Container( margin: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(5),
|
||||
border: Border.all(color: dash.scheduleActive ? Colors.green : Colors.black)),
|
||||
border: Border.all(color: dash.scheduleActive ? Colors.green : ( PermsService.getPerm(Perms.WORKFLOW_BOOKING) ?Colors.black : Colors.grey ))),
|
||||
width: 200, height: 30,
|
||||
child: Icon(
|
||||
dash.scheduleActive ? Icons.cancel_schedule_send : Icons.schedule_send, color: dash.scheduleActive ? Colors.green : Colors.black),
|
||||
@@ -452,17 +465,17 @@ class SchedulerFormsWidgetState extends State<SchedulerFormsWidget> {
|
||||
widget.item.info["shared"] != null && (widget.item.info["shared"] as List<dynamic>).isNotEmpty ? Column( children: [
|
||||
Container(
|
||||
height: 20,
|
||||
width: 250,
|
||||
width: 200,
|
||||
decoration: const BoxDecoration(border: Border(top: BorderSide(color: Colors.black))),
|
||||
),
|
||||
Container( alignment: Alignment.center, padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
Container( alignment: Alignment.center, padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child:Text( textAlign: TextAlign.center, overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontSize: 14, color: Colors.black, fontWeight: FontWeight.bold),
|
||||
"Workflow is shared in ${(widget.item.info["shared"] as List<dynamic>).length} workspace(s)")),
|
||||
...(widget.item.info["shared"] as List<dynamic>).where( (e) => SharedWorkspaceLocal.getSharedWorkspace(e) != null
|
||||
...(widget.item.info["shared"] as List<dynamic>).where( (e) => CollaborativeAreaLocal.getCollaborativeArea(e) != null
|
||||
).map((e) {
|
||||
var sw = SharedWorkspaceLocal.getSharedWorkspace(e);
|
||||
return Container( alignment: Alignment.center, padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 5),
|
||||
var sw = CollaborativeAreaLocal.getCollaborativeArea(e);
|
||||
return Container( alignment: Alignment.center, padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
child: Row( children: [
|
||||
const Padding(padding: EdgeInsets.only(right: 10), child: Icon(Icons.work, color: Colors.grey, size: 15)),
|
||||
Text(style: const TextStyle(fontSize: 12, color: Colors.grey),
|
||||
|
||||
@@ -5,12 +5,13 @@ import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/widgets/inputs/sub_text_input.dart';
|
||||
|
||||
class SubExposeFormsWidget extends StatefulWidget {
|
||||
bool readOnly;
|
||||
Expose item;
|
||||
Dashboard dash;
|
||||
String elementID = "";
|
||||
double width = 200;
|
||||
double width = 180;
|
||||
bool empty = false;
|
||||
SubExposeFormsWidget ({ super.key, required this.dash,
|
||||
SubExposeFormsWidget ({ super.key, required this.dash, this.readOnly = false,
|
||||
this.empty = false, required this.item, required this.elementID, required this.width });
|
||||
@override SubExposeFormsWidgetState createState() => SubExposeFormsWidgetState();
|
||||
}
|
||||
@@ -19,9 +20,10 @@ class SubExposeFormsWidgetState extends State<SubExposeFormsWidget> {
|
||||
return Column( children : [
|
||||
Container( margin: const EdgeInsets.only(left: 10, right: 10, top: 5),
|
||||
decoration: BoxDecoration(border: Border.all(color: Colors.grey, width: 1)),
|
||||
width: 250
|
||||
width: 180
|
||||
),
|
||||
SubTextInputWidget(subkey: "reference port", initialValue: widget.item.port != null ? '${widget.item.port}' : null,
|
||||
SubTextInputWidget(subkey: "reference port", readOnly: widget.readOnly,
|
||||
initialValue: widget.item.port != null ? '${widget.item.port}' : null,
|
||||
width: widget.width, empty: widget.empty, change: (value) {
|
||||
try {
|
||||
widget.item.port = int.parse(value);
|
||||
@@ -34,7 +36,9 @@ class SubExposeFormsWidgetState extends State<SubExposeFormsWidget> {
|
||||
var el = widget.dash.getElement(widget.elementID);
|
||||
el!.element = widget.item as dynamic;
|
||||
}),
|
||||
SubTextInputWidget(subkey: "PAT", initialValue: widget.item.PAT != null ? '${widget.item.PAT}' : null,
|
||||
SubTextInputWidget(
|
||||
readOnly: widget.readOnly,
|
||||
subkey: "PAT", initialValue: widget.item.PAT != null ? '${widget.item.PAT}' : null,
|
||||
width: widget.width, empty: widget.empty, change: (value) {
|
||||
try {
|
||||
widget.item.PAT = int.parse(value);
|
||||
@@ -48,6 +52,7 @@ class SubExposeFormsWidgetState extends State<SubExposeFormsWidget> {
|
||||
el!.element = widget.item as dynamic;
|
||||
}),
|
||||
SubTextInputWidget(subkey: "reverse path", initialValue: widget.item.PAT != null ? '${widget.item.PAT}' : null,
|
||||
readOnly: widget.readOnly,
|
||||
width: widget.width, empty: widget.empty, change: (value) {
|
||||
try {
|
||||
widget.item.path = value;
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:oc_front/models/workflow.dart';
|
||||
import 'package:oc_front/widgets/inputs/sub_text_input.dart';
|
||||
|
||||
class SubKeysMapFormsWidget extends StatefulWidget {
|
||||
bool readOnly = false;
|
||||
FlowData item;
|
||||
Dashboard dash;
|
||||
String varKey = "";
|
||||
@@ -14,7 +15,7 @@ class SubKeysMapFormsWidget extends StatefulWidget {
|
||||
String elementID = "";
|
||||
String categoryKey = "";
|
||||
List<GraphItem> graphItems = [];
|
||||
SubKeysMapFormsWidget({ super.key, required this.dash, required this.isInput,
|
||||
SubKeysMapFormsWidget({ super.key, required this.dash, required this.isInput, this.readOnly = false,
|
||||
this.empty = false, required this.item, required this.elementID, required this.graphItems,
|
||||
required this.categoryKey, required this.varKey });
|
||||
@override SubKeysMapFormsWidgetState createState() => SubKeysMapFormsWidgetState();
|
||||
@@ -31,7 +32,7 @@ class SubKeysMapFormsWidgetState extends State<SubKeysMapFormsWidget> {
|
||||
if (el == null || el.model == null) { continue; }
|
||||
for ( var r in el.model!.refs.keys) {
|
||||
var env = widget.item.getVariable(["container", "env"], widget.item.serialize());
|
||||
if (env == null && env is Map<String, dynamic>) { continue; }
|
||||
if (env == null || env is Map<String, dynamic>) { continue; }
|
||||
var n = "${el.topic.toUpperCase()}_${el.getName().toUpperCase().replaceAll(" ", "_")}_${r.toUpperCase()}_$count";
|
||||
if (env[n] == null) {
|
||||
save = true;
|
||||
@@ -39,7 +40,8 @@ class SubKeysMapFormsWidgetState extends State<SubKeysMapFormsWidget> {
|
||||
env[n]= "{{ ${ widget.isInput ? "in" : "out" }_${graphItem.id}_$r }}";
|
||||
widget.item.setVariable(["container", "env"], env, el.serialize());
|
||||
children.add( Padding(padding: const EdgeInsets.only(bottom: 10),
|
||||
child: SubTextInputWidget(subkey: n, width: 200, empty: false, change: (value) {}, initialValue: n, readOnly: true, noLabel: true)));
|
||||
child: SubTextInputWidget(subkey: n, width: 180, empty: false, change: (value) {},
|
||||
initialValue: n, readOnly: true, noLabel: true)));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -50,7 +52,7 @@ class SubKeysMapFormsWidgetState extends State<SubKeysMapFormsWidget> {
|
||||
return Container();
|
||||
}
|
||||
return Column( children : [
|
||||
Container(width: 250, padding: const EdgeInsets.only(top: 10, bottom: 10),
|
||||
Container(width: 200, padding: const EdgeInsets.only(top: 10, bottom: 10),
|
||||
decoration: const BoxDecoration(border: Border(bottom: BorderSide(color: Colors.grey, width: 1)))),
|
||||
Padding( padding: const EdgeInsets.only(top: 10),
|
||||
child: Text("<${widget.isInput ? "INPUT ENV VARIABLE" : "OUTPUT ENV VARIABLE"}>", style: const TextStyle(fontSize: 13, fontWeight: FontWeight.bold),
|
||||
|
||||
@@ -10,6 +10,7 @@ class MapForm {
|
||||
}
|
||||
|
||||
class SubMapFormsWidget extends StatefulWidget {
|
||||
bool readOnly;
|
||||
String categoryKey = "";
|
||||
String varKey = "";
|
||||
String elementID = "";
|
||||
@@ -17,7 +18,7 @@ class SubMapFormsWidget extends StatefulWidget {
|
||||
Dashboard dash;
|
||||
bool empty = false;
|
||||
List<MapForm> forms = [];
|
||||
SubMapFormsWidget ({ super.key, required this.dash,
|
||||
SubMapFormsWidget ({ super.key, required this.dash, this.readOnly = false,
|
||||
this.empty = false, required this.item, required this.elementID,
|
||||
required this.categoryKey, required this.varKey });
|
||||
@override SubMapFormsWidgetState createState() => SubMapFormsWidgetState();
|
||||
@@ -44,8 +45,9 @@ class SubMapFormsWidgetState extends State<SubMapFormsWidget> {
|
||||
continue;
|
||||
}
|
||||
widget.forms.add(MapForm(key: key, value: m[key]));
|
||||
children.add(Padding( padding: const EdgeInsets.symmetric(horizontal: 15), child: Row( children: [
|
||||
SubTextInputWidget(subkey: "key", initialValue: key, width: 91, empty: widget.empty,
|
||||
children.add(Row( children: [
|
||||
SubTextInputWidget(subkey: "key", readOnly: widget.readOnly,
|
||||
initialValue: key, width: 77.5, empty: widget.empty,
|
||||
change: (value) {
|
||||
setState(() {
|
||||
widget.forms[i].key = value;
|
||||
@@ -58,8 +60,8 @@ class SubMapFormsWidgetState extends State<SubMapFormsWidget> {
|
||||
});
|
||||
}),
|
||||
const Padding(padding: EdgeInsets.only(left: 5, right: 5, top: 15), child: Text("=", textAlign: TextAlign.center,)),
|
||||
SubTextInputWidget(subkey: "value", initialValue: widget.forms[i].value, width: 90.8, empty: widget.empty,
|
||||
change: (value) {
|
||||
SubTextInputWidget(subkey: "value", initialValue: widget.forms[i].value, width: 77.5, empty: widget.empty,
|
||||
readOnly: widget.readOnly, change: (value) {
|
||||
Future.delayed(const Duration(seconds: 2), () {
|
||||
widget.dash.save!(widget.dash.id);
|
||||
});
|
||||
@@ -69,13 +71,13 @@ class SubMapFormsWidgetState extends State<SubMapFormsWidget> {
|
||||
widget.item.setVariable(l, toMap(), widget.item.serialize())) as dynamic;
|
||||
el!.element = widget.item as dynamic;
|
||||
}),
|
||||
])));
|
||||
]));
|
||||
i++;
|
||||
}
|
||||
return Column( children : [
|
||||
Container(width: 250, padding: const EdgeInsets.only(top: 10),
|
||||
Container(width: 200, padding: const EdgeInsets.only(top: 10),
|
||||
decoration: const BoxDecoration(border: Border(bottom: BorderSide(color: Colors.grey, width: 1))),),
|
||||
Row( children: [
|
||||
widget.readOnly ? Container() : Row( children: [
|
||||
InkWell( onTap: () {
|
||||
widget.forms.add(MapForm(key: "", value: ""));
|
||||
var el = widget.dash.getElement(widget.elementID);
|
||||
@@ -83,9 +85,9 @@ class SubMapFormsWidgetState extends State<SubMapFormsWidget> {
|
||||
widget.item.setVariable(l, toMap(), widget.item.serialize())) as dynamic;
|
||||
el!.element = widget.item as dynamic;
|
||||
setState(() {});
|
||||
}, child: Container( margin: const EdgeInsets.only(left: 15, top: 10),
|
||||
}, child: Container( margin: const EdgeInsets.only(top: 10),
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), border: Border.all(color: Colors.grey, width: 1)),
|
||||
width: 150, height: 30,
|
||||
width: 125, height: 30,
|
||||
child: Row( mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [ const Padding( padding: EdgeInsets.only(right: 5), child: Icon(Icons.add)), Text("add ${widget.varKey} vars")]),
|
||||
),
|
||||
@@ -99,7 +101,7 @@ class SubMapFormsWidgetState extends State<SubMapFormsWidget> {
|
||||
el!.element = widget.item as dynamic;
|
||||
setState(() { widget.dash.save!(widget.dash.id); });
|
||||
}, child:
|
||||
Container( margin: const EdgeInsets.only(left: 5, right: 10, top: 10),
|
||||
Container( margin: const EdgeInsets.only(left: 5, top: 10),
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), border: Border.all(color: Colors.grey, width: 1)),
|
||||
width: 45, height: 30,
|
||||
child: const Row( mainAxisAlignment: MainAxisAlignment.center,
|
||||
|
||||
@@ -9,14 +9,14 @@ class WebReferenceFormsWidget extends StatefulWidget {
|
||||
class WebReferenceFormsWidgetState extends State<WebReferenceFormsWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
return Column( children: [
|
||||
SubTextInputWidget(subkey: "path", width: 200, empty: false, change: (value) {
|
||||
widget.item.protocols = value.split(",");
|
||||
SubTextInputWidget(subkey: "path", width: 180, empty: false, change: (value) {
|
||||
widget.item.path = value.split(",");
|
||||
}, initialValue: widget.item.path, readOnly: true,),
|
||||
SubTextInputWidget(subkey: "protocol", width: 200, empty: false, change: (value) {
|
||||
widget.item.protocols = value.split(",");
|
||||
SubTextInputWidget(subkey: "protocol", width: 180, empty: false, change: (value) {
|
||||
widget.item.protocol = value.split(",");
|
||||
}, initialValue: widget.item.protocol, readOnly: true,),
|
||||
SubTextInputWidget(subkey: "type", width: 200, empty: false, change: (value) {
|
||||
widget.item.protocols = value.split(",");
|
||||
SubTextInputWidget(subkey: "type", width: 180, empty: false, change: (value) {
|
||||
widget.item.type = value.split(",");
|
||||
}, initialValue: widget.item.type, readOnly: true,),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/pages/shared.dart';
|
||||
|
||||
class ShallowDropdownInputWidget extends StatefulWidget {
|
||||
double? width;
|
||||
SharedWorkspaceType type = SharedWorkspaceType.workspace;
|
||||
CollaborativeAreaType type = CollaborativeAreaType.workspace;
|
||||
Future<List<Shallow>> Function()? all;
|
||||
Future<void> Function(String)? load;
|
||||
Future<void> Function(String)? remove;
|
||||
@@ -13,7 +14,7 @@ class ShallowDropdownInputWidget extends StatefulWidget {
|
||||
void Function(String?)? change;
|
||||
DropdownMenuItem Function(Shallow)? maptoDropdown;
|
||||
String? current;
|
||||
|
||||
Widget? prefixIcon;
|
||||
IconData? iconLoad;
|
||||
IconData? iconRemove;
|
||||
|
||||
@@ -28,7 +29,7 @@ class ShallowDropdownInputWidget extends StatefulWidget {
|
||||
|
||||
bool deletion = false;
|
||||
|
||||
ShallowDropdownInputWidget ({ Key? key, this.width, this.current, required this.all,
|
||||
ShallowDropdownInputWidget ({ Key? key, this.width, this.current, required this.all, this.prefixIcon,
|
||||
this.iconLoad, this.iconRemove, this.hint, this.filled, this.hintColor, this.color,
|
||||
this.tooltipLoad, this.tooltipRemove, this.deletion = false, this.maptoDropdown,
|
||||
required this.type, this.canLoad, this.canRemove, this.load, this.remove, this.change }): super(key: key);
|
||||
@@ -39,7 +40,7 @@ class ShallowDropdownInputWidgetState extends State<ShallowDropdownInputWidget>
|
||||
if (widget.deletion && widget.remove == null) {
|
||||
widget.remove =(p0) async => widget.current = null;
|
||||
}
|
||||
var t = widget.type == SharedWorkspaceType.workspace ? "workspace" : (widget.type == SharedWorkspaceType.workflow ? "workflow" : "peer");
|
||||
var t = widget.type == CollaborativeAreaType.workspace ? "workspace" : (widget.type == CollaborativeAreaType.workflow ? "workflow" : "peer");
|
||||
return FutureBuilder(future: widget.all!(), builder: (b, s) {
|
||||
List<DropdownMenuItem> items = [];
|
||||
if (widget.maptoDropdown != null) {
|
||||
@@ -53,7 +54,7 @@ class ShallowDropdownInputWidgetState extends State<ShallowDropdownInputWidget>
|
||||
data: Theme.of(context).copyWith(
|
||||
canvasColor: widget.filled ??Colors.white,
|
||||
),
|
||||
child: Container( height: 50, width: (widget.width ?? MediaQuery.of(context).size.width) - (widget.load == null ? 0 : 50) - (widget.remove == null ? 0 : 50),
|
||||
child: Container( height: 50, width: (widget.width ?? getMainWidth(context)) - (widget.load == null ? 0 : 50) - (widget.remove == null ? 0 : 50),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
),
|
||||
@@ -70,13 +71,15 @@ class ShallowDropdownInputWidgetState extends State<ShallowDropdownInputWidget>
|
||||
isExpanded: true,
|
||||
style: TextStyle(color: widget.color ?? Colors.black, fontSize: 15),
|
||||
hint: Text(widget.hint ?? "load $t...",
|
||||
style: TextStyle(color: widget.hintColor ??Colors.grey.shade300, fontSize: 14)),
|
||||
style: TextStyle(color: widget.hintColor ??midColor, fontSize: 14)),
|
||||
icon: Icon( // Add this
|
||||
Icons.arrow_drop_down, // Add this
|
||||
color: widget.hintColor ?? Colors.grey , // Add this
|
||||
color: widget.hintColor ?? Colors.grey , // Add thisprefixIcon
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
filled: true,
|
||||
prefixIconColor: Colors.grey,
|
||||
prefixIcon: widget.prefixIcon,
|
||||
suffixIconColor: widget.hintColor ?? Colors.grey ,
|
||||
focusedBorder: InputBorder.none,
|
||||
fillColor: widget.filled ??Colors.white,
|
||||
@@ -114,7 +117,7 @@ class ShallowDropdownInputWidgetState extends State<ShallowDropdownInputWidget>
|
||||
setState(() { });
|
||||
},
|
||||
child: Container( width: 50,height: 50,
|
||||
decoration: BoxDecoration(color: Colors.black, border: Border(left: BorderSide(color: Colors.grey.shade300))),
|
||||
decoration: BoxDecoration(color: Colors.black, border: Border(left: BorderSide(color: midColor))),
|
||||
child: Icon(widget.iconRemove ?? Icons.delete, color: widget.current == null || widget.canRemove == null || !widget.canRemove!(widget.current) ? Colors.grey : Colors.white)) )
|
||||
),
|
||||
]); });
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:oc_front/pages/shared.dart';
|
||||
|
||||
class ShallowTextInputWidget extends StatefulWidget {
|
||||
double? width;
|
||||
SharedWorkspaceType type = SharedWorkspaceType.workspace;
|
||||
CollaborativeAreaType type = CollaborativeAreaType.workspace;
|
||||
Future<void> Function(Map<String,dynamic>)? load;
|
||||
Future<void> Function(String)? loadStr;
|
||||
Future<void> Function(String)? remove;
|
||||
@@ -12,10 +13,12 @@ class ShallowTextInputWidget extends StatefulWidget {
|
||||
void Function(String?)? change;
|
||||
String? current;
|
||||
String? compare;
|
||||
|
||||
bool readOnly;
|
||||
IconData? iconLoad;
|
||||
IconData? iconRemove;
|
||||
|
||||
MainAxisAlignment alignment = MainAxisAlignment.start;
|
||||
|
||||
String? hint;
|
||||
|
||||
String? tooltipLoad;
|
||||
@@ -28,7 +31,7 @@ class ShallowTextInputWidget extends StatefulWidget {
|
||||
|
||||
String? attr;
|
||||
|
||||
ShallowTextInputWidget ({ Key? key, this.width, this.current, this.attr,
|
||||
ShallowTextInputWidget ({ Key? key, this.width, this.current, this.attr, this.readOnly = false, this.alignment = MainAxisAlignment.start,
|
||||
this.iconLoad, this.iconRemove, this.hint, this.forms = const [], this.loadStr,
|
||||
this.tooltipLoad = "", this.tooltipRemove = "",
|
||||
this.filled, this.hintColor, this.color,
|
||||
@@ -61,16 +64,17 @@ class ShallowTextInputWidgetState extends State<ShallowTextInputWidget> {
|
||||
}
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
var t = widget.type == SharedWorkspaceType.workspace ? "workspace" : (widget.type == SharedWorkspaceType.workflow ? "workflow" : "peer");
|
||||
return Row( children: [
|
||||
var t = widget.type == CollaborativeAreaType.workspace ? "workspace" : (widget.type == CollaborativeAreaType.workflow ? "workflow" : "peer");
|
||||
return Row( mainAxisAlignment: widget.alignment, children: [
|
||||
Tooltip( message: widget.hint ?? "current $t", child:
|
||||
Theme(
|
||||
data: Theme.of(context).copyWith(
|
||||
canvasColor: Colors.grey.shade300,
|
||||
canvasColor: midColor,
|
||||
),
|
||||
child: Container( height: 50, width: (widget.width ?? MediaQuery.of(context).size.width) - (widget.load == null ? 0 : 50) - (widget.remove == null ? 0 : 50),
|
||||
child: Container( height: 50, width: (widget.width ?? getMainWidth(context)) - (widget.load == null ? 0 : 50) - (widget.remove == null ? 0 : 50),
|
||||
decoration: const BoxDecoration( color: Colors.white ),
|
||||
child: TextFormField(
|
||||
enabled: !widget.readOnly,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
widget.current = value;
|
||||
@@ -127,7 +131,7 @@ class ShallowTextInputWidgetState extends State<ShallowTextInputWidget> {
|
||||
setState(() { });
|
||||
},
|
||||
child: Container( width: 50,height: 50,
|
||||
decoration: BoxDecoration(color: Colors.black, border: Border(left: BorderSide(color: Colors.grey.shade300))),
|
||||
decoration: BoxDecoration(color: Colors.black, border: Border(left: BorderSide(color: midColor))),
|
||||
child: Icon(widget.iconRemove ?? Icons.delete, color: widget.current == null || widget.canRemove == null || !widget.canRemove!(widget.current) ? Colors.grey : Colors.white)) )
|
||||
),
|
||||
]);
|
||||
|
||||
@@ -28,7 +28,6 @@ class SubTextInputWidgetState extends State<SubTextInputWidget> {
|
||||
width: widget.width - (widget.readOnly ? 40 : 0), height: 30,
|
||||
child: TextFormField( textAlign: TextAlign.start,
|
||||
enabled: !widget.readOnly,
|
||||
readOnly: widget.readOnly,
|
||||
initialValue: widget.initialValue,
|
||||
onChanged: widget.change,
|
||||
style: const TextStyle(fontSize: 12),
|
||||
@@ -40,7 +39,7 @@ class SubTextInputWidgetState extends State<SubTextInputWidget> {
|
||||
alignLabelWithHint: false,
|
||||
errorStyle: const TextStyle(fontSize: 0),
|
||||
hintStyle: const TextStyle(fontSize: 10),
|
||||
labelStyle: const TextStyle(fontSize: 10),
|
||||
labelStyle: const TextStyle(fontSize: 12),
|
||||
floatingLabelBehavior: FloatingLabelBehavior.always,
|
||||
enabledBorder: const OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
|
||||
border: const OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/widgets/items/items_details/data_item.dart';
|
||||
|
||||
@@ -13,23 +14,23 @@ class ItemWidgetState extends State<ItemWidget> {
|
||||
Widget w = Container();
|
||||
/* if (isData(widget.item.topic)) { w = DataItemWidget(item: widget.item as DataItem); }
|
||||
else if (isComputing(widget.item.topic)) { w = DataItemWidget(item: widget.item as DataItem); }
|
||||
else if (isDataCenter(widget.item.topic)) { w = DataItemWidget(item: widget.item as DataItem); }
|
||||
else if (isCompute(widget.item.topic)) { w = DataItemWidget(item: widget.item as DataItem); }
|
||||
else if (isStorage(widget.item.topic)) { w = DataItemWidget(item: widget.item as DataItem); } */
|
||||
|
||||
return Container(
|
||||
height: MediaQuery.of(context).size.height - 300,
|
||||
height: getHeight(context) - 300,
|
||||
child: SingleChildScrollView(
|
||||
child: Column( children: [
|
||||
widget.item.description == null ? Container() : Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
width: getMainWidth(context),
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(border: Border(bottom: BorderSide(color: Colors.grey.shade300))),
|
||||
decoration: BoxDecoration(border: Border(bottom: BorderSide(color: midColor))),
|
||||
padding: const EdgeInsets.all(30),
|
||||
child: Text(widget.item.description!,
|
||||
style: TextStyle(fontSize: 15, color: Colors.grey, fontWeight: FontWeight.w500))),
|
||||
Container(padding: const EdgeInsets.all(30),
|
||||
color: Colors.grey.shade300,
|
||||
width: MediaQuery.of(context).size.width / 2,
|
||||
color: midColor,
|
||||
width: getMainWidth(context) / 2,
|
||||
child: w
|
||||
)
|
||||
]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/core/models/workspace_local.dart';
|
||||
import 'package:oc_front/core/services/router.dart';
|
||||
@@ -19,7 +20,7 @@ class ItemRowWidget extends StatefulWidget {
|
||||
class ItemRowWidgetState extends State<ItemRowWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
double imageSize = widget.contextWidth <= 400 ? 0 : 80;
|
||||
var ratio = MediaQuery.of(context).size.width != widget.contextWidth ? 0.5 : 1; // 2;
|
||||
var ratio = getMainWidth(context) != widget.contextWidth ? 0.5 : 1; // 2;
|
||||
var itemWidth = (((widget.contextWidth - imageSize) / 3) - 80) / ratio;
|
||||
itemWidth = itemWidth > 100 ? 100 : ( itemWidth < 40 ? 40 : itemWidth );
|
||||
var endWidth = (itemWidth * ratio) + 80;
|
||||
@@ -31,7 +32,7 @@ class ItemRowWidgetState extends State<ItemRowWidget> {
|
||||
width: widget.contextWidth,
|
||||
height: 100,
|
||||
padding: EdgeInsets.only(left: imageSize == 0 ? 20 : 0),
|
||||
decoration: BoxDecoration( border: Border(bottom: BorderSide(color: Colors.grey.shade300)) ),
|
||||
decoration: BoxDecoration( border: Border(bottom: BorderSide(color: midColor)) ),
|
||||
child: Row( children: [
|
||||
widget.low ? Container( padding: const EdgeInsets.only(left: 10),) : Container( padding: const EdgeInsets.all(10),
|
||||
constraints: BoxConstraints(maxWidth: imageSize, minWidth: imageSize),
|
||||
@@ -39,7 +40,7 @@ class ItemRowWidgetState extends State<ItemRowWidget> {
|
||||
height: imageSize, width: imageSize)),
|
||||
Container(
|
||||
width: widget.low ? widget.contextWidth - 20 : widget.contextWidth - (imageSize + 20) - endWidth,
|
||||
child: Padding(padding: widget.contextWidth != MediaQuery.of(context).size.width ?
|
||||
child: Padding(padding: widget.contextWidth != getMainWidth(context) ?
|
||||
const EdgeInsets.symmetric(horizontal: 10) : const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
@@ -49,11 +50,11 @@ class ItemRowWidgetState extends State<ItemRowWidget> {
|
||||
decoration: BoxDecoration(
|
||||
color: isData(widget.item.topic) ? Colors.blue :
|
||||
isComputing(widget.item.topic) ? Colors.green :
|
||||
isDataCenter(widget.item.topic) ? Colors.orange :
|
||||
isStorage(widget.item.topic) ? Colors.red : Colors.grey,
|
||||
isCompute(widget.item.topic) ? Colors.orange :
|
||||
isStorage(widget.item.topic) ? redColor : Colors.grey,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text( MediaQuery.of(context).size.width < 600 ? "" : widget.item.topic.toString(),
|
||||
child: Text( getMainWidth(context) < 600 ? "" : widget.item.topic.toString(),
|
||||
style: const TextStyle(fontSize: 10, color: Colors.white, fontWeight: FontWeight.w600)),
|
||||
),
|
||||
Expanded( child: Text(widget.item.name?.toUpperCase() ?? "",
|
||||
@@ -85,8 +86,8 @@ class ItemRowWidgetState extends State<ItemRowWidget> {
|
||||
constraints: const BoxConstraints(maxWidth: 80),
|
||||
width: itemWidth,
|
||||
decoration: BoxDecoration(
|
||||
boxShadow: [BoxShadow(color: Colors.grey.shade300, spreadRadius: 1, blurRadius: 1, offset: const Offset(0, 1))],
|
||||
color: (WorkspaceLocal.hasItem(widget.item) ? Colors.red : const Color.fromRGBO(38, 166, 154, 1)),
|
||||
boxShadow: [BoxShadow(color: midColor, spreadRadius: 1, blurRadius: 1, offset: const Offset(0, 1))],
|
||||
color: (WorkspaceLocal.hasItem(widget.item) ? redColor : lightColor ),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Icon(WorkspaceLocal.hasItem(widget.item) ? Icons.remove_shopping_cart : Icons.add_shopping_cart,
|
||||
@@ -101,8 +102,8 @@ class ItemRowWidgetState extends State<ItemRowWidget> {
|
||||
constraints: const BoxConstraints(maxWidth: 80, minWidth: 40),
|
||||
width: itemWidth,
|
||||
decoration: BoxDecoration(
|
||||
boxShadow: [BoxShadow(color: Colors.grey.shade300, spreadRadius: 1, blurRadius: 1, offset: const Offset(0, 1))],
|
||||
color: Colors.grey.shade300,
|
||||
boxShadow: [BoxShadow(color: midColor, spreadRadius: 1, blurRadius: 1, offset: const Offset(0, 1))],
|
||||
color: midColor,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: const Icon(Icons.favorite_border, color: Colors.white, size: 20 ))
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
|
||||
const List<GlobalKey<State>> _empty = [];
|
||||
@@ -51,7 +52,7 @@ class ShallowItemRowWidgetState extends State<ShallowItemRowWidget> {
|
||||
constraints: BoxConstraints(maxWidth: widget.contextWidth, minWidth: widget.contextWidth),
|
||||
child: Icon( widget.icon!, size: widget.contextWidth / 1.9, color: const Color(0xFFF67C0B9),)),
|
||||
Container(
|
||||
child: Padding(padding: widget.contextWidth != MediaQuery.of(context).size.width ?
|
||||
child: Padding(padding: widget.contextWidth != getMainWidth(context) ?
|
||||
const EdgeInsets.symmetric(horizontal: 10) : const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:json_string/json_string.dart';
|
||||
import 'package:oc_front/core/sections/header/header.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:oc_front/models/logs.dart';
|
||||
import 'package:oc_front/widgets/dialog/alert.dart';
|
||||
|
||||
@@ -19,7 +20,7 @@ class LogsWidgetState extends State<LogsWidget> {
|
||||
&& (widget.level?.contains(element.level ?? "") ?? true) ).map((e) => LogWidget(item: e)).toList();
|
||||
return Stack( children: [
|
||||
SingleChildScrollView( child: itemRows.isEmpty ?
|
||||
Container( height: MediaQuery.of(context).size.height - 100 - HeaderConstants.height,
|
||||
Container( height: getMainHeight(context) - 100,
|
||||
child: const Center( child: Text("no log registered", style: TextStyle(color: Colors.grey, fontSize: 25 ),)))
|
||||
: Column( children: [...itemRows, Container(height: 50,) ] ) ),
|
||||
]);
|
||||
@@ -47,7 +48,7 @@ class LogWidgetState extends State<LogWidget> {
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container( width: 10, height: 15, color: widget.item.level?.toLowerCase() == "info" ? Colors.green :
|
||||
( widget.item.level?.toLowerCase() == "error" ? Colors.red : (
|
||||
( widget.item.level?.toLowerCase() == "error" ? redColor : (
|
||||
widget.item.level?.toLowerCase() == "warning" ? Colors.orange : Colors.blue))),
|
||||
InkWell( mouseCursor: map.isEmpty ? MouseCursor.defer : SystemMouseCursors.click, onTap: () {
|
||||
if (map.isNotEmpty ) {
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ArrowClipper extends CustomClipper<Path> {
|
||||
@override
|
||||
Path getClip(Size size) {
|
||||
Path path = Path();
|
||||
path.moveTo(0, size.height);
|
||||
path.lineTo(size.width / 2, size.height / 2);
|
||||
path.lineTo(size.width, size.height);
|
||||
return path;
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldReclip(CustomClipper<Path> oldClipper) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,218 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/core/services/router.dart';
|
||||
import 'package:oc_front/widgets/menus/arrow_clipper.dart';
|
||||
|
||||
class TooltipWidget extends StatefulWidget {
|
||||
int index = -1;
|
||||
Size? buttonSize;
|
||||
List<String> labels;
|
||||
Offset? buttonPosition;
|
||||
TooltipWidget ({ Key? key,
|
||||
required this.labels,
|
||||
required this.index,
|
||||
required this.buttonSize,
|
||||
required this.buttonPosition }): super(key: key);
|
||||
@override TooltipWidgetState createState() => TooltipWidgetState();
|
||||
}
|
||||
class TooltipWidgetState extends State<TooltipWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
double minimal = (widget.index < 0 ? 0 : 7 * widget.labels[widget.index].length).toDouble() + 30;
|
||||
return Positioned(
|
||||
top : ((widget.buttonPosition?.dy ?? 1 ) + 11) + (((widget.buttonSize?.height) ?? 1)* 1.5) * (widget.index + 1),
|
||||
left: (widget.buttonPosition?.dx ?? 1) - minimal,
|
||||
child: Container(
|
||||
width: widget.index < 0 ? 0 : (widget.index < 0 ? 0 : minimal),
|
||||
height: (widget.buttonSize?.height ?? 1) - 2,
|
||||
color: Colors.black,
|
||||
child: Text( widget.index < 0 ? "" : widget.labels[widget.index],
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
decoration: TextDecoration.none,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w300),
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.ellipsis
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
GlobalKey<ClipperMenuWidgetState> headerMenuKey = GlobalKey<ClipperMenuWidgetState>();
|
||||
class ClipperMenuWidget extends StatefulWidget {
|
||||
final BorderRadius borderRadius;
|
||||
final Color backgroundColor;
|
||||
final Color iconColor;
|
||||
int index = -1;
|
||||
|
||||
ClipperMenuWidget({
|
||||
required this.borderRadius,
|
||||
this.backgroundColor = const Color.fromRGBO(38, 166, 154, 1),
|
||||
this.iconColor = Colors.black,
|
||||
}) : super(key: headerMenuKey);
|
||||
@override
|
||||
// ignore: library_private_types_in_public_api
|
||||
ClipperMenuWidgetState createState() => ClipperMenuWidgetState();
|
||||
}
|
||||
|
||||
class ClipperMenuWidgetState extends State<ClipperMenuWidget> with SingleTickerProviderStateMixin {
|
||||
late GlobalKey _key;
|
||||
bool isMenuOpen = false;
|
||||
Offset? buttonPosition;
|
||||
Size? buttonSize;
|
||||
final GlobalKey<TooltipWidgetState> _tooltipKey = GlobalKey<TooltipWidgetState>();
|
||||
OverlayEntry? _overlayEntry;
|
||||
BorderRadius? _borderRadius;
|
||||
AnimationController? _animationController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_animationController = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 250),
|
||||
);
|
||||
_borderRadius = widget.borderRadius; // BorderRadius.circular(4)
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_animationController?.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
findButton() {
|
||||
if (_key.currentContext != null) {
|
||||
RenderBox renderBox = _key.currentContext?.findRenderObject()! as RenderBox;
|
||||
buttonSize = renderBox.size;
|
||||
buttonPosition = renderBox.localToGlobal(Offset.zero);
|
||||
}
|
||||
}
|
||||
|
||||
void closeMenu() {
|
||||
try {
|
||||
_overlayEntry?.remove();
|
||||
_animationController?.reverse();
|
||||
isMenuOpen = false;
|
||||
} catch (e) { }
|
||||
|
||||
}
|
||||
|
||||
void openMenu() {
|
||||
findButton();
|
||||
_animationController?.forward();
|
||||
_overlayEntry = _overlayEntryBuilder();
|
||||
if (_overlayEntry != null) { Overlay.of(context).insert(_overlayEntry!); }
|
||||
isMenuOpen = true;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_key = GlobalKey();
|
||||
headerMenuKey = GlobalKey<ClipperMenuWidgetState>();
|
||||
return Container(
|
||||
key: _key,
|
||||
padding: const EdgeInsets.all(0),
|
||||
child: IconButton(
|
||||
splashRadius: 4,
|
||||
icon: _animationController == null ?
|
||||
const Icon(
|
||||
Icons.close,
|
||||
) : AnimatedIcon(
|
||||
icon: AnimatedIcons.menu_close,
|
||||
progress: _animationController!,
|
||||
),
|
||||
onPressed: () {
|
||||
if (isMenuOpen) { closeMenu();
|
||||
} else { openMenu(); }
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
OverlayEntry _overlayEntryBuilder() {
|
||||
var routes = AppRouter.zones.where(
|
||||
(e) => e.path != AppRouter.currentRoute.path && e.label != null && e.icon != null).toList();
|
||||
return OverlayEntry(
|
||||
builder: (context) {
|
||||
return Stack( children: [
|
||||
TooltipWidget(
|
||||
key: _tooltipKey,
|
||||
labels: routes.map((e) => e.label!).toList(),
|
||||
buttonPosition: buttonPosition,
|
||||
buttonSize: buttonSize,
|
||||
index: widget.index
|
||||
),
|
||||
Positioned(
|
||||
top: (buttonPosition?.dy ?? 1 ) + (buttonSize?.height ?? 1),
|
||||
left: buttonPosition?.dx,
|
||||
width: buttonSize?.width,
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: ClipPath(
|
||||
clipper: ArrowClipper(),
|
||||
child: Container(
|
||||
width: 17,
|
||||
height: 17,
|
||||
color: widget.backgroundColor ?? Color(0xFFF),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 15.0),
|
||||
child: Container(
|
||||
height: routes.length * ((buttonSize?.height ?? 1) * 1.5),
|
||||
decoration: BoxDecoration(
|
||||
boxShadow: const [BoxShadow(color: Colors.black54, spreadRadius: 1, blurRadius: 1, offset: Offset(0, 1))],
|
||||
color: widget.backgroundColor,
|
||||
borderRadius: _borderRadius,
|
||||
),
|
||||
child: Theme(
|
||||
data: ThemeData(
|
||||
iconTheme: IconThemeData( color: widget.iconColor ),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: List.generate(routes.length, (index) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
if (index >= 0) { routes[index].go(context, {}); }
|
||||
closeMenu();
|
||||
},
|
||||
child: Container(
|
||||
decoration: index == (routes.length - 1) ? null : const BoxDecoration(
|
||||
border: Border( bottom: BorderSide(color: Colors.white ), ),
|
||||
),
|
||||
width: (buttonSize?.width ?? 1) * 1.5,
|
||||
height: (buttonSize?.height ?? 1) * 1.5,
|
||||
child: MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
onEnter: (state) {
|
||||
_tooltipKey.currentState?.setState(() {
|
||||
_tooltipKey.currentState?.widget.index = index;
|
||||
});
|
||||
},
|
||||
onExit: (state) {
|
||||
_tooltipKey.currentState?.setState(() { _tooltipKey.currentState?.widget.index = -1; });
|
||||
},
|
||||
child: Icon( routes[index].icon, size: 19)
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
]);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_box_transform/flutter_box_transform.dart';
|
||||
import 'package:oc_front/core/sections/header/header.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:oc_front/models/logs.dart';
|
||||
import 'package:oc_front/models/workflow.dart';
|
||||
import 'package:oc_front/widgets/logs.dart';
|
||||
@@ -26,7 +27,7 @@ String? selectedReal;
|
||||
class ScheduleWidgetState extends State<ScheduleWidget> {
|
||||
String search = "";
|
||||
String? level;
|
||||
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"];
|
||||
|
||||
DateTime getFocusedDay() {
|
||||
@@ -35,8 +36,8 @@ class ScheduleWidgetState extends State<ScheduleWidget> {
|
||||
}
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
bool isInfo = MediaQuery.of(context).size.width <= 600 && selected != null;
|
||||
double w = selected != null ? MediaQuery.of(context).size.width - menuSize : MediaQuery.of(context).size.width;
|
||||
bool isInfo = getMainWidth(context) <= 600 && selected != null;
|
||||
double w = selected != null ? getMainWidth(context) - menuSize : getMainWidth(context);
|
||||
List<Widget> children = [];
|
||||
if (selected != null) {
|
||||
for (var wf in widget.data[selected!] ?? (<WorkflowExecution>[])) {
|
||||
@@ -45,8 +46,7 @@ class ScheduleWidgetState extends State<ScheduleWidget> {
|
||||
onTap: () => setState(() { selectedReal = wf.executionData; }),
|
||||
child: Container( margin: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: selectedReal != null && selectedReal == wf.executionData ?
|
||||
const Color.fromRGBO(38, 166, 154, 1) : Colors.transparent, width: 2),
|
||||
border: Border.all(color: selectedReal != null && selectedReal == wf.executionData ? lightColor : Colors.transparent, width: 2),
|
||||
borderRadius: BorderRadius.circular(4), color: Colors.white
|
||||
),
|
||||
child: Container(
|
||||
@@ -85,9 +85,9 @@ class ScheduleWidgetState extends State<ScheduleWidget> {
|
||||
logs = sel.logs ?? [];
|
||||
} catch(e) { /* */ }
|
||||
}
|
||||
menuSize = isInfo ? MediaQuery.of(context).size.width : (menuSize > MediaQuery.of(context).size.width / 2 ? MediaQuery.of(context).size.width / 2 : menuSize);
|
||||
menuSize = isInfo ? getMainWidth(context) : (menuSize > getMainWidth(context) / 2 ? getMainWidth(context) / 2 : menuSize);
|
||||
Rect rect = Rect.fromCenter( center: MediaQuery.of(context).size.center(Offset.zero),
|
||||
width: selected != null ? menuSize : 0, height: (MediaQuery.of(context).size.height - HeaderConstants.height - 50) > 0 ? (MediaQuery.of(context).size.height - HeaderConstants.height - 50) : 0);
|
||||
width: selected != null ? menuSize : 0, height: (getMainHeight(context) - 50) > 0 ? (getMainHeight(context) - 50) : 0);
|
||||
return Row( children: [
|
||||
isInfo ? Container() : SizedBox( width: w,
|
||||
child: widget.isList ? SchedulerItemWidget(data: widget.data, parent: this, focusedDay: getFocusedDay(), width: w)
|
||||
@@ -96,7 +96,7 @@ class ScheduleWidgetState extends State<ScheduleWidget> {
|
||||
),
|
||||
fork.TransformableBox(
|
||||
rect: rect, constraints: BoxConstraints(
|
||||
maxWidth: isInfo ? MediaQuery.of(context).size.width : (selected != null ? MediaQuery.of(context).size.width / 2 : 0),
|
||||
maxWidth: isInfo ? getMainWidth(context) : (selected != null ? getMainWidth(context) / 2 : 0),
|
||||
minWidth: selected != null ? 300 : 0),
|
||||
handleTapSize: 1, handleTapLeftSize: 0, allowFlippingWhileResizing: false, draggable: false, flip: null,
|
||||
resizeModeResolver: () => ResizeMode.freeform,
|
||||
@@ -106,15 +106,15 @@ class ScheduleWidgetState extends State<ScheduleWidget> {
|
||||
handleAlignment: HandleAlignment.inside,
|
||||
onChanged: (result, event) { setState(() { menuSize = result.rect.width; }); },
|
||||
contentBuilder: (context, rect, flip) { return Container(
|
||||
height: MediaQuery.of(context).size.height - HeaderConstants.height - 50,
|
||||
width: isInfo ? MediaQuery.of(context).size.width : (selected != null ? menuSize : 0),
|
||||
color: Colors.grey.shade300,
|
||||
height: getMainHeight(context) - 50,
|
||||
width: isInfo ? getMainWidth(context) : (selected != null ? menuSize : 0),
|
||||
color: midColor,
|
||||
child: Column(
|
||||
children: [
|
||||
Row( children: [
|
||||
InkWell( onTap: () => setState(() { widget.isDayPlanner = true; }),
|
||||
child: Tooltip( message: "day planning", child:
|
||||
Container( height: 50, width: (isInfo ? MediaQuery.of(context).size.width : (selected != null ? menuSize : 0)) / (selectedReal != null ? 2 : 1 ),
|
||||
Container( height: 50, width: (isInfo ? getMainWidth(context) : (selected != null ? menuSize : 0)) / (selectedReal != null ? 2 : 1 ),
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: widget.isDayPlanner ? Colors.grey : Colors.transparent,
|
||||
@@ -125,7 +125,7 @@ class ScheduleWidgetState extends State<ScheduleWidget> {
|
||||
InkWell( onTap: () => setState(() { widget.isDayPlanner = false; }),
|
||||
child: Tooltip( message: "monitor task", child:
|
||||
Container( height: 50, width: selectedReal == null ? 0 : (
|
||||
(isInfo ? MediaQuery.of(context).size.width : (selected != null ? menuSize : 0)) / 2),
|
||||
(isInfo ? getMainWidth(context) : (selected != null ? menuSize : 0)) / 2),
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: !widget.isDayPlanner ? Colors.grey : Colors.transparent,
|
||||
@@ -136,7 +136,7 @@ class ScheduleWidgetState extends State<ScheduleWidget> {
|
||||
)
|
||||
))
|
||||
]),
|
||||
SizedBox( width: isInfo ? MediaQuery.of(context).size.width : (selected != null ? menuSize : 0), height: MediaQuery.of(context).size.height - HeaderConstants.height - (!widget.isDayPlanner && !widget.loading ? 150 : 100 ),
|
||||
SizedBox( width: isInfo ? getMainWidth(context) : (selected != null ? menuSize : 0), height: getMainHeight(context) - (!widget.isDayPlanner && !widget.loading ? 150 : 100 ),
|
||||
child: Stack( children: [
|
||||
SingleChildScrollView( child: Column(
|
||||
mainAxisAlignment: children.isEmpty || widget.loading ? MainAxisAlignment.center : MainAxisAlignment.start,
|
||||
@@ -154,7 +154,7 @@ class ScheduleWidgetState extends State<ScheduleWidget> {
|
||||
width: 150,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
border: Border(left: BorderSide(color: Colors.grey.shade300)),
|
||||
border: Border(left: BorderSide(color: midColor)),
|
||||
),
|
||||
child: DropdownButtonFormField(
|
||||
isExpanded: true,
|
||||
@@ -163,22 +163,22 @@ class ScheduleWidgetState extends State<ScheduleWidget> {
|
||||
hint: const Text("by level...", style: TextStyle(fontSize: 12)),
|
||||
decoration: InputDecoration(
|
||||
filled: true,
|
||||
focusedBorder: const OutlineInputBorder( borderRadius: BorderRadius.zero,
|
||||
borderSide: BorderSide(color: Color.fromARGB(38, 166, 154, 1), width: 0),
|
||||
focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.zero,
|
||||
borderSide: BorderSide(color: lightColor, width: 0),
|
||||
),
|
||||
fillColor: Colors.white,
|
||||
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),
|
||||
borderSide: BorderSide(color: midColor, width: 0),
|
||||
),
|
||||
border: OutlineInputBorder( borderRadius: BorderRadius.zero,
|
||||
borderSide: BorderSide(color: Colors.grey.shade300, width: 0)),
|
||||
borderSide: BorderSide(color: midColor, width: 0)),
|
||||
),
|
||||
items: [
|
||||
DropdownMenuItem(value: "debug,warning,error,info", child: Row( children: [ Container( width: 10, height: 15, color: Colors.grey), Text(" all", style: TextStyle(fontSize: 12, color: Colors.black)) ])),
|
||||
DropdownMenuItem(value: "debug", child: Row( children: [ Container( width: 10, height: 15, color: Colors.blue), Text(" debug", style: TextStyle(fontSize: 12, color: Colors.black)) ])),
|
||||
DropdownMenuItem(value: "warning", child: Row( children: [ Container( width: 10, height: 15, color: Colors.orange), Text(" warning", style: TextStyle(fontSize: 12, color: Colors.black)) ])),
|
||||
DropdownMenuItem(value: "error", child: Row( children: [ Container( width: 10, height: 15, color: Colors.red), Text(" error", style: TextStyle(fontSize: 12, color: Colors.black)) ])),
|
||||
DropdownMenuItem(value: "error", child: Row( children: [ Container( width: 10, height: 15, color: redColor), Text(" error", style: TextStyle(fontSize: 12, color: Colors.black)) ])),
|
||||
DropdownMenuItem(value: "info", child: Row( children: [ Container( width: 10, height: 15, color: Colors.green), Text(" info", style: TextStyle(fontSize: 12, color: Colors.black)) ])),
|
||||
],
|
||||
onChanged: (value) {
|
||||
@@ -190,7 +190,7 @@ class ScheduleWidgetState extends State<ScheduleWidget> {
|
||||
width: menuSize - 150,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
border: Border(left: BorderSide(color: Colors.grey.shade300)),
|
||||
border: Border(left: BorderSide(color: midColor)),
|
||||
),
|
||||
child: TextField(
|
||||
onChanged: (value) { setState(() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/core/sections/header/header.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:oc_front/models/workflow.dart';
|
||||
import 'package:oc_front/widgets/sheduler_items/schedule.dart';
|
||||
import 'package:table_calendar/table_calendar.dart';
|
||||
@@ -23,7 +24,7 @@ class SchedulerCalendarWidget extends StatefulWidget {
|
||||
@override SchedulerCalendarWidgetState createState() => SchedulerCalendarWidgetState();
|
||||
}
|
||||
class SchedulerCalendarWidgetState extends State<SchedulerCalendarWidget> {
|
||||
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"];
|
||||
bool isEvent(Map<String, List<WorkflowExecution>> data, DateTime day) {
|
||||
if (data[day.toIso8601String()] == null || data[day.toIso8601String()]!.isEmpty) { return false; }
|
||||
@@ -34,7 +35,7 @@ class SchedulerCalendarWidgetState extends State<SchedulerCalendarWidget> {
|
||||
widget.focusedDay.isAfter(widget.end) ? widget.end : widget.focusedDay );
|
||||
return Container(
|
||||
padding: const EdgeInsets.only(left: 20, right: 20, bottom: 20),
|
||||
height: MediaQuery.of(context).size.height - HeaderConstants.height - 50,
|
||||
height: getMainHeight(context) - 50,
|
||||
child: TableCalendar<Event>(
|
||||
firstDay: widget.start,
|
||||
lastDay: widget.end,
|
||||
@@ -61,7 +62,7 @@ class SchedulerCalendarWidgetState extends State<SchedulerCalendarWidget> {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
color: Colors.grey.shade300,
|
||||
color: midColor,
|
||||
),
|
||||
child: const Text("...", style: TextStyle(color: Colors.white, fontSize: 10)),
|
||||
)));
|
||||
@@ -90,7 +91,7 @@ class SchedulerCalendarWidgetState extends State<SchedulerCalendarWidget> {
|
||||
alignment: !isEvent(widget.data, date) ? Alignment.center : Alignment.topCenter,
|
||||
margin:const EdgeInsets.all(2.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey.shade300),
|
||||
border: Border.all(color: midColor),
|
||||
shape: BoxShape.rectangle,
|
||||
),
|
||||
child: !isEvent(widget.data, date) ? Text(
|
||||
@@ -106,8 +107,8 @@ class SchedulerCalendarWidgetState extends State<SchedulerCalendarWidget> {
|
||||
alignment: Alignment.center,
|
||||
margin: const EdgeInsets.all(2.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey.shade300),
|
||||
color: Colors.grey.shade300,
|
||||
border: Border.all(color: midColor),
|
||||
color: midColor,
|
||||
shape: BoxShape.rectangle,
|
||||
),
|
||||
child: Text(
|
||||
@@ -119,7 +120,7 @@ class SchedulerCalendarWidgetState extends State<SchedulerCalendarWidget> {
|
||||
alignment: !isEvent(widget.data, date) ? Alignment.center : Alignment.topCenter,
|
||||
margin: const EdgeInsets.all(2.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: const Color.fromRGBO(38, 166, 154, 1), width: 2),
|
||||
border: Border.all(color: lightColor, width: 2),
|
||||
shape: BoxShape.rectangle,
|
||||
),
|
||||
child: !isEvent(widget.data, date) ? Text(
|
||||
|
||||
Reference in New Issue
Block a user