Dashboard chart flow
This commit is contained in:
29
lib/core/models/graph.dart
Normal file
29
lib/core/models/graph.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
import 'package:oc_front/models/search.dart';
|
||||
|
||||
class Graphs {
|
||||
static const Map<String, Graph> graphs = {};
|
||||
|
||||
static Graph getGraph(String id) {
|
||||
return graphs[id]!;
|
||||
}
|
||||
|
||||
static void addGraph(String id, Graph graph) {
|
||||
graphs[id] = graph;
|
||||
}
|
||||
|
||||
static void removeGraph(String id) {
|
||||
graphs.remove(id);
|
||||
}
|
||||
|
||||
static void clear() {
|
||||
graphs.clear();
|
||||
}
|
||||
}
|
||||
|
||||
class Graph {
|
||||
String id;
|
||||
List<AbstractItem> items = [];
|
||||
|
||||
Graph({ required this.id, required this.items }) {
|
||||
}
|
||||
}
|
||||
@@ -15,31 +15,47 @@ class WorkspaceLocal {
|
||||
if (workspace != null) {
|
||||
if (workspace!.data.isNotEmpty) {
|
||||
ItemService<DataItem, DataItem> dataService = ItemService<DataItem, DataItem>();
|
||||
dataService.get(context, workspace!.data.join(",")).then(
|
||||
(value) { if (value.data != null) { items.add(value.data!); } }
|
||||
);
|
||||
for (var element in workspace!.data) {
|
||||
if (WorkspaceLocal.hasItemByID(element)) { continue; }
|
||||
dataService.get(context, element).then(
|
||||
(value) { if (value.data != null) { items.add(value.data!); } }
|
||||
);
|
||||
}
|
||||
}
|
||||
if (workspace!.computing.isNotEmpty) {
|
||||
ItemService<ComputingItem, ComputingItem> computingService = ItemService<ComputingItem, ComputingItem>();
|
||||
computingService.get(context, workspace!.computing.join(",")).then(
|
||||
(value) { if (value.data != null) { items.add(value.data!); } }
|
||||
);
|
||||
for (var element in workspace!.computing) {
|
||||
if (WorkspaceLocal.hasItemByID(element)) { continue; }
|
||||
computingService.get(context, element).then(
|
||||
(value) { if (value.data != null) { items.add(value.data!); } }
|
||||
);
|
||||
}
|
||||
}
|
||||
if (workspace!.datacenter.isNotEmpty) {
|
||||
ItemService<DataCenterItem, DataCenterItem> dataCenterService = ItemService<DataCenterItem, DataCenterItem>();
|
||||
dataCenterService.get(context, workspace!.datacenter.join(",")).then(
|
||||
(value) { if (value.data != null) { items.add(value.data!); } }
|
||||
);
|
||||
for (var element in workspace!.datacenter) {
|
||||
if (WorkspaceLocal.hasItemByID(element)) { continue; }
|
||||
dataCenterService.get(context, element).then(
|
||||
(value) { if (value.data != null) { items.add(value.data!); } }
|
||||
);
|
||||
}
|
||||
}
|
||||
if (workspace!.storage.isNotEmpty) {
|
||||
ItemService<StorageItem, StorageItem> storageService = ItemService<StorageItem, StorageItem>();
|
||||
storageService.get(context, workspace!.storage.join(",")).then(
|
||||
(value) { if (value.data != null) { items.add(value.data!); } }
|
||||
);
|
||||
for (var element in workspace!.storage) {
|
||||
if (WorkspaceLocal.hasItemByID(element)) { continue; }
|
||||
storageService.get(context, element).then(
|
||||
(value) { if (value.data != null) { items.add(value.data!); } }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
static List<AbstractItem> byTopic(String topic) {
|
||||
return WorkspaceLocal.items.where((element) => element.topic.toString() == topic).toList();
|
||||
}
|
||||
|
||||
static AbstractItem? getItem(String id) {
|
||||
var found = WorkspaceLocal.items.where((element) => element.id.toString() == id);
|
||||
return found.isEmpty ? null : found.first;
|
||||
@@ -51,7 +67,6 @@ class WorkspaceLocal {
|
||||
try {
|
||||
_service.post(null, {}, { "id" : item.id.toString(), "rtype" : item.type.toString() });
|
||||
} catch (e) { /* */ }
|
||||
|
||||
}
|
||||
}
|
||||
static void removeItem(AbstractItem item) {
|
||||
@@ -59,6 +74,9 @@ class WorkspaceLocal {
|
||||
try { _service.delete(null, { "id" : item.id.toString(), "rtype" : item.type.toString() });
|
||||
} catch (e) { /* */ }
|
||||
}
|
||||
static bool hasItemByID(String id) {
|
||||
return items.where((element) => element.id == id).isNotEmpty;
|
||||
}
|
||||
static bool hasItem(AbstractItem item) {
|
||||
return items.where((element) => element.name == item.name).isNotEmpty;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/pages/catalog.dart';
|
||||
import 'package:oc_front/core/models/cart.dart';
|
||||
import 'package:oc_front/core/models/workspace_local.dart';
|
||||
import 'package:oc_front/widgets/items/item_row.dart';
|
||||
|
||||
GlobalKey<EndDrawerWidgetState> endDrawerKey = GlobalKey<EndDrawerWidgetState>();
|
||||
@@ -39,7 +39,7 @@ class EndDrawerWidgetState extends State<EndDrawerWidget> {
|
||||
style: TextStyle(fontSize: 25, fontWeight: FontWeight.w600, color: Colors.white))))
|
||||
: Container( child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row( children: itemRows)
|
||||
child: Column( children: itemRows)
|
||||
)),
|
||||
])
|
||||
)
|
||||
|
||||
@@ -1,7 +1,19 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/core/sections/header/menu.dart';
|
||||
import 'package:oc_front/core/sections/header/search.dart';
|
||||
import 'package:oc_front/utils/clipper_menu.dart';
|
||||
import 'package:oc_front/core/services/router.dart';
|
||||
import 'package:oc_front/widgets/menu_clipper/clipper_menu.dart';
|
||||
|
||||
class HeaderConstants {
|
||||
static final List<RouterItem> noHeader = [
|
||||
AppRouter.workflowItem,
|
||||
];
|
||||
static double height = 200;
|
||||
|
||||
static bool isNoHeader(String route) {
|
||||
return noHeader.where((element) => element.route == route).isNotEmpty;
|
||||
}
|
||||
}
|
||||
|
||||
GlobalKey<HeaderWidgetState> headerWidgetKey = GlobalKey<HeaderWidgetState>();
|
||||
class HeaderWidget extends StatefulWidget {
|
||||
@@ -12,9 +24,10 @@ class HeaderWidgetState extends State<HeaderWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
headerWidgetKey = GlobalKey<HeaderWidgetState>();
|
||||
headerMenuKey.currentState?.closeMenu();
|
||||
HeaderConstants.height = HeaderConstants.isNoHeader(AppRouter.currentRoute.route) ? 50 : 200;
|
||||
return Column( children: [
|
||||
const HeaderMenuWidget(),
|
||||
SearchWidget()
|
||||
HeaderConstants.isNoHeader(AppRouter.currentRoute.route) ? Container() : SearchWidget()
|
||||
],);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/utils/clipper_menu.dart';
|
||||
import 'package:oc_front/utils/dialog/login.dart';
|
||||
import 'package:oc_front/widgets/menu_clipper/clipper_menu.dart';
|
||||
import 'package:oc_front/widgets/dialog/login.dart';
|
||||
|
||||
class HeaderMenuWidget extends StatefulWidget{
|
||||
const HeaderMenuWidget ({ super.key });
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:alert_banner/exports.dart';
|
||||
import 'package:oc_front/models/abstract.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/utils/dialog/alert.dart';
|
||||
import 'package:oc_front/widgets/dialog/alert.dart';
|
||||
import 'package:oc_front/core/services/html.dart' if (kIsWeb) 'dart:html' as http;
|
||||
|
||||
class APIService<T extends SerializerDeserializer> {
|
||||
|
||||
@@ -48,17 +48,20 @@ class RouterItem {
|
||||
|
||||
class AppRouter {
|
||||
static const String home = "catalog";
|
||||
static final RouterItem workflowItem = RouterItem(icon: Icons.rebase_edit, label: "workflow manager", route: "workflow",
|
||||
description: "View to select & create new workflow.", help: "Workflow only access to your workspace datas. If a an element of your flow is missing, perhaps means it's missing in workspace.",
|
||||
factory: WorkflowFactory());
|
||||
static final RouterItem catalogItem = RouterItem(description: "", help: "", route: "catalog/:id", factory: CatalogItemFactory(), args: ["id"]);
|
||||
|
||||
static List<RouterItem> zones = [
|
||||
RouterItem(icon: Icons.book_outlined, label: "catalog searcher", route: home, factory: CatalogFactory()),
|
||||
RouterItem(icon: Icons.rebase_edit, label: "workflow manager", route: "workflow",
|
||||
description: "View to select & create new workflow.", help: "Workflow only access to your workspace datas. If a an element of your flow is missing, perhaps means it's missing in workspace.",
|
||||
factory: WorkflowFactory()),
|
||||
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",
|
||||
factory: DatacenterFactory()),
|
||||
RouterItem(icon: Icons.public_outlined, label: "localisations", route: "map", factory: MapFactory()),
|
||||
RouterItem(description: "", help: "", route: "catalog/:id", factory: CatalogItemFactory(), args: ["id"]),
|
||||
catalogItem,
|
||||
];
|
||||
static List<String> history = [];
|
||||
static List<String> realHistory = [];
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:oc_front/core/services/api_service.dart';
|
||||
|
||||
abstract class AbstractService<T extends SerializerDeserializer> {
|
||||
abstract APIService<T> service;
|
||||
abstract String subPath;
|
||||
|
||||
Future<APIResponse<T>> all(BuildContext? context) { throw UnimplementedError(); }
|
||||
Future<APIResponse<T>> get(BuildContext? context, String id);
|
||||
|
||||
@@ -7,16 +7,17 @@ import 'package:oc_front/models/search.dart';
|
||||
|
||||
class ItemService<S extends AbstractItem, T extends SerializerDeserializer<S>> extends AbstractService<T> {
|
||||
@override APIService<T> service = APIService<T>(
|
||||
baseURL: String.fromEnvironment('SEARCH_HOST', defaultValue: 'http://localhost:49618/v1/${getTopic(S)}')
|
||||
baseURL: const String.fromEnvironment('ITEM_HOST', defaultValue: 'http://localhost:49618')
|
||||
);
|
||||
|
||||
@override String subPath = "/v1/${getTopic(S)}";
|
||||
|
||||
@override Future<APIResponse<T>> all(BuildContext? context) { throw UnimplementedError(); }
|
||||
@override Future<APIResponse<T>> get(BuildContext? context, String id) {
|
||||
if (id.contains(",")) { return service.get("/multi/$id", true, context); }
|
||||
return service.get("/$id", true, context);
|
||||
if (id.contains(",")) { return service.get("$subPath/multi/$id", true, context); }
|
||||
return service.get("$subPath/$id", true, context);
|
||||
}
|
||||
@override Future<APIResponse<T>> post(BuildContext? context, Map<String, dynamic> body, Map<String, String> params) {
|
||||
return service.post("/", body, context);
|
||||
return service.post("$subPath/", body, context);
|
||||
}
|
||||
@override Future<APIResponse<T>> put(BuildContext? context, String id, Map<String, dynamic> body, Map<String, String> params) { throw UnimplementedError(); }
|
||||
@override Future<APIResponse<T>> delete(BuildContext? context, Map<String, String> params) { throw UnimplementedError(); }
|
||||
|
||||
@@ -6,12 +6,12 @@ import 'package:oc_front/models/search.dart';
|
||||
|
||||
class SearchService extends AbstractService<Search> {
|
||||
@override APIService<Search> service = APIService<Search>(
|
||||
baseURL: const String.fromEnvironment('SEARCH_HOST', defaultValue: 'http://localhost:49618/v1/search')
|
||||
baseURL: const String.fromEnvironment('SEARCH_HOST', defaultValue: 'http://localhost:49618')
|
||||
);
|
||||
|
||||
@override String subPath = "/v1/search";
|
||||
@override Future<APIResponse<Search>> all(BuildContext? context) { throw UnimplementedError(); }
|
||||
@override Future<APIResponse<Search>> get(BuildContext? context, String id) {
|
||||
return service.get("/byWord?word=$id", true, context);
|
||||
return service.get("$subPath/byWord?word=$id", true, context);
|
||||
}
|
||||
@override Future<APIResponse<Search>> post(BuildContext? context, Map<String, dynamic> body, Map<String, String> params) { throw UnimplementedError(); }
|
||||
@override Future<APIResponse<Search>> put(BuildContext? context, String id, Map<String, dynamic> body, Map<String, String> params) { throw UnimplementedError(); }
|
||||
|
||||
@@ -5,18 +5,17 @@ import 'package:oc_front/models/response.dart';
|
||||
|
||||
class WorflowService extends AbstractService<RawData> {
|
||||
@override APIService<RawData> service = APIService<RawData>(
|
||||
baseURL: const String.fromEnvironment('SEARCH_HOST', defaultValue: 'http://localhost:49618/v1/workflow/')
|
||||
baseURL: const String.fromEnvironment('WORKFLOW_HOST', defaultValue: 'http://localhost:49618')
|
||||
);
|
||||
|
||||
@override String subPath = "/v1/workflow/";
|
||||
@override Future<APIResponse<RawData>> all(BuildContext? context) {
|
||||
print("WorkflowService.all");
|
||||
return service.get("", true, context);
|
||||
return service.get(subPath, true, context);
|
||||
}
|
||||
@override Future<APIResponse<RawData>> get(BuildContext? context, String id) { throw UnimplementedError(); }
|
||||
@override Future<APIResponse<RawData>> post(BuildContext? context, Map<String, dynamic> body, Map<String, String> params) {
|
||||
String path = "?";
|
||||
for (var key in params.keys) { path += "$key=${params[key]}&"; }
|
||||
return service.post(path, body, context);
|
||||
return service.post("$subPath$path", body, context);
|
||||
}
|
||||
@override Future<APIResponse<RawData>> put(BuildContext? context, String id, Map<String, dynamic> body, Map<String, String> params) {
|
||||
throw UnimplementedError();
|
||||
|
||||
@@ -6,17 +6,18 @@ import 'package:oc_front/models/workspace.dart';
|
||||
|
||||
class WorkspaceService extends AbstractService<Workspace> {
|
||||
@override APIService<Workspace> service = APIService<Workspace>(
|
||||
baseURL: const String.fromEnvironment('SEARCH_HOST', defaultValue: 'http://localhost:49618/v1/workspace/')
|
||||
baseURL: const String.fromEnvironment('WORKSPACE_HOST', defaultValue: 'http://localhost:49618')
|
||||
);
|
||||
@override String subPath = "/v1/workspace/";
|
||||
|
||||
@override Future<APIResponse<Workspace>> all(BuildContext? context) {
|
||||
return service.get("/list", true, context);
|
||||
return service.get("$subPath/list", true, context);
|
||||
}
|
||||
@override Future<APIResponse<Workspace>> get(BuildContext? context, String id) { throw UnimplementedError(); }
|
||||
@override Future<APIResponse<Workspace>> post(BuildContext? context, Map<String, dynamic> body, Map<String, String> params) {
|
||||
String path = "?";
|
||||
for (var key in params.keys) { path += "$key=${params[key]}&"; }
|
||||
return service.post(path, body, context);
|
||||
return service.post("$subPath$path", body, context);
|
||||
}
|
||||
@override Future<APIResponse<Workspace>> put(BuildContext? context, String id, Map<String, dynamic> body, Map<String, String> params) {
|
||||
throw UnimplementedError();
|
||||
@@ -24,6 +25,6 @@ class WorkspaceService extends AbstractService<Workspace> {
|
||||
@override Future<APIResponse<Workspace>> delete(BuildContext? context, Map<String, String> params) {
|
||||
String path = "?";
|
||||
for (var key in params.keys) { path += "$key=${params[key]}&"; }
|
||||
return service.delete(path, context);
|
||||
return service.delete("$subPath$path", context);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:oc_front/core/models/cart.dart';
|
||||
import 'package:oc_front/core/models/workspace_local.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';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:oc_front/core/sections/header/header.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/widgets/catalog.dart';
|
||||
import 'package:oc_front/pages/abstract_page.dart';
|
||||
@@ -32,7 +33,7 @@ class CatalogPageWidgetState extends State<CatalogPageWidget> {
|
||||
return Column( children : [
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: CatalogFactory.items.isEmpty ? 0 : MediaQuery.of(context).size.height - 200,
|
||||
height: CatalogFactory.items.isEmpty ? 0 : MediaQuery.of(context).size.height - HeaderConstants.height,
|
||||
child: CatalogWidget(items: CatalogFactory.items) )
|
||||
]
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:oc_front/core/models/cart.dart';
|
||||
import 'package:oc_front/core/models/workspace_local.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/pages/abstract_page.dart';
|
||||
import 'package:oc_front/pages/catalog.dart';
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
|
||||
import 'package:go_router/go_router.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/workflow_service.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/pages/abstract_page.dart';
|
||||
import 'package:oc_front/widgets/dialog/new_box.dart';
|
||||
import 'package:oc_front/widgets/items/item_row.dart';
|
||||
|
||||
class WorkflowFactory implements AbstractFactory {
|
||||
static GlobalKey<WorkflowPageWidgetState> key = GlobalKey<WorkflowPageWidgetState>();
|
||||
@@ -12,157 +20,64 @@ class WorkflowFactory implements AbstractFactory {
|
||||
}
|
||||
|
||||
class WorkflowPageWidget extends StatefulWidget {
|
||||
String? _selected;
|
||||
TextEditingController _ctrl = TextEditingController();
|
||||
WorkflowPageWidget () : super(key: WorkflowFactory.key);
|
||||
@override WorkflowPageWidgetState createState() => WorkflowPageWidgetState();
|
||||
static void search(BuildContext context) { }
|
||||
static Widget factory() { return WorkflowPageWidget(); }
|
||||
}
|
||||
class WorkflowPageWidgetState extends State<WorkflowPageWidget> {
|
||||
|
||||
final WorflowService _service = WorflowService();
|
||||
@override Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height - 200,
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: (MediaQuery.of(context).size.height - 200) / 2,
|
||||
child : Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children : [
|
||||
Container( width: MediaQuery.of(context).size.height / 1.5,
|
||||
height: 50, margin: const EdgeInsets.only(top: 2),
|
||||
child: FutureBuilder<APIResponse<RawData>>(
|
||||
future: _service.all(context),
|
||||
builder: (context, snapshot) {
|
||||
List<DropdownMenuItem> items = [];
|
||||
print(snapshot.error);
|
||||
if (snapshot.hasData && snapshot.data!.data != null
|
||||
&& snapshot.data!.data!.values.isNotEmpty) {
|
||||
items = (snapshot.data!.data!.values as List<dynamic>).map((dynamic value) {
|
||||
final WorflowService _service = WorflowService();
|
||||
Widget itemBuild(Object item) {
|
||||
var e = item as AbstractItem;
|
||||
return e.logo != null ? Image.memory(base64Decode(e.logo ?? ""), fit: BoxFit.fill)
|
||||
: Image.network('https://get-picto.com/wp-content/uploads/2024/01/logo-instagram-png.webp', fit: BoxFit.fill);
|
||||
}
|
||||
Widget itemTooltipBuild(Object item) {
|
||||
var e = item as AbstractItem;
|
||||
return Container(color: Colors.white, child: ItemRowWidget(low: true, contextWidth: 300, item: e));
|
||||
}
|
||||
List<DropdownMenuItem> getItems(Object? data) {
|
||||
data = data as APIResponse<RawData>?;
|
||||
if (data != null && data.data != null && data.data!.values.isNotEmpty) {
|
||||
return (data.data!.values as List<dynamic>).map((dynamic value) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: value.toString(),
|
||||
child: Text(value.toString()),
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
if (widget._selected != null
|
||||
&& !items.where((element) => element.value == widget._selected).isNotEmpty) {
|
||||
items.add(DropdownMenuItem<String>(
|
||||
value: widget._selected.toString(),
|
||||
child: Text(widget._selected.toString()),
|
||||
));
|
||||
}
|
||||
return DropdownButtonFormField(
|
||||
value: widget._selected,
|
||||
hint: const Text("select workflow to load...", style: TextStyle(color: Colors.grey, fontSize: 15)),
|
||||
decoration: InputDecoration(
|
||||
filled: true,
|
||||
focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.zero,
|
||||
borderSide: BorderSide(color: Color.fromARGB(38, 166, 154, 1), width: 2.5),
|
||||
),
|
||||
fillColor: Colors.grey.shade300,
|
||||
contentPadding: const EdgeInsets.only(left: 30, right: 30),
|
||||
enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.zero,
|
||||
borderSide: BorderSide(color: Colors.grey.shade300, width: 2.5),
|
||||
),
|
||||
border: OutlineInputBorder( borderRadius: BorderRadius.zero,
|
||||
borderSide: BorderSide(color: Colors.grey.shade300, width: 2.5)),
|
||||
),
|
||||
items: items, onChanged: (value) {
|
||||
setState(() { widget._selected = value.toString(); });
|
||||
});
|
||||
})
|
||||
),
|
||||
Tooltip(
|
||||
message: 'empty selection',
|
||||
child: InkWell(
|
||||
mouseCursor: widget._selected == null || widget._selected!.isEmpty ? MouseCursor.defer : SystemMouseCursors.click,
|
||||
onTap: () { setState(() { widget._selected = null; }); },
|
||||
child: Container(
|
||||
width: 50, height: 48,
|
||||
decoration: const BoxDecoration( color: Colors.black,
|
||||
border: Border(right: BorderSide(color: Colors.white))),
|
||||
child: Icon(Icons.refresh, color: widget._selected == null || widget._selected!.isEmpty ? Colors.grey : Colors.white),
|
||||
)
|
||||
)
|
||||
),
|
||||
Tooltip(
|
||||
message: 'load workflow selected',
|
||||
child: InkWell(
|
||||
mouseCursor: widget._selected == null || widget._selected!.isEmpty ? MouseCursor.defer : SystemMouseCursors.click,
|
||||
onTap: () {},
|
||||
child: Container(
|
||||
width: 50, height: 48,
|
||||
color: Colors.black,
|
||||
child: Icon(Icons.open_in_browser_outlined,
|
||||
color: widget._selected == null || widget._selected!.isEmpty ? Colors.grey : Colors.white),
|
||||
)
|
||||
)
|
||||
)
|
||||
]),
|
||||
),
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: (MediaQuery.of(context).size.height - 200) / 2,
|
||||
color: Colors.grey.shade300,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Row( children: [
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width / 1.5,
|
||||
height: 50,
|
||||
child: TextFormField(
|
||||
cursorColor: const Color.fromARGB(38, 166, 154, 1),
|
||||
controller: widget._ctrl,
|
||||
onChanged: (value) => setState(() { widget._ctrl.value = TextEditingValue(text: value); }),
|
||||
validator: (value) => value == null || value.isEmpty ? "name is required" : null,
|
||||
decoration: const InputDecoration(
|
||||
hintText: "name a new workflow...",
|
||||
fillColor: Colors.white,
|
||||
filled: true,
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 30),
|
||||
hintStyle: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w300
|
||||
),
|
||||
border: InputBorder.none
|
||||
)
|
||||
)
|
||||
),
|
||||
Tooltip(
|
||||
message: 'add',
|
||||
child:InkWell(
|
||||
mouseCursor: widget._ctrl.value.text.isEmpty ? MouseCursor.defer : SystemMouseCursors.click,
|
||||
onTap: () async {
|
||||
if (widget._ctrl.value.text.isNotEmpty) {
|
||||
await _service.post(context, {}, { "workflowName" : widget._ctrl.value.text });
|
||||
widget._selected = widget._ctrl.value.text;
|
||||
widget._ctrl.value = const TextEditingValue(text: "");
|
||||
setState(() { });
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
color: Colors.black,
|
||||
child: Icon(Icons.add, color: widget._ctrl.value.text.isEmpty ? Colors.grey : Colors.white)
|
||||
)
|
||||
)
|
||||
)
|
||||
],
|
||||
),
|
||||
])
|
||||
)
|
||||
]
|
||||
)
|
||||
}
|
||||
return [];
|
||||
}
|
||||
Widget onDashboardAlertOpened(BuildContext context, Dashboard dash) {
|
||||
return NewBoxWidget<RawData>(service: _service, dash: dash,
|
||||
getItems: getItems);
|
||||
}
|
||||
@override Widget build(BuildContext context) {
|
||||
var quart = MediaQuery.of(context).size.width / 6;
|
||||
return FlowChart<AbstractItem>(
|
||||
onDashboardAlertOpened: onDashboardAlertOpened,
|
||||
dashboard: Dashboard(
|
||||
name: "workflow_${DateTime.now().toString().replaceAll(" ", "_").substring(0, DateTime.now().toString().length - 7)}"),
|
||||
itemWidget: itemBuild,
|
||||
categories: const ["computing", "data", "datacenter", "storage"],
|
||||
draggableItemBuilder: (cat) => WorkspaceLocal.byTopic(cat).toList(),
|
||||
itemWidgetTooltip: itemTooltipBuild,
|
||||
innerMenuWidth: quart > 80 ? quart : 80,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height - HeaderConstants.height,
|
||||
onNewConnection: (p1, p2) { },
|
||||
onDashboardTapped: (context, position) { },
|
||||
onScaleUpdate: (newScale) { },
|
||||
onDashboardSecondaryTapped: (context, position) { },
|
||||
onDashboardLongTapped: (context, position) { },
|
||||
onDashboardSecondaryLongTapped: (context, position) { },
|
||||
onElementLongPressed: (context, position, element) { },
|
||||
onElementSecondaryLongTapped: (context, position, element) { },
|
||||
onElementPressed: (context, position, element) { },
|
||||
onElementSecondaryTapped: (context, position, element) { },
|
||||
onHandlerPressed: (context, position, handler, element) { },
|
||||
onHandlerLongPressed: (context, position, handler, element) { },
|
||||
onPivotSecondaryPressed: (context, pivot) { },
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/core/models/cart.dart';
|
||||
import 'package:oc_front/core/models/workspace_local.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/widgets/items/item_row.dart';
|
||||
|
||||
|
||||
158
lib/widgets/dialog/new_box.dart
Normal file
158
lib/widgets/dialog/new_box.dart
Normal file
@@ -0,0 +1,158 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/abstract_service.dart';
|
||||
import 'package:oc_front/models/abstract.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
|
||||
abstract class New {
|
||||
String name = "";
|
||||
}
|
||||
|
||||
class NewBoxWidget<T extends SerializerDeserializer<dynamic>> extends StatefulWidget {
|
||||
String? _selected;
|
||||
Dashboard dash;
|
||||
final TextEditingController _ctrl = TextEditingController();
|
||||
AbstractService<T> service;
|
||||
Function validate = () {};
|
||||
NewBoxWidget ({ super.key, required this.service, required this.dash, this.getItems });
|
||||
@override NewBoxWidgetState<T> createState() => NewBoxWidgetState<T>();
|
||||
|
||||
List<DropdownMenuItem> Function(APIResponse<T>? data)? getItems;
|
||||
}
|
||||
class NewBoxWidgetState<T extends SerializerDeserializer<dynamic>> extends State<NewBoxWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
widget._ctrl.value = TextEditingValue(text: widget.dash.defaultName);
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children : [
|
||||
FutureBuilder<APIResponse<T>>(
|
||||
future: (widget.service as AbstractService<T>).all(context),
|
||||
builder: (context, snapshot) {
|
||||
List<DropdownMenuItem> items = widget.getItems != null ? widget.getItems!(snapshot.data) : [];
|
||||
if (widget._selected != null
|
||||
&& !items.where((element) => element.value == widget._selected).isNotEmpty) {
|
||||
items.add(DropdownMenuItem<String>(
|
||||
value: widget._selected.toString(),
|
||||
child: Text(widget._selected.toString()),
|
||||
));
|
||||
}
|
||||
return SizedBox( width: 400, height: 50, child: DropdownButtonFormField(
|
||||
value: widget._selected,
|
||||
hint: const Text("select workflow to load...", style: TextStyle(color: Colors.grey, fontSize: 15)),
|
||||
decoration: InputDecoration(
|
||||
filled: true,
|
||||
focusedBorder: const OutlineInputBorder( borderRadius: BorderRadius.zero,
|
||||
borderSide: BorderSide(color: Color.fromARGB(38, 166, 154, 1), width: 0),
|
||||
),
|
||||
fillColor: Colors.grey.shade300,
|
||||
contentPadding: const EdgeInsets.only(left: 30, right: 30, top: 10, bottom: 30),
|
||||
enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.zero,
|
||||
borderSide: BorderSide(color: Colors.grey.shade300, width: 0),
|
||||
),
|
||||
border: OutlineInputBorder( borderRadius: BorderRadius.zero,
|
||||
borderSide: BorderSide(color: Colors.grey.shade300, width: 0)),
|
||||
),
|
||||
items: items, onChanged: (value) {
|
||||
setState(() {
|
||||
widget._selected = value.toString();
|
||||
});
|
||||
}));
|
||||
}),
|
||||
Tooltip(
|
||||
message: 'empty selection',
|
||||
child: InkWell(
|
||||
mouseCursor: widget._selected == null || widget._selected!.isEmpty ? MouseCursor.defer : SystemMouseCursors.click,
|
||||
onTap: () {
|
||||
if (widget._selected == null || widget._selected!.isEmpty) { return; }
|
||||
setState(() { widget._selected = null; });
|
||||
},
|
||||
child: Container(
|
||||
width: 50, height: 50,
|
||||
decoration: const BoxDecoration( color: Colors.black,
|
||||
border: Border(right: BorderSide(color: Colors.white))),
|
||||
child: Icon(Icons.refresh, color: widget._selected == null || widget._selected!.isEmpty ? Colors.grey : Colors.white),
|
||||
)
|
||||
)
|
||||
),
|
||||
Tooltip(
|
||||
message: 'load workflow selected',
|
||||
child: InkWell(
|
||||
mouseCursor: widget._selected == null || widget._selected!.isEmpty
|
||||
? MouseCursor.defer : SystemMouseCursors.click,
|
||||
onTap: () {
|
||||
if (widget._selected == null || widget._selected!.isEmpty) { return; }
|
||||
widget.dash.name = widget._selected ?? widget.dash.name;
|
||||
widget.dash.notifyListeners();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Container(
|
||||
width: 50, height: 50,
|
||||
color: Colors.black,
|
||||
child: Icon(Icons.open_in_browser_outlined,
|
||||
color: widget._selected == null || widget._selected!.isEmpty ? Colors.grey : Colors.white),
|
||||
)
|
||||
)
|
||||
)
|
||||
]),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 10),
|
||||
width: 450,
|
||||
height: 50,
|
||||
child: TextFormField(
|
||||
cursorColor: const Color.fromARGB(38, 166, 154, 1),
|
||||
controller: widget._ctrl,
|
||||
onChanged: (value) => setState(() { widget._ctrl.value = TextEditingValue(text: value); }),
|
||||
validator: (value) => value == null || value.isEmpty ? "name is required" : null,
|
||||
decoration: InputDecoration(
|
||||
hintText: "name a new workflow...",
|
||||
fillColor: Colors.grey.shade300,
|
||||
filled: true,
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 30, vertical: 20),
|
||||
hintStyle: const TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w300
|
||||
),
|
||||
border: InputBorder.none
|
||||
)
|
||||
)
|
||||
),
|
||||
Tooltip(
|
||||
message: 'add',
|
||||
child:InkWell(
|
||||
mouseCursor: widget._ctrl.value.text.isEmpty ? MouseCursor.defer : SystemMouseCursors.click,
|
||||
onTap: () async {
|
||||
if (widget._ctrl.value.text.isNotEmpty) {
|
||||
await widget.service.post(context, {}, { "workflowName" : widget._ctrl.value.text });
|
||||
widget._selected = widget._ctrl.value.text;
|
||||
widget._ctrl.value = const TextEditingValue(text: "");
|
||||
widget.dash.name = widget._selected ?? widget.dash.name;
|
||||
widget.dash.notifyListeners();
|
||||
// ignore: use_build_context_synchronously
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(top: 10),
|
||||
width: 50,
|
||||
height: 50,
|
||||
color: Colors.black,
|
||||
child: Icon(Icons.add, color: widget._ctrl.value.text.isEmpty ? Colors.grey : Colors.white)
|
||||
)
|
||||
)
|
||||
)
|
||||
])
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/widgets/items_details/data_item.dart';
|
||||
import 'package:oc_front/widgets/items/items_details/data_item.dart';
|
||||
|
||||
class ItemWidget extends StatefulWidget {
|
||||
AbstractItem item;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/core/models/cart.dart';
|
||||
import 'package:oc_front/core/models/workspace_local.dart';
|
||||
import 'package:oc_front/core/services/router.dart';
|
||||
|
||||
const List<GlobalKey<State>> _empty = [];
|
||||
@@ -10,8 +10,9 @@ class ItemRowWidget extends StatefulWidget {
|
||||
bool readOnly = false;
|
||||
double contextWidth = 0;
|
||||
AbstractItem item;
|
||||
bool low = false;
|
||||
List<GlobalKey<State>> keys = [];
|
||||
ItemRowWidget ({ super.key,
|
||||
ItemRowWidget ({ super.key, this.low = false,
|
||||
required this.contextWidth, this.readOnly = false, required this.item, this.keys = _empty });
|
||||
@override ItemRowWidgetState createState() => ItemRowWidgetState();
|
||||
}
|
||||
@@ -31,17 +32,17 @@ class ItemRowWidgetState extends State<ItemRowWidget> {
|
||||
height: 100,
|
||||
decoration: BoxDecoration( border: Border(bottom: BorderSide(color: Colors.grey.shade300)) ),
|
||||
child: Row( children: [
|
||||
Padding( padding: const EdgeInsets.all(10),
|
||||
widget.low ? Container( padding: EdgeInsets.only(left: 10),) : Padding( padding: const EdgeInsets.all(10),
|
||||
child: image ?? Image.network('https://get-picto.com/wp-content/uploads/2024/01/logo-instagram-png.webp',
|
||||
height: imageSize, width: imageSize)),
|
||||
Container(
|
||||
width: widget.contextWidth - (imageSize + 20) - endWidth,
|
||||
width: widget.low ? widget.contextWidth - 20 : widget.contextWidth - (imageSize + 20) - endWidth,
|
||||
child: Padding(padding: widget.contextWidth != MediaQuery.of(context).size.width ?
|
||||
const EdgeInsets.symmetric(horizontal: 10) : const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
Row( children: [
|
||||
Container(padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
|
||||
widget.low ? Container() : Container(padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
|
||||
margin: const EdgeInsets.only(right: 20),
|
||||
decoration: BoxDecoration(
|
||||
color: isData(widget.item.topic) ? Colors.blue :
|
||||
@@ -54,7 +55,7 @@ class ItemRowWidgetState extends State<ItemRowWidget> {
|
||||
style: const TextStyle(fontSize: 10, color: Colors.white, fontWeight: FontWeight.w600)),
|
||||
),
|
||||
Expanded( child: Text(widget.item.name?.toUpperCase() ?? "",
|
||||
style: const TextStyle(fontSize: 20, overflow: TextOverflow.ellipsis, fontWeight: FontWeight.w600, color: Color(0xFFF67C0B9))),
|
||||
style: TextStyle(fontSize: widget.low ? 14 : 20, overflow: TextOverflow.ellipsis, fontWeight: FontWeight.w600, color: Color(0xFFF67C0B9))),
|
||||
)
|
||||
]),
|
||||
Text( "From ${widget.item.owner ?? "unknown owner"}",
|
||||
@@ -63,7 +64,7 @@ class ItemRowWidgetState extends State<ItemRowWidget> {
|
||||
],)
|
||||
)
|
||||
),
|
||||
Container(
|
||||
widget.low ? Container() : Container(
|
||||
width: endWidth,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@@ -108,8 +109,8 @@ class ItemRowWidgetState extends State<ItemRowWidget> {
|
||||
])
|
||||
)]),
|
||||
);
|
||||
return widget.readOnly ? w : InkWell( mouseCursor: SystemMouseCursors.click,
|
||||
onTap: () { AppRouter.zones.last.go(context, { "id" : widget.item.id ?? "" }); },
|
||||
return widget.readOnly || widget.low ? w : InkWell( mouseCursor: SystemMouseCursors.click,
|
||||
onTap: () { AppRouter.catalogItem.go(context, { "id" : widget.item.id ?? "" }); },
|
||||
child: w );
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/core/sections/header/menu.dart';
|
||||
import 'package:oc_front/core/services/router.dart';
|
||||
import 'package:oc_front/utils/arrow_clipper.dart';
|
||||
import 'package:oc_front/widgets/menu_clipper/arrow_clipper.dart';
|
||||
|
||||
class TooltipWidget extends StatefulWidget {
|
||||
int index = -1;
|
||||
@@ -109,7 +109,7 @@ class ClipperMenuWidgetState extends State<ClipperMenuWidget> with SingleTickerP
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_key = GlobalKey();
|
||||
headerMenuKey = widget.key as GlobalKey<ClipperMenuWidgetState>;
|
||||
headerMenuKey = GlobalKey<ClipperMenuWidgetState>();
|
||||
return Container(
|
||||
key: _key,
|
||||
padding: const EdgeInsets.all(0),
|
||||
Reference in New Issue
Block a user