Switched to database scheme seperation from MoonCores SingleDb. Updated mooncore versions. Updating to correct Async naming
This commit is contained in:
@@ -10,15 +10,15 @@ await startup.Run(args, pluginLoader.Instances);
|
||||
|
||||
var cs = new Startup();
|
||||
|
||||
await cs.Initialize(args, pluginLoader.Instances);
|
||||
await cs.InitializeAsync(args, pluginLoader.Instances);
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
await cs.AddMoonlight(builder);
|
||||
await cs.AddMoonlightAsync(builder);
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
await cs.AddMoonlight(app);
|
||||
await cs.AddMoonlightAsync(app);
|
||||
|
||||
// Handle setup of wasm app hosting in the runtime
|
||||
// so the Moonlight.ApiServer doesn't need the wasm package
|
||||
|
||||
@@ -62,7 +62,7 @@ public record AppConfiguration
|
||||
public record FilesData
|
||||
{
|
||||
[YamlMember(Description = "The maximum file size limit a combine operation is allowed to process")]
|
||||
public long CombineLimit { get; set; } = ByteConverter.FromGigaBytes(5).MegaBytes;
|
||||
public double CombineLimit { get; set; } = ByteConverter.FromGigaBytes(5).MegaBytes;
|
||||
}
|
||||
|
||||
public record FrontendData
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
using Hangfire.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MoonCore.Extended.SingleDb;
|
||||
using Moonlight.ApiServer.Configuration;
|
||||
using Moonlight.ApiServer.Database.Entities;
|
||||
using Moonlight.ApiServer.Models;
|
||||
|
||||
namespace Moonlight.ApiServer.Database;
|
||||
|
||||
public class CoreDataContext : DatabaseContext
|
||||
public class CoreDataContext : DbContext
|
||||
{
|
||||
public override string Prefix { get; } = "Core";
|
||||
private readonly AppConfiguration Configuration;
|
||||
|
||||
public DbSet<User> Users { get; set; }
|
||||
public DbSet<ApiKey> ApiKeys { get; set; }
|
||||
@@ -17,18 +16,32 @@ public class CoreDataContext : DatabaseContext
|
||||
|
||||
public CoreDataContext(AppConfiguration configuration)
|
||||
{
|
||||
Options = new()
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if(optionsBuilder.IsConfigured)
|
||||
return;
|
||||
|
||||
var database = Configuration.Database;
|
||||
|
||||
var connectionString = $"Host={database.Host};" +
|
||||
$"Port={database.Port};" +
|
||||
$"Database={database.Database};" +
|
||||
$"Username={database.Username};" +
|
||||
$"Password={database.Password}";
|
||||
|
||||
optionsBuilder.UseNpgsql(connectionString, builder =>
|
||||
{
|
||||
Host = configuration.Database.Host,
|
||||
Port = configuration.Database.Port,
|
||||
Username = configuration.Database.Username,
|
||||
Password = configuration.Database.Password,
|
||||
Database = configuration.Database.Database
|
||||
};
|
||||
builder.MigrationsHistoryTable("MigrationsHistory", "core");
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Model.SetDefaultSchema("core");
|
||||
|
||||
base.OnModelCreating(modelBuilder);
|
||||
modelBuilder.OnHangfireModelCreating();
|
||||
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Moonlight.ApiServer.Database;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Moonlight.ApiServer.Database.Migrations
|
||||
{
|
||||
[DbContext(typeof(CoreDataContext))]
|
||||
[Migration("20250226080942_AddedUsersAndApiKey")]
|
||||
partial class AddedUsersAndApiKey
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.11")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Moonlight.ApiServer.Database.Entities.ApiKey", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("ExpiresAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("PermissionsJson")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.Property<string>("Secret")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Core_ApiKeys", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Moonlight.ApiServer.Database.Entities.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PermissionsJson")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.Property<DateTime>("TokenValidTimestamp")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Core_Users", (string)null);
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Moonlight.ApiServer.Database.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddedUsersAndApiKey : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Core_ApiKeys",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Secret = table.Column<string>(type: "text", nullable: false),
|
||||
Description = table.Column<string>(type: "text", nullable: false),
|
||||
PermissionsJson = table.Column<string>(type: "jsonb", nullable: false),
|
||||
ExpiresAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Core_ApiKeys", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Core_Users",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Username = table.Column<string>(type: "text", nullable: false),
|
||||
Email = table.Column<string>(type: "text", nullable: false),
|
||||
Password = table.Column<string>(type: "text", nullable: false),
|
||||
TokenValidTimestamp = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
PermissionsJson = table.Column<string>(type: "jsonb", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Core_Users", x => x.Id);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Core_ApiKeys");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Core_Users");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Moonlight.ApiServer.Database;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Moonlight.ApiServer.Database.Migrations
|
||||
{
|
||||
[DbContext(typeof(CoreDataContext))]
|
||||
[Migration("20250314095412_ModifiedApiKeyEntity")]
|
||||
partial class ModifiedApiKeyEntity
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.11")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Moonlight.ApiServer.Database.Entities.ApiKey", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("ExpiresAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("PermissionsJson")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Core_ApiKeys", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Moonlight.ApiServer.Database.Entities.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PermissionsJson")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.Property<DateTime>("TokenValidTimestamp")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Core_Users", (string)null);
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Moonlight.ApiServer.Database.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class ModifiedApiKeyEntity : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Secret",
|
||||
table: "Core_ApiKeys");
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "CreatedAt",
|
||||
table: "Core_ApiKeys",
|
||||
type: "timestamp with time zone",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CreatedAt",
|
||||
table: "Core_ApiKeys");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Secret",
|
||||
table: "Core_ApiKeys",
|
||||
type: "text",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,393 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Moonlight.ApiServer.Database;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Moonlight.ApiServer.Database.Migrations
|
||||
{
|
||||
[DbContext(typeof(CoreDataContext))]
|
||||
[Migration("20250405172522_AddedHangfireTables")]
|
||||
partial class AddedHangfireTables
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.11")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireCounter", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime?>("ExpireAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Key")
|
||||
.IsRequired()
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<long>("Value")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ExpireAt");
|
||||
|
||||
b.HasIndex("Key", "Value");
|
||||
|
||||
b.ToTable("HangfireCounter");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireHash", b =>
|
||||
{
|
||||
b.Property<string>("Key")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<string>("Field")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<DateTime?>("ExpireAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Key", "Field");
|
||||
|
||||
b.HasIndex("ExpireAt");
|
||||
|
||||
b.ToTable("HangfireHash");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireJob", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("ExpireAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("InvocationData")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long?>("StateId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("StateName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ExpireAt");
|
||||
|
||||
b.HasIndex("StateId");
|
||||
|
||||
b.HasIndex("StateName");
|
||||
|
||||
b.ToTable("HangfireJob");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireJobParameter", b =>
|
||||
{
|
||||
b.Property<long>("JobId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("JobId", "Name");
|
||||
|
||||
b.ToTable("HangfireJobParameter");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireList", b =>
|
||||
{
|
||||
b.Property<string>("Key")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<int>("Position")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime?>("ExpireAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Key", "Position");
|
||||
|
||||
b.HasIndex("ExpireAt");
|
||||
|
||||
b.ToTable("HangfireList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireLock", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<DateTime>("AcquiredAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("HangfireLock");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireQueuedJob", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime?>("FetchedAt")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<long>("JobId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Queue")
|
||||
.IsRequired()
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("JobId");
|
||||
|
||||
b.HasIndex("Queue", "FetchedAt");
|
||||
|
||||
b.ToTable("HangfireQueuedJob");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireServer", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<DateTime>("Heartbeat")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Queues")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("StartedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("WorkerCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Heartbeat");
|
||||
|
||||
b.ToTable("HangfireServer");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireSet", b =>
|
||||
{
|
||||
b.Property<string>("Key")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<DateTime?>("ExpireAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<double>("Score")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Key", "Value");
|
||||
|
||||
b.HasIndex("ExpireAt");
|
||||
|
||||
b.HasIndex("Key", "Score");
|
||||
|
||||
b.ToTable("HangfireSet");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireState", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Data")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long>("JobId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<string>("Reason")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("JobId");
|
||||
|
||||
b.ToTable("HangfireState");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Moonlight.ApiServer.Database.Entities.ApiKey", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("ExpiresAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("PermissionsJson")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Core_ApiKeys", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Moonlight.ApiServer.Database.Entities.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PermissionsJson")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.Property<DateTime>("TokenValidTimestamp")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Core_Users", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireJob", b =>
|
||||
{
|
||||
b.HasOne("Hangfire.EntityFrameworkCore.HangfireState", "State")
|
||||
.WithMany()
|
||||
.HasForeignKey("StateId");
|
||||
|
||||
b.Navigation("State");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireJobParameter", b =>
|
||||
{
|
||||
b.HasOne("Hangfire.EntityFrameworkCore.HangfireJob", "Job")
|
||||
.WithMany("Parameters")
|
||||
.HasForeignKey("JobId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Job");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireQueuedJob", b =>
|
||||
{
|
||||
b.HasOne("Hangfire.EntityFrameworkCore.HangfireJob", "Job")
|
||||
.WithMany("QueuedJobs")
|
||||
.HasForeignKey("JobId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Job");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireState", b =>
|
||||
{
|
||||
b.HasOne("Hangfire.EntityFrameworkCore.HangfireJob", "Job")
|
||||
.WithMany("States")
|
||||
.HasForeignKey("JobId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Job");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireJob", b =>
|
||||
{
|
||||
b.Navigation("Parameters");
|
||||
|
||||
b.Navigation("QueuedJobs");
|
||||
|
||||
b.Navigation("States");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,393 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Moonlight.ApiServer.Database;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Moonlight.ApiServer.Database.Migrations
|
||||
{
|
||||
[DbContext(typeof(CoreDataContext))]
|
||||
[Migration("20250712202608_SwitchedToPgArraysForPermissions")]
|
||||
partial class SwitchedToPgArraysForPermissions
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "9.0.7")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireCounter", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime?>("ExpireAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Key")
|
||||
.IsRequired()
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<long>("Value")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ExpireAt");
|
||||
|
||||
b.HasIndex("Key", "Value");
|
||||
|
||||
b.ToTable("HangfireCounter");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireHash", b =>
|
||||
{
|
||||
b.Property<string>("Key")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<string>("Field")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<DateTime?>("ExpireAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Key", "Field");
|
||||
|
||||
b.HasIndex("ExpireAt");
|
||||
|
||||
b.ToTable("HangfireHash");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireJob", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("ExpireAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("InvocationData")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long?>("StateId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("StateName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ExpireAt");
|
||||
|
||||
b.HasIndex("StateId");
|
||||
|
||||
b.HasIndex("StateName");
|
||||
|
||||
b.ToTable("HangfireJob");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireJobParameter", b =>
|
||||
{
|
||||
b.Property<long>("JobId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("JobId", "Name");
|
||||
|
||||
b.ToTable("HangfireJobParameter");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireList", b =>
|
||||
{
|
||||
b.Property<string>("Key")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<int>("Position")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime?>("ExpireAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Key", "Position");
|
||||
|
||||
b.HasIndex("ExpireAt");
|
||||
|
||||
b.ToTable("HangfireList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireLock", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<DateTime>("AcquiredAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("HangfireLock");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireQueuedJob", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime?>("FetchedAt")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<long>("JobId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Queue")
|
||||
.IsRequired()
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("JobId");
|
||||
|
||||
b.HasIndex("Queue", "FetchedAt");
|
||||
|
||||
b.ToTable("HangfireQueuedJob");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireServer", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<DateTime>("Heartbeat")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Queues")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("StartedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("WorkerCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Heartbeat");
|
||||
|
||||
b.ToTable("HangfireServer");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireSet", b =>
|
||||
{
|
||||
b.Property<string>("Key")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<DateTime?>("ExpireAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<double>("Score")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Key", "Value");
|
||||
|
||||
b.HasIndex("ExpireAt");
|
||||
|
||||
b.HasIndex("Key", "Score");
|
||||
|
||||
b.ToTable("HangfireSet");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireState", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Data")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long>("JobId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<string>("Reason")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("JobId");
|
||||
|
||||
b.ToTable("HangfireState");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Moonlight.ApiServer.Database.Entities.ApiKey", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTimeOffset>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTimeOffset>("ExpiresAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.PrimitiveCollection<string[]>("Permissions")
|
||||
.IsRequired()
|
||||
.HasColumnType("text[]");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Core_ApiKeys", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Moonlight.ApiServer.Database.Entities.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.PrimitiveCollection<string[]>("Permissions")
|
||||
.IsRequired()
|
||||
.HasColumnType("text[]");
|
||||
|
||||
b.Property<DateTimeOffset>("TokenValidTimestamp")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Core_Users", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireJob", b =>
|
||||
{
|
||||
b.HasOne("Hangfire.EntityFrameworkCore.HangfireState", "State")
|
||||
.WithMany()
|
||||
.HasForeignKey("StateId");
|
||||
|
||||
b.Navigation("State");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireJobParameter", b =>
|
||||
{
|
||||
b.HasOne("Hangfire.EntityFrameworkCore.HangfireJob", "Job")
|
||||
.WithMany("Parameters")
|
||||
.HasForeignKey("JobId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Job");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireQueuedJob", b =>
|
||||
{
|
||||
b.HasOne("Hangfire.EntityFrameworkCore.HangfireJob", "Job")
|
||||
.WithMany("QueuedJobs")
|
||||
.HasForeignKey("JobId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Job");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireState", b =>
|
||||
{
|
||||
b.HasOne("Hangfire.EntityFrameworkCore.HangfireJob", "Job")
|
||||
.WithMany("States")
|
||||
.HasForeignKey("JobId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Job");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireJob", b =>
|
||||
{
|
||||
b.Navigation("Parameters");
|
||||
|
||||
b.Navigation("QueuedJobs");
|
||||
|
||||
b.Navigation("States");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Moonlight.ApiServer.Database.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class SwitchedToPgArraysForPermissions : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PermissionsJson",
|
||||
table: "Core_Users");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PermissionsJson",
|
||||
table: "Core_ApiKeys");
|
||||
|
||||
migrationBuilder.AddColumn<string[]>(
|
||||
name: "Permissions",
|
||||
table: "Core_Users",
|
||||
type: "text[]",
|
||||
nullable: false,
|
||||
defaultValue: new string[0]);
|
||||
|
||||
migrationBuilder.AddColumn<string[]>(
|
||||
name: "Permissions",
|
||||
table: "Core_ApiKeys",
|
||||
type: "text[]",
|
||||
nullable: false,
|
||||
defaultValue: new string[0]);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Permissions",
|
||||
table: "Core_Users");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Permissions",
|
||||
table: "Core_ApiKeys");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "PermissionsJson",
|
||||
table: "Core_Users",
|
||||
type: "jsonb",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "PermissionsJson",
|
||||
table: "Core_ApiKeys",
|
||||
type: "jsonb",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Moonlight.ApiServer.Database.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddedThemes : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Core_Themes",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
IsEnabled = table.Column<bool>(type: "boolean", nullable: false),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Author = table.Column<string>(type: "text", nullable: false),
|
||||
Version = table.Column<string>(type: "text", nullable: false),
|
||||
UpdateUrl = table.Column<string>(type: "text", nullable: true),
|
||||
DonateUrl = table.Column<string>(type: "text", nullable: true),
|
||||
Content = table.Column<string>(type: "jsonb", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Core_Themes", x => x.Id);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Core_Themes");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,15 +12,16 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace Moonlight.ApiServer.Database.Migrations
|
||||
{
|
||||
[DbContext(typeof(CoreDataContext))]
|
||||
[Migration("20250720203346_AddedThemes")]
|
||||
partial class AddedThemes
|
||||
[Migration("20250919201409_RecreatedMigrationsForChangeOfSchema")]
|
||||
partial class RecreatedMigrationsForChangeOfSchema
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "9.0.7")
|
||||
.HasDefaultSchema("core")
|
||||
.HasAnnotation("ProductVersion", "9.0.8")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
@@ -50,7 +51,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasIndex("Key", "Value");
|
||||
|
||||
b.ToTable("HangfireCounter");
|
||||
b.ToTable("HangfireCounter", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireHash", b =>
|
||||
@@ -73,7 +74,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasIndex("ExpireAt");
|
||||
|
||||
b.ToTable("HangfireHash");
|
||||
b.ToTable("HangfireHash", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireJob", b =>
|
||||
@@ -109,7 +110,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasIndex("StateName");
|
||||
|
||||
b.ToTable("HangfireJob");
|
||||
b.ToTable("HangfireJob", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireJobParameter", b =>
|
||||
@@ -126,7 +127,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasKey("JobId", "Name");
|
||||
|
||||
b.ToTable("HangfireJobParameter");
|
||||
b.ToTable("HangfireJobParameter", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireList", b =>
|
||||
@@ -148,7 +149,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasIndex("ExpireAt");
|
||||
|
||||
b.ToTable("HangfireList");
|
||||
b.ToTable("HangfireList", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireLock", b =>
|
||||
@@ -162,7 +163,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("HangfireLock");
|
||||
b.ToTable("HangfireLock", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireQueuedJob", b =>
|
||||
@@ -191,7 +192,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasIndex("Queue", "FetchedAt");
|
||||
|
||||
b.ToTable("HangfireQueuedJob");
|
||||
b.ToTable("HangfireQueuedJob", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireServer", b =>
|
||||
@@ -217,7 +218,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasIndex("Heartbeat");
|
||||
|
||||
b.ToTable("HangfireServer");
|
||||
b.ToTable("HangfireServer", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireSet", b =>
|
||||
@@ -242,7 +243,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasIndex("Key", "Score");
|
||||
|
||||
b.ToTable("HangfireSet");
|
||||
b.ToTable("HangfireSet", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireState", b =>
|
||||
@@ -275,7 +276,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasIndex("JobId");
|
||||
|
||||
b.ToTable("HangfireState");
|
||||
b.ToTable("HangfireState", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Moonlight.ApiServer.Database.Entities.ApiKey", b =>
|
||||
@@ -302,7 +303,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Core_ApiKeys", (string)null);
|
||||
b.ToTable("ApiKeys", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Moonlight.ApiServer.Database.Entities.Theme", b =>
|
||||
@@ -336,7 +337,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Core_Themes", (string)null);
|
||||
b.ToTable("Themes", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Moonlight.ApiServer.Database.Entities.User", b =>
|
||||
@@ -368,7 +369,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Core_Users", (string)null);
|
||||
b.ToTable("Users", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireJob", b =>
|
||||
@@ -515,11 +516,11 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b1.Property<float>("Depth")
|
||||
.HasColumnType("real");
|
||||
b1.Property<int>("Depth")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b1.Property<float>("Noise")
|
||||
.HasColumnType("real");
|
||||
b1.Property<int>("Noise")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b1.Property<float>("RadiusBox")
|
||||
.HasColumnType("real");
|
||||
@@ -538,7 +539,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b1.HasKey("ThemeId");
|
||||
|
||||
b1.ToTable("Core_Themes");
|
||||
b1.ToTable("Themes", "core");
|
||||
|
||||
b1.ToJson("Content");
|
||||
|
||||
@@ -7,13 +7,34 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace Moonlight.ApiServer.Database.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddedHangfireTables : Migration
|
||||
public partial class RecreatedMigrationsForChangeOfSchema : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.EnsureSchema(
|
||||
name: "core");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ApiKeys",
|
||||
schema: "core",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Description = table.Column<string>(type: "text", nullable: false),
|
||||
Permissions = table.Column<string[]>(type: "text[]", nullable: false),
|
||||
ExpiresAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ApiKeys", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "HangfireCounter",
|
||||
schema: "core",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
@@ -29,6 +50,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "HangfireHash",
|
||||
schema: "core",
|
||||
columns: table => new
|
||||
{
|
||||
Key = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
|
||||
@@ -43,6 +65,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "HangfireList",
|
||||
schema: "core",
|
||||
columns: table => new
|
||||
{
|
||||
Key = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
|
||||
@@ -57,6 +80,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "HangfireLock",
|
||||
schema: "core",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
|
||||
@@ -69,6 +93,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "HangfireServer",
|
||||
schema: "core",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
|
||||
@@ -84,6 +109,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "HangfireSet",
|
||||
schema: "core",
|
||||
columns: table => new
|
||||
{
|
||||
Key = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
||||
@@ -96,8 +122,47 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
table.PrimaryKey("PK_HangfireSet", x => new { x.Key, x.Value });
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Themes",
|
||||
schema: "core",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
IsEnabled = table.Column<bool>(type: "boolean", nullable: false),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Author = table.Column<string>(type: "text", nullable: false),
|
||||
Version = table.Column<string>(type: "text", nullable: false),
|
||||
UpdateUrl = table.Column<string>(type: "text", nullable: true),
|
||||
DonateUrl = table.Column<string>(type: "text", nullable: true),
|
||||
Content = table.Column<string>(type: "jsonb", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Themes", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Users",
|
||||
schema: "core",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Username = table.Column<string>(type: "text", nullable: false),
|
||||
Email = table.Column<string>(type: "text", nullable: false),
|
||||
Password = table.Column<string>(type: "text", nullable: false),
|
||||
TokenValidTimestamp = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
Permissions = table.Column<string[]>(type: "text[]", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Users", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "HangfireJob",
|
||||
schema: "core",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
@@ -115,6 +180,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "HangfireJobParameter",
|
||||
schema: "core",
|
||||
columns: table => new
|
||||
{
|
||||
JobId = table.Column<long>(type: "bigint", nullable: false),
|
||||
@@ -127,6 +193,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
table.ForeignKey(
|
||||
name: "FK_HangfireJobParameter_HangfireJob_JobId",
|
||||
column: x => x.JobId,
|
||||
principalSchema: "core",
|
||||
principalTable: "HangfireJob",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
@@ -134,6 +201,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "HangfireQueuedJob",
|
||||
schema: "core",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
@@ -148,6 +216,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
table.ForeignKey(
|
||||
name: "FK_HangfireQueuedJob_HangfireJob_JobId",
|
||||
column: x => x.JobId,
|
||||
principalSchema: "core",
|
||||
principalTable: "HangfireJob",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
@@ -155,6 +224,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "HangfireState",
|
||||
schema: "core",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
@@ -171,6 +241,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
table.ForeignKey(
|
||||
name: "FK_HangfireState_HangfireJob_JobId",
|
||||
column: x => x.JobId,
|
||||
principalSchema: "core",
|
||||
principalTable: "HangfireJob",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
@@ -178,73 +249,88 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_HangfireCounter_ExpireAt",
|
||||
schema: "core",
|
||||
table: "HangfireCounter",
|
||||
column: "ExpireAt");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_HangfireCounter_Key_Value",
|
||||
schema: "core",
|
||||
table: "HangfireCounter",
|
||||
columns: new[] { "Key", "Value" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_HangfireHash_ExpireAt",
|
||||
schema: "core",
|
||||
table: "HangfireHash",
|
||||
column: "ExpireAt");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_HangfireJob_ExpireAt",
|
||||
schema: "core",
|
||||
table: "HangfireJob",
|
||||
column: "ExpireAt");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_HangfireJob_StateId",
|
||||
schema: "core",
|
||||
table: "HangfireJob",
|
||||
column: "StateId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_HangfireJob_StateName",
|
||||
schema: "core",
|
||||
table: "HangfireJob",
|
||||
column: "StateName");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_HangfireList_ExpireAt",
|
||||
schema: "core",
|
||||
table: "HangfireList",
|
||||
column: "ExpireAt");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_HangfireQueuedJob_JobId",
|
||||
schema: "core",
|
||||
table: "HangfireQueuedJob",
|
||||
column: "JobId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_HangfireQueuedJob_Queue_FetchedAt",
|
||||
schema: "core",
|
||||
table: "HangfireQueuedJob",
|
||||
columns: new[] { "Queue", "FetchedAt" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_HangfireServer_Heartbeat",
|
||||
schema: "core",
|
||||
table: "HangfireServer",
|
||||
column: "Heartbeat");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_HangfireSet_ExpireAt",
|
||||
schema: "core",
|
||||
table: "HangfireSet",
|
||||
column: "ExpireAt");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_HangfireSet_Key_Score",
|
||||
schema: "core",
|
||||
table: "HangfireSet",
|
||||
columns: new[] { "Key", "Score" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_HangfireState_JobId",
|
||||
schema: "core",
|
||||
table: "HangfireState",
|
||||
column: "JobId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_HangfireJob_HangfireState_StateId",
|
||||
schema: "core",
|
||||
table: "HangfireJob",
|
||||
column: "StateId",
|
||||
principalSchema: "core",
|
||||
principalTable: "HangfireState",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
@@ -254,37 +340,60 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_HangfireJob_HangfireState_StateId",
|
||||
schema: "core",
|
||||
table: "HangfireJob");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "HangfireCounter");
|
||||
name: "ApiKeys",
|
||||
schema: "core");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "HangfireHash");
|
||||
name: "HangfireCounter",
|
||||
schema: "core");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "HangfireJobParameter");
|
||||
name: "HangfireHash",
|
||||
schema: "core");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "HangfireList");
|
||||
name: "HangfireJobParameter",
|
||||
schema: "core");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "HangfireLock");
|
||||
name: "HangfireList",
|
||||
schema: "core");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "HangfireQueuedJob");
|
||||
name: "HangfireLock",
|
||||
schema: "core");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "HangfireServer");
|
||||
name: "HangfireQueuedJob",
|
||||
schema: "core");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "HangfireSet");
|
||||
name: "HangfireServer",
|
||||
schema: "core");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "HangfireState");
|
||||
name: "HangfireSet",
|
||||
schema: "core");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "HangfireJob");
|
||||
name: "Themes",
|
||||
schema: "core");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Users",
|
||||
schema: "core");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "HangfireState",
|
||||
schema: "core");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "HangfireJob",
|
||||
schema: "core");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,8 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "9.0.7")
|
||||
.HasDefaultSchema("core")
|
||||
.HasAnnotation("ProductVersion", "9.0.8")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
@@ -47,7 +48,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasIndex("Key", "Value");
|
||||
|
||||
b.ToTable("HangfireCounter");
|
||||
b.ToTable("HangfireCounter", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireHash", b =>
|
||||
@@ -70,7 +71,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasIndex("ExpireAt");
|
||||
|
||||
b.ToTable("HangfireHash");
|
||||
b.ToTable("HangfireHash", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireJob", b =>
|
||||
@@ -106,7 +107,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasIndex("StateName");
|
||||
|
||||
b.ToTable("HangfireJob");
|
||||
b.ToTable("HangfireJob", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireJobParameter", b =>
|
||||
@@ -123,7 +124,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasKey("JobId", "Name");
|
||||
|
||||
b.ToTable("HangfireJobParameter");
|
||||
b.ToTable("HangfireJobParameter", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireList", b =>
|
||||
@@ -145,7 +146,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasIndex("ExpireAt");
|
||||
|
||||
b.ToTable("HangfireList");
|
||||
b.ToTable("HangfireList", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireLock", b =>
|
||||
@@ -159,7 +160,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("HangfireLock");
|
||||
b.ToTable("HangfireLock", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireQueuedJob", b =>
|
||||
@@ -188,7 +189,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasIndex("Queue", "FetchedAt");
|
||||
|
||||
b.ToTable("HangfireQueuedJob");
|
||||
b.ToTable("HangfireQueuedJob", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireServer", b =>
|
||||
@@ -214,7 +215,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasIndex("Heartbeat");
|
||||
|
||||
b.ToTable("HangfireServer");
|
||||
b.ToTable("HangfireServer", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireSet", b =>
|
||||
@@ -239,7 +240,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasIndex("Key", "Score");
|
||||
|
||||
b.ToTable("HangfireSet");
|
||||
b.ToTable("HangfireSet", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireState", b =>
|
||||
@@ -272,7 +273,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasIndex("JobId");
|
||||
|
||||
b.ToTable("HangfireState");
|
||||
b.ToTable("HangfireState", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Moonlight.ApiServer.Database.Entities.ApiKey", b =>
|
||||
@@ -299,7 +300,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Core_ApiKeys", (string)null);
|
||||
b.ToTable("ApiKeys", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Moonlight.ApiServer.Database.Entities.Theme", b =>
|
||||
@@ -333,7 +334,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Core_Themes", (string)null);
|
||||
b.ToTable("Themes", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Moonlight.ApiServer.Database.Entities.User", b =>
|
||||
@@ -365,7 +366,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Core_Users", (string)null);
|
||||
b.ToTable("Users", "core");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hangfire.EntityFrameworkCore.HangfireJob", b =>
|
||||
@@ -512,11 +513,11 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b1.Property<float>("Depth")
|
||||
.HasColumnType("real");
|
||||
b1.Property<int>("Depth")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b1.Property<float>("Noise")
|
||||
.HasColumnType("real");
|
||||
b1.Property<int>("Noise")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b1.Property<float>("RadiusBox")
|
||||
.HasColumnType("real");
|
||||
@@ -535,7 +536,7 @@ namespace Moonlight.ApiServer.Database.Migrations
|
||||
|
||||
b1.HasKey("ThemeId");
|
||||
|
||||
b1.ToTable("Core_Themes");
|
||||
b1.ToTable("Themes", "core");
|
||||
|
||||
b1.ToJson("Content");
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ApiKeysController : Controller
|
||||
|
||||
[HttpGet]
|
||||
[Authorize(Policy = "permissions:admin.apikeys.get")]
|
||||
public async Task<ActionResult<ICountedData<ApiKeyResponse>>> Get(
|
||||
public async Task<ActionResult<ICountedData<ApiKeyResponse>>> GetAsync(
|
||||
[FromQuery] int startIndex,
|
||||
[FromQuery] int count,
|
||||
[FromQuery] string? orderBy,
|
||||
@@ -81,7 +81,7 @@ public class ApiKeysController : Controller
|
||||
|
||||
[HttpGet("{id:int}")]
|
||||
[Authorize(Policy = "permissions:admin.apikeys.get")]
|
||||
public async Task<ActionResult<ApiKeyResponse>> GetSingle(int id)
|
||||
public async Task<ActionResult<ApiKeyResponse>> GetSingleAsync(int id)
|
||||
{
|
||||
var apiKey = await ApiKeyRepository
|
||||
.Get()
|
||||
@@ -97,7 +97,7 @@ public class ApiKeysController : Controller
|
||||
|
||||
[HttpPost]
|
||||
[Authorize(Policy = "permissions:admin.apikeys.create")]
|
||||
public async Task<CreateApiKeyResponse> Create([FromBody] CreateApiKeyRequest request)
|
||||
public async Task<CreateApiKeyResponse> CreateAsync([FromBody] CreateApiKeyRequest request)
|
||||
{
|
||||
var apiKey = ApiKeyMapper.ToApiKey(request);
|
||||
|
||||
@@ -117,7 +117,7 @@ public class ApiKeysController : Controller
|
||||
|
||||
[HttpPatch("{id:int}")]
|
||||
[Authorize(Policy = "permissions:admin.apikeys.update")]
|
||||
public async Task<ActionResult<ApiKeyResponse>> Update([FromRoute] int id, [FromBody] UpdateApiKeyRequest request)
|
||||
public async Task<ActionResult<ApiKeyResponse>> UpdateAsync([FromRoute] int id, [FromBody] UpdateApiKeyRequest request)
|
||||
{
|
||||
var apiKey = await ApiKeyRepository
|
||||
.Get()
|
||||
@@ -135,7 +135,7 @@ public class ApiKeysController : Controller
|
||||
|
||||
[HttpDelete("{id:int}")]
|
||||
[Authorize(Policy = "permissions:admin.apikeys.delete")]
|
||||
public async Task<ActionResult> Delete([FromRoute] int id)
|
||||
public async Task<ActionResult> DeleteAsync([FromRoute] int id)
|
||||
{
|
||||
var apiKey = await ApiKeyRepository
|
||||
.Get()
|
||||
|
||||
@@ -19,9 +19,9 @@ public class AdvancedController : Controller
|
||||
|
||||
[HttpGet("frontend")]
|
||||
[Authorize(Policy = "permissions:admin.system.advanced.frontend")]
|
||||
public async Task Frontend()
|
||||
public async Task FrontendAsync()
|
||||
{
|
||||
var stream = await FrontendService.GenerateZip();
|
||||
var stream = await FrontendService.GenerateZipAsync();
|
||||
await Results.File(stream, fileDownloadName: "frontend.zip").ExecuteAsync(HttpContext);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public class ThemesController : Controller
|
||||
|
||||
[HttpGet]
|
||||
[Authorize(Policy = "permissions:admin.system.customisation.themes.read")]
|
||||
public async Task<ActionResult<ICountedData<ThemeResponse>>> Get(
|
||||
public async Task<ActionResult<ICountedData<ThemeResponse>>> GetAsync(
|
||||
[FromQuery] int startIndex,
|
||||
[FromQuery] int count,
|
||||
[FromQuery] string? orderBy,
|
||||
@@ -81,7 +81,7 @@ public class ThemesController : Controller
|
||||
|
||||
[HttpGet("{id:int}")]
|
||||
[Authorize(Policy = "permissions:admin.system.customisation.themes.read")]
|
||||
public async Task<ActionResult<ThemeResponse>> GetSingle([FromRoute] int id)
|
||||
public async Task<ActionResult<ThemeResponse>> GetSingleAsync([FromRoute] int id)
|
||||
{
|
||||
var theme = await ThemeRepository
|
||||
.Get()
|
||||
@@ -97,7 +97,7 @@ public class ThemesController : Controller
|
||||
|
||||
[HttpPost]
|
||||
[Authorize(Policy = "permissions:admin.system.customisation.themes.write")]
|
||||
public async Task<ActionResult<ThemeResponse>> Create([FromBody] CreateThemeRequest request)
|
||||
public async Task<ActionResult<ThemeResponse>> CreateAsync([FromBody] CreateThemeRequest request)
|
||||
{
|
||||
var theme = ThemeMapper.ToTheme(request);
|
||||
|
||||
@@ -108,7 +108,7 @@ public class ThemesController : Controller
|
||||
|
||||
[HttpPatch("{id:int}")]
|
||||
[Authorize(Policy = "permissions:admin.system.customisation.themes.write")]
|
||||
public async Task<ActionResult<ThemeResponse>> Update([FromRoute] int id, [FromBody] UpdateThemeRequest request)
|
||||
public async Task<ActionResult<ThemeResponse>> UpdateAsync([FromRoute] int id, [FromBody] UpdateThemeRequest request)
|
||||
{
|
||||
var theme = await ThemeRepository
|
||||
.Get()
|
||||
@@ -141,7 +141,7 @@ public class ThemesController : Controller
|
||||
|
||||
[HttpDelete("{id:int}")]
|
||||
[Authorize(Policy = "permissions:admin.system.customisation.themes.write")]
|
||||
public async Task<ActionResult> Delete([FromRoute] int id)
|
||||
public async Task<ActionResult> DeleteAsync([FromRoute] int id)
|
||||
{
|
||||
var theme = await ThemeRepository
|
||||
.Get()
|
||||
|
||||
@@ -21,7 +21,7 @@ public class DiagnoseController : Controller
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult> Diagnose([FromBody] GenerateDiagnoseRequest request)
|
||||
public async Task<ActionResult> DiagnoseAsync([FromBody] GenerateDiagnoseRequest request)
|
||||
{
|
||||
var stream = await DiagnoseService.GenerateDiagnoseAsync(request.Providers);
|
||||
|
||||
@@ -29,7 +29,7 @@ public class DiagnoseController : Controller
|
||||
}
|
||||
|
||||
[HttpGet("providers")]
|
||||
public async Task<ActionResult<DiagnoseProvideResponse[]>> GetProviders()
|
||||
public async Task<ActionResult<DiagnoseProvideResponse[]>> GetProvidersAsync()
|
||||
{
|
||||
return await DiagnoseService.GetProvidersAsync();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class CombineController : Controller
|
||||
}
|
||||
|
||||
[HttpPost("combine")]
|
||||
public async Task<IResult> Combine([FromBody] CombineRequest request)
|
||||
public async Task<IResult> CombineAsync([FromBody] CombineRequest request)
|
||||
{
|
||||
// Validate file lenght
|
||||
if (request.Files.Length < 2)
|
||||
|
||||
@@ -19,7 +19,7 @@ public class CompressController : Controller
|
||||
private const string BaseDirectory = "storage";
|
||||
|
||||
[HttpPost("compress")]
|
||||
public async Task<IResult> Compress([FromBody] CompressRequest request)
|
||||
public async Task<IResult> CompressAsync([FromBody] CompressRequest request)
|
||||
{
|
||||
// Validate item length
|
||||
if (request.Items.Length == 0)
|
||||
@@ -48,11 +48,11 @@ public class CompressController : Controller
|
||||
switch (request.Format)
|
||||
{
|
||||
case "tar.gz":
|
||||
await CompressTarGz(destinationPath, itemsPaths, rootPath);
|
||||
await CompressTarGzAsync(destinationPath, itemsPaths, rootPath);
|
||||
break;
|
||||
|
||||
case "zip":
|
||||
await CompressZip(destinationPath, itemsPaths, rootPath);
|
||||
await CompressZipAsync(destinationPath, itemsPaths, rootPath);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -66,14 +66,14 @@ public class CompressController : Controller
|
||||
|
||||
#region Tar Gz
|
||||
|
||||
private async Task CompressTarGz(string destination, IEnumerable<string> items, string root)
|
||||
private async Task CompressTarGzAsync(string destination, IEnumerable<string> items, string root)
|
||||
{
|
||||
await using var outStream = System.IO.File.Create(destination);
|
||||
await using var gzoStream = new GZipOutputStream(outStream);
|
||||
await using var tarStream = new TarOutputStream(gzoStream, Encoding.UTF8);
|
||||
|
||||
foreach (var item in items)
|
||||
await CompressItemToTarGz(tarStream, item, root);
|
||||
await CompressItemToTarGzAsync(tarStream, item, root);
|
||||
|
||||
await tarStream.FlushAsync();
|
||||
await gzoStream.FlushAsync();
|
||||
@@ -84,7 +84,7 @@ public class CompressController : Controller
|
||||
outStream.Close();
|
||||
}
|
||||
|
||||
private async Task CompressItemToTarGz(TarOutputStream tarOutputStream, string item, string root)
|
||||
private async Task CompressItemToTarGzAsync(TarOutputStream tarOutputStream, string item, string root)
|
||||
{
|
||||
if (System.IO.File.Exists(item))
|
||||
{
|
||||
@@ -117,7 +117,7 @@ public class CompressController : Controller
|
||||
if (Directory.Exists(item))
|
||||
{
|
||||
foreach (var fsEntry in Directory.EnumerateFileSystemEntries(item))
|
||||
await CompressItemToTarGz(tarOutputStream, fsEntry, root);
|
||||
await CompressItemToTarGzAsync(tarOutputStream, fsEntry, root);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,13 +125,13 @@ public class CompressController : Controller
|
||||
|
||||
#region ZIP
|
||||
|
||||
private async Task CompressZip(string destination, IEnumerable<string> items, string root)
|
||||
private async Task CompressZipAsync(string destination, IEnumerable<string> items, string root)
|
||||
{
|
||||
await using var outStream = System.IO.File.Create(destination);
|
||||
await using var zipOutputStream = new ZipOutputStream(outStream);
|
||||
|
||||
foreach (var item in items)
|
||||
await AddItemToZip(zipOutputStream, item, root);
|
||||
await AddItemToZipAsync(zipOutputStream, item, root);
|
||||
|
||||
await zipOutputStream.FlushAsync();
|
||||
await outStream.FlushAsync();
|
||||
@@ -140,7 +140,7 @@ public class CompressController : Controller
|
||||
outStream.Close();
|
||||
}
|
||||
|
||||
private async Task AddItemToZip(ZipOutputStream outputStream, string item, string root)
|
||||
private async Task AddItemToZipAsync(ZipOutputStream outputStream, string item, string root)
|
||||
{
|
||||
if (System.IO.File.Exists(item))
|
||||
{
|
||||
@@ -175,7 +175,7 @@ public class CompressController : Controller
|
||||
if (Directory.Exists(item))
|
||||
{
|
||||
foreach (var subItem in Directory.EnumerateFileSystemEntries(item))
|
||||
await AddItemToZip(outputStream, subItem, root);
|
||||
await AddItemToZipAsync(outputStream, subItem, root);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class DecompressController : Controller
|
||||
private const string BaseDirectory = "storage";
|
||||
|
||||
[HttpPost("decompress")]
|
||||
public async Task Decompress([FromBody] DecompressRequest request)
|
||||
public async Task DecompressAsync([FromBody] DecompressRequest request)
|
||||
{
|
||||
var path = Path.Combine(BaseDirectory, FilePathHelper.SanitizePath(request.Path));
|
||||
var destination = Path.Combine(BaseDirectory, FilePathHelper.SanitizePath(request.Destination));
|
||||
@@ -25,18 +25,18 @@ public class DecompressController : Controller
|
||||
switch (request.Format)
|
||||
{
|
||||
case "tar.gz":
|
||||
await DecompressTarGz(path, destination);
|
||||
await DecompressTarGzAsync(path, destination);
|
||||
break;
|
||||
|
||||
case "zip":
|
||||
await DecompressZip(path, destination);
|
||||
await DecompressZipAsync(path, destination);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#region Tar Gz
|
||||
|
||||
private async Task DecompressTarGz(string path, string destination)
|
||||
private async Task DecompressTarGzAsync(string path, string destination)
|
||||
{
|
||||
await using var fs = System.IO.File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
await using var gzipInputStream = new GZipInputStream(fs);
|
||||
@@ -74,7 +74,7 @@ public class DecompressController : Controller
|
||||
|
||||
#region Zip
|
||||
|
||||
private async Task DecompressZip(string path, string destination)
|
||||
private async Task DecompressZipAsync(string path, string destination)
|
||||
{
|
||||
await using var fs = System.IO.File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
await using var zipInputStream = new ZipInputStream(fs);
|
||||
|
||||
@@ -25,7 +25,7 @@ public class DownloadUrlController : Controller
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task Get([FromQuery] string path)
|
||||
public async Task GetAsync([FromQuery] string path)
|
||||
{
|
||||
var physicalPath = Path.Combine(BaseDirectory, FilePathHelper.SanitizePath(path));
|
||||
var name = Path.GetFileName(physicalPath);
|
||||
@@ -55,7 +55,7 @@ public class DownloadUrlController : Controller
|
||||
await using var zipStream = new ZipOutputStream(Response.Body);
|
||||
zipStream.IsStreamOwner = false;
|
||||
|
||||
await StreamFolderAsZip(zipStream, physicalPath, baseDirectory, HttpContext.RequestAborted);
|
||||
await StreamFolderAsZipAsync(zipStream, physicalPath, baseDirectory, HttpContext.RequestAborted);
|
||||
}
|
||||
catch (ZipException)
|
||||
{
|
||||
@@ -68,7 +68,7 @@ public class DownloadUrlController : Controller
|
||||
}
|
||||
}
|
||||
|
||||
private async Task StreamFolderAsZip(
|
||||
private async Task StreamFolderAsZipAsync(
|
||||
ZipOutputStream zipStream,
|
||||
string path, string rootPath,
|
||||
CancellationToken cancellationToken
|
||||
@@ -102,7 +102,7 @@ public class DownloadUrlController : Controller
|
||||
if (HttpContext.RequestAborted.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
await StreamFolderAsZip(zipStream, directory, rootPath, cancellationToken);
|
||||
await StreamFolderAsZipAsync(zipStream, directory, rootPath, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class DownloadUrlController : Controller
|
||||
// Yes I know we can just create that url on the client as the exist validation is done on both endpoints,
|
||||
// but we leave it here for future modifications. E.g. using a distributed file provider or smth like that
|
||||
[HttpPost]
|
||||
public Task<DownloadUrlResponse> Post([FromQuery] string path)
|
||||
public Task<DownloadUrlResponse> PostAsync([FromQuery] string path)
|
||||
{
|
||||
var safePath = FilePathHelper.SanitizePath(path);
|
||||
var physicalPath = Path.Combine(BaseDirectory, safePath);
|
||||
|
||||
@@ -15,7 +15,7 @@ public class FilesController : Controller
|
||||
private const string BaseDirectory = "storage";
|
||||
|
||||
[HttpPost("touch")]
|
||||
public async Task CreateFile([FromQuery] string path)
|
||||
public async Task CreateFileAsync([FromQuery] string path)
|
||||
{
|
||||
var safePath = FilePathHelper.SanitizePath(path);
|
||||
var physicalPath = Path.Combine(BaseDirectory, safePath);
|
||||
@@ -31,7 +31,7 @@ public class FilesController : Controller
|
||||
}
|
||||
|
||||
[HttpPost("mkdir")]
|
||||
public Task CreateFolder([FromQuery] string path)
|
||||
public Task CreateFolderAsync([FromQuery] string path)
|
||||
{
|
||||
var safePath = FilePathHelper.SanitizePath(path);
|
||||
var physicalPath = Path.Combine(BaseDirectory, safePath);
|
||||
@@ -47,7 +47,7 @@ public class FilesController : Controller
|
||||
}
|
||||
|
||||
[HttpGet("list")]
|
||||
public Task<FileSystemEntryResponse[]> List([FromQuery] string path)
|
||||
public Task<FileSystemEntryResponse[]> ListAsync([FromQuery] string path)
|
||||
{
|
||||
var safePath = FilePathHelper.SanitizePath(path);
|
||||
var physicalPath = Path.Combine(BaseDirectory, safePath);
|
||||
@@ -92,7 +92,7 @@ public class FilesController : Controller
|
||||
}
|
||||
|
||||
[HttpPost("move")]
|
||||
public Task Move([FromQuery] string oldPath, [FromQuery] string newPath)
|
||||
public Task MoveAsync([FromQuery] string oldPath, [FromQuery] string newPath)
|
||||
{
|
||||
var oldSafePath = FilePathHelper.SanitizePath(oldPath);
|
||||
var newSafePath = FilePathHelper.SanitizePath(newPath);
|
||||
@@ -123,7 +123,7 @@ public class FilesController : Controller
|
||||
}
|
||||
|
||||
[HttpDelete("delete")]
|
||||
public Task Delete([FromQuery] string path)
|
||||
public Task DeleteAsync([FromQuery] string path)
|
||||
{
|
||||
var safePath = FilePathHelper.SanitizePath(path);
|
||||
var physicalDirPath = Path.Combine(BaseDirectory, safePath);
|
||||
@@ -141,7 +141,7 @@ public class FilesController : Controller
|
||||
}
|
||||
|
||||
[HttpPost("upload")]
|
||||
public async Task<IResult> Upload([FromQuery] string path)
|
||||
public async Task<IResult> UploadAsync([FromQuery] string path)
|
||||
{
|
||||
if (Request.Form.Files.Count != 1)
|
||||
return Results.Problem("Only one file is allowed in the request", statusCode: 400);
|
||||
@@ -179,7 +179,7 @@ public class FilesController : Controller
|
||||
}
|
||||
|
||||
[HttpGet("download")]
|
||||
public async Task Download([FromQuery] string path)
|
||||
public async Task DownloadAsync([FromQuery] string path)
|
||||
{
|
||||
var safePath = FilePathHelper.SanitizePath(path);
|
||||
var physicalPath = Path.Combine(BaseDirectory, safePath);
|
||||
|
||||
@@ -18,7 +18,7 @@ public class HangfireController : Controller
|
||||
}
|
||||
|
||||
[HttpGet("stats")]
|
||||
public Task<HangfireStatsResponse> GetStats()
|
||||
public Task<HangfireStatsResponse> GetStatsAsync()
|
||||
{
|
||||
var statistics = JobStorage.GetMonitoringApi().GetStatistics();
|
||||
|
||||
|
||||
@@ -18,21 +18,21 @@ public class SystemController : Controller
|
||||
|
||||
[HttpGet]
|
||||
[Authorize(Policy = "permissions:admin.system.overview")]
|
||||
public async Task<SystemOverviewResponse> GetOverview()
|
||||
public async Task<SystemOverviewResponse> GetOverviewAsync()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
Uptime = await ApplicationService.GetUptime(),
|
||||
CpuUsage = await ApplicationService.GetCpuUsage(),
|
||||
MemoryUsage = await ApplicationService.GetMemoryUsage(),
|
||||
OperatingSystem = await ApplicationService.GetOsName()
|
||||
Uptime = await ApplicationService.GetUptimeAsync(),
|
||||
CpuUsage = await ApplicationService.GetCpuUsageAsync(),
|
||||
MemoryUsage = await ApplicationService.GetMemoryUsageAsync(),
|
||||
OperatingSystem = await ApplicationService.GetOsNameAsync()
|
||||
};
|
||||
}
|
||||
|
||||
[HttpPost("shutdown")]
|
||||
[Authorize(Policy = "permissions:admin.system.shutdown")]
|
||||
public async Task Shutdown()
|
||||
public async Task ShutdownAsync()
|
||||
{
|
||||
await ApplicationService.Shutdown();
|
||||
await ApplicationService.ShutdownAsync();
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public class UsersController : Controller
|
||||
|
||||
[HttpGet]
|
||||
[Authorize(Policy = "permissions:admin.users.get")]
|
||||
public async Task<ActionResult<ICountedData<UserResponse>>> Get(
|
||||
public async Task<ActionResult<ICountedData<UserResponse>>> GetAsync(
|
||||
[FromQuery] int startIndex,
|
||||
[FromQuery] int count,
|
||||
[FromQuery] string? orderBy,
|
||||
@@ -83,7 +83,7 @@ public class UsersController : Controller
|
||||
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Policy = "permissions:admin.users.get")]
|
||||
public async Task<ActionResult<UserResponse>> GetSingle(int id)
|
||||
public async Task<ActionResult<UserResponse>> GetSingleAsync(int id)
|
||||
{
|
||||
var user = await UserRepository
|
||||
.Get()
|
||||
@@ -98,7 +98,7 @@ public class UsersController : Controller
|
||||
|
||||
[HttpPost]
|
||||
[Authorize(Policy = "permissions:admin.users.create")]
|
||||
public async Task<ActionResult<UserResponse>> Create([FromBody] CreateUserRequest request)
|
||||
public async Task<ActionResult<UserResponse>> CreateAsync([FromBody] CreateUserRequest request)
|
||||
{
|
||||
// Reformat values
|
||||
request.Username = request.Username.ToLower().Trim();
|
||||
@@ -128,7 +128,7 @@ public class UsersController : Controller
|
||||
|
||||
[HttpPatch("{id}")]
|
||||
[Authorize(Policy = "permissions:admin.users.update")]
|
||||
public async Task<ActionResult<UserResponse>> Update([FromRoute] int id, [FromBody] UpdateUserRequest request)
|
||||
public async Task<ActionResult<UserResponse>> UpdateAsync([FromRoute] int id, [FromBody] UpdateUserRequest request)
|
||||
{
|
||||
var user = await UserRepository
|
||||
.Get()
|
||||
@@ -171,7 +171,7 @@ public class UsersController : Controller
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Policy = "permissions:admin.users.delete")]
|
||||
public async Task<ActionResult> Delete([FromRoute] int id, [FromQuery] bool force = false)
|
||||
public async Task<ActionResult> DeleteAsync([FromRoute] int id, [FromQuery] bool force = false)
|
||||
{
|
||||
var user = await UserRepository
|
||||
.Get()
|
||||
@@ -184,13 +184,13 @@ public class UsersController : Controller
|
||||
|
||||
if (!force)
|
||||
{
|
||||
var validationResult = await deletionService.Validate(user);
|
||||
var validationResult = await deletionService.ValidateAsync(user);
|
||||
|
||||
if (!validationResult.IsAllowed)
|
||||
return Problem("Unable to delete user", statusCode: 400, title: validationResult.Reason);
|
||||
}
|
||||
|
||||
await deletionService.Delete(user, force);
|
||||
await deletionService.DeleteAsync(user, force);
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public class AuthController : Controller
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<AuthSchemeResponse[]> GetSchemes()
|
||||
public async Task<AuthSchemeResponse[]> GetSchemesAsync()
|
||||
{
|
||||
var schemes = await SchemeProvider.GetAllSchemesAsync();
|
||||
|
||||
@@ -47,7 +47,7 @@ public class AuthController : Controller
|
||||
}
|
||||
|
||||
[HttpGet("{identifier:alpha}")]
|
||||
public async Task StartScheme([FromRoute] string identifier)
|
||||
public async Task StartSchemeAsync([FromRoute] string identifier)
|
||||
{
|
||||
// Validate identifier against our enable list
|
||||
var allowedSchemes = Configuration.Authentication.EnabledSchemes;
|
||||
@@ -91,7 +91,7 @@ public class AuthController : Controller
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("check")]
|
||||
public async Task<AuthClaimResponse[]> Check()
|
||||
public async Task<AuthClaimResponse[]> CheckAsync()
|
||||
{
|
||||
var username = User.FindFirstValue(ClaimTypes.Name)!;
|
||||
var id = User.FindFirstValue(ClaimTypes.NameIdentifier)!;
|
||||
@@ -113,7 +113,7 @@ public class AuthController : Controller
|
||||
foreach (var extension in Extensions)
|
||||
{
|
||||
claims.AddRange(
|
||||
await extension.GetFrontendClaims(User)
|
||||
await extension.GetFrontendClaimsAsync(User)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public class AuthController : Controller
|
||||
}
|
||||
|
||||
[HttpGet("logout")]
|
||||
public async Task Logout()
|
||||
public async Task LogoutAsync()
|
||||
{
|
||||
await HttpContext.SignOutAsync();
|
||||
await Results.Redirect("/").ExecuteAsync(HttpContext);
|
||||
|
||||
@@ -18,13 +18,13 @@ public class FrontendController : Controller
|
||||
}
|
||||
|
||||
[HttpGet("frontend.json")]
|
||||
public async Task<FrontendConfiguration> GetConfiguration()
|
||||
=> await FrontendService.GetConfiguration();
|
||||
public async Task<FrontendConfiguration> GetConfigurationAsync()
|
||||
=> await FrontendService.GetConfigurationAsync();
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IResult> Index()
|
||||
public async Task<IResult> IndexAsync()
|
||||
{
|
||||
var content = await FrontendService.GenerateIndexHtml();
|
||||
var content = await FrontendService.GenerateIndexHtmlAsync();
|
||||
|
||||
return Results.Text(content, "text/html", Encoding.UTF8);
|
||||
}
|
||||
|
||||
@@ -45,29 +45,29 @@ public class LocalAuthController : Controller
|
||||
|
||||
[HttpGet]
|
||||
[HttpGet("login")]
|
||||
public async Task<IResult> Login()
|
||||
public async Task<ActionResult> LoginAsync()
|
||||
{
|
||||
var html = await ComponentHelper.RenderComponent<Login>(ServiceProvider);
|
||||
var html = await ComponentHelper.RenderToHtmlAsync<Login>(ServiceProvider);
|
||||
|
||||
return Results.Content(html, "text/html");
|
||||
return Content(html, "text/html");
|
||||
}
|
||||
|
||||
[HttpGet("register")]
|
||||
public async Task<IResult> Register()
|
||||
public async Task<ActionResult> RegisterAsync()
|
||||
{
|
||||
var html = await ComponentHelper.RenderComponent<Register>(ServiceProvider);
|
||||
var html = await ComponentHelper.RenderToHtmlAsync<Register>(ServiceProvider);
|
||||
|
||||
return Results.Content(html, "text/html");
|
||||
return Content(html, "text/html");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[HttpPost("login")]
|
||||
public async Task<IResult> Login([FromForm] string email, [FromForm] string password)
|
||||
public async Task<ActionResult> LoginAsync([FromForm] string email, [FromForm] string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Perform login
|
||||
var user = await InternalLogin(email, password);
|
||||
var user = await InternalLoginAsync(email, password);
|
||||
|
||||
// Login user
|
||||
var options = Options.Get(LocalAuthConstants.AuthenticationScheme);
|
||||
@@ -84,34 +84,34 @@ public class LocalAuthController : Controller
|
||||
), new AuthenticationProperties());
|
||||
|
||||
// Redirect back to wasm app
|
||||
return Results.Redirect("/");
|
||||
return Redirect("/");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
string errorMessage;
|
||||
|
||||
if (e is HttpApiException apiException)
|
||||
errorMessage = apiException.Title;
|
||||
if (e is AggregateException aggregateException)
|
||||
errorMessage = aggregateException.Message;
|
||||
else
|
||||
{
|
||||
errorMessage = "An internal error occured";
|
||||
Logger.LogError(e, "An unhandled error occured while logging in user");
|
||||
}
|
||||
|
||||
var html = await ComponentHelper.RenderComponent<Login>(ServiceProvider,
|
||||
var html = await ComponentHelper.RenderToHtmlAsync<Login>(ServiceProvider,
|
||||
parameters => { parameters["ErrorMessage"] = errorMessage; });
|
||||
|
||||
return Results.Content(html, "text/html");
|
||||
return Content(html, "text/html");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("register")]
|
||||
public async Task<IResult> Register([FromForm] string email, [FromForm] string password, [FromForm] string username)
|
||||
public async Task<ActionResult> RegisterAsync([FromForm] string email, [FromForm] string password, [FromForm] string username)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Perform register
|
||||
var user = await InternalRegister(username, email, password);
|
||||
var user = await InternalRegisterAsync(username, email, password);
|
||||
|
||||
// Login user
|
||||
var options = Options.Get(LocalAuthConstants.AuthenticationScheme);
|
||||
@@ -128,37 +128,37 @@ public class LocalAuthController : Controller
|
||||
), new AuthenticationProperties());
|
||||
|
||||
// Redirect back to wasm app
|
||||
return Results.Redirect("/");
|
||||
return Redirect("/");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
string errorMessage;
|
||||
|
||||
if (e is HttpApiException apiException)
|
||||
errorMessage = apiException.Title;
|
||||
if (e is AggregateException aggregateException)
|
||||
errorMessage = aggregateException.Message;
|
||||
else
|
||||
{
|
||||
errorMessage = "An internal error occured";
|
||||
Logger.LogError(e, "An unhandled error occured while logging in user");
|
||||
}
|
||||
|
||||
var html = await ComponentHelper.RenderComponent<Register>(ServiceProvider,
|
||||
var html = await ComponentHelper.RenderToHtmlAsync<Register>(ServiceProvider,
|
||||
parameters => { parameters["ErrorMessage"] = errorMessage; });
|
||||
|
||||
return Results.Content(html, "text/html");
|
||||
return Content(html, "text/html");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<User> InternalRegister(string username, string email, string password)
|
||||
private async Task<User> InternalRegisterAsync(string username, string email, string password)
|
||||
{
|
||||
email = email.ToLower();
|
||||
username = username.ToLower();
|
||||
|
||||
if (await UserRepository.Get().AnyAsync(x => x.Username == username))
|
||||
throw new HttpApiException("A account with that username already exists", 400);
|
||||
throw new AggregateException("A account with that username already exists");
|
||||
|
||||
if (await UserRepository.Get().AnyAsync(x => x.Email == email))
|
||||
throw new HttpApiException("A account with that email already exists", 400);
|
||||
throw new AggregateException("A account with that email already exists");
|
||||
|
||||
string[] permissions = [];
|
||||
|
||||
@@ -185,7 +185,7 @@ public class LocalAuthController : Controller
|
||||
return finalUser;
|
||||
}
|
||||
|
||||
private async Task<User> InternalLogin(string email, string password)
|
||||
private async Task<User> InternalLoginAsync(string email, string password)
|
||||
{
|
||||
email = email.ToLower();
|
||||
|
||||
@@ -194,10 +194,10 @@ public class LocalAuthController : Controller
|
||||
.FirstOrDefaultAsync(x => x.Email == email);
|
||||
|
||||
if (user == null)
|
||||
throw new HttpApiException("Invalid combination of email and password", 400);
|
||||
throw new AggregateException("Invalid combination of email and password");
|
||||
|
||||
if (!HashHelper.Verify(password, user.Password))
|
||||
throw new HttpApiException("Invalid combination of email and password", 400);
|
||||
throw new AggregateException("Invalid combination of email and password");
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class SwaggerController : Controller
|
||||
|
||||
[HttpGet]
|
||||
[Authorize]
|
||||
public async Task<ActionResult> Get()
|
||||
public async Task<ActionResult> GetAsync()
|
||||
{
|
||||
if (!Configuration.Development.EnableApiDocs)
|
||||
return BadRequest("Api docs are disabled");
|
||||
@@ -32,7 +32,7 @@ public class SwaggerController : Controller
|
||||
var options = new ApiDocsOptions();
|
||||
var optionsJson = JsonSerializer.Serialize(options);
|
||||
|
||||
var html = await ComponentHelper.RenderComponent<SwaggerPage>(
|
||||
var html = await ComponentHelper.RenderToHtmlAsync<SwaggerPage>(
|
||||
ServiceProvider,
|
||||
parameters =>
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Moonlight.ApiServer.Http.Hubs;
|
||||
public class DiagnoseHub : Hub
|
||||
{
|
||||
[HubMethodName("Ping")]
|
||||
public async Task Ping()
|
||||
public async Task PingAsync()
|
||||
{
|
||||
await Clients.All.SendAsync("Pong");
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ public class ApplicationMetric : IMetric
|
||||
private Gauge<int> CpuUsage;
|
||||
private Gauge<double> Uptime;
|
||||
|
||||
public Task Initialize(Meter meter)
|
||||
public Task InitializeAsync(Meter meter)
|
||||
{
|
||||
MemoryUsage = meter.CreateGauge<long>("moonlight_memory_usage");
|
||||
CpuUsage = meter.CreateGauge<int>("moonlight_cpu_usage");
|
||||
@@ -20,17 +20,17 @@ public class ApplicationMetric : IMetric
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task Run(IServiceProvider provider, CancellationToken cancellationToken)
|
||||
public async Task RunAsync(IServiceProvider provider, CancellationToken cancellationToken)
|
||||
{
|
||||
var applicationService = provider.GetRequiredService<ApplicationService>();
|
||||
|
||||
var memory = await applicationService.GetMemoryUsage();
|
||||
var memory = await applicationService.GetMemoryUsageAsync();
|
||||
MemoryUsage.Record(memory);
|
||||
|
||||
var uptime = await applicationService.GetUptime();
|
||||
var uptime = await applicationService.GetUptimeAsync();
|
||||
Uptime.Record(uptime.TotalSeconds);
|
||||
|
||||
var cpu = await applicationService.GetCpuUsage();
|
||||
var cpu = await applicationService.GetCpuUsageAsync();
|
||||
CpuUsage.Record(cpu);
|
||||
}
|
||||
}
|
||||
@@ -11,14 +11,14 @@ public class UsersMetric : IMetric
|
||||
{
|
||||
private Gauge<int> Users;
|
||||
|
||||
public Task Initialize(Meter meter)
|
||||
public Task InitializeAsync(Meter meter)
|
||||
{
|
||||
Users = meter.CreateGauge<int>("moonlight_users");
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task Run(IServiceProvider provider, CancellationToken cancellationToken)
|
||||
public async Task RunAsync(IServiceProvider provider, CancellationToken cancellationToken)
|
||||
{
|
||||
var usersRepo = provider.GetRequiredService<DatabaseRepository<User>>();
|
||||
var count = await usersRepo.Get().CountAsync(cancellationToken: cancellationToken);
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Moonlight.ApiServer.Implementations.Startup;
|
||||
|
||||
public class CoreStartup : IPluginStartup
|
||||
{
|
||||
public Task BuildApplication(IServiceProvider serviceProvider, IHostApplicationBuilder builder)
|
||||
public Task BuildApplicationAsync(IServiceProvider serviceProvider, IHostApplicationBuilder builder)
|
||||
{
|
||||
var configuration = serviceProvider.GetRequiredService<AppConfiguration>();
|
||||
|
||||
@@ -142,7 +142,7 @@ public class CoreStartup : IPluginStartup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task ConfigureApplication(IServiceProvider serviceProvider, IApplicationBuilder app)
|
||||
public Task ConfigureApplicationAsync(IServiceProvider serviceProvider, IApplicationBuilder app)
|
||||
{
|
||||
var configuration = serviceProvider.GetRequiredService<AppConfiguration>();
|
||||
|
||||
@@ -156,7 +156,7 @@ public class CoreStartup : IPluginStartup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task ConfigureEndpoints(IServiceProvider serviceProvider, IEndpointRouteBuilder routeBuilder)
|
||||
public Task ConfigureEndpointsAsync(IServiceProvider serviceProvider, IEndpointRouteBuilder routeBuilder)
|
||||
{
|
||||
var configuration = serviceProvider.GetRequiredService<AppConfiguration>();
|
||||
|
||||
|
||||
@@ -12,5 +12,5 @@ public interface IAuthCheckExtension
|
||||
/// </summary>
|
||||
/// <param name="principal">The principal of the current signed-in user</param>
|
||||
/// <returns>An array of claim responses which gets added to the list of claims to send to the frontend</returns>
|
||||
public Task<AuthClaimResponse[]> GetFrontendClaims(ClaimsPrincipal principal);
|
||||
public Task<AuthClaimResponse[]> GetFrontendClaimsAsync(ClaimsPrincipal principal);
|
||||
}
|
||||
@@ -4,6 +4,6 @@ namespace Moonlight.ApiServer.Interfaces;
|
||||
|
||||
public interface IMetric
|
||||
{
|
||||
public Task Initialize(Meter meter);
|
||||
public Task Run(IServiceProvider provider, CancellationToken cancellationToken);
|
||||
public Task InitializeAsync(Meter meter);
|
||||
public Task RunAsync(IServiceProvider provider, CancellationToken cancellationToken);
|
||||
}
|
||||
@@ -12,7 +12,7 @@ public interface IUserAuthExtension
|
||||
/// <param name="user">The current user this method is called for</param>
|
||||
/// <param name="principal">The principal after being processed by moonlight itself</param>
|
||||
/// <returns>The result of the synchronisation. Returning false will immediately invalidate the sign-in and no other extensions will be called</returns>
|
||||
public Task<bool> Sync(User user, ClaimsPrincipal principal);
|
||||
public Task<bool> SyncAsync(User user, ClaimsPrincipal principal);
|
||||
|
||||
/// <summary>
|
||||
/// IMPORTANT: Please note that heavy operations should not occur in this method as it will be called for every request
|
||||
@@ -21,5 +21,5 @@ public interface IUserAuthExtension
|
||||
/// <param name="user">The current user this method is called for</param>
|
||||
/// <param name="principal">The principal after being processed by moonlight itself</param>
|
||||
/// <returns>The result of the validation. Returning false will immediately invalidate the users session and no other extensions will be called</returns>
|
||||
public Task<bool> Validate(User user, ClaimsPrincipal principal);
|
||||
public Task<bool> ValidateAsync(User user, ClaimsPrincipal principal);
|
||||
}
|
||||
@@ -5,6 +5,6 @@ namespace Moonlight.ApiServer.Interfaces;
|
||||
|
||||
public interface IUserDeleteHandler
|
||||
{
|
||||
public Task<UserDeleteValidationResult> Validate(User user);
|
||||
public Task Delete(User user, bool force);
|
||||
public Task<UserDeleteValidationResult> ValidateAsync(User user);
|
||||
public Task DeleteAsync(User user, bool force);
|
||||
}
|
||||
@@ -27,9 +27,10 @@
|
||||
<PackageReference Include="Hangfire.EntityFrameworkCore" Version="0.7.0"/>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.9" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.StackExchangeRedis" Version="9.0.9" />
|
||||
<PackageReference Include="MoonCore" Version="1.9.9" />
|
||||
<PackageReference Include="MoonCore.Extended" Version="1.3.8" />
|
||||
<PackageReference Include="MoonCore" Version="2.0.0" />
|
||||
<PackageReference Include="MoonCore.Extended" Version="1.3.9" />
|
||||
<PackageReference Include="MoonCore.PluginFramework.Generator" Version="1.0.2"/>
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
||||
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.12.0" />
|
||||
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.12.0-beta.1"/>
|
||||
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.12.0"/>
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Moonlight.ApiServer.Plugins;
|
||||
|
||||
public interface IPluginStartup
|
||||
{
|
||||
public Task BuildApplication(IServiceProvider serviceProvider, IHostApplicationBuilder builder);
|
||||
public Task ConfigureApplication(IServiceProvider serviceProvider, IApplicationBuilder app);
|
||||
public Task ConfigureEndpoints(IServiceProvider serviceProvider, IEndpointRouteBuilder routeBuilder);
|
||||
public Task BuildApplicationAsync(IServiceProvider serviceProvider, IHostApplicationBuilder builder);
|
||||
public Task ConfigureApplicationAsync(IServiceProvider serviceProvider, IApplicationBuilder app);
|
||||
public Task ConfigureEndpointsAsync(IServiceProvider serviceProvider, IEndpointRouteBuilder routeBuilder);
|
||||
}
|
||||
@@ -14,7 +14,7 @@ public class ApiKeyAuthService
|
||||
ApiKeyRepository = apiKeyRepository;
|
||||
}
|
||||
|
||||
public async Task<bool> Validate(ClaimsPrincipal? principal)
|
||||
public async Task<bool> ValidateAsync(ClaimsPrincipal? principal)
|
||||
{
|
||||
// Ignore malformed claims principal
|
||||
if (principal is not { Identity.IsAuthenticated: true })
|
||||
|
||||
@@ -19,7 +19,7 @@ public class ApplicationService
|
||||
Host = host;
|
||||
}
|
||||
|
||||
public Task<string> GetOsName()
|
||||
public Task<string> GetOsNameAsync()
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
@@ -58,7 +58,7 @@ public class ApplicationService
|
||||
return Task.FromResult("N/A");
|
||||
}
|
||||
|
||||
public async Task<long> GetMemoryUsage()
|
||||
public async Task<long> GetMemoryUsageAsync()
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
@@ -87,14 +87,14 @@ public class ApplicationService
|
||||
}
|
||||
}
|
||||
|
||||
public Task<TimeSpan> GetUptime()
|
||||
public Task<TimeSpan> GetUptimeAsync()
|
||||
{
|
||||
var process = Process.GetCurrentProcess();
|
||||
var uptime = DateTime.Now - process.StartTime;
|
||||
return Task.FromResult(uptime);
|
||||
}
|
||||
|
||||
public Task<int> GetCpuUsage()
|
||||
public Task<int> GetCpuUsageAsync()
|
||||
{
|
||||
var process = Process.GetCurrentProcess();
|
||||
var cpuTime = process.TotalProcessorTime;
|
||||
@@ -105,7 +105,7 @@ public class ApplicationService
|
||||
return Task.FromResult(cpuUsage);
|
||||
}
|
||||
|
||||
public Task Shutdown()
|
||||
public Task ShutdownAsync()
|
||||
{
|
||||
Logger.LogCritical("Restart of api server has been requested");
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class FrontendService
|
||||
ThemeRepository = themeRepository;
|
||||
}
|
||||
|
||||
public Task<FrontendConfiguration> GetConfiguration()
|
||||
public Task<FrontendConfiguration> GetConfigurationAsync()
|
||||
{
|
||||
var configuration = new FrontendConfiguration()
|
||||
{
|
||||
@@ -51,7 +51,7 @@ public class FrontendService
|
||||
return Task.FromResult(configuration);
|
||||
}
|
||||
|
||||
public async Task<string> GenerateIndexHtml() // TODO: Cache
|
||||
public async Task<string> GenerateIndexHtmlAsync() // TODO: Cache
|
||||
{
|
||||
// Load requested theme
|
||||
var theme = await ThemeRepository
|
||||
@@ -70,7 +70,7 @@ public class FrontendService
|
||||
.Distinct()
|
||||
.ToArray();
|
||||
|
||||
return await ComponentHelper.RenderComponent<FrontendPage>(
|
||||
return await ComponentHelper.RenderToHtmlAsync<FrontendPage>(
|
||||
ServiceProvider,
|
||||
parameters =>
|
||||
{
|
||||
@@ -82,7 +82,7 @@ public class FrontendService
|
||||
);
|
||||
}
|
||||
|
||||
public async Task<Stream> GenerateZip() // TODO: Rework to be able to extract everything successfully
|
||||
public async Task<Stream> GenerateZipAsync() // TODO: Rework to be able to extract everything successfully
|
||||
{
|
||||
// We only allow the access to this function when we are actually hosting the frontend
|
||||
if (!Configuration.Frontend.EnableHosting)
|
||||
@@ -109,16 +109,16 @@ public class FrontendService
|
||||
var zipArchive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true);
|
||||
|
||||
// Add wasm application
|
||||
await ArchiveFsItem(zipArchive, wasmPath, wasmPath);
|
||||
await ArchiveFsItemAsync(zipArchive, wasmPath, wasmPath);
|
||||
|
||||
// Add blazor files
|
||||
await ArchiveFsItem(zipArchive, blazorPath, blazorPath, "_framework/");
|
||||
await ArchiveFsItemAsync(zipArchive, blazorPath, blazorPath, "_framework/");
|
||||
|
||||
// Add frontend.json
|
||||
var frontendConfig = await GetConfiguration();
|
||||
var frontendConfig = await GetConfigurationAsync();
|
||||
frontendConfig.HostEnvironment = "Static";
|
||||
var frontendJson = JsonSerializer.Serialize(frontendConfig);
|
||||
await ArchiveText(zipArchive, "frontend.json", frontendJson);
|
||||
await ArchiveTextAsync(zipArchive, "frontend.json", frontendJson);
|
||||
|
||||
// Finish zip archive and reset stream so the code calling this function can process it
|
||||
zipArchive.Dispose();
|
||||
@@ -128,7 +128,7 @@ public class FrontendService
|
||||
return memoryStream;
|
||||
}
|
||||
|
||||
private async Task ArchiveFsItem(ZipArchive archive, string path, string prefixToRemove, string prefixToAdd = "")
|
||||
private async Task ArchiveFsItemAsync(ZipArchive archive, string path, string prefixToRemove, string prefixToAdd = "")
|
||||
{
|
||||
if (File.Exists(path))
|
||||
{
|
||||
@@ -147,17 +147,17 @@ public class FrontendService
|
||||
else
|
||||
{
|
||||
foreach (var directoryItem in Directory.EnumerateFileSystemEntries(path))
|
||||
await ArchiveFsItem(archive, directoryItem, prefixToRemove, prefixToAdd);
|
||||
await ArchiveFsItemAsync(archive, directoryItem, prefixToRemove, prefixToAdd);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ArchiveText(ZipArchive archive, string path, string content)
|
||||
private async Task ArchiveTextAsync(ZipArchive archive, string path, string content)
|
||||
{
|
||||
var data = Encoding.UTF8.GetBytes(content);
|
||||
await ArchiveBytes(archive, path, data);
|
||||
await ArchiveBytesAsync(archive, path, data);
|
||||
}
|
||||
|
||||
private async Task ArchiveBytes(ZipArchive archive, string path, byte[] bytes)
|
||||
private async Task ArchiveBytesAsync(ZipArchive archive, string path, byte[] bytes)
|
||||
{
|
||||
var entry = archive.CreateEntry(path);
|
||||
await using var dataStream = entry.Open();
|
||||
|
||||
@@ -33,7 +33,7 @@ public class MetricsBackgroundService : BackgroundService
|
||||
Metrics = metrics.ToArray();
|
||||
}
|
||||
|
||||
private async Task Initialize()
|
||||
private async Task InitializeAsync()
|
||||
{
|
||||
Logger.LogDebug(
|
||||
"Initializing metrics: {names}",
|
||||
@@ -41,12 +41,12 @@ public class MetricsBackgroundService : BackgroundService
|
||||
);
|
||||
|
||||
foreach (var metric in Metrics)
|
||||
await metric.Initialize(Meter);
|
||||
await metric.InitializeAsync(Meter);
|
||||
}
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
await Initialize();
|
||||
await InitializeAsync();
|
||||
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
@@ -56,7 +56,7 @@ public class MetricsBackgroundService : BackgroundService
|
||||
{
|
||||
try
|
||||
{
|
||||
await metric.Run(scope.ServiceProvider, stoppingToken);
|
||||
await metric.RunAsync(scope.ServiceProvider, stoppingToken);
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ public class UserAuthService
|
||||
Extensions = extensions;
|
||||
}
|
||||
|
||||
public async Task<bool> Sync(ClaimsPrincipal? principal)
|
||||
public async Task<bool> SyncAsync(ClaimsPrincipal? principal)
|
||||
{
|
||||
// Ignore malformed claims principal
|
||||
if (principal is not { Identity.IsAuthenticated: true })
|
||||
@@ -107,7 +107,7 @@ public class UserAuthService
|
||||
// Call extensions
|
||||
foreach (var extension in Extensions)
|
||||
{
|
||||
var result = await extension.Sync(user, principal);
|
||||
var result = await extension.SyncAsync(user, principal);
|
||||
|
||||
if (!result) // Exit immediately if result is false
|
||||
return false;
|
||||
@@ -116,7 +116,7 @@ public class UserAuthService
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<bool> Validate(ClaimsPrincipal? principal)
|
||||
public async Task<bool> ValidateAsync(ClaimsPrincipal? principal)
|
||||
{
|
||||
// Ignore malformed claims principal
|
||||
if (principal is not { Identity.IsAuthenticated: true })
|
||||
@@ -157,7 +157,7 @@ public class UserAuthService
|
||||
// Call extensions
|
||||
foreach (var extension in Extensions)
|
||||
{
|
||||
var result = await extension.Validate(user, principal);
|
||||
var result = await extension.ValidateAsync(user, principal);
|
||||
|
||||
if (!result) // Exit immediately if result is false
|
||||
return false;
|
||||
|
||||
@@ -19,11 +19,11 @@ public class UserDeletionService
|
||||
Handlers = handlers.ToArray();
|
||||
}
|
||||
|
||||
public async Task<UserDeleteValidationResult> Validate(User user)
|
||||
public async Task<UserDeleteValidationResult> ValidateAsync(User user)
|
||||
{
|
||||
foreach (var handler in Handlers)
|
||||
{
|
||||
var result = await handler.Validate(user);
|
||||
var result = await handler.ValidateAsync(user);
|
||||
|
||||
if (!result.IsAllowed)
|
||||
return result;
|
||||
@@ -32,10 +32,10 @@ public class UserDeletionService
|
||||
return UserDeleteValidationResult.Allow();
|
||||
}
|
||||
|
||||
public async Task Delete(User user, bool force)
|
||||
public async Task DeleteAsync(User user, bool force)
|
||||
{
|
||||
foreach (var handler in Handlers)
|
||||
await handler.Delete(user, force);
|
||||
await handler.DeleteAsync(user, force);
|
||||
|
||||
await UserRepository.RemoveAsync(user);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Moonlight.ApiServer.Startup;
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
private Task RegisterAuth()
|
||||
private Task RegisterAuthAsync()
|
||||
{
|
||||
WebApplicationBuilder.Services
|
||||
.AddAuthentication(options => { options.DefaultScheme = "MainScheme"; })
|
||||
@@ -62,7 +62,7 @@ public partial class Startup
|
||||
.RequestServices
|
||||
.GetRequiredService<ApiKeyAuthService>();
|
||||
|
||||
var result = await apiKeyAuthService.Validate(context.Principal);
|
||||
var result = await apiKeyAuthService.ValidateAsync(context.Principal);
|
||||
|
||||
if (!result)
|
||||
context.Fail("API key has been deleted");
|
||||
@@ -120,7 +120,7 @@ public partial class Startup
|
||||
.RequestServices
|
||||
.GetRequiredService<UserAuthService>();
|
||||
|
||||
var result = await userSyncService.Sync(context.Principal);
|
||||
var result = await userSyncService.SyncAsync(context.Principal);
|
||||
|
||||
if (!result)
|
||||
context.Principal = new();
|
||||
@@ -135,7 +135,7 @@ public partial class Startup
|
||||
.RequestServices
|
||||
.GetRequiredService<UserAuthService>();
|
||||
|
||||
var result = await userSyncService.Validate(context.Principal);
|
||||
var result = await userSyncService.ValidateAsync(context.Principal);
|
||||
|
||||
if (!result)
|
||||
context.RejectPrincipal();
|
||||
@@ -178,7 +178,7 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task UseAuth()
|
||||
private Task UseAuthAsync()
|
||||
{
|
||||
WebApplication.UseAuthentication();
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Moonlight.ApiServer.Startup;
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
private Task RegisterBase()
|
||||
private Task RegisterBaseAsync()
|
||||
{
|
||||
WebApplicationBuilder.Services.AutoAddServices<Startup>();
|
||||
WebApplicationBuilder.Services.AddHttpClient();
|
||||
@@ -29,7 +29,7 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task UseBase()
|
||||
private Task UseBaseAsync()
|
||||
{
|
||||
WebApplication.UseRouting();
|
||||
WebApplication.UseExceptionHandler();
|
||||
@@ -37,7 +37,7 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task MapBase()
|
||||
private Task MapBaseAsync()
|
||||
{
|
||||
WebApplication.MapControllers();
|
||||
|
||||
@@ -47,7 +47,7 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task ConfigureKestrel()
|
||||
private Task ConfigureKestrelAsync()
|
||||
{
|
||||
WebApplicationBuilder.WebHost.ConfigureKestrel(kestrelOptions =>
|
||||
{
|
||||
|
||||
@@ -8,11 +8,11 @@ namespace Moonlight.ApiServer.Startup;
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
private async Task SetupAppConfiguration()
|
||||
private async Task SetupAppConfigurationAsync()
|
||||
{
|
||||
var configPath = Path.Combine("storage", "config.yml");
|
||||
|
||||
await YamlDefaultGenerator.Generate<AppConfiguration>(configPath);
|
||||
await YamlDefaultGenerator.GenerateAsync<AppConfiguration>(configPath);
|
||||
|
||||
// Configure configuration (wow)
|
||||
var configurationBuilder = new ConfigurationBuilder();
|
||||
@@ -27,7 +27,7 @@ public partial class Startup
|
||||
configurationRoot.Bind(Configuration);
|
||||
}
|
||||
|
||||
private Task RegisterAppConfiguration()
|
||||
private Task RegisterAppConfigurationAsync()
|
||||
{
|
||||
WebApplicationBuilder.Services.AddSingleton(Configuration);
|
||||
return Task.CompletedTask;
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Moonlight.ApiServer.Startup;
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
private Task RegisterDatabase()
|
||||
private Task RegisterDatabaseAsync()
|
||||
{
|
||||
WebApplicationBuilder.Services.AddDatabaseMappings();
|
||||
WebApplicationBuilder.Services.AddServiceCollectionAccessor();
|
||||
@@ -16,9 +16,9 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task PrepareDatabase()
|
||||
private async Task PrepareDatabaseAsync()
|
||||
{
|
||||
await WebApplication.Services.EnsureDatabaseMigrated();
|
||||
await WebApplication.Services.EnsureDatabaseMigratedAsync();
|
||||
|
||||
WebApplication.Services.GenerateDatabaseMappings();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Moonlight.ApiServer.Startup;
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
private Task RegisterHangfire()
|
||||
private Task RegisterHangfireAsync()
|
||||
{
|
||||
WebApplicationBuilder.Services.AddHangfire((provider, configuration) =>
|
||||
{
|
||||
@@ -38,7 +38,7 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task UseHangfire()
|
||||
private Task UseHangfireAsync()
|
||||
{
|
||||
if (WebApplication.Environment.IsDevelopment())
|
||||
WebApplication.UseHangfireDashboard();
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Moonlight.ApiServer.Startup;
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
private Task SetupLogging()
|
||||
private Task SetupLoggingAsync()
|
||||
{
|
||||
var loggerFactory = new LoggerFactory();
|
||||
loggerFactory.AddAnsiConsole();
|
||||
@@ -16,7 +16,7 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task RegisterLogging()
|
||||
private async Task RegisterLoggingAsync()
|
||||
{
|
||||
// Configure application logging
|
||||
WebApplicationBuilder.Logging.ClearProviders();
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Moonlight.ApiServer.Startup;
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
private Task PrintVersion()
|
||||
private Task PrintVersionAsync()
|
||||
{
|
||||
// Fancy start console output... yes very fancy :>
|
||||
var rainbow = new Crayon.Rainbow(0.5);
|
||||
@@ -25,7 +25,7 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task CreateStorage()
|
||||
private Task CreateStorageAsync()
|
||||
{
|
||||
Directory.CreateDirectory("storage");
|
||||
Directory.CreateDirectory(Path.Combine("storage", "logs"));
|
||||
@@ -33,7 +33,7 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task RegisterCors()
|
||||
private Task RegisterCorsAsync()
|
||||
{
|
||||
var allowedOrigins = Configuration.Kestrel.AllowedOrigins;
|
||||
|
||||
@@ -64,7 +64,7 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task UseCors()
|
||||
private Task UseCorsAsync()
|
||||
{
|
||||
WebApplication.UseCors();
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ public partial class Startup
|
||||
private IServiceProvider PluginLoadServiceProvider;
|
||||
private IPluginStartup[] PluginStartups;
|
||||
|
||||
private Task InitializePlugins()
|
||||
private Task InitializePluginsAsync()
|
||||
{
|
||||
// Create service provider for starting up
|
||||
var serviceCollection = new ServiceCollection();
|
||||
@@ -28,13 +28,13 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task HookPluginBuild()
|
||||
private async Task HookPluginBuildAsync()
|
||||
{
|
||||
foreach (var pluginAppStartup in PluginStartups)
|
||||
{
|
||||
try
|
||||
{
|
||||
await pluginAppStartup.BuildApplication(PluginLoadServiceProvider, WebApplicationBuilder);
|
||||
await pluginAppStartup.BuildApplicationAsync(PluginLoadServiceProvider, WebApplicationBuilder);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -47,13 +47,13 @@ public partial class Startup
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HookPluginConfigure()
|
||||
private async Task HookPluginConfigureAsync()
|
||||
{
|
||||
foreach (var pluginAppStartup in PluginStartups)
|
||||
{
|
||||
try
|
||||
{
|
||||
await pluginAppStartup.ConfigureApplication(PluginLoadServiceProvider, WebApplication);
|
||||
await pluginAppStartup.ConfigureApplicationAsync(PluginLoadServiceProvider, WebApplication);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -66,13 +66,13 @@ public partial class Startup
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HookPluginEndpoints()
|
||||
private async Task HookPluginEndpointsAsync()
|
||||
{
|
||||
foreach (var pluginEndpointStartup in PluginStartups)
|
||||
{
|
||||
try
|
||||
{
|
||||
await pluginEndpointStartup.ConfigureEndpoints(PluginLoadServiceProvider, WebApplication);
|
||||
await pluginEndpointStartup.ConfigureEndpointsAsync(PluginLoadServiceProvider, WebApplication);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Moonlight.ApiServer.Startup;
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
public Task RegisterSignalR()
|
||||
public Task RegisterSignalRAsync()
|
||||
{
|
||||
var signalRBuilder = WebApplicationBuilder.Services.AddSignalR();
|
||||
|
||||
@@ -16,7 +16,7 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task MapSignalR()
|
||||
public Task MapSignalRAsync()
|
||||
{
|
||||
WebApplication.MapHub<DiagnoseHub>("/api/admin/system/diagnose/ws");
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public partial class Startup
|
||||
public WebApplication WebApplication { get; private set; }
|
||||
public WebApplicationBuilder WebApplicationBuilder { get; private set; }
|
||||
|
||||
public Task Initialize(string[] args, IPluginStartup[]? plugins = null)
|
||||
public Task InitializeAsync(string[] args, IPluginStartup[]? plugins = null)
|
||||
{
|
||||
Args = args;
|
||||
PluginStartups = plugins ?? [];
|
||||
@@ -27,43 +27,43 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task AddMoonlight(WebApplicationBuilder builder)
|
||||
public async Task AddMoonlightAsync(WebApplicationBuilder builder)
|
||||
{
|
||||
WebApplicationBuilder = builder;
|
||||
|
||||
await PrintVersion();
|
||||
await PrintVersionAsync();
|
||||
|
||||
await CreateStorage();
|
||||
await SetupAppConfiguration();
|
||||
await SetupLogging();
|
||||
await InitializePlugins();
|
||||
await CreateStorageAsync();
|
||||
await SetupAppConfigurationAsync();
|
||||
await SetupLoggingAsync();
|
||||
await InitializePluginsAsync();
|
||||
|
||||
await ConfigureKestrel();
|
||||
await RegisterAppConfiguration();
|
||||
await RegisterLogging();
|
||||
await RegisterBase();
|
||||
await RegisterDatabase();
|
||||
await RegisterAuth();
|
||||
await RegisterCors();
|
||||
await RegisterHangfire();
|
||||
await RegisterSignalR();
|
||||
await HookPluginBuild();
|
||||
await ConfigureKestrelAsync();
|
||||
await RegisterAppConfigurationAsync();
|
||||
await RegisterLoggingAsync();
|
||||
await RegisterBaseAsync();
|
||||
await RegisterDatabaseAsync();
|
||||
await RegisterAuthAsync();
|
||||
await RegisterCorsAsync();
|
||||
await RegisterHangfireAsync();
|
||||
await RegisterSignalRAsync();
|
||||
await HookPluginBuildAsync();
|
||||
}
|
||||
|
||||
public async Task AddMoonlight(WebApplication application)
|
||||
public async Task AddMoonlightAsync(WebApplication application)
|
||||
{
|
||||
WebApplication = application;
|
||||
|
||||
await PrepareDatabase();
|
||||
await PrepareDatabaseAsync();
|
||||
|
||||
await UseCors();
|
||||
await UseBase();
|
||||
await UseAuth();
|
||||
await UseHangfire();
|
||||
await HookPluginConfigure();
|
||||
await UseCorsAsync();
|
||||
await UseBaseAsync();
|
||||
await UseAuthAsync();
|
||||
await UseHangfireAsync();
|
||||
await HookPluginConfigureAsync();
|
||||
|
||||
await MapBase();
|
||||
await MapSignalR();
|
||||
await HookPluginEndpoints();
|
||||
await MapBaseAsync();
|
||||
await MapSignalRAsync();
|
||||
await HookPluginEndpointsAsync();
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,8 @@
|
||||
<PackageReference Include="MoonCore.PluginFramework" Version="1.0.8" />
|
||||
<PackageReference Include="MoonCore.PluginFramework.Generator" Version="1.0.2" />
|
||||
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.8" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.8" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.9" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.9" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="Plugins.props" />
|
||||
|
||||
@@ -7,14 +7,14 @@ pluginLoader.Initialize();
|
||||
|
||||
var startup = new Startup();
|
||||
|
||||
await startup.Initialize(pluginLoader.Instances);
|
||||
await startup.InitializeAsync(pluginLoader.Instances);
|
||||
|
||||
var wasmHostBuilder = WebAssemblyHostBuilder.CreateDefault(args);
|
||||
|
||||
await startup.AddMoonlight(wasmHostBuilder);
|
||||
await startup.AddMoonlightAsync(wasmHostBuilder);
|
||||
|
||||
var wasmApp = wasmHostBuilder.Build();
|
||||
|
||||
await startup.AddMoonlight(wasmApp);
|
||||
await startup.AddMoonlightAsync(wasmApp);
|
||||
|
||||
await wasmApp.RunAsync();
|
||||
@@ -114,4 +114,24 @@
|
||||
.dropdown-menu {
|
||||
@apply bg-base-150;
|
||||
}
|
||||
|
||||
.advance-select-menu {
|
||||
@apply !border-base-content/20 border-2 ring-0! outline-0! bg-base-200/50 !px-0;
|
||||
}
|
||||
|
||||
.advance-select-option {
|
||||
@apply !rounded-none hover:!bg-primary;
|
||||
}
|
||||
|
||||
.advance-select-option.selected {
|
||||
@apply !bg-primary !text-primary-content;
|
||||
}
|
||||
|
||||
.advance-select-toggle {
|
||||
@apply !border-base-content/20 border-2 ring-0! outline-0! focus:border-primary! focus-within:border-primary! bg-base-200/50;
|
||||
}
|
||||
|
||||
.table thead {
|
||||
@apply !normal-case;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ namespace Moonlight.Client.Implementations;
|
||||
|
||||
public class CoreStartup : IPluginStartup
|
||||
{
|
||||
public Task BuildApplication(IServiceProvider serviceProvider, WebAssemblyHostBuilder builder)
|
||||
public Task BuildApplicationAsync(IServiceProvider serviceProvider, WebAssemblyHostBuilder builder)
|
||||
{
|
||||
builder.Services.AddSingleton<ISidebarItemProvider, DefaultSidebarItemProvider>();
|
||||
builder.Services.AddSingleton<IOverviewElementProvider, DefaultOverviewElementProvider>();
|
||||
@@ -15,6 +15,6 @@ public class CoreStartup : IPluginStartup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task ConfigureApplication(IServiceProvider serviceProvider, WebAssemblyHost app)
|
||||
public Task ConfigureApplicationAsync(IServiceProvider serviceProvider, WebAssemblyHost app)
|
||||
=> Task.CompletedTask;
|
||||
}
|
||||
@@ -11,7 +11,7 @@ public class LogErrorFilter : IGlobalErrorFilter
|
||||
Logger = logger;
|
||||
}
|
||||
|
||||
public Task<bool> HandleException(Exception ex)
|
||||
public Task<bool> HandleExceptionAsync(Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "Global error processed");
|
||||
return Task.FromResult(false);
|
||||
|
||||
@@ -18,21 +18,21 @@ public class SystemFsAccess : IFsAccess, ICombineAccess, IArchiveAccess, IDownlo
|
||||
ApiClient = apiClient;
|
||||
}
|
||||
|
||||
public async Task CreateFile(string path)
|
||||
public async Task CreateFileAsync(string path)
|
||||
{
|
||||
await ApiClient.Post(
|
||||
$"{BaseApiUrl}/touch?path={path}"
|
||||
);
|
||||
}
|
||||
|
||||
public async Task CreateDirectory(string path)
|
||||
public async Task CreateDirectoryAsync(string path)
|
||||
{
|
||||
await ApiClient.Post(
|
||||
$"{BaseApiUrl}/mkdir?path={path}"
|
||||
);
|
||||
}
|
||||
|
||||
public async Task<FsEntry[]> List(string path)
|
||||
public async Task<FsEntry[]> ListAsync(string path)
|
||||
{
|
||||
var entries = await ApiClient.GetJson<FileSystemEntryResponse[]>(
|
||||
$"{BaseApiUrl}/list?path={path}"
|
||||
@@ -48,14 +48,14 @@ public class SystemFsAccess : IFsAccess, ICombineAccess, IArchiveAccess, IDownlo
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
public async Task Move(string oldPath, string newPath)
|
||||
public async Task MoveAsync(string oldPath, string newPath)
|
||||
{
|
||||
await ApiClient.Post(
|
||||
$"{BaseApiUrl}/move?oldPath={oldPath}&newPath={newPath}"
|
||||
);
|
||||
}
|
||||
|
||||
public async Task Read(string path, Func<Stream, Task> onHandleData)
|
||||
public async Task ReadAsync(string path, Func<Stream, Task> onHandleData)
|
||||
{
|
||||
await using var stream = await ApiClient.GetStream(
|
||||
$"{BaseApiUrl}/download?path={path}"
|
||||
@@ -66,7 +66,7 @@ public class SystemFsAccess : IFsAccess, ICombineAccess, IArchiveAccess, IDownlo
|
||||
stream.Close();
|
||||
}
|
||||
|
||||
public async Task Write(string path, Stream dataStream)
|
||||
public async Task WriteAsync(string path, Stream dataStream)
|
||||
{
|
||||
using var multiPartForm = new MultipartFormDataContent();
|
||||
|
||||
@@ -78,14 +78,14 @@ public class SystemFsAccess : IFsAccess, ICombineAccess, IArchiveAccess, IDownlo
|
||||
);
|
||||
}
|
||||
|
||||
public async Task Delete(string path)
|
||||
public async Task DeleteAsync(string path)
|
||||
{
|
||||
await ApiClient.Delete(
|
||||
$"{BaseApiUrl}/delete?path={path}"
|
||||
);
|
||||
}
|
||||
|
||||
public async Task Combine(string destination, string[] files)
|
||||
public async Task CombineAsync(string destination, string[] files)
|
||||
{
|
||||
await ApiClient.Post(
|
||||
$"{BaseApiUrl}/combine",
|
||||
@@ -103,7 +103,7 @@ public class SystemFsAccess : IFsAccess, ICombineAccess, IArchiveAccess, IDownlo
|
||||
new("tar.gz", ["tar.gz"], "Tar.gz Archive")
|
||||
];
|
||||
|
||||
public async Task Archive(
|
||||
public async Task ArchiveAsync(
|
||||
string destination,
|
||||
ArchiveFormat format,
|
||||
string root,
|
||||
@@ -120,7 +120,7 @@ public class SystemFsAccess : IFsAccess, ICombineAccess, IArchiveAccess, IDownlo
|
||||
});
|
||||
}
|
||||
|
||||
public async Task Unarchive(
|
||||
public async Task UnarchiveAsync(
|
||||
string path,
|
||||
ArchiveFormat format,
|
||||
string destination,
|
||||
@@ -137,13 +137,13 @@ public class SystemFsAccess : IFsAccess, ICombineAccess, IArchiveAccess, IDownlo
|
||||
);
|
||||
}
|
||||
|
||||
public async Task<string> GetFileUrl(string path)
|
||||
=> await GetDownloadUrl(path);
|
||||
public async Task<string> GetFileUrlAsync(string path)
|
||||
=> await GetDownloadUrlAsync(path);
|
||||
|
||||
public async Task<string> GetFolderUrl(string path)
|
||||
=> await GetDownloadUrl(path);
|
||||
public async Task<string> GetFolderUrlAsync(string path)
|
||||
=> await GetDownloadUrlAsync(path);
|
||||
|
||||
private async Task<string> GetDownloadUrl(string path)
|
||||
private async Task<string> GetDownloadUrlAsync(string path)
|
||||
{
|
||||
var response = await ApiClient.PostJson<DownloadUrlResponse>(
|
||||
$"{BaseApiUrl}/downloadUrl?path={path}"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MoonCore.Blazor.FlyonUi.Exceptions;
|
||||
using MoonCore.Blazor.FlyonUi.Toasts;
|
||||
using MoonCore.Exceptions;
|
||||
|
||||
namespace Moonlight.Client.Implementations;
|
||||
@@ -7,18 +8,25 @@ namespace Moonlight.Client.Implementations;
|
||||
public class UnauthenticatedErrorFilter : IGlobalErrorFilter
|
||||
{
|
||||
private readonly NavigationManager Navigation;
|
||||
private readonly ToastService ToastService;
|
||||
|
||||
public UnauthenticatedErrorFilter(NavigationManager navigation)
|
||||
public UnauthenticatedErrorFilter(
|
||||
NavigationManager navigation,
|
||||
ToastService toastService
|
||||
)
|
||||
{
|
||||
Navigation = navigation;
|
||||
ToastService = toastService;
|
||||
}
|
||||
|
||||
public Task<bool> HandleException(Exception ex)
|
||||
public async Task<bool> HandleExceptionAsync(Exception ex)
|
||||
{
|
||||
if (ex is not HttpApiException { Status: 401 })
|
||||
return Task.FromResult(false);
|
||||
return false;
|
||||
|
||||
await ToastService.InfoAsync("Session expired", "Your session has expired. Reloading..");
|
||||
|
||||
Navigation.NavigateTo("/api/auth/logout", true);
|
||||
return Task.FromResult(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -22,11 +22,11 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazor-ApexCharts" Version="6.0.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.9" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="9.0.9" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.8" />
|
||||
<PackageReference Include="MoonCore" Version="1.9.9" />
|
||||
<PackageReference Include="MoonCore.Blazor" Version="1.3.1" />
|
||||
<PackageReference Include="MoonCore.Blazor.FlyonUi" Version="1.2.2" />
|
||||
<PackageReference Include="MoonCore" Version="2.0.0" />
|
||||
<PackageReference Include="MoonCore.Blazor.FlyonUi" Version="1.2.4" />
|
||||
<PackageReference Include="System.Security.Claims" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -4,6 +4,6 @@ namespace Moonlight.Client.Plugins;
|
||||
|
||||
public interface IPluginStartup
|
||||
{
|
||||
public Task BuildApplication(IServiceProvider serviceProvider, WebAssemblyHostBuilder builder);
|
||||
public Task ConfigureApplication(IServiceProvider serviceProvider, WebAssemblyHost app);
|
||||
public Task BuildApplicationAsync(IServiceProvider serviceProvider, WebAssemblyHostBuilder builder);
|
||||
public Task ConfigureApplicationAsync(IServiceProvider serviceProvider, WebAssemblyHost app);
|
||||
}
|
||||
@@ -9,9 +9,9 @@ public class WindowService
|
||||
JsRuntime = jsRuntime;
|
||||
}
|
||||
|
||||
public async Task Open(string url, string title, int height, int width)
|
||||
public async Task OpenAsync(string url, string title, int height, int width)
|
||||
=> await JsRuntime.InvokeVoidAsync("moonlight.window.open", url, title, height, width);
|
||||
|
||||
public async Task Close()
|
||||
public async Task CloseAsync()
|
||||
=> await JsRuntime.InvokeVoidAsync("moonlight.window.closeCurrent");
|
||||
}
|
||||
@@ -9,7 +9,7 @@ namespace Moonlight.Client.Startup;
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
private Task RegisterAuthentication()
|
||||
private Task RegisterAuthenticationAsync()
|
||||
{
|
||||
WebAssemblyHostBuilder.Services.AddAuthorizationCore();
|
||||
WebAssemblyHostBuilder.Services.AddCascadingAuthenticationState();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using MoonCore.Blazor.FlyonUi;
|
||||
using MoonCore.Blazor.Services;
|
||||
using MoonCore.Extensions;
|
||||
using MoonCore.Helpers;
|
||||
using Moonlight.Client.Services;
|
||||
@@ -10,7 +9,7 @@ namespace Moonlight.Client.Startup;
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
private Task RegisterBase()
|
||||
private Task RegisterBaseAsync()
|
||||
{
|
||||
WebAssemblyHostBuilder.RootComponents.Add<App>("#app");
|
||||
WebAssemblyHostBuilder.RootComponents.Add<HeadOutlet>("head::after");
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Moonlight.Client.Startup;
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
private Task SetupLogging()
|
||||
private Task SetupLoggingAsync()
|
||||
{
|
||||
var loggerFactory = new LoggerFactory();
|
||||
|
||||
@@ -18,7 +18,7 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task RegisterLogging()
|
||||
private Task RegisterLoggingAsync()
|
||||
{
|
||||
WebAssemblyHostBuilder.Logging.ClearProviders();
|
||||
WebAssemblyHostBuilder.Logging.AddAnsiConsole();
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Moonlight.Client.Startup;
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
private Task PrintVersion()
|
||||
private Task PrintVersionAsync()
|
||||
{
|
||||
// Fancy start console output... yes very fancy :>
|
||||
Console.Write("Running ");
|
||||
@@ -27,7 +27,7 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task LoadConfiguration()
|
||||
private async Task LoadConfigurationAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ public partial class Startup
|
||||
private IPluginStartup[] PluginStartups;
|
||||
private IServiceProvider PluginLoadServiceProvider;
|
||||
|
||||
private Task InitializePlugins()
|
||||
private Task InitializePluginsAsync()
|
||||
{
|
||||
// Define minimal service collection
|
||||
var startupSc = new ServiceCollection();
|
||||
@@ -38,13 +38,13 @@ public partial class Startup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task HookPluginBuild()
|
||||
private async Task HookPluginBuildAsync()
|
||||
{
|
||||
foreach (var pluginAppStartup in PluginStartups)
|
||||
{
|
||||
try
|
||||
{
|
||||
await pluginAppStartup.BuildApplication(PluginLoadServiceProvider, WebAssemblyHostBuilder);
|
||||
await pluginAppStartup.BuildApplicationAsync(PluginLoadServiceProvider, WebAssemblyHostBuilder);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -57,13 +57,13 @@ public partial class Startup
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HookPluginConfigure()
|
||||
private async Task HookPluginConfigureAsync()
|
||||
{
|
||||
foreach (var pluginAppStartup in PluginStartups)
|
||||
{
|
||||
try
|
||||
{
|
||||
await pluginAppStartup.ConfigureApplication(PluginLoadServiceProvider, WebAssemblyHost);
|
||||
await pluginAppStartup.ConfigureApplicationAsync(PluginLoadServiceProvider, WebAssemblyHost);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -16,33 +16,33 @@ public partial class Startup
|
||||
public FrontendConfiguration Configuration { get; private set; }
|
||||
|
||||
|
||||
public Task Initialize(IPluginStartup[]? plugins = null)
|
||||
public Task InitializeAsync(IPluginStartup[]? plugins = null)
|
||||
{
|
||||
PluginStartups = plugins ?? [];
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task AddMoonlight(WebAssemblyHostBuilder builder)
|
||||
public async Task AddMoonlightAsync(WebAssemblyHostBuilder builder)
|
||||
{
|
||||
WebAssemblyHostBuilder = builder;
|
||||
|
||||
await PrintVersion();
|
||||
await PrintVersionAsync();
|
||||
|
||||
await SetupLogging();
|
||||
await LoadConfiguration();
|
||||
await InitializePlugins();
|
||||
await SetupLoggingAsync();
|
||||
await LoadConfigurationAsync();
|
||||
await InitializePluginsAsync();
|
||||
|
||||
await RegisterLogging();
|
||||
await RegisterBase();
|
||||
await RegisterAuthentication();
|
||||
await HookPluginBuild();
|
||||
await RegisterLoggingAsync();
|
||||
await RegisterBaseAsync();
|
||||
await RegisterAuthenticationAsync();
|
||||
await HookPluginBuildAsync();
|
||||
}
|
||||
|
||||
public async Task AddMoonlight(WebAssemblyHost assemblyHost)
|
||||
public async Task AddMoonlightAsync(WebAssemblyHost assemblyHost)
|
||||
{
|
||||
WebAssemblyHost = assemblyHost;
|
||||
|
||||
await HookPluginConfigure();
|
||||
await HookPluginConfigureAsync();
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,8 @@
|
||||
-ml-4
|
||||
-translate-x-full
|
||||
-translate-y-1/2
|
||||
[animation-duration:0.8s]
|
||||
[animation-timing-function:ease]
|
||||
absolute
|
||||
accordion
|
||||
accordion-bordered
|
||||
@@ -42,6 +44,7 @@ align-bottom
|
||||
align-middle
|
||||
animate-bounce
|
||||
animate-ping
|
||||
animate-spin
|
||||
aria-[current='page']:text-bg-soft-primary
|
||||
avatar
|
||||
avatar-placeholder
|
||||
@@ -76,23 +79,31 @@ border
|
||||
border-0
|
||||
border-1
|
||||
border-2
|
||||
border-3
|
||||
border-b
|
||||
border-b-2
|
||||
border-b-base-content/20
|
||||
border-b-primary
|
||||
border-base-content
|
||||
border-base-content/20
|
||||
border-base-content/25
|
||||
border-base-content/40
|
||||
border-base-content/5
|
||||
border-dashed
|
||||
border-dotted
|
||||
border-error/30
|
||||
border-info/30
|
||||
border-l-transparent
|
||||
border-r-transparent
|
||||
border-solid
|
||||
border-success/30
|
||||
border-t
|
||||
border-t-transparent
|
||||
border-transparent
|
||||
border-warning/30
|
||||
bottom-0
|
||||
bottom-full
|
||||
breadcrumbs
|
||||
break-words
|
||||
btn
|
||||
btn-accent
|
||||
@@ -160,6 +171,7 @@ duration-500
|
||||
ease-in-out
|
||||
ease-linear
|
||||
end-3
|
||||
error-message
|
||||
file-upload-complete:progress-success
|
||||
fill-base-content
|
||||
fill-black
|
||||
@@ -187,6 +199,8 @@ font-inter
|
||||
font-medium
|
||||
font-normal
|
||||
font-semibold
|
||||
footer
|
||||
footer-center
|
||||
gap-0.5
|
||||
gap-1
|
||||
gap-1.5
|
||||
@@ -220,10 +234,13 @@ helper-text
|
||||
hidden
|
||||
hover:bg-primary/5
|
||||
hover:bg-transparent
|
||||
hover:cursor-pointer
|
||||
hover:text-base-content
|
||||
hover:text-base-content/60
|
||||
hover:text-primary
|
||||
image-full
|
||||
indicator
|
||||
indicator-item
|
||||
inline
|
||||
inline-block
|
||||
inline-flex
|
||||
@@ -281,7 +298,6 @@ list-disc
|
||||
list-inside
|
||||
list-none
|
||||
loading
|
||||
loading-lg
|
||||
loading-sm
|
||||
loading-spinner
|
||||
loading-xl
|
||||
@@ -296,6 +312,7 @@ max-md:flex-wrap
|
||||
max-md:justify-center
|
||||
max-sm:hidden
|
||||
max-w-7xl
|
||||
max-w-8
|
||||
max-w-80
|
||||
max-w-full
|
||||
max-w-lg
|
||||
@@ -360,10 +377,12 @@ mt-8
|
||||
mx-1
|
||||
mx-auto
|
||||
my-3
|
||||
my-5
|
||||
my-auto
|
||||
object-cover
|
||||
opacity-0
|
||||
opacity-100
|
||||
opacity-75
|
||||
open
|
||||
origin-top-left
|
||||
outline
|
||||
@@ -396,7 +415,6 @@ pt-0
|
||||
pt-0.5
|
||||
pt-2
|
||||
pt-3
|
||||
px-0.5
|
||||
px-1.5
|
||||
px-2
|
||||
px-2.5
|
||||
@@ -471,10 +489,12 @@ space-x-2.5
|
||||
space-y-1
|
||||
space-y-4
|
||||
sr-only
|
||||
stack
|
||||
static
|
||||
status
|
||||
status-error
|
||||
sticky
|
||||
success-message
|
||||
switch
|
||||
tab
|
||||
tab-active
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<label for="@Id" class="btn btn-square border-0 ring-0 outline-0" style="background-color: @Value">
|
||||
<i class="text-lg text-base-content @Icon"></i>
|
||||
</label>
|
||||
<input value="@Value" @oninput="Update" id="@Id" type="color" class="h-0 w-0 opacity-0"/>
|
||||
<input value="@Value" @oninput="UpdateAsync" id="@Id" type="color" class="h-0 w-0 opacity-0"/>
|
||||
|
||||
@code
|
||||
{
|
||||
@@ -37,7 +37,7 @@
|
||||
Id = $"color-selector-{GetHashCode()}";
|
||||
}
|
||||
|
||||
private async Task Update(ChangeEventArgs args)
|
||||
private async Task UpdateAsync(ChangeEventArgs args)
|
||||
{
|
||||
Value = args.Value?.ToString() ?? "#FFFFFF";
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
for all SignalR Hubs to be synced.
|
||||
</p>
|
||||
<div class="mt-5">
|
||||
<LazyLoader Load="Load">
|
||||
<LazyLoader Load="LoadAsync">
|
||||
<WButton OnClick="OnClick" CssClasses="btn btn-primary">
|
||||
Send broadcast
|
||||
</WButton>
|
||||
@@ -30,9 +30,9 @@
|
||||
{
|
||||
private HubConnection? Connection;
|
||||
|
||||
private async Task Load(LazyLoader lazyLoader)
|
||||
private async Task LoadAsync(LazyLoader lazyLoader)
|
||||
{
|
||||
await lazyLoader.UpdateText("Connecting to SignalR endpoint");
|
||||
await lazyLoader.UpdateTextAsync("Connecting to SignalR endpoint");
|
||||
|
||||
Connection = new HubConnectionBuilder()
|
||||
.WithUrl(Navigation.ToAbsoluteUri("/api/admin/system/diagnose/ws"))
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
Connection.On(
|
||||
"Pong",
|
||||
async () => await ToastService.Success("Received broadcast")
|
||||
async () => await ToastService.SuccessAsync("Received broadcast")
|
||||
);
|
||||
|
||||
await Connection.StartAsync();
|
||||
|
||||
@@ -137,7 +137,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<input @onclick="_ => UpdateRadiusBox(possibleValue)" type="radio" name="radius-box" class="radio hidden"/>
|
||||
<input @onclick="_ => UpdateRadiusBoxAsync(possibleValue)" type="radio" name="radius-box" class="radio hidden"/>
|
||||
}
|
||||
<span class="label-text w-full">
|
||||
<div class="pe-1.5 pt-1.5" aria-hidden="true">
|
||||
@@ -164,7 +164,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<input @onclick="_ => UpdateRadiusField(possibleValue)" type="radio" name="radius-field" class="radio hidden"/>
|
||||
<input @onclick="_ => UpdateRadiusFieldAsync(possibleValue)" type="radio" name="radius-field" class="radio hidden"/>
|
||||
}
|
||||
<span class="label-text w-full">
|
||||
<div class="pe-1.5 pt-1.5" aria-hidden="true">
|
||||
@@ -191,7 +191,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<input @onclick="_ => UpdateRadiusSelector(possibleValue)" type="radio" name="radius-selector" class="radio hidden"/>
|
||||
<input @onclick="_ => UpdateRadiusSelectorAsync(possibleValue)" type="radio" name="radius-selector" class="radio hidden"/>
|
||||
}
|
||||
<span class="label-text w-full">
|
||||
<div class="pe-1.5 pt-1.5" aria-hidden="true">
|
||||
@@ -302,19 +302,19 @@
|
||||
set => Theme.Noise = value ? 1 : 0;
|
||||
}
|
||||
|
||||
private async Task UpdateRadiusBox(float value)
|
||||
private async Task UpdateRadiusBoxAsync(float value)
|
||||
{
|
||||
Theme.RadiusBox = value;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async Task UpdateRadiusField(float value)
|
||||
private async Task UpdateRadiusFieldAsync(float value)
|
||||
{
|
||||
Theme.RadiusField = value;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async Task UpdateRadiusSelector(float value)
|
||||
private async Task UpdateRadiusSelectorAsync(float value)
|
||||
{
|
||||
Theme.RadiusSelector = value;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
public event Func<Task> OnStateChanged;
|
||||
public bool ShowMobileNavigation { get; private set; } = false;
|
||||
|
||||
public async Task ToggleMobileNavigation()
|
||||
public async Task ToggleMobileNavigationAsync()
|
||||
{
|
||||
ShowMobileNavigation = !ShowMobileNavigation;
|
||||
await OnStateChanged();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<header class="flex items-center px-4 lg:hidden border-b border-base-content/5">
|
||||
<div class="py-2.5">
|
||||
<span class="relative">
|
||||
<button @onclick="Layout.ToggleMobileNavigation" aria-label="Open navigation"
|
||||
<button @onclick="Layout.ToggleMobileNavigationAsync" aria-label="Open navigation"
|
||||
class="relative flex min-w-0 items-center gap-3 rounded-lg p-2 text-left text-base/6 sm:text-sm/5 text-base-content"
|
||||
type="button">
|
||||
<i class="icon-menu text-xl"></i>
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a href="#" @onclick:preventDefault @onclick="Logout" class="flex items-center">
|
||||
<a href="#" @onclick:preventDefault @onclick="LogoutAsync" class="flex items-center">
|
||||
<i class="icon-log-out text-lg"></i>
|
||||
</a>
|
||||
</div>
|
||||
@@ -121,7 +121,7 @@
|
||||
<div class="truncate">Moonlight v2.1</div>
|
||||
</div>
|
||||
|
||||
<button @onclick="Layout.ToggleMobileNavigation" aria-label="Close navigation" type="button"
|
||||
<button @onclick="Layout.ToggleMobileNavigationAsync" aria-label="Close navigation" type="button"
|
||||
class="relative flex min-w-0 items-center gap-3 rounded-lg p-2 text-left text-base/6 text-base-content">
|
||||
<i class="icon-x text-lg"></i>
|
||||
</button>
|
||||
@@ -180,7 +180,7 @@
|
||||
<div class="flex flex-col gap-0.5">
|
||||
<div class="relative">
|
||||
<a class="flex w-full items-center gap-3 rounded-lg px-2 py-2.5 text-left text-base/6 sm:py-2 sm:text-sm/5 text-base-content"
|
||||
href="#" @onclick:preventDefault @onclick="Logout">
|
||||
href="#" @onclick:preventDefault @onclick="LogoutAsync">
|
||||
<i class="icon-log-out"></i>
|
||||
<span class="truncate">Logout</span>
|
||||
</a>
|
||||
@@ -252,13 +252,13 @@
|
||||
if (!Layout.ShowMobileNavigation)
|
||||
return;
|
||||
|
||||
await Layout.ToggleMobileNavigation();
|
||||
await Layout.ToggleMobileNavigationAsync();
|
||||
};
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task Logout()
|
||||
private Task LogoutAsync()
|
||||
{
|
||||
Navigation.NavigateTo("/api/auth/logout", true);
|
||||
return Task.CompletedTask;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<div class="flex h-screen justify-center items-center">
|
||||
<div class="sm:min-w-md">
|
||||
<div class="bg-base-100 shadow-base-300/20 z-1 w-full space-y-6 rounded-xl p-6 shadow-md lg:p-8">
|
||||
<LazyLoader EnableDefaultSpacing="false" Load="Load">
|
||||
<LazyLoader EnableDefaultSpacing="false" Load="LoadAsync">
|
||||
@if (ShowSelection)
|
||||
{
|
||||
<div class="flex justify-center items-center gap-3">
|
||||
@@ -34,7 +34,7 @@
|
||||
if (config == null) // Ignore all schemes which have no ui configured
|
||||
continue;
|
||||
|
||||
<button @onclick="() => Start(scheme)" class="btn btn-text w-full"
|
||||
<button @onclick="() => StartAsync(scheme)" class="btn btn-text w-full"
|
||||
style="background-color: @(config.Color)">
|
||||
<img src="@config.IconUrl"
|
||||
alt="scheme icon"
|
||||
@@ -71,7 +71,7 @@
|
||||
};
|
||||
}
|
||||
|
||||
private async Task Load(LazyLoader arg)
|
||||
private async Task LoadAsync(LazyLoader arg)
|
||||
{
|
||||
AuthSchemes = await ApiClient.GetJson<AuthSchemeResponse[]>(
|
||||
"api/auth"
|
||||
@@ -82,12 +82,12 @@
|
||||
// showing the selection screen
|
||||
|
||||
if (AuthSchemes.Length == 1)
|
||||
await Start(AuthSchemes[0]);
|
||||
await StartAsync(AuthSchemes[0]);
|
||||
else
|
||||
ShowSelection = true;
|
||||
}
|
||||
|
||||
private Task Start(AuthSchemeResponse scheme)
|
||||
private Task StartAsync(AuthSchemeResponse scheme)
|
||||
{
|
||||
Navigation.NavigateTo($"/api/auth/{scheme.Identifier}", true);
|
||||
return Task.CompletedTask;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<i class="icon-chevron-left"></i>
|
||||
Back
|
||||
</a>
|
||||
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
|
||||
<WButton OnClick="Form.SubmitAsync" CssClasses="btn btn-primary">
|
||||
<i class="icon-check"></i>
|
||||
Create
|
||||
</WButton>
|
||||
@@ -66,17 +66,17 @@
|
||||
|
||||
var response = await ApiClient.PostJson<CreateApiKeyResponse>("api/admin/apikeys", Request);
|
||||
|
||||
await DownloadService.Download(
|
||||
await DownloadService.DownloadAsync(
|
||||
$"moonlight-key-{response.Id}.txt",
|
||||
response.Secret
|
||||
);
|
||||
|
||||
await AlertService.Success(
|
||||
await AlertService.SuccessAsync(
|
||||
"API Key successfully created",
|
||||
"The API Key has been downloaded. Dont lose it, you cant view it anymore"
|
||||
);
|
||||
|
||||
await ToastService.Success("Successfully created api key");
|
||||
await ToastService.SuccessAsync("Successfully created api key");
|
||||
Navigation.NavigateTo("/admin/api");
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
<DataGrid @ref="Grid"
|
||||
TGridItem="ApiKeyResponse"
|
||||
ItemsProvider="ItemsProvider"
|
||||
ItemsProvider="ItemsProviderAsync"
|
||||
EnableFiltering="true"
|
||||
EnablePagination="true">
|
||||
<PropertyColumn Field="x => x.Id" Sortable="true" />
|
||||
@@ -92,7 +92,7 @@
|
||||
{
|
||||
private DataGrid<ApiKeyResponse> Grid;
|
||||
|
||||
private async Task<DataGridItemResult<ApiKeyResponse>> ItemsProvider(DataGridItemRequest request)
|
||||
private async Task<DataGridItemResult<ApiKeyResponse>> ItemsProviderAsync(DataGridItemRequest request)
|
||||
{
|
||||
var query = $"?startIndex={request.StartIndex}&count={request.Count}";
|
||||
|
||||
@@ -116,13 +116,13 @@
|
||||
|
||||
private async Task DeleteAsync(ApiKeyResponse apiKeyResponse)
|
||||
{
|
||||
await AlertService.ConfirmDanger(
|
||||
"API Key deletion",
|
||||
await AlertService.ConfirmDangerAsync(
|
||||
"API Key Deletion",
|
||||
$"Do you really want to delete the api key '{apiKeyResponse.Description}'",
|
||||
async () =>
|
||||
{
|
||||
await ApiClient.Delete($"api/admin/apikeys/{apiKeyResponse.Id}");
|
||||
await ToastService.Success("Successfully deleted api key");
|
||||
await ToastService.SuccessAsync("Successfully deleted api key");
|
||||
|
||||
await Grid.RefreshAsync();
|
||||
}
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
@inject NavigationManager Navigation
|
||||
@inject ToastService ToastService
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
<LazyLoader Load="LoadAsync">
|
||||
<PageHeader Title="Update API Key">
|
||||
<a href="/admin/api" class="btn btn-secondary">
|
||||
<i class="icon-chevron-left"></i>
|
||||
Back
|
||||
</a>
|
||||
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
|
||||
<WButton OnClick="Form.SubmitAsync" CssClasses="btn btn-primary">
|
||||
<i class="icon-check"></i>
|
||||
Update
|
||||
</WButton>
|
||||
@@ -40,7 +40,7 @@
|
||||
private HandleForm Form;
|
||||
private UpdateApiKeyRequest Request;
|
||||
|
||||
private async Task Load(LazyLoader _)
|
||||
private async Task LoadAsync(LazyLoader _)
|
||||
{
|
||||
var detail = await ApiClient.GetJson<ApiKeyResponse>($"api/admin/apikeys/{Id}");
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
{
|
||||
await ApiClient.Patch($"api/admin/apikeys/{Id}", Request);
|
||||
|
||||
await ToastService.Success("Successfully updated api key");
|
||||
await ToastService.SuccessAsync("Successfully updated api key");
|
||||
Navigation.NavigateTo("/admin/api");
|
||||
}
|
||||
}
|
||||
@@ -26,17 +26,17 @@
|
||||
includes your installed theme and plugins. For more information, have a look at <a class="text-primary" href="https://help.moonlightpanel.xyz">our docs</a>
|
||||
</p>
|
||||
|
||||
<WButton OnClick="GenerateFrontend" CssClasses="btn btn-primary mt-5">Generate frontend.zip</WButton>
|
||||
<WButton OnClick="GenerateFrontendAsync" CssClasses="btn btn-primary mt-5">Generate frontend.zip</WButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code
|
||||
{
|
||||
private async Task GenerateFrontend(WButton _)
|
||||
private async Task GenerateFrontendAsync(WButton _)
|
||||
{
|
||||
var stream = await ApiClient.GetStream("api/admin/system/advanced/frontend");
|
||||
|
||||
await DownloadService.Download("frontend.zip", stream);
|
||||
await DownloadService.DownloadAsync("frontend.zip", stream);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
<div class="my-8">
|
||||
<DataGrid TGridItem="ThemeResponse"
|
||||
ItemsProvider="ItemsProvider"
|
||||
ItemsProvider="ItemsProviderAsync"
|
||||
EnableFiltering="true"
|
||||
EnablePagination="true">
|
||||
|
||||
@@ -105,7 +105,7 @@
|
||||
{
|
||||
private DataGrid<ThemeResponse> Grid;
|
||||
|
||||
private async Task<DataGridItemResult<ThemeResponse>> ItemsProvider(DataGridItemRequest request)
|
||||
private async Task<DataGridItemResult<ThemeResponse>> ItemsProviderAsync(DataGridItemRequest request)
|
||||
{
|
||||
var query = $"?startIndex={request.StartIndex}&count={request.Count}";
|
||||
|
||||
@@ -142,13 +142,13 @@
|
||||
{
|
||||
if (!file.Name.EndsWith(".json"))
|
||||
{
|
||||
await ToastService.Error($"Unable to import {file.Name}", "Only .json files are supported");
|
||||
await ToastService.ErrorAsync($"Unable to import {file.Name}", "Only .json files are supported");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (file.Size > maxFileSize)
|
||||
{
|
||||
await ToastService.Error($"Unable to import {file.Name}", "Exceeded the maximum file limit of 1MB");
|
||||
await ToastService.ErrorAsync($"Unable to import {file.Name}", "Exceeded the maximum file limit of 1MB");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@
|
||||
|
||||
if (themeTransfer == null)
|
||||
{
|
||||
await ToastService.Error($"Unable to import {file.Name}", "Failed to deserialize the content");
|
||||
await ToastService.ErrorAsync($"Unable to import {file.Name}", "Failed to deserialize the content");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@
|
||||
Version = themeTransfer.Version
|
||||
});
|
||||
|
||||
await ToastService.Success("Successfully imported theme", theme.Name);
|
||||
await ToastService.SuccessAsync("Successfully imported theme", theme.Name);
|
||||
|
||||
await Grid.RefreshAsync();
|
||||
}
|
||||
@@ -203,19 +203,19 @@
|
||||
|
||||
var fileName = $"{transfer.Name.Replace(" ", string.Empty).Trim()}.json";
|
||||
|
||||
await DownloadService.Download(fileName, json);
|
||||
await DownloadService.DownloadAsync(fileName, json);
|
||||
}
|
||||
|
||||
private async Task DeleteAsync(ThemeResponse response)
|
||||
{
|
||||
await AlertService.ConfirmDanger(
|
||||
await AlertService.ConfirmDangerAsync(
|
||||
"Theme deletion",
|
||||
$"Do you really want to delete the theme: {response.Name}",
|
||||
async () =>
|
||||
{
|
||||
await ThemeService.DeleteAsync(response.Id);
|
||||
|
||||
await ToastService.Success("Successfully deleted theme");
|
||||
await ToastService.SuccessAsync("Successfully deleted theme");
|
||||
await Grid.RefreshAsync();
|
||||
}
|
||||
);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<i class="icon-chevron-left"></i>
|
||||
Back
|
||||
</a>
|
||||
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
|
||||
<WButton OnClick="Form.SubmitAsync" CssClasses="btn btn-primary">
|
||||
<i class="icon-check"></i>
|
||||
Create
|
||||
</WButton>
|
||||
@@ -59,7 +59,7 @@
|
||||
private async Task OnValidSubmit()
|
||||
{
|
||||
await ThemeService.CreateAsync(Request);
|
||||
await ToastService.Success("Successfully created theme");
|
||||
await ToastService.SuccessAsync("Successfully created theme");
|
||||
|
||||
NavigationManager.NavigateTo("/admin/system/customisation");
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
@inject ToastService ToastService
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
<LazyLoader Load="LoadAsync">
|
||||
<PageHeader Title="@($"Update {Request.Name}")">
|
||||
<a href="/admin/system/customisation" class="btn btn-secondary">
|
||||
<i class="icon-chevron-left"></i>
|
||||
Back
|
||||
</a>
|
||||
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
|
||||
<WButton OnClick="Form.SubmitAsync" CssClasses="btn btn-primary">
|
||||
<i class="icon-check"></i>
|
||||
Update
|
||||
</WButton>
|
||||
@@ -80,7 +80,7 @@
|
||||
|
||||
private HandleForm Form;
|
||||
|
||||
private async Task Load(LazyLoader _)
|
||||
private async Task LoadAsync(LazyLoader _)
|
||||
{
|
||||
Response = await ThemeService.GetAsync(Id);
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
{
|
||||
await ThemeService.UpdateAsync(Id, Request);
|
||||
|
||||
await ToastService.Success("Successfully updated theme");
|
||||
await ToastService.SuccessAsync("Successfully updated theme");
|
||||
Navigation.NavigateTo("/admin/system/customisation");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@
|
||||
If you only want to export specific parts of the diagnose report, click on "Advanced" and select the desired providers
|
||||
</p>
|
||||
|
||||
<WButton OnClick="GenerateDiagnose" CssClasses="btn btn-primary my-5">Generate report</WButton>
|
||||
<WButton OnClick="GenerateDiagnoseAsync" CssClasses="btn btn-primary my-5">Generate report</WButton>
|
||||
|
||||
<div class="text-sm">
|
||||
<a class="text-primary cursor-pointer flex items-center" @onclick:preventDefault
|
||||
@onclick="ToggleDropDown">
|
||||
@onclick="ToggleDropDownAsync">
|
||||
<span class="me-1.5">Advanced</span>
|
||||
@if (DropdownOpen)
|
||||
{
|
||||
@@ -45,7 +45,7 @@
|
||||
</a>
|
||||
|
||||
<div class="@(DropdownOpen ? "" : "hidden")">
|
||||
<LazyLoader Load="Load">
|
||||
<LazyLoader Load="LoadAsync">
|
||||
<div class="mb-2 py-2 border-b border-base-content/70 flex items-center gap-3">
|
||||
<input id="selectall_checkbox" @bind="SelectAll" type="checkbox" class="checkbox checkbox-primary checkbox-xs">
|
||||
<label for="selectall_checkbox">Select all</label>
|
||||
@@ -86,7 +86,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
private async Task Load(LazyLoader arg)
|
||||
private async Task LoadAsync(LazyLoader arg)
|
||||
{
|
||||
var providers = await ApiClient.GetJson<DiagnoseProvideResponse[]>(
|
||||
"api/admin/system/diagnose/providers"
|
||||
@@ -96,7 +96,7 @@
|
||||
.ToDictionary(x => x, _ => true);
|
||||
}
|
||||
|
||||
private async Task GenerateDiagnose(WButton button)
|
||||
private async Task GenerateDiagnoseAsync(WButton button)
|
||||
{
|
||||
var request = new GenerateDiagnoseRequest();
|
||||
|
||||
@@ -111,11 +111,11 @@
|
||||
|
||||
var stream = await ApiClient.PostStream("api/admin/system/diagnose", request);
|
||||
|
||||
await DownloadService.Download("diagnose.zip", stream);
|
||||
await DownloadService.DownloadAsync("diagnose.zip", stream);
|
||||
}
|
||||
|
||||
|
||||
private async Task ToggleDropDown()
|
||||
private async Task ToggleDropDownAsync()
|
||||
{
|
||||
DropdownOpen = !DropdownOpen;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
</HelperMessage>
|
||||
</div>
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
<LazyLoader Load="LoadAsync">
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-4 gap-5">
|
||||
<StatCard Title="Servers" Text="@Stats.Servers.ToString()" Icon="icon-server"/>
|
||||
<StatCard Title="Recurring" Text="@Stats.Recurring.ToString()" Icon="icon-calendar-sync"/>
|
||||
@@ -39,7 +39,7 @@
|
||||
{
|
||||
private HangfireStatsResponse Stats;
|
||||
|
||||
private async Task Load(LazyLoader _)
|
||||
private async Task LoadAsync(LazyLoader _)
|
||||
{
|
||||
Stats = await ApiClient.GetJson<HangfireStatsResponse>(
|
||||
"api/admin/system/hangfire/stats"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<NavTabs Index="0" Names="UiConstants.AdminNavNames" Links="UiConstants.AdminNavLinks" />
|
||||
</div>
|
||||
|
||||
<LazyLoader Load="LoadOverview">
|
||||
<LazyLoader Load="LoadOverviewAsync">
|
||||
<div class="gap-5 grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-4">
|
||||
<StatCard Title="CPU Usage" Text="@(OverviewData.CpuUsage + "%")" Icon="icon-cpu"/>
|
||||
<StatCard Title="Memory Usage" Text="@(Formatter.FormatSize(OverviewData.MemoryUsage))" Icon="icon-memory-stick"/>
|
||||
@@ -28,7 +28,7 @@
|
||||
<div class="flex">
|
||||
<div class="card card-body">
|
||||
<div class="flex justify-center">
|
||||
<WButton OnClick="Restart" CssClasses="btn btn-error w-full">
|
||||
<WButton OnClick="RestartAsync" CssClasses="btn btn-error w-full">
|
||||
<i class="icon-repeat me-2"></i>
|
||||
Restart/Shutdown
|
||||
</WButton>
|
||||
@@ -41,12 +41,12 @@
|
||||
{
|
||||
private SystemOverviewResponse OverviewData;
|
||||
|
||||
private async Task LoadOverview(LazyLoader arg)
|
||||
private async Task LoadOverviewAsync(LazyLoader arg)
|
||||
{
|
||||
OverviewData = await ApiClient.GetJson<SystemOverviewResponse>("api/admin/system");
|
||||
}
|
||||
|
||||
private async Task Restart(WButton _)
|
||||
private async Task RestartAsync(WButton _)
|
||||
{
|
||||
await ApiClient.Post("api/admin/system/shutdown");
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<i class="icon-chevron-left"></i>
|
||||
Back
|
||||
</a>
|
||||
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
|
||||
<WButton OnClick="Form.SubmitAsync" CssClasses="btn btn-primary">
|
||||
<i class="icon-check"></i>
|
||||
Create
|
||||
</WButton>
|
||||
@@ -67,7 +67,7 @@
|
||||
|
||||
await ApiClient.Post("api/admin/users", Request);
|
||||
|
||||
await ToastService.Success("Successfully created user");
|
||||
await ToastService.SuccessAsync("Successfully created user");
|
||||
Navigation.NavigateTo("/admin/users");
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<DataGrid @ref="Grid"
|
||||
TGridItem="UserResponse"
|
||||
ItemsProvider="ItemsProvider"
|
||||
ItemsProvider="ItemsProviderAsync"
|
||||
EnableFiltering="true"
|
||||
EnablePagination="true">
|
||||
<PropertyColumn Field="x => x.Id" Sortable="true" />
|
||||
@@ -46,7 +46,7 @@
|
||||
{
|
||||
private DataGrid<UserResponse> Grid;
|
||||
|
||||
private async Task<DataGridItemResult<UserResponse>> ItemsProvider(DataGridItemRequest request)
|
||||
private async Task<DataGridItemResult<UserResponse>> ItemsProviderAsync(DataGridItemRequest request)
|
||||
{
|
||||
var query = $"?startIndex={request.StartIndex}&count={request.Count}";
|
||||
|
||||
@@ -70,13 +70,13 @@
|
||||
|
||||
private async Task DeleteAsync(UserResponse response)
|
||||
{
|
||||
await AlertService.ConfirmDanger(
|
||||
await AlertService.ConfirmDangerAsync(
|
||||
"User deletion",
|
||||
$"Do you really want to delete the user '{response.Username}'",
|
||||
async () =>
|
||||
{
|
||||
await ApiClient.Delete($"api/admin/users/{response.Id}");
|
||||
await ToastService.Success("Successfully deleted user");
|
||||
await ToastService.SuccessAsync("Successfully deleted user");
|
||||
|
||||
await Grid.RefreshAsync();
|
||||
}
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
@inject NavigationManager Navigation
|
||||
@inject ToastService ToastService
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
<LazyLoader Load="LoadAsync">
|
||||
<PageHeader Title="Update User">
|
||||
<a href="/admin/users" class="btn btn-secondary">
|
||||
<i class="icon-chevron-left"></i>
|
||||
Back
|
||||
</a>
|
||||
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
|
||||
<WButton OnClick="Form.SubmitAsync" CssClasses="btn btn-primary">
|
||||
<i class="icon-check"></i>
|
||||
Update
|
||||
</WButton>
|
||||
@@ -62,7 +62,7 @@
|
||||
|
||||
private List<string> Permissions = [];
|
||||
|
||||
private async Task Load(LazyLoader _)
|
||||
private async Task LoadAsync(LazyLoader _)
|
||||
{
|
||||
var detail = await ApiClient.GetJson<UserResponse>($"api/admin/users/{Id}");
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
|
||||
await ApiClient.Patch($"api/admin/users/{Id}", Request);
|
||||
|
||||
await ToastService.Success("Successfully updated user");
|
||||
await ToastService.SuccessAsync("Successfully updated user");
|
||||
Navigation.NavigateTo("/admin/users");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user