Major Change Inputs & Co
This commit is contained in:
parent
2c86e90b76
commit
05854c84d8
@ -41,7 +41,7 @@ class CollaborativeAreaLocal {
|
||||
await _service.delete(null, id, {});
|
||||
}
|
||||
|
||||
static Future<void> createCollaborativeArea(String name, BuildContext? context) async {
|
||||
static Future<void> createCollaborativeArea(BuildContext context, String name) async {
|
||||
Workspace n = Workspace(name: name);
|
||||
await _service.post(context, n.serialize(), {}).then((value) {
|
||||
if (value.data != null) {
|
||||
|
@ -1,9 +1,13 @@
|
||||
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/resources/compute.dart';
|
||||
import 'package:oc_front/models/resources/data.dart';
|
||||
import 'package:oc_front/models/resources/processing.dart';
|
||||
import 'package:oc_front/models/resources/resources.dart';
|
||||
import 'package:oc_front/models/resources/storage.dart';
|
||||
import 'package:oc_front/models/resources/workflow.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/models/workspace.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/workspace_service.dart';
|
||||
import 'package:oc_front/pages/catalog.dart';
|
||||
@ -22,7 +26,7 @@ class WorkspaceLocal {
|
||||
static final WorkspaceService _service = WorkspaceService();
|
||||
static List<AbstractItem> items = [];
|
||||
|
||||
static Future<void> init(BuildContext context, bool changeCurrent) async {
|
||||
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;
|
||||
@ -144,7 +148,7 @@ class WorkspaceLocal {
|
||||
}
|
||||
|
||||
static List<AbstractItem> byWorkspace(String id) {
|
||||
List<AbstractItem<FlowData>> d = [];
|
||||
List<AbstractItem> d = [];
|
||||
var w = workspaces[id]!;
|
||||
d = [ ...d, ...w.datas.where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
d = [ ...d, ...w.computes.where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
@ -156,7 +160,7 @@ class WorkspaceLocal {
|
||||
|
||||
static List<AbstractItem> byTopic(String topic, bool all) {
|
||||
if (all) {
|
||||
List<AbstractItem<FlowData>> d = [];
|
||||
List<AbstractItem> d = [];
|
||||
for (var w in workspaces.values) {
|
||||
d = [ ...d, ...w.datas.where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
d = [ ...d, ...w.computes.where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
@ -171,7 +175,7 @@ class WorkspaceLocal {
|
||||
|
||||
static AbstractItem? getItem(String id, bool all) {
|
||||
if (all) {
|
||||
List<AbstractItem<FlowData>> d = [];
|
||||
List<AbstractItem> 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.computes.where((element) => element.id.toString() == id).where((element) => !d.map( (d2) => d2.id).contains(element.id)) ];
|
||||
@ -189,13 +193,15 @@ class WorkspaceLocal {
|
||||
if (!WorkspaceLocal.hasItem(item) && workspaces[current] != null && workspaces[current]!.id != null) {
|
||||
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 == "processing") { workspaces[current]!.processings.add(item as ProcessingItem); }
|
||||
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(), {});
|
||||
} catch (e) { /* */ }
|
||||
_service.put(null, item.id ?? "", workspaces[current]!.serialize(), {});
|
||||
try {
|
||||
_service.put(null, workspaces[current]!.id!, workspaces[current]!.serialize(), {});
|
||||
} catch (e) {
|
||||
_service.put(null, item.id ?? "", workspaces[current]!.serialize(), {});
|
||||
}
|
||||
}
|
||||
}
|
||||
static void removeItem(AbstractItem item) {
|
||||
@ -205,9 +211,11 @@ class WorkspaceLocal {
|
||||
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(), {});
|
||||
} catch (e) { /* */ }
|
||||
_service.put(null, item.id ?? "", workspaces[current]!.serialize(), {});
|
||||
try {
|
||||
_service.put(null, workspaces[current]!.id!, workspaces[current]!.serialize(), {});
|
||||
} catch (e) {
|
||||
_service.put(null, item.id ?? "", workspaces[current]!.serialize(), {});
|
||||
}
|
||||
}
|
||||
static bool hasItemByID(String id) {
|
||||
return items.where((element) => element.id == id).isNotEmpty;
|
||||
|
@ -1,11 +1,12 @@
|
||||
import 'package:flutter/material.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:flutter/material.dart';
|
||||
import 'package:oc_front/pages/shared.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_text_input.dart';
|
||||
import 'package:oc_front/pages/catalog.dart';
|
||||
import 'package:oc_front/widgets/items/item_row.dart';
|
||||
import 'package:oc_front/models/resources/resources.dart';
|
||||
import 'package:oc_front/core/models/workspace_local.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_text_input.dart';
|
||||
import 'package:oc_front/core/models/shared_workspace_local.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_dropdown_input.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/workspace_service.dart';
|
||||
|
||||
@ -62,7 +63,7 @@ class EndDrawerWidgetState extends State<EndDrawerWidget> {
|
||||
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!}",
|
||||
"actually not shared" : "share with ${CollaborativeAreaLocal.workspaces[WorkspaceLocal.workspaces[WorkspaceLocal.current]!.shared!]}",
|
||||
style: TextStyle( fontSize: 14, color: Colors.grey ),),
|
||||
]),
|
||||
),
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:localstorage/localstorage.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';
|
||||
@ -14,7 +15,10 @@ class SearchConstants {
|
||||
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(); }
|
||||
static void clear() {
|
||||
localStorage.setItem("search", "");
|
||||
_searchHost.clear();
|
||||
}
|
||||
}
|
||||
|
||||
class HeaderConstants {
|
||||
@ -56,7 +60,7 @@ class HeaderConstants {
|
||||
}
|
||||
|
||||
class HeaderWidget extends StatefulWidget {
|
||||
HeaderWidget () : super(key: null);
|
||||
const HeaderWidget () : super(key: null);
|
||||
@override HeaderWidgetState createState() => HeaderWidgetState();
|
||||
}
|
||||
class HeaderWidgetState extends State<HeaderWidget> {
|
||||
@ -79,24 +83,34 @@ class HeaderWidgetState extends State<HeaderWidget> {
|
||||
child: Row(crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
InkWell( onTap: () {
|
||||
AppRouter.currentRoute.factory.back(context);
|
||||
},
|
||||
child:
|
||||
Container(width: 50, height: 50,
|
||||
color: Colors.black,
|
||||
child: Center(child: Icon(Icons.keyboard_backspace, color: Colors.white))
|
||||
),
|
||||
),
|
||||
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,
|
||||
filled: midColor,
|
||||
current: AppRouter.currentRoute.factory.getSearch(),
|
||||
width: getMainWidth(context) - 501,
|
||||
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 ))),
|
||||
|
@ -5,13 +5,13 @@ 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/pages/catalog.dart';
|
||||
|
||||
class HeaderMenuWidget extends StatefulWidget{
|
||||
HeaderMenuWidget (): super(key: HeaderConstants.getKey());
|
||||
@override HeaderMenuWidgetState createState() => HeaderMenuWidgetState();
|
||||
}
|
||||
class HeaderMenuWidgetState extends State<HeaderMenuWidget> {
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: getWidth(context),
|
||||
@ -23,12 +23,16 @@ class HeaderMenuWidgetState extends State<HeaderMenuWidget> {
|
||||
child: Stack(children: [
|
||||
AppRouter.currentRoute.factory.searchFill() ? Container() : Positioned( top: 0, left: 30,
|
||||
child: InkWell( onTap: () {
|
||||
CatalogFactory.key.currentState?.widget.isSearch = true;
|
||||
CatalogFactory.key.currentState?.widget.items = [];
|
||||
AppRouter.zones.first.go(context, {});
|
||||
AppRouter.zones.first.factory.getKey().currentState?.setState(() {});
|
||||
HeaderConstants.headerKey.currentState?.setState(() {});
|
||||
},
|
||||
child: Wrap( alignment: WrapAlignment.center, children: [
|
||||
SvgPicture.asset("assets/images/icon.svg", width: 70, height: 70, semanticsLabel: 'OpenCloud Logo'),
|
||||
Container( height: 50, alignment: Alignment.centerLeft, margin: const EdgeInsets.only(left: 20),
|
||||
child: Text(AppRouter.currentRoute.label ?? "Where am I ?", style: TextStyle( color: Colors.grey)))
|
||||
SvgPicture.asset("assets/images/icon.svg", width: 70, height: 70, semanticsLabel: 'OpenCloud Logo'),
|
||||
Container( height: 50, alignment: Alignment.centerLeft, margin: const EdgeInsets.only(left: 20),
|
||||
child: Text(AppRouter.currentRoute.label ?? "Where am I ?", style: TextStyle( color: Colors.grey)))
|
||||
]))),
|
||||
Padding( padding: const EdgeInsets.only(left: 50),
|
||||
child: Row(crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
|
@ -15,7 +15,7 @@ class APIService<T extends SerializerDeserializer> {
|
||||
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' },
|
||||
headers: { 'Content-Type': 'application/json; charset=UTF-8', 'Access-Control-Allow-Origin': '*' },
|
||||
),
|
||||
)..interceptors.add(LogInterceptor( requestHeader: true, ));
|
||||
|
||||
@ -23,7 +23,7 @@ class APIService<T extends SerializerDeserializer> {
|
||||
_dio = Dio(
|
||||
BaseOptions(
|
||||
baseUrl: baseURL, // you can keep this blank
|
||||
headers: { 'Content-Type': 'application/json; charset=UTF-8' },
|
||||
headers: { 'Content-Type': 'application/json; charset=UTF-8', 'Access-Control-Allow-Origin': '*' },
|
||||
),
|
||||
)..interceptors.add(LogInterceptor( requestHeader: true, ),);
|
||||
}
|
||||
@ -84,24 +84,29 @@ class APIService<T extends SerializerDeserializer> {
|
||||
if (resp.error == "") {
|
||||
if (context != null && succeed != "") {
|
||||
// ignore: use_build_context_synchronously
|
||||
showAlertBanner(context, () {}, InfoAlertBannerChild(text: succeed), // <-- Put any widget here you want!
|
||||
try {
|
||||
showAlertBanner(context, () {}, InfoAlertBannerChild(text: succeed), // <-- Put any widget here you want!
|
||||
alertBannerLocation: AlertBannerLocation.bottom,);
|
||||
} catch (e) { /* */ }
|
||||
}
|
||||
return resp;
|
||||
}
|
||||
err = resp.error ?? "internal error";
|
||||
}
|
||||
if (response.statusCode == 401) { err = "not authorized"; }
|
||||
} else if (response.statusCode == 401) { err = "not authorized"; }
|
||||
} catch(e, s) {
|
||||
print(e);
|
||||
print(s);
|
||||
err = e.toString();
|
||||
if (!e.toString().contains("context")) {
|
||||
print(e);
|
||||
print(s);
|
||||
err = e.toString();
|
||||
}
|
||||
}
|
||||
//if (err.contains("token") && err.contains("expired")) { AuthService().unAuthenticate(); }
|
||||
if (context != null) {
|
||||
// ignore: use_build_context_synchronously
|
||||
showAlertBanner( context, () {}, AlertAlertBannerChild(text: err),// <-- Put any widget here you want!
|
||||
try {
|
||||
showAlertBanner( context, () {}, AlertAlertBannerChild(text: err),// <-- Put any widget here you want!
|
||||
alertBannerLocation: AlertBannerLocation.bottom,);
|
||||
} catch (e) { /* */ }
|
||||
}
|
||||
throw Exception(err);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import 'package:oc_front/main.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
class AuthService {
|
||||
static var isAuth = const bool.fromEnvironment('AUTH_MODE', defaultValue: false);
|
||||
static final _clientID = const String.fromEnvironment('CLIENT_ID', defaultValue: 'test-client');
|
||||
static APIService<SimpleData> service = APIService(
|
||||
baseURL: const String.fromEnvironment('AUTH_HOST', defaultValue: 'http://localhost:8080/auth'),
|
||||
);
|
||||
@ -32,7 +33,8 @@ class AuthService {
|
||||
if (!isAuth) {
|
||||
return true;
|
||||
}
|
||||
return (localStorage.getItem('accessToken') ?? "") != "";
|
||||
return (localStorage.getItem('accessToken') ?? "") != ""
|
||||
&& localStorage.getItem('username') != "";
|
||||
}
|
||||
|
||||
static String? getUsername() {
|
||||
@ -43,7 +45,7 @@ class AuthService {
|
||||
}
|
||||
|
||||
static Future<void> login(String username, String password) async {
|
||||
var token = await service.post("/ldap/login", <String, dynamic> {
|
||||
var token = await service.post("/login?client_id=$_clientID", <String, dynamic> {
|
||||
"username": username,
|
||||
"password": password
|
||||
}, null);
|
||||
@ -51,16 +53,16 @@ class AuthService {
|
||||
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(() {});
|
||||
localStorage.setItem('expiresIn', DateTime.now().add(
|
||||
Duration(seconds: token.data?.value['expires_in'])).toIso8601String());
|
||||
mainKey?.currentState?.setState(() {});
|
||||
PermsService.init(token.data?.value['access_token']);
|
||||
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);
|
||||
var token = await service.delete("/logout?client_id=$_clientID", null);
|
||||
if (token.code == 200) {
|
||||
localStorage.setItem('accessToken', '');
|
||||
localStorage.setItem('username', '');
|
||||
@ -73,13 +75,14 @@ class AuthService {
|
||||
if (!isConnected()) {
|
||||
return false;
|
||||
}
|
||||
var isIntrospected = await service.get("/introspect", true, null);
|
||||
// ignore: invalid_return_type_for_catch_error
|
||||
var isIntrospected = await service.get("/introspect", true, null).catchError((e) => mainKey?.currentState?.setState(() {}));
|
||||
return isIntrospected.code == 200;
|
||||
}
|
||||
|
||||
static Future<void> refresh(String accessToken, String username, Duration duration) async {
|
||||
Future.delayed(duration, () {
|
||||
service.post("/refresh", <String, dynamic> {
|
||||
service.post("/refresh?client_id=$_clientID", <String, dynamic> {
|
||||
"access_token": accessToken,
|
||||
"username": username
|
||||
}, null).then((token) {
|
||||
|
49
lib/core/services/enum_service.dart
Normal file
49
lib/core/services/enum_service.dart
Normal file
@ -0,0 +1,49 @@
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/core/services/api_service.dart';
|
||||
|
||||
class EnumService {
|
||||
static final APIService<EnumData> _service = APIService<EnumData>(
|
||||
baseURL: const String.fromEnvironment('ITEM_HOST',
|
||||
defaultValue: 'http://localhost:8080/catalog')
|
||||
);
|
||||
static String subPath = "/enum/";
|
||||
static Map<String, Map<String,dynamic>> enums = {};
|
||||
|
||||
static int? get(String path, dynamic name) {
|
||||
var n = enums[path];
|
||||
if (n == null) {
|
||||
return null;
|
||||
}
|
||||
var names = "$name";
|
||||
for (var nn in n.keys) {
|
||||
if (n[nn] == names || nn == names) {
|
||||
return int.parse(nn);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static void init() {
|
||||
_load("infrastructure");
|
||||
_load("storage/type");
|
||||
_load("storage/size");
|
||||
_load("resource/type");
|
||||
_load("booking/status");
|
||||
_load("status");
|
||||
_load("pricing/strategy/buy");
|
||||
_load("pricing/strategy/data");
|
||||
_load("pricing/strategy/time");
|
||||
_load("pricing/strategy/storage");
|
||||
_load("pricing/strategy/privilege/storage");
|
||||
_load("pricing/strategy/privilege");
|
||||
_load("pricing/refund/type");
|
||||
}
|
||||
|
||||
static void _load(String name) {
|
||||
_service.get("$subPath$name", false, null).then((response) {
|
||||
if (response.code == 200) {
|
||||
enums[name] = response.data!.value;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:oc_front/main.dart';
|
||||
|
||||
enum Perms {
|
||||
SEARCH_INTERNAL,// ignore: constant_identifier_names
|
||||
SEARCH_EXTERNAL, // ignore: constant_identifier_names
|
||||
@ -23,21 +25,21 @@ enum Perms {
|
||||
}
|
||||
|
||||
Map<Perms, String> perms = {
|
||||
Perms.SEARCH_INTERNAL: 'GET__catalog_compute_search_search'.toUpperCase(),
|
||||
Perms.SEARCH_INTERNAL: 'GET__CATALOG_COMPUTE_SEARCH_SEARCH'.toUpperCase(),
|
||||
Perms.SEARCH_EXTERNAL: 'Search External'.toUpperCase(),
|
||||
Perms.WORKSPACE_SHARE: 'POST__shared_collaborative_area_id_workspace_id2'.toUpperCase(),
|
||||
Perms.WORKFLOW_CREATE: 'POST__workflow_'.toUpperCase(),
|
||||
Perms.WORKFLOW_UNSHARE: 'DELETE__shared_collaborative_area_id_workflow_id2'.toUpperCase(),
|
||||
Perms.PEER_SHARE: 'POST__shared_collaborative_area_id_peer_id2'.toUpperCase(),
|
||||
Perms.PEER_UNSHARE: 'DELETE__shared_collaborative_area_id_peer_id2'.toUpperCase(),
|
||||
Perms.COLLABORATIVE_AREA_CREATE: 'POST__shared_collaborative_area_'.toUpperCase(),
|
||||
Perms.COLLABORATIVE_AREA_EDIT: 'PUT__shared_collaborative_area_id'.toUpperCase(),
|
||||
Perms.COLLABORATIVE_AREA_DELETE: 'DELETE__shared_collaborative_area_id'.toUpperCase(),
|
||||
Perms.WORKSPACE_UNSHARE: 'DELETE__shared_collaborative_area_id_workspace_id2'.toUpperCase(),
|
||||
Perms.WORKFLOW_EDIT: 'PUT__workflow_id'.toUpperCase(),
|
||||
Perms.WORKFLOW_DELETE: 'DELETE__workflow_id'.toUpperCase(),
|
||||
Perms.WORKFLOW_BOOKING: 'POST__datacenter_booking_'.toUpperCase(),
|
||||
Perms.WORKFLOW_SHARE: 'POST__shared_collaborative_area_id_workflow_id2'.toUpperCase(),
|
||||
Perms.WORKSPACE_SHARE: 'POST__SHARED_COLLABORATIVE_AREA_ID_WORKSPACE_ID2'.toUpperCase(),
|
||||
Perms.WORKFLOW_CREATE: 'POST__WORKFLOW_'.toUpperCase(),
|
||||
Perms.WORKFLOW_UNSHARE: 'DELETE__SHARED_COLLABORATIVE_AREA_ID_WORKFLOW_ID2'.toUpperCase(),
|
||||
Perms.PEER_SHARE: 'POST__SHARED_COLLABORATIVE_AREA_ID_PEER_ID2'.toUpperCase(),
|
||||
Perms.PEER_UNSHARE: 'DELETE__SHARED_COLLABORATIVE_AREA_ID_PEER_ID2'.toUpperCase(),
|
||||
Perms.COLLABORATIVE_AREA_CREATE: 'POST__SHARED_COLLABORATIVE_AREA_'.toUpperCase(),
|
||||
Perms.COLLABORATIVE_AREA_EDIT: 'PUT__SHARED_COLLABORATIVE_AREA_ID'.toUpperCase(),
|
||||
Perms.COLLABORATIVE_AREA_DELETE: 'DELETE__SHARED_COLLABORATIVE_AREA_ID'.toUpperCase(),
|
||||
Perms.WORKSPACE_UNSHARE: 'DELETE__SHARED_COLLABORATIVE_AREA_ID_WORKSPACE_ID2'.toUpperCase(),
|
||||
Perms.WORKFLOW_EDIT: 'PUT__WORKFLOW_ID'.toUpperCase(),
|
||||
Perms.WORKFLOW_DELETE: 'DELETE__WORKFLOW_ID'.toUpperCase(),
|
||||
Perms.WORKFLOW_BOOKING: 'POST__DATACENTER_BOOKING_'.toUpperCase(),
|
||||
Perms.WORKFLOW_SHARE: 'POST__SHARED_COLLABORATIVE_AREA_ID_WORKFLOW_ID2'.toUpperCase(),
|
||||
};
|
||||
|
||||
class PermsService {
|
||||
@ -69,7 +71,7 @@ class PermsService {
|
||||
try {
|
||||
var what = json.decode(foo);
|
||||
what = what["session"]["access_token"] as Map<String, dynamic>;
|
||||
|
||||
|
||||
for (var w in perms.keys) {
|
||||
if (what.keys.contains(perms[w])) {
|
||||
_perms[w] = true;
|
||||
@ -77,6 +79,7 @@ class PermsService {
|
||||
_perms[w] = false;
|
||||
}
|
||||
}
|
||||
mainKey?.currentState?.setState(() {});
|
||||
} catch (e) {/**/}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ class AppRouter {
|
||||
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 catalogItem = RouterItem(label: "resource", description: "", help: "", route: "catalog/:id", factory: CatalogItemFactory(), args: ["id"]);
|
||||
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 compute = RouterItem(icon: Icons.dns_outlined, label: "my compute", route: "compute", factory: DatacenterFactory());
|
||||
|
@ -4,21 +4,20 @@ import 'package:oc_front/core/services/specialized_services/abstract_service.dar
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/models/workflow.dart';
|
||||
|
||||
class BookingExecutionService extends AbstractService<WorkflowExecutions> {
|
||||
@override APIService<WorkflowExecutions> service = APIService<WorkflowExecutions>(
|
||||
class BookingExecutionService extends AbstractService<WorkflowExecution> {
|
||||
@override APIService<WorkflowExecution> service = APIService<WorkflowExecution>(
|
||||
baseURL: const String.fromEnvironment('DATACENTER_HOST', defaultValue: 'http://localhost:8080/datacenter')
|
||||
);
|
||||
@override String subPath = "/booking/";
|
||||
|
||||
@override Future<APIResponse<WorkflowExecutions>> search(BuildContext? context, List<String> words, Map<String, dynamic> params) {
|
||||
print("${subPath}search/${words.join("/")}");
|
||||
@override Future<APIResponse<WorkflowExecution>> search(BuildContext? context, List<String> words, Map<String, dynamic> params) {
|
||||
return service.get("${subPath}search/${words.join("/")}", false, context);
|
||||
}
|
||||
|
||||
@override Future<APIResponse<WorkflowExecutions>> post(BuildContext? context, Map<String, dynamic> body, Map<String, String> params) {
|
||||
@override Future<APIResponse<WorkflowExecution>> post(BuildContext? context, Map<String, dynamic> body, Map<String, String> params) {
|
||||
return throw UnimplementedError();
|
||||
}
|
||||
@override Future<APIResponse<WorkflowExecutions>> put(BuildContext? context, String id, Map<String, dynamic> body, Map<String, String> params) {
|
||||
@override Future<APIResponse<WorkflowExecution>> put(BuildContext? context, String id, Map<String, dynamic> body, Map<String, String> params) {
|
||||
return throw UnimplementedError();
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/core/services/api_service.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/abstract_service.dart';
|
||||
import 'package:oc_front/models/resources/resources.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
|
||||
class DatacenterService extends AbstractService<Resource> {
|
||||
@override APIService<Resource> service = APIService<Resource>(
|
||||
baseURL: const String.fromEnvironment('DATACENTER_HOST', defaultValue: 'http://localhost:8080/datacenter')
|
||||
);
|
||||
@override String subPath = "/";
|
||||
|
||||
@override Future<APIResponse<Resource>> search(BuildContext? context, List<String> words, Map<String, dynamic> params) {
|
||||
return throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override Future<APIResponse<Resource>> post(BuildContext? context, Map<String, dynamic> body, Map<String, String> params) {
|
||||
return throw UnimplementedError();
|
||||
}
|
||||
@override Future<APIResponse<Resource>> put(BuildContext? context, String id, Map<String, dynamic> body, Map<String, String> params) {
|
||||
return throw UnimplementedError();
|
||||
}
|
||||
}
|
@ -16,7 +16,6 @@ class LogsService extends AbstractService<LogsResult> {
|
||||
if (p == "start" || p == "end") { continue; }
|
||||
v.add("$p=\"${params[p]}\"");
|
||||
}
|
||||
print("${subPath}query_range?query={${v.join(", ")}}&start=${params["start"].toString().substring(0, 10)}&end=${params["end"].toString().substring(0, 10)}");
|
||||
return service.get("${subPath}query_range?query={${v.join(", ")}}&start=${params["start"].toString().substring(0, 10)}&end=${params["end"].toString().substring(0, 10)}", false, context);
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/core/services/api_service.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/abstract_service.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/core/services/api_service.dart';
|
||||
import 'package:oc_front/models/resources/resources.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/abstract_service.dart';
|
||||
|
||||
class ResourceService extends AbstractService<Resource> {
|
||||
@override APIService<Resource> service = APIService<Resource>(
|
||||
|
@ -10,6 +10,10 @@ class WorkflowExecutionService extends AbstractService<WorkflowExecutions> {
|
||||
);
|
||||
@override String subPath = "/";
|
||||
|
||||
Future<APIResponse<WorkflowExecutions>> schedule(BuildContext? context, String id, Map<String, dynamic> body, Map<String, dynamic> params) {
|
||||
return service.post("${subPath}workflow/$id", body, context);
|
||||
}
|
||||
|
||||
@override Future<APIResponse<WorkflowExecutions>> search(BuildContext? context, List<String> words, Map<String, dynamic> params) {
|
||||
return service.get("${subPath}search/${words.join("/")}", false, context);
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ 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/enum_service.dart';
|
||||
import 'package:oc_front/core/services/router.dart';
|
||||
import 'package:oc_front/core/sections/end_drawer.dart';
|
||||
import 'package:oc_front/widgets/dialog/login.dart';
|
||||
@ -27,6 +28,8 @@ class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
AuthService.init();
|
||||
EnumService.init();
|
||||
SearchConstants.clear();
|
||||
return MaterialApp.router( routerConfig: GoRouter( routes: AppRouter.routes ) );
|
||||
}
|
||||
}
|
||||
@ -68,7 +71,7 @@ double getMainHeight(BuildContext context) {
|
||||
double getMainWidth(BuildContext context) {
|
||||
return getWidth(context) - 50;
|
||||
}
|
||||
|
||||
bool loginIsSet = false;
|
||||
class MainPageState extends State<MainPage> {
|
||||
bool isCtrl = false;
|
||||
final FocusNode node = FocusNode();
|
||||
@ -89,12 +92,12 @@ class MainPageState extends State<MainPage> {
|
||||
// than having to individually change instances of widgets.i
|
||||
scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
isCtrl = false;
|
||||
if (!AuthService.isConnected()) {
|
||||
print("isConnected: ${AuthService.isConnected()}");
|
||||
if (!AuthService.isConnected() && !loginIsSet) {
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
loginIsSet = true;
|
||||
showDialog(
|
||||
barrierDismissible: false,
|
||||
context: context, builder: (context) {
|
||||
context: context ?? context, builder: (context) {
|
||||
return AlertDialog(
|
||||
insetPadding: EdgeInsets.zero,
|
||||
backgroundColor: Colors.white,
|
||||
@ -105,9 +108,7 @@ class MainPageState extends State<MainPage> {
|
||||
}
|
||||
return FutureBuilder(future: AuthService.init(),
|
||||
builder: (e, s) {
|
||||
WorkspaceLocal.init(context, false);
|
||||
CollaborativeAreaLocal.init(context, false);
|
||||
|
||||
WorkspaceLocal.init(context, false);
|
||||
HeaderConstants.height = HeaderConstants.isNoHeader(AppRouter.currentRoute.route) || AppRouter.currentRoute.factory.searchFill() ? 50 : 100;
|
||||
return Scaffold( key: scaffoldKey, endDrawer: EndDrawerWidget(), body:
|
||||
SingleChildScrollView(
|
||||
|
222
lib/models/resources/compute.dart
Normal file
222
lib/models/resources/compute.dart
Normal file
@ -0,0 +1,222 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/core/services/enum_service.dart';
|
||||
import 'package:oc_front/models/abstract.dart';
|
||||
import 'package:oc_front/models/resources/processing.dart';
|
||||
import 'package:oc_front/models/resources/resources.dart';
|
||||
|
||||
class ComputeItem extends AbstractItem<ComputePricing, ComputePartnership, ComputeInstance, ComputeItem> {
|
||||
// special attributes
|
||||
int? infrastructureEnum;
|
||||
String? architecture;
|
||||
|
||||
ComputeItem({
|
||||
this.infrastructureEnum,
|
||||
this.architecture
|
||||
}): super();
|
||||
|
||||
@override String get topic => "compute";
|
||||
|
||||
@override deserialize(dynamic data) {
|
||||
try { data = data as Map<String, dynamic>;
|
||||
} catch (e) { return ComputeItem(); }
|
||||
var w = ComputeItem(
|
||||
infrastructureEnum: data.containsKey("infrastructure") ? EnumService.get("infrastructure", data["infrastructure"]) : null,
|
||||
architecture: data.containsKey("architecture") && data["architecture"] != null ? data["architecture"] : null,
|
||||
);
|
||||
w.mapFromJSON(data, ComputeInstance());
|
||||
if (w.logo != null) { // get image dimensions
|
||||
var image = Image.network(w.logo!);
|
||||
image.image
|
||||
.resolve(const ImageConfiguration())
|
||||
.addListener(
|
||||
ImageStreamListener(
|
||||
(ImageInfo info, bool _) {
|
||||
w.width = info.image.width.toDouble();
|
||||
w.height = info.image.height.toDouble();
|
||||
}));
|
||||
}
|
||||
return w;
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> infos() {
|
||||
return {
|
||||
"infrastructure": EnumService.enums["infrastructure"] != null
|
||||
&& EnumService.enums["infrastructure"]!["$infrastructureEnum"] != null ? EnumService.enums["infrastructure"]!["$infrastructureEnum"] : infrastructureEnum,
|
||||
"architecture": architecture,
|
||||
};
|
||||
}
|
||||
|
||||
@override Map<String, dynamic> serialize() {
|
||||
Map<String, dynamic> obj = infos();
|
||||
obj["infrastructure"] = infrastructureEnum;
|
||||
obj.addAll(toJSON());
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
class ComputeInstance extends AbstractInstance<ComputePricing, ComputePartnership> {
|
||||
String? securityLevel;
|
||||
List<String>? powerSources = [];
|
||||
double? annualEnergyConsumption;
|
||||
Map<String,CPU> cpus = {};
|
||||
Map<String,GPU> gpus = {};
|
||||
List<ComputeNode> nodes = [];
|
||||
|
||||
ComputeInstance({
|
||||
this.securityLevel,
|
||||
this.powerSources = const [],
|
||||
this.annualEnergyConsumption,
|
||||
this.cpus = const {},
|
||||
this.gpus = const {},
|
||||
this.nodes = const [],
|
||||
}): super();
|
||||
|
||||
@override
|
||||
Map<String, dynamic> infos() {
|
||||
return {
|
||||
"security_level": securityLevel,
|
||||
"power_sources": powerSources,
|
||||
"annual_co2_emissions": annualEnergyConsumption,
|
||||
"cpus": toMapJson(cpus),
|
||||
"gpus": toMapJson(gpus),
|
||||
"nodes": toListJson(nodes),
|
||||
"inputs": toListJson(inputs),
|
||||
"outputs": toListJson(outputs),
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
ComputeInstance deserialize(json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return ComputeInstance(); }
|
||||
var w = ComputeInstance(
|
||||
securityLevel: json.containsKey("security_level") && json["security_level"] != null ? json["security_level"] : null,
|
||||
powerSources: json.containsKey("power_sources") && json["power_sources"] != null ? List<String>.from(json["power_sources"]) : [],
|
||||
annualEnergyConsumption: json.containsKey("annual_co2_emissions") && json["annual_co2_emissions"] != null ? json["annual_co2_emissions"] : null,
|
||||
//cpus: json.containsKey("cpus") && json["cpus"] != null ? fromMapJson(json["cpus"], CPU()) : {},
|
||||
// gpus: json.containsKey("gpus") && json["gpus"] != null ? fromMapJson(json["gpus"], GPU()) : {},
|
||||
//nodes: json.containsKey("nodes") && json["nodes"] != null ? fromListJson(json["nodes"], ComputeNode()) : [],
|
||||
);
|
||||
w.mapFromJSON(json, ComputePartnership());
|
||||
return w;
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> serialize() {
|
||||
var obj = infos();
|
||||
obj.addAll(toJSON());
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
class ComputePartnership extends AbstractPartnerShip<ComputePricing> {
|
||||
Map<String, dynamic> maxAllowedCPUsCores = {};
|
||||
Map<String, dynamic> maxAllowedGPUsMemoryGB = {};
|
||||
double? maxAllowedRAM;
|
||||
|
||||
ComputePartnership({
|
||||
this.maxAllowedCPUsCores = const {},
|
||||
this.maxAllowedGPUsMemoryGB = const {},
|
||||
this.maxAllowedRAM,
|
||||
}): super();
|
||||
|
||||
@override
|
||||
ComputePartnership deserialize(json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return ComputePartnership(); }
|
||||
var w = ComputePartnership(
|
||||
maxAllowedCPUsCores: json.containsKey("allowed_cpus") && json["allowed_cpus"] != null ? json["allowed_cpus"] : {},
|
||||
maxAllowedGPUsMemoryGB: json.containsKey("allowed_gpus") && json["allowed_gpus"] != null ? json["allowed_gpus"] : {},
|
||||
maxAllowedRAM: json.containsKey("allowed_ram") && json["allowed_ram"] != null ? double.parse("${json["allowed_ram"]}") : null,
|
||||
);
|
||||
w.mapFromJSON(json, ComputePricing());
|
||||
return w;
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> serialize() {
|
||||
Map<String, dynamic> obj = {
|
||||
"allowed_cpus": maxAllowedCPUsCores,
|
||||
"allowed_gpus": maxAllowedGPUsMemoryGB,
|
||||
"allowed_ram": maxAllowedRAM,
|
||||
};
|
||||
obj.addAll(toJSON());
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ComputePricing extends AbstractPricing {
|
||||
Map<String, dynamic> cpusPrice = {};
|
||||
Map<String, dynamic> gpusPrice = {};
|
||||
double? ramPrice;
|
||||
|
||||
ComputePricing({
|
||||
this.cpusPrice = const {},
|
||||
this.gpusPrice = const {},
|
||||
this.ramPrice,
|
||||
});
|
||||
|
||||
@override ComputePricing deserialize(json) {
|
||||
var w = ComputePricing(
|
||||
cpusPrice: json.containsKey("cpus") && json["cpus"] != null ? json["cpus"] : {},
|
||||
gpusPrice: json.containsKey("gpus") && json["gpus"] != null ? json["gpus"] : {},
|
||||
ramPrice: json.containsKey("ram") && json["ram"] != null ? json["ram"] : null,
|
||||
);
|
||||
w.mapFromJSON(json);
|
||||
return w;
|
||||
}
|
||||
@override
|
||||
Map<String, dynamic> serialize() {
|
||||
var obj = {
|
||||
"cpus": cpusPrice,
|
||||
"gpus": gpusPrice,
|
||||
"ram": ramPrice,
|
||||
};
|
||||
obj.addAll(toJSON());
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
class ComputeNode extends SerializerDeserializer<ComputeNode> {
|
||||
String? name;
|
||||
int? quantity;
|
||||
Map<String,dynamic> cpus = {};
|
||||
Map<String,dynamic> gpus = {};
|
||||
RAM? ram;
|
||||
|
||||
ComputeNode({
|
||||
this.cpus = const {},
|
||||
this.gpus = const {},
|
||||
this.ram,
|
||||
this.name,
|
||||
this.quantity,
|
||||
});
|
||||
|
||||
@override
|
||||
ComputeNode deserialize(json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return ComputeNode(); }
|
||||
return ComputeNode(
|
||||
name: json.containsKey("name") && json["name"] != null ? json["name"] : null,
|
||||
quantity: json.containsKey("quantity") && json["quantity"] != null ? json["quantity"] : null,
|
||||
cpus: json.containsKey("cpus") && json["cpus"] != null ? fromMapJson(json["cpus"], CPU()) : {},
|
||||
gpus: json.containsKey("gpus") && json["gpus"] != null ? fromMapJson(json["gpus"], GPU()) : {},
|
||||
ram: json.containsKey("ram") && json["ram"] != null ? RAM().deserialize(json["ram"]) : null,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> serialize() {
|
||||
return {
|
||||
"name": name,
|
||||
"quantity": quantity,
|
||||
"cpus": cpus,
|
||||
"gpus": gpus,
|
||||
"ram": ram!.serialize(),
|
||||
};
|
||||
}
|
||||
|
||||
}
|
166
lib/models/resources/data.dart
Normal file
166
lib/models/resources/data.dart
Normal file
@ -0,0 +1,166 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/models/abstract.dart';
|
||||
import 'package:oc_front/models/resources/resources.dart';
|
||||
|
||||
class DataItem extends AbstractItem<DataPricing, DataPartnership, DataInstance, DataItem> {
|
||||
// special attributes
|
||||
String? type;
|
||||
String? source;
|
||||
String? quality;
|
||||
bool openData = false;
|
||||
bool static = false;
|
||||
bool personalData = false;
|
||||
bool anonymizedPersonalData = false;
|
||||
double? size;
|
||||
String? example;
|
||||
DateTime? updatePeriod;
|
||||
|
||||
DataItem({
|
||||
this.type,
|
||||
this.source,
|
||||
this.quality,
|
||||
this.openData = false,
|
||||
this.static = false,
|
||||
this.personalData = false,
|
||||
this.anonymizedPersonalData = false,
|
||||
this.size,
|
||||
this.example,
|
||||
this.updatePeriod,
|
||||
}): super();
|
||||
|
||||
@override String get topic => "data";
|
||||
|
||||
@override deserialize(dynamic data) {
|
||||
try { data = data as Map<String, dynamic>;
|
||||
} catch (e) { return DataItem(); }
|
||||
var w = DataItem(
|
||||
type: data.containsKey("type") && data["type"] != null ? data["type"] : null,
|
||||
source: data.containsKey("source") && data["source"] != null ? data["source"] : null,
|
||||
quality: data.containsKey("quality") && data["quality"] != null ? data["quality"] : null,
|
||||
openData: data.containsKey("open_data") && data["open_data"] != null ? data["open_data"] : false,
|
||||
static: data.containsKey("static") && data["static"] != null ? data["static"] : false,
|
||||
personalData: data.containsKey("personal_data") && data["l"] != null ? data["personal_data"] : false,
|
||||
anonymizedPersonalData: data.containsKey("anonymized_personal_data") && data["anonymized_personal_data"] != null ? data["anonymized_personal_data"] : false,
|
||||
size: data.containsKey("size") && data["size"] != null ? data["size"] : null,
|
||||
example: data.containsKey("example") && data["example"] != null ? data["example"] : null,
|
||||
updatePeriod: data.containsKey("update_period") && data["update_period"] != null ? DateTime.parse(data["update_period"]) : null,
|
||||
);
|
||||
w.mapFromJSON(data, DataInstance());
|
||||
if (w.logo != null) { // get image dimensions
|
||||
var image = Image.network(w.logo!);
|
||||
image.image
|
||||
.resolve(const ImageConfiguration())
|
||||
.addListener(
|
||||
ImageStreamListener(
|
||||
(ImageInfo info, bool _) {
|
||||
w.width = info.image.width.toDouble();
|
||||
w.height = info.image.height.toDouble();
|
||||
}));
|
||||
}
|
||||
return w;
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> infos() {
|
||||
return {
|
||||
"type": type,
|
||||
"quality": quality,
|
||||
"open_data": openData,
|
||||
"static": static,
|
||||
"personal_data": personalData,
|
||||
"anonymized_personal_data": anonymizedPersonalData,
|
||||
"size": size,
|
||||
"example": example,
|
||||
"update_period": updatePeriod?.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
@override Map<String, dynamic> serialize() {
|
||||
var obj = infos();
|
||||
obj.addAll(toJSON());
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
class DataInstance extends AbstractInstance<DataPricing, DataPartnership> {
|
||||
String? source;
|
||||
DataInstance(
|
||||
{this.source}
|
||||
): super();
|
||||
|
||||
@override
|
||||
Map<String, dynamic> infos() {
|
||||
return {
|
||||
"inputs": toListJson(inputs),
|
||||
"outputs": toListJson(outputs),
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
DataInstance deserialize(json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return DataInstance(); }
|
||||
var w = DataInstance(
|
||||
source: json.containsKey("source") && json["source"] != null ? json["source"] : null,
|
||||
);
|
||||
w.mapFromJSON(json, DataPartnership());
|
||||
return w;
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> serialize() {
|
||||
var obj = toJSON();
|
||||
obj["source"] = source;
|
||||
obj.addAll(infos());
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
class DataPartnership extends AbstractPartnerShip<DataPricing> {
|
||||
double? maxDownloadableGBAllowed;
|
||||
bool personalDataAllowed = false;
|
||||
bool anonymizedPersonalDataAllowed = false;
|
||||
|
||||
DataPartnership({
|
||||
this.maxDownloadableGBAllowed,
|
||||
this.personalDataAllowed = false,
|
||||
this.anonymizedPersonalDataAllowed = false,
|
||||
}): super();
|
||||
|
||||
@override
|
||||
DataPartnership deserialize(json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return DataPartnership(); }
|
||||
var w = DataPartnership(
|
||||
maxDownloadableGBAllowed: json.containsKey("max_downloadable_gb_allowed") && json["max_downloadable_gb_allowed"] != null ? json["max_downloadable_gb_allowed"] : null,
|
||||
personalDataAllowed: json.containsKey("personal_data_allowed") && json["personal_data_allowed"] != null ? json["personal_data_allowed"] : false,
|
||||
anonymizedPersonalDataAllowed: json.containsKey("anonymized_personal_data_allowed") && json["anonymized_personal_data_allowed"] != null ? json["anonymized_personal_data_allowed"] : false,
|
||||
);
|
||||
w.mapFromJSON(json, DataPricing());
|
||||
return w;
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> serialize() {
|
||||
Map<String, dynamic> obj = {
|
||||
"max_downloadable_gb_allowed": maxDownloadableGBAllowed,
|
||||
"personal_data_allowed": personalDataAllowed,
|
||||
"anonymized_personal_data_allowed": anonymizedPersonalDataAllowed,
|
||||
};
|
||||
obj.addAll(toJSON());
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
class DataPricing extends AbstractPricing {
|
||||
@override DataPricing deserialize(json) {
|
||||
var w = DataPricing();
|
||||
w.mapFromJSON(json);
|
||||
return w;
|
||||
}
|
||||
@override
|
||||
Map<String, dynamic> serialize() {
|
||||
return toJSON();
|
||||
}
|
||||
}
|
357
lib/models/resources/processing.dart
Normal file
357
lib/models/resources/processing.dart
Normal file
@ -0,0 +1,357 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/core/services/enum_service.dart';
|
||||
import 'package:oc_front/models/abstract.dart';
|
||||
import 'package:oc_front/models/resources/resources.dart';
|
||||
|
||||
class ProcessingItem extends AbstractItem<ProcessingPricing, ProcessingPartnership, ProcessingInstance, ProcessingItem> {
|
||||
// special attributes
|
||||
int? infrastructureEnum;
|
||||
bool isService = false;
|
||||
bool openSource = false;
|
||||
String? license;
|
||||
String? maturity;
|
||||
ProcessingUsage? usage;
|
||||
|
||||
ProcessingItem({
|
||||
this.infrastructureEnum,
|
||||
this.isService = false,
|
||||
this.openSource = false,
|
||||
this.license,
|
||||
this.maturity,
|
||||
this.usage,
|
||||
}): super();
|
||||
|
||||
@override String get topic => "processing";
|
||||
|
||||
@override deserialize(dynamic data) {
|
||||
try { data = data as Map<String, dynamic>;
|
||||
} catch (e) { return ProcessingItem(); }
|
||||
var w = ProcessingItem(
|
||||
infrastructureEnum: data.containsKey("infrastructure") ? EnumService.get("infrastructure", data["infrastructure"]) : null,
|
||||
isService: data.containsKey("is_service") && data["is_service"] != null ? data["is_service"] : false,
|
||||
openSource: data.containsKey("open_source") && data["open_source"] != null ? data["open_source"] : false,
|
||||
license: data.containsKey("license") && data["license"] != null ? data["license"] : null,
|
||||
maturity: data.containsKey("maturity") && data["maturity"] != null ? data["maturity"] : null,
|
||||
usage: data.containsKey("usage") && data["usage"] != null ? ProcessingUsage().deserialize(data["usage"]) : null,
|
||||
);
|
||||
w.mapFromJSON(data, ProcessingInstance());
|
||||
if (w.logo != null) { // get image dimensions
|
||||
var image = Image.network(w.logo!);
|
||||
image.image
|
||||
.resolve(const ImageConfiguration())
|
||||
.addListener(
|
||||
ImageStreamListener(
|
||||
(ImageInfo info, bool _) {
|
||||
w.width = info.image.width.toDouble();
|
||||
w.height = info.image.height.toDouble();
|
||||
}));
|
||||
}
|
||||
return w;
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> infos() {
|
||||
return {
|
||||
"infrastructure": EnumService.enums["infrastructure"] != null
|
||||
&& EnumService.enums["infrastructure"]!["$infrastructureEnum"] != null ?
|
||||
EnumService.enums["infrastructure"]!["$infrastructureEnum"] : infrastructureEnum,
|
||||
"is_service": isService,
|
||||
"open_source": openSource,
|
||||
"license": license,
|
||||
"maturity": maturity,
|
||||
};
|
||||
}
|
||||
|
||||
@override Map<String, dynamic> serialize() {
|
||||
var obj = infos();
|
||||
obj["infrastructure"] = infrastructureEnum;
|
||||
obj["usage"] = usage?.serialize();
|
||||
obj.addAll(toJSON());
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
class ProcessingAccess extends SerializerDeserializer<ProcessingAccess> {
|
||||
Containered? container;
|
||||
|
||||
ProcessingAccess({
|
||||
this.container,
|
||||
});
|
||||
|
||||
@override ProcessingAccess deserialize(dynamic json) {
|
||||
try {
|
||||
json = json as Map<String, dynamic>;
|
||||
} catch (e) {
|
||||
return ProcessingAccess();
|
||||
}
|
||||
return ProcessingAccess(
|
||||
container: json.containsKey("container") && json["container"] != null ? Containered().deserialize(json["container"]) : null,
|
||||
);
|
||||
}
|
||||
|
||||
@override Map<String, dynamic> serialize() {
|
||||
return {
|
||||
"container": container?.serialize(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class ProcessingInstance extends AbstractInstance<ProcessingPricing, ProcessingPartnership> {
|
||||
ProcessingAccess? access;
|
||||
ProcessingInstance(
|
||||
{this.access}
|
||||
): super();
|
||||
|
||||
@override
|
||||
ProcessingInstance deserialize(json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return ProcessingInstance(); }
|
||||
var w = ProcessingInstance();
|
||||
w.access = json.containsKey("access") && json["access"] != null ? ProcessingAccess().deserialize(json['access']) : null;
|
||||
w.mapFromJSON(json, ProcessingPartnership());
|
||||
return w;
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> serialize() {
|
||||
var obj = toJSON();
|
||||
obj["access"] = access?.serialize();
|
||||
return obj;
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> infos() {
|
||||
return {
|
||||
"inputs": toListJson(inputs),
|
||||
"outputs": toListJson(outputs),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class ProcessingPartnership extends AbstractPartnerShip<ProcessingPricing> {
|
||||
ProcessingPartnership(): super();
|
||||
|
||||
@override
|
||||
ProcessingPartnership deserialize(json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return ProcessingPartnership(); }
|
||||
var w = ProcessingPartnership();
|
||||
w.mapFromJSON(json, ProcessingPricing());
|
||||
return w;
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> serialize() {
|
||||
return toJSON();
|
||||
}
|
||||
}
|
||||
|
||||
class ProcessingPricing extends AbstractPricing {
|
||||
@override ProcessingPricing deserialize(json) {
|
||||
var w = ProcessingPricing();
|
||||
w.mapFromJSON(json);
|
||||
return w;
|
||||
}
|
||||
@override
|
||||
Map<String, dynamic> serialize() {
|
||||
return toJSON();
|
||||
}
|
||||
}
|
||||
|
||||
class ProcessingUsage extends SerializerDeserializer<ProcessingUsage> {
|
||||
Map<String,CPU> cpus = {};
|
||||
Map<String,GPU> gpus = {};
|
||||
RAM? ram;
|
||||
double? storageSize;
|
||||
String? hypothesis;
|
||||
String? scalingModel;
|
||||
|
||||
ProcessingUsage({
|
||||
this.cpus = const {},
|
||||
this.gpus = const {},
|
||||
this.ram,
|
||||
this.storageSize,
|
||||
this.hypothesis,
|
||||
this.scalingModel,
|
||||
});
|
||||
|
||||
@override
|
||||
ProcessingUsage deserialize(json) {
|
||||
return ProcessingUsage(
|
||||
cpus: json.containsKey("cpus") && json["cpus"] != null ? fromMapJson(json["cpus"], CPU()) : {},
|
||||
gpus: json.containsKey("gpus") && json["gpus"] != null ? fromMapJson(json["gpus"], GPU()) : {},
|
||||
ram: json.containsKey("ram") && json["ram"] != null ? RAM().deserialize(json["ram"]) : null,
|
||||
storageSize: json.containsKey("storage_size") && json["storage_size"] != null ? json["storage_size"]?.toDouble() : null,
|
||||
hypothesis: json.containsKey("hypothesis") && json["hypothesis"] != null ? json["hypothesis"] : null,
|
||||
scalingModel: json.containsKey("scaling_model") && json["scaling_model"] != null ? json["scaling_model"] : null,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> serialize() {
|
||||
return {
|
||||
"cpus": toMapJson(cpus),
|
||||
"gpus": toMapJson(gpus),
|
||||
"ram": ram?.serialize(),
|
||||
"storage_size": storageSize,
|
||||
"hypothesis": hypothesis,
|
||||
"scaling_model": scalingModel,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class CPU extends SerializerDeserializer<CPU> {
|
||||
CPU({
|
||||
this.cores,
|
||||
this.platform,
|
||||
this.architecture,
|
||||
this.minimumMemory,
|
||||
this.shared = false,
|
||||
});
|
||||
double? cores;
|
||||
String? platform;
|
||||
bool shared = false;
|
||||
String? architecture;
|
||||
double? minimumMemory;
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return CPU(); }
|
||||
return CPU(
|
||||
cores: json.containsKey("cores") && json["cores"] != null ? json["cores"]?.toDouble() : null,
|
||||
platform: json.containsKey("platform") && json["platform"] != null ? json["platform"] : null,
|
||||
architecture: json.containsKey("architecture") && json["architecture"] != null ? json["architecture"] : null,
|
||||
minimumMemory: json.containsKey("minimumMemory") && json["minimumMemory"] != null ? json["minimumMemory"]?.toDouble() : null,
|
||||
shared: json.containsKey("shared") && json["shared"] != null ? json["shared"] : false,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"cores": cores,
|
||||
"platform": platform,
|
||||
"architecture": architecture,
|
||||
"minimumMemory": minimumMemory,
|
||||
"shared": shared,
|
||||
};
|
||||
}
|
||||
class GPU extends SerializerDeserializer<GPU> {
|
||||
GPU({
|
||||
this.cudaCores,
|
||||
this.memory,
|
||||
this.model,
|
||||
this.tensorCores,
|
||||
});
|
||||
double? cudaCores;
|
||||
double? memory;
|
||||
String? model;
|
||||
double? tensorCores;
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return GPU(); }
|
||||
return GPU(
|
||||
cudaCores: json.containsKey("cuda_cores") && json["cuda_cores"] != null ? json["cuda_cores"]?.toDouble() : null,
|
||||
memory: json.containsKey("memory") && json["memory"] != null ? json["memory"]?.toDouble() : null,
|
||||
model: json.containsKey("model") && json["model"] != null ? json["model"] : null,
|
||||
tensorCores: json.containsKey("tensor_cores") && json["tensor_cores"] != null ? json["tensor_cores"]?.toDouble() : null,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"cuda_cores": cudaCores,
|
||||
"memory": memory,
|
||||
"model": model,
|
||||
"tensor_cores": tensorCores,
|
||||
};
|
||||
}
|
||||
class RAM extends SerializerDeserializer<RAM> {
|
||||
RAM({
|
||||
this.ecc = false,
|
||||
this.size,
|
||||
});
|
||||
bool ecc = false;
|
||||
double? size;
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return RAM(); }
|
||||
return RAM(
|
||||
ecc: json.containsKey("ecc") && json["ecc"] != null ? json["ecc"] : false,
|
||||
size: json.containsKey("size") && json["size"] != null ? json["size"]?.toDouble() : null,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"ecc": ecc,
|
||||
"size": size,
|
||||
};
|
||||
}
|
||||
|
||||
class Expose extends SerializerDeserializer<Expose> {
|
||||
Expose({
|
||||
this.PAT,
|
||||
this.port,
|
||||
this.path,
|
||||
});
|
||||
|
||||
int? port;
|
||||
int? PAT;
|
||||
String? path;
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return Expose(); }
|
||||
return Expose(
|
||||
port: json.containsKey("port") && json["port"] != null ? json["port"] : null,
|
||||
PAT: json.containsKey("PAT") && json["PAT"] != null ? json["PAT"] : null,
|
||||
path: json.containsKey("reverse") && json["reverse"] != null ? json["reverse"] : null,
|
||||
);
|
||||
}
|
||||
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"port": port,
|
||||
"PAT": PAT,
|
||||
"reverse": path,
|
||||
};
|
||||
}
|
||||
|
||||
class Containered extends SerializerDeserializer<Containered> {
|
||||
Containered({
|
||||
this.image,
|
||||
this.args,
|
||||
this.command,
|
||||
this.env,
|
||||
this.volumes,
|
||||
this.exposes = const [],
|
||||
});
|
||||
|
||||
String? args;
|
||||
String? image;
|
||||
String? command;
|
||||
Map<String, dynamic>? env;
|
||||
Map<String, dynamic>? volumes;
|
||||
List<Expose> exposes = [];
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return Containered(); }
|
||||
return Containered(
|
||||
args: json.containsKey("args") && json["args"] != null ? json["args"] : null,
|
||||
image: json.containsKey("image") && json["image"] != null ? json["image"] : null,
|
||||
command: json.containsKey("command") && json["command"] != null ? json["command"] : null,
|
||||
env: json.containsKey("env") && json["env"] != null ? json["env"] : null,
|
||||
volumes: json.containsKey("volumes") && json["volumes"] != null ? json["volumes"] : null,
|
||||
exposes: json.containsKey("exposes") && json["exposes"] != null ? fromListJson(json["exposes"], Expose()) : [],
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() {
|
||||
var w = {
|
||||
"args": args,
|
||||
"image": image,
|
||||
"command": command,
|
||||
"env": env,
|
||||
"volumes": volumes,
|
||||
"exposes": toListJson(exposes),
|
||||
};
|
||||
return w;
|
||||
}
|
||||
}
|
497
lib/models/resources/resources.dart
Normal file
497
lib/models/resources/resources.dart
Normal file
@ -0,0 +1,497 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:oc_front/models/abstract.dart';
|
||||
import 'package:oc_front/models/resources/compute.dart';
|
||||
import 'package:oc_front/models/resources/data.dart';
|
||||
import 'package:oc_front/models/resources/processing.dart';
|
||||
import 'package:oc_front/models/resources/storage.dart';
|
||||
import 'package:oc_front/models/resources/workflow.dart';
|
||||
|
||||
class Resource implements SerializerDeserializer<Resource> {
|
||||
List<DataItem> datas = [];
|
||||
List<ProcessingItem> processings = [];
|
||||
List<StorageItem> storages = [];
|
||||
List<ComputeItem> computes = [];
|
||||
List<WorkflowItem> workflows = [];
|
||||
|
||||
Resource({
|
||||
this.datas = const [],
|
||||
this.processings = const [],
|
||||
this.storages = const [],
|
||||
this.computes = const [],
|
||||
this.workflows = const [],
|
||||
});
|
||||
|
||||
@override Resource deserialize(json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return Resource(); }
|
||||
return Resource(
|
||||
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()) : [],
|
||||
workflows: json.containsKey("workflow_resource") ? fromListJson(json["workflow_resource"], WorkflowItem()) : [],
|
||||
);
|
||||
}
|
||||
|
||||
@override Map<String, dynamic> serialize() {
|
||||
return {
|
||||
"compute_resource": toListJson<ComputeItem>(computes),
|
||||
"data_resource": toListJson<DataItem>(datas),
|
||||
"processing_resource": toListJson<ProcessingItem>(processings),
|
||||
"storage_resource": toListJson<StorageItem>(storages),
|
||||
"workflow_resource": toListJson<WorkflowItem>(workflows),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class Owner extends SerializerDeserializer<Owner> {
|
||||
String? name;
|
||||
String? logo;
|
||||
|
||||
Owner({
|
||||
this.name,
|
||||
this.logo,
|
||||
});
|
||||
|
||||
@override Owner deserialize(json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return Owner(); }
|
||||
return Owner(
|
||||
name: json.containsKey("name") ? json["name"] : null,
|
||||
logo: json.containsKey("logo") ? json["logo"] : null,
|
||||
);
|
||||
}
|
||||
|
||||
@override Map<String, dynamic> serialize() {
|
||||
return {
|
||||
"name": name,
|
||||
"logo": logo,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
abstract class Infos {
|
||||
Map<String, dynamic> infos();
|
||||
}
|
||||
|
||||
class Artifact extends SerializerDeserializer<Artifact> {
|
||||
String? attrPath;
|
||||
String? attrFrom;
|
||||
bool readOnly = true;
|
||||
|
||||
Artifact({
|
||||
this.attrPath,
|
||||
this.attrFrom,
|
||||
this.readOnly = true,
|
||||
});
|
||||
|
||||
@override Artifact deserialize(json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return Artifact(); }
|
||||
return Artifact(
|
||||
attrPath: json.containsKey("attr_path") ? json["attr_path"] : null,
|
||||
attrFrom: json.containsKey("attr_from") ? json["attr_from"] : null,
|
||||
readOnly: json.containsKey("readonly") ? json["readonly"] : true,
|
||||
);
|
||||
}
|
||||
|
||||
@override Map<String, dynamic> serialize() {
|
||||
return {
|
||||
"attr_path": attrPath,
|
||||
"attr_from": attrFrom,
|
||||
"readonly": readOnly,
|
||||
};
|
||||
}
|
||||
}
|
||||
class Param extends SerializerDeserializer<Param> {
|
||||
String? name;
|
||||
String? attr;
|
||||
dynamic value;
|
||||
String? origin;
|
||||
bool optionnal = false;
|
||||
bool readOnly = true;
|
||||
|
||||
Param({
|
||||
this.name,
|
||||
this.attr,
|
||||
this.value,
|
||||
this.origin,
|
||||
this.optionnal = false,
|
||||
this.readOnly = true,
|
||||
});
|
||||
|
||||
@override Param deserialize(json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return Param(); }
|
||||
return Param(
|
||||
name: json.containsKey("name") ? json["name"] : null,
|
||||
attr: json.containsKey("attr") ? json["attr"] : null,
|
||||
value: json.containsKey("value") ? json["value"] : null,
|
||||
origin: json.containsKey("origin") ? json["origin"] : null,
|
||||
optionnal: json.containsKey("optionnal") ? json["optionnal"] : false,
|
||||
readOnly: json.containsKey("readonly") ? json["readonly"] : false,
|
||||
);
|
||||
}
|
||||
|
||||
@override Map<String, dynamic> serialize() {
|
||||
return {
|
||||
"name": name,
|
||||
"attr": attr,
|
||||
"value": value,
|
||||
"origin": origin,
|
||||
"optionnal": optionnal,
|
||||
"readonly": readOnly,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractItem<X extends AbstractPricing, Y extends AbstractPartnerShip<X>, S extends AbstractInstance<X,Y>, T extends FlowData> extends FlowData implements SerializerDeserializer<T>, Infos {
|
||||
String? id;
|
||||
String? name;
|
||||
String? logo;
|
||||
String? type;
|
||||
String? creatorID;
|
||||
String? updaterID;
|
||||
DateTime? createdAt;
|
||||
DateTime? updatedAt;
|
||||
List<Owner> owners;
|
||||
String? description;
|
||||
String? restrictions;
|
||||
String? shortDescription;
|
||||
int selectedInstance = -1;
|
||||
|
||||
List<AbstractInstance<X,Y>> instances = [];
|
||||
|
||||
String get topic => "";
|
||||
|
||||
AbstractItem({
|
||||
this.id,
|
||||
this.type,
|
||||
this.name,
|
||||
this.logo,
|
||||
this.creatorID,
|
||||
this.updaterID,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.description,
|
||||
this.shortDescription,
|
||||
this.owners = const [],
|
||||
this.selectedInstance = -1,
|
||||
});
|
||||
|
||||
void addEnv(List<dynamic> infos) {
|
||||
var inst = getSelectedInstance();
|
||||
if (inst == null) { return; }
|
||||
inst.env = [];
|
||||
for (var info in infos) {
|
||||
inst.env.add(Param(name: info["name"], attr: info["attr"], value: info["value"],
|
||||
origin: info["origin"], optionnal: info["optionnal"], readOnly: info["readonly"]));
|
||||
}
|
||||
}
|
||||
|
||||
AbstractInstance<X,Y>? getSelectedInstance() {
|
||||
if (selectedInstance == -1) { return instances.isEmpty ? null : instances[0]; }
|
||||
return instances[selectedInstance];
|
||||
}
|
||||
|
||||
@override String getID() {
|
||||
return id ?? "";
|
||||
}
|
||||
|
||||
@override String getType() {
|
||||
return type ?? "";
|
||||
}
|
||||
|
||||
|
||||
@override String getName() {
|
||||
return name ?? "";
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> infos();
|
||||
|
||||
double? width;
|
||||
double? height;
|
||||
@override
|
||||
double? getWidth() {
|
||||
return width;
|
||||
}
|
||||
@override
|
||||
double? getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
Map<String, dynamic> setVariable(String key, dynamic value, Map<String, dynamic> map) {
|
||||
map[key] = value;
|
||||
return map;
|
||||
}
|
||||
|
||||
dynamic getVariable(String key, Map<String, dynamic> map) {
|
||||
return map[key];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJSON() {
|
||||
return {
|
||||
"id": id,
|
||||
"type": type ?? topic,
|
||||
"name": name,
|
||||
"logo": logo,
|
||||
"owners": toListJson(owners),
|
||||
"creator_id": creatorID,
|
||||
"updater_id": updaterID,
|
||||
"creation_date": createdAt?.toIso8601String(),
|
||||
"update_date": updatedAt?.toIso8601String(),
|
||||
"description": description,
|
||||
"short_description": shortDescription,
|
||||
"selected_instance": selectedInstance,
|
||||
"instances": instances.map((e) => e.serialize()).toList(),
|
||||
};
|
||||
}
|
||||
|
||||
void mapFromJSON(dynamic json, S ex) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return; }
|
||||
this.id = json.containsKey("id") ? json["id"] : null;
|
||||
this.type = json.containsKey("type") ? json["type"] : topic;
|
||||
this.name = json.containsKey("name") ? json["name"] : null;
|
||||
this.logo = json.containsKey("logo") ? json["logo"] : null;
|
||||
this.creatorID = json.containsKey("creator_id") ? json["creator_id"] : null;
|
||||
this.updaterID = json.containsKey("updater_id") ? json["updater_id"] : null;
|
||||
this.description = json.containsKey("description") ? json["description"] : null;
|
||||
this.owners = json.containsKey("owners") ? fromListJson(json["owners"], Owner()) : [];
|
||||
this.instances = json.containsKey("instances") ? fromListJson(json["instances"], ex) : [];
|
||||
this.updatedAt = json.containsKey("update_date") ? DateTime.parse(json["update_date"]) : null;
|
||||
this.selectedInstance = json.containsKey("selected_instance") ? json["selected_instance"] : -1;
|
||||
this.shortDescription = json.containsKey("short_description") ? json["short_description"] : null;
|
||||
this.createdAt = json.containsKey("creation_date") ? DateTime.parse(json["creation_date"]) : null;
|
||||
}
|
||||
}
|
||||
|
||||
class Location extends SerializerDeserializer<Location> {
|
||||
double? latitude;
|
||||
double? longitude;
|
||||
|
||||
Location({
|
||||
this.latitude,
|
||||
this.longitude,
|
||||
});
|
||||
|
||||
@override
|
||||
Location deserialize(json) {
|
||||
return Location(
|
||||
latitude: json.containsKey("latitude") ? json["latitude"] : null,
|
||||
longitude: json.containsKey("longitude") ? json["longitude"] : null,
|
||||
);
|
||||
}
|
||||
@override
|
||||
Map<String, dynamic> serialize() {
|
||||
return {
|
||||
"latitude": latitude,
|
||||
"longitude": longitude,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractInstance<X extends AbstractPricing, S extends AbstractPartnerShip<X>> extends SerializerDeserializer<AbstractInstance<X,S>> implements Infos {
|
||||
String? id;
|
||||
String? name;
|
||||
int? countryCode;
|
||||
Location? location;
|
||||
List<S> partnerships = [];
|
||||
List<Param> env = [];
|
||||
List<Param> inputs = [];
|
||||
List<Param> outputs = [];
|
||||
|
||||
bool isEnv(String key) {
|
||||
for (var e in env) {
|
||||
if (e.name?.contains(key) ?? false || key.contains(e.name ?? "none")) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isEnvAttr(String attr, String origin, bool isOrigin) {
|
||||
for (var e in env) {
|
||||
if (e.attr == attr && ((isOrigin && e.origin != null) || (!isOrigin && e.origin == origin))) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> infos();
|
||||
|
||||
void mapFromJSON(dynamic json, S ex) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return; }
|
||||
this.countryCode = json.containsKey("country_code") ? json["country_code"] : null;
|
||||
this.id = json.containsKey("id") ? json["id"] : null;
|
||||
this.name = json.containsKey("name") ? json["name"] : null;
|
||||
this.env = json.containsKey("env") ? fromListJson(json["env"], Param()) : [];
|
||||
this.inputs = json.containsKey("inputs") ? fromListJson(json["inputs"], Param()) : [];
|
||||
this.outputs = json.containsKey("outputs") ? fromListJson(json["outputs"], Param()) : [];
|
||||
this.location = json.containsKey("location") ? Location().deserialize(json["location"]) : null;
|
||||
this.partnerships = json.containsKey("partnerships") ? fromListJson(json["partnerships"], ex) : [];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJSON() {
|
||||
return {
|
||||
"country_code": countryCode,
|
||||
"id": id,
|
||||
"name": name,
|
||||
"location": location?.serialize(),
|
||||
"env": toListJson(env),
|
||||
"inputs": toListJson(inputs),
|
||||
"outputs": toListJson(outputs),
|
||||
"partnerships": partnerships.map((e) => e.serialize()).toList(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractPartnerShip<S extends AbstractPricing> extends SerializerDeserializer<AbstractPartnerShip<S>> {
|
||||
String? namespace;
|
||||
List<AbstractPricing> pricings = [];
|
||||
|
||||
void mapFromJSON(dynamic json, S ex) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return; }
|
||||
this.namespace = json.containsKey("namespace") ? json["namespace"] : null;
|
||||
this.pricings = json.containsKey("pricings") ? fromListJson(json["pricings"], ex) : [];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJSON() {
|
||||
return {
|
||||
"namespace": namespace,
|
||||
"pricings": pricings,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractPricing extends SerializerDeserializer<AbstractPricing> {
|
||||
PricingStrategy? pricing;
|
||||
int? refundTypeEnum;
|
||||
int? refundRatio;
|
||||
List<dynamic> additionnalRefundTypeEnum = [];
|
||||
int? privilegeStrategyEnum;
|
||||
int? garantedDelaySecond;
|
||||
bool exceeding = false;
|
||||
int? exceedingRatio;
|
||||
|
||||
void mapFromJSON(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return; }
|
||||
pricing = json.containsKey("pricing") ? PricingStrategy().deserialize(json["pricing"]) : null;
|
||||
refundTypeEnum = json.containsKey("refund_type") ? json["refund_type"] : null;
|
||||
refundRatio = json.containsKey("refund_ratio") ? json["refund_ratio"] : null;
|
||||
additionnalRefundTypeEnum = json.containsKey("additionnal_refund_type") ? json["additionnal_refund_type"] : [];
|
||||
privilegeStrategyEnum = json.containsKey("privilege_strategy") ? json["privilege_strategy"] : null;
|
||||
garantedDelaySecond = json.containsKey("garanted_delay") ? json["garanted_delay"] : null;
|
||||
exceeding = json.containsKey("exceeding") ? json["exceeding"] : false;
|
||||
exceedingRatio = json.containsKey("exceeding_ratio") ? json["exceeding_ratio"] : null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJSON() {
|
||||
return {
|
||||
"pricing": pricing?.serialize(),
|
||||
"refund_type": refundTypeEnum,
|
||||
"refund_ratio": refundRatio,
|
||||
"additionnal_refund_type": additionnalRefundTypeEnum,
|
||||
"privilege_strategy": privilegeStrategyEnum,
|
||||
"garanted_delay": garantedDelaySecond,
|
||||
"exceeding": exceeding,
|
||||
"exceeding_ratio": exceedingRatio,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class PricingStrategy extends SerializerDeserializer<PricingStrategy> {
|
||||
double? price;
|
||||
String? currency;
|
||||
int? buyingStrategyEnum;
|
||||
int? timeStrategyEnum;
|
||||
int? overrideStrategyEnum;
|
||||
|
||||
PricingStrategy({
|
||||
this.price,
|
||||
this.currency,
|
||||
this.buyingStrategyEnum,
|
||||
this.timeStrategyEnum,
|
||||
this.overrideStrategyEnum,
|
||||
});
|
||||
|
||||
@override
|
||||
PricingStrategy deserialize(dynamic json) {
|
||||
return PricingStrategy(
|
||||
price: json.containsKey("price") && json["price"] != null ? json["price"] : null,
|
||||
currency: json.containsKey("currency") && json["currency"] != null ? json["currency"] : null,
|
||||
buyingStrategyEnum: json.containsKey("buying_strategy") ? json["buying_strategy"] : null,
|
||||
timeStrategyEnum: json.containsKey("time_strategy") ? json["time_strategy"] : null,
|
||||
overrideStrategyEnum: json.containsKey("override_strategy") ? json["override_strategy"] : null,
|
||||
);
|
||||
}
|
||||
@override
|
||||
Map<String, dynamic> serialize() {
|
||||
return {
|
||||
"price": price,
|
||||
"currency": currency,
|
||||
"buying_strategy": buyingStrategyEnum,
|
||||
"time_strategy": timeStrategyEnum,
|
||||
"override_strategy": overrideStrategyEnum,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class Model extends SerializerDeserializer<Model> {
|
||||
dynamic value;
|
||||
String? type;
|
||||
bool readonly = false;
|
||||
|
||||
Model({
|
||||
this.value,
|
||||
this.type,
|
||||
this.readonly = false,
|
||||
});
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return Model(); }
|
||||
return Model(
|
||||
value: json.containsKey("value") ? json["value"] : null,
|
||||
type: json.containsKey("type") ? json["type"] : null,
|
||||
readonly: json.containsKey("readonly") ? json["readonly"] : false,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"value": value,
|
||||
"type": type,
|
||||
"readonly": readonly,
|
||||
};
|
||||
}
|
||||
|
||||
Type? getTopicType(String topic) {
|
||||
if (topic == "processing") { return ProcessingItem; }
|
||||
else if (topic == "data") { return DataItem; }
|
||||
else if (topic == "compute") { return ComputeItem; }
|
||||
else if (topic == "storage") { return StorageItem; }
|
||||
else if (topic == "workflow") { return WorkflowItem; }
|
||||
else { return null; }
|
||||
}
|
||||
|
||||
String getTopic(Type type) {
|
||||
if (type == AbstractItem) { return "resource"; }
|
||||
if (type == ProcessingItem) { return "processing"; }
|
||||
if (type == DataItem) { return "data"; }
|
||||
if (type == ComputeItem) { return "compute"; }
|
||||
if (type == StorageItem) { return "storage"; }
|
||||
if (type == WorkflowItem) { return "workflow"; }
|
||||
return "";
|
||||
}
|
||||
|
||||
bool isComputing(String topic) => topic == "processing";
|
||||
bool isData(String topic) => topic == "data";
|
||||
bool isCompute(String topic) => topic == "compute";
|
||||
bool isStorage(String topic) => topic == "storage";
|
||||
bool isWorkflow(String topic) => topic == "workflow";
|
||||
|
||||
Color getColor(String topic) => isData(topic) ? Colors.blue : isComputing(topic) ? Colors.green :
|
||||
isCompute(topic) ? Colors.orange : isStorage(topic) ? redColor : Colors.grey;
|
166
lib/models/resources/storage.dart
Normal file
166
lib/models/resources/storage.dart
Normal file
@ -0,0 +1,166 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/core/services/enum_service.dart';
|
||||
import 'package:oc_front/models/abstract.dart';
|
||||
import 'package:oc_front/models/resources/resources.dart';
|
||||
|
||||
class StorageItem extends AbstractItem<StoragePricing, StoragePartnership, StorageInstance, StorageItem> {
|
||||
StorageItem({
|
||||
this.acronym,
|
||||
this.typeEnum,
|
||||
}): super();
|
||||
|
||||
@override String get topic => "storage";
|
||||
// special attributes
|
||||
String? acronym;
|
||||
int? typeEnum;
|
||||
|
||||
@override deserialize(dynamic data) {
|
||||
try { data = data as Map<String, dynamic>;
|
||||
} catch (e) { return StorageItem(); }
|
||||
var w = StorageItem(
|
||||
acronym: data.containsKey("acronym") && data["acronym"] != null ? data["acronym"] : null,
|
||||
typeEnum: data.containsKey("storage_type") && data["storage_type"] != null ? EnumService.get("storage/type", data["storage_type"]) : null,
|
||||
);
|
||||
w.mapFromJSON(data, StorageInstance());
|
||||
if (w.logo != null) { // get image dimensions
|
||||
var image = Image.network(w.logo!);
|
||||
image.image
|
||||
.resolve(const ImageConfiguration())
|
||||
.addListener(
|
||||
ImageStreamListener(
|
||||
(ImageInfo info, bool _) {
|
||||
w.width = info.image.width.toDouble();
|
||||
w.height = info.image.height.toDouble();
|
||||
}));
|
||||
}
|
||||
return w;
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> infos() {
|
||||
return {
|
||||
"acronym": acronym,
|
||||
"storage_type": EnumService.enums["storage/type"] != null
|
||||
&& EnumService.enums["storage/type"]!["$typeEnum"] != null ?
|
||||
EnumService.enums["storage/type"]!["$typeEnum"] : typeEnum,
|
||||
};
|
||||
}
|
||||
|
||||
@override Map<String, dynamic> serialize() {
|
||||
var obj = infos();
|
||||
obj.addAll(toJSON());
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
class StorageInstance extends AbstractInstance<StoragePricing, StoragePartnership> {
|
||||
String? source;
|
||||
bool local = false;
|
||||
String? securityLevel;
|
||||
int? storageSizeEnum;
|
||||
int? size;
|
||||
bool encryption = false;
|
||||
String? redundancy;
|
||||
String? throughput;
|
||||
|
||||
StorageInstance({
|
||||
this.source,
|
||||
this.local = false,
|
||||
this.securityLevel,
|
||||
this.storageSizeEnum,
|
||||
this.size,
|
||||
this.encryption = false,
|
||||
this.redundancy,
|
||||
this.throughput,
|
||||
}): super();
|
||||
|
||||
@override
|
||||
StorageInstance deserialize(json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return StorageInstance(); }
|
||||
var w = StorageInstance(
|
||||
source: json.containsKey("source") && json["source"] != null ? json["source"] : null,
|
||||
local: json.containsKey("local") && json["local"] != null ? json["local"] : false,
|
||||
securityLevel: json.containsKey("security_level") && json["security_level"] != null ? json["security_level"] : null,
|
||||
storageSizeEnum: json.containsKey("size_type") ? EnumService.get("storage/size", json["size_type"]) : null,
|
||||
size: json.containsKey("size") && json["size"] != null ? json["size"] : null,
|
||||
encryption: json.containsKey("encryption") && json["encryption"] != null ? json["encryption"] : false,
|
||||
redundancy: json.containsKey("redundancy") && json["redundancy"] != null ? json["redundancy"] : null,
|
||||
throughput: json.containsKey("throughput") && json["throughput"] != null ? json["throughput"] : null,
|
||||
);
|
||||
w.mapFromJSON(json, StoragePartnership());
|
||||
return w;
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> infos() {
|
||||
return {
|
||||
"local": local,
|
||||
"security_level": securityLevel,
|
||||
"size_type": EnumService.enums["storage/size"] != null
|
||||
&& EnumService.enums["storage/size"]!["$storageSizeEnum"] != null ?
|
||||
EnumService.enums["storage/size"]!["$storageSizeEnum"] : storageSizeEnum,
|
||||
"size": size,
|
||||
"encryption": encryption,
|
||||
"redundancy": redundancy,
|
||||
"throughput": throughput,
|
||||
"inputs": toListJson(inputs),
|
||||
"outputs": toListJson(outputs),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Map<String, dynamic> serialize() {
|
||||
var obj = infos();
|
||||
obj["source"] = source;
|
||||
obj["size_type"] = storageSizeEnum;
|
||||
obj.addAll(toJSON());
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
class StoragePartnership extends AbstractPartnerShip<StoragePricing> {
|
||||
double? maxSizeGBAllowed;
|
||||
bool onlyEncryptedAllowed = false;
|
||||
|
||||
StoragePartnership({
|
||||
this.maxSizeGBAllowed,
|
||||
this.onlyEncryptedAllowed = false,
|
||||
}): super();
|
||||
|
||||
@override
|
||||
StoragePartnership deserialize(json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return StoragePartnership(); }
|
||||
var w = StoragePartnership(
|
||||
maxSizeGBAllowed: json.containsKey("allowed_gb") && json["allowed_gb"] != null ? json["allowed_gb"] : null,
|
||||
onlyEncryptedAllowed: json.containsKey("personal_data_allowed") && json["personal_data_allowed"] != null ? json["personal_data_allowed"] : false,
|
||||
);
|
||||
w.mapFromJSON(json, StoragePricing());
|
||||
return w;
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> serialize() {
|
||||
Map<String, dynamic> obj = {
|
||||
"allowed_gb": maxSizeGBAllowed,
|
||||
"personal_data_allowed": onlyEncryptedAllowed,
|
||||
};
|
||||
obj.addAll(toJSON());
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
class StoragePricing extends AbstractPricing {
|
||||
@override StoragePricing deserialize(json) {
|
||||
var w = StoragePricing();
|
||||
w.mapFromJSON(json);
|
||||
return w;
|
||||
}
|
||||
@override
|
||||
Map<String, dynamic> serialize() {
|
||||
return toJSON();
|
||||
}
|
||||
}
|
101
lib/models/resources/workflow.dart
Normal file
101
lib/models/resources/workflow.dart
Normal file
@ -0,0 +1,101 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/models/resources/resources.dart';
|
||||
|
||||
class WorkflowItem extends AbstractItem<WorkflowPricing, WorkflowPartnership, WorkflowInstance, WorkflowItem> {
|
||||
// special attributes
|
||||
String? workflowID;
|
||||
|
||||
WorkflowItem({
|
||||
this.workflowID,
|
||||
}): super();
|
||||
|
||||
@override String get topic => "workflow";
|
||||
|
||||
@override deserialize(dynamic data) {
|
||||
try { data = data as Map<String, dynamic>;
|
||||
} catch (e) { return WorkflowItem(); }
|
||||
var w = WorkflowItem(
|
||||
workflowID: data.containsKey("workflow_id") && data["workflow_id"] != null ? data["workflow_id"] : null,
|
||||
);
|
||||
w.mapFromJSON(data, WorkflowInstance());
|
||||
if (w.logo != null) { // get image dimensions
|
||||
var image = Image.network(w.logo!);
|
||||
image.image
|
||||
.resolve(const ImageConfiguration())
|
||||
.addListener(
|
||||
ImageStreamListener(
|
||||
(ImageInfo info, bool _) {
|
||||
w.width = info.image.width.toDouble();
|
||||
w.height = info.image.height.toDouble();
|
||||
}));
|
||||
}
|
||||
return w;
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> infos() {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override Map<String, dynamic> serialize() {
|
||||
Map<String, dynamic> obj ={
|
||||
"workflow_id": workflowID,
|
||||
};
|
||||
obj.addAll(toJSON());
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
class WorkflowInstance extends AbstractInstance<WorkflowPricing, WorkflowPartnership> {
|
||||
WorkflowInstance(): super();
|
||||
|
||||
@override
|
||||
WorkflowInstance deserialize(json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return WorkflowInstance(); }
|
||||
var w = WorkflowInstance();
|
||||
w.mapFromJSON(json, WorkflowPartnership());
|
||||
return w;
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> infos() {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> serialize() {
|
||||
return toJSON();
|
||||
}
|
||||
}
|
||||
|
||||
class WorkflowPartnership extends AbstractPartnerShip<WorkflowPricing> {
|
||||
WorkflowPartnership(): super();
|
||||
|
||||
@override
|
||||
WorkflowPartnership deserialize(json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return WorkflowPartnership(); }
|
||||
var w = WorkflowPartnership();
|
||||
w.mapFromJSON(json, WorkflowPricing());
|
||||
return w;
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> serialize() {
|
||||
return toJSON();
|
||||
}
|
||||
}
|
||||
|
||||
class WorkflowPricing extends AbstractPricing {
|
||||
@override WorkflowPricing deserialize(json) {
|
||||
var w = WorkflowPricing();
|
||||
w.mapFromJSON(json);
|
||||
return w;
|
||||
}
|
||||
@override
|
||||
Map<String, dynamic> serialize() {
|
||||
return toJSON();
|
||||
}
|
||||
}
|
@ -1,5 +1,10 @@
|
||||
import 'package:oc_front/models/abstract.dart';
|
||||
import 'package:oc_front/models/logs.dart';
|
||||
import 'package:oc_front/models/resources/compute.dart';
|
||||
import 'package:oc_front/models/resources/data.dart';
|
||||
import 'package:oc_front/models/resources/processing.dart';
|
||||
import 'package:oc_front/models/resources/resources.dart';
|
||||
import 'package:oc_front/models/resources/storage.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/models/shared.dart';
|
||||
import 'package:oc_front/models/workflow.dart';
|
||||
@ -20,6 +25,7 @@ Map<Type, SerializerDeserializer> refs = <Type, SerializerDeserializer> {
|
||||
Check: Check(),
|
||||
CollaborativeArea: CollaborativeArea(),
|
||||
SimpleData: SimpleData(),
|
||||
EnumData: EnumData(),
|
||||
};
|
||||
|
||||
class APIResponse<T extends SerializerDeserializer> {
|
||||
@ -53,7 +59,9 @@ class APIResponse<T extends SerializerDeserializer> {
|
||||
code: j.containsKey("code") && j["code"] != null ? j["code"] : 200,
|
||||
error: j.containsKey("error") && j["error"] != null ? j["error"] : "",
|
||||
);
|
||||
} catch (e) { return APIResponse<T>( data: refs[T]!.deserialize(data), ); }
|
||||
} catch (e) {
|
||||
return APIResponse<T>( data: refs[T]?.deserialize(data), );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,17 +74,34 @@ class SimpleData extends SerializerDeserializer<SimpleData> {
|
||||
@override Map<String, dynamic> serialize() => { };
|
||||
}
|
||||
|
||||
class EnumData extends SerializerDeserializer<EnumData> {
|
||||
EnumData({ this.value = const {} });
|
||||
Map<String, dynamic> value = {};
|
||||
@override deserialize(dynamic json) {
|
||||
return EnumData(value: json as Map<String, dynamic>);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => { };
|
||||
}
|
||||
|
||||
class RawData extends SerializerDeserializer<RawData> {
|
||||
RawData({ this.values = const []});
|
||||
List<dynamic> values = [];
|
||||
@override deserialize(dynamic json) {
|
||||
return RawData(values: json ?? []); }
|
||||
try {
|
||||
return RawData(values: json ?? []);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
print(json);
|
||||
return RawData();
|
||||
}
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => { };
|
||||
}
|
||||
|
||||
abstract class ShallowData {
|
||||
String getID();
|
||||
String getName();
|
||||
Map<String, dynamic> serialize();
|
||||
}
|
||||
|
||||
class Shallow {
|
||||
|
37
lib/models/schedule.dart
Normal file
37
lib/models/schedule.dart
Normal file
@ -0,0 +1,37 @@
|
||||
import 'package:oc_front/models/abstract.dart';
|
||||
|
||||
class Scheduler extends SerializerDeserializer<Scheduler> {
|
||||
DateTime? start;
|
||||
DateTime? end;
|
||||
double? duration;
|
||||
String? cron;
|
||||
|
||||
Scheduler({
|
||||
this.start,
|
||||
this.end,
|
||||
this.duration,
|
||||
this.cron,
|
||||
});
|
||||
|
||||
@override
|
||||
Scheduler deserialize(json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return Scheduler(); }
|
||||
var w = Scheduler(
|
||||
start: json.containsKey("start") && json["start"] != null ? DateTime.parse(json["start"]) : null,
|
||||
end: json.containsKey("end") && json["end"] != null ? DateTime.parse(json["end"]) : null,
|
||||
duration: json.containsKey("duration_s") && json["duration_s"] != null ? json["duration_s"] : -1,
|
||||
cron: json.containsKey("cron") && json["cron"] != null ? json["cron"] : null,
|
||||
);
|
||||
return w;
|
||||
}
|
||||
|
||||
@override Map<String, dynamic> serialize() {
|
||||
return {
|
||||
"start": start?.toIso8601String(),
|
||||
"end": end?.toIso8601String(),
|
||||
"duration_s": duration,
|
||||
"cron": cron,
|
||||
};
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -79,13 +79,14 @@ class CollaborativeArea extends SerializerDeserializer<CollaborativeArea> {
|
||||
rule : json.containsKey("collaborative_area") ? CollaborativeAreaRule().deserialize(json["collaborative_area"]) : CollaborativeAreaRule(),
|
||||
id: json.containsKey("id") ? json["id"] : null,
|
||||
name: json.containsKey("name") ? json["name"] : null,
|
||||
creatorID: json.containsKey("creator_id") ? json["creator_id"] : null,
|
||||
description: json.containsKey("description") ? json["description"] : null,
|
||||
version: json.containsKey("version") ? json["version"] : null,
|
||||
attributes: json.containsKey("attributes") ? json["attributes"] : {},
|
||||
workspaces: json.containsKey("shared_workspaces") ? fromListJson(json["shared_workspaces"], Workspace()) : [],
|
||||
workflows: json.containsKey("shared_workflows") ? fromListJson(json["shared_workflows"], Workflow()) : [],
|
||||
peers: json.containsKey("shared_peers") ? fromListJson(json["shared_peers"], Peer()) : [],
|
||||
rules: json.containsKey("rules") ? json["rules"] : [],
|
||||
workspaces: json.containsKey("shared_workspaces") && json["shared_workspaces"] != null ? fromListJson(json["shared_workspaces"], Workspace()) : [],
|
||||
workflows: json.containsKey("shared_workflows") && json["shared_workflows"] != null ? fromListJson(json["shared_workflows"], Workflow()) : [],
|
||||
peers: json.containsKey("shared_peers") && json["shared_peers"] != null ? fromListJson(json["shared_peers"], Peer()) : [],
|
||||
rules: json.containsKey("shared_rules") && json["shared_rules"] != null ? json["shared_rules"] : [],
|
||||
);
|
||||
}
|
||||
@override
|
||||
|
@ -1,40 +1,41 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
|
||||
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
|
||||
import 'package:oc_front/core/models/workspace_local.dart';
|
||||
import 'package:oc_front/models/abstract.dart';
|
||||
import 'package:oc_front/models/logs.dart';
|
||||
import 'package:oc_front/models/resources/compute.dart';
|
||||
import 'package:oc_front/models/resources/data.dart';
|
||||
import 'package:oc_front/models/resources/processing.dart';
|
||||
import 'package:oc_front/models/resources/resources.dart';
|
||||
import 'package:oc_front/models/resources/storage.dart';
|
||||
import 'package:oc_front/models/resources/workflow.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/widgets/forms/sub_keys_forms.dart';
|
||||
|
||||
class Check extends SerializerDeserializer<Check> {
|
||||
bool is_available = false;
|
||||
bool isAvailable = false;
|
||||
|
||||
Check({
|
||||
this.is_available = false,
|
||||
this.isAvailable = false,
|
||||
});
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return Check(); }
|
||||
return Check(
|
||||
is_available: json.containsKey("is_available") ? json["is_available"] : false,
|
||||
isAvailable: json.containsKey("is_available") ? json["is_available"] : false,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() {
|
||||
return {
|
||||
"is_available": is_available,
|
||||
"is_available": isAvailable,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class WorkflowExecutions extends SerializerDeserializer<WorkflowExecutions> {
|
||||
List<WorkflowExecution> executions = [];
|
||||
String? executionData;
|
||||
int? status;
|
||||
String? workflowId;
|
||||
|
||||
|
||||
WorkflowExecutions({
|
||||
this.executions = const [],
|
||||
});
|
||||
@ -56,7 +57,7 @@ class WorkflowExecutions extends SerializerDeserializer<WorkflowExecutions> {
|
||||
class WorkflowExecution extends SerializerDeserializer<WorkflowExecution> {
|
||||
String? id;
|
||||
String? name;
|
||||
String? executionData;
|
||||
String? startDate;
|
||||
String? endDate;
|
||||
int? status;
|
||||
String? workflowId;
|
||||
@ -66,7 +67,7 @@ class WorkflowExecution extends SerializerDeserializer<WorkflowExecution> {
|
||||
|
||||
WorkflowExecution({
|
||||
this.id,
|
||||
this.executionData,
|
||||
this.startDate,
|
||||
this.status,
|
||||
this.workflowId,
|
||||
this.name,
|
||||
@ -79,7 +80,7 @@ class WorkflowExecution extends SerializerDeserializer<WorkflowExecution> {
|
||||
return WorkflowExecution(
|
||||
id: json.containsKey("id") ? json["id"] : "",
|
||||
endDate: json.containsKey("end_date") ? json["end_date"] : "",
|
||||
executionData: json.containsKey("execution_date") ? json["execution_date"] : "",
|
||||
startDate: json.containsKey("execution_date") ? json["execution_date"] : "",
|
||||
status: json.containsKey("state") ? json["state"] : 1,
|
||||
workflowId: json.containsKey("workflow_id") ? json["workflow_id"] : "",
|
||||
name: json.containsKey("name") ? json["name"] : "",
|
||||
@ -91,7 +92,7 @@ class WorkflowExecution extends SerializerDeserializer<WorkflowExecution> {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"end_date": endDate,
|
||||
"execution_data": executionData,
|
||||
"execution_data": startDate,
|
||||
"status": status,
|
||||
"workflow_id": workflowId,
|
||||
};
|
||||
@ -108,8 +109,6 @@ class Workflow extends SerializerDeserializer<Workflow> implements ShallowData
|
||||
List<dynamic> processing;
|
||||
List<dynamic> workflows;
|
||||
Graph? graph;
|
||||
Scheduler? schedule;
|
||||
bool scheduleActive = false;
|
||||
List<dynamic> shared;
|
||||
|
||||
Workflow({
|
||||
@ -121,14 +120,12 @@ class Workflow extends SerializerDeserializer<Workflow> implements ShallowData
|
||||
this.processing = const [],
|
||||
this.workflows = const [],
|
||||
this.graph,
|
||||
this.schedule,
|
||||
this.scheduleActive = false,
|
||||
this.shared = const [],
|
||||
});
|
||||
|
||||
@override String getID() => id ?? "";
|
||||
@override String getName() => name ?? "";
|
||||
@override String getDescription() => "";
|
||||
String getDescription() => "";
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
@ -140,11 +137,9 @@ class Workflow extends SerializerDeserializer<Workflow> implements ShallowData
|
||||
processing: json.containsKey("processings") ? json["processings"] : [],
|
||||
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"] : [],
|
||||
shared: json.containsKey("shared") ? json["shared"] : [],
|
||||
graph: json.containsKey("graph") ? Graph().deserialize(json["graph"]) : null,
|
||||
schedule: json.containsKey("schedule") ? Scheduler().deserialize(json["schedule"]) : null,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() {
|
||||
@ -152,12 +147,10 @@ class Workflow extends SerializerDeserializer<Workflow> implements ShallowData
|
||||
"id": id,
|
||||
"name": name,
|
||||
"datas": data,
|
||||
"computes" : compute,
|
||||
"storages": storage,
|
||||
"processings": processing,
|
||||
"computes" : compute,
|
||||
"workflows": workflows,
|
||||
"schedule_active": scheduleActive,
|
||||
"schedule": schedule?.serialize(),
|
||||
"processings": processing,
|
||||
};
|
||||
if (graph != null) {
|
||||
obj["graph"] = graph!.serialize();
|
||||
@ -168,24 +161,17 @@ class Workflow extends SerializerDeserializer<Workflow> implements ShallowData
|
||||
void fromDashboard(Map<String, dynamic> j) {
|
||||
id = j["id"];
|
||||
name = j["name"];
|
||||
scheduleActive = j["schedule_active"];
|
||||
if (j.containsKey("graph")) {
|
||||
graph = Graph();
|
||||
graph!.fromDashboard(j["graph"]);
|
||||
}
|
||||
if (j.containsKey("schedule")) {
|
||||
schedule = Scheduler();
|
||||
schedule!.fromDashboard(j["schedule"]);
|
||||
}
|
||||
}
|
||||
Map<String, dynamic> toDashboard() {
|
||||
return {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"graph": graph?.toDashboard(),
|
||||
"schedule_active": scheduleActive,
|
||||
"schedule": schedule?.toDashboard(),
|
||||
"shared": shared,
|
||||
"graph": graph?.toDashboard(),
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -221,7 +207,7 @@ class Scheduler extends SerializerDeserializer<Scheduler> {
|
||||
end = DateTime.parse(j["end"]);
|
||||
}
|
||||
|
||||
} catch (e) {}
|
||||
} catch (e) { /**/ }
|
||||
}
|
||||
Map<String, dynamic> toDashboard() {
|
||||
return {
|
||||
@ -279,6 +265,159 @@ class Graph extends SerializerDeserializer<Graph> {
|
||||
this.links = const [],
|
||||
});
|
||||
|
||||
Map<String, List<dynamic>> getInfosToUpdate(SubMapFormsType type) {
|
||||
Map<String, List<dynamic>> infos = {};
|
||||
for (var item in items.values) {
|
||||
var inst = item.getElement()?.getSelectedInstance();
|
||||
if (inst == null) { return infos; }
|
||||
infos[item.id ?? ""] = (type == SubMapFormsType.INPUT ? inst.inputs : (
|
||||
type == SubMapFormsType.OUTPUT ? inst.outputs : inst.env)).map( (e) => e.serialize()).toList();
|
||||
}
|
||||
return infos;
|
||||
}
|
||||
|
||||
Map<String, List<dynamic>> getEnvToUpdate() {
|
||||
return getInfosToUpdate(SubMapFormsType.ENV);
|
||||
}
|
||||
|
||||
Map<String, List<dynamic>> getInputToUpdate() {
|
||||
return getInfosToUpdate(SubMapFormsType.INPUT);
|
||||
}
|
||||
|
||||
Map<String, List<dynamic>> getOutputToUpdate() {
|
||||
return getInfosToUpdate(SubMapFormsType.OUTPUT);
|
||||
}
|
||||
|
||||
|
||||
GraphItem getItemByElementID(String id) {
|
||||
return items[id] ?? GraphItem();
|
||||
}
|
||||
Map<String,GraphItem?> getArrowByElementID(String id) {
|
||||
Map<String,GraphItem?> arr = {};
|
||||
for (var link in links) {
|
||||
var nested = false;
|
||||
var reverse = false;
|
||||
String? from = link.source?.id;
|
||||
String? to = link.destination?.id;
|
||||
bool isInLink = (from?.contains(id) ?? false) || (to?.contains(id) ?? false);
|
||||
if (isInLink && (["storage", "compute"].contains(getItemByElementID(from ?? "").getElement()?.getType())
|
||||
|| ["storage", "compute"].contains(getItemByElementID(to ?? "").getElement()?.getType()))) {
|
||||
nested = true;
|
||||
reverse = link.source?.id?.contains(id) ?? false;
|
||||
}
|
||||
if (nested || isInLink) {
|
||||
arr[reverse ? (to ?? "") : (from ?? "") ] = getItemByElementID(reverse ? (to ?? "") : (from ?? "") );
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
void fillEnv(AbstractItem? mainItem, GraphItem? item, SubMapFormsType type, Map<String,int> alreadySeen) {
|
||||
if (mainItem == null || item == null) {
|
||||
return;
|
||||
}
|
||||
AbstractItem? el = item.getElement();
|
||||
if (el?.getSelectedInstance() == null) {
|
||||
return;
|
||||
}
|
||||
var inst = el!.getSelectedInstance()!;
|
||||
|
||||
var inst2 = mainItem.getSelectedInstance()!;
|
||||
var what = type == SubMapFormsType.INPUT ? inst.inputs : (
|
||||
type == SubMapFormsType.OUTPUT ? inst.outputs : inst.env);
|
||||
var what2 = type == SubMapFormsType.INPUT ? inst2.inputs : (
|
||||
type == SubMapFormsType.OUTPUT ? inst2.outputs : inst2.env);
|
||||
for (var e in what2) {
|
||||
if (e.attr != null && e.value == null) {
|
||||
e.value = inst2.serialize()[e.attr!];
|
||||
}
|
||||
}
|
||||
// should find arrow env info and add it to the env
|
||||
List<Param> extParams = [];
|
||||
var arrows = links.where( (e) => (e.source?.id?.contains(item.id ?? "") ?? false) || (e.destination?.id?.contains(item.id ?? "") ?? false));
|
||||
for (var arrow in arrows) {
|
||||
for (var info in arrow.infos) {
|
||||
var i = info as Map<String, dynamic>;
|
||||
for (var entry in i.entries) {
|
||||
if (entry.value == null) { continue; }
|
||||
|
||||
var varName = "LINK_${el.getName().toUpperCase().replaceAll(" ", "_")}_${entry.key.toUpperCase()}";
|
||||
/*alreadySeen[varName] = (alreadySeen[varName] ?? -1) + 1;
|
||||
if ((alreadySeen[varName] ?? 0) > 1) {
|
||||
varName = "${varName}_${alreadySeen[varName]}";
|
||||
}*/
|
||||
if ((entry.value is String) && !isEnvAttr(entry.value, what2)) {
|
||||
extParams.add(Param( name: varName,
|
||||
attr: entry.key, value: entry.value, origin: item.id, readOnly: true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for ( var param in what) {
|
||||
if (param.attr == null) { continue; }
|
||||
var varName = param.name != null && (param.name!.contains("LINK_")
|
||||
|| param.name!.contains("DATA_")
|
||||
|| param.name!.contains("PROCESSING_")
|
||||
|| param.name!.contains("STORAGE_")
|
||||
|| param.name!.contains("WORKFLOW_")
|
||||
|| param.name!.contains("COMPUTE") ) ? param.name : "${el.topic.toUpperCase()}_${el.getName().toUpperCase().replaceAll(" ", "_")}_${param.attr!.toUpperCase()}";
|
||||
/*alreadySeen[varName] = (alreadySeen[varName] ?? -1) + 1;
|
||||
if ((alreadySeen[varName] ?? 0) > 0) {
|
||||
varName = "${varName}_${alreadySeen[varName]}";
|
||||
}*/
|
||||
dynamic env;
|
||||
if (param.value == null) {
|
||||
var s = el.serialize();
|
||||
s.addAll(el.getSelectedInstance()?.serialize() ?? {});
|
||||
env = s[param.attr!];
|
||||
} else {
|
||||
env = param.value;
|
||||
}
|
||||
// bool isSrc = param.origin == null;
|
||||
//if (isSrc) { continue; }
|
||||
if (!isEnvAttr(env, what2)) {
|
||||
extParams.add(Param( name: varName,
|
||||
attr: param.attr, value: env, origin: item.id, readOnly: true));
|
||||
}
|
||||
}
|
||||
for (var param in extParams) {
|
||||
what2.add(param);
|
||||
}
|
||||
}
|
||||
|
||||
bool isEnvAttr(String value, List<Param> params) {
|
||||
for (var e in params) {
|
||||
if (value == e.value) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void fill() {
|
||||
Map<String, int> alreadySeen = {};
|
||||
var its = items.values.toList();
|
||||
for (var type in [SubMapFormsType.INPUT, SubMapFormsType.OUTPUT, SubMapFormsType.ENV]) {
|
||||
for (var item in its) {
|
||||
var envs = type == SubMapFormsType.INPUT ? item.getElement()?.getSelectedInstance()?.inputs : (
|
||||
type == SubMapFormsType.OUTPUT ? item.getElement()?.getSelectedInstance()?.outputs : item.getElement()?.getSelectedInstance()?.env);
|
||||
if (envs != null) {
|
||||
envs.removeWhere( (e) => e.readOnly && e.name != null
|
||||
&& (e.name!.contains("LINK_")
|
||||
|| e.name!.contains("DATA_")
|
||||
|| e.name!.contains("PROCESSING_")
|
||||
|| e.name!.contains("STORAGE_")
|
||||
|| e.name!.contains("WORKFLOW_")
|
||||
|| e.name!.contains("COMPUTE") ));
|
||||
}
|
||||
}
|
||||
for (var item in [...its, ...its.reversed]) {
|
||||
var itss = getArrowByElementID(item.id ?? "");
|
||||
for (var i in itss.values) {
|
||||
fillEnv(item.getElement(), i, type, alreadySeen);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void fromDashboard(Map<String, dynamic> j) {
|
||||
items = {};
|
||||
for (var el in (j["elements"] as Map<dynamic, dynamic>).values) {
|
||||
@ -292,9 +431,11 @@ class Graph extends SerializerDeserializer<Graph> {
|
||||
return d;
|
||||
}).toList();
|
||||
j["zoom"] = zoom;
|
||||
fill();
|
||||
}
|
||||
|
||||
Map<String, dynamic> toDashboard() {
|
||||
fill();
|
||||
List<Map<String, dynamic>> elements = [];
|
||||
List<Map<String, dynamic>> arrows = [];
|
||||
for (var el in items.values) {
|
||||
@ -313,28 +454,70 @@ class Graph extends SerializerDeserializer<Graph> {
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return Graph(); }
|
||||
return Graph(
|
||||
var g = Graph(
|
||||
zoom: json.containsKey("zoom") ? double.parse(json["zoom"].toString()) : 0,
|
||||
links: json.containsKey("links") ? fromListJson(json["links"], GraphLink()) : [],
|
||||
items: json.containsKey("items") ? fromMapJson<GraphItem>(json["items"], GraphItem()) : {},
|
||||
);
|
||||
g.fill();
|
||||
return g;
|
||||
}
|
||||
@override Map<String, dynamic> serialize() {
|
||||
fill();
|
||||
return {
|
||||
"zoom": zoom,
|
||||
"items": toMapJson(items),
|
||||
"links": toListJson(links),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class StorageProcessingGraphLink extends SerializerDeserializer<StorageProcessingGraphLink> {
|
||||
bool write = false;
|
||||
String? source;
|
||||
String? destination;
|
||||
String? filename;
|
||||
|
||||
StorageProcessingGraphLink({
|
||||
this.write = false,
|
||||
this.source,
|
||||
this.destination,
|
||||
this.filename,
|
||||
});
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return StorageProcessingGraphLink(); }
|
||||
return StorageProcessingGraphLink(
|
||||
write: json.containsKey("write") ? json["write"] : false,
|
||||
source: json.containsKey("source") ? json["source"] : "",
|
||||
destination: json.containsKey("destination") ? json["destination"] : "",
|
||||
filename: json.containsKey("filename") && json["filename"] != null ? json["filename"] : "",
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() {
|
||||
return {
|
||||
"write": write,
|
||||
"source": source,
|
||||
"destination": destination,
|
||||
"filename": filename,
|
||||
};
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"zoom": zoom,
|
||||
"items": toMapJson(items),
|
||||
"links": toListJson(links),
|
||||
};
|
||||
}
|
||||
|
||||
class GraphLink extends SerializerDeserializer<GraphLink> {
|
||||
Position? source;
|
||||
Position? destination;
|
||||
GraphLinkStyle? style;
|
||||
List<StorageProcessingGraphLink> infos = [];
|
||||
List<Param> env = [];
|
||||
|
||||
GraphLink({
|
||||
this.source,
|
||||
this.destination,
|
||||
this.style,
|
||||
this.infos = const [],
|
||||
this.env = const [],
|
||||
});
|
||||
|
||||
void fromDashboard(Map<String, dynamic> j) {
|
||||
@ -342,6 +525,8 @@ class GraphLink extends SerializerDeserializer<GraphLink> {
|
||||
destination = Position(id: j["to"]["id"], x: j["to"]["x"], y: j["to"]["y"]);
|
||||
style = GraphLinkStyle();
|
||||
style!.fromDashboard(j["params"]);
|
||||
infos = fromListJson(j["infos"], StorageProcessingGraphLink());
|
||||
env = fromListJson(j["env"], Param());
|
||||
}
|
||||
|
||||
Map<String, dynamic> toDashboard() {
|
||||
@ -357,6 +542,8 @@ class GraphLink extends SerializerDeserializer<GraphLink> {
|
||||
"y": destination?.y ?? 0,
|
||||
},
|
||||
"params": style?.toDashboard(),
|
||||
"infos": toListJson(infos),
|
||||
"env": env.map( (el) => el.serialize()).toList(),
|
||||
};
|
||||
}
|
||||
|
||||
@ -364,9 +551,11 @@ class GraphLink extends SerializerDeserializer<GraphLink> {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return GraphLink(); }
|
||||
return GraphLink(
|
||||
source: json.containsKey("source") ? Position().deserialize(json["source"]) : null,
|
||||
destination: json.containsKey("destination") ? Position().deserialize(json["destination"]) : null,
|
||||
style: json.containsKey("style") ? GraphLinkStyle().deserialize(json["style"]) : null,
|
||||
source: json.containsKey("source") && json["source"] != null ? Position().deserialize(json["source"]) : null,
|
||||
destination: json.containsKey("destination") && json["destination"] != null ? Position().deserialize(json["destination"]) : null,
|
||||
style: json.containsKey("style") && json["style"] != null ? GraphLinkStyle().deserialize(json["style"]) : null,
|
||||
infos: json.containsKey("storage_link_infos") && json["storage_link_infos"] != null ? fromListJson(json["storage_link_infos"], StorageProcessingGraphLink()) : [],
|
||||
env: json.containsKey("env") && json["env"] != null ? fromListJson(json["env"], Param()) : [],
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() {
|
||||
@ -380,6 +569,8 @@ class GraphLink extends SerializerDeserializer<GraphLink> {
|
||||
if (style != null) {
|
||||
obj["style"] = style!.serialize();
|
||||
}
|
||||
obj["storage_link_infos"] = toListJson(infos);
|
||||
obj["env"] = toListJson(env);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
@ -521,33 +712,19 @@ class GraphItem extends SerializerDeserializer<GraphItem> {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
void fromDashboard(Map<String, dynamic> j) {
|
||||
id = j["id"];
|
||||
position = Position(x: j["x"], y: j["y"]);
|
||||
width = j["width"];
|
||||
height = j["height"];
|
||||
|
||||
var abs = WorkspaceLocal.getItem(j["element"]?["id"] ?? "", true) as AbstractItem<FlowData>?;
|
||||
if (abs != null) {
|
||||
if (abs.topic == "data") {
|
||||
data = DataItem().deserialize(abs.serialize());
|
||||
data!.model = ResourceModel().deserialize(j["element"]["resource_model"]);
|
||||
} else if (abs.topic == "processing") {
|
||||
processing = ProcessingItem().deserialize(abs.serialize());
|
||||
processing!.model = ResourceModel().deserialize(j["element"]["resource_model"]);
|
||||
if ((j["element"] as Map<String, dynamic>).containsKey("container")) {
|
||||
processing!.container = Containered().deserialize(j["element"]["container"]);
|
||||
processing!.container?.env?.removeWhere((key, value) => key == "" || value == "");
|
||||
processing!.container?.volumes?.removeWhere((key, value) => key == "" || value == "");
|
||||
processing!.expose.removeWhere((element) => element.port == null || element.port == 0 || (element.PAT == 0 && element.path == ""));
|
||||
|
||||
}
|
||||
} 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());
|
||||
if (j["element"] != null) {
|
||||
if (j["element"]["type"] == "data") { data = DataItem().deserialize(j["element"]);
|
||||
} else if (j["element"]["type"] == "processing") { processing = ProcessingItem().deserialize(j["element"]);
|
||||
} else if (j["element"]["type"] == "compute") { compute = ComputeItem().deserialize(j["element"]);
|
||||
} else if (j["element"]["type"] == "storage") { storage = StorageItem().deserialize(j["element"]);
|
||||
} else if (j["element"]["type"] == "workflow") { workflow = WorkflowItem().deserialize(j["element"]);
|
||||
} else {
|
||||
compute = null;
|
||||
data = null;
|
||||
@ -566,7 +743,8 @@ class GraphItem extends SerializerDeserializer<GraphItem> {
|
||||
|
||||
Map<String, dynamic> toDashboard() {
|
||||
Map<String, dynamic> element = {};
|
||||
for(var el in [data, processing, storage, compute, workflow]) {
|
||||
List<AbstractItem?> items = [data, processing, storage, compute, workflow];
|
||||
for(var el in items) {
|
||||
if (el != null && el.getID() != "") {
|
||||
element = el.serialize();
|
||||
break;
|
||||
|
@ -1,7 +1,10 @@
|
||||
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
|
||||
import 'package:oc_front/models/abstract.dart';
|
||||
import 'package:oc_front/models/resources/compute.dart';
|
||||
import 'package:oc_front/models/resources/data.dart';
|
||||
import 'package:oc_front/models/resources/processing.dart';
|
||||
import 'package:oc_front/models/resources/storage.dart';
|
||||
import 'package:oc_front/models/resources/workflow.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
|
||||
class Workspace extends SerializerDeserializer<Workspace> implements ShallowData {
|
||||
String? id;
|
||||
@ -44,13 +47,15 @@ class Workspace extends SerializerDeserializer<Workspace> implements ShallowData
|
||||
workflows: json.containsKey("workflow_resources") ? fromListJson(json["workflow_resources"], WorkflowItem()) : []
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"processings": processings.map((e) => e.id).toList(),
|
||||
"storages": storages.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(),
|
||||
};
|
||||
@override Map<String, dynamic> serialize() {
|
||||
return {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"processings": processings.map((e) => e.id).toList(),
|
||||
"storages": storages.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(),
|
||||
};
|
||||
}
|
||||
}
|
@ -6,4 +6,6 @@ abstract class AbstractFactory {
|
||||
Widget factory(GoRouterState state, List<String> args);
|
||||
bool searchFill();
|
||||
void search(BuildContext context, bool special);
|
||||
String? getSearch();
|
||||
void back(BuildContext context);
|
||||
}
|
@ -1,26 +1,71 @@
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:oc_front/widgets/catalog.dart';
|
||||
import 'package:localstorage/localstorage.dart';
|
||||
import 'package:oc_front/pages/abstract_page.dart';
|
||||
import 'package:oc_front/models/resources/resources.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/main.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/widgets/catalog.dart';
|
||||
import 'package:oc_front/pages/abstract_page.dart';
|
||||
|
||||
|
||||
class CatalogFactory implements AbstractFactory {
|
||||
@override GlobalKey getKey() { return key; }
|
||||
static GlobalKey<CatalogPageWidgetState> key = GlobalKey<CatalogPageWidgetState>();
|
||||
@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, bool special) {
|
||||
if (special) { return; }
|
||||
CatalogFactory.key.currentState?.widget.search.search(context, [ SearchConstants.get()! ], {}).then((value) {
|
||||
if (value.data == null) { return; }
|
||||
key.currentState?.widget.items = [ ...value.data!.workflows,
|
||||
...value.data!.processings, ...value.data!.datas, ...value.data!.storages, ...value.data!.computes,];
|
||||
@override void back(BuildContext context) {
|
||||
var s = (localStorage.getItem("search") ?? "");
|
||||
if (s != "") {
|
||||
localStorage.setItem("search", s.split(",").sublist(1).join(","));
|
||||
SearchConstants.set(s.split(",").sublist(1).join(","));
|
||||
if ((localStorage.getItem("search") ?? "") == "") {
|
||||
SearchConstants.remove();
|
||||
key.currentState?.widget.isSearch = true;
|
||||
key.currentState?.widget.items = [];
|
||||
HeaderConstants.headerKey.currentState?.setState(() {});
|
||||
HeaderConstants.headerWidget?.setState(() {});
|
||||
CatalogFactory.key.currentState?.setState(() {});
|
||||
} else {
|
||||
CatalogFactory().search(context, false);
|
||||
}
|
||||
} else {
|
||||
SearchConstants.remove();
|
||||
key.currentState?.widget.isSearch = true;
|
||||
key.currentState?.widget.items = [];
|
||||
HeaderConstants.headerKey.currentState?.setState(() {});
|
||||
HeaderConstants.headerWidget?.setState(() {});
|
||||
CatalogFactory.key.currentState?.setState(() {}); // ignore: invalid_use_of_protected_member
|
||||
CatalogFactory.key.currentState?.setState(() {});
|
||||
}
|
||||
}
|
||||
@override bool searchFill() { return (key.currentState?.widget.items.isEmpty ?? true) && (key.currentState?.widget.isSearch ?? true); }
|
||||
@override Widget factory(GoRouterState state, List<String> args) { return CatalogPageWidget(); }
|
||||
@override String? getSearch() {
|
||||
if ((localStorage.getItem("search") ?? "") == "") { return null; }
|
||||
return localStorage.getItem("search")!.split(",")[0];
|
||||
}
|
||||
@override void search(BuildContext context, bool special) {
|
||||
if (special) { return; } // T
|
||||
key.currentState?.widget.isSearch = true;
|
||||
var s = (localStorage.getItem("search") ?? "");
|
||||
if (s != "") {
|
||||
if (SearchConstants.get() == null) {
|
||||
localStorage.setItem("search", s);
|
||||
} else if (s.split(",")[0] != SearchConstants.get()) {
|
||||
localStorage.setItem("search", "${SearchConstants.get()!},$s");
|
||||
}
|
||||
} else if ((SearchConstants.get() ?? "") == "") { return;
|
||||
} else { localStorage.setItem("search", SearchConstants.get()!); }
|
||||
CatalogFactory.key.currentState?.widget.search.search(context, [
|
||||
localStorage.getItem("search")!.split(",")[0] ], {}).then((value) {
|
||||
if (value.data == null) {
|
||||
key.currentState?.widget.items = [];
|
||||
} else {
|
||||
key.currentState?.widget.isSearch = false;
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -28,6 +73,7 @@ class CatalogFactory implements AbstractFactory {
|
||||
// ignore: must_be_immutable
|
||||
class CatalogPageWidget extends StatefulWidget {
|
||||
double? itemWidth;
|
||||
bool isSearch = true;
|
||||
List<AbstractItem> items = [];
|
||||
final ResourceService search = ResourceService();
|
||||
CatalogPageWidget ({
|
||||
@ -37,7 +83,16 @@ class CatalogPageWidget extends StatefulWidget {
|
||||
}
|
||||
class CatalogPageWidgetState extends State<CatalogPageWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
if (widget.items.isEmpty) { return Container(); }
|
||||
if (widget.items.isEmpty) {
|
||||
if (widget.isSearch) { return Container(); }
|
||||
return Container(
|
||||
width: getMainWidth(context),
|
||||
height: getMainHeight(context) - 50,
|
||||
color: Colors.grey.shade300,
|
||||
child: const Center(child: Text("NO RESOURCES FOUND",
|
||||
style: TextStyle(fontSize: 30, color: Colors.grey))
|
||||
),
|
||||
); }
|
||||
return Column( children : [
|
||||
SizedBox( width: getMainWidth(context),
|
||||
height: getMainHeight(context) - 50,
|
||||
@ -46,35 +101,3 @@ class CatalogPageWidgetState extends State<CatalogPageWidget> {
|
||||
);
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
PermsService.getPerm(Perms.WORKSPACE_SHARE) ? ShallowDropdownInputWidget(
|
||||
iconLoad: Icons.share_rounded,
|
||||
tooltipLoad: 'share',
|
||||
tooltipRemove: 'unshare',
|
||||
color: Colors.white,
|
||||
filled: const Color.fromRGBO(38, 166, 154, 1),
|
||||
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: (getMainWidth(context) / 3),
|
||||
canLoad: (String? change) => CollaborativeAreaLocal.workspaces[change] == null
|
||||
|| !CollaborativeAreaLocal.workspaces[change]!.workspaces.map(
|
||||
(e) => e.id ).contains(WorkspaceLocal.current),
|
||||
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
|
||||
CollaborativeAreaLocal.init(context, false);
|
||||
},
|
||||
remove: (String val) async {
|
||||
await SharedService().removeWorkspace(context, val, WorkspaceLocal.current ?? "");
|
||||
// ignore: use_build_context_synchronously
|
||||
CollaborativeAreaLocal.init(context, false);
|
||||
}) : Container(width: (getMainWidth(context) / 3), height: 50,
|
||||
color: const Color.fromRGBO(38, 166, 154, 1)),
|
||||
*/
|
@ -1,8 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:localstorage/localstorage.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/router.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/models/resources/resources.dart';
|
||||
import 'package:oc_front/pages/abstract_page.dart';
|
||||
import 'package:oc_front/pages/catalog.dart';
|
||||
import 'package:oc_front/widgets/items/item.dart';
|
||||
@ -11,6 +14,13 @@ import 'package:oc_front/widgets/items/item_row.dart';
|
||||
class CatalogItemFactory implements AbstractFactory {
|
||||
static GlobalKey<CatalogItemPageWidgetState> key = GlobalKey<CatalogItemPageWidgetState>();
|
||||
@override GlobalKey getKey() { return key; }
|
||||
@override void back(BuildContext context) {
|
||||
search(context, false);
|
||||
}
|
||||
@override String? getSearch() {
|
||||
if ((localStorage.getItem("search") ?? "") == "") { return null; }
|
||||
return localStorage.getItem("search")!.split(",")[0];
|
||||
}
|
||||
@override bool searchFill() { return false; }
|
||||
@override Widget factory(GoRouterState state, List<String> args) {
|
||||
var id = state.pathParameters[args.first];
|
||||
@ -19,13 +29,22 @@ class CatalogItemFactory implements AbstractFactory {
|
||||
return CatalogItemPageWidget(item : item!);
|
||||
} catch (e) {
|
||||
var item = WorkspaceLocal.getItem(id ?? "", false);
|
||||
if (item != null) { return CatalogItemPageWidget(item : item as AbstractItem); }
|
||||
if (item != null) { return CatalogItemPageWidget(item : item); }
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
@override void search(BuildContext context, bool special) { }
|
||||
@override void search(BuildContext context, bool special) {
|
||||
if (special) { return; } // T
|
||||
var s = SearchConstants.get();
|
||||
AppRouter.catalog.go(context, {});
|
||||
Future.delayed(Duration(milliseconds: 10), () {
|
||||
SearchConstants.set(s);
|
||||
CatalogFactory().search(context, false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class CatalogItemPageWidget extends StatefulWidget {
|
||||
AbstractItem item;
|
||||
CatalogItemPageWidget ({ required this.item }) : super(key: CatalogItemFactory.key);
|
||||
@ -35,7 +54,7 @@ class CatalogItemPageWidgetState extends State<CatalogItemPageWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
return Column( children: [
|
||||
ItemRowWidget(contextWidth: getMainWidth(context), item: widget.item, readOnly: true,),
|
||||
ItemWidget(item: widget.item,),
|
||||
ItemWidget(item: widget.item),
|
||||
]);
|
||||
}
|
||||
}
|
@ -4,18 +4,20 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/booking_service.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:intl/intl.dart' as intl;
|
||||
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 DatacenterFactory implements AbstractFactory {
|
||||
@override GlobalKey getKey() { return key; }
|
||||
@override String? getSearch() { return ""; }
|
||||
@override void back(BuildContext context) { }
|
||||
static GlobalKey<ComputePageWidgetState> key = GlobalKey<ComputePageWidgetState>();
|
||||
@override bool searchFill() { return false; }
|
||||
@override Widget factory(GoRouterState state, List<String> args) { return ComputePageWidget(); }
|
||||
@override void search(BuildContext context, bool special) { }
|
||||
}
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class ComputePageWidget extends StatefulWidget {
|
||||
bool isList = true;
|
||||
DateTime start = DateTime.now();
|
||||
@ -169,7 +171,7 @@ class ComputePageWidgetState extends State<ComputePageWidget> {
|
||||
)
|
||||
]))
|
||||
),
|
||||
ScheduleWidget( service: widget._service, key: k, start: widget.start, end : widget.end, isList: widget.isList, isBox: false)
|
||||
ScheduleWidget( key: k, start: widget.start, end : widget.end, isList: widget.isList, isBox: false)
|
||||
]);
|
||||
}
|
||||
}
|
@ -1,18 +1,32 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/datacenter_service.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:oc_front/models/resources/compute.dart';
|
||||
import 'package:oc_front/models/resources/resources.dart';
|
||||
import 'package:oc_front/models/resources/storage.dart';
|
||||
import 'package:oc_front/pages/abstract_page.dart';
|
||||
import 'package:oc_front/widgets/items/item_row.dart';
|
||||
|
||||
|
||||
class MapFactory implements AbstractFactory {
|
||||
@override GlobalKey getKey() { return key; }
|
||||
@override String? getSearch() { return ""; }
|
||||
@override void back(BuildContext context) { }
|
||||
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, bool special) { }
|
||||
}
|
||||
|
||||
double menuSize = 0;
|
||||
class MapPageWidget extends StatefulWidget {
|
||||
bool isShowed = false;
|
||||
final DatacenterService _service = DatacenterService();
|
||||
MapPageWidget(): super(key: MapFactory.key);
|
||||
@override MapPageWidgetState createState() => MapPageWidgetState();
|
||||
static void search(BuildContext context) { }
|
||||
@ -22,26 +36,193 @@ class MapPageWidgetState extends State<MapPageWidget> {
|
||||
double currentZoom = 2.0;
|
||||
LatLng currentCenter = const LatLng(51.5, -0.09);
|
||||
static final MapController _mapController = MapController();
|
||||
void _zoom() {
|
||||
currentZoom = currentZoom - 1;
|
||||
_mapController.move(currentCenter, currentZoom);
|
||||
}
|
||||
bool selected = true;
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
child : FlutterMap(
|
||||
mapController: _mapController,
|
||||
options: MapOptions(
|
||||
initialCenter: currentCenter,
|
||||
initialZoom: currentZoom,
|
||||
return FutureBuilder(future: widget._service.all(context), builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||
Map<String, Map<AbstractItem, LatLng>> coordinates = {};
|
||||
List<Marker> markerCoordinates = [];
|
||||
if (snapshot.data != null&& snapshot.data!.data != null && snapshot.data!.data!.values.isNotEmpty) {
|
||||
for (var element in snapshot.data!.data!.values) {
|
||||
if (element["type"] == "storage") {
|
||||
StorageItem resource = StorageItem().deserialize(element);
|
||||
var instance = resource.getSelectedInstance();
|
||||
if (instance == null || instance.location == null) { continue; }
|
||||
if (coordinates[resource.topic] == null) { coordinates[resource.topic] = {}; }
|
||||
coordinates[resource.topic]![resource] = LatLng(instance.location!.latitude ?? 0, instance.location!.longitude ?? 0);
|
||||
} else if (element["type"] == "compute") {
|
||||
ComputeItem resource = ComputeItem().deserialize(element);
|
||||
var instance = resource.getSelectedInstance();
|
||||
if (instance == null || instance.location == null) { continue; }
|
||||
if (coordinates[resource.topic] == null) { coordinates[resource.topic] = {}; }
|
||||
var lr = Random().nextInt(max(1, 100)) / 10000;
|
||||
var lfr = Random().nextInt(max(1, 100)) / 10000;
|
||||
coordinates[resource.topic]![resource] = LatLng((instance.location!.latitude ?? 0) + lr, (instance.location!.longitude ?? 0) + lfr);
|
||||
}
|
||||
}
|
||||
for (var topic in coordinates.keys) {
|
||||
for (var coord in coordinates[topic]!.keys) {
|
||||
markerCoordinates.add(Marker(
|
||||
width: 25,
|
||||
height: 30,
|
||||
point: coordinates[topic]![coord]!,
|
||||
child: HoverMenu( width: 110, title: Container( alignment: Alignment.center,
|
||||
constraints: BoxConstraints( maxHeight: 100, maxWidth: 100 ),
|
||||
child: Icon(FontAwesomeIcons.locationDot,
|
||||
shadows: <Shadow>[Shadow(color: Color.fromRGBO(0, 0, 0, 1), blurRadius: 10.0)],
|
||||
color: getColor(topic)) ),
|
||||
items: [ Container(color: Colors.white,
|
||||
child: ItemRowWidget(low: true, contextWidth: 290, item: coord)) ]
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
Rect rect = Rect.fromCenter( center: MediaQuery.of(context).size.center(Offset.zero),
|
||||
width: selected ? menuSize : 0, height: (getMainHeight(context) - 50) > 0 ? (getMainHeight(context) - 50) : 0);
|
||||
return Expanded(
|
||||
child : FlutterMap(
|
||||
mapController: _mapController,
|
||||
options: MapOptions(
|
||||
initialCenter: currentCenter,
|
||||
initialZoom: currentZoom,
|
||||
),
|
||||
children: [
|
||||
TileLayer(
|
||||
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
userAgentPackageName: 'dev.fleaflet.flutter_map.example',
|
||||
),
|
||||
MarkerLayer(
|
||||
markers: markerCoordinates,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return const CircularProgressIndicator();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class HoverMenuController {
|
||||
HoverMenuState? currentState;
|
||||
|
||||
void hideSubMenu() {
|
||||
currentState?.hideSubMenu();
|
||||
}
|
||||
}
|
||||
|
||||
class HoverMenu extends StatefulWidget {
|
||||
final Widget title;
|
||||
final double? width;
|
||||
final List<Widget> items;
|
||||
final HoverMenuController? controller;
|
||||
bool isHovered = false;
|
||||
|
||||
|
||||
HoverMenu({
|
||||
Key? key,
|
||||
required this.title,
|
||||
this.items = const [],
|
||||
this.width,
|
||||
this.controller,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
HoverMenuState createState() => HoverMenuState();
|
||||
}
|
||||
|
||||
class HoverMenuState extends State<HoverMenu> {
|
||||
OverlayEntry? _overlayEntry;
|
||||
final _focusNode = FocusNode();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_focusNode.addListener(_onFocusChanged);
|
||||
|
||||
if (widget.controller != null) {
|
||||
widget.controller?.currentState = this;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_focusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _onFocusChanged() {
|
||||
if (_focusNode.hasFocus) {
|
||||
_overlayEntry = _createOverlayEntry();
|
||||
Overlay.of(context).insert(_overlayEntry!);
|
||||
} else {
|
||||
_overlayEntry?.remove();
|
||||
_removeOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
void _removeOverlay() {
|
||||
widget.isHovered = false;
|
||||
}
|
||||
|
||||
void hideSubMenu() {
|
||||
_focusNode.unfocus();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
elevation: 0.0,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(0)),
|
||||
splashFactory: NoSplash.splashFactory,
|
||||
padding: EdgeInsets.zero,
|
||||
foregroundColor: Colors.transparent,
|
||||
surfaceTintColor: Colors.transparent,
|
||||
backgroundColor: Colors.transparent,
|
||||
shadowColor: Colors.transparent,
|
||||
),
|
||||
children: [
|
||||
TileLayer(
|
||||
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
userAgentPackageName: 'dev.fleaflet.flutter_map.example',
|
||||
)
|
||||
],
|
||||
)
|
||||
focusNode: _focusNode,
|
||||
onHover: (isHovered) {
|
||||
if (isHovered && !widget.isHovered) {
|
||||
_focusNode.requestFocus();
|
||||
isHovered = true;
|
||||
} else {
|
||||
_focusNode.unfocus();
|
||||
widget.isHovered = false;
|
||||
}
|
||||
},
|
||||
onPressed: () {},
|
||||
child: widget.title,
|
||||
);
|
||||
}
|
||||
|
||||
OverlayEntry _createOverlayEntry() {
|
||||
final renderBox = context.findRenderObject() as RenderBox;
|
||||
final size = renderBox.size;
|
||||
final offset = renderBox.localToGlobal(Offset.zero);
|
||||
|
||||
return OverlayEntry(
|
||||
maintainState: true,
|
||||
builder: (context) => Positioned(
|
||||
left: offset.dx - 300,
|
||||
top: offset.dy + size.height,
|
||||
width: 300,
|
||||
child: TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.zero,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(0)),
|
||||
splashFactory: NoSplash.splashFactory,
|
||||
backgroundColor: Colors.transparent,
|
||||
),
|
||||
onPressed: () {},
|
||||
child: ListView(
|
||||
padding: EdgeInsets.zero,
|
||||
shrinkWrap: true,
|
||||
children: widget.items)),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -9,12 +9,15 @@ import 'package:oc_front/widgets/sheduler_items/schedule.dart';
|
||||
|
||||
class SchedulerFactory implements AbstractFactory {
|
||||
@override GlobalKey getKey() { return key; }
|
||||
@override String? getSearch() { return ""; }
|
||||
@override void back(BuildContext context) { }
|
||||
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, bool special) { }
|
||||
}
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class SchedulerPageWidget extends StatefulWidget {
|
||||
bool isList = true;
|
||||
DateTime start = DateTime.now();
|
||||
@ -164,7 +167,7 @@ class SchedulerPageWidgetState extends State<SchedulerPageWidget> {
|
||||
)
|
||||
]))
|
||||
),
|
||||
ScheduleWidget( service: widget._service, key: k, start: widget.start, end : widget.end, isList: widget.isList, )
|
||||
ScheduleWidget( key: k, start: widget.start, end : widget.end, isList: widget.isList, )
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +1,32 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:oc_front/core/models/shared_workspace_local.dart';
|
||||
import 'package:oc_front/models/shared.dart';
|
||||
import 'package:oc_front/models/workflow.dart';
|
||||
import 'package:oc_front/widgets/catalog.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/pages/abstract_page.dart';
|
||||
import 'package:oc_front/models/resources/resources.dart';
|
||||
import 'package:oc_front/core/models/workspace_local.dart';
|
||||
import 'package:oc_front/core/sections/header/header.dart';
|
||||
import 'package:oc_front/core/services/perms_service.dart';
|
||||
import 'package:oc_front/core/services/router.dart';
|
||||
import 'package:oc_front/widgets/items/shallow_item_row.dart';
|
||||
import 'package:oc_front/widgets/dialog/shallow_creation.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_text_input.dart';
|
||||
import 'package:oc_front/core/models/shared_workspace_local.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_dropdown_input.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/peer_service.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/shared_service.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/workflow_service.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/models/shared.dart';
|
||||
import 'package:oc_front/models/workflow.dart';
|
||||
import 'package:oc_front/pages/abstract_page.dart';
|
||||
import 'package:oc_front/widgets/catalog.dart';
|
||||
import 'package:oc_front/widgets/dialog/shallow_creation.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_text_input.dart';
|
||||
import 'package:oc_front/widgets/items/shallow_item_row.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_dropdown_input.dart';
|
||||
|
||||
enum CollaborativeAreaType { global, collaborative_area, workspace, workflow, peer, resource }
|
||||
|
||||
class SharedFactory implements AbstractFactory {
|
||||
@override GlobalKey getKey() { return key; }
|
||||
@override String? getSearch() { return ""; }
|
||||
@override void back(BuildContext context) { }
|
||||
static GlobalKey<SharedPageWidgetState> key = GlobalKey<SharedPageWidgetState>();
|
||||
@override bool searchFill() { return false; }
|
||||
@override Widget factory(GoRouterState state, List<String> args) { return SharedPageWidget(); }
|
||||
@ -36,6 +35,7 @@ class SharedFactory implements AbstractFactory {
|
||||
|
||||
class SharedPageWidget extends StatefulWidget {
|
||||
CollaborativeAreaType type = CollaborativeAreaType.global;
|
||||
bool showDialog = false;
|
||||
SharedPageWidget(): super(key: SharedFactory.key);
|
||||
@override SharedPageWidgetState createState() => SharedPageWidgetState();
|
||||
static void search(BuildContext context) { }
|
||||
@ -56,7 +56,6 @@ class SharedPageWidgetState extends State<SharedPageWidget> {
|
||||
child : Icon(icon,
|
||||
color: widget.type == workspaceType ? Colors.white : Colors.white, size: 20))));
|
||||
}
|
||||
|
||||
@override Widget build(BuildContext context) {
|
||||
GlobalKey<ShallowTextInputWidgetState> key = GlobalKey<ShallowTextInputWidgetState>();
|
||||
if (CollaborativeAreaLocal.current == null) {
|
||||
@ -64,52 +63,59 @@ class SharedPageWidgetState extends State<SharedPageWidget> {
|
||||
HeaderConstants.setTitle("Choose a Collaborative Area");
|
||||
HeaderConstants.setDescription("select a shared workspace to continue");
|
||||
});
|
||||
Future.delayed( const Duration(milliseconds: 100), () {
|
||||
showDialog(
|
||||
barrierDismissible: false,
|
||||
context: context, builder: (BuildContext ctx) => AlertDialog(
|
||||
titlePadding: EdgeInsets.zero,
|
||||
insetPadding: EdgeInsets.zero,
|
||||
backgroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(0)),
|
||||
title: ShallowCreationDialogWidget(
|
||||
formKey: key,
|
||||
canClose: () => CollaborativeAreaLocal.current != null,
|
||||
context: context,
|
||||
load: (p0) async {
|
||||
CollaborativeAreaLocal.current = p0;
|
||||
HeaderConstants.setTitle("Collaborative Area <${CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current]?.name ?? ""}>");
|
||||
HeaderConstants.setDescription(CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current]?.description ?? "");
|
||||
Future.delayed(const Duration(seconds: 1), () => SharedFactory.key.currentState?.setState(() {}));
|
||||
},
|
||||
form: [
|
||||
ShallowTextInputWidget(
|
||||
change :(p0) => key.currentState?.setState(() {}),
|
||||
canLoad: (po) => po != null && po.isNotEmpty,
|
||||
type: CollaborativeAreaType.collaborative_area,
|
||||
width: getMainWidth(context) <= 540 ? getMainWidth(context) - 140 : 400,
|
||||
attr: "description",
|
||||
color: Colors.black,
|
||||
hintColor: Colors.grey,
|
||||
hint: "enter collaborative area description...",
|
||||
filled: midColor,
|
||||
)
|
||||
],
|
||||
create: PermsService.getPerm(Perms.COLLABORATIVE_AREA_CREATE) ? (p0) async => await SharedService().post(context, p0, {}).then((value) {
|
||||
if (value.data != null) {
|
||||
CollaborativeAreaLocal.current = value.data!.id;
|
||||
}
|
||||
CollaborativeAreaLocal.init(context, true);
|
||||
if (!widget.showDialog) {
|
||||
Future.delayed( const Duration(milliseconds: 100), () {
|
||||
widget.showDialog = true;
|
||||
showDialog(
|
||||
barrierDismissible: false,
|
||||
context: context,
|
||||
builder: (BuildContext ctx) => AlertDialog(
|
||||
titlePadding: EdgeInsets.zero,
|
||||
insetPadding: EdgeInsets.zero,
|
||||
backgroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(0)),
|
||||
title: ShallowCreationDialogWidget(
|
||||
formKey: key,
|
||||
canClose: () => CollaborativeAreaLocal.current != null,
|
||||
context: context,
|
||||
load: (p0) async {
|
||||
CollaborativeAreaLocal.current = p0;
|
||||
HeaderConstants.setTitle("Collaborative Area <${CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current]?.name ?? ""}>");
|
||||
HeaderConstants.setDescription(CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current]?.description ?? "");
|
||||
Future.delayed(const Duration(seconds: 1), () => SharedFactory.key.currentState?.setState(() { widget.showDialog = false; }));
|
||||
},
|
||||
form: [
|
||||
ShallowTextInputWidget(
|
||||
change :(p0) => key.currentState?.setState(() {}),
|
||||
canLoad: (po) => po != null && po.isNotEmpty,
|
||||
type: CollaborativeAreaType.collaborative_area,
|
||||
width: getMainWidth(context) <= 540 ? getMainWidth(context) - 140 : 400,
|
||||
attr: "description",
|
||||
color: Colors.black,
|
||||
hintColor: Colors.grey,
|
||||
hint: "enter collaborative area description...",
|
||||
filled: midColor,
|
||||
)
|
||||
],
|
||||
create: PermsService.getPerm(Perms.COLLABORATIVE_AREA_CREATE) ? (p0) async => await SharedService().post(context, p0, {}).then((value) {
|
||||
if (value.data != null) {
|
||||
CollaborativeAreaLocal.current = value.data!.id;
|
||||
}
|
||||
CollaborativeAreaLocal.init(context, true);
|
||||
|
||||
HeaderConstants.setTitle("Collaborative Area <${CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current]?.name ?? ""}>");
|
||||
HeaderConstants.setDescription(CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current]?.description ?? "");
|
||||
Future.delayed(const Duration(seconds: 1), () => SharedFactory.key.currentState?.setState(() {}));
|
||||
}) : null,
|
||||
type: CollaborativeAreaType.collaborative_area,
|
||||
all: () async => CollaborativeAreaLocal.workspaces.values.map(
|
||||
(e) => Shallow(id: e.id ?? "", name: e.name ?? "") ).toList(),
|
||||
)));
|
||||
});
|
||||
HeaderConstants.setTitle("Collaborative Area <${CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current]?.name ?? ""}>");
|
||||
HeaderConstants.setDescription(CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current]?.description ?? "");
|
||||
Future.delayed(const Duration(seconds: 1), () => SharedFactory.key.currentState?.setState(() { widget.showDialog = false; }));
|
||||
}) : null,
|
||||
type: CollaborativeAreaType.collaborative_area,
|
||||
all: () async {
|
||||
await CollaborativeAreaLocal.init(context, true);
|
||||
return CollaborativeAreaLocal.workspaces.values.map(
|
||||
(e) => Shallow(id: e.id ?? "", name: e.name ?? "") ).toList();
|
||||
}
|
||||
)));
|
||||
});
|
||||
}
|
||||
} else {
|
||||
Future.delayed( const Duration(milliseconds: 100), () {
|
||||
HeaderConstants.setTitle("Collaborative Area <${CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current]?.name ?? ""}>");
|
||||
@ -119,107 +125,7 @@ class SharedPageWidgetState extends State<SharedPageWidget> {
|
||||
Widget w = WorkspaceSharedPageWidget(type: widget.type);
|
||||
List<Widget> addMenu = [];
|
||||
CollaborativeArea? current = CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current ?? ""];
|
||||
if (widget.type == CollaborativeAreaType.workspace) {
|
||||
addMenu.add( Row( mainAxisAlignment: MainAxisAlignment.end,
|
||||
children : [ Container( padding: EdgeInsets.only(left: 20), decoration: BoxDecoration(
|
||||
border: Border(left: BorderSide(color: Colors.white))
|
||||
), child: ShallowDropdownInputWidget(
|
||||
tooltipLoad: "share",
|
||||
tooltipRemove: "unshare",
|
||||
iconLoad: Icons.share,
|
||||
type: widget.type,
|
||||
filled: lightColor,
|
||||
hintColor: midColor,
|
||||
color: Colors.white,
|
||||
prefixIcon: Icon(Icons.shopping_cart, color: Colors.white),
|
||||
current: WorkspaceLocal.current,
|
||||
all: () async => WorkspaceLocal.getWorkspacesShallow(),
|
||||
width: getMainWidth(context) / 3,
|
||||
canLoad: (String? change) => current == null || !current.workspaces.map( (e) => e.id ).contains(change),
|
||||
canRemove: (String? change) => current == null || current.workspaces.map( (e) => e.id ).contains(change),
|
||||
load: PermsService.getPerm(Perms.WORKSPACE_SHARE) ? (String val) async {
|
||||
await service.addWorkspace(context, CollaborativeAreaLocal.current ?? "", val);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
setState(() {});
|
||||
} : null,
|
||||
remove: PermsService.getPerm(Perms.WORKSPACE_UNSHARE) ? (String val) async {
|
||||
await service.removeWorkspace(context, CollaborativeAreaLocal.current ?? "", val);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
setState(() {});
|
||||
} : null))
|
||||
]));
|
||||
}
|
||||
if (widget.type == CollaborativeAreaType.workflow) {
|
||||
addMenu.add( Row( mainAxisAlignment: MainAxisAlignment.end,
|
||||
children : [ Container( padding: EdgeInsets.only(left: 20), decoration: BoxDecoration(
|
||||
border: Border(left: BorderSide(color: Colors.white))
|
||||
), child: ShallowDropdownInputWidget(
|
||||
tooltipLoad: "share",
|
||||
tooltipRemove: "unshare",
|
||||
iconLoad: Icons.share,
|
||||
filled: lightColor,
|
||||
hintColor: midColor,
|
||||
color: Colors.white,
|
||||
type: widget.type, all: () async {
|
||||
List<Shallow> shals = [];
|
||||
await WorflowService().all(context).then((value) {
|
||||
if (value.data != null) {
|
||||
shals = value.data!.values.map((e) => Shallow(id: e["id"], name: e["name"])).toList();
|
||||
}
|
||||
});
|
||||
return shals;
|
||||
},
|
||||
width: getMainWidth(context) / 3,
|
||||
canLoad: (String? change) => current == null || !current.workflows.map( (e) => e.id ).contains(change),
|
||||
canRemove: (String? change) => current == null || current.workflows.map( (e) => e.id ).contains(change),
|
||||
load: PermsService.getPerm(Perms.WORKFLOW_SHARE) ? (String change) async {
|
||||
await service.addWorkflow(context, CollaborativeAreaLocal.current ?? "", change);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
setState(() {});
|
||||
} : null,
|
||||
remove: PermsService.getPerm(Perms.WORKFLOW_UNSHARE) ? (String change) async {
|
||||
await service.removeWorkflow(context, CollaborativeAreaLocal.current ?? "", change);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
setState(() {});
|
||||
} : null))
|
||||
]));
|
||||
}
|
||||
if (widget.type == CollaborativeAreaType.peer) {
|
||||
addMenu.add( Row( mainAxisAlignment: MainAxisAlignment.end,
|
||||
children : [
|
||||
Container( padding: EdgeInsets.only(left: 20), decoration: BoxDecoration(
|
||||
border: Border(left: BorderSide(color: Colors.white))
|
||||
), child: ShallowDropdownInputWidget(
|
||||
tooltipLoad: "add",
|
||||
iconLoad: Icons.add,
|
||||
filled: lightColor,
|
||||
hintColor: midColor,
|
||||
color: Colors.white,
|
||||
type: widget.type, all: () async {
|
||||
List<Shallow> shals = [];
|
||||
await PeerService().all(context).then((value) {
|
||||
if (value.data != null) {
|
||||
shals = value.data!.values.map((e) => Shallow(id: e["id"], name: e["name"])).toList();
|
||||
}
|
||||
});
|
||||
return shals;
|
||||
},
|
||||
width: getMainWidth(context) / 3,
|
||||
canLoad: (String? change) => current == null || !current.peers.map( (e) => e.id ).contains(change),
|
||||
canRemove: (String? change) => current == null || current.peers.map( (e) => e.id ).contains(change),
|
||||
load: PermsService.getPerm(Perms.PEER_SHARE) ? (String change) async {
|
||||
await service.addPeer(context, CollaborativeAreaLocal.current ?? "", change);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
setState(() {});
|
||||
} : null,
|
||||
remove: PermsService.getPerm(Perms.PEER_UNSHARE) ? (String change) async {
|
||||
await service.removePeer(context, CollaborativeAreaLocal.current ?? "", change);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
setState(() {});
|
||||
} : null))
|
||||
]));
|
||||
}
|
||||
print(w);
|
||||
addMenu.add(getDropdown(widget.type, current, this, context, false));
|
||||
return Column( children: [
|
||||
Container(
|
||||
height: 50,
|
||||
@ -318,9 +224,10 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
List<Widget> badges = [];
|
||||
List<Widget> bbadges = [];
|
||||
badges.add(Container( margin: const EdgeInsets.only(left: 5), padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
decoration: BoxDecoration( borderRadius: BorderRadius.circular(4),
|
||||
color: isData(w.topic) ? Colors.blue : isComputing(w.topic) ? Colors.green :
|
||||
isCompute(w.topic) ? Colors.orange : isStorage(w.topic) ? redColor : Colors.grey ),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
color: getColor(w.topic)
|
||||
),
|
||||
child:Text(w.topic, style: TextStyle( color: Colors.white, fontSize: 11) )));
|
||||
bbadges.add(Container( margin: const EdgeInsets.only(left: 5),
|
||||
decoration: BoxDecoration( color: Colors.grey, borderRadius: BorderRadius.circular(4) ),
|
||||
@ -337,10 +244,16 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
|
||||
List<Widget> getCardItems(List<ShallowData> data) {
|
||||
List<Widget> items = [];
|
||||
for (var w in data) {
|
||||
List<ShallowData> neoData = [];
|
||||
for (var d in data) {
|
||||
try { neoData.firstWhere( (e) => e.getID() == d.getID());
|
||||
} catch (e) { neoData.add(d); }
|
||||
}
|
||||
for (var w in neoData) {
|
||||
List<Widget> badges = [];
|
||||
if (w is Peer && w.getID(
|
||||
) == CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current ?? ""]?.rule?.creator) {
|
||||
if (w is Peer && (
|
||||
w.getID() != CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current ?? ""]?.rule?.creator
|
||||
|| w.getID() != CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current ?? ""]?.creatorID)) {
|
||||
badges.add(Padding( padding: const EdgeInsets.only(left: 5), child: Icon(Icons.star, color: Colors.orange.shade300 )));
|
||||
} else if (widget.type == CollaborativeAreaType.workspace) {
|
||||
badges.add(Container( margin: const EdgeInsets.only(left: 5), padding: EdgeInsets.all(5), color: Colors.grey.shade200,
|
||||
@ -349,11 +262,13 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
items.add(ShallowItemRowWidget(
|
||||
color: Colors.grey.shade200,
|
||||
item: w, badges: badges,
|
||||
delete: w is Peer && PermsService.getPerm(Perms.PEER_UNSHARE) && w.getID() != CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current ?? ""]?.rule?.creator ? (String? change) async {
|
||||
delete: w is Peer ? (PermsService.getPerm(Perms.PEER_UNSHARE) && (
|
||||
w.getID() != CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current ?? ""]?.rule?.creator
|
||||
&& w.getID() != CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current ?? ""]?.creatorID) ? (String? change) async {
|
||||
await SharedService().removePeer(context, CollaborativeAreaLocal.current ?? "", change ?? "");
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
setState(() {});
|
||||
} : (w is Workflow && PermsService.getPerm(Perms.WORKSPACE_UNSHARE)) ? (String? change) async {
|
||||
} : null) : (w is Workflow && PermsService.getPerm(Perms.WORKSPACE_UNSHARE)) ? (String? change) async {
|
||||
await SharedService().removeWorkflow(context, CollaborativeAreaLocal.current ?? "", change ?? "");
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
setState(() {});
|
||||
@ -381,7 +296,7 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
Peer? creator;
|
||||
SharedService service = SharedService();
|
||||
try { creator = space.peers.firstWhere( (e) => (space.rule?.creator ?? "") == e.id);
|
||||
} catch (e) { }
|
||||
} catch (e) { /**/ }
|
||||
Map<String, List<AbstractItem>> datas = {};
|
||||
for (var w in space.workspaces) {
|
||||
datas[w.getName()] =<AbstractItem> [
|
||||
@ -406,9 +321,9 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 50),
|
||||
child: Text(space.description ?? "",
|
||||
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w400, color: Colors.grey))
|
||||
), // TODO
|
||||
Text("COLLABORATIVE AREA ACCESS RULES", textAlign: TextAlign.start,
|
||||
style: TextStyle(color: darkColor, fontSize: 20, fontWeight: FontWeight.bold), overflow: TextOverflow.clip),
|
||||
),
|
||||
Padding( padding: EdgeInsets.only(left: 30), child: Text("COLLABORATIVE AREA ACCESS RULES", textAlign: TextAlign.start,
|
||||
style: TextStyle(color: darkColor, fontSize: 20, fontWeight: FontWeight.bold), overflow: TextOverflow.clip)),
|
||||
Container(
|
||||
width: getMainWidth(context) - 50,
|
||||
margin: EdgeInsets.symmetric(vertical: 20),
|
||||
@ -427,39 +342,14 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
),
|
||||
|
||||
Row( children: [
|
||||
Text("COLLABORATIVE AREA PEERS", textAlign: TextAlign.start,
|
||||
style: TextStyle(color: darkColor, fontSize: 20, fontWeight: FontWeight.bold), overflow: TextOverflow.clip),
|
||||
Padding( padding: EdgeInsets.only(left: 30), child: Text("COLLABORATIVE AREA PEERS", textAlign: TextAlign.start,
|
||||
style: TextStyle(color: darkColor, fontSize: 20, fontWeight: FontWeight.bold), overflow: TextOverflow.clip)),
|
||||
PermsService.getPerm(Perms.PEER_SHARE) ? Container(
|
||||
margin: EdgeInsets.only(left: 20), padding: EdgeInsets.only(left: 15),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(left: BorderSide(color: Colors.grey))
|
||||
), child:ShallowDropdownInputWidget(
|
||||
tooltipLoad: "add peer",
|
||||
hint: "add peer",
|
||||
iconLoad: Icons.add,
|
||||
type: widget.type,
|
||||
filled: midColor,
|
||||
hintColor: Colors.grey,
|
||||
color: Colors.black,
|
||||
prefixIcon: Icon(Icons.person, color: Colors.grey),
|
||||
all: () async {
|
||||
List<Shallow> shals = [];
|
||||
await PeerService().all(context).then((value) {
|
||||
if (value.data != null) {
|
||||
shals = value.data!.values.map((e) => Shallow(id: e["id"], name: e["name"])).where( (e) => !space.peers.map( (e) => e.id ).contains(e.id)).toList();
|
||||
}
|
||||
setState(() {});
|
||||
});
|
||||
return shals;
|
||||
},
|
||||
width: getMainWidth(context) / 3,
|
||||
canLoad: (String? change) => true,
|
||||
load: (String val) async {
|
||||
await service.addPeer(context, CollaborativeAreaLocal.current ?? "", val);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
setState(() {});
|
||||
},
|
||||
) ) : Container()]),
|
||||
), child: getDropdown(CollaborativeAreaType.peer, CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current], this, context, true)
|
||||
) : Container()]),
|
||||
Container(
|
||||
width: getMainWidth(context) - 50,
|
||||
margin: EdgeInsets.symmetric(vertical: 20),
|
||||
@ -467,8 +357,8 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 50),
|
||||
child: Wrap( alignment: WrapAlignment.center, children: getCardItems(space.peers)),
|
||||
),
|
||||
space.rules.isNotEmpty ? Text("RULES", textAlign: TextAlign.start,
|
||||
style: TextStyle(color: darkColor, fontSize: 20, fontWeight: FontWeight.bold), overflow: TextOverflow.clip) : Container(),
|
||||
space.rules.isNotEmpty ? Padding( padding: EdgeInsets.only(left: 30), child: Text("RULES", textAlign: TextAlign.start,
|
||||
style: TextStyle(color: darkColor, fontSize: 20, fontWeight: FontWeight.bold), overflow: TextOverflow.clip)) : Container(),
|
||||
space.rules.isNotEmpty ? Container(
|
||||
width: getMainWidth(context) - 50,
|
||||
margin: EdgeInsets.symmetric(vertical: 20),
|
||||
@ -483,30 +373,13 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
}).toList() )
|
||||
) : Container(),
|
||||
Row( children: [
|
||||
Text("WORKSPACES / RESOURCES", textAlign: TextAlign.start,
|
||||
style: TextStyle(color: darkColor, fontSize: 20, fontWeight: FontWeight.bold), overflow: TextOverflow.clip),
|
||||
Padding( padding: EdgeInsets.only(left: 30), child: Text("WORKSPACES / RESOURCES", textAlign: TextAlign.start,
|
||||
style: TextStyle(color: darkColor, fontSize: 20, fontWeight: FontWeight.bold), overflow: TextOverflow.clip)),
|
||||
PermsService.getPerm(Perms.WORKSPACE_SHARE) ? Container(
|
||||
margin: EdgeInsets.only(left: 20), padding: EdgeInsets.only(left: 15),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(left: BorderSide(color: Colors.grey))
|
||||
), child: ShallowDropdownInputWidget(
|
||||
tooltipLoad: "add workspace",
|
||||
hint: "add workspace",
|
||||
iconLoad: Icons.add,
|
||||
type: widget.type,
|
||||
filled: midColor,
|
||||
hintColor: Colors.grey,
|
||||
color: Colors.black,
|
||||
prefixIcon: Icon(Icons.shopping_cart, color: Colors.grey),
|
||||
all: () async => WorkspaceLocal.getWorkspacesShallow().where( (e) => !space.workspaces.map( (e) => e.id ).contains(e.id)).toList(),
|
||||
width: getMainWidth(context) / 3,
|
||||
canLoad: (String? change) => true,
|
||||
load: (String val) async {
|
||||
await service.addWorkspace(context, CollaborativeAreaLocal.current ?? "", val);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
setState(() {});
|
||||
},
|
||||
)) : Container() ]),
|
||||
), child: getDropdown(CollaborativeAreaType.workspace, CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current], this, context, true)) : Container() ]),
|
||||
Container(
|
||||
width: getMainWidth(context) - 50,
|
||||
margin: EdgeInsets.symmetric(vertical: 20),
|
||||
@ -515,38 +388,13 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
child: Wrap( alignment: WrapAlignment.center, children: getCardWorkspaceItems(datas))
|
||||
),
|
||||
Row( children: [
|
||||
Text("WORKFLOWS", textAlign: TextAlign.start,
|
||||
style: TextStyle(color: darkColor, fontSize: 20, fontWeight: FontWeight.bold), overflow: TextOverflow.clip),
|
||||
Padding( padding: EdgeInsets.only(left: 30), child: Text("WORKFLOWS", textAlign: TextAlign.start,
|
||||
style: TextStyle(color: darkColor, fontSize: 20, fontWeight: FontWeight.bold), overflow: TextOverflow.clip)),
|
||||
PermsService.getPerm(Perms.WORKFLOW_SHARE) ? Container(
|
||||
margin: EdgeInsets.only(left: 20), padding: EdgeInsets.only(left: 15),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(left: BorderSide(color: Colors.grey))
|
||||
), child:ShallowDropdownInputWidget(
|
||||
tooltipLoad: "add workflow",
|
||||
hint: "add workflow",
|
||||
iconLoad: Icons.add,
|
||||
type: widget.type,
|
||||
filled: midColor,
|
||||
hintColor: Colors.grey,
|
||||
color: Colors.black,
|
||||
prefixIcon: Icon(Icons.rebase_edit, color: Colors.grey),
|
||||
all: () async {
|
||||
List<Shallow> shals = [];
|
||||
await WorflowService().all(context).then((value) {
|
||||
if (value.data != null) {
|
||||
shals = value.data!.values.map((e) => Shallow(id: e["id"], name: e["name"])).where( (e) => !space.workflows.map( (e) => e.id ).contains(e.id)).toList();
|
||||
}
|
||||
});
|
||||
return shals;
|
||||
},
|
||||
width: getMainWidth(context) / 3,
|
||||
canLoad: (String? change) => true,
|
||||
load: (String val) async {
|
||||
await service.addWorkflow(context, CollaborativeAreaLocal.current ?? "", val);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
setState(() {});
|
||||
},
|
||||
)) : Container()]),
|
||||
), child: getDropdown(CollaborativeAreaType.workflow, CollaborativeAreaLocal.workspaces[CollaborativeAreaLocal.current], this, context, true)) : Container()]),
|
||||
Container(
|
||||
width: getMainWidth(context) - 50,
|
||||
margin: EdgeInsets.symmetric(vertical: 20),
|
||||
@ -557,6 +405,7 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
],)
|
||||
);
|
||||
}
|
||||
|
||||
if (CollaborativeAreaLocal.current == null) {
|
||||
return Container(
|
||||
color: midColor,
|
||||
@ -576,11 +425,14 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
data = space?.peers ?? [];
|
||||
}
|
||||
if (widget.type == CollaborativeAreaType.workspace) {
|
||||
for (var w in data) {
|
||||
if (widget.type == CollaborativeAreaType.workspace) {
|
||||
if (WorkspaceLocal.workspaces[w.getID()] == null) { continue; }
|
||||
items.add(WorkspaceSharedItemPageWidget(name: "Workspace <${WorkspaceLocal.workspaces[w.getID()]!.name}>", id: w.getID()));
|
||||
}
|
||||
List<ShallowData> neoData = [];
|
||||
for (var d in data) {
|
||||
try { neoData.firstWhere( (e) => e.getID() == d.getID());
|
||||
} catch (e) { neoData.add(d); }
|
||||
}
|
||||
for (var w in neoData) {
|
||||
if (WorkspaceLocal.workspaces[w.getID()] == null) { continue; }
|
||||
items.add(WorkspaceSharedItemPageWidget(name: "Workspace <${WorkspaceLocal.workspaces[w.getID()]!.name}>", id: w.getID()));
|
||||
}
|
||||
} else {
|
||||
items = getCardItems(data);
|
||||
@ -603,6 +455,7 @@ class WorkspaceSharedPageWidgetState extends State<WorkspaceSharedPageWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class WorkspaceSharedItemPageWidget extends StatefulWidget {
|
||||
bool open = true;
|
||||
String id = "";
|
||||
@ -638,4 +491,130 @@ class WorkspaceSharedItemPageWidgetState extends State<WorkspaceSharedItemPageWi
|
||||
items: WorkspaceLocal.byWorkspace(widget.id)) : Container()
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Widget getDropdown(CollaborativeAreaType type, CollaborativeArea? current, State<dynamic> state, BuildContext context, bool mainPage ) {
|
||||
if (type == CollaborativeAreaType.workspace) {
|
||||
return Row( mainAxisAlignment: MainAxisAlignment.end,
|
||||
children : [ Container( padding: EdgeInsets.only(left: mainPage ? 0 : 20), decoration: BoxDecoration(
|
||||
border: mainPage ? null : Border(left: BorderSide(color: Colors.white))
|
||||
), child: ShallowDropdownInputWidget(
|
||||
tooltipLoad: "share",
|
||||
tooltipRemove: "unshare",
|
||||
iconLoad: Icons.share,
|
||||
type: type,
|
||||
filled: mainPage ? Colors.white : lightColor,
|
||||
hintColor: mainPage ? Colors.grey : midColor,
|
||||
color: mainPage ? Colors.black : Colors.white,
|
||||
prefixIcon: Icon(Icons.shopping_cart, color: Colors.white),
|
||||
current: WorkspaceLocal.current,
|
||||
all: () async => WorkspaceLocal.getWorkspacesShallow(),
|
||||
width: getMainWidth(context) / 3,
|
||||
canLoad: (String? change) => current != null && !current.workspaces.map( (e) => e.id ).contains(change),
|
||||
canRemove: (String? change) => current != null && current.workspaces.map( (e) => e.id ).contains(change),
|
||||
load: PermsService.getPerm(Perms.WORKSPACE_SHARE) ? (String val) async {
|
||||
await SharedService().addWorkspace(context, CollaborativeAreaLocal.current ?? "", val);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
state.setState(() {});
|
||||
if (mainPage) {
|
||||
SharedFactory.key.currentState?.setState(() {});
|
||||
}
|
||||
} : null,
|
||||
remove: PermsService.getPerm(Perms.WORKSPACE_UNSHARE) ? (String val) async {
|
||||
await SharedService().removeWorkspace(context, CollaborativeAreaLocal.current ?? "", val);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
state.setState(() {});
|
||||
if (mainPage) {
|
||||
SharedFactory.key.currentState?.setState(() {});
|
||||
}
|
||||
} : null))
|
||||
]);
|
||||
}
|
||||
if (type == CollaborativeAreaType.workflow) {
|
||||
return Row( mainAxisAlignment: MainAxisAlignment.end,
|
||||
children : [ Container( padding: EdgeInsets.only(left: mainPage ? 0 : 20), decoration: BoxDecoration(
|
||||
border: mainPage ? null : Border(left: BorderSide(color: Colors.white))
|
||||
), child: ShallowDropdownInputWidget(
|
||||
tooltipLoad: "share",
|
||||
tooltipRemove: "unshare",
|
||||
iconLoad: Icons.share,
|
||||
filled: mainPage ? Colors.white : lightColor,
|
||||
hintColor: mainPage ? Colors.grey : midColor,
|
||||
color: mainPage ? Colors.black : Colors.white,
|
||||
type: type, all: () async {
|
||||
List<Shallow> shals = [];
|
||||
await WorflowService().all(context).then((value) {
|
||||
if (value.data != null) {
|
||||
shals = value.data!.values.map((e) => Shallow(id: e["id"], name: e["name"])).toList();
|
||||
}
|
||||
});
|
||||
return shals;
|
||||
},
|
||||
width: getMainWidth(context) / 3,
|
||||
canLoad: (String? change) => current != null && !current.workflows.map( (e) => e.id ).contains(change),
|
||||
canRemove: (String? change) => current != null && current.workflows.map( (e) => e.id ).contains(change),
|
||||
load: PermsService.getPerm(Perms.WORKFLOW_SHARE) ? (String change) async {
|
||||
await SharedService().addWorkflow(context, CollaborativeAreaLocal.current ?? "", change);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
state.setState(() {});
|
||||
if (mainPage) {
|
||||
SharedFactory.key.currentState?.setState(() {});
|
||||
}
|
||||
} : null,
|
||||
remove: PermsService.getPerm(Perms.WORKFLOW_UNSHARE) ? (String change) async {
|
||||
await SharedService().removeWorkflow(context, CollaborativeAreaLocal.current ?? "", change);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
state.setState(() {});
|
||||
if (mainPage) {
|
||||
SharedFactory.key.currentState?.setState(() {});
|
||||
}
|
||||
} : null))
|
||||
]);
|
||||
}
|
||||
if (type == CollaborativeAreaType.peer) {
|
||||
return Row( mainAxisAlignment: MainAxisAlignment.end,
|
||||
children : [
|
||||
Container( padding: EdgeInsets.only(left: mainPage ? 0 : 20), decoration: BoxDecoration(
|
||||
border: mainPage ? null : Border(left: BorderSide(color : Colors.white))
|
||||
), child: ShallowDropdownInputWidget(
|
||||
tooltipLoad: "add",
|
||||
iconLoad: Icons.add,
|
||||
filled: mainPage ? Colors.white : lightColor,
|
||||
hintColor: mainPage ? Colors.grey : midColor,
|
||||
color: mainPage ? Colors.black : Colors.white,
|
||||
type: type, all: () async {
|
||||
List<Shallow> shals = [];
|
||||
await PeerService().all(context).then((value) {
|
||||
if (value.data != null) {
|
||||
shals = value.data!.values.where( (e) {
|
||||
print("e: $e ${e["id"]} ${current?.creatorID}");
|
||||
return e["id"] != current?.creatorID;
|
||||
}
|
||||
).map((e) => Shallow(id: e["id"], name: e["name"])).toList();
|
||||
}
|
||||
});
|
||||
return shals;
|
||||
},
|
||||
width: getMainWidth(context) / 3,
|
||||
canLoad: (String? change) => current != null && !current.peers.map( (e) => e.id ).contains(change),
|
||||
canRemove: (String? change) => current != null && current.peers.map( (e) => e.id ).contains(change),
|
||||
load: PermsService.getPerm(Perms.PEER_SHARE) ? (String change) async {
|
||||
await SharedService().addPeer(context, CollaborativeAreaLocal.current ?? "", change);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
state.setState(() {});
|
||||
if (mainPage) {
|
||||
SharedFactory.key.currentState?.setState(() {});
|
||||
}
|
||||
} : null,
|
||||
remove: PermsService.getPerm(Perms.PEER_UNSHARE) ? (String change) async {
|
||||
await SharedService().removePeer(context, CollaborativeAreaLocal.current ?? "", change);
|
||||
await CollaborativeAreaLocal.init(context, false);
|
||||
state.setState(() {});
|
||||
if (mainPage) {
|
||||
SharedFactory.key.currentState?.setState(() {});
|
||||
}
|
||||
} : null))
|
||||
]);
|
||||
}
|
||||
return Container();
|
||||
}
|
@ -6,35 +6,41 @@ import 'package:oc_front/core/models/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/main.dart';
|
||||
import 'package:oc_front/models/resources/compute.dart';
|
||||
import 'package:oc_front/models/resources/data.dart';
|
||||
import 'package:oc_front/models/resources/processing.dart';
|
||||
import 'package:oc_front/models/resources/resources.dart';
|
||||
import 'package:oc_front/models/resources/storage.dart';
|
||||
import 'package:oc_front/models/resources/workflow.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/resource_forms.dart';
|
||||
import 'package:oc_front/widgets/forms/scheduler_forms.dart';
|
||||
import 'package:oc_front/widgets/forms/storage_forms.dart';
|
||||
import 'package:oc_front/widgets/forms/storage_processing_link_forms.dart';
|
||||
import 'package:oc_front/widgets/items/item_row.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_dropdown_input.dart';
|
||||
|
||||
Dashboard dash = Dashboard(name: "");
|
||||
class WorkflowFactory implements AbstractFactory {
|
||||
@override GlobalKey getKey() { return key; }
|
||||
@override String? getSearch() { return ""; }
|
||||
@override void back(BuildContext context) { }
|
||||
static GlobalKey<WorkflowPageWidgetState> key = GlobalKey<WorkflowPageWidgetState>();
|
||||
@override bool searchFill() { return false; }
|
||||
@override Widget factory(GoRouterState state, List<String> args) {
|
||||
String? id;
|
||||
try { id = state.pathParameters[args.first];
|
||||
} catch (e) { }
|
||||
} catch (e) { /**/ }
|
||||
return WorkflowPageWidget(id: id);
|
||||
}
|
||||
@override void search(BuildContext context, bool special) { }
|
||||
}
|
||||
bool getAll = true;
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class WorkflowPageWidget extends StatefulWidget {
|
||||
String? id;
|
||||
WorkflowPageWidget ({ this.id }) : super(key: WorkflowFactory.key);
|
||||
@ -55,19 +61,20 @@ final WorflowService _service = WorflowService();
|
||||
var e = item as AbstractItem;
|
||||
return Container(color: Colors.white, child: ItemRowWidget(low: true, contextWidth: 290, item: e));
|
||||
}
|
||||
Widget getArrowForms(ArrowPainter? arrow) {
|
||||
if (arrow == null) { return Container(); }
|
||||
var from = dash.getElement(arrow.fromID);
|
||||
var to = dash.getElement(arrow.toID);
|
||||
if ((from?.element?.getType() == "storage" && to?.element?.getType() == "processing")
|
||||
|| (from?.element?.getType() == "processing" && to?.element?.getType() == "storage")) {
|
||||
return StorageProcessingLinkFormsWidget( dash: dash, item: arrow);
|
||||
}
|
||||
return Container();
|
||||
}
|
||||
List<Widget> getForms(FlowData? obj, String id) {
|
||||
var objAbs = obj as AbstractItem?;
|
||||
if (objAbs == null) { return []; }
|
||||
List<Widget> res = [];
|
||||
if ( objAbs.topic == "processing") {
|
||||
res = [ProcessingFormsWidget(item: objAbs as ProcessingItem, dash: dash, elementID: id)];
|
||||
} else if ( objAbs.topic == "data" ) {
|
||||
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)];
|
||||
}
|
||||
List<Widget> res = [ ResourceFormsWidget(item: objAbs, dash: dash, elementID: id) ];
|
||||
return [ Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
children: [
|
||||
@ -84,18 +91,20 @@ 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: 16);
|
||||
} else if (compute.technology == 1) {
|
||||
return Icon(FontAwesomeIcons.lifeRing, size: 16);
|
||||
} else if (compute.technology == 2) {
|
||||
return Icon(FontAwesomeIcons.cubes, size: 16);
|
||||
} else if (compute.technology == 3) {
|
||||
return Icon(FontAwesomeIcons.hardDrive, size: 16);
|
||||
} else if (compute.technology == 4) {
|
||||
return Icon(FontAwesomeIcons.v, size: 16);
|
||||
if (objAbs.topic == "compute") {
|
||||
var instance = objAbs as ComputeItem;
|
||||
if (instance.infrastructureEnum != null) {
|
||||
if (instance.infrastructureEnum == 0) {
|
||||
return Icon(FontAwesomeIcons.docker, size: 16);
|
||||
} else if (instance.infrastructureEnum == 1) {
|
||||
return Icon(FontAwesomeIcons.lifeRing, size: 16);
|
||||
} else if (instance.infrastructureEnum == 2) {
|
||||
return Icon(FontAwesomeIcons.cubes, size: 16);
|
||||
} else if (instance.infrastructureEnum == 3) {
|
||||
return Icon(FontAwesomeIcons.hardDrive, size: 16);
|
||||
} else if (instance.infrastructureEnum == 4) {
|
||||
return Icon(FontAwesomeIcons.v, size: 16);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -136,10 +145,11 @@ final WorflowService _service = WorflowService();
|
||||
}
|
||||
await _service.get(context, dash.id ?? "").then((value) async {
|
||||
if (value.data != null) {
|
||||
// ignore: use_build_context_synchronously
|
||||
await WorkspaceLocal.init(context, false);
|
||||
WorkspaceLocal.changeWorkspaceByName("${value.data?.name ?? ""}_workspace");
|
||||
dash.clear();
|
||||
dash.deserialize(value.data!.toDashboard());
|
||||
dash.deserialize(value.data!.toDashboard(), false);
|
||||
Future.delayed(const Duration(seconds: 1), () {
|
||||
dash.name = name;
|
||||
dash.shouldSave = true;
|
||||
@ -149,26 +159,20 @@ final WorflowService _service = WorflowService();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> saveDash(String? id) async {
|
||||
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 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) );
|
||||
var computing = WorkspaceLocal.byTopic("processing", true).where(
|
||||
(element) => dash.elements.map( (e) => e.element?.getID()).contains(element.id) );
|
||||
var workflows = WorkspaceLocal.byTopic("workflows", true).where(
|
||||
(element) => dash.elements.map( (e) => e.element?.getID()).contains(element.id) );
|
||||
Future<void> saveDash(String? id, BuildContext? context) async {
|
||||
if (id == null || !dash.isOpened || !dash.shouldSave || !PermsService.getPerm(Perms.WORKFLOW_EDIT)) { return; }
|
||||
var datas = dash.elements.where( (e) => e.element?.serialize()["type"] == "data");
|
||||
var compute = dash.elements.where( (e) => e.element?.serialize()["type"] == "compute");
|
||||
var storage = dash.elements.where( (e) => e.element?.serialize()["type"] == "storage");
|
||||
var processing = dash.elements.where( (e) => e.element?.serialize()["type"] == "processing");
|
||||
var workflows = dash.elements.where( (e) => e.element?.serialize()["type"] == "workflow");
|
||||
var updateW = Workflow(
|
||||
name: dash.name,
|
||||
graph: Graph(),
|
||||
data: datas.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(),
|
||||
processing: processing.map((e) => e.id).toSet().toList(),
|
||||
workflows: workflows.map((e) => e.id).toSet().toList(),
|
||||
);
|
||||
updateW.fromDashboard(dash.serialize());
|
||||
@ -177,8 +181,8 @@ final WorflowService _service = WorflowService();
|
||||
item.position?.x = (item.position?.x ?? 0) + (item.width! / 2) + 7.5;
|
||||
item.position?.y = (item.position?.y ?? 0) + (item.height! / 2) + 7.5;
|
||||
for (var i in (updateW.graph?.links ?? [] as List<GraphLink>).where((element) => id == element.source?.id)) {
|
||||
i.source?.x = (i.source?.x ?? 0) + (item.width! / 2) + 7;
|
||||
i.source?.y = (i.source?.y ?? 0) + (item.width! / 2) + 7;
|
||||
i.source?.x = (i.source?.x ?? 0) + (item.width! / 2) + 7.5;
|
||||
i.source?.y = (i.source?.y ?? 0) + (item.width! / 2) + 7.5;
|
||||
}
|
||||
for (var i in (updateW.graph?.links ?? [] as List<GraphLink>).where((element) => id == element.destination?.id)) {
|
||||
i.destination?.x = (i.destination?.x ?? 0) + (item.width! / 2) + 7.5;
|
||||
@ -187,31 +191,24 @@ final WorflowService _service = WorflowService();
|
||||
}
|
||||
updateW.graph?.zoom = dash.getZoomFactor();
|
||||
dash.addToHistory();
|
||||
await _service.put(context, id, updateW.serialize(), {}).then( (e) async {
|
||||
if (dash.addChange) {
|
||||
dash.addChange = false;
|
||||
await WorkspaceLocal.init(context, false);
|
||||
WorkspaceLocal.changeWorkspaceByName("${dash.name}_workspace");
|
||||
dash.selectedLeftMenuKey.currentState?.setState(() { });
|
||||
}
|
||||
});
|
||||
_service.put(null, id, updateW.serialize(), {}).then( (e) async {
|
||||
dash.applyInfos(updateW.graph?.getEnvToUpdate() ?? {}, updateW.toDashboard());
|
||||
if (dash.addChange) {
|
||||
dash.addChange = false;
|
||||
// ignore: use_build_context_synchronously
|
||||
await WorkspaceLocal.init(context, false);
|
||||
WorkspaceLocal.changeWorkspaceByName("${dash.name}_workspace");
|
||||
dash.selectedLeftMenuKey.currentState?.setState(() { });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
FlowData? transformToData(Map<String, dynamic> data) {
|
||||
var d = WorkspaceLocal.getItem(data["id"] ?? "", true);
|
||||
if (d == null) { return null; }
|
||||
d.model = ResourceModel().deserialize(data["resource_model"]);
|
||||
if (d.topic == "data") { return d as DataItem; }
|
||||
if (d.topic == "compute") { return d as ComputeItem; }
|
||||
if (d.topic == "storage") { return d as StorageItem; }
|
||||
if (d.topic == "processing") {
|
||||
d = d as ProcessingItem;
|
||||
if (data.containsKey("container")) {
|
||||
d.container = Containered().deserialize(data["container"]);
|
||||
}
|
||||
return d;
|
||||
}
|
||||
if (d.topic == "workflows") { return d as WorkflowItem; }
|
||||
if (data["type"] == "data") { return DataItem().deserialize(data); }
|
||||
if (data["type"] == "compute") { return ComputeItem().deserialize(data); }
|
||||
if (data["type"] == "storage") { return StorageItem().deserialize(data); }
|
||||
if (data["type"] == "processing") { return ProcessingItem().deserialize(data); }
|
||||
if (data["type"] == "workflows") { return WorkflowItem().deserialize(data); }
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -249,12 +246,14 @@ final WorflowService _service = WorflowService();
|
||||
WorkspaceLocal.changeWorkspaceByName(p0.split("~")[1]);
|
||||
await dash.load!(p0);
|
||||
}
|
||||
dash.inDialog = false;
|
||||
dash.notifyListeners();
|
||||
},
|
||||
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.inDialog = false;
|
||||
dash.notifyListeners();
|
||||
await WorkspaceLocal.init(context, true);
|
||||
dash.isOpened = true;
|
||||
@ -288,26 +287,33 @@ final WorflowService _service = WorflowService();
|
||||
dash.midDashColor = midColor;
|
||||
dash.transformToData = transformToData;
|
||||
dash.infoItemWidget = getForms;
|
||||
dash.infoLinkWidget = getArrowForms;
|
||||
dash.infoWidget = getDashInfoForms;
|
||||
dash.widthOffset = 50;
|
||||
dash.arrowStyleRules = [
|
||||
(dash) {
|
||||
for (var arrow in dash.arrows) {
|
||||
var from = dash.elements.firstWhere((element) => arrow.fromID.contains(element.id)).element;
|
||||
var to = dash.elements.firstWhere((element) => arrow.toID.contains(element.id)).element;
|
||||
if ((from is ProcessingItem && to is ComputeItem) || (to is ProcessingItem && from is ComputeItem)) {
|
||||
arrow.params.color = Colors.orange;
|
||||
arrow.params.dashSpace = 2;
|
||||
arrow.params.dashWidth = 2;
|
||||
} else if ((from is ProcessingItem && to is StorageItem) || (to is ProcessingItem && from is StorageItem)) {
|
||||
arrow.params.color = redColor;
|
||||
arrow.params.dashSpace = 2;
|
||||
arrow.params.dashWidth = 2;
|
||||
} else if ((from is ProcessingItem && to is DataItem) || (to is ProcessingItem && from is DataItem)) {
|
||||
arrow.params.color = Colors.blue;
|
||||
arrow.params.dashSpace = 2;
|
||||
arrow.params.dashWidth = 2;
|
||||
} else {
|
||||
try {
|
||||
var from = dash.elements.firstWhere((element) => arrow.fromID.split("_")[0] == element.id).element;
|
||||
var to = dash.elements.firstWhere((element) => arrow.toID.split("_")[0] == element.id).element;
|
||||
if ((from is ProcessingItem && to is ComputeItem) || (to is ProcessingItem && from is ComputeItem)) {
|
||||
arrow.params.color = Colors.orange;
|
||||
arrow.params.dashSpace = 2;
|
||||
arrow.params.dashWidth = 2;
|
||||
} else if ((from is ProcessingItem && to is StorageItem) || (to is ProcessingItem && from is StorageItem)) {
|
||||
arrow.params.color = redColor;
|
||||
arrow.params.dashSpace = 2;
|
||||
arrow.params.dashWidth = 2;
|
||||
} else if ((from is ProcessingItem && to is DataItem) || (to is ProcessingItem && from is DataItem)) {
|
||||
arrow.params.color = Colors.blue;
|
||||
arrow.params.dashSpace = 2;
|
||||
arrow.params.dashWidth = 2;
|
||||
} else {
|
||||
arrow.params.color = Colors.black;
|
||||
arrow.params.dashSpace = 0;
|
||||
arrow.params.dashWidth = 0;
|
||||
}
|
||||
} catch (e) {
|
||||
arrow.params.color = Colors.black;
|
||||
arrow.params.dashSpace = 0;
|
||||
arrow.params.dashWidth = 0;
|
||||
@ -319,32 +325,7 @@ final WorflowService _service = WorflowService();
|
||||
dash.saveRules = [
|
||||
(dash) {
|
||||
dash.error = null;
|
||||
if (dash.scheduleActive) {
|
||||
if (dash.elements.isEmpty || dash.elements.where((element) => element.element is ProcessingItem).isEmpty) {
|
||||
dash.error = "You need at least one processing element";
|
||||
dash.scheduleActive = false;
|
||||
}
|
||||
var processings = dash.elements.where((element) => element.element is ProcessingItem).map((e) => e.element as ProcessingItem);
|
||||
var computes = dash.elements.where((element) => element.element is ComputeItem).map((e) => e.element as ComputeItem);
|
||||
if (processings.length != computes.length) {
|
||||
dash.error = "You need the same number of processing and compute elements";
|
||||
dash.scheduleActive = false;
|
||||
}
|
||||
for (var p in processings) {
|
||||
var links = dash.arrows.where((element) => element.fromID.contains(p.getID()) || element.toID.contains(p.getID()));
|
||||
try {
|
||||
computes.firstWhere( (e) => links.first.toID.contains(e.getID()) || links.first.fromID.contains(e.getID()) );
|
||||
} catch (e) {
|
||||
dash.error = "You need to link each processing element to a compute element";
|
||||
dash.scheduleActive = false;
|
||||
}
|
||||
}
|
||||
if (dash.error != null) {
|
||||
print(dash.error);
|
||||
setState(() {});
|
||||
}
|
||||
return dash.scheduleActive;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
];
|
||||
|
@ -1,14 +1,14 @@
|
||||
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:flutter/material.dart';
|
||||
import 'package:oc_front/widgets/items/item_row.dart';
|
||||
import 'package:oc_front/models/resources/resources.dart';
|
||||
import 'package:oc_front/core/models/workspace_local.dart';
|
||||
|
||||
class CatalogWidget extends StatefulWidget {
|
||||
double? itemWidth;
|
||||
bool readOnly = false;
|
||||
final List<AbstractItem>? items;
|
||||
CatalogWidget ({ Key? key, this.items, this.itemWidth, this.readOnly = false }): super(key: key);
|
||||
CatalogWidget ({ super.key, this.items, this.itemWidth, this.readOnly = false });
|
||||
@override CatalogWidgetState createState() => CatalogWidgetState();
|
||||
}
|
||||
class CatalogWidgetState extends State<CatalogWidget> {
|
||||
|
@ -4,6 +4,7 @@ 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';
|
||||
import 'package:oc_front/pages/workflow.dart';
|
||||
|
||||
class LoginWidget extends StatefulWidget {
|
||||
LoginWidget ({ Key? key }): super(key: key);
|
||||
@ -30,26 +31,32 @@ class LoginWidgetState extends State<LoginWidget> {
|
||||
loading = false;
|
||||
error = "Invalid username or password";
|
||||
});
|
||||
}).then( (e) {
|
||||
if (error == null) {
|
||||
// ignore: use_build_context_synchronously
|
||||
setState(() {
|
||||
loading = false;
|
||||
});
|
||||
loginIsSet = false;
|
||||
dash.inDialog = false;
|
||||
context.pop();
|
||||
mainKey?.currentState?.setState(() {});
|
||||
}
|
||||
});
|
||||
if (error == null) {
|
||||
// ignore: use_build_context_synchronously
|
||||
setState(() {
|
||||
loading = false;
|
||||
});
|
||||
context.pop();
|
||||
}
|
||||
}
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(50), child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
const Center(child: Icon(Icons.person_search, size: 150, color: Colors.grey,)),
|
||||
child: Container( padding: const EdgeInsets.all(50), child: Column(children: [
|
||||
getMainHeight(context) < 600 ? Container() : SizedBox( width: getMainWidth(context) / 4, height: getMainHeight(context) / 4,
|
||||
child: FittedBox(
|
||||
child: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,
|
||||
color: lightColor ), overflow: TextOverflow.ellipsis, ))),
|
||||
Container( margin: const EdgeInsets.only(bottom: 10),
|
||||
child: Center(child: Row( mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: getMainWidth(context) / 3,
|
||||
width: MediaQuery.of(context).size.width / 3,
|
||||
alignment : Alignment.center,
|
||||
child: TextField(
|
||||
controller: usernameCtrl,
|
||||
@ -69,7 +76,7 @@ class LoginWidgetState extends State<LoginWidget> {
|
||||
Center(child: Row( mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: getMainWidth(context) / 3,
|
||||
width: MediaQuery.of(context).size.width / 3,
|
||||
alignment : Alignment.center,
|
||||
child: TextField(
|
||||
controller: passwordCtrl,
|
||||
@ -105,20 +112,22 @@ class LoginWidgetState extends State<LoginWidget> {
|
||||
loading = false;
|
||||
error = "Invalid username or password";
|
||||
});
|
||||
}).then( (e) {
|
||||
if (error == null) {
|
||||
// ignore: use_build_context_synchronously
|
||||
setState(() {
|
||||
loading = false;
|
||||
});
|
||||
loginIsSet = false;
|
||||
dash.inDialog = false;
|
||||
context.pop();
|
||||
mainKey?.currentState?.setState(() {});
|
||||
}
|
||||
});
|
||||
|
||||
if (error == null) {
|
||||
// ignore: use_build_context_synchronously
|
||||
setState(() {
|
||||
loading = true;
|
||||
});
|
||||
context.pop();
|
||||
//mainKey?.currentState!.setState(() {});
|
||||
}
|
||||
},
|
||||
mouseCursor: SystemMouseCursors.click,
|
||||
child: Container(
|
||||
width: getMainWidth(context) / 3,
|
||||
width: MediaQuery.of(context).size.width / 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(
|
||||
|
@ -3,9 +3,11 @@ 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';
|
||||
import 'package:oc_front/pages/workflow.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_dropdown_input.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_text_input.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class ShallowCreationDialogWidget extends StatefulWidget {
|
||||
GlobalKey<ShallowTextInputWidgetState>? formKey;
|
||||
BuildContext context;
|
||||
@ -43,6 +45,7 @@ class ShallowCreationDialogState extends State<ShallowCreationDialogWidget> {
|
||||
Tooltip( message: "back", child: InkWell(
|
||||
mouseCursor: SystemMouseCursors.click,
|
||||
onTap: () {
|
||||
dash.inDialog = false;
|
||||
AppRouter.catalog.go(context, {});
|
||||
},
|
||||
child: const Icon(Icons.arrow_back, color: Colors.black))),
|
||||
@ -50,7 +53,10 @@ class ShallowCreationDialogState extends State<ShallowCreationDialogWidget> {
|
||||
widget.canClose != null && !widget.canClose!() ? Container() : Row ( mainAxisAlignment: MainAxisAlignment.end, children: [
|
||||
Tooltip( message: "close", child: InkWell(
|
||||
mouseCursor: SystemMouseCursors.click,
|
||||
onTap: () { Navigator.pop(context); },
|
||||
onTap: () {
|
||||
dash.inDialog = false;
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Icon(Icons.close, color: Colors.black))),
|
||||
]),
|
||||
],),
|
||||
@ -62,6 +68,7 @@ class ShallowCreationDialogState extends State<ShallowCreationDialogWidget> {
|
||||
width: getMainWidth(context) <= 540 ? getMainWidth(context) - 140 : 400,
|
||||
load: (e) async {
|
||||
await widget.load!(e);
|
||||
dash.inDialog = false;
|
||||
Navigator.pop(widget.context);
|
||||
},
|
||||
iconLoad: Icons.open_in_browser_outlined,
|
||||
@ -83,6 +90,7 @@ class ShallowCreationDialogState extends State<ShallowCreationDialogWidget> {
|
||||
width: getMainWidth(context) <= 540 ? getMainWidth(context) - 140 : 400,
|
||||
load: (e) async {
|
||||
await widget.create!(e);
|
||||
dash.inDialog = false;
|
||||
Navigator.pop(widget.context);
|
||||
},
|
||||
forms: widget.form,
|
||||
|
@ -1,22 +0,0 @@
|
||||
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,),
|
||||
]);
|
||||
}
|
||||
}
|
105
lib/widgets/forms/container_forms.dart
Normal file
105
lib/widgets/forms/container_forms.dart
Normal file
@ -0,0 +1,105 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
|
||||
import 'package:oc_front/models/resources/processing.dart';
|
||||
import 'package:oc_front/models/resources/resources.dart';
|
||||
import 'package:oc_front/widgets/forms/sub_expose_forms.dart';
|
||||
import 'package:oc_front/widgets/inputs/sub_text_input.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class ContainerFormsWidget extends StatefulWidget {
|
||||
int instanceID = 0;
|
||||
Dashboard dash;
|
||||
AbstractItem item;
|
||||
String elementID;
|
||||
ContainerFormsWidget({ super.key, required this.item, required this.dash, required this.elementID });
|
||||
@override ContainerFormsWidgetState createState() => ContainerFormsWidgetState();
|
||||
}
|
||||
|
||||
class ContainerFormsWidgetState extends State<ContainerFormsWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
List<Widget> widgets = [];
|
||||
var instance = widget.item.getSelectedInstance();
|
||||
if (instance != null && instance is ProcessingInstance && instance.access?.container != null) {
|
||||
var container = instance.access!.container!;
|
||||
widgets.add(Container(
|
||||
padding: const EdgeInsets.only(bottom: 10),
|
||||
width: 180,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text("<CONTAINER>", style: const TextStyle(fontSize: 13, fontWeight: FontWeight.bold), textAlign: TextAlign.center),
|
||||
SubTextInputWidget(subkey: "image", width: 180, empty: false, change: (value) { },
|
||||
initialValue: container.image, readOnly: true),
|
||||
SubTextInputWidget(subkey: "command", width: 180, empty: false, change: (value) {
|
||||
container.command = value;
|
||||
for (var el in widget.dash.elements) {
|
||||
if (el.id == widget.elementID) {
|
||||
el.element = widget.item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
widget.dash.saveDash(widget.dash.id, context);
|
||||
}, initialValue: container.command, readOnly: false,),
|
||||
SubTextInputWidget(subkey: "args", width: 180, empty: false, change: (value) {
|
||||
container.args = value;
|
||||
for (var el in widget.dash.elements) {
|
||||
if (el.id == widget.elementID) {
|
||||
el.element = widget.item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
widget.dash.saveDash(widget.dash.id, context);
|
||||
},
|
||||
initialValue: container.args, readOnly: false,)
|
||||
],)
|
||||
));
|
||||
widgets.add(Container(
|
||||
width: 200, decoration: BoxDecoration( border: Border(bottom: BorderSide(color: Colors.grey))),
|
||||
));
|
||||
widgets.add(Container(
|
||||
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: [
|
||||
InkWell( onTap: () {
|
||||
container.exposes.add(Expose());
|
||||
var el = widget.dash.getElement(widget.elementID);
|
||||
el!.element = widget.item as dynamic;
|
||||
setState(() {});
|
||||
}, child:
|
||||
Container( margin: const EdgeInsets.only(top: 5),
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), border: Border.all(color: Colors.grey, width: 1)),
|
||||
width: 125, height: 30,
|
||||
child: const Row( mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [ Padding( padding: EdgeInsets.only(right: 5), child: Icon(Icons.add)), Text("add expose")]),
|
||||
)
|
||||
),
|
||||
InkWell( onTap: () {
|
||||
if (container.exposes.isEmpty) { return; }
|
||||
container.exposes = container.exposes.sublist(0, container.exposes.length - 1);
|
||||
var el = widget.dash.getElement(widget.elementID);
|
||||
el!.element = widget.item as dynamic;
|
||||
setState(() {});
|
||||
}, child:
|
||||
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,
|
||||
children: [ Icon(Icons.delete, color: Colors.black) ]),
|
||||
)
|
||||
)
|
||||
]),
|
||||
],)
|
||||
));
|
||||
for (var expose in container.exposes) {
|
||||
widgets.add(SubExposeFormsWidget( readOnly: true, width: 180, dash: widget.dash, empty: widgets.isEmpty,
|
||||
item: expose, elementID: widget.elementID));
|
||||
}
|
||||
}
|
||||
return Column(children: widgets);
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/widgets/forms/web_reference_forms.dart';
|
||||
|
||||
class DataFormsWidget extends StatefulWidget {
|
||||
DataItem item;
|
||||
String purpose = "";
|
||||
Function validate = () {};
|
||||
DataFormsWidget ({ super.key, required this.item });
|
||||
@override DataFormsWidgetState createState() => DataFormsWidgetState();
|
||||
}
|
||||
class DataFormsWidgetState extends State<DataFormsWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
return Column( children: [
|
||||
WebReferenceFormsWidget(item: widget.item),
|
||||
]);
|
||||
}
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
import 'package:alert_banner/exports.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:json_string/json_string.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/logs_service.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/dialog/alert.dart';
|
||||
import 'package:json_string/json_string.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/logs_service.dart';
|
||||
|
||||
class LogsWidget extends StatefulWidget {
|
||||
String? level;
|
||||
@ -26,7 +26,7 @@ class LogsWidgetState extends State<LogsWidget> {
|
||||
String end = "";
|
||||
try {
|
||||
if (widget.exec!.endDate != null && widget.exec!.endDate != "") {
|
||||
var startD = DateTime.parse(widget.exec!.executionData!);
|
||||
var startD = DateTime.parse(widget.exec!.startDate!);
|
||||
var endD = DateTime.parse(widget.exec!.endDate!);
|
||||
var diff = endD.difference(startD);
|
||||
if (diff.inDays < 30) {
|
||||
@ -38,8 +38,8 @@ class LogsWidgetState extends State<LogsWidget> {
|
||||
end = (startD.add( const Duration(days: 29)).microsecondsSinceEpoch).toString();
|
||||
}
|
||||
} else {
|
||||
start = (DateTime.parse(widget.exec!.executionData!).subtract( const Duration(days: 14)).microsecondsSinceEpoch).toString();
|
||||
end = (DateTime.parse(widget.exec!.executionData!).add( const Duration(days: 14)).microsecondsSinceEpoch).toString();
|
||||
start = (DateTime.parse(widget.exec!.startDate!).subtract( const Duration(days: 14)).microsecondsSinceEpoch).toString();
|
||||
end = (DateTime.parse(widget.exec!.startDate!).add( const Duration(days: 14)).microsecondsSinceEpoch).toString();
|
||||
}
|
||||
} catch(e) { /* */ }
|
||||
return FutureBuilder(future: LogsService().search(context, [], {
|
||||
|
Loading…
Reference in New Issue
Block a user