Finished enqueue site

This commit is contained in:
2025-11-30 11:52:48 +01:00
parent 2cb06c5154
commit ad7c50a988
66 changed files with 457 additions and 60023 deletions

View File

@@ -6,7 +6,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<base href="/"/>
<ResourcePreloader/>
<link rel="stylesheet" href="@Assets["lib/bootstrap/dist/css/bootstrap.min.css"]"/>
<link rel="stylesheet" href="@Assets["app.css"]"/>
<link rel="stylesheet" href="@Assets["SpotiParty.Web.styles.css"]"/>
<ImportMap/>

View File

@@ -0,0 +1,31 @@
@using SpotifyAPI.Web
<div class="track" @onclick="HandleClick">
<img src=@Img alt="Cover">
<div class="track-info">
<span class="track-name">@Name</span>
<span class="track-artists">@Artists</span>
</div>
<span class="track-duration">@Duration</span>
</div>
@code {
[Parameter]
public required FullTrack Track { get; set; }
[Parameter]
public EventCallback<FullTrack> OnClick { get; set; }
public string Img => Track.Album.Images.First().Url;
public string Name => Track.Name;
public string Artists => string.Join(", ", Track.Artists.Select(a => a.Name));
public string Duration => TimeSpan.FromMilliseconds(Track.DurationMs).ToString(@"mm\:ss");
private async Task HandleClick() {
if (OnClick.HasDelegate) {
await OnClick.InvokeAsync(Track);
}
}
}

View File

@@ -0,0 +1,39 @@
.track {
display: flex;
flex-direction: row;
margin: 0.5rem;
gap: 0.5rem;
height: 50px;
}
track, track * {
cursor: default !important;
}
.track img {
aspect-ratio: 1/1;
height: 100%;
}
.track-info {
display: flex;
flex-direction: column;
flex: 1;
min-width: 0;
}
.track-info span {
text-align: left;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.track-name {
font-weight: bold;
}
.track-duration {
margin-left: auto;
margin-block: auto;
}

View File

@@ -1,23 +0,0 @@
@inherits LayoutComponentBase
<div class="page">
<div class="sidebar">
<NavMenu/>
</div>
<main>
<div class="top-row px-4">
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
</div>
<article class="content px-4">
@Body
</article>
</main>
</div>
<div id="blazor-error-ui" data-nosnippet>
An unhandled error has occurred.
<a href="." class="reload">Reload</a>
<span class="dismiss">🗙</span>
</div>

View File

@@ -1,98 +0,0 @@
.page {
position: relative;
display: flex;
flex-direction: column;
}
main {
flex: 1;
}
.sidebar {
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
}
.top-row {
background-color: #f7f7f7;
border-bottom: 1px solid #d6d5d5;
justify-content: flex-end;
height: 3.5rem;
display: flex;
align-items: center;
}
.top-row ::deep a, .top-row ::deep .btn-link {
white-space: nowrap;
margin-left: 1.5rem;
text-decoration: none;
}
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
text-decoration: underline;
}
.top-row ::deep a:first-child {
overflow: hidden;
text-overflow: ellipsis;
}
@media (max-width: 640.98px) {
.top-row {
justify-content: space-between;
}
.top-row ::deep a, .top-row ::deep .btn-link {
margin-left: 0;
}
}
@media (min-width: 641px) {
.page {
flex-direction: row;
}
.sidebar {
width: 250px;
height: 100vh;
position: sticky;
top: 0;
}
.top-row {
position: sticky;
top: 0;
z-index: 1;
}
.top-row.auth ::deep a:first-child {
flex: 1;
text-align: right;
width: 0;
}
.top-row, article {
padding-left: 2rem !important;
padding-right: 1.5rem !important;
}
}
#blazor-error-ui {
color-scheme: light only;
background: lightyellow;
bottom: 0;
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
box-sizing: border-box;
display: none;
left: 0;
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
position: fixed;
width: 100%;
z-index: 1000;
}
#blazor-error-ui .dismiss {
cursor: pointer;
position: absolute;
right: 0.75rem;
top: 0.5rem;
}

View File

@@ -1,29 +0,0 @@
<div class="top-row ps-3 navbar navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="">SpotiParty.Web</a>
</div>
</div>
<input type="checkbox" title="Navigation menu" class="navbar-toggler"/>
<div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">
<nav class="nav flex-column">
<div class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Home
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="counter">
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Counter
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="weather">
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> Weather
</NavLink>
</div>
</nav>
</div>

View File

