Spaces:
Running
Running
Commit ·
b01b49e
1
Parent(s): 13b962e
feat: Upgrade AutoLayoutEngine to support rich node generation (color, status, progress, tags, subgoals, etc.)
Browse filesFiles changed (2)
1 unmodified line2345671 unmodified line910111213143 unmodified lines1819201 unmodified linenamespace FlowAPI.Application.DTOs.AI{public class QuestNodeDto{public string Id { get; set; } = string.Empty;1 unmodified linepublic string? Description { get; set; }public string? DependsOn { get; set; }public string? Condition { get; set; }}public class QuestSchemaDto3 unmodified linespublic List<QuestNodeDto> Nodes { get; set; } = new();}}1 unmodified line2345678910111213141516171819202122232425261 unmodified line2829303132333435363738394041424344454647484950513 unmodified lines555657581 unmodified linenamespace FlowAPI.Application.DTOs.AI{public class QuestAssigneeDto{public string Email { get; set; } = string.Empty;public string DisplayName { get; set; } = string.Empty;public string SharedWithUserId { get; set; } = string.Empty;}public class QuestSubgoalsDto{public int Total { get; set; }public int Done { get; set; }}public class QuestOptionDto{public string Id { get; set; } = string.Empty;public string Label { get; set; } = string.Empty;}public class QuestNodeDto{public string Id { get; set; } = string.Empty;1 unmodified linepublic string? Description { get; set; }public string? DependsOn { get; set; }public string? Condition { get; set; }// Expanded fields to support rich graphspublic string? Type { get; set; }public string? Status { get; set; }public int? Progress { get; set; }public bool? ShowProgress { get; set; }public string? Color { get; set; }public bool? IsPinned { get; set; }public List<string>? Tags { get; set; }public List<QuestAssigneeDto>? Assignees { get; set; }public QuestSubgoalsDto? Subgoals { get; set; }public string? Url { get; set; }public List<QuestOptionDto>? Options { get; set; }public List<string>? SelectedOptions { get; set; }public bool? MultiSelect { get; set; }public object? ResetRule { get; set; }public double? Width { get; set; }public double? Height { get; set; }}public class QuestSchemaDto3 unmodified linespublic List<QuestNodeDto> Nodes { get; set; } = new();}}
93 unmodified lines94959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512614 unmodified lines14114214393 unmodified linesdouble posY = layer * StepY;// Determine visual propertiesstring? nodeColor = null;if (!string.IsNullOrEmpty(node.Condition)){if (node.Condition.Equals("Fail", StringComparison.OrdinalIgnoreCase)){nodeColor = "#ba1a1a"; // Red for Fail paths}else if (node.Condition.Equals("Success", StringComparison.OrdinalIgnoreCase)){nodeColor = "#45a84a"; // Green for Success paths}}response.Nodes.Add(new NodeDto{Id = nodeGuid,Label = node.Label,PosX = posX,PosY = posY,Type = "sketch",State = 0, // PendingDecision = node.Condition,Description = node.Description,Color = nodeColor,IsPinned = false,Width = 160,Height = 80});// 4. Create Edges14 unmodified lines}}}93 unmodified lines94959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118214 unmodified lines19719819920093 unmodified linesdouble posY = layer * StepY;// Determine visual propertiesstring? nodeColor = node.Color;if (string.IsNullOrEmpty(nodeColor) && !string.IsNullOrEmpty(node.Condition)){if (node.Condition.Equals("Fail", StringComparison.OrdinalIgnoreCase)){nodeColor = "pink";}else if (node.Condition.Equals("Success", StringComparison.OrdinalIgnoreCase)){nodeColor = "green";}}// Map Status string to integer State Enum value (Todo = 0, In Progress = 1, Review = 2, Done = 3)int stateVal = 0;if (!string.IsNullOrEmpty(node.Status)){if (node.Status.Equals("Done", StringComparison.OrdinalIgnoreCase)) stateVal = 3;else if (node.Status.Equals("Review", StringComparison.OrdinalIgnoreCase)) stateVal = 2;else if (node.Status.Equals("In Progress", StringComparison.OrdinalIgnoreCase) || node.Status.Equals("Progress", StringComparison.OrdinalIgnoreCase)) stateVal = 1;}// Build rich data object for serialization into Decision columnvar decisionObj = new Dictionary<string, object?>();decisionObj["decision"] = node.Condition;decisionObj["description"] = node.Description ?? "";decisionObj["progress"] = node.Progress ?? 0;decisionObj["showProgress"] = node.ShowProgress ?? false;decisionObj["color"] = nodeColor ?? "default";decisionObj["isPinned"] = node.IsPinned ?? false;decisionObj["tags"] = node.Tags ?? new List<string>();decisionObj["status"] = node.Status ?? "Todo";decisionObj["assignees"] = node.Assignees ?? new List<QuestAssigneeDto>();if (node.Subgoals != null){decisionObj["subgoals"] = new { total = node.Subgoals.Total, done = node.Subgoals.Done };}if (node.Options != null){decisionObj["options"] = node.Options.Select(o => new { id = o.Id, label = o.Label }).ToList();}if (node.SelectedOptions != null){decisionObj["selectedOptions"] = node.SelectedOptions;}if (node.MultiSelect != null){decisionObj["multiSelect"] = node.MultiSelect.Value;}if (node.ResetRule != null){decisionObj["resetRule"] = node.ResetRule;}if (!string.IsNullOrEmpty(node.Url)){decisionObj["url"] = node.Url;}// For image/path/text nodes, save payload inside Data if neededstring? nodeData = null;if (node.Type == "image" && !string.IsNullOrEmpty(node.Url)){nodeData = node.Url;}string decisionJson = System.Text.Json.JsonSerializer.Serialize(decisionObj);response.Nodes.Add(new NodeDto{Id = nodeGuid,Label = node.Label,PosX = posX,PosY = posY,Type = node.Type ?? "sketch",State = stateVal,Decision = decisionJson, // JSON string matches frontend expected parsing!Description = node.Description,Color = nodeColor,IsPinned = node.IsPinned ?? false,Width = node.Width ?? 220,Height = node.Height ?? 116,Data = nodeData});// 4. Create Edges14 unmodified lines}}}
FlowAPI.Application/DTOs/AI/QuestSchemaDto.cs+38
FlowAPI.Application/Services/AutoLayoutEngine.cs+67-10