Naarfy
Naarfy
CC#
Created by Naarfy on 3/11/2024 in #help
Blazor page reloading after db update ?
Ok I solved it by adding a time buffer "
int timeBuffer = 5;

var groupedComments = comments.GroupBy(c => (DateTime.UtcNow - c.CreatedAt).TotalSeconds > timeBuffer)
.ToDictionary(g => g.Key, g => g.ToList());
int timeBuffer = 5;

var groupedComments = comments.GroupBy(c => (DateTime.UtcNow - c.CreatedAt).TotalSeconds > timeBuffer)
.ToDictionary(g => g.Key, g => g.ToList());
I'm open to suggestions if it's not the right way to go
3 replies
CC#
Created by Naarfy on 3/11/2024 in #help
Blazor page reloading after db update ?
@if (oldComments != null && oldComments.Any())
{
<div>
<h3>Old Comments</h3>
<ul>
@foreach (var comment in oldComments)
{
<li>
<div>
<strong>@comment.Author</strong>
<span>@comment.CreatedAt</span>
</div>
<p>@comment.Content</p>
</li>
}
</ul>
</div>
}

@if (newComments != null && newComments.Any())
{
<div>
<h3>New Comments</h3>
<ul>
@foreach (var comment in newComments)
{
<li>
<div>
<strong>@comment.Author</strong>
<span>@comment.CreatedAt</span>
</div>
<p>@comment.Content</p>
</li>
}
</ul>
</div>
}
@if (oldComments != null && oldComments.Any())
{
<div>
<h3>Old Comments</h3>
<ul>
@foreach (var comment in oldComments)
{
<li>
<div>
<strong>@comment.Author</strong>
<span>@comment.CreatedAt</span>
</div>
<p>@comment.Content</p>
</li>
}
</ul>
</div>
}

@if (newComments != null && newComments.Any())
{
<div>
<h3>New Comments</h3>
<ul>
@foreach (var comment in newComments)
{
<li>
<div>
<strong>@comment.Author</strong>
<span>@comment.CreatedAt</span>
</div>
<p>@comment.Content</p>
</li>
}
</ul>
</div>
}
3 replies
CC#
Created by Naarfy on 3/4/2024 in #help
Blazor - No event handlers associated
The fact that I get random results is what throws me off. I can share my repo here https://github.com/Altho/atbackend/blob/master/atbackend/Components/Pages/NewPost.razor But I don't really see what could cause the issue
5 replies
CC#
Created by Naarfy on 3/4/2024 in #help
Blazor - No event handlers associated
Sometimes, but again, not everytime, I get the error :
Uncaught Error: No interop methods are registered for renderer 1
Uncaught Error: No interop methods are registered for renderer 1
5 replies
CC#
Created by Mekasu0124 on 3/4/2024 in #help
✅ creating a CLI application
Any user will need to download the app, do you mean you want to stream the output of your console to a website ?
27 replies
CC#
Created by Naarfy on 3/4/2024 in #help
Blazor - No event handlers associated
Nevermind it just worked one time when I removed the binding but it failed after. I'd say that if I reboot the server and try again it works fin 2 out of 10 times. I'm really at loss here
5 replies
CC#
Created by Naarfy on 3/4/2024 in #help
Blazor - No event handlers associated
Seems like it's from the /@bind
5 replies
CC#
Created by Naarfy on 3/1/2024 in #help
Converting the Sqlite template to Postgresql
That makes a lot of sense actually, I need to get better at databases, thanks for your help
8 replies
CC#
Created by Naarfy on 3/1/2024 in #help
Converting the Sqlite template to Postgresql
Alright, thanks a lot !
8 replies
CC#
Created by Naarfy on 3/1/2024 in #help
Converting the Sqlite template to Postgresql
Delete all migrations, drop tables and recreate migrations ?
8 replies
CC#
Created by Naarfy on 10/29/2023 in #help
❔ Blazor @bind not triggering update
I added
@rendermode RenderMode.InteractiveServer
@rendermode RenderMode.InteractiveServer
to my page. and it works now. Thank you so much
9 replies
CC#
Created by Naarfy on 10/29/2023 in #help
❔ Blazor @bind not triggering update
Thanks for your reply. I have this
<Router AppAssembly="@typeof(Program).Assembly" AdditionalAssemblies="new[] { typeof(Client._Imports).Assembly }">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
</Router>
<Router AppAssembly="@typeof(Program).Assembly" AdditionalAssemblies="new[] { typeof(Client._Imports).Assembly }">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
</Router>
9 replies
CC#
Created by Naarfy on 10/29/2023 in #help
❔ Blazor @bind not triggering update
I created the template with —interactivity Auto
9 replies
CC#
Created by Naarfy on 10/29/2023 in #help
❔ Blazor @bind not triggering update
I should add that LLM have been completely useless and don't see what's wrong
9 replies
CC#
Created by Naarfy on 10/29/2023 in #help
❔ Blazor @bind not triggering update
<h3>Settings @_username</h3>

