UI debugging + git ignore

This commit is contained in:
mr
2024-08-22 15:46:16 +02:00
parent ceeebfc964
commit 1db9ef0794
26 changed files with 1568 additions and 302 deletions

View File

@@ -1,32 +1,6 @@
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({
@@ -45,7 +19,9 @@ class LogsResult extends SerializerDeserializer<LogsResult> {
);
}
@override Map<String, dynamic> serialize() {
return { };
return {
"result": toListJson(result),
};
}
}
@@ -54,6 +30,7 @@ class Logs extends SerializerDeserializer<Logs> {
List<Log> logs = [];
Logs({
this.level,
this.logs = const [],
});
String getID() {
@@ -65,11 +42,13 @@ class Logs extends SerializerDeserializer<Logs> {
} catch (e) { return Logs(); }
return Logs(
level: json.containsKey("stream") && (json["stream"] as Map<String, dynamic>).containsKey("level") ? json["stream"]["level"] : "",
logs: json.containsKey("values") ? fromListJson(json["values"], Log()) : [],
);
}
@override Map<String, dynamic> serialize() {
return { };
return {
"level": level,
};
}
}
@@ -78,10 +57,12 @@ class Log extends SerializerDeserializer<Log> {
String? message;
String? level;
String? rawMessage;
Map<String, dynamic> map = {};
Log({
this.timestamp,
this.message,
this.rawMessage,
this.level
});
@@ -97,7 +78,7 @@ class Log extends SerializerDeserializer<Log> {
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 ''; })}";
jsonString = "${j["Name"]} : [${j["Namespace"]}] ${j["Status"]} ${j["Progress"]} (${j["Duration"].toString()})\nCreated at ${j["Created"].toString().replaceAllMapped(RegExp(r'\(\w+\)'), (match) { return ''; }).replaceAllMapped(RegExp(r'\+\w+'), (match) { return ''; })}; Started at ${j["Created"].toString().replaceAllMapped(RegExp(r'\(\w+\)'), (match) { return ''; }).replaceAllMapped(RegExp(r'\+\w+'), (match) { return ''; })}";
}
} on JsonFormatException catch (e) { /* */ }
message = jsonString;
@@ -107,10 +88,13 @@ class Log extends SerializerDeserializer<Log> {
@override deserialize(dynamic json) {
try { json = json as List<dynamic>;
} catch (e) { return Log(); }
return Log(
timestamp: json.isNotEmpty ? DateTime.parse(json[0]) : null,
var l = Log(
timestamp: json.isNotEmpty ? DateTime.fromMillisecondsSinceEpoch(int.parse(json[0]) ~/ 1000) : null,
message: json.length > 1 ? getMessage(json[1].toString()) : null,
rawMessage : json.length > 1 ? json[1].toString() : null,
);
l.getMessage(l.message ?? "");
return l;
}
@override Map<String, dynamic> serialize() { return { }; }
}

View File

@@ -15,7 +15,8 @@ Map<Type, SerializerDeserializer> refs = <Type, SerializerDeserializer> {
Workflow: Workflow(),
Resource: Resource(),
WorkflowExecutions: WorkflowExecutions(),
LogResults: LogResults(),
LogsResult: LogsResult(),
Check: Check(),
};
class APIResponse<T extends SerializerDeserializer> {

View File

@@ -1,3 +1,6 @@
import 'dart:async';
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
import 'package:oc_front/models/abstract.dart';
@@ -248,10 +251,21 @@ class ProcessingItem extends SerializerDeserializer<ProcessingItem> implements A
@override String getName() {
return name ?? "";
}
double? width;
double? height;
@override
double? getWidth() {
return width;
}
@override
double? getHeight() {
return height;
}
@override deserialize(dynamic json) {
try { json = json as Map<String, dynamic>;
} catch (e) { return ProcessingItem(); }
return ProcessingItem(
var w = ProcessingItem(
id: json.containsKey("id") ? json["id"] : null,
name: json.containsKey("name") ? json["name"] : null,
logo: json.containsKey("logo") ? json["logo"] : null,
@@ -274,6 +288,19 @@ class ProcessingItem extends SerializerDeserializer<ProcessingItem> implements A
scallingModel: json.containsKey("scalling_model") ? json["scalling_model"] : null,
diskIO: json.containsKey("disk_io") ? json["disk_io"] : null,
);
if (w.logo != null) {
//
var image = Image.network(w.logo!);
image.image
.resolve(const ImageConfiguration())
.addListener(
ImageStreamListener(
(ImageInfo info, bool _) {
w.width = info.image.width.toDouble();
w.height = info.image.height.toDouble();
}));
}
return w;
}
@override Map<String, dynamic> serialize() => {
"id": id,
@@ -336,13 +363,24 @@ class WorkflowItem extends SerializerDeserializer<WorkflowItem> implements Abstr
return id ?? "";
}
double? width;
double? height;
@override
double? getWidth() {
return width;
}
@override
double? getHeight() {
return height;
}
@override String getName() {
return name ?? "";
}
@override deserialize(dynamic json) {
try { json = json as Map<String, dynamic>;
} catch (e) { return WorkflowItem(); }
return WorkflowItem(
var w = WorkflowItem(
id: json.containsKey("id") ? json["id"] : null,
name: json.containsKey("name") ? json["name"] : null,
logo: json.containsKey("logo") ? json["logo"] : null,
@@ -358,6 +396,19 @@ class WorkflowItem extends SerializerDeserializer<WorkflowItem> implements Abstr
model: json.containsKey("resource_model") ? ResourceModel().deserialize(json["resource_model"]) : null,
workflowID: json.containsKey("workflow_id") ? json["workflow_id"] : null,
);
if (w.logo != null) {
//
var image = Image.network(w.logo!);
image.image
.resolve(const ImageConfiguration())
.addListener(
ImageStreamListener(
(ImageInfo info, bool _) {
w.width = info.image.width.toDouble();
w.height = info.image.height.toDouble();
}));
}
return w;
}
@override Map<String, dynamic> serialize() => {
"id": id,
@@ -420,10 +471,21 @@ class DataItem extends SerializerDeserializer<DataItem> implements AbstractItem<
@override String getID() {
return id ?? "";
}
double? width;
double? height;
@override
double? getWidth() {
return width;
}
@override
double? getHeight() {
return height;
}
@override deserialize(dynamic json) {
try { json = json as Map<String, dynamic>;
} catch (e) { return DataItem(); }
return DataItem(
var w = DataItem(
id: json.containsKey("id") ? json["id"] : null,
name: json.containsKey("name") ? json["name"] : null,
logo: json.containsKey("logo") ? json["logo"] : null,
@@ -441,6 +503,19 @@ class DataItem extends SerializerDeserializer<DataItem> implements AbstractItem<
dataType: json.containsKey("data_type") ? json["data_type"] : null,
exemple: json.containsKey("exemple") ? json["exemple"] : null,
);
if (w.logo != null) {
//
var image = Image.network(w.logo!);
image.image
.resolve(const ImageConfiguration())
.addListener(
ImageStreamListener(
(ImageInfo info, bool _) {
w.width = info.image.width.toDouble();
w.height = info.image.height.toDouble();
}));
}
return w;
}
@override Map<String, dynamic> serialize() => {
"id": id,
@@ -505,10 +580,21 @@ class DataCenterItem extends SerializerDeserializer<DataCenterItem> implements A
@override String getName() {
return name ?? "";
}
double? width;
double? height;
@override
double? getWidth() {
return width;
}
@override
double? getHeight() {
return height;
}
@override deserialize(dynamic json) {
try { json = json as Map<String, dynamic>;
} catch (e) { return DataCenterItem(); }
return DataCenterItem(
var w = DataCenterItem(
id: json.containsKey("id") ? json["id"] : null,
name: json.containsKey("name") ? json["name"] : null,
logo: json.containsKey("logo") ? json["logo"] : null,
@@ -526,6 +612,19 @@ class DataCenterItem extends SerializerDeserializer<DataCenterItem> implements A
gpus: json.containsKey("gpus") ? fromListJson(json["gpus"], GPU()) : [],
ram: json.containsKey("ram") ? RAM().deserialize(json["ram"]) : null,
);
if (w.logo != null) {
//
var image = Image.network(w.logo!);
image.image
.resolve(const ImageConfiguration())
.addListener(
ImageStreamListener(
(ImageInfo info, bool _) {
w.width = info.image.width.toDouble();
w.height = info.image.height.toDouble();
}));
}
return w;
}
@override Map<String, dynamic> serialize() => {
"id": id,
@@ -680,10 +779,20 @@ class StorageItem extends SerializerDeserializer<StorageItem> implements Abstrac
@override String getID() {
return id ?? "";
}
double? width;
double? height;
@override
double? getWidth() {
return width;
}
@override
double? getHeight() {
return height;
}
@override deserialize(dynamic json) {
try { json = json as Map<String, dynamic>;
} catch (e) { return StorageItem(); }
return StorageItem(
var w = StorageItem(
id: json.containsKey("id") ? json["id"] : null,
name: json.containsKey("name") ? json["name"] : null,
logo: json.containsKey("logo") ? json["logo"] : null,
@@ -705,6 +814,19 @@ class StorageItem extends SerializerDeserializer<StorageItem> implements Abstrac
redundancy: json.containsKey("redundancy") ? json["redundancy"] : null,
throughput: json.containsKey("throughput") ? json["throughput"] : null,
);
if (w.logo != null) {
//
var image = Image.network(w.logo!);
image.image
.resolve(const ImageConfiguration())
.addListener(
ImageStreamListener(
(ImageInfo info, bool _) {
w.width = info.image.width.toDouble();
w.height = info.image.height.toDouble();
}));
}
return w;
}
@override Map<String, dynamic> serialize() => {
"id": id,

View File

@@ -3,8 +3,31 @@ 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/logs.dart';
import 'package:oc_front/models/search.dart';
class Check extends SerializerDeserializer<Check> {
bool is_available = false;
Check({
this.is_available = false,
});
@override deserialize(dynamic json) {
try { json = json as Map<String, dynamic>;
} catch (e) { return Check(); }
return Check(
is_available: json.containsKey("is_available") ? json["is_available"] : false,
);
}
@override Map<String, dynamic> serialize() {
return {
"is_available": is_available,
};
}
}
class WorkflowExecutions extends SerializerDeserializer<WorkflowExecutions> {
List<WorkflowExecution> executions = [];
String? executionData;
@@ -36,6 +59,8 @@ class WorkflowExecution extends SerializerDeserializer<WorkflowExecution> {
String? endDate;
int? status;
String? workflowId;
List<Log>? logs;
WorkflowExecution({
@@ -83,6 +108,7 @@ class Workflow extends SerializerDeserializer<Workflow> {
List<dynamic> workflows;
Graph? graph;
Scheduler? schedule;
bool scheduleActive = false;
Workflow({
this.id,
@@ -94,6 +120,7 @@ class Workflow extends SerializerDeserializer<Workflow> {
this.workflows = const [],
this.graph,
this.schedule,
this.scheduleActive = false,
});
String getID() {
@@ -110,6 +137,7 @@ class Workflow extends SerializerDeserializer<Workflow> {
processing: json.containsKey("processings") ? json["processings"] : [],
datacenter: json.containsKey("datacenters") ? json["datacenters"] : [],
data: json.containsKey("datas") ? json["datas"] : [],
scheduleActive: json.containsKey("schedule_active") ? json["schedule_active"] : false,
storage: json.containsKey("storages") ? json["storages"] : [],
graph: json.containsKey("graph") ? Graph().deserialize(json["graph"]) : null,
schedule: json.containsKey("schedule") ? Scheduler().deserialize(json["schedule"]) : null,
@@ -124,6 +152,7 @@ class Workflow extends SerializerDeserializer<Workflow> {
"storages": storage,
"processings": processing,
"workflows": workflows,
"schedule_active": scheduleActive,
"schedule": schedule?.serialize(),
};
if (graph != null) {
@@ -135,6 +164,7 @@ class Workflow extends SerializerDeserializer<Workflow> {
void fromDashboard(Map<String, dynamic> j) {
id = j["id"];
name = j["name"];
scheduleActive = j["schedule_active"];
if (j.containsKey("graph")) {
graph = Graph();
graph!.fromDashboard(j["graph"]);
@@ -149,6 +179,7 @@ class Workflow extends SerializerDeserializer<Workflow> {
"id": id,
"name": name,
"graph": graph?.toDashboard(),
"schedule_active": scheduleActive,
"schedule": schedule?.toDashboard(),
};
}
@@ -160,13 +191,15 @@ class Scheduler extends SerializerDeserializer<Scheduler> {
String? cron;
DateTime? start;
DateTime? end;
int? mode;
Scheduler({
this.id,
this.name,
this.cron,
this.start,
this.end
this.end,
this.mode,
});
void fromDashboard(Map<String, dynamic> j) {
@@ -177,13 +210,14 @@ class Scheduler extends SerializerDeserializer<Scheduler> {
if (j.containsKey("end") && j["end"] != null) {
end = DateTime.parse(j["end"]);
}
mode = int.parse(j["mode"].toString());
}
Map<String, dynamic> toDashboard() {
return {
"id": id,
"name": name,
"cron": cron,
"mode": int.parse(mode.toString()),
"start": start?.toIso8601String(),
"end": end?.toIso8601String(),
};
@@ -196,6 +230,7 @@ class Scheduler extends SerializerDeserializer<Scheduler> {
id: json.containsKey("id") ? json["id"] : null,
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,
);
@@ -204,6 +239,7 @@ class Scheduler extends SerializerDeserializer<Scheduler> {
"id": id,
"name": name,
"cron": cron ?? "",
"mode": int.parse(mode.toString()),
"start": start?.toIso8601String(),
"end": end?.toIso8601String(),
};