This commit is contained in:
parent
21633c69c3
commit
6b42bdb0ef
1 changed files with 34 additions and 13 deletions
|
|
@ -24,7 +24,8 @@ pub struct LineageNode {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub label: String,
|
pub label: String,
|
||||||
pub node_type: LineageNodeType,
|
pub node_type: LineageNodeType,
|
||||||
pub status_color: String,
|
pub status_fill: String,
|
||||||
|
pub status_stroke: String,
|
||||||
pub url: String,
|
pub url: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,8 +94,8 @@ impl LineageGraph {
|
||||||
|
|
||||||
// Add styles for status colors
|
// Add styles for status colors
|
||||||
for node in &self.nodes {
|
for node in &self.nodes {
|
||||||
if !node.status_color.is_empty() {
|
if !node.status_fill.is_empty() {
|
||||||
lines.push(format!(" style {} fill:{}", node.id, node.status_color));
|
lines.push(format!(" style {} fill:{},stroke:{}", node.id, node.status_fill, node.status_stroke));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -117,7 +118,7 @@ impl LineageGraph {
|
||||||
|
|
||||||
/// Map status names to colors for the lineage graph.
|
/// Map status names to colors for the lineage graph.
|
||||||
/// Status names are matched case-insensitively against proto-generated enum names.
|
/// Status names are matched case-insensitively against proto-generated enum names.
|
||||||
pub fn status_to_color(status_name: &str) -> &'static str {
|
pub fn status_to_fill(status_name: &str) -> &'static str {
|
||||||
match status_name.to_lowercase().as_str() {
|
match status_name.to_lowercase().as_str() {
|
||||||
"wantsuccessful" | "partitionlive" | "jobrunsucceeded" => "#dcfce7", // green
|
"wantsuccessful" | "partitionlive" | "jobrunsucceeded" => "#dcfce7", // green
|
||||||
"wantbuilding" | "partitionbuilding" | "jobrunrunning" => "#ede9fe", // blue
|
"wantbuilding" | "partitionbuilding" | "jobrunrunning" => "#ede9fe", // blue
|
||||||
|
|
@ -131,6 +132,20 @@ pub fn status_to_color(status_name: &str) -> &'static str {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn status_to_stroke(status_name: &str) -> &'static str {
|
||||||
|
match status_name.to_lowercase().as_str() {
|
||||||
|
"wantsuccessful" | "partitionlive" | "jobrunsucceeded" => "#22c55e", // green-500
|
||||||
|
"wantbuilding" | "partitionbuilding" | "jobrunrunning" => "#8b5cf6", // violet-500
|
||||||
|
"wantidle" | "jobrunqueued" => "#6b7280", // gray-500
|
||||||
|
"wantfailed" | "partitionfailed" | "jobrunfailed" => "#ef4444", // red-500
|
||||||
|
"wantdepmiss" | "jobrundepmiss" => "#f59e0b", // amber-500
|
||||||
|
"wantupstreamfailed" | "partitionupstreamfailed" => "#ef4444", // red-500
|
||||||
|
"wantcanceled" | "jobruncanceled" => "#4b5563", // gray-600
|
||||||
|
"wantupstreambuilding" | "partitionupstreambuilding" => "#7c3aed", // violet-600
|
||||||
|
_ => "#9ca3af", // gray-400 default
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
// Graph Builder
|
// Graph Builder
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
@ -169,9 +184,10 @@ pub fn build_lineage_graph(
|
||||||
// Add want node
|
// Add want node
|
||||||
graph.add_node(LineageNode {
|
graph.add_node(LineageNode {
|
||||||
id: want_node_id.clone(),
|
id: want_node_id.clone(),
|
||||||
label: truncate_label(want_id, 30),
|
label: truncate_label(want_id, 50),
|
||||||
node_type: LineageNodeType::Want,
|
node_type: LineageNodeType::Want,
|
||||||
status_color: status_to_color(status_name).to_string(),
|
status_fill: status_to_fill(status_name).to_string(),
|
||||||
|
status_stroke: status_to_stroke(status_name).to_string(),
|
||||||
url: format!("/wants/{}", want_id),
|
url: format!("/wants/{}", want_id),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -189,9 +205,10 @@ pub fn build_lineage_graph(
|
||||||
|
|
||||||
graph.add_node(LineageNode {
|
graph.add_node(LineageNode {
|
||||||
id: partition_node_id.clone(),
|
id: partition_node_id.clone(),
|
||||||
label: truncate_label(partition_ref, 25),
|
label: truncate_label(partition_ref, 50),
|
||||||
node_type: LineageNodeType::Partition,
|
node_type: LineageNodeType::Partition,
|
||||||
status_color: status_to_color(&partition_status).to_string(),
|
status_fill: status_to_fill(&partition_status).to_string(),
|
||||||
|
status_stroke: status_to_stroke(&partition_status).to_string(),
|
||||||
url: format!("/partitions/{}", urlencoding::encode(partition_ref)),
|
url: format!("/partitions/{}", urlencoding::encode(partition_ref)),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -217,9 +234,10 @@ pub fn build_lineage_graph(
|
||||||
|
|
||||||
graph.add_node(LineageNode {
|
graph.add_node(LineageNode {
|
||||||
id: job_run_node_id.clone(),
|
id: job_run_node_id.clone(),
|
||||||
label: truncate_label(job_label, 25),
|
label: truncate_label(job_label, 50),
|
||||||
node_type: LineageNodeType::JobRun,
|
node_type: LineageNodeType::JobRun,
|
||||||
status_color: status_to_color(job_status_name).to_string(),
|
status_fill: status_to_fill(job_status_name).to_string(),
|
||||||
|
status_stroke: status_to_stroke(job_status_name).to_string(),
|
||||||
url: format!("/job_runs/{}", job_run.id),
|
url: format!("/job_runs/{}", job_run.id),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -302,7 +320,8 @@ mod tests {
|
||||||
id: "W_beta_want".to_string(),
|
id: "W_beta_want".to_string(),
|
||||||
label: "beta-want".to_string(),
|
label: "beta-want".to_string(),
|
||||||
node_type: LineageNodeType::Want,
|
node_type: LineageNodeType::Want,
|
||||||
status_color: "#22c55e".to_string(),
|
status_fill: "#22c55e".to_string(),
|
||||||
|
status_stroke: "#22c55e".to_string(),
|
||||||
url: "/wants/beta-want".to_string(),
|
url: "/wants/beta-want".to_string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -310,7 +329,8 @@ mod tests {
|
||||||
id: "P_data_beta".to_string(),
|
id: "P_data_beta".to_string(),
|
||||||
label: "data/beta".to_string(),
|
label: "data/beta".to_string(),
|
||||||
node_type: LineageNodeType::Partition,
|
node_type: LineageNodeType::Partition,
|
||||||
status_color: "#22c55e".to_string(),
|
status_fill: "#22c55e".to_string(),
|
||||||
|
status_stroke: "#22c55e".to_string(),
|
||||||
url: "/partitions/data%2Fbeta".to_string(),
|
url: "/partitions/data%2Fbeta".to_string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -318,7 +338,8 @@ mod tests {
|
||||||
id: "JR_beta_job".to_string(),
|
id: "JR_beta_job".to_string(),
|
||||||
label: "//job_beta".to_string(),
|
label: "//job_beta".to_string(),
|
||||||
node_type: LineageNodeType::JobRun,
|
node_type: LineageNodeType::JobRun,
|
||||||
status_color: "#f97316".to_string(),
|
status_fill: "#f97316".to_string(),
|
||||||
|
status_stroke: "#f97316".to_string(),
|
||||||
url: "/job_runs/beta-job".to_string(),
|
url: "/job_runs/beta-job".to_string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue