This commit is contained in:
mr
2024-11-08 13:59:22 +01:00
parent 685badc59a
commit 1ca77b6611
69 changed files with 1601 additions and 1337 deletions

View File

@@ -6,31 +6,31 @@ import 'package:oc_front/models/abstract.dart';
const List<ProcessingItem> _emptyComputing = [];
const List<DataItem> _emptyData = [];
const List<DataCenterItem> _emptyDataCenter = [];
const List<ComputeItem> _emptyCompute = [];
const List<StorageItem> _emptyStorage = [];
class Search extends SerializerDeserializer<Search> {
Search({
this.computing = _emptyComputing,
this.datacenter = _emptyDataCenter,
this.compute = _emptyCompute,
this.data = _emptyData,
this.storage = _emptyStorage,
});
List<ProcessingItem> computing;
List<DataCenterItem> datacenter;
List<ComputeItem> compute;
List<DataItem> data;
List<StorageItem> storage;
@override deserialize(dynamic json) {
json = json as Map<String, dynamic>;
return Search(
computing: json.containsKey("processing") ? fromListJson(json["processing"], ProcessingItem()) : [],
datacenter: json.containsKey("datacenter") ? fromListJson(json["datacenter"], DataCenterItem()) : [],
compute: json.containsKey("compute") ? fromListJson(json["compute"], ComputeItem()) : [],
data: json.containsKey("data") ? fromListJson(json["data"], DataItem()) : [],
storage: json.containsKey("storage") ? fromListJson(json["storage"], StorageItem()) : [],
);
}
@override Map<String, dynamic> serialize() => {
"processing": toListJson<ProcessingItem>(computing),
"datacenter": toListJson<DataCenterItem>(datacenter),
"compute": toListJson<ComputeItem>(compute),
"data": toListJson<DataItem>(data),
"storage": toListJson<StorageItem>(storage),
};
@@ -41,14 +41,14 @@ class Resource implements SerializerDeserializer<Resource> {
List<DataItem> datas = [];
List<ProcessingItem> processings = [];
List<StorageItem> storages = [];
List<DataCenterItem> datacenters = [];
List<ComputeItem> computes = [];
List<WorkflowItem> workflows = [];
Resource({
this.datas = const [],
this.processings = const [],
this.storages = const [],
this.datacenters = const [],
this.computes = const [],
this.workflows = const [],
});
@@ -56,7 +56,7 @@ class Resource implements SerializerDeserializer<Resource> {
try { json = json as Map<String, dynamic>;
} catch (e) { return Resource(); }
return Resource(
datacenters: json.containsKey("datacenter_resource") ? fromListJson(json["datacenter_resource"], DataCenterItem()) : [],
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()) : [],
@@ -66,7 +66,7 @@ class Resource implements SerializerDeserializer<Resource> {
@override Map<String, dynamic> serialize() {
return {
"datacenter_resource": toListJson<DataCenterItem>(datacenters),
"compute_resource": toListJson<ComputeItem>(computes),
"data_resource": toListJson<DataItem>(datas),
"processing_resource": toListJson<ProcessingItem>(processings),
"storage_resource": toListJson<StorageItem>(storages),
@@ -198,7 +198,7 @@ class ResourceModel extends SerializerDeserializer<ResourceModel> {
Type? getTopicType(String topic) {
if (topic == "processing") { return ProcessingItem; }
else if (topic == "data") { return DataItem; }
else if (topic == "datacenter") { return DataCenterItem; }
else if (topic == "compute") { return ComputeItem; }
else if (topic == "storage") { return StorageItem; }
else if (topic == "workflow") { return WorkflowItem; }
else { return null; }
@@ -208,7 +208,7 @@ String getTopic(Type type) {
if (type == AbstractItem) { return "resource"; }
if (type == ProcessingItem) { return "processing"; }
if (type == DataItem) { return "data"; }
if (type == DataCenterItem) { return "datacenter"; }
if (type == ComputeItem) { return "compute"; }
if (type == StorageItem) { return "storage"; }
if (type == WorkflowItem) { return "workflow"; }
return "";
@@ -216,7 +216,7 @@ String getTopic(Type type) {
bool isComputing(String topic) => topic == "processing";
bool isData(String topic) => topic == "data";
bool isDataCenter(String topic) => topic == "datacenter";
bool isCompute(String topic) => topic == "compute";
bool isStorage(String topic) => topic == "storage";
bool isWorkflow(String topic) => topic == "workflow";
@@ -710,8 +710,8 @@ class DataItem extends SerializerDeserializer<DataItem> implements AbstractItem<
};
}
class DataCenterItem extends SerializerDeserializer<DataCenterItem> implements AbstractItem<DataCenterItem> {
DataCenterItem({
class ComputeItem extends SerializerDeserializer<ComputeItem> implements AbstractItem<ComputeItem> {
ComputeItem({
this.id,
this.name,
this.logo,
@@ -728,6 +728,11 @@ class DataCenterItem extends SerializerDeserializer<DataCenterItem> implements A
this.cpus = const [],
this.gpus = const [],
this.ram,
this.technology,
this.access,
this.architecture,
this.localisation,
this.isService = false,
});
@override String? id;
@override String? name;
@@ -735,7 +740,7 @@ class DataCenterItem extends SerializerDeserializer<DataCenterItem> implements A
@override String? source;
@override String? ownerLogo;
@override String? owner;
@override String topic = "datacenter";
@override String topic = "compute";
@override double? price;
@override String? licence;
@override List<dynamic> inputs;
@@ -743,9 +748,14 @@ class DataCenterItem extends SerializerDeserializer<DataCenterItem> implements A
@override String? description;
@override String? shortDescription;
@override ResourceModel? model;
bool isService = false;
String? architecture;
int? access;
String? localisation;
// Special Attributes
List<CPU> cpus = [];
List<GPU> gpus = [];
int? technology;
RAM? ram;
@override String getID() {
return id ?? "";
@@ -763,20 +773,42 @@ class DataCenterItem extends SerializerDeserializer<DataCenterItem> implements A
double? getHeight() {
return height;
}
String getTechnology() {
if (technology == 0) { return "docker"; }
if (technology == 1) { return "kubernetes"; }
if (technology == 2) { return "slurm"; }
if (technology == 3) { return "hardware"; }
if (technology == 4) { return "condor"; }
return "";
}
String getAccess() {
if (access == 0) { return "ssh"; }
if (access == 1) { return "ssh kube api"; }
if (access == 2) { return "ssh slurm"; }
if (access == 3) { return "ssh docker"; }
if (access == 4) { return "opencloud"; }
if (access == 5) { return "vpn"; }
return "";
}
@override deserialize(dynamic json) {
try { json = json as Map<String, dynamic>;
} catch (e) { return DataCenterItem(); }
var w = DataCenterItem(
} catch (e) { return ComputeItem(); }
var w = ComputeItem(
isService: json.containsKey("is_service") ? json["is_service"] : false,
id: json.containsKey("id") ? json["id"] : null,
name: json.containsKey("name") ? json["name"] : null,
logo: json.containsKey("logo") ? json["logo"] : null,
technology: json.containsKey("technology") ? json["technology"] : 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,
access: json.containsKey("access") ? json["access"] : null,
architecture: json.containsKey("architecture") ? json["architecture"] : null,
localisation: json.containsKey("localisation") ? json["localisation"] : null,
inputs: json["inputs"] ?? [],
outputs: json["outputs"] ?? [],
source: json.containsKey("source") ? json["source"] : null,
@@ -785,6 +817,7 @@ class DataCenterItem extends SerializerDeserializer<DataCenterItem> implements A
gpus: json.containsKey("gpus") ? fromListJson(json["gpus"], GPU()) : [],
ram: json.containsKey("ram") ? RAM().deserialize(json["ram"]) : null,
);
print(w.technology);
if (w.logo != null) {
//
var image = Image.network(w.logo!);
@@ -829,12 +862,17 @@ class DataCenterItem extends SerializerDeserializer<DataCenterItem> implements A
"owner": owner,
"owner_logo": ownerLogo,
"price": price,
"is_service": isService,
"licence": licence,
"access": access,
"architecture": architecture,
"localisation": localisation,
"description": description,
"short_description": shortDescription,
"inputs": inputs,
"outputs": outputs,
"source": source,
"technology": technology,
"resource_model": model?.serialize(),
"cpus": toListJson<CPU>(cpus),
"gpus": toListJson<GPU>(gpus),