<div class="form-group">
<label for="roleSelect">Select Role:</label>
<select class="form-control" id="roleSelect" @bind="_selectedRoleValue" @oninput="OnSelectedRoleChanged">
<option value="">Select a role</option>
@foreach (var role in _allRoles.Where(r => r != "Super Admin"))
{
<option value="@role">@role</option>
}
</select>
@_selectedRoleValue
</div>

@if (!string.IsNullOrEmpty(_selectedRoleValue))
{
<h4>Permissions for selected role: @_selectedRoleValue</h4>
@foreach (var permission in _filteredPermissions)
{
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="@($"permission_{permission.Id}")" @bind="permission.CanCreatePost" />
<label class="form-check-label" for="@($"permission_{permission.Id}")">Create new category.</label>
</div>
}
}

@code {



private string test = "test";

private List<UserPermissions> _userPermissions = new List<UserPermissions>();
private List<UserPermissions> _filteredPermissions = new List<UserPermissions>();
private ApplicationUser _user = default!;
private string? _username;
private IList<string> _allRoles;
private string _selectedRoleValue = string.Empty;
private string? _phoneNumber;

protected override async Task OnInitializedAsync()
{

_user = await UserAccessor.GetRequiredUserAsync();
_username = await UserManager.GetUserNameAsync(_user);

_allRoles = await DbContext.Roles.Select(r => r.Name).ToListAsync();

foreach (var role in _allRoles)
{
var userPermission = await DbContext.UserPermissions
.Include(up => up.Role)
.Where(up => up.Role.Name == role)
.FirstOrDefaultAsync();
<h3>Settings @_username</h3>

<div class="form-group">
<label for="roleSelect">Select Role:</label>
<select class="form-control" id="roleSelect" @bind="_selectedRoleValue" @oninput="OnSelectedRoleChanged">
<option value="">Select a role</option>
@foreach (var role in _allRoles.Where(r => r != "Super Admin"))
{
<option value="@role">@role</option>
}
</select>
@_selectedRoleValue
</div>

@if (!string.IsNullOrEmpty(_selectedRoleValue))
{
<h4>Permissions for selected role: @_selectedRoleValue</h4>
@foreach (var permission in _filteredPermissions)
{
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="@($"permission_{permission.Id}")" @bind="permission.CanCreatePost" />
<label class="form-check-label" for="@($"permission_{permission.Id}")">Create new category.</label>
</div>
}
}

@code {



private string test = "test";

private List<UserPermissions> _userPermissions = new List<UserPermissions>();
private List<UserPermissions> _filteredPermissions = new List<UserPermissions>();
private ApplicationUser _user = default!;
private string? _username;
private IList<string> _allRoles;
private string _selectedRoleValue = string.Empty;
private string? _phoneNumber;

protected override async Task OnInitializedAsync()
{

_user = await UserAccessor.GetRequiredUserAsync();
_username = await UserManager.GetUserNameAsync(_user);

_allRoles = await DbContext.Roles.Select(r => r.Name).ToListAsync();

foreach (var role in _allRoles)
{
var userPermission = await DbContext.UserPermissions
.Include(up => up.Role)
.Where(up => up.Role.Name == role)
.FirstOrDefaultAsync();
9 replies
CC#
Created by Naarfy on 9/12/2023 in #help
✅ finding dotnet 8.0.0-rc.1.23419.4 ?
wow awesome thanks
7 replies
CC#
Created by Naarfy on 9/12/2023 in #help
✅ finding dotnet 8.0.0-rc.1.23419.4 ?
Thanks a lot, I don't know why I thought it was an earlier preview and didn't see the RC
7 replies