Skip to content

Commit 492f6f0

Browse files
committed
Show sync status
1 parent 080080e commit 492f6f0

3 files changed

Lines changed: 115 additions & 32 deletions

File tree

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
@using PocketDDD.BlazorClient.Features.EventScore.Store;
2+
@using PocketDDD.BlazorClient.Features.Sync.Components
23

34
@inherits Fluxor.Blazor.Web.Components.FluxorComponent
45

56
@inject IState<EventScoreState> State
67
@inject IDispatcher Dispatcher
8+
@inject IDialogService Dialog
79

810
<MudFab Color="Color.Primary"
911
Size="Size.Large"
1012
Label="@State.Value.Score.ToString()"
11-
Style="position:fixed; right:10px; bottom:10px" />
13+
Style="position:fixed; right:10px; bottom:10px"
14+
OnClick="HandleViewSyncStatus" />
1215

1316
@code {
1417
protected override void OnInitialized()
1518
{
1619
Dispatcher.Dispatch(new FetchExistingEventScoreAction());
1720
base.OnInitialized();
1821
}
22+
23+
void HandleViewSyncStatus()
24+
{
25+
Dialog.Show<SyncStatus>("", new DialogOptions { FullScreen = true });
26+
}
1927
}
Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,79 @@
11
@using PocketDDD.BlazorClient.Features.Sync.Store
2+
@inherits Fluxor.Blazor.Web.Components.FluxorComponent
23

34
@inject IState<SyncState> State
45
@inject IDispatcher Dispatcher
56

6-
<h3>SyncStatus</h3>
7+
<MudDialog>
8+
<TitleContent><h2 class="d-flex justify-center">Sync Status</h2></TitleContent>
9+
<DialogContent>
10+
<MudCard>
11+
<MudCardContent>
12+
<MudText Typo="Typo.caption">Signed in as</MudText>
13+
<MudText Typo="Typo.subtitle1">Name: @State.Value.LoggedInUser.Name</MudText>
14+
<MudText Typo="Typo.subtitle2">Token: @State.Value.LoggedInUser.Token</MudText>
15+
</MudCardContent>
16+
</MudCard>
17+
18+
<MudCard Class="mt-2">
19+
<MudCardContent>
20+
<MudText Typo="Typo.caption">Current Score</MudText>
21+
<MudText Typo="Typo.subtitle1">@State.Value.EventScore</MudText>
22+
</MudCardContent>
23+
</MudCard>
24+
25+
<MudCard Class="mt-2">
26+
<MudCardContent>
27+
<MudText Typo="Typo.caption">Outstanding Sync Items</MudText>
28+
<MudText Typo="Typo.subtitle1">@State.Value.OutstandingSyncItems</MudText>
29+
</MudCardContent>
30+
</MudCard>
31+
32+
@WhenSyncingShowSyncAlert()
33+
34+
</DialogContent>
35+
<DialogActions>
36+
<MudButton
37+
Variant="Variant.Filled"
38+
Color="Color.Primary"
39+
FullWidth="true"
40+
StartIcon="@Icons.Material.Filled.CloudSync"
41+
OnClick="HandleSync">
42+
Sync
43+
</MudButton>
44+
<MudButton
45+
Variant="Variant.Filled"
46+
Color="Color.Secondary"
47+
FullWidth="true"
48+
OnClick="HandleClose">
49+
Close
50+
</MudButton>
51+
</DialogActions>
52+
</MudDialog>
53+
54+
@code {
55+
RenderFragment WhenSyncingShowSyncAlert() =>
56+
State.Value.IsSyncing
57+
? @<MudAlert Class="mt-2" Severity="Severity.Info"> Syncing...</MudAlert>
58+
: null;
59+
}
760

861
@code {
62+
[CascadingParameter] MudDialogInstance MudDialog { get; set; }
63+
964
protected override void OnInitialized()
1065
{
1166
Dispatcher.Dispatch(new SyncAction());
1267
base.OnInitialized();
1368
}
1469

70+
void HandleSync()
71+
{
72+
Dispatcher.Dispatch(new SyncAction());
73+
}
74+
75+
void HandleClose()
76+
{
77+
MudDialog.Cancel();
78+
}
1579
}

PocketDDD.BlazorClient/PocketDDD.BlazorClient/Services/PocketDDDApiService.cs

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using PocketDDD.Shared.API.ResponseDTOs;
1+
using MudBlazor;
2+
using PocketDDD.Shared.API.ResponseDTOs;
23
using PocketDDD.Shared.API.RequestDTOs;
34

45
namespace PocketDDD.BlazorClient.Services;
@@ -49,71 +50,82 @@ public Task<LoginResultDTO> Login(string name)
4950
return Task.FromResult(new LoginResultDTO(name, Guid.NewGuid().ToString()));
5051
}
5152

