Skip to content

Commit

Permalink
update diagram func
Browse files Browse the repository at this point in the history
  • Loading branch information
weibaohui committed May 7, 2024
1 parent 412b337 commit 2b6346f
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 15 deletions.
74 changes: 59 additions & 15 deletions BlazorApp/Diagrams/KubeNodeWidget.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@typeparam T
@using Extension
@using Extension.k8s
@using k8s.Models
@inherits BlazorApp.Pages.Common.PageBase

Expand Down Expand Up @@ -45,24 +46,67 @@
</GridCol>
</GridRow>
<GridRow Style="align-items: center" Gutter="8">
<GridCol Span="4">
@if (typeName == "V1Deployment")
{
@if (typeName == "V1Deployment")
{
<GridCol Span="4">
@("deploy")
}
else if (typeName == "V1Pod")
{
</GridCol>
<GridCol Span="20" Style="font-size: 18px">
@{
var item = Node.Item as V1Deployment;
}
@if (item?.IsReady() is true)
{
<Icon Type="heart" Theme="fill" Style="color:#19BE94"/>
}
else
{
<Icon Type="thunderbolt" Theme="fill" Style="color:#f5222d"/>
}
</GridCol>
}
else if (typeName == "V1Pod")
{
<GridCol Span="4">
@("pod")
}
else if (typeName == "V1ReplicaSet")
{
</GridCol>
<GridCol Span="20" Style="font-size: 18px">
@{
var item = Node.Item as V1Pod;
}
@if (item?.IsReady() is true)
{
<Icon Type="heart" Theme="fill" Style="color:#19BE94"/>
}
else
{
<Icon Type="thunderbolt" Theme="fill" Style="color:#f5222d"/>
}
</GridCol>
}
else if (typeName == "V1ReplicaSet")
{
<GridCol Span="4">
@("rs")
}
</GridCol>
<GridCol Span="20" Style="font-size: 18px">
<Icon Type="heart" Theme="fill" Style="color:#f5222d"/>
<Icon Type="heart" Theme="fill" Style="color:#19BE94"/>
</GridCol>
</GridCol>
<GridCol Span="20" Style="font-size: 18px">

@{
var item = Node.Item as V1ReplicaSet;
}
@if (item?.IsReady() is true)
{
<Icon Type="heart" Theme="fill" Style="color:#19BE94"/>
}
else
{
<Icon Type="thunderbolt" Theme="fill" Style="color:#f5222d"/>
}

</GridCol>
}


</GridRow>
</div>
</div>
14 changes: 14 additions & 0 deletions Extension/k8s/DeploymentExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Linq;
using k8s.Models;

namespace Extension.k8s;

public static class DeploymentExtension
{
public static bool IsReady(this V1Deployment deploy)
{
if (deploy.Status?.Conditions == null) return false;

return deploy.Status.Conditions.All(x => x.Status == "True");
}
}
13 changes: 13 additions & 0 deletions Extension/k8s/ReplicaSetExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using k8s.Models;

namespace Extension.k8s;

public static class ReplicaSetExtension
{
public static bool IsReady(this V1ReplicaSet rs)
{
if (rs.Status?.Replicas == 0) return false;

return rs.Status?.Replicas == rs.Status?.ReadyReplicas;
}
}

0 comments on commit 2b6346f

Please sign in to comment.