[CHANGE] Adding accounts

This commit is contained in:
max
2025-09-04 10:37:38 +02:00
parent f7bfee5de2
commit a8cfbbe0db
7 changed files with 145 additions and 5 deletions

View File

@@ -1,6 +1,6 @@

<MudNavMenu>
<MudNavLink Href="/" Icon="@Icons.Material.Filled.Home" Match="NavLinkMatch.Prefix">Home</MudNavLink>
<MudNavLink Href="/" Icon="@Icons.Material.Filled.Home" Match="NavLinkMatch.All">Home</MudNavLink>
<MudNavLink Href="/Channels" Icon="@Icons.Material.Filled.SupervisorAccount" Match="NavLinkMatch.All">Channels</MudNavLink>
<MudNavLink Href="/Library" Icon="@Icons.Material.Filled.LocalLibrary" Match="NavLinkMatch.All">Library</MudNavLink>
<MudNavLink Href="/Playlists" Icon="@Icons.Material.Filled.ViewList" Match="NavLinkMatch.All">Playlists</MudNavLink>

View File

@@ -1,3 +1,86 @@
@page "/Channels"
@inject ILibraryService LibraryService
<PageTitle>Channels</PageTitle>
<MudDialog @bind-Visible="@_addAccountDialogVisible" Options="_dialogOptions">
<TitleContent>
<MudText Typo="Typo.h6">Add new account</MudText>
</TitleContent>
<DialogContent>
<MudDataGrid Items="_cookies" Dense Elevation="0" Outlined>
<Header>
<MudStack Class="ma-2">
<MudText>Cookies</MudText>
</MudStack>
<MudStack Row Spacing="2" Class="ma-1">
<MudTooltip Text="Add cookie">
<MudIconButton Icon="@Icons.Material.Filled.Add" Size="Size.Small" Color="Color.Success" OnClick="() => _cookies.Add(new HttpCookie())"/>
</MudTooltip>
<MudTooltip Text="Add from text">
<MudIconButton Icon="@Icons.Material.Filled.InsertDriveFile" Size="Size.Small" Color="Color.Primary" Disabled/>
</MudTooltip>
</MudStack>
</Header>
<Columns>
<TemplateColumn Title="Name">
<CellTemplate>
<MudTextField Variant="Variant.Text" @bind-Value="@context.Item.Name" Immediate/>
</CellTemplate>
</TemplateColumn>
<TemplateColumn Title="Value">
<CellTemplate>
<MudTextField Variant="Variant.Text" @bind-Value="@context.Item.Value" Immediate/>
</CellTemplate>
</TemplateColumn>
<TemplateColumn>
<CellTemplate>
<MudTooltip Text="Remove">
<MudIconButton Size="Size.Small" Icon="@Icons.Material.Filled.Remove" Color="Color.Error" OnClick="() => _cookies.Remove(context.Item)"/>
</MudTooltip>
</CellTemplate>
</TemplateColumn>
</Columns>
</MudDataGrid>
</DialogContent>
<DialogActions>
<MudStack Spacing="2" Row>
<MudButton Color="Color.Error" OnClick="() => _addAccountDialogVisible = false" Variant="Variant.Outlined">Cancel</MudButton>
<MudButton Color="Color.Primary" Variant="Variant.Outlined" Disabled>Save</MudButton>
</MudStack>
</DialogActions>
</MudDialog>
<MudStack Spacing="2">
<MudPaper Elevation="0" Outlined>
<MudStack Row Class="ma-2">
<MudButton IconSize="Size.Small" StartIcon="@Icons.Material.Filled.Add" Variant="Variant.Outlined" OnClick="() => _addAccountDialogVisible = true">Add account</MudButton>
</MudStack>
</MudPaper>
<MudTable ServerData="ServerReload">
<ToolBarContent>
<MudText Typo="Typo.h6">Channels</MudText>
</ToolBarContent>
<HeaderContent>
<MudTh>Name</MudTh>
<MudTh>Channel id</MudTh>
<MudTh>Has login</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd>@context.Name</MudTd>
<MudTd>@context.Id</MudTd>
<MudTd>@(context.ClientAccount != null)</MudTd>
</RowTemplate>
<NoRecordsContent>
<MudText>No channels found</MudText>
</NoRecordsContent>
<LoadingContent>
<MudText>Loading...</MudText>
</LoadingContent>
<PagerContent>
<MudTablePager/>
</PagerContent>
</MudTable>
</MudStack>

View File

@@ -1,7 +1,28 @@
using Manager.Data.Entities.LibraryContext;
using Microsoft.AspNetCore.Components;
using MudBlazor;
namespace Manager.App.Components.Pages;
public partial class Channels : ComponentBase
{
private bool _addAccountDialogVisible;
private DialogOptions _dialogOptions = new() { BackdropClick = false, CloseButton = true, FullWidth = true };
private List<HttpCookie> _cookies = [];
private async Task<TableData<ChannelEntity>> ServerReload(TableState state, CancellationToken token)
{
var results = await LibraryService.GetChannelAccountsAsync(state.Page * state.PageSize, state.PageSize, token);
if (!results.IsSuccess)
{
return new TableData<ChannelEntity>();
}
return new TableData<ChannelEntity> { Items = results.Value, TotalItems = results.Total };
}
}
public record HttpCookie()
{
public string Name { get; set; }
public string Value { get; set; }
}

View File

@@ -1,9 +1,10 @@
using Manager.App.Models.Library;
using Microsoft.AspNetCore.Components;
using MudBlazor;
namespace Manager.App.Components.Pages;
public partial class Library
public partial class Library : ComponentBase
{
private LibraryInformation? _libraryInformation;
private bool _loading;