52-
public Task<EventDataResponseDTO?> FetchLatestEventData(EventDataUpdateRequestDTO request)
53+
public async Task<EventDataResponseDTO?> FetchLatestEventData(EventDataUpdateRequestDTO request)
5354
{
5455
if (request.Version == 1)
55-
return Task.FromResult<EventDataResponseDTO?>(null);
56+
{
57+
await Task.Delay(1000);
58+
return null;
59+
}
5660

57-
return Task.FromResult<EventDataResponseDTO?>(
61+
return
5862
new EventDataResponseDTO
5963
{
6064
Version = 1,
6165
TimeSlots = new[]
6266
{
63-
new TimeSlot{
67+
new TimeSlot
68+
{
6469
Id = 1,
65-
From = new DateTimeOffset(2023,4,29,8,00,0,TimeSpan.Zero),
66-
To= new DateTimeOffset(2023,4,29,8,30,0,TimeSpan.Zero),
70+
From = new DateTimeOffset(2023, 4, 29, 8, 00, 0, TimeSpan.Zero),
71+
To = new DateTimeOffset(2023, 4, 29, 8, 30, 0, TimeSpan.Zero),
6772
Info = "Registration"
6873
},
69-
new TimeSlot{
74+
new TimeSlot
75+
{
7076
Id = 2,
71-
From = new DateTimeOffset(2023,4,29,8,30,0,TimeSpan.Zero),
72-
To= new DateTimeOffset(2023,4,29,9,0,0,TimeSpan.Zero),
77+
From = new DateTimeOffset(2023, 4, 29, 8, 30, 0, TimeSpan.Zero),
78+
To = new DateTimeOffset(2023, 4, 29, 9, 0, 0, TimeSpan.Zero),
7379
Info = "Intro"
7480
},
75-
new TimeSlot{
81+
new TimeSlot
82+
{
7683
Id = 3,
77-
From = new DateTimeOffset(2023,4,29,9,00,0,TimeSpan.Zero),
78-
To = new DateTimeOffset(2023,4,29,10,00,0,TimeSpan.Zero)
84+
From = new DateTimeOffset(2023, 4, 29, 9, 00, 0, TimeSpan.Zero),
85+
To = new DateTimeOffset(2023, 4, 29, 10, 00, 0, TimeSpan.Zero)
7986
},
80-
new TimeSlot{
87+
new TimeSlot
88+
{
8189
Id = 4,
82-
From = new DateTimeOffset(2023,4,29,10,0,0,TimeSpan.Zero),
83-
To = new DateTimeOffset(2023,4,29,10,20,0,TimeSpan.Zero),
90+
From = new DateTimeOffset(2023, 4, 29, 10, 0, 0, TimeSpan.Zero),
91+
To = new DateTimeOffset(2023, 4, 29, 10, 20, 0, TimeSpan.Zero),
8492
Info = "Coffee"
8593
},
86-
new TimeSlot{
94+
new TimeSlot
95+
{
8796
Id = 5,
88-
From = new DateTimeOffset(2023,4,29,10,20,0,TimeSpan.Zero),
89-
To = new DateTimeOffset(2023,4,29,11,20,0,TimeSpan.Zero)
97+
From = new DateTimeOffset(2023, 4, 29, 10, 20, 0, TimeSpan.Zero),
98+
To = new DateTimeOffset(2023, 4, 29, 11, 20, 0, TimeSpan.Zero)
9099
},
91100
},
92101
Tracks = new[]
93102
{
94-
new Track { Id = 1, Name = "Track 1", RoomName = "Room 1"},
95-
new Track { Id = 2, Name = "Track 2", RoomName = "Room 2"},
96-
new Track { Id = 3, Name = "Track 3", RoomName = "Room 3"}
103+
new Track { Id = 1, Name = "Track 1", RoomName = "Room 1" },
104+
new Track { Id = 2, Name = "Track 2", RoomName = "Room 2" },
105+
new Track { Id = 3, Name = "Track 3", RoomName = "Room 3" }
97106
},
98107
Sessions = new[]
99108
{
100-
new Session {
101-
Id = 1,
102-
FullDescription = "Some full desk",
103-
Speaker = "Ross",
109+
new Session
110+
{
111+
Id = 1,
112+
FullDescription = "Some full desk",
113+
Speaker = "Ross",
104114
TimeSlotId = 3,
105115
TrackId = 1,
106116
Title = "Blazor Session Management"
107117
},
108-
new Session {
118+
new Session
119+
{
109120
Id = 2,
110121
FullDescription = "Second session",
111122
Speaker = "Jim",
112123
TimeSlotId = 3,
113124
TrackId = 2,
114125
Title = "How to code"
115126
},
116-
new Session {
127+
new Session
128+
{
117129
Id = 3,
118130
FullDescription = "Third session",
119131
Speaker = "Bob",
@@ -122,8 +134,7 @@ public Task<LoginResultDTO> Login(string name)
122134
Title = "Off by 1"
123135
},
124136
}
125-
}
126-
);
137+
};
127138
}
128139

129140
public Task<FeedbackResponseDTO> SubmitClientEventFeedback(SubmitEventFeedbackDTO feedbackDTO)

0 commit comments

Comments
 (0)