-
Notifications
You must be signed in to change notification settings - Fork 2
Update/v1.1.0 #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Update/v1.1.0 #11
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| name: Publish NuGet Package | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - uses: actions/setup-dotnet@v3 | ||
| with: | ||
| dotnet-version: '10.0.x' | ||
| - run: dotnet restore | ||
| - run: dotnet build --configuration Release | ||
| - run: dotnet pack --configuration Release | ||
| - run: dotnet nuget push **/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| @page "/admin/backups" | ||
| @using Example.Pages.Admin.Components | ||
| @using PocketBaseSharp.Models | ||
|
|
||
| <AuthorizeView> | ||
| <Authorized> | ||
| <BackupManagement /> | ||
| </Authorized> | ||
| <NotAuthorized> | ||
| <MudCard> | ||
| <MudCardContent> | ||
| <MudText>Access Denied. Please <MudLink Href="/admin/login">login as admin</MudLink>.</MudText> | ||
| </MudCardContent> | ||
| </MudCard> | ||
| </NotAuthorized> | ||
| </AuthorizeView> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| @page "/admin/dashboard" | ||
| @using Example.Pages.Admin.Components | ||
|
|
||
| <AuthorizeView> | ||
| <Authorized> | ||
| <AdminProfile /> | ||
| </Authorized> | ||
| <NotAuthorized> | ||
| <MudCard> | ||
| <MudCardContent> | ||
| <MudText>Access Denied. Please <MudLink Href="/admin/login">login as admin</MudLink>.</MudText> | ||
| </MudCardContent> | ||
| </MudCard> | ||
| </NotAuthorized> | ||
| </AuthorizeView> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| @page "/admin/login" | ||
| @using Example.Pages.Admin.Components | ||
|
|
||
| <AuthorizeView> | ||
| <Authorized> | ||
| <AdminProfile /> | ||
| </Authorized> | ||
| <NotAuthorized> | ||
| <AdminNotLoggedIn /> | ||
| </NotAuthorized> | ||
| </AuthorizeView> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <MudCard> | ||
| <MudCardHeader> | ||
| <CardHeaderContent> | ||
| <MudText Typo="Typo.h6">Admin Login</MudText> | ||
| <MudText Typo="Typo.body1">Default: admin@admin.com / demo123456</MudText> | ||
| </CardHeaderContent> | ||
| </MudCardHeader> | ||
| <MudCardContent> | ||
| <MudTextField @bind-Text="Email" T="string" Label="Admin Email" Variant="Variant.Outlined"></MudTextField> | ||
| <MudTextField @bind-Text="Password" T="string" Label="Admin Password" Variant="Variant.Outlined" InputType="InputType.Password"></MudTextField> | ||
| </MudCardContent> | ||
| <MudCardActions> | ||
| <MudButton EndIcon="@Icons.Material.Filled.Login" Color="Color.Success" OnClick="AdminLoginAsync">Login as Admin</MudButton> | ||
| </MudCardActions> | ||
| </MudCard> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| using Microsoft.AspNetCore.Components.Authorization; | ||
| using Microsoft.AspNetCore.Components; | ||
| using MudBlazor; | ||
| using PocketBaseSharp; | ||
|
|
||
| namespace Example.Pages.Admin.Components | ||
| { | ||
| public partial class AdminNotLoggedIn | ||
| { | ||
| [Inject] | ||
| public NavigationManager NavigationManager { get; set; } = null!; | ||
|
|
||
| [Inject] | ||
| public PocketBase PocketBase { get; set; } = null!; | ||
|
|
||
| [Inject] | ||
| public ISnackbar Snackbar { get; set; } = null!; | ||
|
|
||
| [Inject] | ||
| public AuthenticationStateProvider AuthenticationStateProvider { get; set; } = null!; | ||
|
|
||
| public string? Email { get; set; } | ||
| public string? Password { get; set; } | ||
|
|
||
| protected async Task AdminLoginAsync() | ||
| { | ||
| var valid = CheckInputs(); | ||
| if (valid) | ||
| { | ||
| try | ||
| { | ||
| var result = await PocketBase.Admin.AuthenticateWithPasswordAsync(Email!, Password!); | ||
| if (result.IsSuccess) | ||
| { | ||
| Snackbar.Add("Admin authenticated!", Severity.Success); | ||
| var claims = PocketBaseAuthenticationStateProvider.ParseClaimsFromJwt(result.Value.Token); | ||
| ((PocketBaseAuthenticationStateProvider)AuthenticationStateProvider).MarkUserAsAuthenticated(claims); | ||
| NavigationManager.NavigateTo("/admin/dashboard"); | ||
| } | ||
| else | ||
| { | ||
| Snackbar.Add("Admin authentication failed", Severity.Error); | ||
| } | ||
| } | ||
| catch | ||
| { | ||
| Snackbar.Add("Admin login failed, please check your credentials", Severity.Error); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private bool CheckInputs() | ||
| { | ||
| var emailEmpty = string.IsNullOrWhiteSpace(Email); | ||
| var passwordEmpty = string.IsNullOrWhiteSpace(Password); | ||
|
|
||
| if (emailEmpty || passwordEmpty) | ||
| { | ||
| Snackbar.Add("The Email and Password fields are required.", Severity.Warning); | ||
| return false; | ||
| } | ||
| return true; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| @using PocketBaseSharp.Models | ||
|
|
||
| <MudCard> | ||
| <MudCardHeader> | ||
| <CardHeaderContent> | ||
| <MudText Typo="Typo.h6">Admin Dashboard</MudText> | ||
| </CardHeaderContent> | ||
| </MudCardHeader> | ||
| <MudCardContent> | ||
| <MudText Typo="Typo.body1">Welcome Admin!</MudText> | ||
| <MudStack Class="mt-4" Spacing="2"> | ||
| <MudButton Variant="Variant.Filled" Color="Color.Primary" FullWidth="true" Href="/admin/backups"> | ||
| <MudIcon Icon="@Icons.Material.Filled.Storage" /> | ||
| Backup Management | ||
| </MudButton> | ||
| <MudButton Variant="Variant.Filled" Color="Color.Secondary" FullWidth="true" OnClick="LogoutAsync"> | ||
| <MudIcon Icon="@Icons.Material.Filled.Logout" /> | ||
| Logout | ||
| </MudButton> | ||
| </MudStack> | ||
| </MudCardContent> | ||
| </MudCard> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| using Microsoft.AspNetCore.Components.Authorization; | ||
| using Microsoft.AspNetCore.Components; | ||
| using MudBlazor; | ||
| using PocketBaseSharp; | ||
| using PocketBaseSharp.Extensions; | ||
| using PocketBaseSharp.Models; | ||
|
|
||
| namespace Example.Pages.Admin.Components | ||
| { | ||
| public partial class AdminProfile | ||
| { | ||
| [Inject] | ||
| public NavigationManager NavigationManager { get; set; } = null!; | ||
|
|
||
| [Inject] | ||
| public PocketBase PocketBase { get; set; } = null!; | ||
|
|
||
| [Inject] | ||
| public ISnackbar Snackbar { get; set; } = null!; | ||
|
|
||
| [Inject] | ||
| public AuthenticationStateProvider AuthenticationStateProvider { get; set; } = null!; | ||
|
|
||
| protected AdminModel? _currentAdmin = null; | ||
|
|
||
| protected override async Task OnInitializedAsync() | ||
| { | ||
| var currentAdminResult = await PocketBase.GetCurrentAdminAsync(); | ||
| if (currentAdminResult.IsSuccess) | ||
| { | ||
| _currentAdmin = currentAdminResult.Value; | ||
| } | ||
|
|
||
| await base.OnInitializedAsync(); | ||
| } | ||
|
|
||
| protected async Task LogoutAsync() | ||
| { | ||
| PocketBase.AuthStore.Clear(); | ||
| ((PocketBaseAuthenticationStateProvider)AuthenticationStateProvider).MarkUserAsLoggedOut(); | ||
| Snackbar.Add("Logged out successfully", Severity.Info); | ||
| NavigationManager.NavigateTo("/admin/login"); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| @using PocketBaseSharp | ||
| @using PocketBaseSharp.Models | ||
| @using MudBlazor | ||
| @inject PocketBase PocketBase | ||
| @inject ISnackbar Snackbar | ||
| @inject IDialogService DialogService | ||
|
|
||
| <MudCard> | ||
| <MudCardHeader> | ||
| <CardHeaderContent> | ||
| <MudText Typo="Typo.h6">Database Backup Management</MudText> | ||
| </CardHeaderContent> | ||
| </MudCardHeader> | ||
| <MudCardContent> | ||
| <MudStack Spacing="3"> | ||
| <!-- Create Backup Section --> | ||
| <MudPaper Class="pa-4" Elevation="0" Outlined="true"> | ||
| <MudText Typo="Typo.subtitle1" Class="mb-3">Create New Backup</MudText> | ||
| <MudStack Row="true" Spacing="2" Style="align-items: center;"> | ||
| <MudTextField @bind-Text="BackupName" T="string" Label="Backup Name (optional)" Placeholder="Leave empty for auto-generated name" Variant="Variant.Outlined" Style="flex: 1;"></MudTextField> | ||
| <MudButton Variant="Variant.Filled" Color="Color.Success" OnClick="CreateBackupAsync" Disabled="IsLoading"> | ||
| @if (IsLoading) | ||
| { | ||
| <MudProgressCircular Class="ms-n1" Size="Size.Small" Indeterminate="true" /> | ||
| <MudText Class="ms-2">Creating...</MudText> | ||
| } | ||
| else | ||
| { | ||
| <MudIcon Icon="@Icons.Material.Filled.CloudUpload" /> | ||
| <MudText Class="ms-2">Create Backup</MudText> | ||
| } | ||
| </MudButton> | ||
| </MudStack> | ||
| </MudPaper> | ||
|
|
||
| <!-- Backups List Section --> | ||
| <MudPaper Class="pa-4" Elevation="0" Outlined="true"> | ||
| <MudStack Spacing="2"> | ||
| <MudStack Row="true" Spacing="2" Style="justify-content: space-between; align-items: center;"> | ||
| <MudText Typo="Typo.subtitle1">Available Backups</MudText> | ||
| <MudButton Variant="Variant.Text" Color="Color.Primary" Size="Size.Small" OnClick="RefreshBackupsAsync" Disabled="IsLoading"> | ||
| <MudIcon Icon="@Icons.Material.Filled.Refresh" /> | ||
| Refresh | ||
| </MudButton> | ||
| </MudStack> | ||
|
|
||
| @if (IsLoading && Backups == null) | ||
| { | ||
| <MudProgressLinear Indeterminate="true" /> | ||
| <MudText Align="Align.Center" Class="mt-4">Loading backups...</MudText> | ||
| } | ||
| else if (Backups == null || !Backups.Any()) | ||
| { | ||
| <MudText Class="mt-4">No backups found. Create one to get started.</MudText> | ||
| } | ||
| else | ||
| { | ||
| <MudTable Items="@Backups" Hover="true" Dense="true"> | ||
| <HeaderContent> | ||
| <MudTh>Backup Name</MudTh> | ||
| <MudTh>Size</MudTh> | ||
| <MudTh>Created</MudTh> | ||
| <MudTh>Actions</MudTh> | ||
| </HeaderContent> | ||
| <RowTemplate> | ||
| <MudTd DataLabel="Backup Name">@context.Key</MudTd> | ||
| <MudTd DataLabel="Size">@FormatBytes(context.Size ?? 0)</MudTd> | ||
| <MudTd DataLabel="Created">@context.Modified?.ToString("g")</MudTd> | ||
| <MudTd DataLabel="Actions"> | ||
| <MudStack Row="true" Spacing="1"> | ||
| <MudButton Variant="Variant.Text" Size="Size.Small" Color="Color.Info" OnClick="@(async () => await DownloadBackupAsync(context.Key))"> | ||
| <MudIcon Icon="@Icons.Material.Filled.Download" Size="Size.Small" /> | ||
| </MudButton> | ||
| <MudButton Variant="Variant.Text" Size="Size.Small" Color="Color.Warning" OnClick="@(async () => await RestoreBackupAsync(context.Key))"> | ||
| <MudIcon Icon="@Icons.Material.Filled.Restore" Size="Size.Small" /> | ||
| </MudButton> | ||
| <MudButton Variant="Variant.Text" Size="Size.Small" Color="Color.Error" OnClick="@(async () => await DeleteBackupAsync(context.Key))"> | ||
| <MudIcon Icon="@Icons.Material.Filled.Delete" Size="Size.Small" /> | ||
| </MudButton> | ||
| </MudStack> | ||
| </MudTd> | ||
| </RowTemplate> | ||
| </MudTable> | ||
| } | ||
| </MudStack> | ||
| </MudPaper> | ||
| </MudStack> | ||
| </MudCardContent> | ||
| <MudCardActions> | ||
| <MudButton Href="/admin/dashboard" Variant="Variant.Text">Back to Dashboard</MudButton> | ||
| </MudCardActions> | ||
| </MudCard> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The BaseUrl change from a public hosted instance to localhost (127.0.0.1:8090) will break the demo for users who don't have PocketBase running locally. While this might be intentional for local development, it should be documented in the PR description as a breaking change for the example application, or the value should be configurable via appsettings.json as mentioned in the README at line 65.