@@ -1,105 +0,0 @@
.navbar-toggler {
appearance: none;
cursor: pointer;
width: 3.5rem;
height: 2.5rem;
color: white;
position: absolute;
top: 0.5rem;
right: 1rem;
border: 1px solid rgba(255, 255, 255, 0.1);
background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") no-repeat center/1.75rem rgba(255, 255, 255, 0.1);
}
.navbar-toggler:checked {
background-color: rgba(255, 255, 255, 0.5);
}
.top-row {
min-height: 3.5rem;
background-color: rgba(0,0,0,0.4);
}
.navbar-brand {
font-size: 1.1rem;
}
.bi {
display: inline-block;
position: relative;
width: 1.25rem;
height: 1.25rem;
margin-right: 0.75rem;
top: -1px;
background-size: cover;
}
.bi-house-door-fill-nav-menu {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-house-door-fill' viewBox='0 0 16 16'%3E%3Cpath d='M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z'/%3E%3C/svg%3E");
}
.bi-plus-square-fill-nav-menu {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-plus-square-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm6.5 4.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3a.5.5 0 0 1 1 0z'/%3E%3C/svg%3E");
}
.bi-list-nested-nav-menu {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E");
}
.nav-item {
font-size: 0.9rem;
padding-bottom: 0.5rem;
}
.nav-item:first-of-type {
padding-top: 1rem;
}
.nav-item:last-of-type {
padding-bottom: 1rem;
}
.nav-item ::deep .nav-link {
color: #d7d7d7;
background: none;
border: none;
border-radius: 4px;
height: 3rem;
display: flex;
align-items: center;
line-height: 3rem;
width: 100%;
}
.nav-item ::deep a.active {
background-color: rgba(255,255,255,0.37);
color: white;
}
.nav-item ::deep .nav-link:hover {
background-color: rgba(255,255,255,0.1);
color: white;
}
.nav-scrollable {
display: none;
}
.navbar-toggler:checked ~ .nav-scrollable {
display: block;
}
@media (min-width: 641px) {
.navbar-toggler {
display: none;
}
.nav-scrollable {
/* Never collapse the sidebar for wide screens */
display: block;
/* Allow sidebar to scroll for tall menus */
height: calc(100vh - 3.5rem);
overflow-y: auto;
}
}

View File

@@ -1,19 +0,0 @@
@page "/counter"
@rendermode InteractiveServer
<PageTitle>Counter</PageTitle>
<h1>Counter</h1>
<p role="status">Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
private int currentCount = 0;
private void IncrementCount() {
currentCount++;
}
}

View File

@@ -0,0 +1,49 @@
@page "/enqueue"
@using SpotiParty.Web.Components.Components
@rendermode InteractiveServer
<header>
<h1>🎵 SpotiParty</h1>
<p>Suche ein Lied und füge es zur Warteschlange hinzu</p>
</header>
<main>
<form class="search-section" @onsubmit="ExecuteSearch">
<input type="text" id="searchInput" placeholder="Song oder Künstler suchen..." @onchange="e => _searchText = e.Value!.ToString()!">
<button class="button-primary" type="submit" disabled=@_isLoading>Suchen</button>
</form>
<section class="results-section">
<h2>Suchergebnisse</h2>
<div class="results">
@foreach (var track in _tracks) {
<SpotifyTrack Track="track" OnClick="@OnTrackClick" />
}
</div>
@if (_isLoading) {
<p>Lade...</p>
}
</section>
</main>
<footer>
<p>SpotiParty © @_currentYear</p>
</footer>
<dialog class="confirm-dialog" style="display: @(_selectedTrack is null ? "none" : "block")">
@if (!_success) {
<h3>Bestätigung</h3>
<p>Möchtest du den Titel zur Warteschlange hinzufügen?</p>
@if (_selectedTrack is not null) {
<SpotifyTrack Track="_selectedTrack" />
}
<div class="dialog-buttons">
<button class="button-primary" @onclick="DialogAccept" disabled=@_isAdding>Ja</button>
<button class="button-secondary" @onclick="DialogDismiss" disabled=@_isAdding>Nein</button>
</div>
}
else {
<h3>Bestätigung</h3>
<p>Der Titel wurde zur Warteschlange hinzugefügt!</p>
}
</dialog>

View File

@@ -0,0 +1,66 @@
using Microsoft.AspNetCore.Components;
using SpotifyAPI.Web;
using SpotiParty.Web.Services;
namespace SpotiParty.Web.Components.Pages;
public partial class EnqueuePage(AuthorizationHandler authHandler) : ComponentBase {
private readonly int _currentYear = DateTime.Now.Year;
private SpotifyClient _client = null!;
private string _searchText = string.Empty;
private List<FullTrack> _tracks = new();
private bool _isLoading;
private FullTrack? _selectedTrack;
private bool _isAdding;
private bool _success;
protected override async Task OnInitializedAsync() {
await base.OnInitializedAsync();
_client = await authHandler.ConfigureClient();
}
private async Task ExecuteSearch() {
if (_isLoading) return;
if (string.IsNullOrWhiteSpace(_searchText)) return;
_isLoading = true;
_tracks.Clear();
StateHasChanged();
var request = new SearchRequest(SearchRequest.Types.Track, _searchText);
var response = await _client.Search.Item(request);
var responseTracks = response.Tracks.Items ?? [];
foreach (var track in responseTracks) {
_tracks.Add(track);
}
_isLoading = false;
}
private void OnTrackClick(FullTrack track) {
if (_selectedTrack is not null) return;
_selectedTrack = track;
}
private void DialogDismiss() {
if (_isAdding) return;
_selectedTrack = null;
}
private async Task DialogAccept() {
if (_selectedTrack is null || _isAdding) return;
_isAdding = true;
/*var request = new PlayerAddToQueueRequest(_selectedTrack.Uri);
await _client.Player.AddToQueue(request);*/
await Task.Delay(3000); //TODO: Simulate adding
_isAdding = false;
_success = true;
StateHasChanged();
await Task.Delay(2000);
_success = false;
_selectedTrack = null;
}
}

