Switched to net9 and finished event workflow
This commit is contained in:
27
SpotiParty.Web/Services/AdminDashboardPlugin.cs
Normal file
27
SpotiParty.Web/Services/AdminDashboardPlugin.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using HopFrame.Core.Config;
|
||||
using HopFrame.Web.Plugins.Events;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.FluentUI.AspNetCore.Components;
|
||||
using SpotiParty.Web.Models;
|
||||
|
||||
namespace SpotiParty.Web.Services;
|
||||
|
||||
public class AdminDashboardPlugin(NavigationManager navigator) {
|
||||
|
||||
[HopFrame.Web.Plugins.Annotations.EventHandler]
|
||||
public void OnTableInitialized(TableInitializedEvent e) {
|
||||
if (e.Table.TableType != typeof(Event)) return;
|
||||
|
||||
e.AddEntityButton(new IconInfo {
|
||||
Variant = IconVariant.Regular,
|
||||
Size = IconSize.Size16,
|
||||
Name = "Open"
|
||||
}, OnButtonClicked);
|
||||
}
|
||||
|
||||
private void OnButtonClicked(object o, TableConfig config) {
|
||||
var entity = (Event)o;
|
||||
navigator.NavigateTo(navigator.BaseUri + $"enqueue/{entity.Id}");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,11 +5,17 @@ using SpotiParty.Web.Models;
|
||||
|
||||
namespace SpotiParty.Web.Services;
|
||||
|
||||
public sealed class AuthorizationHandler(NavigationManager navigator, DatabaseContext context, ClientSideStorage storage) {
|
||||
public sealed class AuthorizationHandler(NavigationManager navigator, DatabaseContext context, ClientSideStorage storage, IConfiguration configuration) {
|
||||
|
||||
private async Task<(string clientId, string clientSecret)> GetClientSecrets() {
|
||||
#if DEBUG
|
||||
var fileLines = await File.ReadAllLinesAsync(Path.Combine(Environment.CurrentDirectory, ".dev-token"));
|
||||
return (fileLines[0], fileLines[1]);
|
||||
#endif
|
||||
|
||||
#pragma warning disable CS0162 // Unreachable code detected
|
||||
return (configuration["ClientId"]!, configuration["ClientSecret"]!);
|
||||
#pragma warning restore CS0162 // Unreachable code detected
|
||||
}
|
||||
|
||||
public async Task<SpotifyClient?> ConfigureClient(Guid userId) {
|
||||
|
||||
@@ -29,6 +29,10 @@ public class EventsDashboardRepo(DatabaseContext context, DashboardAuthHandler h
|
||||
}
|
||||
|
||||
public async Task CreateItem(Event item) {
|
||||
var creator = await handler.GetCurrentUser();
|
||||
context.Attach(creator!);
|
||||
item.Host = creator!;
|
||||
|
||||
await context.Events.AddAsync(item);
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user