Shared WS

This commit is contained in:
mr
2024-08-27 15:38:21 +02:00
parent 36a70db69f
commit 6ba32a7dfa
19 changed files with 479 additions and 87 deletions

View File

@@ -109,6 +109,7 @@ class Workflow extends SerializerDeserializer<Workflow> {
Graph? graph;
Scheduler? schedule;
bool scheduleActive = false;
List<dynamic> shared;
Workflow({
this.id,
@@ -121,6 +122,7 @@ class Workflow extends SerializerDeserializer<Workflow> {
this.graph,
this.schedule,
this.scheduleActive = false,
this.shared = const [],
});
String getID() {
@@ -139,6 +141,7 @@ class Workflow extends SerializerDeserializer<Workflow> {
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,
);
@@ -181,6 +184,7 @@ class Workflow extends SerializerDeserializer<Workflow> {
"graph": graph?.toDashboard(),
"schedule_active": scheduleActive,
"schedule": schedule?.toDashboard(),
"shared": shared,
};
}
}
@@ -206,10 +210,12 @@ class Scheduler extends SerializerDeserializer<Scheduler> {
id = j["id"];
name = j["name"];
cron = j["cron"];
start = DateTime.parse(j["start"]);
if (j.containsKey("end") && j["end"] != null) {
end = DateTime.parse(j["end"]);
}
try {
start = DateTime.parse(j["start"]);
if (j.containsKey("end") && j["end"] != null) {
end = DateTime.parse(j["end"]);
}
} catch (e) {}
mode = int.parse(j["mode"].toString());
}
Map<String, dynamic> toDashboard() {
@@ -231,8 +237,8 @@ class Scheduler extends SerializerDeserializer<Scheduler> {
name: json.containsKey("name") ? json["name"] : "",
cron: json.containsKey("cron") ? json["cron"] : "",
mode: json.containsKey("mode") ? json["mode"] : "",
start: json.containsKey("start") ? DateTime.parse(json["start"]) : null,
end: json.containsKey("end") ? DateTime.parse(json["end"]) : null,
start: json.containsKey("start") && json["start"] != null ? DateTime.parse(json["start"]) : null,
end: json.containsKey("end") && json["end"] != null ? DateTime.parse(json["end"]) : null,
);
}
@override Map<String, dynamic> serialize() => {

View File

@@ -10,6 +10,7 @@ class Workspace extends SerializerDeserializer<Workspace> {
List<StorageItem> storages;
List<ProcessingItem> processings;
List<WorkflowItem> workflows;
String? shared;
Workspace({
this.id,
@@ -20,13 +21,16 @@ class Workspace extends SerializerDeserializer<Workspace> {
this.datacenters = const [],
this.storages = const [],
this.processings = const [],
this.shared,
});
@override deserialize(dynamic json) {
try { json = json as Map<String, dynamic>;
} catch (e) { return Workspace(); }
print(json);
return Workspace(
id: json.containsKey("id") ? json["id"] : null,
shared: json["shared"],
name: json.containsKey("name") ? json["name"] : null,
active: json.containsKey("active") ? json["active"] : false,
processings: json.containsKey("processing_resources") ? fromListJson(json["processing_resources"], ProcessingItem()) : [],