Spaces:
Sleeping
Sleeping
Commit ·
b01b49e
1
Parent(s): 13b962e
feat: Upgrade AutoLayoutEngine to support rich node generation (color, status, progress, tags, subgoals, etc.)
Browse files
FlowAPI.Application/DTOs/AI/QuestSchemaDto.cs
CHANGED
|
@@ -2,6 +2,25 @@ using System.Collections.Generic;
|
|
| 2 |
|
| 3 |
namespace FlowAPI.Application.DTOs.AI
|
| 4 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
public class QuestNodeDto
|
| 6 |
{
|
| 7 |
public string Id { get; set; } = string.Empty;
|
|
@@ -9,6 +28,24 @@ namespace FlowAPI.Application.DTOs.AI
|
|
| 9 |
public string? Description { get; set; }
|
| 10 |
public string? DependsOn { get; set; }
|
| 11 |
public string? Condition { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
}
|
| 13 |
|
| 14 |
public class QuestSchemaDto
|
|
@@ -18,3 +55,4 @@ namespace FlowAPI.Application.DTOs.AI
|
|
| 18 |
public List<QuestNodeDto> Nodes { get; set; } = new();
|
| 19 |
}
|
| 20 |
}
|
|
|
|
|
|
| 2 |
|
| 3 |
namespace FlowAPI.Application.DTOs.AI
|
| 4 |
{
|
| 5 |
+
public class QuestAssigneeDto
|
| 6 |
+
{
|
| 7 |
+
public string Email { get; set; } = string.Empty;
|
| 8 |
+
public string DisplayName { get; set; } = string.Empty;
|
| 9 |
+
public string SharedWithUserId { get; set; } = string.Empty;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
public class QuestSubgoalsDto
|
| 13 |
+
{
|
| 14 |
+
public int Total { get; set; }
|
| 15 |
+
public int Done { get; set; }
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
public class QuestOptionDto
|
| 19 |
+
{
|
| 20 |
+
public string Id { get; set; } = string.Empty;
|
| 21 |
+
public string Label { get; set; } = string.Empty;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
public class QuestNodeDto
|
| 25 |
{
|
| 26 |
public string Id { get; set; } = string.Empty;
|
|
|
|
| 28 |
public string? Description { get; set; }
|
| 29 |
public string? DependsOn { get; set; }
|
| 30 |
public string? Condition { get; set; }
|
| 31 |
+
|
| 32 |
+
// Expanded fields to support rich graphs
|
| 33 |
+
public string? Type { get; set; }
|
| 34 |
+
public string? Status { get; set; }
|
| 35 |
+
public int? Progress { get; set; }
|
| 36 |
+
public bool? ShowProgress { get; set; }
|
| 37 |
+
public string? Color { get; set; }
|
| 38 |
+
public bool? IsPinned { get; set; }
|
| 39 |
+
public List<string>? Tags { get; set; }
|
| 40 |
+
public List<QuestAssigneeDto>? Assignees { get; set; }
|
| 41 |
+
public QuestSubgoalsDto? Subgoals { get; set; }
|
| 42 |
+
public string? Url { get; set; }
|
| 43 |
+
public List<QuestOptionDto>? Options { get; set; }
|
| 44 |
+
public List<string>? SelectedOptions { get; set; }
|
| 45 |
+
public bool? MultiSelect { get; set; }
|
| 46 |
+
public object? ResetRule { get; set; }
|
| 47 |
+
public double? Width { get; set; }
|
| 48 |
+
public double? Height { get; set; }
|
| 49 |
}
|
| 50 |
|
| 51 |
public class QuestSchemaDto
|
|
|
|
| 55 |
public List<QuestNodeDto> Nodes { get; set; } = new();
|
| 56 |
}
|
| 57 |
}
|
| 58 |
+
|
FlowAPI.Application/Services/AutoLayoutEngine.cs
CHANGED
|
@@ -94,33 +94,89 @@ namespace FlowAPI.Application.Services
|
|
| 94 |
double posY = layer * StepY;
|
| 95 |
|
| 96 |
// Determine visual properties
|
| 97 |
-
string? nodeColor =
|
| 98 |
-
if (!string.IsNullOrEmpty(node.Condition))
|
| 99 |
{
|
| 100 |
if (node.Condition.Equals("Fail", StringComparison.OrdinalIgnoreCase))
|
| 101 |
{
|
| 102 |
-
nodeColor = "
|
| 103 |
}
|
| 104 |
else if (node.Condition.Equals("Success", StringComparison.OrdinalIgnoreCase))
|
| 105 |
{
|
| 106 |
-
nodeColor = "
|
| 107 |
}
|
| 108 |
}
|
| 109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
response.Nodes.Add(new NodeDto
|
| 111 |
{
|
| 112 |
Id = nodeGuid,
|
| 113 |
Label = node.Label,
|
| 114 |
PosX = posX,
|
| 115 |
PosY = posY,
|
| 116 |
-
Type = "sketch",
|
| 117 |
-
State =
|
| 118 |
-
Decision =
|
| 119 |
Description = node.Description,
|
| 120 |
Color = nodeColor,
|
| 121 |
-
IsPinned = false,
|
| 122 |
-
Width =
|
| 123 |
-
Height =
|
|
|
|
| 124 |
});
|
| 125 |
|
| 126 |
// 4. Create Edges
|
|
@@ -141,3 +197,4 @@ namespace FlowAPI.Application.Services
|
|
| 141 |
}
|
| 142 |
}
|
| 143 |
}
|
|
|
|
|
|
| 94 |
double posY = layer * StepY;
|
| 95 |
|
| 96 |
// Determine visual properties
|
| 97 |
+
string? nodeColor = node.Color;
|
| 98 |
+
if (string.IsNullOrEmpty(nodeColor) && !string.IsNullOrEmpty(node.Condition))
|
| 99 |
{
|
| 100 |
if (node.Condition.Equals("Fail", StringComparison.OrdinalIgnoreCase))
|
| 101 |
{
|
| 102 |
+
nodeColor = "pink";
|
| 103 |
}
|
| 104 |
else if (node.Condition.Equals("Success", StringComparison.OrdinalIgnoreCase))
|
| 105 |
{
|
| 106 |
+
nodeColor = "green";
|
| 107 |
}
|
| 108 |
}
|
| 109 |
|
| 110 |
+
// Map Status string to integer State Enum value (Todo = 0, In Progress = 1, Review = 2, Done = 3)
|
| 111 |
+
int stateVal = 0;
|
| 112 |
+
if (!string.IsNullOrEmpty(node.Status))
|
| 113 |
+
{
|
| 114 |
+
if (node.Status.Equals("Done", StringComparison.OrdinalIgnoreCase)) stateVal = 3;
|
| 115 |
+
else if (node.Status.Equals("Review", StringComparison.OrdinalIgnoreCase)) stateVal = 2;
|
| 116 |
+
else if (node.Status.Equals("In Progress", StringComparison.OrdinalIgnoreCase) || node.Status.Equals("Progress", StringComparison.OrdinalIgnoreCase)) stateVal = 1;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
// Build rich data object for serialization into Decision column
|
| 120 |
+
var decisionObj = new Dictionary<string, object?>();
|
| 121 |
+
decisionObj["decision"] = node.Condition;
|
| 122 |
+
decisionObj["description"] = node.Description ?? "";
|
| 123 |
+
decisionObj["progress"] = node.Progress ?? 0;
|
| 124 |
+
decisionObj["showProgress"] = node.ShowProgress ?? false;
|
| 125 |
+
decisionObj["color"] = nodeColor ?? "default";
|
| 126 |
+
decisionObj["isPinned"] = node.IsPinned ?? false;
|
| 127 |
+
decisionObj["tags"] = node.Tags ?? new List<string>();
|
| 128 |
+
decisionObj["status"] = node.Status ?? "Todo";
|
| 129 |
+
decisionObj["assignees"] = node.Assignees ?? new List<QuestAssigneeDto>();
|
| 130 |
+
|
| 131 |
+
if (node.Subgoals != null)
|
| 132 |
+
{
|
| 133 |
+
decisionObj["subgoals"] = new { total = node.Subgoals.Total, done = node.Subgoals.Done };
|
| 134 |
+
}
|
| 135 |
+
if (node.Options != null)
|
| 136 |
+
{
|
| 137 |
+
decisionObj["options"] = node.Options.Select(o => new { id = o.Id, label = o.Label }).ToList();
|
| 138 |
+
}
|
| 139 |
+
if (node.SelectedOptions != null)
|
| 140 |
+
{
|
| 141 |
+
decisionObj["selectedOptions"] = node.SelectedOptions;
|
| 142 |
+
}
|
| 143 |
+
if (node.MultiSelect != null)
|
| 144 |
+
{
|
| 145 |
+
decisionObj["multiSelect"] = node.MultiSelect.Value;
|
| 146 |
+
}
|
| 147 |
+
if (node.ResetRule != null)
|
| 148 |
+
{
|
| 149 |
+
decisionObj["resetRule"] = node.ResetRule;
|
| 150 |
+
}
|
| 151 |
+
if (!string.IsNullOrEmpty(node.Url))
|
| 152 |
+
{
|
| 153 |
+
decisionObj["url"] = node.Url;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
// For image/path/text nodes, save payload inside Data if needed
|
| 157 |
+
string? nodeData = null;
|
| 158 |
+
if (node.Type == "image" && !string.IsNullOrEmpty(node.Url))
|
| 159 |
+
{
|
| 160 |
+
nodeData = node.Url;
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
string decisionJson = System.Text.Json.JsonSerializer.Serialize(decisionObj);
|
| 164 |
+
|
| 165 |
response.Nodes.Add(new NodeDto
|
| 166 |
{
|
| 167 |
Id = nodeGuid,
|
| 168 |
Label = node.Label,
|
| 169 |
PosX = posX,
|
| 170 |
PosY = posY,
|
| 171 |
+
Type = node.Type ?? "sketch",
|
| 172 |
+
State = stateVal,
|
| 173 |
+
Decision = decisionJson, // JSON string matches frontend expected parsing!
|
| 174 |
Description = node.Description,
|
| 175 |
Color = nodeColor,
|
| 176 |
+
IsPinned = node.IsPinned ?? false,
|
| 177 |
+
Width = node.Width ?? 220,
|
| 178 |
+
Height = node.Height ?? 116,
|
| 179 |
+
Data = nodeData
|
| 180 |
});
|
| 181 |
|
| 182 |
// 4. Create Edges
|
|
|
|
| 197 |
}
|
| 198 |
}
|
| 199 |
}
|
| 200 |
+
|