Files
rr3-server/RR3CommunityServer/Migrations/20260219180936_AddUserSettings.cs
Daniel Elliott 8ba7c605f1 Add device settings management and web panel sync API
Features:
- New DeviceSettings admin page at /devicesettings
- Manage device server configurations (URL, mode, deviceId)
- 3 new API endpoints for APK sync functionality
- UserSettings database model with SQLite storage

Implementation:
- ServerSettingsController.cs with getUserSettings, updateUserSettings, getAllUserSettings
- DeviceSettings.cshtml Razor page with add/edit/delete UI
- DeviceSettings.cshtml.cs page model with CRUD operations
- UserSettings model added to ApiModels.cs
- UserSettings DbSet added to RR3DbContext
- EF Core migration: 20260219180936_AddUserSettings
- Link added to Admin dashboard

API Endpoints:
- GET /api/settings/getUserSettings?deviceId={id} - APK sync endpoint
- POST /api/settings/updateUserSettings - Web panel update
- GET /api/settings/getAllUserSettings - Admin list view

Database Schema:
- UserSettings table (Id, DeviceId, ServerUrl, Mode, LastUpdated)
- SQLite storage with EF Core migrations

Integration:
- Works with APK SettingsActivity sync button
- Real-time configuration updates
- Emoji logging for all operations
- Device-specific server URL management

Usage:
1. Admin configures device settings at /devicesettings
2. User opens RR3 APK and taps Sync from Web Panel
3. APK downloads settings via API
4. Settings saved to SharedPreferences
5. Game restart applies configuration

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-19 10:15:02 -08:00

67 lines
2.8 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace RR3CommunityServer.Migrations
{
/// <inheritdoc />
public partial class AddUserSettings : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "UserSettings",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
DeviceId = table.Column<string>(type: "TEXT", nullable: false),
ServerUrl = table.Column<string>(type: "TEXT", nullable: false),
Mode = table.Column<string>(type: "TEXT", nullable: false),
LastUpdated = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserSettings", x => x.Id);
});
migrationBuilder.UpdateData(
table: "TimeTrials",
keyColumn: "Id",
keyValue: 1,
columns: new[] { "EndDate", "StartDate" },
values: new object[] { new DateTime(2026, 2, 26, 18, 9, 35, 116, DateTimeKind.Utc).AddTicks(3366), new DateTime(2026, 2, 19, 18, 9, 35, 116, DateTimeKind.Utc).AddTicks(3363) });
migrationBuilder.UpdateData(
table: "TimeTrials",
keyColumn: "Id",
keyValue: 2,
columns: new[] { "EndDate", "StartDate" },
values: new object[] { new DateTime(2026, 2, 26, 18, 9, 35, 116, DateTimeKind.Utc).AddTicks(3375), new DateTime(2026, 2, 19, 18, 9, 35, 116, DateTimeKind.Utc).AddTicks(3375) });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "UserSettings");
migrationBuilder.UpdateData(
table: "TimeTrials",
keyColumn: "Id",
keyValue: 1,
columns: new[] { "EndDate", "StartDate" },
values: new object[] { new DateTime(2026, 2, 25, 9, 51, 0, 392, DateTimeKind.Utc).AddTicks(5137), new DateTime(2026, 2, 18, 9, 51, 0, 392, DateTimeKind.Utc).AddTicks(5134) });
migrationBuilder.UpdateData(
table: "TimeTrials",
keyColumn: "Id",
keyValue: 2,
columns: new[] { "EndDate", "StartDate" },
values: new object[] { new DateTime(2026, 2, 25, 9, 51, 0, 392, DateTimeKind.Utc).AddTicks(5146), new DateTime(2026, 2, 18, 9, 51, 0, 392, DateTimeKind.Utc).AddTicks(5146) });
}
}
}