View File

@@ -0,0 +1,120 @@
header {
text-align: center;
padding: 1rem;
background: var(--color-primary);
color: var(--color-text);
}
header h1 {
margin: 0;
font-size: 2rem;
&:focus {
outline: none;
}
}
main {
display: flex;
flex-direction: column;
gap: 1rem;
padding: 1.5rem;
flex-grow: 1;
min-height: 0;
}
.search-section {
display: flex;
gap: 0.5rem;
}
.search-section input {
padding: 0.5rem;
flex-grow: 1;
border-radius: 5px;
border: none;
&:focus {
outline: none;
}
}
section, form {
width: 100%;
padding: 1rem;
border-radius: 10px;
background: var(--color-background-light);
}
.results-section {
flex: 1;
margin-inline: auto;
overflow-y: auto;
}
h2 {
border-bottom: 1px solid var(--color-accent);
padding-bottom: 0.5rem;
margin-top: 0;
}
footer {
margin-top: auto;
text-align: center;
padding: 0.5rem;
background: var(--color-primary);
}
.confirm-dialog {
border: none;
border-radius: 10px;
padding: 1.5rem;
background: var(--color-background);
color: var(--color-text);
width: 320px;
max-width: 90%;
box-shadow: 0 4px 12px rgba(0,0,0,0.5);
top: 50%;
translate: 0 -50%;
}
.confirm-dialog::backdrop {
background: rgba(0,0,0,0.6);
}
.confirm-dialog h3 {
margin-top: 0;
margin-bottom: 0.5rem;
font-size: 1.2rem;
border-bottom: 1px solid var(--color-accent);
padding-bottom: 0.5rem;
}
.confirm-dialog p {
margin: 1rem 0;
}
.dialog-buttons {
display: flex;
justify-content: flex-end;
gap: 0.5rem;
}
.dialog-buttons button:disabled {
background: var(--color-background-light) !important;
}
.button-secondary {
padding: 0.6rem 1rem;
border: none;
border-radius: 5px;
background: var(--color-accent);
color: var(--color-text);
cursor: pointer;
}
.button-secondary:hover {
background: #555555;
}

View File

@@ -1,35 +0,0 @@
@page "/Error"
@using System.Diagnostics
<PageTitle>Error</PageTitle>
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
@if (ShowRequestId) {
<p>
<strong>Request ID:</strong> <code>@RequestId</code>
</p>
}
<h3>Development Mode</h3>
<p>
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>
@code{
[CascadingParameter] private HttpContext? HttpContext { get; set; }
private string? RequestId { get; set; }
private bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
protected override void OnInitialized() =>
RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;
}

View File

@@ -1,7 +0,0 @@
@page "/"
<PageTitle>Home</PageTitle>
<h1>Hello, world!</h1>
Welcome to your new app.

View File

@@ -1,5 +1,12 @@
@page "/not-found"
@layout MainLayout
<h3>Not Found</h3>
<p>Sorry, the content you are looking for does not exist.</p>
@inject NavigationManager Navigator
@code {
protected override void OnInitialized() {
base.OnInitialized();
Navigator.NavigateTo("/enqueue", forceLoad: true);
}
}

View File

@@ -1,61 +0,0 @@
@page "/weather"
@attribute [StreamRendering]
<PageTitle>Weather</PageTitle>
<h1>Weather</h1>
<p>This component demonstrates showing data.</p>
@if (forecasts == null) {
<p>
<em>Loading...</em>
</p>
}
else {
<table class="table">
<thead>
<tr>
<th>Date</th>
<th aria-label="Temperature in Celsius">Temp. (C)</th>
<th aria-label="Temperature in Fahrenheit">Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
@foreach (var forecast in forecasts) {
<tr>
<td>@forecast.Date.ToShortDateString()</td>
<td>@forecast.TemperatureC</td>
<td>@forecast.TemperatureF</td>
<td>@forecast.Summary</td>
</tr>
}
</tbody>
</table>
}
@code {
private WeatherForecast[]? forecasts;
protected override async Task OnInitializedAsync() {
// Simulate asynchronous loading to demonstrate streaming rendering
await Task.Delay(500);
var startDate = DateOnly.FromDateTime(DateTime.Now);
var summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" };
forecasts = Enumerable.Range(1, 5).Select(index => new WeatherForecast {
Date = startDate.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = summaries[Random.Shared.Next(summaries.Length)]
}).ToArray();
}
private class WeatherForecast {
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
public string? Summary { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
}

View File

@@ -1,6 +1,6 @@
<Router AppAssembly="typeof(Program).Assembly" NotFoundPage="typeof(Pages.NotFound)">
<Found Context="routeData">
<RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)"/>
<RouteView RouteData="routeData"/>
<FocusOnNavigate RouteData="routeData" Selector="h1"/>
</Found>
</Router>