| | | 1 | | namespace Elsa.Dashboard.Api.Models; |
| | | 2 | | |
| | | 3 | | public record DashboardQuery(string? Range = null, bool IncludeSystem = false); |
| | | 4 | | |
| | | 5 | | public record DashboardOverview |
| | | 6 | | { |
| | | 7 | | public DashboardCapabilityStatus Capability { get; init; } = DashboardCapabilityStatus.Available; |
| | | 8 | | public string? BackendName { get; init; } |
| | | 9 | | public string? EnvironmentName { get; init; } |
| | | 10 | | public DashboardRuntimeStatus Runtime { get; init; } = new(); |
| | | 11 | | public DashboardWorkflowInstanceMetrics WorkflowInstances { get; init; } = new(); |
| | | 12 | | public DashboardDiagnosticsSummary Diagnostics { get; init; } = new(); |
| | | 13 | | public string AppliedRange { get; init; } = DashboardRangeKeys.TwentyFourHours; |
| | | 14 | | public DateTimeOffset From { get; init; } |
| | | 15 | | public DateTimeOffset To { get; init; } |
| | | 16 | | } |
| | | 17 | | |
| | | 18 | | public record DashboardCapabilityStatus |
| | | 19 | | { |
| | 12 | 20 | | public static DashboardCapabilityStatus Available { get; } = new("Available"); |
| | 27 | 21 | | public static DashboardCapabilityStatus NotInstalled { get; } = new("NotInstalled"); |
| | 3 | 22 | | public static DashboardCapabilityStatus Unauthorized { get; } = new("Unauthorized"); |
| | 3 | 23 | | public static DashboardCapabilityStatus Unavailable { get; } = new("Unavailable"); |
| | | 24 | | |
| | 6 | 25 | | public DashboardCapabilityStatus(string status, string? reason = null) |
| | | 26 | | { |
| | 6 | 27 | | Status = status; |
| | 6 | 28 | | Reason = reason; |
| | 6 | 29 | | } |
| | | 30 | | |
| | 20 | 31 | | public string Status { get; init; } |
| | 6 | 32 | | public string? Reason { get; init; } |
| | | 33 | | } |
| | | 34 | | |
| | | 35 | | public record DashboardRuntimeStatus |
| | | 36 | | { |
| | | 37 | | public string Status { get; init; } = DashboardRuntimeStatusKeys.Unavailable; |
| | | 38 | | public bool IsAcceptingWork { get; init; } |
| | | 39 | | public int ActiveExecutionCycleCount { get; init; } |
| | | 40 | | public int IngressSourceCount { get; init; } |
| | | 41 | | public int FailedIngressSourceCount { get; init; } |
| | | 42 | | public DateTimeOffset? PausedAt { get; init; } |
| | | 43 | | public DateTimeOffset? DrainStartedAt { get; init; } |
| | | 44 | | public string? Reason { get; init; } |
| | | 45 | | } |
| | | 46 | | |
| | | 47 | | public record DashboardWorkflowInstanceMetrics |
| | | 48 | | { |
| | | 49 | | public long Running { get; init; } |
| | | 50 | | public long Completed { get; init; } |
| | | 51 | | public long Faulted { get; init; } |
| | | 52 | | public long Suspended { get; init; } |
| | | 53 | | public long Interrupted { get; init; } |
| | | 54 | | public long IncidentBearing { get; init; } |
| | | 55 | | public TimeSpan? AverageDuration { get; init; } |
| | | 56 | | } |
| | | 57 | | |
| | | 58 | | public record DashboardDiagnosticsSummary |
| | | 59 | | { |
| | | 60 | | public DashboardStructuredLogSummary StructuredLogs { get; init; } = new(); |
| | | 61 | | public DashboardConsoleLogSummary ConsoleLogs { get; init; } = new(); |
| | | 62 | | } |
| | | 63 | | |
| | | 64 | | public record DashboardStructuredLogSummary |
| | | 65 | | { |
| | | 66 | | public DashboardCapabilityStatus Capability { get; init; } = DashboardCapabilityStatus.NotInstalled; |
| | | 67 | | public int SourceCount { get; init; } |
| | | 68 | | public int StaleSourceCount { get; init; } |
| | | 69 | | public int RecentErrorOrCriticalCount { get; init; } |
| | | 70 | | public long DroppedWriteCount { get; init; } |
| | | 71 | | public long DroppedEventCount { get; init; } |
| | | 72 | | } |
| | | 73 | | |
| | | 74 | | public record DashboardConsoleLogSummary |
| | | 75 | | { |
| | | 76 | | public DashboardCapabilityStatus Capability { get; init; } = DashboardCapabilityStatus.NotInstalled; |
| | | 77 | | public int SourceCount { get; init; } |
| | | 78 | | public int StaleSourceCount { get; init; } |
| | | 79 | | public int RecentStderrCount { get; init; } |
| | | 80 | | public long DroppedLineCount { get; init; } |
| | | 81 | | } |
| | | 82 | | |
| | | 83 | | public record DashboardFinding |
| | | 84 | | { |
| | | 85 | | public string Id { get; init; } = null!; |
| | | 86 | | public string Severity { get; init; } = DashboardFindingSeverity.Info; |
| | | 87 | | public string Message { get; init; } = null!; |
| | | 88 | | public string? TargetKind { get; init; } |
| | | 89 | | public string? Target { get; init; } |
| | | 90 | | public int Priority { get; init; } |
| | | 91 | | } |
| | | 92 | | |
| | | 93 | | public record DashboardNeedsAttentionResponse |
| | | 94 | | { |
| | | 95 | | public IReadOnlyCollection<DashboardFinding> Findings { get; init; } = []; |
| | | 96 | | public DashboardCapabilityStatus Capability { get; init; } = DashboardCapabilityStatus.Available; |
| | | 97 | | public string AppliedRange { get; init; } = DashboardRangeKeys.TwentyFourHours; |
| | | 98 | | } |
| | | 99 | | |
| | | 100 | | public record DashboardTrendRequest |
| | | 101 | | { |
| | | 102 | | public string? Range { get; init; } |
| | | 103 | | public string? Granularity { get; init; } |
| | | 104 | | public bool IncludeSystem { get; init; } |
| | | 105 | | } |
| | | 106 | | |
| | | 107 | | public record DashboardTrendResponse |
| | | 108 | | { |
| | | 109 | | public IReadOnlyCollection<DashboardTrendBucket> Buckets { get; init; } = []; |
| | | 110 | | public string AppliedRange { get; init; } = DashboardRangeKeys.TwentyFourHours; |
| | | 111 | | public string Granularity { get; init; } = DashboardTrendGranularity.Hour; |
| | | 112 | | public DateTimeOffset From { get; init; } |
| | | 113 | | public DateTimeOffset To { get; init; } |
| | | 114 | | } |
| | | 115 | | |
| | | 116 | | public record DashboardTrendBucket |
| | | 117 | | { |
| | | 118 | | public DateTimeOffset From { get; init; } |
| | | 119 | | public DateTimeOffset To { get; init; } |
| | | 120 | | public long CreatedOrStarted { get; init; } |
| | | 121 | | public long Finished { get; init; } |
| | | 122 | | public long Faulted { get; init; } |
| | | 123 | | public long Suspended { get; init; } |
| | | 124 | | public long IncidentBearing { get; init; } |
| | | 125 | | } |
| | | 126 | | |
| | | 127 | | public record DashboardRecentActivityItem |
| | | 128 | | { |
| | | 129 | | public string InstanceId { get; init; } = null!; |
| | | 130 | | public string DefinitionId { get; init; } = null!; |
| | | 131 | | public string? WorkflowName { get; init; } |
| | | 132 | | public string Status { get; init; } = null!; |
| | | 133 | | public string SubStatus { get; init; } = null!; |
| | | 134 | | public int IncidentCount { get; init; } |
| | | 135 | | public TimeSpan? Duration { get; init; } |
| | | 136 | | public DateTimeOffset CreatedAt { get; init; } |
| | | 137 | | public DateTimeOffset? UpdatedAt { get; init; } |
| | | 138 | | public DateTimeOffset? FinishedAt { get; init; } |
| | | 139 | | } |
| | | 140 | | |
| | | 141 | | public record DashboardRecentActivityResponse |
| | | 142 | | { |
| | | 143 | | public IReadOnlyCollection<DashboardRecentActivityItem> Items { get; init; } = []; |
| | | 144 | | public string AppliedRange { get; init; } = DashboardRangeKeys.TwentyFourHours; |
| | | 145 | | public DateTimeOffset From { get; init; } |
| | | 146 | | public DateTimeOffset To { get; init; } |
| | | 147 | | } |
| | | 148 | | |
| | | 149 | | public record DashboardWorkflowHotspotsRequest |
| | | 150 | | { |
| | | 151 | | public string? Range { get; init; } |
| | | 152 | | public string Metric { get; init; } = DashboardHotspotMetric.Faults; |
| | | 153 | | public int Take { get; init; } = 10; |
| | | 154 | | public bool IncludeSystem { get; init; } |
| | | 155 | | } |
| | | 156 | | |
| | | 157 | | public record DashboardWorkflowHotspotsResponse |
| | | 158 | | { |
| | | 159 | | public IReadOnlyCollection<DashboardHotspot> Items { get; init; } = []; |
| | | 160 | | public string AppliedRange { get; init; } = DashboardRangeKeys.TwentyFourHours; |
| | | 161 | | public string Metric { get; init; } = DashboardHotspotMetric.Faults; |
| | | 162 | | public DateTimeOffset From { get; init; } |
| | | 163 | | public DateTimeOffset To { get; init; } |
| | | 164 | | } |
| | | 165 | | |
| | | 166 | | public record DashboardHotspot |
| | | 167 | | { |
| | | 168 | | public string DefinitionId { get; init; } = null!; |
| | | 169 | | public string? WorkflowName { get; init; } |
| | | 170 | | public long Value { get; init; } |
| | | 171 | | public TimeSpan? AverageDuration { get; init; } |
| | | 172 | | } |
| | | 173 | | |
| | | 174 | | public static class DashboardRangeKeys |
| | | 175 | | { |
| | | 176 | | public const string OneHour = "1h"; |
| | | 177 | | public const string TwentyFourHours = "24h"; |
| | | 178 | | public const string SevenDays = "7d"; |
| | | 179 | | } |
| | | 180 | | |
| | | 181 | | public static class DashboardRuntimeStatusKeys |
| | | 182 | | { |
| | | 183 | | public const string AcceptingWork = "AcceptingWork"; |
| | | 184 | | public const string Paused = "Paused"; |
| | | 185 | | public const string Draining = "Draining"; |
| | | 186 | | public const string Unavailable = "Unavailable"; |
| | | 187 | | } |
| | | 188 | | |
| | | 189 | | public static class DashboardTrendGranularity |
| | | 190 | | { |
| | | 191 | | public const string Minute = "minute"; |
| | | 192 | | public const string Hour = "hour"; |
| | | 193 | | public const string Day = "day"; |
| | | 194 | | } |
| | | 195 | | |
| | | 196 | | public static class DashboardFindingSeverity |
| | | 197 | | { |
| | | 198 | | public const string Info = "Info"; |
| | | 199 | | public const string Warning = "Warning"; |
| | | 200 | | public const string Error = "Error"; |
| | | 201 | | public const string Critical = "Critical"; |
| | | 202 | | public const string Success = "Success"; |
| | | 203 | | } |
| | | 204 | | |
| | | 205 | | public static class DashboardHotspotMetric |
| | | 206 | | { |
| | | 207 | | public const string Faults = "Faults"; |
| | | 208 | | public const string Executions = "Executions"; |
| | | 209 | | public const string Incidents = "Incidents"; |
| | | 210 | | public const string Duration = "Duration"; |
| | | 211 | | } |