Skip to content

Commit

Permalink
Merge pull request #21 from neozhu/improve/offlinemode
Browse files Browse the repository at this point in the history
Optimize Offline Mode for Create, Update, and Delete Operations
  • Loading branch information
neozhu authored Dec 18, 2024
2 parents e7c3921 + 2eac85c commit 64042ff
Show file tree
Hide file tree
Showing 10 changed files with 240 additions and 55 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ By incorporating robust offline capabilities, CleanAspire empowers developers to
version: '3.8'
services:
apiservice:
image: blazordevlab/cleanaspire-api:0.0.49
image: blazordevlab/cleanaspire-api:0.0.50
environment:
- ASPNETCORE_ENVIRONMENT=Development
- AllowedHosts=*
Expand All @@ -108,7 +108,7 @@ services:


webfrontend:
image: blazordevlab/cleanaspire-clientapp:0.0.49
image: blazordevlab/cleanaspire-clientapp:0.0.50
ports:
- "8016:80"
- "8017:443"
Expand Down
2 changes: 1 addition & 1 deletion src/CleanAspire.Api/CleanAspire.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReference Include="Microsoft.Extensions.ApiDescription.Server" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="9.0.0" />
<PackageReference Include="Scalar.AspNetCore" Version="1.2.55" />
<PackageReference Include="Scalar.AspNetCore" Version="1.2.61" />
<PackageReference Include="Scrutor" Version="5.0.2" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.6" />
<PackageReference Include="StrongGrid" Version="0.110.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static async Task<PaginatedResult<TResult>> ProjectToPaginatedDataAsync<T
}
var count = await query.CountAsync(cancellationToken);
var data = await query
.Skip((pageNumber - 1) * pageSize)
.Skip(pageNumber * pageSize)
.Take(pageSize)
.ToListAsync(cancellationToken);

Expand Down
2 changes: 1 addition & 1 deletion src/CleanAspire.ClientApp/CleanAspire.ClientApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.16.0" />
<PackageReference Include="Microsoft.Kiota.Serialization.Multipart" Version="1.16.0" />
<PackageReference Include="Microsoft.Kiota.Serialization.Text" Version="1.16.0" />
<PackageReference Include="MudBlazor" Version="8.0.0-preview.5" />
<PackageReference Include="MudBlazor" Version="8.0.0-preview.6" />
<PackageReference Include="OneOf" Version="3.0.271" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,14 @@
MudDialog.Close(DialogResult.Ok(true));
_saving = false;
},
invalid =>
{
Snackbar.Add(invalid.Message ?? L["Failed validation"], Severity.Error);
_saving = false;
},
error =>
{
Snackbar.Add(L["Failed to create product."], Severity.Error);
Snackbar.Add(error.Message ?? L["Failed to create product."], Severity.Error);
_saving = false;
}
);
Expand Down
12 changes: 3 additions & 9 deletions src/CleanAspire.ClientApp/Pages/Products/Edit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,11 @@
}
private async Task Save()
{
var online = await OnlineStatusInterop.GetOnlineStatusAsync();
if (!online)
{
Snackbar.Add(L["You are offline. Please check your internet connection."], Severity.Error);
return;
}
editForm?.Validate();
if (success == true)
{
_saving = true;
var result = await ApiClientService.ExecuteAsync(() => ApiClient.Products.PutAsync(model));
var result = await ProductServiceProxy.UpdateProductAsync(model);
_saving = result.Match(
ok =>
{
Expand All @@ -121,12 +115,12 @@
},
invalid =>
{
Snackbar.Add(invalid.Message, Severity.Error);
Snackbar.Add(invalid.Message ?? L["Failed validation"], Severity.Error);
return false;
},
error =>
{
Snackbar.Add(error.Message, Severity.Error);
Snackbar.Add(error.Message ?? L["Failed to save."], Severity.Error);
return false;

}
Expand Down
8 changes: 1 addition & 7 deletions src/CleanAspire.ClientApp/Pages/Products/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,6 @@
}
private async Task Delete()
{
var online = await OnlineStatusInterop.GetOnlineStatusAsync();
if (!online)
{
Snackbar.Add(L["You are offline. Please check your internet connection."], Severity.Error);
return;
}
await DialogServiceHelper.ShowConfirmationDialog("delete confirm", L["Are you sure you want to delete the selected items?"], async () =>
{
if (_selectedItems.Any())
Expand All @@ -142,7 +136,7 @@
},
error =>
{
Snackbar.Add(L["Failed to delete selected items."], Severity.Error);
Snackbar.Add(error.Message??L["Failed to delete selected items."], Severity.Error);
});

}
Expand Down
Loading

0 comments on commit 64042ff

Please sign in to comment.