New local front deployment + new args

This commit is contained in:
mr
2024-10-15 11:28:29 +02:00
parent dacda3b3a6
commit 685badc59a
32 changed files with 952 additions and 325 deletions

View File

@@ -146,28 +146,53 @@ class Model extends SerializerDeserializer<Model> {
class ResourceModel extends SerializerDeserializer<ResourceModel> {
String? id;
String? type;
Map<String, Model>? model;
Map<String, dynamic> refs;
Map<String, Map<String,Model>>? model;
ResourceModel({
this.id,
this.type,
this.refs = const {},
this.model,
});
@override deserialize(dynamic json) {
try { json = json as Map<String, dynamic>;
} catch (e) { return ResourceModel(); }
return ResourceModel(
var w = ResourceModel(
id: json.containsKey("id") ? json["id"] : null,
type: json.containsKey("type") ? json["type"] : null,
model: json.containsKey("model") ? fromMapJson(json["model"], Model()) : {},
refs: json.containsKey("var_refs") ? json["var_refs"] : {},
);
if (json.containsKey("model")) {
w.model = {};
for (var key in (json["model"] as Map<dynamic, dynamic>).keys) {
w.model![key] = {};
for (var k2 in (json["model"][key] as Map<dynamic, dynamic>).keys) {
w.model![key]![k2] = Model().deserialize(json["model"][key][k2]);
}
}
}
return w;
}
@override Map<String, dynamic> serialize() {
Map<String, dynamic> t = {
"id": id,
"type": type,
"var_refs": refs,
};
t["model"] = {};
if (model != null) {
for (var key in model!.keys) {
t["model"][key] = {};
for (var k2 in model![key]!.keys) {
t["model"][key]![k2] = model![key]![k2]!.serialize();
}
}
}
return t;
}
@override Map<String, dynamic> serialize() => {
"id": id,
"type": type,
"model": toMapJson<Model>(model ?? {}),
};
}
Type? getTopicType(String topic) {
@@ -195,6 +220,73 @@ bool isDataCenter(String topic) => topic == "datacenter";
bool isStorage(String topic) => topic == "storage";
bool isWorkflow(String topic) => topic == "workflow";
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,
PAT: json.containsKey("PAT") ? json["PAT"] : null,
path: json.containsKey("reverse") ? 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,
});
String? args;
String? image;
String? command;
Map<String, dynamic>? env;
Map<String, dynamic>? volumes;
@override deserialize(dynamic json) {
try { json = json as Map<String, dynamic>;
} catch (e) { return Containered(); }
return Containered(
args: json.containsKey("args") ? json["args"] : null,
image: json.containsKey("image") ? json["image"] : null,
command: json.containsKey("command") ? json["command"] : null,
env: json.containsKey("env") ? json["env"] : null,
volumes: json.containsKey("volumes") ? json["volumes"] : null,
);
}
@override Map<String, dynamic> serialize() {
var w = {
"args": args,
"image": image,
"command": command,
"env": env,
"volumes": volumes,
};
return w;
}
}
class ProcessingItem extends SerializerDeserializer<ProcessingItem> implements AbstractItem<ProcessingItem> {
ProcessingItem({
this.id,
@@ -217,7 +309,9 @@ class ProcessingItem extends SerializerDeserializer<ProcessingItem> implements A
this.parrallel = false,
this.scallingModel,
this.diskIO,
this.expose = const [],
this.container,
this.model,
});
@override ResourceModel? model;
@@ -235,6 +329,8 @@ class ProcessingItem extends SerializerDeserializer<ProcessingItem> implements A
@override String? description;
@override String? shortDescription;
Containered? container;
List<Expose> expose = [];
// Special Attributes
List<CPU> cpus = [];
List<GPU> gpus = [];
@@ -261,6 +357,26 @@ class ProcessingItem extends SerializerDeserializer<ProcessingItem> implements A
double? getHeight() {
return height;
}
@override
Map<String, dynamic> setVariable(List<String> keys, dynamic value, Map<String, dynamic> map) {
if (keys.isEmpty) { return map; }
var key = keys[0];
if (keys.length > 1 && map[key] != null) {
map[key] = setVariable(keys.sublist(1), value, map[key]);
} else {
map[key] = value;
}
return map;
}
@override
dynamic getVariable(List<String> keys, Map<String, dynamic> map) {
if (keys.isEmpty) { return null; }
var key = keys[0];
if (keys.length > 1 && map[key] != null) {
return getVariable(keys.sublist(1), map[key]);
}
return map[key];
}
@override deserialize(dynamic json) {
try { json = json as Map<String, dynamic>;
@@ -278,7 +394,9 @@ class ProcessingItem extends SerializerDeserializer<ProcessingItem> implements A
inputs: json["inputs"] ?? [],
outputs: json["outputs"] ?? [],
source: json.containsKey("source") ? json["source"] : null,
expose: json.containsKey("expose") ? fromListJson(json["expose"], Expose()) : [],
container: json.containsKey("container") ? Containered().deserialize(json["container"]) : null,
model: json.containsKey("resource_model") ? ResourceModel().deserialize(json["resource_model"]) : null,
cpus: json.containsKey("cpus") ? fromListJson(json["cpus"], CPU()) : [],
gpus: json.containsKey("gpus") ? fromListJson(json["gpus"], GPU()) : [],
@@ -289,7 +407,6 @@ class ProcessingItem extends SerializerDeserializer<ProcessingItem> implements A
diskIO: json.containsKey("disk_io") ? json["disk_io"] : null,
);
if (w.logo != null) {
//
var image = Image.network(w.logo!);
image.image
.resolve(const ImageConfiguration())
@@ -302,7 +419,8 @@ class ProcessingItem extends SerializerDeserializer<ProcessingItem> implements A
}
return w;
}
@override Map<String, dynamic> serialize() => {
@override Map<String, dynamic> serialize() {
return {
"id": id,
"name": name,
"logo": logo,
@@ -323,7 +441,10 @@ class ProcessingItem extends SerializerDeserializer<ProcessingItem> implements A
"parrallel": parrallel,
"scalling_model": scallingModel,
"disk_io": diskIO,
};
""
"expose": toListJson<Expose>(expose),
"container": container?.serialize(),
}; }
}
class WorkflowItem extends SerializerDeserializer<WorkflowItem> implements AbstractItem<WorkflowItem> {
@@ -377,6 +498,27 @@ class WorkflowItem extends SerializerDeserializer<WorkflowItem> implements Abstr
@override String getName() {
return name ?? "";
}
@override
Map<String, dynamic> setVariable(List<String> keys, dynamic value, Map<String, dynamic> map) {
if (keys.isEmpty) { return map; }
var key = keys[0];
if (keys.length > 1 && map[key] != null) {
map[key] = setVariable(keys.sublist(1), value, map[key]);
} else {
map[key] = value;
}
return map;
}
@override
dynamic getVariable(List<String> keys, Map<String, dynamic> map) {
if (keys.isEmpty) { return null; }
var key = keys[0];
if (keys.length > 1 && map[key] != null) {
return getVariable(keys.sublist(1), map[key]);
}
return map[key];
}
@override deserialize(dynamic json) {
try { json = json as Map<String, dynamic>;
} catch (e) { return WorkflowItem(); }
@@ -443,8 +585,10 @@ class DataItem extends SerializerDeserializer<DataItem> implements AbstractItem<
this.inputs = _empty,
this.outputs = _empty,
this.model,
this.protocol,
this.path,
this.protocols = const [],
this.dataType,
this.type,
this.exemple,
});
@override String? id;
@@ -463,7 +607,9 @@ class DataItem extends SerializerDeserializer<DataItem> implements AbstractItem<
@override ResourceModel? model;
// Special Attributes
List<String> protocols = [];
String? dataType;
String? type;
String? protocol;
String? path;
String? exemple;
@override String getName() {
return name ?? "";
@@ -482,6 +628,28 @@ class DataItem extends SerializerDeserializer<DataItem> implements AbstractItem<
double? getHeight() {
return height;
}
@override
Map<String, dynamic> setVariable(List<String> keys, dynamic value, Map<String, dynamic> map) {
if (keys.isEmpty) { return map; }
var key = keys[0];
if (keys.length > 1 && map[key] != null) {
map[key] = setVariable(keys.sublist(1), value, map[key]);
} else {
map[key] = value;
}
return map;
}
@override
dynamic getVariable(List<String> keys, Map<String, dynamic> map) {
if (keys.isEmpty) { return null; }
var key = keys[0];
if (keys.length > 1 && map[key] != null) {
return getVariable(keys.sublist(1), map[key]);
}
return map[key];
}
@override deserialize(dynamic json) {
try { json = json as Map<String, dynamic>;
} catch (e) { return DataItem(); }
@@ -500,7 +668,9 @@ class DataItem extends SerializerDeserializer<DataItem> implements AbstractItem<
source: json.containsKey("source") ? json["source"] : null,
model: json.containsKey("resource_model") ? ResourceModel().deserialize(json["resource_model"]) : null,
protocols: json.containsKey("protocols") ? json["protocols"] : [],
dataType: json.containsKey("data_type") ? json["data_type"] : null,
type: json.containsKey("type") ? json["type"] : null,
protocol: json.containsKey("protocol") ? json["protocol"] : null,
path: json.containsKey("path") ? json["path"] : null,
exemple: json.containsKey("exemple") ? json["exemple"] : null,
);
if (w.logo != null) {
@@ -517,6 +687,7 @@ class DataItem extends SerializerDeserializer<DataItem> implements AbstractItem<
}
return w;
}
@override Map<String, dynamic> serialize() => {
"id": id,
"name": name,
@@ -532,7 +703,9 @@ class DataItem extends SerializerDeserializer<DataItem> implements AbstractItem<
"source": source,
"resource_model": model?.serialize(),
"protocols": protocols,
"data_type": dataType,
"type": type,
"protocol": protocol,
"path": path,
"exemple": exemple,
};
}
@@ -626,6 +799,29 @@ class DataCenterItem extends SerializerDeserializer<DataCenterItem> implements A
}
return w;
}
@override
Map<String, dynamic> setVariable(List<String> keys, dynamic value, Map<String, dynamic> map) {
if (keys.isEmpty) { return map; }
var key = keys[0];
if (keys.length > 1 && map[key] != null) {
map[key] = setVariable(keys.sublist(1), value, map[key]);
} else {
map[key] = value;
}
return map;
}
@override
dynamic getVariable(List<String> keys, Map<String, dynamic> map) {
if (keys.isEmpty) { return null; }
var key = keys[0];
if (keys.length > 1 && map[key] != null) {
return getVariable(keys.sublist(1), map[key]);
}
return map[key];
}
@override Map<String, dynamic> serialize() => {
"id": id,
"name": name,
@@ -745,12 +941,15 @@ class StorageItem extends SerializerDeserializer<StorageItem> implements Abstrac
this.acronym,
this.type,
this.size,
this.url,
this.path,
this.protocol,
this.encryption = false,
this.redundancy,
this.throughput,
this.model,
this.local = false,
});
bool local = false;
@override String? id;
@override String? name;
@override String? logo;
@@ -768,8 +967,9 @@ class StorageItem extends SerializerDeserializer<StorageItem> implements Abstrac
// special attributes
String? acronym;
String? type;
String? path;
String? protocol;
int? size;
String? url;
bool encryption = false;
String? redundancy;
String? throughput;
@@ -789,6 +989,29 @@ class StorageItem extends SerializerDeserializer<StorageItem> implements Abstrac
double? getHeight() {
return height;
}
@override
dynamic getVariable(List<String> keys, Map<String, dynamic> map) {
if (keys.isEmpty) { return null; }
var key = keys[0];
if (keys.length > 1 && map[key] != null) {
return getVariable(keys.sublist(1), map[key]);
}
return map[key];
}
@override
Map<String, dynamic> setVariable(List<String> keys, dynamic value, Map<String, dynamic> map) {
if (keys.isEmpty) { return map; }
var key = keys[0];
if (keys.length > 1 && map[key] != null) {
map[key] = setVariable(keys.sublist(1), value, map[key]);
} else {
map[key] = value;
}
return map;
}
@override deserialize(dynamic json) {
try { json = json as Map<String, dynamic>;
} catch (e) { return StorageItem(); }
@@ -802,6 +1025,7 @@ class StorageItem extends SerializerDeserializer<StorageItem> implements Abstrac
licence: json.containsKey("licence") ? json["licence"] : null,
description: json.containsKey("description") ? json["description"] : null,
shortDescription: json.containsKey("short_description") ? json["short_description"] : null,
local: json.containsKey("local") ? json["local"] : false,
inputs: json["inputs"] ?? [],
outputs: json["outputs"] ?? [],
source: json.containsKey("source") ? json["source"] : null,
@@ -809,7 +1033,8 @@ class StorageItem extends SerializerDeserializer<StorageItem> implements Abstrac
acronym: json.containsKey("acronym") ? json["acronym"] : null,
type: json.containsKey("type") ? json["type"] : null,
size: json.containsKey("size") ? json["size"] : null,
url: json.containsKey("url") ? json["url"] : null,
path: json.containsKey("path") ? json["path"] : null,
protocol: json.containsKey("protocol") ? json["protocol"] : null,
encryption: json.containsKey("encryption") ? json["encryption"] : false,
redundancy: json.containsKey("redundancy") ? json["redundancy"] : null,
throughput: json.containsKey("throughput") ? json["throughput"] : null,
@@ -835,6 +1060,7 @@ class StorageItem extends SerializerDeserializer<StorageItem> implements Abstrac
"owner": owner,
"owner_logo": ownerLogo,
"price": price,
"local": local,
"licence": licence,
"description": description,
"short_description": shortDescription,
@@ -845,7 +1071,8 @@ class StorageItem extends SerializerDeserializer<StorageItem> implements Abstrac
"acronym": acronym,
"type": type,
"size": size,
"url": url,
"path": path,
"protocol": protocol,
"encryption": encryption,
"redundancy": redundancy,
"throughput": throughput,

View File

@@ -76,8 +76,6 @@ class WorkflowExecution extends SerializerDeserializer<WorkflowExecution> {
@override deserialize(dynamic json) {
try { json = json as Map<String, dynamic>;
} catch (e) { return WorkflowExecution(); }
print("qsdqdqssd");
print(json);
return WorkflowExecution(
id: json.containsKey("id") ? json["id"] : "",
endDate: json.containsKey("end_date") ? json["end_date"] : "",
@@ -514,6 +512,15 @@ class GraphItem extends SerializerDeserializer<GraphItem> {
this.workflow,
});
AbstractItem? getElement() {
if (data != null) { return data!; }
if (processing != null) { return processing!; }
if (storage != null) { return storage!; }
if (datacenter != null) { return datacenter!; }
if (workflow != null) { return workflow!; }
return null;
}
void fromDashboard(Map<String, dynamic> j) {
id = j["id"];
position = Position(x: j["x"], y: j["y"]);
@@ -528,15 +535,19 @@ class GraphItem extends SerializerDeserializer<GraphItem> {
} 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 == "datacenter") {
datacenter = DataCenterItem().deserialize(abs.serialize());
datacenter!.model = ResourceModel().deserialize(j["element"]["resource_model"]);
} else if (abs.topic == "storage") {
storage = StorageItem().deserialize(abs.serialize());
storage!.model = ResourceModel().deserialize(j["element"]["resource_model"]);
} else if (abs.topic == "workflow") {
workflow = WorkflowItem().deserialize(abs.serialize());
workflow!.model = ResourceModel().deserialize(j["element"]["resource_model"]);
} else {
datacenter = null;
data = null;