11@page " /"
2+ @using FlowSynx .Client .Messages .Responses .Metrics .Query
3+
24@attribute [Authorize]
5+ @inject IAccessTokenProvider TokenProvider
6+ @inject IFlowSynxClient FlowSynxClient
7+ @inject ISnackbar SnackBar
8+
9+ <PageTitle >Workflow Dashboard</PageTitle >
10+
11+ <MudContainer MaxWidth =" MaxWidth.ExtraLarge" Class =" pa-6" >
12+ <!-- Header -->
13+ <MudStack Spacing =" 2" Class =" mb-6" >
14+ <MudText Typo =" Typo.h4" Class =" fw-bold" >Workflow Management Dashboard</MudText >
15+ </MudStack >
16+
17+ <!-- Top Stats -->
18+ <MudGrid GutterSize =" 3" >
19+ @foreach ( var stat in Stats )
20+ {
21+ <MudItem xs =" 12" sm =" 6" md =" 3" >
22+ <MudPaper Class =" pa-3 d-flex flex-column align-center elevation-6 stat-card" >
23+ <MudIcon Icon =" @stat.Icon" Size =" Size.Large" Color =" @stat.IconColor" Class =" mb-2" />
24+ <MudText Typo =" Typo.subtitle1" Class =" mb-1" >@stat.Label </MudText >
25+ <MudText Typo =" Typo.h4" Color =" @stat.ValueColor" Class =" fw-bold" >@stat.Value </MudText >
26+ </MudPaper >
27+ </MudItem >
28+ }
29+ </MudGrid >
30+ </MudContainer >
31+
32+ @code {
33+ private SummaryResponse SummaryResponse = new ();
34+
35+ private List <StatCard > Stats => new ()
36+ {
37+ new StatCard
38+ {
39+ Label = " Active Workflows" ,
40+ Value = SummaryResponse .ActiveWorkflows ,
41+ Icon = Icons .Material .Filled .PlayCircle ,
42+ IconColor = Color .Default ,
43+ ValueColor = Color .Default
44+ },
45+ new StatCard
46+ {
47+ Label = " Running Tasks" ,
48+ Value = SummaryResponse .RunningTasks ,
49+ Icon = Icons .Material .Filled .Autorenew ,
50+ IconColor = Color .Default ,
51+ ValueColor = Color .Default
52+ },
53+ new StatCard
54+ {
55+ Label = " Completed Today" ,
56+ Value = SummaryResponse .CompletedToday ,
57+ Icon = Icons .Material .Filled .CheckCircle ,
58+ IconColor = Color .Default ,
59+ ValueColor = Color .Default
60+ },
61+ new StatCard
62+ {
63+ Label = " Failed Workflows" ,
64+ Value = SummaryResponse .FailedWorkflows ,
65+ Icon = Icons .Material .Filled .Error ,
66+ IconColor = Color .Default ,
67+ ValueColor = Color .Default
68+ }
69+ };
70+
71+ protected override async Task OnInitializedAsync ()
72+ {
73+ SummaryResponse = await LoadData (CancellationToken .None );
74+ }
75+
76+ private async Task <SummaryResponse > LoadData (CancellationToken cancellationToken )
77+ {
78+ try
79+ {
80+ var token = string .Empty ;
81+ var accessTokenResult = await TokenProvider .GetAccessTokenAsync ();
82+
83+ if (string .IsNullOrEmpty (accessTokenResult ))
84+ token = " No token available or user not authenticated." ;
85+ else
86+ token = accessTokenResult ;
87+
88+ var authenticationStrategy = new FlowSynx .Client .Authentication .BearerTokenAuthStrategy (token );
89+ FlowSynxClient .SetAuthenticationStrategy (authenticationStrategy );
90+ var result = await FlowSynxClient .Metrics .GetWorkflowSummary (cancellationToken );
91+
92+ if (result .StatusCode != 200 )
93+ {
94+ SnackBar .Add (" Failed to load plugins: Bad response code." , Severity .Error );
95+ return new SummaryResponse ();
96+ }
97+
98+ if (! result .Payload .Succeeded )
99+ {
100+ var errorMessage = string .Join (Environment .NewLine , result .Payload .Messages );
101+ SnackBar .Add ($" Plugin error:\n {errorMessage }" , Severity .Error );
102+ return new SummaryResponse ();
103+ }
3104
4- <PageTitle >Home</PageTitle >
105+ var summaryResult = result .Payload .Data ;
106+ return new SummaryResponse
107+ {
108+ ActiveWorkflows = summaryResult .ActiveWorkflows ,
109+ CompletedToday = summaryResult .CompletedToday ,
110+ FailedWorkflows = summaryResult .FailedWorkflows ,
111+ RunningTasks = summaryResult .RunningTasks
112+ };
113+ }
114+ catch (Exception ex )
115+ {
116+ SnackBar .Add ($" Exception occurred: {ex .Message }" , Severity .Error );
117+ return new SummaryResponse ();
118+ }
119+ }
5120
6- <h1 >Welcome to FlowSynx Console</h1 >
7- Web-based management console for orchestrating, executing, and monitoring workflows via the FlowSynx Workflow Automation API.
121+ private class StatCard
122+ {
123+ public string Label { get ; set ; }
124+ public int Value { get ; set ; }
125+ public string Icon { get ; set ; }
126+ public Color IconColor { get ; set ; }
127+ public Color ValueColor { get ; set ; }
128+ }
129+ }
0 commit comments