intermediate
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:developer' as developer;
|
||||
|
||||
abstract class SerializerDeserializer<T> {
|
||||
T deserialize(dynamic json);
|
||||
|
||||
116
lib/models/logs.dart
Normal file
116
lib/models/logs.dart
Normal file
@@ -0,0 +1,116 @@
|
||||
import 'package:oc_front/models/abstract.dart';
|
||||
import 'package:json_string/json_string.dart';
|
||||
|
||||
class LogResults extends SerializerDeserializer<LogResults> {
|
||||
String? status;
|
||||
LogsResult? data;
|
||||
|
||||
LogResults({
|
||||
this.status,
|
||||
this.data,
|
||||
});
|
||||
|
||||
String getID() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return LogResults(); }
|
||||
return LogResults(
|
||||
status: json.containsKey("status") ? json["status"] : "",
|
||||
data: json.containsKey("data") ? LogsResult().deserialize(json["data"]) : null,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() {
|
||||
return { };
|
||||
}
|
||||
}
|
||||
|
||||
class LogsResult extends SerializerDeserializer<LogsResult> {
|
||||
List<Logs> result;
|
||||
LogsResult({
|
||||
this.result = const [],
|
||||
});
|
||||
|
||||
String getID() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return LogsResult(); }
|
||||
return LogsResult(
|
||||
result: json.containsKey("result") ? fromListJson(json["result"], Logs()) : [],
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() {
|
||||
return { };
|
||||
}
|
||||
}
|
||||
|
||||
class Logs extends SerializerDeserializer<Logs> {
|
||||
String? level;
|
||||
List<Log> logs = [];
|
||||
Logs({
|
||||
this.level,
|
||||
});
|
||||
|
||||
String getID() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return Logs(); }
|
||||
return Logs(
|
||||
level: json.containsKey("stream") && (json["stream"] as Map<String, dynamic>).containsKey("level") ? json["stream"]["level"] : "",
|
||||
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() {
|
||||
return { };
|
||||
}
|
||||
}
|
||||
|
||||
class Log extends SerializerDeserializer<Log> {
|
||||
DateTime? timestamp;
|
||||
String? message;
|
||||
|
||||
String? level;
|
||||
Map<String, dynamic> map = {};
|
||||
Log({
|
||||
this.timestamp,
|
||||
this.message,
|
||||
this.level
|
||||
});
|
||||
|
||||
String getID() {
|
||||
return "";
|
||||
}
|
||||
|
||||
String getMessage(String mess) {
|
||||
var jsonString = mess;
|
||||
try {
|
||||
var j = JsonString(mess.replaceAll("\\", "")).decodedValue as Map<String, dynamic>;
|
||||
map = j;
|
||||
if (j["Status"] == "Pending") {
|
||||
jsonString = "${j["Name"]} : [${j["Namespace"]}] Status: ${j["Status"]}... \nCreated at ${j["Created"].toString().replaceAllMapped(RegExp(r'\(\w+\)'), (match) { return ''; }).replaceAllMapped(RegExp(r'\+\w+'), (match) { return ''; })}";
|
||||
} else {
|
||||
jsonString = "${j["Name"]} : [${j["Namespace"]}] ${j["Status"]} ${j["Progress"]} (${j["Duration"].toString().replaceAll("seconds", "s")})\nStarted at ${j["Created"].toString().replaceAllMapped(RegExp(r'\(\w+\)'), (match) { return ''; }).replaceAllMapped(RegExp(r'\+\w+'), (match) { return ''; })}";
|
||||
}
|
||||
} on JsonFormatException catch (e) { /* */ }
|
||||
message = jsonString;
|
||||
return jsonString;
|
||||
}
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as List<dynamic>;
|
||||
} catch (e) { return Log(); }
|
||||
return Log(
|
||||
timestamp: json.isNotEmpty ? DateTime.parse(json[0]) : null,
|
||||
message: json.length > 1 ? getMessage(json[1].toString()) : null,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() { return { }; }
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:oc_front/models/abstract.dart';
|
||||
import 'package:oc_front/models/logs.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/models/workflow.dart';
|
||||
import 'package:oc_front/models/workspace.dart';
|
||||
|
||||
Map<Type, SerializerDeserializer> refs = <Type, SerializerDeserializer> {
|
||||
@@ -9,15 +11,21 @@ Map<Type, SerializerDeserializer> refs = <Type, SerializerDeserializer> {
|
||||
DataItem: DataItem(),
|
||||
DataCenterItem: DataCenterItem(),
|
||||
StorageItem: StorageItem(),
|
||||
ComputingItem: ComputingItem(),
|
||||
ProcessingItem: ProcessingItem(),
|
||||
Workflow: Workflow(),
|
||||
Resource: Resource(),
|
||||
WorkflowExecutions: WorkflowExecutions(),
|
||||
LogResults: LogResults(),
|
||||
};
|
||||
|
||||
class APIResponse<T extends SerializerDeserializer> {
|
||||
APIResponse({
|
||||
this.data,
|
||||
this.code = 200,
|
||||
this.error = "",
|
||||
this.offset = 0,
|
||||
});
|
||||
int code = 200;
|
||||
int offset = 0;
|
||||
T? data ;
|
||||
String? error = "";
|
||||
@@ -28,18 +36,22 @@ class APIResponse<T extends SerializerDeserializer> {
|
||||
}
|
||||
|
||||
APIResponse<T> deserialize(dynamic j) {
|
||||
dynamic data;
|
||||
try { data = j["data"];
|
||||
} catch (e) { data = j; }
|
||||
try {
|
||||
return APIResponse<T>(
|
||||
data: refs[T]!.deserialize(j),
|
||||
data: refs[T]!.deserialize(data),
|
||||
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(j), ); }
|
||||
|
||||
} catch (e) { return APIResponse<T>( data: refs[T]!.deserialize(data), ); }
|
||||
}
|
||||
}
|
||||
|
||||
class RawData extends SerializerDeserializer<RawData> {
|
||||
RawData({ this.values = const []});
|
||||
dynamic values;
|
||||
@override deserialize(dynamic json) { return RawData(values: json); }
|
||||
List<dynamic> values = [];
|
||||
@override deserialize(dynamic json) { return RawData(values: json ?? []); }
|
||||
@override Map<String, dynamic> serialize() => { };
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
|
||||
import 'package:oc_front/models/abstract.dart';
|
||||
|
||||
const List<ComputingItem> _emptyComputing = [];
|
||||
const List<ProcessingItem> _emptyComputing = [];
|
||||
const List<DataItem> _emptyData = [];
|
||||
const List<DataCenterItem> _emptyDataCenter = [];
|
||||
const List<StorageItem> _emptyStorage = [];
|
||||
@@ -11,248 +12,539 @@ class Search extends SerializerDeserializer<Search> {
|
||||
this.data = _emptyData,
|
||||
this.storage = _emptyStorage,
|
||||
});
|
||||
List<ComputingItem> computing;
|
||||
List<ProcessingItem> computing;
|
||||
List<DataCenterItem> datacenter;
|
||||
List<DataItem> data;
|
||||
List<StorageItem> storage;
|
||||
@override deserialize(dynamic json) {
|
||||
json = json as Map<String, dynamic>;
|
||||
return Search(
|
||||
computing: json.containsKey("computing") ? fromListJson(json["computing"], ComputingItem()) : [],
|
||||
computing: json.containsKey("processing") ? fromListJson(json["processing"], ProcessingItem()) : [],
|
||||
datacenter: json.containsKey("datacenter") ? fromListJson(json["datacenter"], DataCenterItem()) : [],
|
||||
data: json.containsKey("data") ? fromListJson(json["data"], DataItem()) : [],
|
||||
storage: json.containsKey("storage") ? fromListJson(json["storage"], StorageItem()) : [],
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {};
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"processing": toListJson<ProcessingItem>(computing),
|
||||
"datacenter": toListJson<DataCenterItem>(datacenter),
|
||||
"data": toListJson<DataItem>(data),
|
||||
"storage": toListJson<StorageItem>(storage),
|
||||
};
|
||||
}
|
||||
const List<String> _empty = [];
|
||||
abstract class AbstractItem {
|
||||
|
||||
class Resource implements SerializerDeserializer<Resource> {
|
||||
List<DataItem> datas = [];
|
||||
List<ProcessingItem> processings = [];
|
||||
List<StorageItem> storages = [];
|
||||
List<DataCenterItem> datacenters = [];
|
||||
List<WorkflowItem> workflows = [];
|
||||
|
||||
Resource({
|
||||
this.datas = const [],
|
||||
this.processings = const [],
|
||||
this.storages = const [],
|
||||
this.datacenters = const [],
|
||||
this.workflows = const [],
|
||||
});
|
||||
|
||||
@override Resource deserialize(json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return Resource(); }
|
||||
return Resource(
|
||||
datacenters: json.containsKey("datacenter_resource") ? fromListJson(json["datacenter_resource"], DataCenterItem()) : [],
|
||||
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 {
|
||||
"datacenter_resource": toListJson<DataCenterItem>(datacenters),
|
||||
"data_resource": toListJson<DataItem>(datas),
|
||||
"processing_resource": toListJson<ProcessingItem>(processings),
|
||||
"storage_resource": toListJson<StorageItem>(storages),
|
||||
"workflow_resource": toListJson<WorkflowItem>(workflows),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractItem<T extends FlowData> extends FlowData implements SerializerDeserializer<T> {
|
||||
String? id;
|
||||
String? name;
|
||||
String? logo;
|
||||
String? type;
|
||||
String? owner;
|
||||
String? ownerLogo;
|
||||
String? source;
|
||||
String? description;
|
||||
String? shortDescription;
|
||||
double? price;
|
||||
String? licence;
|
||||
List<dynamic> inputs = [];
|
||||
List<dynamic> outputs = [];
|
||||
ResourceModel? model;
|
||||
String topic = "";
|
||||
|
||||
AbstractItem({
|
||||
this.id,
|
||||
this.name,
|
||||
this.logo,
|
||||
this.owner,
|
||||
this.ownerLogo,
|
||||
this.price,
|
||||
this.source,
|
||||
this.licence,
|
||||
this.description,
|
||||
this.model,
|
||||
this.shortDescription,
|
||||
this.inputs = const [],
|
||||
this.outputs = const [],
|
||||
});
|
||||
|
||||
@override String getID() {
|
||||
return id ?? "";
|
||||
}
|
||||
|
||||
@override String getName() {
|
||||
return name ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
};
|
||||
}
|
||||
|
||||
class ResourceModel extends SerializerDeserializer<ResourceModel> {
|
||||
String? id;
|
||||
String? type;
|
||||
Map<String, Model>? model;
|
||||
|
||||
ResourceModel({
|
||||
this.id,
|
||||
this.type,
|
||||
this.model,
|
||||
});
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return ResourceModel(); }
|
||||
return ResourceModel(
|
||||
id: json.containsKey("id") ? json["id"] : null,
|
||||
type: json.containsKey("type") ? json["type"] : null,
|
||||
model: json.containsKey("model") ? fromMapJson(json["model"], Model()) : {},
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"id": id,
|
||||
"type": type,
|
||||
"model": toMapJson<Model>(model ?? {}),
|
||||
};
|
||||
}
|
||||
|
||||
Type? getTopicType(String topic) {
|
||||
if (topic == "computing") { return ComputingItem; }
|
||||
if (topic == "processing") { return ProcessingItem; }
|
||||
else if (topic == "data") { return DataItem; }
|
||||
else if (topic == "datacenter") { return DataCenterItem; }
|
||||
else if (topic == "storage") { return StorageItem; }
|
||||
else if (topic == "workflow") { return WorkflowItem; }
|
||||
else { return null; }
|
||||
}
|
||||
|
||||
String getTopic(Type type) {
|
||||
if (type == ComputingItem) { return "computing"; }
|
||||
if (type == AbstractItem) { return "resource"; }
|
||||
if (type == ProcessingItem) { return "processing"; }
|
||||
if (type == DataItem) { return "data"; }
|
||||
if (type == DataCenterItem) { return "datacenter"; }
|
||||
if (type == StorageItem) { return "storage"; }
|
||||
if (type == WorkflowItem) { return "workflow"; }
|
||||
return "";
|
||||
}
|
||||
|
||||
bool isComputing(String topic) => topic == "computing";
|
||||
bool isComputing(String topic) => topic == "processing";
|
||||
bool isData(String topic) => topic == "data";
|
||||
bool isDataCenter(String topic) => topic == "datacenter";
|
||||
bool isStorage(String topic) => topic == "storage";
|
||||
bool isWorkflow(String topic) => topic == "workflow";
|
||||
|
||||
class ComputingItem extends SerializerDeserializer<ComputingItem> implements AbstractItem {
|
||||
ComputingItem({
|
||||
class ProcessingItem extends SerializerDeserializer<ProcessingItem> implements AbstractItem<ProcessingItem> {
|
||||
ProcessingItem({
|
||||
this.id,
|
||||
this.name,
|
||||
this.logo,
|
||||
this.type,
|
||||
this.owner,
|
||||
this.ownerLogo,
|
||||
this.price,
|
||||
this.image,
|
||||
this.command,
|
||||
this.source,
|
||||
this.licence,
|
||||
this.description,
|
||||
this.requirements,
|
||||
this.ports = _empty,
|
||||
this.shortDescription,
|
||||
this.dinputs = _empty,
|
||||
this.doutputs = _empty,
|
||||
this.arguments = _empty,
|
||||
this.environment = _empty,
|
||||
this.inputs = _empty,
|
||||
this.outputs = _empty,
|
||||
|
||||
this.cpus = const [],
|
||||
this.gpus = const [],
|
||||
this.ram,
|
||||
this.storage,
|
||||
this.parrallel = false,
|
||||
this.scallingModel,
|
||||
this.diskIO,
|
||||
|
||||
this.model,
|
||||
});
|
||||
@override ResourceModel? model;
|
||||
@override String? id;
|
||||
@override String? name;
|
||||
@override String? logo;
|
||||
@override String? type;
|
||||
@override String? source;
|
||||
@override String? ownerLogo;
|
||||
@override String? owner;
|
||||
@override String topic = "computing";
|
||||
double? price;
|
||||
String? image;
|
||||
String? command;
|
||||
String? licence;
|
||||
List<dynamic> ports;
|
||||
List<dynamic> dinputs;
|
||||
List<dynamic> doutputs;
|
||||
List<dynamic> arguments;
|
||||
@override String topic = "processing";
|
||||
@override double? price;
|
||||
@override String? licence;
|
||||
@override List<dynamic> inputs;
|
||||
@override List<dynamic> outputs;
|
||||
@override String? description;
|
||||
@override String? shortDescription;
|
||||
List<dynamic> environment;
|
||||
ExecRequirements? requirements;
|
||||
|
||||
// Special Attributes
|
||||
List<CPU> cpus = [];
|
||||
List<GPU> gpus = [];
|
||||
RAM? ram;
|
||||
int? storage;
|
||||
bool parrallel = false;
|
||||
int? scallingModel;
|
||||
String? diskIO;
|
||||
|
||||
@override String getID() {
|
||||
return id ?? "";
|
||||
}
|
||||
|
||||
@override String getName() {
|
||||
return name ?? "";
|
||||
}
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return ComputingItem(); }
|
||||
return ComputingItem(
|
||||
id: json.containsKey("ID") ? json["ID"] : null,
|
||||
} catch (e) { return ProcessingItem(); }
|
||||
return ProcessingItem(
|
||||
id: json.containsKey("id") ? json["id"] : null,
|
||||
name: json.containsKey("name") ? json["name"] : null,
|
||||
logo: json.containsKey("logo") ? json["logo"] : null,
|
||||
type: json.containsKey("type") ? json["type"] : null,
|
||||
owner: json.containsKey("owner") ? json["owner"] : null,
|
||||
ownerLogo: json.containsKey("owner_logo") ? json["owner_logo"] : null,
|
||||
price: json.containsKey("price") ? json["price"]?.toDouble() : null,
|
||||
image: json.containsKey("image") ? json["image"] : null,
|
||||
command: json.containsKey("command") ? json["command"] : null,
|
||||
licence: json.containsKey("licence") ? json["licence"] : null,
|
||||
description: json.containsKey("description") ? json["description"] : null,
|
||||
ports: json["ports"] ?? [],
|
||||
shortDescription: json.containsKey("short_description") ? json["short_description"] : null,
|
||||
dinputs: json["dinputs"] ?? [],
|
||||
doutputs: json["doutputs"] ?? [],
|
||||
arguments: json["arguments"] ?? [],
|
||||
environment: json["environment"] ?? [],
|
||||
requirements: json.containsKey("requirements") ? ExecRequirements().deserialize(json["execution_requirements"]) : null,
|
||||
inputs: json["inputs"] ?? [],
|
||||
outputs: json["outputs"] ?? [],
|
||||
source: json.containsKey("source") ? json["source"] : 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()) : [],
|
||||
ram: json.containsKey("ram") ? RAM().deserialize(json["ram"]) : null,
|
||||
storage: json.containsKey("storage") ? json["storage"] : null,
|
||||
parrallel: json.containsKey("parrallel") ? json["parrallel"] : false,
|
||||
scallingModel: json.containsKey("scalling_model") ? json["scalling_model"] : null,
|
||||
diskIO: json.containsKey("disk_io") ? json["disk_io"] : null,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {};
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"logo": logo,
|
||||
"owner": owner,
|
||||
"owner_logo": ownerLogo,
|
||||
"price": price,
|
||||
"licence": licence,
|
||||
"description": description,
|
||||
"short_description": shortDescription,
|
||||
"inputs": inputs,
|
||||
"outputs": outputs,
|
||||
"source": source,
|
||||
"resource_model": model?.serialize(),
|
||||
"cpus": toListJson<CPU>(cpus),
|
||||
"gpus": toListJson<GPU>(gpus),
|
||||
"ram": ram?.serialize(),
|
||||
"storage": storage,
|
||||
"parrallel": parrallel,
|
||||
"scalling_model": scallingModel,
|
||||
"disk_io": diskIO,
|
||||
};
|
||||
}
|
||||
|
||||
class ExecRequirements extends SerializerDeserializer<ExecRequirements> {
|
||||
ExecRequirements({
|
||||
this.ram,
|
||||
this.cpus,
|
||||
this.gpus,
|
||||
this.diskIO,
|
||||
this.scallingModel,
|
||||
this.parallel = false,
|
||||
class WorkflowItem extends SerializerDeserializer<WorkflowItem> implements AbstractItem<WorkflowItem> {
|
||||
WorkflowItem({
|
||||
this.id,
|
||||
this.name,
|
||||
this.logo,
|
||||
this.owner,
|
||||
this.ownerLogo,
|
||||
this.price,
|
||||
this.source,
|
||||
this.licence,
|
||||
this.description,
|
||||
this.shortDescription,
|
||||
this.inputs = _empty,
|
||||
this.outputs = _empty,
|
||||
this.model,
|
||||
this.workflowID,
|
||||
});
|
||||
double? ram;
|
||||
double? cpus;
|
||||
double? gpus;
|
||||
String? diskIO;
|
||||
bool parallel = false;
|
||||
double? scallingModel;
|
||||
@override ResourceModel? model;
|
||||
@override String? id;
|
||||
@override String? name;
|
||||
@override String? logo;
|
||||
@override String? source;
|
||||
@override String? ownerLogo;
|
||||
@override String? owner;
|
||||
@override String topic = "workflow";
|
||||
@override double? price;
|
||||
@override String? licence;
|
||||
@override List<dynamic> inputs;
|
||||
@override List<dynamic> outputs;
|
||||
@override String? description;
|
||||
@override String? shortDescription;
|
||||
|
||||
String? workflowID;
|
||||
@override String getID() {
|
||||
return id ?? "";
|
||||
}
|
||||
|
||||
@override String getName() {
|
||||
return name ?? "";
|
||||
}
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return ExecRequirements(); }
|
||||
return ExecRequirements(
|
||||
ram: json.containsKey("ram") ? json["ram"]?.toDouble() : null,
|
||||
cpus: json.containsKey("cpus") ? json["cpus"]?.toDouble() : null,
|
||||
gpus: json.containsKey("gpus") ? json["gpus"]?.toDouble() : null,
|
||||
diskIO: json.containsKey("disk_io") ? json["disk_io"] : null,
|
||||
scallingModel: json.containsKey("scaling_model") ? json["scaling_model"]?.toDouble() : null,
|
||||
parallel: json.containsKey("parallel") ? json["parallel"] : false,
|
||||
} catch (e) { return WorkflowItem(); }
|
||||
return WorkflowItem(
|
||||
id: json.containsKey("id") ? json["id"] : null,
|
||||
name: json.containsKey("name") ? json["name"] : null,
|
||||
logo: json.containsKey("logo") ? json["logo"] : null,
|
||||
owner: json.containsKey("owner") ? json["owner"] : null,
|
||||
ownerLogo: json.containsKey("owner_logo") ? json["owner_logo"] : null,
|
||||
price: json.containsKey("price") ? json["price"]?.toDouble() : null,
|
||||
licence: json.containsKey("licence") ? json["licence"] : null,
|
||||
description: json.containsKey("description") ? json["description"] : null,
|
||||
shortDescription: json.containsKey("short_description") ? json["short_description"] : null,
|
||||
inputs: json["inputs"] ?? [],
|
||||
outputs: json["outputs"] ?? [],
|
||||
source: json.containsKey("source") ? json["source"] : null,
|
||||
model: json.containsKey("resource_model") ? ResourceModel().deserialize(json["resource_model"]) : null,
|
||||
workflowID: json.containsKey("workflow_id") ? json["workflow_id"] : null,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {};
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"logo": logo,
|
||||
"owner": owner,
|
||||
"owner_logo": ownerLogo,
|
||||
"price": price,
|
||||
"licence": licence,
|
||||
"description": description,
|
||||
"short_description": shortDescription,
|
||||
"inputs": inputs,
|
||||
"outputs": outputs,
|
||||
"source": source,
|
||||
"resource_model": model?.serialize(),
|
||||
"workflow_id": workflowID,
|
||||
};
|
||||
}
|
||||
|
||||
class DataItem extends SerializerDeserializer<DataItem> implements AbstractItem {
|
||||
class DataItem extends SerializerDeserializer<DataItem> implements AbstractItem<DataItem> {
|
||||
DataItem({
|
||||
this.id,
|
||||
this.name,
|
||||
this.logo,
|
||||
this.type,
|
||||
this.dtype,
|
||||
this.owner,
|
||||
this.example,
|
||||
this.location,
|
||||
this.ownerLogo,
|
||||
this.price,
|
||||
this.source,
|
||||
this.licence,
|
||||
this.description,
|
||||
this.protocol = _empty,
|
||||
this.shortDescription,
|
||||
this.inputs = _empty,
|
||||
this.outputs = _empty,
|
||||
this.model,
|
||||
this.protocols = const [],
|
||||
this.dataType,
|
||||
this.exemple,
|
||||
});
|
||||
@override String? id;
|
||||
@override String? name;
|
||||
@override String? logo;
|
||||
@override String? type;
|
||||
@override String topic = "data";
|
||||
String? dtype;
|
||||
String? example;
|
||||
String? location;
|
||||
@override String? description;
|
||||
List<dynamic> protocol;
|
||||
@override String? shortDescription;
|
||||
@override String? source;
|
||||
@override String? ownerLogo;
|
||||
@override String? owner;
|
||||
|
||||
@override String topic = "data";
|
||||
@override double? price;
|
||||
@override String? licence;
|
||||
@override List<dynamic> inputs;
|
||||
@override List<dynamic> outputs;
|
||||
@override String? description;
|
||||
@override String? shortDescription;
|
||||
@override ResourceModel? model;
|
||||
// Special Attributes
|
||||
List<String> protocols = [];
|
||||
String? dataType;
|
||||
String? exemple;
|
||||
@override String getName() {
|
||||
return name ?? "";
|
||||
}
|
||||
@override String getID() {
|
||||
return id ?? "";
|
||||
}
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return DataItem(); }
|
||||
return DataItem(
|
||||
id: json.containsKey("ID") ? json["ID"] : null,
|
||||
id: json.containsKey("id") ? json["id"] : null,
|
||||
name: json.containsKey("name") ? json["name"] : null,
|
||||
logo: json.containsKey("logo") ? json["logo"] : null,
|
||||
type: json.containsKey("type") ? json["type"] : null,
|
||||
owner: json.containsKey("owner") ? json["owner"] : null,
|
||||
dtype: json.containsKey("dtype") ? json["dtype"] : null,
|
||||
example: json.containsKey("example") ? json["example"] : null,
|
||||
location: json.containsKey("location") ? json["location"] : null,
|
||||
ownerLogo: json.containsKey("owner_logo") ? json["owner_logo"] : null,
|
||||
price: json.containsKey("price") ? json["price"]?.toDouble() : null,
|
||||
licence: json.containsKey("licence") ? json["licence"] : null,
|
||||
description: json.containsKey("description") ? json["description"] : null,
|
||||
protocol: json["protocol"] ?? [],
|
||||
shortDescription: json.containsKey("short_description") ? json["short_description"] : null
|
||||
shortDescription: json.containsKey("short_description") ? json["short_description"] : null,
|
||||
inputs: json["inputs"] ?? [],
|
||||
outputs: json["outputs"] ?? [],
|
||||
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,
|
||||
exemple: json.containsKey("exemple") ? json["exemple"] : null,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {};
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"logo": logo,
|
||||
"owner": owner,
|
||||
"owner_logo": ownerLogo,
|
||||
"price": price,
|
||||
"licence": licence,
|
||||
"description": description,
|
||||
"short_description": shortDescription,
|
||||
"inputs": inputs,
|
||||
"outputs": outputs,
|
||||
"source": source,
|
||||
"resource_model": model?.serialize(),
|
||||
"protocols": protocols,
|
||||
"data_type": dataType,
|
||||
"exemple": exemple,
|
||||
};
|
||||
}
|
||||
const List<GPU> _emptyGPU = [];
|
||||
class DataCenterItem extends SerializerDeserializer<DataCenterItem> implements AbstractItem {
|
||||
|
||||
class DataCenterItem extends SerializerDeserializer<DataCenterItem> implements AbstractItem<DataCenterItem> {
|
||||
DataCenterItem({
|
||||
this.id,
|
||||
this.cpu,
|
||||
this.ram,
|
||||
this.name,
|
||||
this.logo,
|
||||
this.type,
|
||||
this.owner,
|
||||
this.acronym,
|
||||
this.bookingPrice,
|
||||
this.ownerLogo,
|
||||
this.price,
|
||||
this.source,
|
||||
this.licence,
|
||||
this.description,
|
||||
this.hosts = _empty,
|
||||
this.gpus = _emptyGPU,
|
||||
this.shortDescription,
|
||||
this.inputs = _empty,
|
||||
this.outputs = _empty,
|
||||
this.model,
|
||||
this.cpus = const [],
|
||||
this.gpus = const [],
|
||||
this.ram,
|
||||
});
|
||||
CPU? cpu;
|
||||
RAM? ram;
|
||||
@override String? id;
|
||||
@override String? name;
|
||||
@override String? logo;
|
||||
@override String? type;
|
||||
@override String? source;
|
||||
@override String? ownerLogo;
|
||||
@override String? owner;
|
||||
@override String topic = "datacenter";
|
||||
String? acronym;
|
||||
List<GPU> gpus = [];
|
||||
@override double? price;
|
||||
@override String? licence;
|
||||
@override List<dynamic> inputs;
|
||||
@override List<dynamic> outputs;
|
||||
@override String? description;
|
||||
List<dynamic> hosts;
|
||||
double? bookingPrice;
|
||||
@override String? shortDescription;
|
||||
|
||||
@override ResourceModel? model;
|
||||
// Special Attributes
|
||||
List<CPU> cpus = [];
|
||||
List<GPU> gpus = [];
|
||||
RAM? ram;
|
||||
@override String getID() {
|
||||
return id ?? "";
|
||||
}
|
||||
@override String getName() {
|
||||
return name ?? "";
|
||||
}
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return DataCenterItem(); }
|
||||
return DataCenterItem(
|
||||
id: json.containsKey("ID") ? json["ID"] : null,
|
||||
ram: json.containsKey("ram") ? RAM().deserialize(json["ram"]) : null,
|
||||
cpu: json.containsKey("cpu") ? CPU().deserialize(json["cpu"]) : null,
|
||||
acronym: json.containsKey("acronym") ? json["acronym"] : null,
|
||||
id: json.containsKey("id") ? json["id"] : null,
|
||||
name: json.containsKey("name") ? json["name"] : null,
|
||||
logo: json.containsKey("logo") ? json["logo"] : null,
|
||||
type: json.containsKey("type") ? json["type"] : null,
|
||||
owner: json.containsKey("owner") ? json["owner"] : null,
|
||||
bookingPrice: json.containsKey("bookingPrice") ? json["bookingPrice"]?.toDouble() : null,
|
||||
ownerLogo: json.containsKey("owner_logo") ? json["owner_logo"] : null,
|
||||
price: json.containsKey("price") ? json["price"]?.toDouble() : null,
|
||||
licence: json.containsKey("licence") ? json["licence"] : null,
|
||||
description: json.containsKey("description") ? json["description"] : null,
|
||||
hosts: json["hosts"] ?? [],
|
||||
shortDescription: json.containsKey("short_description") ? json["short_description"] : null,
|
||||
gpus: json.containsKey("gpus") ? fromListJson(json["gpus"] ?? [], GPU()) : [],
|
||||
inputs: json["inputs"] ?? [],
|
||||
outputs: json["outputs"] ?? [],
|
||||
source: json.containsKey("source") ? json["source"] : 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()) : [],
|
||||
ram: json.containsKey("ram") ? RAM().deserialize(json["ram"]) : null,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {};
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"logo": logo,
|
||||
"owner": owner,
|
||||
"owner_logo": ownerLogo,
|
||||
"price": price,
|
||||
"licence": licence,
|
||||
"description": description,
|
||||
"short_description": shortDescription,
|
||||
"inputs": inputs,
|
||||
"outputs": outputs,
|
||||
"source": source,
|
||||
"resource_model": model?.serialize(),
|
||||
"cpus": toListJson<CPU>(cpus),
|
||||
"gpus": toListJson<GPU>(gpus),
|
||||
"ram": ram?.serialize(),
|
||||
};
|
||||
}
|
||||
class CPU extends SerializerDeserializer<CPU> {
|
||||
CPU({
|
||||
@@ -279,7 +571,13 @@ class CPU extends SerializerDeserializer<CPU> {
|
||||
shared: json.containsKey("shared") ? json["shared"] : false,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {};
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"cores": cores,
|
||||
"platform": platform,
|
||||
"architecture": architecture,
|
||||
"minimumMemory": minimumMemory,
|
||||
"shared": shared,
|
||||
};
|
||||
}
|
||||
class GPU extends SerializerDeserializer<GPU> {
|
||||
GPU({
|
||||
@@ -303,7 +601,12 @@ class GPU extends SerializerDeserializer<GPU> {
|
||||
tensorCores: json.containsKey("tensor_cores") ? json["tensor_cores"]?.toDouble() : null,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {};
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"cuda_cores": cudaCores,
|
||||
"memory": memory,
|
||||
"model": model,
|
||||
"tensor_cores": tensorCores,
|
||||
};
|
||||
}
|
||||
class RAM extends SerializerDeserializer<RAM> {
|
||||
RAM({
|
||||
@@ -321,61 +624,108 @@ class RAM extends SerializerDeserializer<RAM> {
|
||||
size: json.containsKey("size") ? json["size"]?.toDouble() : null,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {};
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"ecc": ecc,
|
||||
"size": size,
|
||||
};
|
||||
}
|
||||
class StorageItem extends SerializerDeserializer<StorageItem> implements AbstractItem {
|
||||
class StorageItem extends SerializerDeserializer<StorageItem> implements AbstractItem<StorageItem> {
|
||||
StorageItem({
|
||||
this.id,
|
||||
this.url,
|
||||
this.size,
|
||||
this.name,
|
||||
this.logo,
|
||||
this.type,
|
||||
this.owner,
|
||||
this.acronym,
|
||||
this.throughput,
|
||||
this.redundancy,
|
||||
this.ownerLogo,
|
||||
this.price,
|
||||
this.source,
|
||||
this.licence,
|
||||
this.description,
|
||||
this.bookingPrice,
|
||||
this.shortDescription,
|
||||
this.inputs = _empty,
|
||||
this.outputs = _empty,
|
||||
this.acronym,
|
||||
this.type,
|
||||
this.size,
|
||||
this.url,
|
||||
this.encryption = false,
|
||||
this.redundancy,
|
||||
this.throughput,
|
||||
this.model,
|
||||
});
|
||||
@override String? id;
|
||||
String? url;
|
||||
@override String? name;
|
||||
@override String? logo;
|
||||
@override String? type;
|
||||
@override String? id;
|
||||
@override String? name;
|
||||
@override String? logo;
|
||||
@override String? source;
|
||||
@override String? ownerLogo;
|
||||
@override String? owner;
|
||||
@override String topic = "storage";
|
||||
double? size;
|
||||
@override String? owner;
|
||||
@override double? price;
|
||||
@override String? licence;
|
||||
@override List<dynamic> inputs;
|
||||
@override List<dynamic> outputs;
|
||||
@override String? description;
|
||||
@override String? shortDescription;
|
||||
@override ResourceModel? model;
|
||||
// special attributes
|
||||
String? acronym;
|
||||
String? type;
|
||||
int? size;
|
||||
String? url;
|
||||
bool encryption = false;
|
||||
String? redundancy;
|
||||
String? throughput;
|
||||
@override String? description;
|
||||
double? bookingPrice;
|
||||
bool encryption = false;
|
||||
@override String? shortDescription;
|
||||
|
||||
|
||||
@override String getName() {
|
||||
return name ?? "";
|
||||
}
|
||||
@override String getID() {
|
||||
return id ?? "";
|
||||
}
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return StorageItem(); }
|
||||
return StorageItem(
|
||||
id: json.containsKey("ID") ? json["ID"] : null,
|
||||
url: json.containsKey("URL") ? json["URL"] : null,
|
||||
size: json.containsKey("size") ? json["size"]?.toDouble() : null,
|
||||
id: json.containsKey("id") ? json["id"] : null,
|
||||
name: json.containsKey("name") ? json["name"] : null,
|
||||
logo: json.containsKey("logo") ? json["logo"] : null,
|
||||
type: json.containsKey("type") ? json["type"] : null,
|
||||
owner: json.containsKey("owner") ? json["owner"] : null,
|
||||
acronym: json.containsKey("DCacronym") ? json["DCacronym"] : null,
|
||||
bookingPrice: json.containsKey("bookingPrice") ? json["bookingPrice"]?.toDouble() : null,
|
||||
ownerLogo: json.containsKey("owner_logo") ? json["owner_logo"] : null,
|
||||
price: json.containsKey("price") ? json["price"]?.toDouble() : null,
|
||||
licence: json.containsKey("licence") ? json["licence"] : null,
|
||||
description: json.containsKey("description") ? json["description"] : null,
|
||||
throughput: json.containsKey("throughput") ? json["throughput"] : [],
|
||||
shortDescription: json.containsKey("short_description") ? json["short_description"] : null,
|
||||
redundancy: json.containsKey("redundancy") ? json["redundancy"] : [],
|
||||
inputs: json["inputs"] ?? [],
|
||||
outputs: json["outputs"] ?? [],
|
||||
source: json.containsKey("source") ? json["source"] : null,
|
||||
model: json.containsKey("resource_model") ? ResourceModel().deserialize(json["resource_model"]) : null,
|
||||
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,
|
||||
encryption: json.containsKey("encryption") ? json["encryption"] : false,
|
||||
redundancy: json.containsKey("redundancy") ? json["redundancy"] : null,
|
||||
throughput: json.containsKey("throughput") ? json["throughput"] : null,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {};
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"logo": logo,
|
||||
"owner": owner,
|
||||
"owner_logo": ownerLogo,
|
||||
"price": price,
|
||||
"licence": licence,
|
||||
"description": description,
|
||||
"short_description": shortDescription,
|
||||
"inputs": inputs,
|
||||
"outputs": outputs,
|
||||
"source": source,
|
||||
"resource_model": model?.serialize(),
|
||||
"acronym": acronym,
|
||||
"type": type,
|
||||
"size": size,
|
||||
"url": url,
|
||||
"encryption": encryption,
|
||||
"redundancy": redundancy,
|
||||
"throughput": throughput,
|
||||
};
|
||||
}
|
||||
559
lib/models/workflow.dart
Normal file
559
lib/models/workflow.dart
Normal file
@@ -0,0 +1,559 @@
|
||||
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/search.dart';
|
||||
|
||||
class WorkflowExecutions extends SerializerDeserializer<WorkflowExecutions> {
|
||||
List<WorkflowExecution> executions = [];
|
||||
String? executionData;
|
||||
int? status;
|
||||
String? workflowId;
|
||||
|
||||
WorkflowExecutions({
|
||||
this.executions = const [],
|
||||
});
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as List<dynamic>;
|
||||
} catch (e) { return WorkflowExecutions(); }
|
||||
return WorkflowExecutions(
|
||||
executions: fromListJson(json, WorkflowExecution()),
|
||||
);
|
||||
}
|
||||
|
||||
@override Map<String, dynamic> serialize() {
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class WorkflowExecution extends SerializerDeserializer<WorkflowExecution> {
|
||||
String? id;
|
||||
String? name;
|
||||
String? executionData;
|
||||
String? endDate;
|
||||
int? status;
|
||||
String? workflowId;
|
||||
|
||||
|
||||
WorkflowExecution({
|
||||
this.id,
|
||||
this.executionData,
|
||||
this.status,
|
||||
this.workflowId,
|
||||
this.name,
|
||||
this.endDate,
|
||||
});
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return 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"] : "",
|
||||
status: json.containsKey("status") ? json["status"] : 1,
|
||||
workflowId: json.containsKey("workflow_id") ? json["workflow_id"] : "",
|
||||
name: json.containsKey("name") ? json["name"] : "",
|
||||
);
|
||||
}
|
||||
|
||||
@override Map<String, dynamic> serialize() {
|
||||
return {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"end_date": endDate,
|
||||
"execution_data": executionData,
|
||||
"status": status,
|
||||
"workflow_id": workflowId,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Workflow extends SerializerDeserializer<Workflow> {
|
||||
String? id;
|
||||
String? name;
|
||||
List<dynamic> data;
|
||||
List<dynamic> datacenter;
|
||||
List<dynamic> storage;
|
||||
List<dynamic> processing;
|
||||
List<dynamic> workflows;
|
||||
Graph? graph;
|
||||
Scheduler? schedule;
|
||||
|
||||
Workflow({
|
||||
this.id,
|
||||
this.name = "",
|
||||
this.data = const [],
|
||||
this.datacenter = const [],
|
||||
this.storage = const [],
|
||||
this.processing = const [],
|
||||
this.workflows = const [],
|
||||
this.graph,
|
||||
this.schedule,
|
||||
});
|
||||
|
||||
String getID() {
|
||||
return id ?? "";
|
||||
}
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return Workflow(); }
|
||||
return Workflow(
|
||||
id: json.containsKey("id") ? json["id"] : "",
|
||||
name: json.containsKey("name") ? json["name"] : "",
|
||||
workflows: json.containsKey("workflows") ? json["workflows"] : [],
|
||||
processing: json.containsKey("processings") ? json["processings"] : [],
|
||||
datacenter: json.containsKey("datacenters") ? json["datacenters"] : [],
|
||||
data: json.containsKey("datas") ? json["datas"] : [],
|
||||
storage: json.containsKey("storages") ? json["storages"] : [],
|
||||
graph: json.containsKey("graph") ? Graph().deserialize(json["graph"]) : null,
|
||||
schedule: json.containsKey("schedule") ? Scheduler().deserialize(json["schedule"]) : null,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() {
|
||||
var obj = {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"datas": data,
|
||||
"datacenters" : datacenter,
|
||||
"storages": storage,
|
||||
"processings": processing,
|
||||
"workflows": workflows,
|
||||
"schedule": schedule?.serialize(),
|
||||
};
|
||||
if (graph != null) {
|
||||
obj["graph"] = graph!.serialize();
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
void fromDashboard(Map<String, dynamic> j) {
|
||||
id = j["id"];
|
||||
name = j["name"];
|
||||
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": schedule?.toDashboard(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class Scheduler extends SerializerDeserializer<Scheduler> {
|
||||
String? id;
|
||||
String? name;
|
||||
String? cron;
|
||||
DateTime? start;
|
||||
DateTime? end;
|
||||
|
||||
Scheduler({
|
||||
this.id,
|
||||
this.name,
|
||||
this.cron,
|
||||
this.start,
|
||||
this.end
|
||||
});
|
||||
|
||||
void fromDashboard(Map<String, dynamic> j) {
|
||||
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"]);
|
||||
}
|
||||
|
||||
}
|
||||
Map<String, dynamic> toDashboard() {
|
||||
return {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"cron": cron,
|
||||
"start": start?.toIso8601String(),
|
||||
"end": end?.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return Scheduler(); }
|
||||
return Scheduler(
|
||||
id: json.containsKey("id") ? json["id"] : null,
|
||||
name: json.containsKey("name") ? json["name"] : "",
|
||||
cron: json.containsKey("cron") ? json["cron"] : "",
|
||||
start: json.containsKey("start") ? DateTime.parse(json["start"]) : null,
|
||||
end: json.containsKey("end") ? DateTime.parse(json["end"]) : null,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"cron": cron ?? "",
|
||||
"start": start?.toIso8601String(),
|
||||
"end": end?.toIso8601String(),
|
||||
};
|
||||
}
|
||||
class Graph extends SerializerDeserializer<Graph> {
|
||||
double zoom;
|
||||
Map<String, GraphItem> items = {};
|
||||
List<GraphLink> links = [];
|
||||
|
||||
Graph({
|
||||
this.zoom = 1,
|
||||
this.items = const {},
|
||||
this.links = const [],
|
||||
});
|
||||
|
||||
void fromDashboard(Map<String, dynamic> j) {
|
||||
items = {};
|
||||
for (var el in (j["elements"] as Map<dynamic, dynamic>).values) {
|
||||
var d = GraphItem();
|
||||
d.fromDashboard(el as Map<String, dynamic>);
|
||||
items[d.id ?? ""] = d;
|
||||
}
|
||||
links = (j["arrows"] as List<dynamic>).map( (el) {
|
||||
var d = GraphLink();
|
||||
d.fromDashboard(el);
|
||||
return d;
|
||||
}).toList();
|
||||
j["zoom"] = zoom;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toDashboard() {
|
||||
List<Map<String, dynamic>> elements = [];
|
||||
List<Map<String, dynamic>> arrows = [];
|
||||
for (var el in items.values) {
|
||||
elements.add(el.toDashboard());
|
||||
}
|
||||
for (var l in links) {
|
||||
arrows.add(l.toDashboard());
|
||||
}
|
||||
return {
|
||||
"zoom": zoom,
|
||||
"elements": elements,
|
||||
"arrows": arrows,
|
||||
};
|
||||
}
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return Graph(); }
|
||||
return 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()) : {},
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"zoom": zoom,
|
||||
"items": toMapJson(items),
|
||||
"links": toListJson(links),
|
||||
};
|
||||
}
|
||||
|
||||
class GraphLink extends SerializerDeserializer<GraphLink> {
|
||||
Position? source;
|
||||
Position? destination;
|
||||
GraphLinkStyle? style;
|
||||
|
||||
GraphLink({
|
||||
this.source,
|
||||
this.destination,
|
||||
this.style,
|
||||
});
|
||||
|
||||
void fromDashboard(Map<String, dynamic> j) {
|
||||
source = Position(id: j["from"]["id"], x: j["from"]["x"], y: j["from"]["y"]);
|
||||
destination = Position(id: j["to"]["id"], x: j["to"]["x"], y: j["to"]["y"]);
|
||||
style = GraphLinkStyle();
|
||||
style!.fromDashboard(j["params"]);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toDashboard() {
|
||||
return {
|
||||
"from": {
|
||||
"id": source?.id ?? "",
|
||||
"x" : source?.x ?? 0,
|
||||
"y": source?.y ?? 0,
|
||||
},
|
||||
"to": {
|
||||
"id": destination?.id ?? "",
|
||||
"x" : destination?.x ?? 0,
|
||||
"y": destination?.y ?? 0,
|
||||
},
|
||||
"params": style?.toDashboard(),
|
||||
};
|
||||
}
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
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,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() {
|
||||
var obj = <String, dynamic>{};
|
||||
if (source != null) {
|
||||
obj["source"] = source!.serialize();
|
||||
}
|
||||
if (destination != null) {
|
||||
obj["destination"] = destination!.serialize();
|
||||
}
|
||||
if (style != null) {
|
||||
obj["style"] = style!.serialize();
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
class GraphLinkStyle extends SerializerDeserializer<GraphLinkStyle> {
|
||||
Color color = Colors.black;
|
||||
double stroke = 1;
|
||||
double tension = 23;
|
||||
double headRadius = 10;
|
||||
double dashWidth = 0;
|
||||
double dashSpace = 0;
|
||||
double startArrowWidth = 1;
|
||||
double endArrowWidth = 10;
|
||||
Position? startArrow;
|
||||
Position? endArrow;
|
||||
ArrowStyle arrowStyle = ArrowStyle.curve;
|
||||
ArrowDirection arrowDirection = ArrowDirection.forward;
|
||||
|
||||
GraphLinkStyle({
|
||||
this.color = Colors.black,
|
||||
this.stroke = 1,
|
||||
this.tension = 23,
|
||||
this.headRadius = 10,
|
||||
this.dashWidth = 0,
|
||||
this.dashSpace = 0,
|
||||
this.startArrowWidth = 10,
|
||||
this.endArrowWidth = 10,
|
||||
this.startArrow,
|
||||
this.endArrow,
|
||||
this.arrowStyle = ArrowStyle.curve,
|
||||
this.arrowDirection = ArrowDirection.forward
|
||||
});
|
||||
|
||||
void fromDashboard(Map<String, dynamic> j) {
|
||||
dashSpace = j["dash_space"];
|
||||
dashWidth = j["dash_width"];
|
||||
endArrowWidth = j["backward_arrow_width"];
|
||||
startArrowWidth = j["forward_arrow_width"];
|
||||
stroke = j["thickness"];
|
||||
arrowDirection = ArrowDirection.values.firstWhere((element) => element.index == j["direction"]);
|
||||
headRadius = j["head_radius"];
|
||||
color = Color(j["color"]);
|
||||
arrowStyle = ArrowStyle.values.firstWhere((element) => element.index == j["arrow_style"]);
|
||||
tension = j["tension"];
|
||||
startArrow = Position(x: j["start_arrow_position_x"], y: j["start_arrow_position_y"]);
|
||||
endArrow = Position(x: j["end_arrow_position_x"], y: j["end_arrow_position_y"]);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toDashboard() {
|
||||
return {
|
||||
"dash_space": dashSpace,
|
||||
"dash_width": dashWidth,
|
||||
"backward_arrow_width": endArrowWidth,
|
||||
"forward_arrow_width": startArrowWidth,
|
||||
"thickness": stroke,
|
||||
"direction": arrowDirection.index,
|
||||
"head_radius": headRadius,
|
||||
"tail_length": 25.0,
|
||||
"color": int.parse(color.toHexString(), radix: 16),
|
||||
"arrow_style" : arrowStyle.index,
|
||||
"tension" : tension,
|
||||
"start_arrow_position_x": startArrow?.x ?? 0,
|
||||
"start_arrow_position_y": startArrow?.y ?? 0,
|
||||
"end_arrow_position_x": endArrow?.x ?? 0,
|
||||
"end_arrow_position_y": endArrow?.y ?? 0,
|
||||
};
|
||||
}
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return GraphLinkStyle(); }
|
||||
return GraphLinkStyle(
|
||||
color: json.containsKey("color") ? Color(json["color"] as int) : Colors.black,
|
||||
stroke: json.containsKey("stroke") ? double.parse(json["stroke"].toString()) : 0,
|
||||
tension: json.containsKey("tension") ? double.parse(json["tension"].toString()) : 0,
|
||||
headRadius: json.containsKey("head_radius") ? double.parse(json["head_radius"].toString()) : 0,
|
||||
dashWidth: json.containsKey("dash_width") ? double.parse(json["dash_width"].toString()) : 0,
|
||||
dashSpace: json.containsKey("dash_space") ? double.parse(json["dash_space"].toString()) : 0,
|
||||
startArrow: json.containsKey("start_arrow") ? Position().deserialize(json["start_arrow"]) : null,
|
||||
endArrow: json.containsKey("end_arrow") ? Position().deserialize(json["end_arrow"]) : null,
|
||||
arrowDirection: json.containsKey("arrow_direction") ? ArrowDirection.values.firstWhere((el) => el.index == json["arrow_direction"]) : ArrowDirection.forward,
|
||||
arrowStyle: json.containsKey("arrow_style") ? ArrowStyle.values.firstWhere((el) => el.index == json["arrow_style"]) : ArrowStyle.curve,
|
||||
startArrowWidth: json.containsKey("start_arrow_width") ? double.parse(json["start_arrow_width"].toString()) : 0,
|
||||
endArrowWidth: json.containsKey("end_arrow_width") ? double.parse(json["end_arrow_width"].toString()) : 0,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() {
|
||||
var obj = <String, dynamic> {
|
||||
"color" : int.parse(color.toHexString(), radix: 16),
|
||||
"stroke" : stroke,
|
||||
"tension" : tension,
|
||||
"head_radius" : headRadius,
|
||||
"dash_width" : dashWidth,
|
||||
"dash_space" : dashSpace,
|
||||
"arrow_direction" : arrowDirection.index,
|
||||
"arrow_style" : arrowStyle.index,
|
||||
"start_arrow_width" : startArrowWidth,
|
||||
"end_arrow_width" : endArrowWidth,
|
||||
};
|
||||
if (startArrow != null) {
|
||||
obj["start_arrow"] = startArrow!.serialize();
|
||||
}
|
||||
if (endArrow != null) {
|
||||
obj["end_arrow"] = endArrow!.serialize();
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
class GraphItem extends SerializerDeserializer<GraphItem> {
|
||||
String? id;
|
||||
double? width;
|
||||
double? height;
|
||||
Position? position;
|
||||
DataItem? data;
|
||||
ProcessingItem? processing;
|
||||
StorageItem? storage;
|
||||
DataCenterItem? datacenter;
|
||||
WorkflowItem? workflow;
|
||||
|
||||
GraphItem({
|
||||
this.id,
|
||||
this.width,
|
||||
this.height,
|
||||
this.position,
|
||||
this.data,
|
||||
this.processing,
|
||||
this.storage,
|
||||
this.datacenter,
|
||||
this.workflow,
|
||||
});
|
||||
|
||||
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"]);
|
||||
}
|
||||
if (abs.topic == "processing") {
|
||||
processing = ProcessingItem().deserialize(abs.serialize());
|
||||
processing!.model = ResourceModel().deserialize(j["element"]["resource_model"]);
|
||||
}
|
||||
if (abs.topic == "datacenter") {
|
||||
datacenter = DataCenterItem().deserialize(abs.serialize());
|
||||
datacenter!.model = ResourceModel().deserialize(j["element"]["resource_model"]);
|
||||
}
|
||||
if (abs.topic == "storage") {
|
||||
storage = StorageItem().deserialize(abs.serialize());
|
||||
storage!.model = ResourceModel().deserialize(j["element"]["resource_model"]);
|
||||
}
|
||||
if (abs.topic == "workflow") {
|
||||
workflow = WorkflowItem().deserialize(abs.serialize());
|
||||
workflow!.model = ResourceModel().deserialize(j["element"]["resource_model"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toDashboard() {
|
||||
Map<String, dynamic> element = {};
|
||||
for(var el in [data, processing, storage, datacenter, workflow]) {
|
||||
if (el != null && el.getID() != "") {
|
||||
element = el.serialize();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return {
|
||||
"id": id,
|
||||
"x": (position?.x ?? 0),
|
||||
"y": (position?.y ?? 0),
|
||||
"width": width ?? 0,
|
||||
"height": height ?? 0,
|
||||
"element": element,
|
||||
};
|
||||
}
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return GraphItem(); }
|
||||
return GraphItem(
|
||||
id: json.containsKey("id") ? json["id"] : null,
|
||||
width: json.containsKey("width") ? double.parse(json["width"].toString()) : null,
|
||||
height: json.containsKey("height") ? double.parse(json["height"].toString()) : null,
|
||||
position: json.containsKey("position") ? Position().deserialize(json["position"]) : null,
|
||||
data: json.containsKey("data") ? DataItem().deserialize(json["data"]) : null,
|
||||
processing: json.containsKey("processing") ? ProcessingItem().deserialize(json["processing"]) : null,
|
||||
storage: json.containsKey("storage") ? StorageItem().deserialize(json["storage"]) : null,
|
||||
datacenter: json.containsKey("datacenter") ? DataCenterItem().deserialize(json["datacenter"]) : null,
|
||||
workflow: json.containsKey("workflow") ? WorkflowItem().deserialize(json["workflow"]) : null,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() {
|
||||
return {
|
||||
"id": id,
|
||||
"width": width,
|
||||
"height": height,
|
||||
"data": data?.serialize(),
|
||||
"processing": processing?.serialize(),
|
||||
"storage": storage?.serialize(),
|
||||
"datacenter": datacenter?.serialize(),
|
||||
"workflow": workflow?.serialize(),
|
||||
"position": position?.serialize(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class Position extends SerializerDeserializer<Position> {
|
||||
String? id;
|
||||
double? x;
|
||||
double? y;
|
||||
|
||||
Position({
|
||||
this.id,
|
||||
this.x,
|
||||
this.y,
|
||||
});
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return Position(); }
|
||||
return Position(
|
||||
id: json.containsKey("id") ? json["id"] : null,
|
||||
x: json.containsKey("x") ? double.parse(json["x"].toString()) : null,
|
||||
y: json.containsKey("y") ? double.parse(json["y"].toString()) : null,
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"id": id,
|
||||
"x": x,
|
||||
"y": y,
|
||||
};
|
||||
}
|
||||
@@ -1,29 +1,48 @@
|
||||
import 'package:oc_front/models/abstract.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
|
||||
class Workspace extends SerializerDeserializer<Workspace> {
|
||||
String? id;
|
||||
List<dynamic> data;
|
||||
List<dynamic> datacenter;
|
||||
List<dynamic> storage;
|
||||
List<dynamic> computing;
|
||||
String? name;
|
||||
bool? active;
|
||||
List<DataItem> datas;
|
||||
List<DataCenterItem> datacenters;
|
||||
List<StorageItem> storages;
|
||||
List<ProcessingItem> processings;
|
||||
List<WorkflowItem> workflows;
|
||||
|
||||
Workspace({
|
||||
this.id,
|
||||
this.computing = const [],
|
||||
this.data = const [],
|
||||
this.datacenter = const [],
|
||||
this.storage = const [],
|
||||
this.name,
|
||||
this.active = false,
|
||||
this.workflows = const [],
|
||||
this.datas = const [],
|
||||
this.datacenters = const [],
|
||||
this.storages = const [],
|
||||
this.processings = const [],
|
||||
});
|
||||
|
||||
@override deserialize(dynamic json) {
|
||||
try { json = json as Map<String, dynamic>;
|
||||
} catch (e) { return Workspace(); }
|
||||
return Workspace(
|
||||
computing: json.containsKey("computing") ? json["computing"] : [],
|
||||
datacenter: json.containsKey("datacenter") ? json["datacenter"] : [],
|
||||
data: json.containsKey("data") ? json["data"] : [],
|
||||
storage: json.containsKey("storage") ? json["storage"] : [],
|
||||
id: json.containsKey("id") ? json["id"] : null,
|
||||
name: json.containsKey("name") ? json["name"] : null,
|
||||
active: json.containsKey("active") ? json["active"] : false,
|
||||
processings: json.containsKey("processing_resources") ? fromListJson(json["processing_resources"], ProcessingItem()) : [],
|
||||
storages: json.containsKey("storage_resources") ? fromListJson(json["storage_resources"], StorageItem()) : [],
|
||||
datacenters: json.containsKey("datacenter_resources") ? fromListJson(json["datacenter_resources"], DataCenterItem()) : [],
|
||||
datas: json.containsKey("data_resources") ? fromListJson(json["data_resources"], DataItem()) : [],
|
||||
workflows: json.containsKey("workflow_resources") ? fromListJson(json["workflow_resources"], WorkflowItem()) : []
|
||||
);
|
||||
}
|
||||
@override Map<String, dynamic> serialize() => {};
|
||||
@override Map<String, dynamic> serialize() => {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"processings": processings.map((e) => e.id).toList(),
|
||||
"storages": storages.map((e) => e.id).toList(),
|
||||
"datacenters": datacenters.map((e) => e.id).toList(),
|
||||
"datas": datas.map((e) => e.id).toList(),
|
||||
"workflows": workflows.map((e) => e.id).toList(),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user