Latest Front with debug
This commit is contained in:
@@ -58,3 +58,17 @@ class RawData extends SerializerDeserializer<RawData> {
|
||||
@override deserialize(dynamic json) { return RawData(values: json ?? []); }
|
||||
@override Map<String, dynamic> serialize() => { };
|
||||
}
|
||||
|
||||
abstract class ShallowData {
|
||||
String getID();
|
||||
String getName();
|
||||
}
|
||||
|
||||
class Shallow {
|
||||
String id;
|
||||
String name;
|
||||
Shallow({
|
||||
this.id = "",
|
||||
this.name = "",
|
||||
});
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/models/abstract.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/models/workflow.dart';
|
||||
import 'package:oc_front/models/workspace.dart';
|
||||
|
||||
@@ -35,7 +35,7 @@ class SharedWorkspace extends SerializerDeserializer<SharedWorkspace> {
|
||||
id: json.containsKey("id") ? json["id"] : null,
|
||||
name: json.containsKey("name") ? json["name"] : null,
|
||||
description: json.containsKey("description") ? json["description"] : null,
|
||||
creatorID: json.containsKey("creator_id") ? json["creator_id"] : null,
|
||||
creatorID: json.containsKey("peer_id") ? json["peer_id"] : null,
|
||||
version: json.containsKey("version") ? json["version"] : null,
|
||||
attributes: json.containsKey("attributes") ? json["attributes"] : {},
|
||||
workspaces: json.containsKey("shared_workspaces") ? fromListJson(json["shared_workspaces"], Workspace()) : [],
|
||||
@@ -87,13 +87,16 @@ class Rule extends SerializerDeserializer<Rule> {
|
||||
};
|
||||
}
|
||||
|
||||
class Peer extends SerializerDeserializer<Peer> {
|
||||
class Peer extends SerializerDeserializer<Peer> implements ShallowData {
|
||||
String? id;
|
||||
String? name;
|
||||
|
||||
Peer(
|
||||
{this.id,
|
||||
this.name,});
|
||||
|
||||
@override String getID() => id ?? "";
|
||||
@override String getName() => name ?? "";
|
||||
|
||||
@override
|
||||
deserialize(dynamic json) {
|
||||
|
||||
@@ -4,6 +4,7 @@ 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/response.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
|
||||
class Check extends SerializerDeserializer<Check> {
|
||||
@@ -98,7 +99,7 @@ class WorkflowExecution extends SerializerDeserializer<WorkflowExecution> {
|
||||
|
||||
}
|
||||
|
||||
class Workflow extends SerializerDeserializer<Workflow> {
|
||||
class Workflow extends SerializerDeserializer<Workflow> implements ShallowData {
|
||||
String? id;
|
||||
String? name;
|
||||
List<dynamic> data;
|
||||
@@ -125,9 +126,9 @@ class Workflow extends SerializerDeserializer<Workflow> {
|
||||
this.shared = const [],
|
||||
});
|
||||
|
||||
String getID() {
|
||||
return id ?? "";
|
||||
}
|
||||
@override String getID() => id ?? "";
|
||||
@override String getName() => name ?? "";
|
||||
@override String getDescription() => "";
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
@@ -210,20 +211,24 @@ class Scheduler extends SerializerDeserializer<Scheduler> {
|
||||
id = j["id"];
|
||||
name = j["name"];
|
||||
cron = j["cron"];
|
||||
mode =j["mode"];
|
||||
try {
|
||||
start = DateTime.parse(j["start"]);
|
||||
start = j["start"] != null ? DateTime.parse(j["start"]) : DateTime.now().add( const Duration(minutes: 1)).toUtc();
|
||||
if (start == DateTime.utc(0)) {
|
||||
start = DateTime.now().add( const Duration(minutes: 1)).toUtc();
|
||||
}
|
||||
if (j.containsKey("end") && j["end"] != null) {
|
||||
end = DateTime.parse(j["end"]);
|
||||
}
|
||||
|
||||
} catch (e) {}
|
||||
mode = int.parse(j["mode"].toString());
|
||||
}
|
||||
Map<String, dynamic> toDashboard() {
|
||||
return {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"cron": cron,
|
||||
"mode": int.parse(mode.toString()),
|
||||
"mode": mode ?? 1,
|
||||
"start": start?.toIso8601String(),
|
||||
"end": end?.toIso8601String(),
|
||||
};
|
||||
@@ -241,15 +246,28 @@ class Scheduler extends SerializerDeserializer<Scheduler> {
|
||||
end: json.containsKey("end") && json["end"] != null ? DateTime.parse(json["end"]) : null,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"cron": cron ?? "",
|
||||
"mode": int.parse(mode.toString()),
|
||||
"start": start?.toIso8601String(),
|
||||
"end": end?.toIso8601String(),
|
||||
};
|
||||
@override Map<String, dynamic> serialize() {
|
||||
try {
|
||||
return {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"cron": cron ?? "",
|
||||
"mode": mode ?? 1,
|
||||
"start": start?.toIso8601String(),
|
||||
"end": end?.toIso8601String(),
|
||||
};
|
||||
} catch (e) {
|
||||
return {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"cron": cron ?? "",
|
||||
"start": start?.toIso8601String(),
|
||||
"end": end?.toIso8601String(),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Graph extends SerializerDeserializer<Graph> {
|
||||
double zoom;
|
||||
Map<String, GraphItem> items = {};
|
||||
@@ -505,24 +523,32 @@ class GraphItem extends SerializerDeserializer<GraphItem> {
|
||||
if (abs.topic == "data") {
|
||||
data = DataItem().deserialize(abs.serialize());
|
||||
data!.model = ResourceModel().deserialize(j["element"]["resource_model"]);
|
||||
}
|
||||
if (abs.topic == "processing") {
|
||||
} else if (abs.topic == "processing") {
|
||||
processing = ProcessingItem().deserialize(abs.serialize());
|
||||
processing!.model = ResourceModel().deserialize(j["element"]["resource_model"]);
|
||||
}
|
||||
if (abs.topic == "datacenter") {
|
||||
} else if (abs.topic == "datacenter") {
|
||||
datacenter = DataCenterItem().deserialize(abs.serialize());
|
||||
datacenter!.model = ResourceModel().deserialize(j["element"]["resource_model"]);
|
||||
}
|
||||
if (abs.topic == "storage") {
|
||||
} else if (abs.topic == "storage") {
|
||||
storage = StorageItem().deserialize(abs.serialize());
|
||||
storage!.model = ResourceModel().deserialize(j["element"]["resource_model"]);
|
||||
}
|
||||
if (abs.topic == "workflow") {
|
||||
} else if (abs.topic == "workflow") {
|
||||
workflow = WorkflowItem().deserialize(abs.serialize());
|
||||
workflow!.model = ResourceModel().deserialize(j["element"]["resource_model"]);
|
||||
} else {
|
||||
datacenter = null;
|
||||
data = null;
|
||||
processing = null;
|
||||
storage = null;
|
||||
workflow = null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
datacenter = null;
|
||||
data = null;
|
||||
processing = null;
|
||||
storage = null;
|
||||
workflow = null;
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toDashboard() {
|
||||
@@ -595,7 +621,7 @@ class Position extends SerializerDeserializer<Position> {
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"id": id,
|
||||
"x": x,
|
||||
"x": x ,
|
||||
"y": y,
|
||||
};
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
|
||||
import 'package:oc_front/models/abstract.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
|
||||
class Workspace extends SerializerDeserializer<Workspace> {
|
||||
class Workspace extends SerializerDeserializer<Workspace> implements ShallowData {
|
||||
String? id;
|
||||
String? name;
|
||||
bool? active;
|
||||
@@ -24,10 +26,12 @@ class Workspace extends SerializerDeserializer<Workspace> {
|
||||
this.shared,
|
||||
});
|
||||
|
||||
@override String getID() => id ?? "";
|
||||
@override String getName() => name ?? "";
|
||||
|
||||
@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"],
|
||||
|
||||
Reference in New Issue
Block a user