Compare commits

...

58 Commits
v0.2.2 ... main

Author SHA1 Message Date
Pat Hartl 5ef16fc4cc Add missing collection model 2023-12-04 01:42:02 -06:00
Pat Hartl db8d3e4bf6 Add role pane to settings with ability to add/delete roles 2023-12-04 01:41:49 -06:00
Pat Hartl f2462c0d20 Switch change password icon to lock 2023-12-04 01:41:02 -06:00
Pat Hartl b87fe92c63 Order tag inputs by the label 2023-12-04 01:40:43 -06:00
Pat Hartl c735556281 Add collections to navigation 2023-12-04 01:40:28 -06:00
Pat Hartl d4bcde9d28 Merge branch 'main' of https://github.com/pathartl/LANCommander 2023-12-04 01:40:13 -06:00
Pat Hartl 920b6b26f7 Added collections with the ability to add games to a collection 2023-12-04 01:39:59 -06:00
Pat Hartl d31fccc9f3
Update installermanifest.yaml 2023-12-03 21:12:35 -06:00
Pat Hartl c48d5b5d59 Add migration to fix PowerShell scripts that were updated to use Get-PrimaryDisplay 2023-12-03 14:29:51 -06:00
Pat Hartl dfb9f51acd Remove unused dialog code. Prefix action file picker with {InstallDir} 2023-12-03 14:16:56 -06:00
Pat Hartl 03b0d9da93 Remove Windows-only dashboard charts. Add overall playtime chart. 2023-12-03 14:09:48 -06:00
Pat Hartl e2883322e6 Display total number of games as subtitle 2023-12-03 02:35:41 -06:00
Pat Hartl 50eff6784f Load data a little later on game edit screen. Fix TagsInput sometimes losing data. 2023-12-02 23:48:36 -06:00
Pat Hartl 171f82df3e Fix package references 2023-12-02 23:08:32 -06:00
Pat Hartl 8b7be9157e Import YamlDorNet from Playnite 2023-12-02 18:40:43 -06:00
Pat Hartl 96c6d58486 Revert "Update LANCommander.Release.yml"
This reverts commit 6fb77adb63.
2023-12-02 18:38:09 -06:00
Pat Hartl fd6e3e56a4 Revert "Update LANCommander.Release.yml"
This reverts commit ba46970406.
2023-12-02 18:38:05 -06:00
Pat Hartl d4fe8db48d Add regex flag to save paths 2023-12-02 17:53:54 -06:00
Pat Hartl 281353b86c Remove regex save path database migration 2023-12-02 17:52:08 -06:00
Pat Hartl ba46970406
Update LANCommander.Release.yml 2023-12-02 14:32:06 -06:00
Pat Hartl 6fb77adb63
Update LANCommander.Release.yml 2023-12-02 14:23:17 -06:00
Pat Hartl b38f2b6cef Allow padding of strings by setting a MinLength when converting to bytes 2023-12-01 18:32:43 -06:00
Pat Hartl 7568688c97 Add search, page size, and page index to router 2023-12-01 18:21:10 -06:00
Pat Hartl a8c62151f3 Fix snippets 2023-11-30 19:46:04 -06:00
Pat Hartl 32e135de7b Merge branch 'net8.0' 2023-11-30 19:14:48 -06:00
Pat Hartl c37095d4c4 Merge branch 'main' into net8.0 2023-11-30 19:12:56 -06:00
Pat Hartl a716bafc4d Merge branch 'save-path-regex' 2023-11-30 19:12:47 -06:00
Pat Hartl e4531321b1 Display error message if script couldn't save. Stop success from blocking dialog close. 2023-11-30 19:12:25 -06:00
Pat Hartl 78168e94a5 Fix new scripts not being created 2023-11-30 19:08:20 -06:00
Pat Hartl 82779bcc72 Restore files from save archive based on entries in manifest 2023-11-30 18:37:23 -06:00
Pat Hartl 7b625b2f60 Use Path.DirectorySeparatorChar 2023-11-30 18:31:05 -06:00
Pat Hartl 74d8790ee2 Fix files skipped over if not in install directory 2023-11-30 18:30:15 -06:00
Pat Hartl 745cf0cce6 Prefer Path.DirectorySeparatorChar. Remove unused deserializer 2023-11-30 18:29:11 -06:00
Pat Hartl 7c22aaa139 Record save file paths in manifest. Support regex pathing in upload 2023-11-30 18:25:37 -06:00
Pat Hartl eb73885991 Add unknown to save file download if game doesn't exist. Add .zip file extension 2023-11-30 17:31:40 -06:00
Pat Hartl ce80dfa51f Fix pathing for save in download 2023-11-30 17:31:11 -06:00
Pat Hartl 349001d8f6 Merge branch 'main' into save-path-regex 2023-11-30 17:23:40 -06:00
Pat Hartl d705b34f84 Updated test packages 2023-11-30 17:22:54 -06:00
Pat Hartl 0246ee017c Update ZstdSharp 2023-11-30 00:16:25 -06:00
Pat Hartl 818160d658 Update to .NET 8.0 2023-11-30 00:16:07 -06:00
Pat Hartl 035c98cd18 Initialize save controller 2023-11-30 00:10:54 -06:00
Pat Hartl d3e13aee9e Fix variable snippets 2023-11-29 18:19:28 -06:00
Pat Hartl ce402cf5c1 Refactored archive editor to not bind archives and handle service calls through uploader.
Fixes #40
2023-11-29 18:07:10 -06:00
Pat Hartl 3dbee36886 Remove binding for scripts on script editor for redists 2023-11-29 17:10:48 -06:00
Pat Hartl 7793c9a1e8 Fix button spacing on script editor table 2023-11-29 17:10:25 -06:00
Pat Hartl c4c25ad85b Allow redist detection scripts to run as admin 2023-11-29 17:09:52 -06:00
Pat Hartl 1d2f82fdef Switch redistibutable edit button to link 2023-11-29 17:09:04 -06:00
Pat Hartl a533e9ad8c Fix redistributable downloading 2023-11-29 17:08:33 -06:00
Pat Hartl c3a5edbe46 Update SharpCompress to latest version and rework cancellation 2023-11-28 21:20:07 -06:00
Pat Hartl 8cc97f9bdb Spliit the script editor into its own dialog separate from the table. Only pass IDs between game, editor, and dialog for better performance. 2023-11-28 20:48:03 -06:00
Pat Hartl 875b7b7caa Throw error messages when exception occurs while browsing an archive 2023-11-28 20:46:14 -06:00
Pat Hartl 6cc947b47e Fix adding new archive for redist not showing upon completion
Fixes #42
2023-11-28 19:39:41 -06:00
Pat Hartl a450ac4a18 Fix included packages in Playnite release builds 2023-11-28 18:56:09 -06:00
Pat Hartl ffa24dbecc Fix game deletions not working due to relationship with game saves, save paths, and play sessions 2023-11-28 17:56:16 -06:00
Pat Hartl d0d6701380 Push alert when there is an error deleting a game 2023-11-27 20:28:51 -06:00
Pat Hartl ab67092c2f Fix metadata lookup modal styling 2023-11-22 17:23:21 -06:00
Pat Hartl d97e1f48b3 Fix IGDB check for single player mode 2023-11-22 17:19:15 -06:00
Pat Hartl 5d5e137e18 Add flag to mark save path as regex 2023-11-08 20:43:18 -06:00
76 changed files with 10086 additions and 791 deletions

View File

@ -38,11 +38,14 @@
<Reference Include="ByteSize, Version=2.1.1.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="ByteSize, Version=2.1.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ByteSize.2.1.1\lib\net45\ByteSize.dll</HintPath> <HintPath>..\packages\ByteSize.2.1.1\lib\net45\ByteSize.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath> <HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL"> <Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.7.0.0\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll</HintPath> <HintPath>..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.8.0.0\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference> </Reference>
<Reference Include="Playnite.SDK, Version=6.10.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Playnite.SDK, Version=6.10.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\PlayniteSDK.6.10.0\lib\net462\Playnite.SDK.dll</HintPath> <HintPath>..\packages\PlayniteSDK.6.10.0\lib\net462\Playnite.SDK.dll</HintPath>
@ -52,8 +55,8 @@
<Reference Include="RestSharp, Version=106.15.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL"> <Reference Include="RestSharp, Version=106.15.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.106.15.0\lib\net452\RestSharp.dll</HintPath> <HintPath>..\packages\RestSharp.106.15.0\lib\net452\RestSharp.dll</HintPath>
</Reference> </Reference>
<Reference Include="SharpCompress, Version=0.34.1.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="SharpCompress, Version=0.34.2.0, Culture=neutral, PublicKeyToken=afb0a02973931d96, processorArchitecture=MSIL">
<HintPath>..\packages\SharpCompress.0.34.1\lib\net462\SharpCompress.dll</HintPath> <HintPath>..\packages\SharpCompress.0.34.2\lib\net462\SharpCompress.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
@ -74,14 +77,14 @@
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath> <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Text.Encoding.CodePages, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="System.Text.Encoding.CodePages, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encoding.CodePages.7.0.0\lib\net462\System.Text.Encoding.CodePages.dll</HintPath> <HintPath>..\packages\System.Text.Encoding.CodePages.8.0.0\lib\net462\System.Text.Encoding.CodePages.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Text.Encodings.Web, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="System.Text.Encodings.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.7.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath> <HintPath>..\packages\System.Text.Encodings.Web.8.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Text.Json, Version=7.0.0.3, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="System.Text.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.7.0.3\lib\net462\System.Text.Json.dll</HintPath> <HintPath>..\packages\System.Text.Json.8.0.0\lib\net462\System.Text.Json.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath> <HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
@ -100,6 +103,7 @@
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
<Reference Include="YamlDotNet, Version=5.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="YamlDotNet, Version=5.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\YamlDotNet.5.4.0\lib\net45\YamlDotNet.dll</HintPath> <HintPath>..\packages\YamlDotNet.5.4.0\lib\net45\YamlDotNet.dll</HintPath>
<Private>True</Private>
</Reference> </Reference>
<Reference Include="ZstdSharp, Version=0.7.2.0, Culture=neutral, PublicKeyToken=8d151af33a4ad5cf, processorArchitecture=MSIL"> <Reference Include="ZstdSharp, Version=0.7.2.0, Culture=neutral, PublicKeyToken=8d151af33a4ad5cf, processorArchitecture=MSIL">
<HintPath>..\packages\ZstdSharp.Port.0.7.2\lib\net461\ZstdSharp.dll</HintPath> <HintPath>..\packages\ZstdSharp.Port.0.7.2\lib\net461\ZstdSharp.dll</HintPath>

View File

@ -339,6 +339,7 @@ namespace LANCommander.PlaynitePlugin
try try
{ {
SaveController = new LANCommanderSaveController(this, args.Game);
SaveController.Download(args.Game); SaveController.Download(args.Game);
} }
catch (Exception ex) catch (Exception ex)
@ -358,6 +359,7 @@ namespace LANCommander.PlaynitePlugin
try try
{ {
SaveController = new LANCommanderSaveController(this, args.Game);
SaveController.Upload(args.Game); SaveController.Upload(args.Game);
} }
catch (Exception ex) catch (Exception ex)

View File

@ -38,3 +38,13 @@ Packages:
- Full game download will be skipped if the game files already exist, see full release notes for more details - Full game download will be skipped if the game files already exist, see full release notes for more details
- Play sessions are now recorded to the server with user ID, start time, and end time - Play sessions are now recorded to the server with user ID, start time, and end time
- Connection status now updates correctly when authenticating through addon settings - Connection status now updates correctly when authenticating through addon settings
- Version: 0.3.0
RequiredApiVersion: 6.0.0
ReleaseDate: 2023-12-03
PackageUrl: https://github.com/LANCommander/LANCommander/releases/download/v0.3.0/LANCommander.PlaynitePlugin_48e1bac7-e0a0-45d7-ba83-36f5e9e959fc_0_3_0.pext
Changelog:
- Save paths now support regex patterns (experimental)
- Fixed redistributable archive downloading
- Fixed redistributable scripts not being able to run as admin if marked as such
- Fixed game save downloading
- Fixed addon loading of YamlDotNet library

View File

@ -1,20 +1,22 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="ByteSize" version="2.1.1" targetFramework="net462" /> <package id="ByteSize" version="2.1.1" targetFramework="net462" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net462" /> <package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net462" />
<package id="NuGet.CommandLine" version="6.7.0" targetFramework="net462" developmentDependency="true" /> <package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="8.0.0" targetFramework="net462" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="8.0.0" targetFramework="net462" />
<package id="NuGet.CommandLine" version="6.8.0" targetFramework="net462" developmentDependency="true" />
<package id="PlayniteSDK" version="6.10.0" targetFramework="net462" /> <package id="PlayniteSDK" version="6.10.0" targetFramework="net462" />
<package id="PowerShellStandard.Library" version="5.1.1" targetFramework="net462" /> <package id="PowerShellStandard.Library" version="5.1.1" targetFramework="net462" />
<package id="RestSharp" version="106.15.0" targetFramework="net462" /> <package id="RestSharp" version="106.15.0" targetFramework="net462" />
<package id="rix0rrr.BeaconLib" version="1.0.2" targetFramework="net462" /> <package id="rix0rrr.BeaconLib" version="1.0.2" targetFramework="net462" />
<package id="SharpCompress" version="0.34.1" targetFramework="net462" /> <package id="SharpCompress" version="0.34.2" targetFramework="net462" />
<package id="System.Buffers" version="4.5.1" targetFramework="net462" /> <package id="System.Buffers" version="4.5.1" targetFramework="net462" />
<package id="System.Memory" version="4.5.5" targetFramework="net462" /> <package id="System.Memory" version="4.5.5" targetFramework="net462" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net462" /> <package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net462" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net462" /> <package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net462" />
<package id="System.Text.Encoding.CodePages" version="7.0.0" targetFramework="net462" /> <package id="System.Text.Encoding.CodePages" version="8.0.0" targetFramework="net462" />
<package id="System.Text.Encodings.Web" version="7.0.0" targetFramework="net462" /> <package id="System.Text.Encodings.Web" version="8.0.0" targetFramework="net462" />
<package id="System.Text.Json" version="7.0.3" targetFramework="net462" /> <package id="System.Text.Json" version="8.0.0" targetFramework="net462" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net462" /> <package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net462" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net462" /> <package id="System.ValueTuple" version="4.5.0" targetFramework="net462" />
<package id="YamlDotNet" version="5.4.0" targetFramework="net462" /> <package id="YamlDotNet" version="5.4.0" targetFramework="net462" />

View File

@ -39,21 +39,57 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.2.2.10\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath> <HintPath>..\packages\MSTest.TestFramework.2.2.10\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.2.2.10\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath> <HintPath>..\packages\MSTest.TestFramework.2.2.10\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
</Reference> </Reference>
<Reference Include="RestSharp, Version=106.15.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.106.15.0\lib\net452\RestSharp.dll</HintPath>
</Reference>
<Reference Include="SharpCompress, Version=0.34.2.0, Culture=neutral, PublicKeyToken=afb0a02973931d96, processorArchitecture=MSIL">
<HintPath>..\packages\SharpCompress.0.34.2\lib\net462\SharpCompress.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> <Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encoding.CodePages, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encoding.CodePages.8.0.0\lib\net462\System.Text.Encoding.CodePages.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="YamlDotNet, Version=5.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\YamlDotNet.5.4.0\lib\net45\YamlDotNet.dll</HintPath>
</Reference>
<Reference Include="ZstdSharp, Version=0.7.4.0, Culture=neutral, PublicKeyToken=8d151af33a4ad5cf, processorArchitecture=MSIL">
<HintPath>..\packages\ZstdSharp.Port.0.7.4\lib\net462\ZstdSharp.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Cmdlets.cs" /> <Compile Include="Cmdlets.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="app.config" />
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -61,6 +97,10 @@
<Project>{807943bf-0c7d-4ed3-8393-cfee64e3138c}</Project> <Project>{807943bf-0c7d-4ed3-8393-cfee64e3138c}</Project>
<Name>LANCommander.PowerShell</Name> <Name>LANCommander.PowerShell</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\LANCommander.SDK\LANCommander.SDK.csproj">
<Project>{4c2a71fd-a30b-4d62-888a-4ef843d8e506}</Project>
<Name>LANCommander.SDK</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" /> <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View File

@ -1,5 +1,16 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Microsoft.Bcl.AsyncInterfaces" version="5.0.0" targetFramework="net462" />
<package id="MSTest.TestAdapter" version="2.2.10" targetFramework="net462" /> <package id="MSTest.TestAdapter" version="2.2.10" targetFramework="net462" />
<package id="MSTest.TestFramework" version="2.2.10" targetFramework="net462" /> <package id="MSTest.TestFramework" version="2.2.10" targetFramework="net462" />
<package id="RestSharp" version="106.15.0" targetFramework="net462" />
<package id="SharpCompress" version="0.34.2" targetFramework="net462" />
<package id="System.Buffers" version="4.5.1" targetFramework="net462" />
<package id="System.Memory" version="4.5.5" targetFramework="net462" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net462" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net462" />
<package id="System.Text.Encoding.CodePages" version="8.0.0" targetFramework="net462" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net462" />
<package id="YamlDotNet" version="5.4.0" targetFramework="net462" />
<package id="ZstdSharp.Port" version="0.7.4" targetFramework="net462" />
</packages> </packages>

View File

@ -20,6 +20,9 @@ namespace LANCommander.PowerShell.Cmdlets
[Parameter] [Parameter]
public int MaxLength { get; set; } = 0; public int MaxLength { get; set; } = 0;
[Parameter]
public int MinLength { get; set; } = 0;
protected override void ProcessRecord() protected override void ProcessRecord()
{ {
byte[] output; byte[] output;
@ -27,6 +30,11 @@ namespace LANCommander.PowerShell.Cmdlets
if (MaxLength > 0 && Input.Length > MaxLength) if (MaxLength > 0 && Input.Length > MaxLength)
Input = Input.Substring(0, MaxLength); Input = Input.Substring(0, MaxLength);
if (MinLength > 0 && MinLength < MaxLength)
Input = Input.PadRight(MinLength, '\0');
else if (MinLength > 0)
Input = Input.PadRight(MaxLength, '\0');
if (Utf16 && BigEndian) if (Utf16 && BigEndian)
output = System.Text.Encoding.BigEndianUnicode.GetBytes(Input); output = System.Text.Encoding.BigEndianUnicode.GetBytes(Input);
else if (Utf16) else if (Utf16)

View File

@ -179,34 +179,31 @@ namespace LANCommander.SDK
Reader.Dispose(); Reader.Dispose();
Stream.Dispose(); Stream.Dispose();
} }
catch (ReaderCancelledException ex)
{
Logger?.LogTrace("User cancelled the download");
extractionResult.Canceled = true;
if (Directory.Exists(destination))
{
Logger?.LogTrace("Cleaning up orphaned files after cancelled install");
Directory.Delete(destination, true);
}
}
catch (Exception ex) catch (Exception ex)
{ {
if (Reader.Cancelled) Logger?.LogError(ex, "Could not extract to path {Destination}", destination);
if (Directory.Exists(destination))
{ {
Logger?.LogTrace("User cancelled the download"); Logger?.LogTrace("Cleaning up orphaned install files after bad install");
extractionResult.Canceled = true; Directory.Delete(destination, true);
if (Directory.Exists(destination))
{
Logger?.LogTrace("Cleaning up orphaned files after cancelled install");
Directory.Delete(destination, true);
}
} }
else
{
Logger?.LogError(ex, "Could not extract to path {Destination}", destination);
if (Directory.Exists(destination)) throw new Exception("The game archive could not be extracted, is it corrupted? Please try again");
{
Logger?.LogTrace("Cleaning up orphaned install files after bad install");
Directory.Delete(destination, true);
}
throw new Exception("The game archive could not be extracted, is it corrupted? Please try again");
}
} }
if (!extractionResult.Canceled) if (!extractionResult.Canceled)

View File

@ -13,6 +13,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using YamlDotNet.Serialization; using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NamingConventions;
@ -60,40 +61,35 @@ namespace LANCommander.SDK
ExtractFilesFromZip(tempFile, tempLocation); ExtractFilesFromZip(tempFile, tempLocation);
var deserializer = new DeserializerBuilder()
.WithNamingConvention(new PascalCaseNamingConvention())
.Build();
#region Move files #region Move files
foreach (var savePath in manifest.SavePaths.Where(sp => sp.Type == "File")) foreach (var savePath in manifest.SavePaths.Where(sp => sp.Type == "File"))
{ {
bool inInstallDir = savePath.Path.StartsWith("{InstallDir}"); bool inInstallDir = savePath.Path.StartsWith("{InstallDir}");
string tempSavePath = Path.Combine(tempLocation, savePath.Id.ToString()); string tempSavePath = Path.Combine(tempLocation, savePath.Id.ToString());
var tempSavePathFile = Path.Combine(tempSavePath, savePath.Path.Replace('/', '\\').Replace("{InstallDir}\\", "")); foreach (var entry in savePath.Entries)
destination = Environment.ExpandEnvironmentVariables(savePath.Path.Replace('/', '\\').Replace("{InstallDir}", installDirectory));
if (File.Exists(tempSavePathFile))
{ {
// Is file, move file var tempSavePathFile = Path.Combine(tempSavePath, entry.ArchivePath);
if (File.Exists(destination))
File.Delete(destination);
File.Move(tempSavePathFile, destination); destination = Environment.ExpandEnvironmentVariables(entry.ActualPath).Replace("{InstallDir}", installDirectory);
}
else if (Directory.Exists(tempSavePath))
{
var files = Directory.GetFiles(tempSavePath, "*", SearchOption.AllDirectories);
if (inInstallDir) if (File.Exists(tempSavePathFile))
{ {
if (File.Exists(destination))
File.Delete(destination);
File.Move(tempSavePathFile, destination);
}
else if (Directory.Exists(tempSavePath))
{
var files = Directory.GetFiles(tempSavePath, "*", SearchOption.AllDirectories);
foreach (var file in files) foreach (var file in files)
{ {
if (inInstallDir) if (inInstallDir)
{ {
// Files are in the game's install directory. Move them there from the save path. // Files are in the game's install directory. Move them there from the save path.
destination = file.Replace(tempSavePath, savePath.Path.Replace('/', '\\').TrimEnd('\\').Replace("{InstallDir}", installDirectory)); destination = file.Replace(tempSavePath, savePath.Path.Replace('/', Path.DirectorySeparatorChar).TrimEnd(Path.DirectorySeparatorChar).Replace("{InstallDir}", installDirectory));
if (File.Exists(destination)) if (File.Exists(destination))
File.Delete(destination); File.Delete(destination);
@ -103,7 +99,7 @@ namespace LANCommander.SDK
else else
{ {
// Specified path is probably an absolute path, maybe with environment variables. // Specified path is probably an absolute path, maybe with environment variables.
destination = Environment.ExpandEnvironmentVariables(file.Replace(tempSavePathFile, savePath.Path.Replace('/', '\\'))); destination = Environment.ExpandEnvironmentVariables(file.Replace(tempSavePathFile, savePath.Path.Replace('/', Path.DirectorySeparatorChar)));
if (File.Exists(destination)) if (File.Exists(destination))
File.Delete(destination); File.Delete(destination);
@ -112,10 +108,6 @@ namespace LANCommander.SDK
} }
} }
} }
else
{
}
} }
} }
#endregion #endregion
@ -163,31 +155,42 @@ namespace LANCommander.SDK
#region Add files from defined paths #region Add files from defined paths
foreach (var savePath in manifest.SavePaths.Where(sp => sp.Type == "File")) foreach (var savePath in manifest.SavePaths.Where(sp => sp.Type == "File"))
{ {
var localPath = Environment.ExpandEnvironmentVariables(savePath.Path.Replace('/', '\\').Replace("{InstallDir}", installDirectory)); IEnumerable<string> localPaths;
if (Directory.Exists(localPath)) if (savePath.IsRegex)
{ {
AddDirectoryToZip(archive, localPath, localPath, savePath.Id); var regex = new Regex(Environment.ExpandEnvironmentVariables(savePath.Path.Replace('/', '\\').Replace("{InstallDir}", installDirectory)));
}
else if (File.Exists(localPath))
{
archive.AddEntry(Path.Combine(savePath.Id.ToString(), savePath.Path.Replace("{InstallDir}/", "")), localPath);
}
}
#endregion
#region Add files from defined paths localPaths = Directory.GetFiles(installDirectory, "*", SearchOption.AllDirectories)
foreach (var savePath in manifest.SavePaths.Where(sp => sp.Type == "File")) .Where(p => regex.IsMatch(p))
{ .ToList();
var localPath = Environment.ExpandEnvironmentVariables(savePath.Path.Replace('/', '\\').Replace("{InstallDir}", installDirectory));
if (Directory.Exists(localPath))
{
AddDirectoryToZip(archive, localPath, localPath, savePath.Id);
} }
else if (File.Exists(localPath)) else
localPaths = new string[] { savePath.Path };
var entries = new List<SavePathEntry>();
foreach (var localPath in localPaths)
{ {
archive.AddEntry(Path.Combine(savePath.Id.ToString(), savePath.Path.Replace("{InstallDir}/", "")), localPath); var actualPath = Environment.ExpandEnvironmentVariables(savePath.Path.Replace('/', Path.DirectorySeparatorChar).Replace("{InstallDir}", installDirectory));
var relativePath = actualPath.Replace(installDirectory + Path.DirectorySeparatorChar, "");
if (Directory.Exists(actualPath))
{
AddDirectoryToZip(archive, relativePath, actualPath, savePath.Id);
}
else if (File.Exists(actualPath))
{
archive.AddEntry(Path.Combine(savePath.Id.ToString(), relativePath), actualPath);
}
entries.Add(new SavePathEntry
{
ArchivePath = relativePath,
ActualPath = actualPath.Replace(installDirectory, "{InstallDir}")
});
savePath.Entries = entries;
} }
} }
#endregion #endregion
@ -225,7 +228,11 @@ namespace LANCommander.SDK
} }
#endregion #endregion
archive.AddEntry("_manifest.yml", ManifestHelper.GetPath(installDirectory)); var tempManifest = Path.GetTempFileName();
File.WriteAllText(tempManifest, ManifestHelper.Serialize(manifest));
archive.AddEntry("_manifest.yml", tempManifest);
using (var ms = new MemoryStream()) using (var ms = new MemoryStream())
{ {

View File

@ -43,13 +43,7 @@ namespace LANCommander.SDK.Helpers
Logger?.LogTrace("Attempting to write manifest to path {Destination}", destination); Logger?.LogTrace("Attempting to write manifest to path {Destination}", destination);
var serializer = new SerializerBuilder() var yaml = Serialize(manifest);
.WithNamingConvention(new PascalCaseNamingConvention())
.Build();
Logger?.LogTrace("Serializing manifest");
var yaml = serializer.Serialize(manifest);
Logger?.LogTrace("Writing manifest file"); Logger?.LogTrace("Writing manifest file");
@ -58,6 +52,19 @@ namespace LANCommander.SDK.Helpers
return destination; return destination;
} }
public static string Serialize(GameManifest manifest)
{
var serializer = new SerializerBuilder()
.WithNamingConvention(new PascalCaseNamingConvention())
.Build();
Logger?.LogTrace("Serializing manifest");
var yaml = serializer.Serialize(manifest);
return yaml;
}
public static string GetPath(string installDirectory) public static string GetPath(string installDirectory)
{ {
return Path.Combine(installDirectory, ManifestFilename); return Path.Combine(installDirectory, ManifestFilename);

View File

@ -5,10 +5,10 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="PowerShellStandard.Library" Version="5.1.1" /> <PackageReference Include="PowerShellStandard.Library" Version="5.1.1" />
<PackageReference Include="RestSharp" Version="106.15.0" /> <PackageReference Include="RestSharp" Version="106.15.0" />
<PackageReference Include="SharpCompress" Version="0.34.1" /> <PackageReference Include="SharpCompress" Version="0.34.2" />
<PackageReference Include="YamlDotNet" Version="5.4.0" /> <PackageReference Include="YamlDotNet" Version="5.4.0" />
</ItemGroup> </ItemGroup>

View File

@ -47,5 +47,13 @@ namespace LANCommander.SDK
public Guid Id { get; set; } public Guid Id { get; set; }
public string Type { get; set; } public string Type { get; set; }
public string Path { get; set; } public string Path { get; set; }
public bool IsRegex { get; set; }
public IEnumerable<SavePathEntry> Entries { get; set; }
}
public class SavePathEntry
{
public string ArchivePath { get; set; }
public string ActualPath { get; set; }
} }
} }

View File

@ -9,6 +9,7 @@ namespace LANCommander.SDK.Models
{ {
public SavePathType Type { get; set; } public SavePathType Type { get; set; }
public string Path { get; set; } public string Path { get; set; }
public bool IsRegex { get; set; }
public virtual Game Game { get; set; } public virtual Game Game { get; set; }
} }
} }

View File

@ -58,7 +58,7 @@ namespace LANCommander.SDK
var detectionScript = redistributable.Scripts.FirstOrDefault(s => s.Type == ScriptType.DetectInstall); var detectionScript = redistributable.Scripts.FirstOrDefault(s => s.Type == ScriptType.DetectInstall);
detectionScriptTempFile = ScriptHelper.SaveTempScript(detectionScript); detectionScriptTempFile = ScriptHelper.SaveTempScript(detectionScript);
var detectionResult = RunScript(detectionScriptTempFile, redistributable); var detectionResult = RunScript(detectionScriptTempFile, redistributable, detectionScript.RequiresAdmin);
// Redistributable is not installed // Redistributable is not installed
if (detectionResult == 0) if (detectionResult == 0)

View File

@ -46,15 +46,14 @@
</SpaceItem> </SpaceItem>
</Space> </Space>
<ArchiveUploader @ref="Uploader" OnArchiveUploaded="AddArchive" /> <ArchiveUploader @ref="Uploader" GameId="GameId" RedistributableId="RedistributableId" OnArchiveUploaded="LoadData" />
@code { @code {
[Parameter] public Guid GameId { get; set; } [Parameter] public Guid GameId { get; set; }
[Parameter] public Guid RedistributableId { get; set; } [Parameter] public Guid RedistributableId { get; set; }
[Parameter] public ICollection<Archive> Archives { get; set; }
[Parameter] public EventCallback<ICollection<Archive>> ArchivesChanged { get; set; }
Archive Archive; ICollection<Archive> Archives { get; set; }
ArchiveUploader Uploader; ArchiveUploader Uploader;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
@ -66,7 +65,10 @@
private async Task LoadData() private async Task LoadData()
{ {
Archives = await ArchiveService.Get(a => a.GameId == GameId).ToListAsync(); if (GameId != Guid.Empty)
Archives = await ArchiveService.Get(a => a.GameId == GameId).ToListAsync();
else if (RedistributableId != Guid.Empty)
Archives = await ArchiveService.Get(a => a.RedistributableId == RedistributableId).ToListAsync();
} }
private async Task Download(Archive archive) private async Task Download(Archive archive)
@ -78,27 +80,7 @@
private async Task UploadArchive() private async Task UploadArchive()
{ {
if (GameId != Guid.Empty) await Uploader.Open();
Archive = new Archive() { GameId = GameId, Id = Guid.NewGuid() };
if (RedistributableId != Guid.Empty)
Archive = new Archive() { RedistributableId = RedistributableId, Id = Guid.NewGuid() };
await Uploader.Open(Archive);
}
private async Task AddArchive(Archive archive)
{
var lastArchive = Archives.OrderByDescending(a => a.CreatedOn).FirstOrDefault();
Archive = await ArchiveService.Add(archive);
await LoadData();
var settings = SettingService.GetSettings();
if (lastArchive != null && settings.Archives.EnablePatching)
BackgroundJob.Enqueue<PatchArchiveBackgroundJob>(x => x.Execute(lastArchive.Id, Archive.Id));
} }
private async Task Delete(Archive archive) private async Task Delete(Archive archive)
@ -107,6 +89,8 @@
{ {
await ArchiveService.Delete(archive); await ArchiveService.Delete(archive);
await LoadData();
await MessageService.Success("Archive deleted!"); await MessageService.Success("Archive deleted!");
} }
catch (Exception ex) catch (Exception ex)

View File

@ -2,6 +2,7 @@
@using System.Diagnostics; @using System.Diagnostics;
@using Hangfire; @using Hangfire;
@using LANCommander.Jobs.Background; @using LANCommander.Jobs.Background;
@using Microsoft.EntityFrameworkCore;
@inject HttpClient HttpClient @inject HttpClient HttpClient
@inject NavigationManager Navigator @inject NavigationManager Navigator
@inject ArchiveService ArchiveService @inject ArchiveService ArchiveService
@ -62,7 +63,9 @@
</Modal> </Modal>
@code { @code {
[Parameter] public EventCallback<Archive> OnArchiveUploaded { get; set; } [Parameter] public Guid GameId { get; set; }
[Parameter] public Guid RedistributableId { get; set; }
[Parameter] public EventCallback<Guid> OnArchiveUploaded { get; set; }
Archive Archive; Archive Archive;
@ -113,9 +116,21 @@
File = args.File; File = args.File;
} }
public async Task Open(Archive archive) public async Task Open(Guid? archiveId = null)
{ {
Archive = archive; if (archiveId.HasValue && archiveId != Guid.Empty)
{
Archive = await ArchiveService.Get(archiveId.Value);
}
else
{
Archive = new Archive();
if (GameId != Guid.Empty)
Archive.GameId = GameId;
else if (RedistributableId != Guid.Empty)
Archive.RedistributableId = RedistributableId;
}
Visible = true; Visible = true;
@ -128,8 +143,8 @@
{ {
if (FileInput != null) if (FileInput != null)
{ {
if (!String.IsNullOrWhiteSpace(archive.ObjectKey) && archive.ObjectKey != Guid.Empty.ToString()) if (!String.IsNullOrWhiteSpace(Archive.ObjectKey) && Archive.ObjectKey != Guid.Empty.ToString())
await JS.InvokeVoidAsync("Uploader.Init", "FileInput", archive.ObjectKey.ToString()); await JS.InvokeVoidAsync("Uploader.Init", "FileInput", Archive.ObjectKey.ToString());
else else
await JS.InvokeVoidAsync("Uploader.Init", "FileInput", ""); await JS.InvokeVoidAsync("Uploader.Init", "FileInput", "");
@ -163,12 +178,32 @@
Archive.ObjectKey = objectKey.ToString(); Archive.ObjectKey = objectKey.ToString();
Archive.CompressedSize = File.Size; Archive.CompressedSize = File.Size;
if (Archive.Id != Guid.Empty)
Archive = await ArchiveService.Update(Archive);
else
Archive = await ArchiveService.Add(Archive);
Visible = false; Visible = false;
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);
Archive? lastArchive = null;
var settings = SettingService.GetSettings();
if (settings.Archives.EnablePatching)
{
if (Archive.GameId != Guid.Empty)
lastArchive = await ArchiveService.Get(a => a.Id != Archive.Id && a.GameId == Archive.GameId).OrderByDescending(a => a.CreatedOn).FirstOrDefaultAsync();
else if (Archive.RedistributableId != Guid.Empty)
lastArchive = await ArchiveService.Get(a => a.Id != Archive.Id && a.RedistributableId == Archive.RedistributableId).OrderByDescending(a => a.CreatedOn).FirstOrDefaultAsync();
if (lastArchive != null && settings.Archives.EnablePatching)
BackgroundJob.Enqueue<PatchArchiveBackgroundJob>(x => x.Execute(lastArchive.Id, Archive.Id));
}
if (OnArchiveUploaded.HasDelegate) if (OnArchiveUploaded.HasDelegate)
await OnArchiveUploaded.InvokeAsync(Archive); await OnArchiveUploaded.InvokeAsync(Archive.Id);
await MessageService.Success("Archive uploaded!"); await MessageService.Success("Archive uploaded!");
} }

View File

@ -239,24 +239,37 @@
async Task<HashSet<FileManagerDirectory>> GetArchiveDirectoriesAsync(Guid archiveId) async Task<HashSet<FileManagerDirectory>> GetArchiveDirectoriesAsync(Guid archiveId)
{ {
var entries = await ArchiveService.GetContents(archiveId); try
var directories = new HashSet<FileManagerDirectory>();
var root = new FileManagerDirectory
{ {
Name = "Root", var entries = await ArchiveService.GetContents(archiveId);
Path = "", var directories = new HashSet<FileManagerDirectory>();
IsExpanded = true
};
root.PopulateChildren(entries); var root = new FileManagerDirectory
{
Name = "Root",
Path = "",
IsExpanded = true
};
await ChangeDirectory(root, true); root.PopulateChildren(entries);
return new HashSet<FileManagerDirectory> await ChangeDirectory(root, true);
return new HashSet<FileManagerDirectory>
{
root
};
}
catch (FileNotFoundException ex)
{ {
root MessageService.Error("Could not open archive! Is it missing?");
}; }
catch (Exception ex)
{
MessageService.Error("An unknown error occurred trying to open the archive");
}
return new HashSet<FileManagerDirectory>();
} }
string GetEntryName(IFileManagerEntry entry) string GetEntryName(IFileManagerEntry entry)

View File

@ -4,75 +4,12 @@
@using LANCommander.Models @using LANCommander.Models
@using LANCommander.Services @using LANCommander.Services
@using System.IO.Compression; @using System.IO.Compression;
@using Microsoft.EntityFrameworkCore;
@inject ScriptService ScriptService @inject ScriptService ScriptService
@inject ModalService ModalService @inject ModalService ModalService
@inject IMessageService MessageService @inject IMessageService MessageService
@{
RenderFragment Footer =
@<Template>
<Button OnClick="Save" Disabled="@(String.IsNullOrWhiteSpace(Script.Name))" Type="@ButtonType.Primary">Save</Button>
<Button OnClick="Close">Close</Button>
</Template>;
}
<Modal Visible="ModalVisible" Footer="@Footer" Title="@(Script == null ? "Add Script" : "Edit Script")" OkText="@("Save")" Maximizable="false" DefaultMaximized="true" Closable="true" OnCancel="Close">
<Form Model="@Script" Layout="@FormLayout.Vertical">
<FormItem>
@foreach (var group in Snippets.Select(s => s.Group).Distinct())
{
<Dropdown>
<Overlay>
<Menu>
@foreach (var snippet in Snippets.Where(s => s.Group == group))
{
<MenuItem OnClick="() => InsertSnippet(snippet)">
@snippet.Name
</MenuItem>
}
</Menu>
</Overlay>
<ChildContent>
<Button Type="@ButtonType.Primary">@group</Button>
</ChildContent>
</Dropdown>
}
@if (ArchiveId != Guid.Empty)
{
<Button Icon="@IconType.Outline.FolderOpen" OnClick="BrowseForPath" Type="@ButtonType.Text">Browse</Button>
}
<Button Icon="@IconType.Outline.Build" OnClick="() => RegToPowerShell.Open()" Type="@ButtonType.Text">Import .reg</Button>
</FormItem>
<FormItem>
<StandaloneCodeEditor @ref="Editor" Id="editor" ConstructionOptions="EditorConstructionOptions" />
</FormItem>
<FormItem Label="Name">
<Input @bind-Value="@context.Name" />
</FormItem>
<FormItem Label="Type">
<Select @bind-Value="context.Type" TItem="ScriptType" TItemValue="ScriptType" DataSource="Enum.GetValues<ScriptType>().Where(st => AllowedTypes == null || AllowedTypes.Contains(st))">
<LabelTemplate Context="Value">@Value.GetDisplayName()</LabelTemplate>
<ItemTemplate Context="Value">@Value.GetDisplayName()</ItemTemplate>
</Select>
</FormItem>
<FormItem>
<Checkbox @bind-Checked="context.RequiresAdmin">Requires Admin</Checkbox>
</FormItem>
<FormItem Label="Description">
<TextArea @bind-Value="context.Description" MaxLength=500 ShowCount />
</FormItem>
</Form>
</Modal>
<RegToPowerShell @ref="RegToPowerShell" OnParsed="(text) => InsertText(text)" />
<Space Direction="DirectionVHType.Vertical" Size="@("large")" Style="width: 100%"> <Space Direction="DirectionVHType.Vertical" Size="@("large")" Style="width: 100%">
<SpaceItem> <SpaceItem>
@ -85,8 +22,9 @@
<ActionColumn Title=""> <ActionColumn Title="">
<Space Style="display: flex; justify-content: end"> <Space Style="display: flex; justify-content: end">
<SpaceItem> <SpaceItem>
<Button OnClick="() => Edit(context)" Icon="@IconType.Outline.Edit" Type="@ButtonType.Text" /> <Button OnClick="() => Edit(context.Id)" Icon="@IconType.Outline.Edit" Type="@ButtonType.Text" />
</SpaceItem>
<SpaceItem>
<Popconfirm OnConfirm="() => Delete(context)" Title="Are you sure you want to delete this script?"> <Popconfirm OnConfirm="() => Delete(context)" Title="Are you sure you want to delete this script?">
<Button Icon="@IconType.Outline.Close" Type="@ButtonType.Text" Danger /> <Button Icon="@IconType.Outline.Close" Type="@ButtonType.Text" Danger />
</Popconfirm> </Popconfirm>
@ -115,61 +53,51 @@
[Parameter] public Guid GameId { get; set; } [Parameter] public Guid GameId { get; set; }
[Parameter] public Guid RedistributableId { get; set; } [Parameter] public Guid RedistributableId { get; set; }
[Parameter] public Guid ArchiveId { get; set; } [Parameter] public Guid ArchiveId { get; set; }
[Parameter] public ICollection<Script> Scripts { get; set; }
[Parameter] public EventCallback<ICollection<Script>> ScriptsChanged { get; set; }
[Parameter] public IEnumerable<ScriptType> AllowedTypes { get; set; } [Parameter] public IEnumerable<ScriptType> AllowedTypes { get; set; }
Script Script; ICollection<Script> Scripts { get; set; } = new List<Script>();
bool ModalVisible = false; protected override async Task OnParametersSetAsync()
IEnumerable<Snippet> Snippets { get; set; }
StandaloneCodeEditor? Editor;
RegToPowerShell RegToPowerShell;
private StandaloneEditorConstructionOptions EditorConstructionOptions(StandaloneCodeEditor editor)
{ {
return new StandaloneEditorConstructionOptions await LoadData();
}
private async Task LoadData()
{
if (GameId != Guid.Empty)
Scripts = await ScriptService.Get(s => s.GameId == GameId).ToListAsync();
else if (RedistributableId != Guid.Empty)
Scripts = await ScriptService.Get(s => s.RedistributableId == RedistributableId).ToListAsync();
await InvokeAsync(StateHasChanged);
}
private async void Edit(Guid? scriptId = null)
{
var modalOptions = new ModalOptions()
{ {
AutomaticLayout = true, Title = scriptId == null ? "Add Script" : "Edit Script",
Language = "powershell", Maximizable = false,
Value = Script.Contents, DefaultMaximized = true,
Theme = "vs-dark", Closable = true,
OkText = "Save"
}; };
}
protected override async Task OnInitializedAsync() var options = new ScriptEditorOptions()
{ {
if (Scripts == null) ScriptId = scriptId ?? default,
Scripts = new List<Script>(); AllowedTypes = AllowedTypes,
ArchiveId = ArchiveId,
GameId = GameId,
RedistributableId = RedistributableId
};
Snippets = ScriptService.GetSnippets(); var modalRef = await ModalService.CreateModalAsync<ScriptEditorDialog, ScriptEditorOptions, Script>(modalOptions, options);
if (Script == null) modalRef.OnOk = async (script) =>
Script = new Script(); {
} await LoadData();
};
private async void Edit(Script script = null)
{
if (script == null) {
if (GameId != Guid.Empty)
Script = new Script() { GameId = GameId };
if (RedistributableId != Guid.Empty)
Script = new Script() { RedistributableId = RedistributableId };
if (Editor != null)
await Editor.SetValue("");
}
else
Script = script;
if (Editor != null && Script != null)
await Editor.SetValue(Script.Contents);
ModalVisible = true;
StateHasChanged();
} }
private async void Delete(Script script = null) private async void Delete(Script script = null)
@ -179,81 +107,4 @@
await MessageService.Success("Script deleted!"); await MessageService.Success("Script deleted!");
} }
private void Close()
{
ModalVisible = false;
}
private async Task Save()
{
var value = await Editor.GetValue();
Script.Contents = value;
if (Script.Id == Guid.Empty)
Script = await ScriptService.Add(Script);
else
Script = await ScriptService.Update(Script);
Close();
StateHasChanged();
await MessageService.Success("Script saved!");
}
private async Task InsertText(string text)
{
var line = await Editor.GetPosition();
var range = new BlazorMonaco.Range(line.LineNumber, 1, line.LineNumber, 1);
var currentSelections = await Editor.GetSelections();
await Editor.ExecuteEdits("ScriptEditor", new List<IdentifiedSingleEditOperation>()
{
new IdentifiedSingleEditOperation
{
Range = range,
Text = text,
ForceMoveMarkers = true
}
}, currentSelections);
}
private async Task InsertSnippet(Snippet snippet)
{
await InsertText(snippet.Content);
}
private async void BrowseForPath()
{
var modalOptions = new ModalOptions()
{
Title = "Choose Reference",
Maximizable = false,
DefaultMaximized = true,
Closable = true,
OkText = "Insert File Path"
};
var browserOptions = new FilePickerOptions()
{
ArchiveId = ArchiveId,
Select = true,
Multiple = false
};
var modalRef = await ModalService.CreateModalAsync<FilePickerDialog, FilePickerOptions, IEnumerable<IFileManagerEntry>>(modalOptions, browserOptions);
modalRef.OnOk = (results) =>
{
var path = results.FirstOrDefault().Path;
InsertText($"$InstallDir\\{path.Replace('/', '\\')}");
StateHasChanged();
return Task.CompletedTask;
};
}
} }

View File

@ -0,0 +1,195 @@
@using LANCommander.Components.FileManagerComponents;
@using LANCommander.Extensions;
@using LANCommander.Data.Enums;
@using LANCommander.Models;
@inherits FeedbackComponent<ScriptEditorOptions, Script>
@inject ScriptService ScriptService
@inject ModalService ModalService
@inject IMessageService MessageService
<Form Model="@Script" Layout="@FormLayout.Vertical">
<FormItem>
@foreach (var group in Snippets.Select(s => s.Group).Distinct())
{
<Dropdown>
<Overlay>
<Menu>
@foreach (var snippet in Snippets.Where(s => s.Group == group))
{
<MenuItem OnClick="() => InsertSnippet(snippet)">
@snippet.Name
</MenuItem>
}
</Menu>
</Overlay>
<ChildContent>
<Button Type="@ButtonType.Primary">@group</Button>
</ChildContent>
</Dropdown>
}
@if (Options.ArchiveId != Guid.Empty)
{
<Button Icon="@IconType.Outline.FolderOpen" OnClick="BrowseForPath" Type="@ButtonType.Text">Browse</Button>
}
<Button Icon="@IconType.Outline.Build" OnClick="() => RegToPowerShell.Open()" Type="@ButtonType.Text">Import .reg</Button>
</FormItem>
<FormItem>
<StandaloneCodeEditor @ref="Editor" Id="@("editor-" + Id.ToString())" ConstructionOptions="EditorConstructionOptions" />
</FormItem>
<FormItem Label="Name">
<Input @bind-Value="@context.Name" />
</FormItem>
<FormItem Label="Type">
<Select @bind-Value="context.Type" TItem="ScriptType" TItemValue="ScriptType" DataSource="Enum.GetValues<ScriptType>().Where(st => Options.AllowedTypes == null || Options.AllowedTypes.Contains(st))">
<LabelTemplate Context="Value">@Value.GetDisplayName()</LabelTemplate>
<ItemTemplate Context="Value">@Value.GetDisplayName()</ItemTemplate>
</Select>
</FormItem>
<FormItem>
<Checkbox @bind-Checked="context.RequiresAdmin">Requires Admin</Checkbox>
</FormItem>
<FormItem Label="Description">
<TextArea @bind-Value="context.Description" MaxLength=500 ShowCount />
</FormItem>
</Form>
<RegToPowerShell @ref="RegToPowerShell" OnParsed="(text) => InsertText(text)" />
@code {
Guid Id = Guid.NewGuid();
Script Script;
StandaloneCodeEditor? Editor;
RegToPowerShell RegToPowerShell;
IEnumerable<Snippet> Snippets { get; set; }
private StandaloneEditorConstructionOptions EditorConstructionOptions(StandaloneCodeEditor editor)
{
return new StandaloneEditorConstructionOptions
{
AutomaticLayout = true,
Language = "powershell",
Value = Script.Contents,
Theme = "vs-dark",
};
}
protected override async Task OnInitializedAsync()
{
if (Options.ScriptId != Guid.Empty)
Script = await ScriptService.Get(Options.ScriptId);
else if (Options.GameId != Guid.Empty)
Script = new Script()
{
GameId = Options.GameId
};
else if (Options.RedistributableId != Guid.Empty)
Script = new Script()
{
RedistributableId = Options.RedistributableId
};
Snippets = ScriptService.GetSnippets();
}
public override async Task OnFeedbackOkAsync(ModalClosingEventArgs args)
{
await Save();
Editor.Dispose();
await base.OkCancelRefWithResult!.OnOk(Script);
}
public override async Task CancelAsync(ModalClosingEventArgs args)
{
Editor.Dispose();
await base.CancelAsync(args);
}
private async void BrowseForPath()
{
var modalOptions = new ModalOptions()
{
Title = "Choose Reference",
Maximizable = false,
DefaultMaximized = true,
Closable = true,
OkText = "Insert File Path"
};
var browserOptions = new FilePickerOptions()
{
ArchiveId = Options.ArchiveId,
Select = true,
Multiple = false
};
var modalRef = await ModalService.CreateModalAsync<FilePickerDialog, FilePickerOptions, IEnumerable<IFileManagerEntry>>(modalOptions, browserOptions);
modalRef.OnOk = (results) =>
{
var path = results.FirstOrDefault().Path;
InsertText($"$InstallDir\\{path.Replace('/', '\\')}");
StateHasChanged();
return Task.CompletedTask;
};
}
private async Task InsertText(string text)
{
var line = await Editor.GetPosition();
var range = new BlazorMonaco.Range(line.LineNumber, 1, line.LineNumber, 1);
var currentSelections = await Editor.GetSelections();
await Editor.ExecuteEdits("ScriptEditor", new List<IdentifiedSingleEditOperation>()
{
new IdentifiedSingleEditOperation
{
Range = range,
Text = text,
ForceMoveMarkers = true
}
}, currentSelections);
}
private async Task InsertSnippet(Snippet snippet)
{
await InsertText(snippet.Content);
}
private async Task Save()
{
try
{
var value = await Editor.GetValue();
Script.Contents = value;
if (Script.Id == Guid.Empty)
Script = await ScriptService.Add(Script);
else
Script = await ScriptService.Update(Script);
MessageService.Success("Script saved!");
}
catch (Exception ex)
{
MessageService.Error("Script could not be saved!");
throw ex;
}
}
}

View File

@ -2,7 +2,7 @@
<Select Mode="tags" TItem="Guid" TItemValue="Guid" @bind-Values="@SelectedValues" OnSelectedItemsChanged="OnSelectedItemsChanged" EnableSearch> <Select Mode="tags" TItem="Guid" TItemValue="Guid" @bind-Values="@SelectedValues" OnSelectedItemsChanged="OnSelectedItemsChanged" EnableSearch>
<SelectOptions> <SelectOptions>
@foreach (var entity in Entities) @foreach (var entity in Entities.OrderBy(OptionLabelSelector))
{ {
<SelectOption TItemValue="Guid" TItem="Guid" Value="@entity.Id" Label="@OptionLabelSelector.Invoke(entity)" /> <SelectOption TItemValue="Guid" TItem="Guid" Value="@entity.Id" Label="@OptionLabelSelector.Invoke(entity)" />
} }
@ -45,7 +45,7 @@
} }
if (ValuesChanged.HasDelegate) if (ValuesChanged.HasDelegate)
await ValuesChanged.InvokeAsync(); await ValuesChanged.InvokeAsync(Values);
StateHasChanged(); StateHasChanged();
} }

View File

@ -31,7 +31,14 @@ namespace LANCommander.Controllers
if (!System.IO.File.Exists(filename)) if (!System.IO.File.Exists(filename))
return NotFound(); return NotFound();
return File(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read), "application/octet-stream", $"{archive.Game.Title.SanitizeFilename()}.zip"); string name = "";
if (archive.GameId != null && archive.GameId != Guid.Empty)
name = $"{archive.Game.Title.SanitizeFilename()}.zip";
else if (archive.RedistributableId != null && archive.RedistributableId != Guid.Empty)
name = $"{archive.Redistributable.Name.SanitizeFilename()}.zip";
return File(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read), "application/octet-stream", name);
} }
} }
} }

View File

@ -30,7 +30,7 @@ namespace LANCommander.Controllers
if (!System.IO.File.Exists(filename)) if (!System.IO.File.Exists(filename))
return NotFound(); return NotFound();
return File(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read), "application/zip", $"{save.User?.UserName} - {save.Game?.Title} - {save.CreatedOn.ToString("MM-dd-yyyy.hh-mm")}"); return File(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read), "application/zip", $"{save.User?.UserName} - {(save.Game == null ? "Unknown" : save.Game?.Title)} - {save.CreatedOn.ToString("MM-dd-yyyy.hh-mm")}.zip");
} }
} }
} }

View File

@ -17,6 +17,26 @@ namespace LANCommander.Data
{ {
base.OnModelCreating(builder); base.OnModelCreating(builder);
builder.ConfigureBaseRelationships<Data.Models.Action>();
builder.ConfigureBaseRelationships<Archive>();
builder.ConfigureBaseRelationships<Category>();
builder.ConfigureBaseRelationships<Collection>();
builder.ConfigureBaseRelationships<Company>();
builder.ConfigureBaseRelationships<Game>();
builder.ConfigureBaseRelationships<GameSave>();
builder.ConfigureBaseRelationships<Genre>();
builder.ConfigureBaseRelationships<Key>();
builder.ConfigureBaseRelationships<Media>();
builder.ConfigureBaseRelationships<MultiplayerMode>();
builder.ConfigureBaseRelationships<PlaySession>();
builder.ConfigureBaseRelationships<Redistributable>();
builder.ConfigureBaseRelationships<SavePath>();
builder.ConfigureBaseRelationships<Script>();
builder.ConfigureBaseRelationships<Server>();
builder.ConfigureBaseRelationships<ServerConsole>();
builder.ConfigureBaseRelationships<ServerHttpPath>();
builder.ConfigureBaseRelationships<Tag>();
builder.Entity<Genre>() builder.Entity<Genre>()
.HasMany(g => g.Games) .HasMany(g => g.Games)
.WithMany(g => g.Genres); .WithMany(g => g.Genres);
@ -34,6 +54,7 @@ namespace LANCommander.Data
.HasMany(t => t.Games) .HasMany(t => t.Games)
.WithMany(g => g.Tags); .WithMany(g => g.Tags);
#region Game Relationships
builder.Entity<Game>() builder.Entity<Game>()
.HasMany(g => g.Archives) .HasMany(g => g.Archives)
.WithOne(g => g.Game) .WithOne(g => g.Game)
@ -63,6 +84,28 @@ namespace LANCommander.Data
.IsRequired(true) .IsRequired(true)
.OnDelete(DeleteBehavior.Cascade); .OnDelete(DeleteBehavior.Cascade);
builder.Entity<Game>()
.HasMany(g => g.Media)
.WithOne(m => m.Game)
.OnDelete(DeleteBehavior.Cascade);
builder.Entity<Game>()
.HasMany(g => g.SavePaths)
.WithOne(p => p.Game)
.OnDelete(DeleteBehavior.Cascade);
builder.Entity<Game>()
.HasMany(g => g.PlaySessions)
.WithOne(ps => ps.Game)
.IsRequired(false)
.OnDelete(DeleteBehavior.SetNull);
builder.Entity<Game>()
.HasMany(g => g.GameSaves)
.WithOne(gs => gs.Game)
.IsRequired(false)
.OnDelete(DeleteBehavior.SetNull);
builder.Entity<Game>() builder.Entity<Game>()
.HasMany(g => g.Developers) .HasMany(g => g.Developers)
.WithMany(c => c.DevelopedGames) .WithMany(c => c.DevelopedGames)
@ -89,41 +132,28 @@ namespace LANCommander.Data
gr => gr.HasOne<Redistributable>().WithMany().HasForeignKey("RedistributableId"), gr => gr.HasOne<Redistributable>().WithMany().HasForeignKey("RedistributableId"),
gr => gr.HasOne<Game>().WithMany().HasForeignKey("GameId") gr => gr.HasOne<Game>().WithMany().HasForeignKey("GameId")
); );
#endregion
builder.Entity<Game>() #region User Relationships
.HasMany(g => g.Media)
.WithOne(m => m.Game)
.OnDelete(DeleteBehavior.Cascade);
builder.Entity<User>() builder.Entity<User>()
.HasMany(u => u.GameSaves) .HasMany(u => u.GameSaves)
.WithOne(gs => gs.User) .WithOne(gs => gs.User)
.IsRequired(true) .IsRequired(true)
.OnDelete(DeleteBehavior.Cascade); .OnDelete(DeleteBehavior.Cascade);
builder.Entity<Game>()
.HasMany(g => g.GameSaves)
.WithOne(gs => gs.Game)
.IsRequired(true)
.OnDelete(DeleteBehavior.NoAction);
builder.Entity<User>() builder.Entity<User>()
.HasMany(u => u.PlaySessions) .HasMany(u => u.PlaySessions)
.WithOne(ps => ps.User) .WithOne(ps => ps.User)
.IsRequired(true) .IsRequired(true)
.OnDelete(DeleteBehavior.Cascade); .OnDelete(DeleteBehavior.Cascade);
#endregion
builder.Entity<Game>() #region Server Relationships
.HasMany(g => g.PlaySessions)
.WithOne(ps => ps.Game)
.IsRequired(true)
.OnDelete(DeleteBehavior.NoAction);
builder.Entity<Server>() builder.Entity<Server>()
.HasOne(s => s.Game) .HasOne(s => s.Game)
.WithMany(g => g.Servers) .WithMany(g => g.Servers)
.IsRequired(false) .IsRequired(false)
.OnDelete(DeleteBehavior.NoAction); .OnDelete(DeleteBehavior.SetNull);
builder.Entity<Server>() builder.Entity<Server>()
.HasMany<ServerConsole>() .HasMany<ServerConsole>()
@ -136,7 +166,9 @@ namespace LANCommander.Data
.WithOne(s => s.Server) .WithOne(s => s.Server)
.IsRequired(true) .IsRequired(true)
.OnDelete(DeleteBehavior.Cascade); .OnDelete(DeleteBehavior.Cascade);
#endregion
#region Redistributable Relationships
builder.Entity<Redistributable>() builder.Entity<Redistributable>()
.HasMany(r => r.Archives) .HasMany(r => r.Archives)
.WithOne(a => a.Redistributable) .WithOne(a => a.Redistributable)
@ -148,6 +180,29 @@ namespace LANCommander.Data
.WithOne(s => s.Redistributable) .WithOne(s => s.Redistributable)
.IsRequired(false) .IsRequired(false)
.OnDelete(DeleteBehavior.Cascade); .OnDelete(DeleteBehavior.Cascade);
#endregion
#region Collection Relationships
builder.Entity<Collection>()
.HasMany(c => c.Games)
.WithMany(g => g.Collections)
.UsingEntity<Dictionary<string, object>>(
"CollectionGame",
cg => cg.HasOne<Game>().WithMany().HasForeignKey("GameId"),
cg => cg.HasOne<Collection>().WithMany().HasForeignKey("CollectionId")
);
#endregion
#region Role Relationships
builder.Entity<Role>()
.HasMany(r => r.Collections)
.WithMany(c => c.Roles)
.UsingEntity<Dictionary<string, object>>(
"RoleCollection",
rc => rc.HasOne<Collection>().WithMany().HasForeignKey("CollectionId"),
rc => rc.HasOne<Role>().WithMany().HasForeignKey("RoleId")
);
#endregion
} }
public DbSet<Game>? Games { get; set; } public DbSet<Game>? Games { get; set; }

View File

@ -0,0 +1,23 @@
using LANCommander.Data.Models;
using Microsoft.EntityFrameworkCore;
namespace LANCommander.Data
{
public static class ModelBuilderExtensions
{
public static void ConfigureBaseRelationships<T>(this ModelBuilder modelBuilder) where T : BaseModel
{
modelBuilder.Entity<T>()
.HasOne(x => x.CreatedBy)
.WithMany()
.IsRequired(false)
.OnDelete(DeleteBehavior.SetNull);
modelBuilder.Entity<T>()
.HasOne(x => x.UpdatedBy)
.WithMany()
.IsRequired(false)
.OnDelete(DeleteBehavior.SetNull);
}
}
}

View File

@ -10,10 +10,13 @@ namespace LANCommander.Data.Models
[Display(Name = "Created On")] [Display(Name = "Created On")]
public DateTime CreatedOn { get; set; } public DateTime CreatedOn { get; set; }
[Display(Name = "Created By")] [Display(Name = "Created By")]
public virtual User? CreatedBy { get; set; } public virtual User? CreatedBy { get; set; }
[Display(Name = "Updated On")] [Display(Name = "Updated On")]
public DateTime UpdatedOn { get; set; } public DateTime UpdatedOn { get; set; }
[Display(Name = "Updated By")] [Display(Name = "Updated By")]
public virtual User? UpdatedBy { get; set; } public virtual User? UpdatedBy { get; set; }
} }

View File

@ -0,0 +1,15 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
namespace LANCommander.Data.Models
{
[Table("Collections")]
public class Collection : BaseModel
{
public string Name { get; set; }
[JsonIgnore]
public virtual ICollection<Game> Games { get; set; }
[JsonIgnore]
public virtual ICollection<Role> Roles { get; set; }
}
}

View File

@ -39,5 +39,6 @@ namespace LANCommander.Data.Models
public string? ValidKeyRegex { get; set; } public string? ValidKeyRegex { get; set; }
public virtual ICollection<Key>? Keys { get; set; } public virtual ICollection<Key>? Keys { get; set; }
public virtual ICollection<Collection> Collections { get; set; }
} }
} }

View File

@ -7,7 +7,7 @@ namespace LANCommander.Data.Models
[Table("GameSaves")] [Table("GameSaves")]
public class GameSave : BaseModel public class GameSave : BaseModel
{ {
public Guid GameId { get; set; } public Guid? GameId { get; set; }
[JsonIgnore] [JsonIgnore]
[ForeignKey(nameof(GameId))] [ForeignKey(nameof(GameId))]
[InverseProperty("GameSaves")] [InverseProperty("GameSaves")]

View File

@ -7,7 +7,7 @@ namespace LANCommander.Data.Models
[Table("PlaySessions")] [Table("PlaySessions")]
public class PlaySession : BaseModel public class PlaySession : BaseModel
{ {
public Guid GameId { get; set; } public Guid? GameId { get; set; }
[JsonIgnore] [JsonIgnore]
[ForeignKey(nameof(GameId))] [ForeignKey(nameof(GameId))]
[InverseProperty("PlaySessions")] [InverseProperty("PlaySessions")]

View File

@ -6,5 +6,6 @@ namespace LANCommander.Data.Models
[Table("Roles")] [Table("Roles")]
public class Role : IdentityRole<Guid> public class Role : IdentityRole<Guid>
{ {
public virtual ICollection<Collection> Collections { get; set; }
} }
} }

View File

@ -10,6 +10,7 @@ namespace LANCommander.Data.Models
{ {
public SavePathType Type { get; set; } public SavePathType Type { get; set; }
public string Path { get; set; } public string Path { get; set; }
public bool IsRegex { get; set; }
public Guid? GameId { get; set; } public Guid? GameId { get; set; }
[JsonIgnore] [JsonIgnore]

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-LANCommander-C1F79CFA-9767-4AD7-BD5A-2549F8328A2D</UserSecretsId> <UserSecretsId>aspnet-LANCommander-C1F79CFA-9767-4AD7-BD5A-2549F8328A2D</UserSecretsId>
@ -34,14 +34,14 @@
<PackageReference Include="Hangfire.InMemory" Version="0.6.0" /> <PackageReference Include="Hangfire.InMemory" Version="0.6.0" />
<PackageReference Include="IGDB" Version="2.3.2" /> <PackageReference Include="IGDB" Version="2.3.2" />
<PackageReference Include="IPXRelayDotNet" Version="1.0.0" /> <PackageReference Include="IPXRelayDotNet" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.13" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="7.0.13" /> <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.13" /> <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="7.0.13" /> <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="7.0.13" /> <PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="7.0.13" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.13" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.13"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
@ -50,14 +50,14 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" /> <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.11" /> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.0" />
<PackageReference Include="NLog" Version="5.2.5" /> <PackageReference Include="NLog" Version="5.2.5" />
<PackageReference Include="NLog.Web.AspNetCore" Version="5.3.5" /> <PackageReference Include="NLog.Web.AspNetCore" Version="5.3.5" />
<PackageReference Include="RegParserDotNet" Version="1.0.4" /> <PackageReference Include="RegParserDotNet" Version="1.0.4" />
<PackageReference Include="rix0rrr.BeaconLib" Version="1.0.2" /> <PackageReference Include="rix0rrr.BeaconLib" Version="1.0.2" />
<PackageReference Include="swashbuckle" Version="5.6.0" /> <PackageReference Include="swashbuckle" Version="5.6.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="7.0.0" /> <PackageReference Include="System.Diagnostics.PerformanceCounter" Version="8.0.0" />
<PackageReference Include="XtermBlazor" Version="1.10.0" /> <PackageReference Include="XtermBlazor" Version="1.10.0" />
<PackageReference Include="YamlDotNet" Version="13.3.1" /> <PackageReference Include="YamlDotNet" Version="13.3.1" />
</ItemGroup> </ItemGroup>
@ -66,7 +66,6 @@
<Folder Include="bin\Debug\net6.0\" /> <Folder Include="bin\Debug\net6.0\" />
<Folder Include="Data\Migrations\" /> <Folder Include="Data\Migrations\" />
<Folder Include="Migrations\" /> <Folder Include="Migrations\" />
<Folder Include="Pages\Games\Archives\" />
<Folder Include="Scripts\" /> <Folder Include="Scripts\" />
</ItemGroup> </ItemGroup>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,975 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace LANCommander.Migrations
{
/// <inheritdoc />
public partial class FixDeletionBehaviors : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Actions_AspNetUsers_CreatedById",
table: "Actions");
migrationBuilder.DropForeignKey(
name: "FK_Actions_AspNetUsers_UpdatedById",
table: "Actions");
migrationBuilder.DropForeignKey(
name: "FK_Archive_AspNetUsers_CreatedById",
table: "Archive");
migrationBuilder.DropForeignKey(
name: "FK_Archive_AspNetUsers_UpdatedById",
table: "Archive");
migrationBuilder.DropForeignKey(
name: "FK_Categories_AspNetUsers_CreatedById",
table: "Categories");
migrationBuilder.DropForeignKey(
name: "FK_Categories_AspNetUsers_UpdatedById",
table: "Categories");
migrationBuilder.DropForeignKey(
name: "FK_Companies_AspNetUsers_CreatedById",
table: "Companies");
migrationBuilder.DropForeignKey(
name: "FK_Companies_AspNetUsers_UpdatedById",
table: "Companies");
migrationBuilder.DropForeignKey(
name: "FK_Games_AspNetUsers_CreatedById",
table: "Games");
migrationBuilder.DropForeignKey(
name: "FK_Games_AspNetUsers_UpdatedById",
table: "Games");
migrationBuilder.DropForeignKey(
name: "FK_GameSaves_AspNetUsers_CreatedById",
table: "GameSaves");
migrationBuilder.DropForeignKey(
name: "FK_GameSaves_AspNetUsers_UpdatedById",
table: "GameSaves");
migrationBuilder.DropForeignKey(
name: "FK_GameSaves_Games_GameId",
table: "GameSaves");
migrationBuilder.DropForeignKey(
name: "FK_Genres_AspNetUsers_CreatedById",
table: "Genres");
migrationBuilder.DropForeignKey(
name: "FK_Genres_AspNetUsers_UpdatedById",
table: "Genres");
migrationBuilder.DropForeignKey(
name: "FK_Keys_AspNetUsers_CreatedById",
table: "Keys");
migrationBuilder.DropForeignKey(
name: "FK_Keys_AspNetUsers_UpdatedById",
table: "Keys");
migrationBuilder.DropForeignKey(
name: "FK_Media_AspNetUsers_CreatedById",
table: "Media");
migrationBuilder.DropForeignKey(
name: "FK_Media_AspNetUsers_UpdatedById",
table: "Media");
migrationBuilder.DropForeignKey(
name: "FK_MultiplayerModes_AspNetUsers_CreatedById",
table: "MultiplayerModes");
migrationBuilder.DropForeignKey(
name: "FK_MultiplayerModes_AspNetUsers_UpdatedById",
table: "MultiplayerModes");
migrationBuilder.DropForeignKey(
name: "FK_PlaySessions_AspNetUsers_CreatedById",
table: "PlaySessions");
migrationBuilder.DropForeignKey(
name: "FK_PlaySessions_AspNetUsers_UpdatedById",
table: "PlaySessions");
migrationBuilder.DropForeignKey(
name: "FK_PlaySessions_Games_GameId",
table: "PlaySessions");
migrationBuilder.DropForeignKey(
name: "FK_Redistributables_AspNetUsers_CreatedById",
table: "Redistributables");
migrationBuilder.DropForeignKey(
name: "FK_Redistributables_AspNetUsers_UpdatedById",
table: "Redistributables");
migrationBuilder.DropForeignKey(
name: "FK_SavePaths_AspNetUsers_CreatedById",
table: "SavePaths");
migrationBuilder.DropForeignKey(
name: "FK_SavePaths_AspNetUsers_UpdatedById",
table: "SavePaths");
migrationBuilder.DropForeignKey(
name: "FK_SavePaths_Games_GameId",
table: "SavePaths");
migrationBuilder.DropForeignKey(
name: "FK_Scripts_AspNetUsers_CreatedById",
table: "Scripts");
migrationBuilder.DropForeignKey(
name: "FK_Scripts_AspNetUsers_UpdatedById",
table: "Scripts");
migrationBuilder.DropForeignKey(
name: "FK_ServerConsoles_AspNetUsers_CreatedById",
table: "ServerConsoles");
migrationBuilder.DropForeignKey(
name: "FK_ServerConsoles_AspNetUsers_UpdatedById",
table: "ServerConsoles");
migrationBuilder.DropForeignKey(
name: "FK_ServerHttpPath_AspNetUsers_CreatedById",
table: "ServerHttpPath");
migrationBuilder.DropForeignKey(
name: "FK_ServerHttpPath_AspNetUsers_UpdatedById",
table: "ServerHttpPath");
migrationBuilder.DropForeignKey(
name: "FK_Servers_AspNetUsers_CreatedById",
table: "Servers");
migrationBuilder.DropForeignKey(
name: "FK_Servers_AspNetUsers_UpdatedById",
table: "Servers");
migrationBuilder.DropForeignKey(
name: "FK_Servers_Games_GameId",
table: "Servers");
migrationBuilder.DropForeignKey(
name: "FK_Tags_AspNetUsers_CreatedById",
table: "Tags");
migrationBuilder.DropForeignKey(
name: "FK_Tags_AspNetUsers_UpdatedById",
table: "Tags");
migrationBuilder.AlterColumn<Guid>(
name: "GameId",
table: "PlaySessions",
type: "TEXT",
nullable: true,
oldClrType: typeof(Guid),
oldType: "TEXT");
migrationBuilder.AlterColumn<Guid>(
name: "GameId",
table: "GameSaves",
type: "TEXT",
nullable: true,
oldClrType: typeof(Guid),
oldType: "TEXT");
migrationBuilder.AddForeignKey(
name: "FK_Actions_AspNetUsers_CreatedById",
table: "Actions",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Actions_AspNetUsers_UpdatedById",
table: "Actions",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Archive_AspNetUsers_CreatedById",
table: "Archive",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Archive_AspNetUsers_UpdatedById",
table: "Archive",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Categories_AspNetUsers_CreatedById",
table: "Categories",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Categories_AspNetUsers_UpdatedById",
table: "Categories",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Companies_AspNetUsers_CreatedById",
table: "Companies",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Companies_AspNetUsers_UpdatedById",
table: "Companies",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Games_AspNetUsers_CreatedById",
table: "Games",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Games_AspNetUsers_UpdatedById",
table: "Games",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_GameSaves_AspNetUsers_CreatedById",
table: "GameSaves",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_GameSaves_AspNetUsers_UpdatedById",
table: "GameSaves",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_GameSaves_Games_GameId",
table: "GameSaves",
column: "GameId",
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Genres_AspNetUsers_CreatedById",
table: "Genres",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Genres_AspNetUsers_UpdatedById",
table: "Genres",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Keys_AspNetUsers_CreatedById",
table: "Keys",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Keys_AspNetUsers_UpdatedById",
table: "Keys",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Media_AspNetUsers_CreatedById",
table: "Media",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Media_AspNetUsers_UpdatedById",
table: "Media",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_MultiplayerModes_AspNetUsers_CreatedById",
table: "MultiplayerModes",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_MultiplayerModes_AspNetUsers_UpdatedById",
table: "MultiplayerModes",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_PlaySessions_AspNetUsers_CreatedById",
table: "PlaySessions",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_PlaySessions_AspNetUsers_UpdatedById",
table: "PlaySessions",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_PlaySessions_Games_GameId",
table: "PlaySessions",
column: "GameId",
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Redistributables_AspNetUsers_CreatedById",
table: "Redistributables",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Redistributables_AspNetUsers_UpdatedById",
table: "Redistributables",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_SavePaths_AspNetUsers_CreatedById",
table: "SavePaths",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_SavePaths_AspNetUsers_UpdatedById",
table: "SavePaths",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_SavePaths_Games_GameId",
table: "SavePaths",
column: "GameId",
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Scripts_AspNetUsers_CreatedById",
table: "Scripts",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Scripts_AspNetUsers_UpdatedById",
table: "Scripts",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_ServerConsoles_AspNetUsers_CreatedById",
table: "ServerConsoles",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_ServerConsoles_AspNetUsers_UpdatedById",
table: "ServerConsoles",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_ServerHttpPath_AspNetUsers_CreatedById",
table: "ServerHttpPath",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_ServerHttpPath_AspNetUsers_UpdatedById",
table: "ServerHttpPath",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Servers_AspNetUsers_CreatedById",
table: "Servers",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Servers_AspNetUsers_UpdatedById",
table: "Servers",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Servers_Games_GameId",
table: "Servers",
column: "GameId",
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Tags_AspNetUsers_CreatedById",
table: "Tags",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Tags_AspNetUsers_UpdatedById",
table: "Tags",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Actions_AspNetUsers_CreatedById",
table: "Actions");
migrationBuilder.DropForeignKey(
name: "FK_Actions_AspNetUsers_UpdatedById",
table: "Actions");
migrationBuilder.DropForeignKey(
name: "FK_Archive_AspNetUsers_CreatedById",
table: "Archive");
migrationBuilder.DropForeignKey(
name: "FK_Archive_AspNetUsers_UpdatedById",
table: "Archive");
migrationBuilder.DropForeignKey(
name: "FK_Categories_AspNetUsers_CreatedById",
table: "Categories");
migrationBuilder.DropForeignKey(
name: "FK_Categories_AspNetUsers_UpdatedById",
table: "Categories");
migrationBuilder.DropForeignKey(
name: "FK_Companies_AspNetUsers_CreatedById",
table: "Companies");
migrationBuilder.DropForeignKey(
name: "FK_Companies_AspNetUsers_UpdatedById",
table: "Companies");
migrationBuilder.DropForeignKey(
name: "FK_Games_AspNetUsers_CreatedById",
table: "Games");
migrationBuilder.DropForeignKey(
name: "FK_Games_AspNetUsers_UpdatedById",
table: "Games");
migrationBuilder.DropForeignKey(
name: "FK_GameSaves_AspNetUsers_CreatedById",
table: "GameSaves");
migrationBuilder.DropForeignKey(
name: "FK_GameSaves_AspNetUsers_UpdatedById",
table: "GameSaves");
migrationBuilder.DropForeignKey(
name: "FK_GameSaves_Games_GameId",
table: "GameSaves");
migrationBuilder.DropForeignKey(
name: "FK_Genres_AspNetUsers_CreatedById",
table: "Genres");
migrationBuilder.DropForeignKey(
name: "FK_Genres_AspNetUsers_UpdatedById",
table: "Genres");
migrationBuilder.DropForeignKey(
name: "FK_Keys_AspNetUsers_CreatedById",
table: "Keys");
migrationBuilder.DropForeignKey(
name: "FK_Keys_AspNetUsers_UpdatedById",
table: "Keys");
migrationBuilder.DropForeignKey(
name: "FK_Media_AspNetUsers_CreatedById",
table: "Media");
migrationBuilder.DropForeignKey(
name: "FK_Media_AspNetUsers_UpdatedById",
table: "Media");
migrationBuilder.DropForeignKey(
name: "FK_MultiplayerModes_AspNetUsers_CreatedById",
table: "MultiplayerModes");
migrationBuilder.DropForeignKey(
name: "FK_MultiplayerModes_AspNetUsers_UpdatedById",
table: "MultiplayerModes");
migrationBuilder.DropForeignKey(
name: "FK_PlaySessions_AspNetUsers_CreatedById",
table: "PlaySessions");
migrationBuilder.DropForeignKey(
name: "FK_PlaySessions_AspNetUsers_UpdatedById",
table: "PlaySessions");
migrationBuilder.DropForeignKey(
name: "FK_PlaySessions_Games_GameId",
table: "PlaySessions");
migrationBuilder.DropForeignKey(
name: "FK_Redistributables_AspNetUsers_CreatedById",
table: "Redistributables");
migrationBuilder.DropForeignKey(
name: "FK_Redistributables_AspNetUsers_UpdatedById",
table: "Redistributables");
migrationBuilder.DropForeignKey(
name: "FK_SavePaths_AspNetUsers_CreatedById",
table: "SavePaths");
migrationBuilder.DropForeignKey(
name: "FK_SavePaths_AspNetUsers_UpdatedById",
table: "SavePaths");
migrationBuilder.DropForeignKey(
name: "FK_SavePaths_Games_GameId",
table: "SavePaths");
migrationBuilder.DropForeignKey(
name: "FK_Scripts_AspNetUsers_CreatedById",
table: "Scripts");
migrationBuilder.DropForeignKey(
name: "FK_Scripts_AspNetUsers_UpdatedById",
table: "Scripts");
migrationBuilder.DropForeignKey(
name: "FK_ServerConsoles_AspNetUsers_CreatedById",
table: "ServerConsoles");
migrationBuilder.DropForeignKey(
name: "FK_ServerConsoles_AspNetUsers_UpdatedById",
table: "ServerConsoles");
migrationBuilder.DropForeignKey(
name: "FK_ServerHttpPath_AspNetUsers_CreatedById",
table: "ServerHttpPath");
migrationBuilder.DropForeignKey(
name: "FK_ServerHttpPath_AspNetUsers_UpdatedById",
table: "ServerHttpPath");
migrationBuilder.DropForeignKey(
name: "FK_Servers_AspNetUsers_CreatedById",
table: "Servers");
migrationBuilder.DropForeignKey(
name: "FK_Servers_AspNetUsers_UpdatedById",
table: "Servers");
migrationBuilder.DropForeignKey(
name: "FK_Servers_Games_GameId",
table: "Servers");
migrationBuilder.DropForeignKey(
name: "FK_Tags_AspNetUsers_CreatedById",
table: "Tags");
migrationBuilder.DropForeignKey(
name: "FK_Tags_AspNetUsers_UpdatedById",
table: "Tags");
migrationBuilder.AlterColumn<Guid>(
name: "GameId",
table: "PlaySessions",
type: "TEXT",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
oldClrType: typeof(Guid),
oldType: "TEXT",
oldNullable: true);
migrationBuilder.AlterColumn<Guid>(
name: "GameId",
table: "GameSaves",
type: "TEXT",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
oldClrType: typeof(Guid),
oldType: "TEXT",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Actions_AspNetUsers_CreatedById",
table: "Actions",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Actions_AspNetUsers_UpdatedById",
table: "Actions",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Archive_AspNetUsers_CreatedById",
table: "Archive",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Archive_AspNetUsers_UpdatedById",
table: "Archive",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Categories_AspNetUsers_CreatedById",
table: "Categories",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Categories_AspNetUsers_UpdatedById",
table: "Categories",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Companies_AspNetUsers_CreatedById",
table: "Companies",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Companies_AspNetUsers_UpdatedById",
table: "Companies",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Games_AspNetUsers_CreatedById",
table: "Games",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Games_AspNetUsers_UpdatedById",
table: "Games",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_GameSaves_AspNetUsers_CreatedById",
table: "GameSaves",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_GameSaves_AspNetUsers_UpdatedById",
table: "GameSaves",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_GameSaves_Games_GameId",
table: "GameSaves",
column: "GameId",
principalTable: "Games",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Genres_AspNetUsers_CreatedById",
table: "Genres",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Genres_AspNetUsers_UpdatedById",
table: "Genres",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Keys_AspNetUsers_CreatedById",
table: "Keys",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Keys_AspNetUsers_UpdatedById",
table: "Keys",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Media_AspNetUsers_CreatedById",
table: "Media",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Media_AspNetUsers_UpdatedById",
table: "Media",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_MultiplayerModes_AspNetUsers_CreatedById",
table: "MultiplayerModes",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_MultiplayerModes_AspNetUsers_UpdatedById",
table: "MultiplayerModes",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_PlaySessions_AspNetUsers_CreatedById",
table: "PlaySessions",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_PlaySessions_AspNetUsers_UpdatedById",
table: "PlaySessions",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_PlaySessions_Games_GameId",
table: "PlaySessions",
column: "GameId",
principalTable: "Games",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Redistributables_AspNetUsers_CreatedById",
table: "Redistributables",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Redistributables_AspNetUsers_UpdatedById",
table: "Redistributables",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_SavePaths_AspNetUsers_CreatedById",
table: "SavePaths",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_SavePaths_AspNetUsers_UpdatedById",
table: "SavePaths",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_SavePaths_Games_GameId",
table: "SavePaths",
column: "GameId",
principalTable: "Games",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Scripts_AspNetUsers_CreatedById",
table: "Scripts",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Scripts_AspNetUsers_UpdatedById",
table: "Scripts",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_ServerConsoles_AspNetUsers_CreatedById",
table: "ServerConsoles",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_ServerConsoles_AspNetUsers_UpdatedById",
table: "ServerConsoles",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_ServerHttpPath_AspNetUsers_CreatedById",
table: "ServerHttpPath",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_ServerHttpPath_AspNetUsers_UpdatedById",
table: "ServerHttpPath",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Servers_AspNetUsers_CreatedById",
table: "Servers",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Servers_AspNetUsers_UpdatedById",
table: "Servers",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Servers_Games_GameId",
table: "Servers",
column: "GameId",
principalTable: "Games",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Tags_AspNetUsers_CreatedById",
table: "Tags",
column: "CreatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Tags_AspNetUsers_UpdatedById",
table: "Tags",
column: "UpdatedById",
principalTable: "AspNetUsers",
principalColumn: "Id");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace LANCommander.Migrations
{
/// <inheritdoc />
public partial class AddSavePathRegexFlag : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsRegex",
table: "SavePaths",
type: "INTEGER",
nullable: false,
defaultValue: false);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsRegex",
table: "SavePaths");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace LANCommander.Migrations
{
/// <inheritdoc />
public partial class FixScriptDisplayBounds : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("UPDATE Scripts SET Contents = REPLACE(Contents, '$Display.Width', '$Display.Bounds.Width')");
migrationBuilder.Sql("UPDATE Scripts SET Contents = REPLACE(Contents, '$Display.Height', '$Display.Bounds.Height')");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,124 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace LANCommander.Migrations
{
/// <inheritdoc />
public partial class AddCollections : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Collections",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
Name = table.Column<string>(type: "TEXT", nullable: false),
CreatedOn = table.Column<DateTime>(type: "TEXT", nullable: false),
CreatedById = table.Column<Guid>(type: "TEXT", nullable: true),
UpdatedOn = table.Column<DateTime>(type: "TEXT", nullable: false),
UpdatedById = table.Column<Guid>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Collections", x => x.Id);
table.ForeignKey(
name: "FK_Collections_AspNetUsers_CreatedById",
column: x => x.CreatedById,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Collections_AspNetUsers_UpdatedById",
column: x => x.UpdatedById,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "CollectionGame",
columns: table => new
{
CollectionId = table.Column<Guid>(type: "TEXT", nullable: false),
GameId = table.Column<Guid>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CollectionGame", x => new { x.CollectionId, x.GameId });
table.ForeignKey(
name: "FK_CollectionGame_Collections_CollectionId",
column: x => x.CollectionId,
principalTable: "Collections",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_CollectionGame_Games_GameId",
column: x => x.GameId,
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "RoleCollection",
columns: table => new
{
CollectionId = table.Column<Guid>(type: "TEXT", nullable: false),
RoleId = table.Column<Guid>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RoleCollection", x => new { x.CollectionId, x.RoleId });
table.ForeignKey(
name: "FK_RoleCollection_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RoleCollection_Collections_CollectionId",
column: x => x.CollectionId,
principalTable: "Collections",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_CollectionGame_GameId",
table: "CollectionGame",
column: "GameId");
migrationBuilder.CreateIndex(
name: "IX_Collections_CreatedById",
table: "Collections",
column: "CreatedById");
migrationBuilder.CreateIndex(
name: "IX_Collections_UpdatedById",
table: "Collections",
column: "UpdatedById");
migrationBuilder.CreateIndex(
name: "IX_RoleCollection_RoleId",
table: "RoleCollection",
column: "RoleId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CollectionGame");
migrationBuilder.DropTable(
name: "RoleCollection");
migrationBuilder.DropTable(
name: "Collections");
}
}
}

View File

@ -16,7 +16,7 @@ namespace LANCommander.Migrations
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "7.0.13") .HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("Proxies:ChangeTracking", false) .HasAnnotation("Proxies:ChangeTracking", false)
.HasAnnotation("Proxies:CheckEquality", false) .HasAnnotation("Proxies:CheckEquality", false)
.HasAnnotation("Proxies:LazyLoading", true); .HasAnnotation("Proxies:LazyLoading", true);
@ -36,6 +36,21 @@ namespace LANCommander.Migrations
b.ToTable("CategoryGame"); b.ToTable("CategoryGame");
}); });
modelBuilder.Entity("CollectionGame", b =>
{
b.Property<Guid>("CollectionId")
.HasColumnType("TEXT");
b.Property<Guid>("GameId")
.HasColumnType("TEXT");
b.HasKey("CollectionId", "GameId");
b.HasIndex("GameId");
b.ToTable("CollectionGame");
});
modelBuilder.Entity("GameDeveloper", b => modelBuilder.Entity("GameDeveloper", b =>
{ {
b.Property<Guid>("DeveloperId") b.Property<Guid>("DeveloperId")
@ -257,6 +272,37 @@ namespace LANCommander.Migrations
b.ToTable("Categories"); b.ToTable("Categories");
}); });
modelBuilder.Entity("LANCommander.Data.Models.Collection", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<Guid?>("CreatedById")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedOn")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<Guid?>("UpdatedById")
.HasColumnType("TEXT");
b.Property<DateTime>("UpdatedOn")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("CreatedById");
b.HasIndex("UpdatedById");
b.ToTable("Collections");
});
modelBuilder.Entity("LANCommander.Data.Models.Company", b => modelBuilder.Entity("LANCommander.Data.Models.Company", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
@ -355,7 +401,7 @@ namespace LANCommander.Migrations
b.Property<DateTime>("CreatedOn") b.Property<DateTime>("CreatedOn")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<Guid>("GameId") b.Property<Guid?>("GameId")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<Guid?>("UpdatedById") b.Property<Guid?>("UpdatedById")
@ -585,7 +631,7 @@ namespace LANCommander.Migrations
b.Property<DateTime?>("End") b.Property<DateTime?>("End")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<Guid>("GameId") b.Property<Guid?>("GameId")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<DateTime?>("Start") b.Property<DateTime?>("Start")
@ -692,6 +738,9 @@ namespace LANCommander.Migrations
b.Property<Guid?>("GameId") b.Property<Guid?>("GameId")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<bool>("IsRegex")
.HasColumnType("INTEGER");
b.Property<string>("Path") b.Property<string>("Path")
.IsRequired() .IsRequired()
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@ -1154,6 +1203,21 @@ namespace LANCommander.Migrations
b.ToTable("AspNetUserTokens", (string)null); b.ToTable("AspNetUserTokens", (string)null);
}); });
modelBuilder.Entity("RoleCollection", b =>
{
b.Property<Guid>("CollectionId")
.HasColumnType("TEXT");
b.Property<Guid>("RoleId")
.HasColumnType("TEXT");
b.HasKey("CollectionId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("RoleCollection");
});
modelBuilder.Entity("CategoryGame", b => modelBuilder.Entity("CategoryGame", b =>
{ {
b.HasOne("LANCommander.Data.Models.Category", null) b.HasOne("LANCommander.Data.Models.Category", null)
@ -1169,6 +1233,21 @@ namespace LANCommander.Migrations
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("CollectionGame", b =>
{
b.HasOne("LANCommander.Data.Models.Collection", null)
.WithMany()
.HasForeignKey("CollectionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("LANCommander.Data.Models.Game", null)
.WithMany()
.HasForeignKey("GameId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("GameDeveloper", b => modelBuilder.Entity("GameDeveloper", b =>
{ {
b.HasOne("LANCommander.Data.Models.Company", null) b.HasOne("LANCommander.Data.Models.Company", null)
@ -1248,7 +1327,8 @@ namespace LANCommander.Migrations
{ {
b.HasOne("LANCommander.Data.Models.User", "CreatedBy") b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById"); .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Data.Models.Game", "Game") b.HasOne("LANCommander.Data.Models.Game", "Game")
.WithMany("Actions") .WithMany("Actions")
@ -1258,7 +1338,8 @@ namespace LANCommander.Migrations
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
.WithMany() .WithMany()
.HasForeignKey("UpdatedById"); .HasForeignKey("UpdatedById")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
@ -1271,7 +1352,8 @@ namespace LANCommander.Migrations
{ {
b.HasOne("LANCommander.Data.Models.User", "CreatedBy") b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById"); .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Data.Models.Game", "Game") b.HasOne("LANCommander.Data.Models.Game", "Game")
.WithMany("Archives") .WithMany("Archives")
@ -1289,7 +1371,8 @@ namespace LANCommander.Migrations
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
.WithMany() .WithMany()
.HasForeignKey("UpdatedById"); .HasForeignKey("UpdatedById")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
@ -1306,7 +1389,8 @@ namespace LANCommander.Migrations
{ {
b.HasOne("LANCommander.Data.Models.User", "CreatedBy") b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById"); .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Data.Models.Category", "Parent") b.HasOne("LANCommander.Data.Models.Category", "Parent")
.WithMany("Children") .WithMany("Children")
@ -1314,7 +1398,8 @@ namespace LANCommander.Migrations
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
.WithMany() .WithMany()
.HasForeignKey("UpdatedById"); .HasForeignKey("UpdatedById")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
@ -1323,15 +1408,34 @@ namespace LANCommander.Migrations
b.Navigation("UpdatedBy"); b.Navigation("UpdatedBy");
}); });
modelBuilder.Entity("LANCommander.Data.Models.Collection", b =>
{
b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
.WithMany()
.HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
.WithMany()
.HasForeignKey("UpdatedById")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("CreatedBy");
b.Navigation("UpdatedBy");
});
modelBuilder.Entity("LANCommander.Data.Models.Company", b => modelBuilder.Entity("LANCommander.Data.Models.Company", b =>
{ {
b.HasOne("LANCommander.Data.Models.User", "CreatedBy") b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById"); .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
.WithMany() .WithMany()
.HasForeignKey("UpdatedById"); .HasForeignKey("UpdatedById")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
@ -1342,11 +1446,13 @@ namespace LANCommander.Migrations
{ {
b.HasOne("LANCommander.Data.Models.User", "CreatedBy") b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById"); .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
.WithMany() .WithMany()
.HasForeignKey("UpdatedById"); .HasForeignKey("UpdatedById")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
@ -1357,17 +1463,18 @@ namespace LANCommander.Migrations
{ {
b.HasOne("LANCommander.Data.Models.User", "CreatedBy") b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById"); .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Data.Models.Game", "Game") b.HasOne("LANCommander.Data.Models.Game", "Game")
.WithMany("GameSaves") .WithMany("GameSaves")
.HasForeignKey("GameId") .HasForeignKey("GameId")
.OnDelete(DeleteBehavior.NoAction) .OnDelete(DeleteBehavior.SetNull);
.IsRequired();
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
.WithMany() .WithMany()
.HasForeignKey("UpdatedById"); .HasForeignKey("UpdatedById")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Data.Models.User", "User") b.HasOne("LANCommander.Data.Models.User", "User")
.WithMany("GameSaves") .WithMany("GameSaves")
@ -1388,11 +1495,13 @@ namespace LANCommander.Migrations
{ {
b.HasOne("LANCommander.Data.Models.User", "CreatedBy") b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById"); .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
.WithMany() .WithMany()
.HasForeignKey("UpdatedById"); .HasForeignKey("UpdatedById")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
@ -1407,7 +1516,8 @@ namespace LANCommander.Migrations
b.HasOne("LANCommander.Data.Models.User", "CreatedBy") b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById"); .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Data.Models.Game", "Game") b.HasOne("LANCommander.Data.Models.Game", "Game")
.WithMany("Keys") .WithMany("Keys")
@ -1417,7 +1527,8 @@ namespace LANCommander.Migrations
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
.WithMany() .WithMany()
.HasForeignKey("UpdatedById"); .HasForeignKey("UpdatedById")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("ClaimedByUser"); b.Navigation("ClaimedByUser");
@ -1432,7 +1543,8 @@ namespace LANCommander.Migrations
{ {
b.HasOne("LANCommander.Data.Models.User", "CreatedBy") b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById"); .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Data.Models.Game", "Game") b.HasOne("LANCommander.Data.Models.Game", "Game")
.WithMany("Media") .WithMany("Media")
@ -1442,7 +1554,8 @@ namespace LANCommander.Migrations
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
.WithMany() .WithMany()
.HasForeignKey("UpdatedById"); .HasForeignKey("UpdatedById")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
@ -1455,7 +1568,8 @@ namespace LANCommander.Migrations
{ {
b.HasOne("LANCommander.Data.Models.User", "CreatedBy") b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById"); .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Data.Models.Game", "Game") b.HasOne("LANCommander.Data.Models.Game", "Game")
.WithMany("MultiplayerModes") .WithMany("MultiplayerModes")
@ -1465,7 +1579,8 @@ namespace LANCommander.Migrations
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
.WithMany() .WithMany()
.HasForeignKey("UpdatedById"); .HasForeignKey("UpdatedById")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
@ -1478,17 +1593,18 @@ namespace LANCommander.Migrations
{ {
b.HasOne("LANCommander.Data.Models.User", "CreatedBy") b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById"); .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Data.Models.Game", "Game") b.HasOne("LANCommander.Data.Models.Game", "Game")
.WithMany("PlaySessions") .WithMany("PlaySessions")
.HasForeignKey("GameId") .HasForeignKey("GameId")
.OnDelete(DeleteBehavior.NoAction) .OnDelete(DeleteBehavior.SetNull);
.IsRequired();
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
.WithMany() .WithMany()
.HasForeignKey("UpdatedById"); .HasForeignKey("UpdatedById")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Data.Models.User", "User") b.HasOne("LANCommander.Data.Models.User", "User")
.WithMany("PlaySessions") .WithMany("PlaySessions")
@ -1509,11 +1625,13 @@ namespace LANCommander.Migrations
{ {
b.HasOne("LANCommander.Data.Models.User", "CreatedBy") b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById"); .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
.WithMany() .WithMany()
.HasForeignKey("UpdatedById"); .HasForeignKey("UpdatedById")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
@ -1524,15 +1642,18 @@ namespace LANCommander.Migrations
{ {
b.HasOne("LANCommander.Data.Models.User", "CreatedBy") b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById"); .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Data.Models.Game", "Game") b.HasOne("LANCommander.Data.Models.Game", "Game")
.WithMany("SavePaths") .WithMany("SavePaths")
.HasForeignKey("GameId"); .HasForeignKey("GameId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
.WithMany() .WithMany()
.HasForeignKey("UpdatedById"); .HasForeignKey("UpdatedById")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
@ -1545,7 +1666,8 @@ namespace LANCommander.Migrations
{ {
b.HasOne("LANCommander.Data.Models.User", "CreatedBy") b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById"); .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Data.Models.Game", "Game") b.HasOne("LANCommander.Data.Models.Game", "Game")
.WithMany("Scripts") .WithMany("Scripts")
@ -1559,7 +1681,8 @@ namespace LANCommander.Migrations
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
.WithMany() .WithMany()
.HasForeignKey("UpdatedById"); .HasForeignKey("UpdatedById")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
@ -1574,16 +1697,18 @@ namespace LANCommander.Migrations
{ {
b.HasOne("LANCommander.Data.Models.User", "CreatedBy") b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById"); .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Data.Models.Game", "Game") b.HasOne("LANCommander.Data.Models.Game", "Game")
.WithMany("Servers") .WithMany("Servers")
.HasForeignKey("GameId") .HasForeignKey("GameId")
.OnDelete(DeleteBehavior.NoAction); .OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
.WithMany() .WithMany()
.HasForeignKey("UpdatedById"); .HasForeignKey("UpdatedById")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
@ -1596,7 +1721,8 @@ namespace LANCommander.Migrations
{ {
b.HasOne("LANCommander.Data.Models.User", "CreatedBy") b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById"); .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Data.Models.Server", "Server") b.HasOne("LANCommander.Data.Models.Server", "Server")
.WithMany() .WithMany()
@ -1610,7 +1736,8 @@ namespace LANCommander.Migrations
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
.WithMany() .WithMany()
.HasForeignKey("UpdatedById"); .HasForeignKey("UpdatedById")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
@ -1623,7 +1750,8 @@ namespace LANCommander.Migrations
{ {
b.HasOne("LANCommander.Data.Models.User", "CreatedBy") b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById"); .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Data.Models.Server", "Server") b.HasOne("LANCommander.Data.Models.Server", "Server")
.WithMany() .WithMany()
@ -1637,7 +1765,8 @@ namespace LANCommander.Migrations
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
.WithMany() .WithMany()
.HasForeignKey("UpdatedById"); .HasForeignKey("UpdatedById")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
@ -1650,11 +1779,13 @@ namespace LANCommander.Migrations
{ {
b.HasOne("LANCommander.Data.Models.User", "CreatedBy") b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById"); .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
.WithMany() .WithMany()
.HasForeignKey("UpdatedById"); .HasForeignKey("UpdatedById")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
@ -1712,6 +1843,21 @@ namespace LANCommander.Migrations
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("RoleCollection", b =>
{
b.HasOne("LANCommander.Data.Models.Collection", null)
.WithMany()
.HasForeignKey("CollectionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("LANCommander.Data.Models.Role", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("LANCommander.Data.Models.Category", b => modelBuilder.Entity("LANCommander.Data.Models.Category", b =>
{ {
b.Navigation("Children"); b.Navigation("Children");

View File

@ -0,0 +1,7 @@
namespace LANCommander.Models
{
public class AddToCollectionOptions
{
public IEnumerable<Guid> GameIds { get; set; }
}
}

View File

@ -0,0 +1,10 @@
namespace LANCommander.Models
{
public class RoleViewModel
{
public string Name { get; set; }
public int Users { get; set; }
public int Collections { get; set; }
}
}

View File

@ -0,0 +1,13 @@
using LANCommander.Data.Enums;
namespace LANCommander.Models
{
public class ScriptEditorOptions
{
public Guid ScriptId { get; set; }
public Guid GameId { get; set; }
public Guid RedistributableId { get; set; }
public Guid ArchiveId { get; set; }
public IEnumerable<ScriptType> AllowedTypes { get; set; }
}
}

View File

@ -0,0 +1,145 @@
@page "/Collections/{id:guid}"
@page "/Collections/Add"
@using LANCommander.Data.Enums;
@using LANCommander.Extensions
@attribute [Authorize(Roles = "Administrator")]
@inject CollectionService CollectionService
@inject IMessageService MessageService
@inject NavigationManager NavigationManager
<PageHeader>
<PageHeaderTitle>
<Input Size="@InputSize.Large" @bind-Value="@Collection.Name" />
</PageHeaderTitle>
<PageHeaderExtra>
<Button Type="@ButtonType.Primary" OnClick="Save">Save</Button>
</PageHeaderExtra>
</PageHeader>
<Table TItem="Game" DataSource="@Collection.Games" Responsive>
<Column TData="string" Title="Icon">
<Image Src="@GetIcon(context)" Height="32" Width="32" Preview="false"></Image>
</Column>
<PropertyColumn Property="g => g.Title" Sortable Filterable />
<PropertyColumn Property="g => g.ReleasedOn" Format="MM/dd/yyyy" Sortable Filterable />
<PropertyColumn Property="g => g.Singleplayer" Sortable Filterable>
<Checkbox Disabled="true" Checked="context.Singleplayer" />
</PropertyColumn>
<Column TData="bool" Title="Multiplayer">
<Checkbox Disabled="true" Checked="context.MultiplayerModes?.Count > 0" />
</Column>
<Column TData="string[]" Title="Developers">
@foreach (var dev in context.Developers)
{
<Tag>@dev.Name</Tag>
}
</Column>
<Column TData="string[]" Title="Publishers">
@foreach (var pub in context.Publishers)
{
<Tag>@pub.Name</Tag>
}
</Column>
<Column TData="string[]" Title="Genres">
@foreach (var genre in context.Genres)
{
<Tag>@genre.Name</Tag>
}
</Column>
<Column TData="Data.Enums.MultiplayerType[]" Title="Multiplayer Modes">
@foreach (var mode in context.MultiplayerModes.Select(mm => mm.Type).Distinct())
{
<Tag>@mode.GetDisplayName()</Tag>
}
</Column>
<ActionColumn Title="" Style="text-align: right">
<ChildContent>
<Space Direction="DirectionVHType.Horizontal">
<SpaceItem>
<Popconfirm OnConfirm="() => RemoveGame(context)" Title="Are you sure you want to remove this game from the collection?">
<Button Icon="@IconType.Outline.Close" Type="@ButtonType.Text" Danger />
</Popconfirm>
</SpaceItem>
</Space>
</ChildContent>
</ActionColumn>
</Table>
@code {
[Parameter] public Guid Id { get; set; }
Collection Collection;
protected override async Task OnInitializedAsync()
{
if (Id == Guid.Empty)
Collection = new Collection();
else
Collection = await CollectionService.Get(Id);
}
private async Task Save()
{
try
{
if (Collection.Id != Guid.Empty)
{
Collection = await CollectionService.Update(Collection);
await MessageService.Success("Collection updated!");
}
else
{
Collection = await CollectionService.Add(Collection);
NavigationManager.LocationChanged += NotifyCollectionAdded;
NavigationManager.NavigateTo($"/Collections/{Collection.Id}");
}
}
catch (Exception ex)
{
await MessageService.Error("Could not save!");
}
}
private void NotifyCollectionAdded(object? sender, LocationChangedEventArgs e)
{
NavigationManager.LocationChanged -= NotifyCollectionAdded;
MessageService.Success("Collection added!");
}
private async Task RemoveGame(Game game)
{
try
{
Collection.Games.Remove(game);
await CollectionService.Update(Collection);
}
catch (Exception ex)
{
MessageService.Error("Game could not be removed from the collection!");
}
}
private string GetIcon(Game game)
{
var media = game?.Media?.FirstOrDefault(m => m.Type == Data.Enums.MediaType.Icon);
if (media != null)
return $"/api/Media/{media.Id}/Download?fileId={media.FileId}";
else
return "/favicon.ico";
}
}

View File

@ -0,0 +1,110 @@
@page "/Collections"
@using Microsoft.EntityFrameworkCore;
@attribute [Authorize(Roles = "Administrator")]
@inject CollectionService CollectionService
@inject NavigationManager NavigationManager
@inject IMessageService MessageService
<PageHeader Title="Collections">
<PageHeaderExtra>
<Space Direction="DirectionVHType.Horizontal">
<SpaceItem>
<Search Placeholder="Search" @bind-Value="Search" BindOnInput DebounceMilliseconds="150" OnChange="() => LoadData()" />
</SpaceItem>
</Space>
</PageHeaderExtra>
</PageHeader>
<TableColumnPicker @ref="Picker" Key="Collections" @bind-Visible="ColumnPickerVisible" />
<Table TItem="Collection" DataSource="@Collections" Loading="@Loading" PageSize="25" Responsive>
<PropertyColumn Property="r => r.Name" Sortable Hidden="@(Picker.IsColumnHidden("Name"))" />
<PropertyColumn Property="s => s.CreatedOn" Format="MM/dd/yyyy hh:mm tt" Sortable Hidden="@(Picker.IsColumnHidden("Created On"))" />
<PropertyColumn Property="s => s.CreatedBy" Sortable Hidden="@(Picker.IsColumnHidden("Created By"))">
@context.CreatedBy?.UserName
</PropertyColumn>
<PropertyColumn Property="g => g.UpdatedOn" Format="MM/dd/yyyy hh:mm tt" Sortable Hidden="@(Picker.IsColumnHidden("Updated On"))" />
<PropertyColumn Property="g => g.UpdatedBy" Sortable Hidden="@(Picker.IsColumnHidden("Updated By"))">
@context.UpdatedBy?.UserName
</PropertyColumn>
<Column Title="Games" TData="int">
@context.Games.Count
</Column>
<ActionColumn Title="" Style="text-align: right; white-space: nowrap">
<TitleTemplate>
<div style="text-align: right">
<Button Icon="@IconType.Outline.Edit" Type="@ButtonType.Text" OnClick="() => OpenColumnPicker()" />
</div>
</TitleTemplate>
<ChildContent>
<Space Direction="DirectionVHType.Horizontal">
<SpaceItem>
<a href="/Collections/@(context.Id)" class="ant-btn ant-btn-primary">Edit</a>
</SpaceItem>
<SpaceItem>
<Popconfirm OnConfirm="() => Delete(context)" Title="Are you sure you want to delete this Collection?">
<Button Icon="@IconType.Outline.Close" Type="@ButtonType.Text" Danger />
</Popconfirm>
</SpaceItem>
</Space>
</ChildContent>
</ActionColumn>
</Table>
@code {
IEnumerable<Collection> Collections { get; set; } = new List<Collection>();
bool Loading = true;
string Search = "";
TableColumnPicker Picker;
bool ColumnPickerVisible = false;
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
LoadData();
Loading = false;
StateHasChanged();
}
}
private async Task LoadData()
{
var fuzzySearch = Search.ToLower().Trim();
Collections = await CollectionService.Get(r => r.Name.ToLower().Contains(fuzzySearch)).OrderBy(r => r.Name).ToListAsync();
}
private void Add()
{
NavigationManager.NavigateTo("/Collections/Add");
}
private async Task Delete(Collection Collection)
{
Collections = new List<Collection>();
Loading = true;
await CollectionService.Delete(Collection);
Collections = await CollectionService.Get(x => true).OrderBy(r => r.Name).ToListAsync();
Loading = false;
}
private async Task OpenColumnPicker()
{
ColumnPickerVisible = true;
}
private async Task CloseColumnPicker()
{
ColumnPickerVisible = false;
}
}

View File

@ -1,94 +0,0 @@
@using System.Diagnostics;
@using LANCommander.Extensions;
@using AntDesign.Charts;
@using System.Collections.Concurrent;
<Spin Spinning="Loading">
<Area @ref="Chart" Config="Config" />
</Spin>
@code {
[Parameter] public int TimerHistory { get; set; }
[Parameter] public int TimerInterval { get; set; }
IChartComponent? Chart;
System.Timers.Timer Timer;
bool Loading = true;
Dictionary<string, double[]> Data = new Dictionary<string, double[]>();
ConcurrentDictionary<string, PerformanceCounter> PerformanceCounters = new ConcurrentDictionary<string, PerformanceCounter>();
string JsConfig = @"{
meta: {
value: {
alias: 'Speed',
formatter: (v) => humanFileSize(v, true) + '/s'
}
}
}";
AreaConfig Config = new AreaConfig
{
Name = "Network Download Rate",
Padding = "auto",
SeriesField = "series",
YField = "value",
XField = "index",
Animation = false,
XAxis = new ValueCatTimeAxis
{
Visible = false
}
};
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
if (Timer == null)
{
Timer = new System.Timers.Timer();
Timer.Interval = TimerInterval;
Timer.Elapsed += async (s, e) =>
{
await RefreshData();
};
}
await Chart.UpdateChart(Config, null, null, JsConfig);
Timer.Start();
Loading = false;
StateHasChanged();
}
}
private async Task RefreshData()
{
#if WINDOWS
var category = new PerformanceCounterCategory("Network Interface");
foreach (var instance in category.GetInstanceNames())
{
if (!Data.ContainsKey(instance))
Data[instance] = new double[TimerHistory];
if (!PerformanceCounters.ContainsKey(instance))
PerformanceCounters[instance] = new PerformanceCounter("Network Interface", "Bytes Received/sec", instance);
Data[instance] = Data[instance].ShiftArrayAndInsert((double)PerformanceCounters[instance].NextValue(), TimerHistory);
}
try
{
await Chart.ChangeData(Data.SelectMany(x => x.Value.Select((y, i) => new { value = y, index = i, series = x.Key })), true);
}
catch { }
#endif
}
}

View File

@ -1,93 +0,0 @@
@using System.Diagnostics;
@using LANCommander.Extensions;
@using AntDesign.Charts;
@using System.Collections.Concurrent;
<Spin Spinning="Loading">
<Area @ref="Chart" Config="Config" />
</Spin>
@code {
[Parameter] public int TimerHistory { get; set; }
[Parameter] public int TimerInterval { get; set; }
IChartComponent? Chart;
System.Timers.Timer Timer;
bool Loading = true;
Dictionary<string, double[]> Data = new Dictionary<string, double[]>();
ConcurrentDictionary<string, PerformanceCounter> PerformanceCounters = new ConcurrentDictionary<string, PerformanceCounter>();
string JsConfig = @"{
meta: {
value: {
alias: 'Speed',
formatter: (v) => humanFileSize(v, true) + '/s'
}
}
}";
AreaConfig Config = new AreaConfig
{
Name = "Network Upload Rate",
Padding = "auto",
SeriesField = "series",
YField = "value",
XField = "index",
Animation = false,
XAxis = new ValueCatTimeAxis
{
Visible = false
}
};
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
if (Timer == null)
{
Timer = new System.Timers.Timer();
Timer.Interval = TimerInterval;
Timer.Elapsed += async (s, e) =>
{
await RefreshData();
};
}
await Chart.UpdateChart(Config, null, null, JsConfig);
Timer.Start();
Loading = false;
StateHasChanged();
}
}
private async Task RefreshData()
{
#if WINDOWS
var category = new PerformanceCounterCategory("Network Interface");
foreach (var instance in category.GetInstanceNames())
{
if (!Data.ContainsKey(instance))
Data[instance] = new double[TimerHistory];
if (!PerformanceCounters.ContainsKey(instance))
PerformanceCounters[instance] = new PerformanceCounter("Network Interface", "Bytes Sent/sec", instance);
Data[instance] = Data[instance].ShiftArrayAndInsert((double)PerformanceCounters[instance].NextValue(), TimerHistory);
}
try
{
await Chart.ChangeData(Data.SelectMany(x => x.Value.Select((y, i) => new { value = y, index = i, series = x.Key })), true);
}
catch { }
#endif
}
}

View File

@ -0,0 +1,65 @@
@using AntDesign.Charts
@using ByteSizeLib
@inject PlaySessionService PlaySessionService
<Spin Spinning="Loading">
<Pie Data="Data" Config="Config" JsConfig="@JsConfig" />
</Spin>
@code {
object[] Data;
bool Loading = true;
string JsConfig = @"{
meta: {
value: {
alias: 'Overall Playtime',
formatter: (v) => new Date(v * 1000).toISOString().slice(11, 19)
}
},
label: {
visible: true,
type: 'outer-center'
}
}";
PieConfig Config = new PieConfig
{
Radius = 0.8,
AngleField = "value",
ColorField = "type",
};
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
Dictionary<string, TimeSpan> playtimes = new Dictionary<string, TimeSpan>();
var sessions = await PlaySessionService.Get();
foreach (var gameSessions in sessions.Where(s => s.GameId.HasValue && s.GameId.Value != Guid.Empty).GroupBy(s => s.GameId))
{
var total = new TimeSpan();
foreach (var session in gameSessions.Where(gs => gs.Start != null && gs.End != null))
{
total = total.Add(session.End.Value.Subtract(session.Start.Value));
}
playtimes[gameSessions.First().Game.Title] = total;
}
Data = playtimes.Select(pt => new
{
type = pt.Key,
value = (int)pt.Value.TotalSeconds
}).ToArray();
Loading = false;
StateHasChanged();
}
}
}

View File

@ -1,85 +0,0 @@
@using System.Diagnostics;
@using LANCommander.Extensions;
@using AntDesign.Charts;
<Spin Spinning="Loading">
<Area @ref="Chart" Config="Config" />
</Spin>
@code {
[Parameter] public int TimerHistory { get; set; }
[Parameter] public int TimerInterval { get; set; }
IChartComponent? Chart;
System.Timers.Timer Timer;
bool Loading = true;
double[] Data;
PerformanceCounter PerformanceCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
string JsConfig = @"{
meta: {
value: {
alias: '% Usage',
formatter: (v) => v + '%'
}
}
}";
AreaConfig Config = new AreaConfig
{
Name = "Processor Utilization",
Padding = "auto",
YField = "value",
XField = "index",
Animation = false,
IsPercent = true,
YAxis = new ValueAxis
{
Min = 0,
Max = 100
},
XAxis = new ValueCatTimeAxis
{
Visible = false
}
};
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
if (Timer == null)
{
Timer = new System.Timers.Timer();
Timer.Interval = TimerInterval;
Timer.Elapsed += async (s, e) =>
{
await RefreshData();
};
}
await Chart.UpdateChart(Config, null, null, JsConfig);
Timer.Start();
Loading = false;
StateHasChanged();
}
}
private async Task RefreshData()
{
#if WINDOWS
Data = Data.ShiftArrayAndInsert((double)Math.Ceiling(PerformanceCounter.NextValue()), TimerHistory);
try
{
await Chart.ChangeData(Data.Select((x, i) => new { value = x, index = i }), true);
}
catch { }
#endif
}
}

View File

@ -7,25 +7,9 @@
<GridRow Gutter="(16, 16)"> <GridRow Gutter="(16, 16)">
<GridCol Xs="24" Md="12"> <GridCol Xs="24" Md="12">
<Card Title="Network Download Rate"> <Card Title="Overall Playtime">
<Body> <Body>
<NetworkDownloadRate TimerHistory="60" TimerInterval="1000" /> <OverallPlaytime />
</Body>
</Card>
</GridCol>
<GridCol Xs="24" Md="12">
<Card Title="Network Upload Rate">
<Body>
<NetworkUploadRate TimerHistory="60" TimerInterval="1000" />
</Body>
</Card>
</GridCol>
<GridCol Xs="24" Md="12">
<Card Title="CPU Usage (%)">
<Body>
<ProcessorUtilization TimerHistory="60" TimerInterval="1000" />
</Body> </Body>
</Card> </Card>
</GridCol> </GridCol>

View File

@ -12,7 +12,7 @@
<Input Type="text" @bind-Value="context.Name" /> <Input Type="text" @bind-Value="context.Name" />
</PropertyColumn> </PropertyColumn>
<PropertyColumn Property="a => a.Path"> <PropertyColumn Property="a => a.Path">
<FilePicker @bind-Value="context.Path" ArchiveId="@ArchiveId" AllowDirectories="true" /> <FilePicker @bind-Value="context.Path" ArchiveId="@ArchiveId" AllowDirectories="true" Prefix="{InstallDir}\" Title="Select Action Executable" />
</PropertyColumn> </PropertyColumn>
<PropertyColumn Property="a => a.Arguments"> <PropertyColumn Property="a => a.Arguments">
<Input Type="text" @bind-Value="context.Arguments" /> <Input Type="text" @bind-Value="context.Arguments" />
@ -90,43 +90,6 @@
Move(action.SortOrder, action.SortOrder + 1); Move(action.SortOrder, action.SortOrder + 1);
} }
private async void BrowseForActionPath(Data.Models.Action action)
{
var modalOptions = new ModalOptions()
{
Title = "Choose Action Executable",
Maximizable = false,
DefaultMaximized = true,
Closable = true,
OkText = "Select File"
};
var browserOptions = new FilePickerOptions()
{
ArchiveId = ArchiveId,
Select = true,
Multiple = false
};
var modalRef = await ModalService.CreateModalAsync<FilePickerDialog, FilePickerOptions, IEnumerable<IFileManagerEntry>>(modalOptions, browserOptions);
modalRef.OnOk = (results) =>
{
action.Path = results.FirstOrDefault().Path;
var parts = action.Path.Split('/');
if (parts.Length > 1)
{
action.Path = parts.Last();
action.WorkingDirectory = "{InstallDir}/" + String.Join('/', parts.Take(parts.Length - 1));
}
StateHasChanged();
return Task.CompletedTask;
};
}
private void Move(int oldIndex, int newIndex) private void Move(int oldIndex, int newIndex)
{ {
foreach (var action in Actions) foreach (var action in Actions)

View File

@ -0,0 +1,107 @@
@using LANCommander.Models
@inherits FeedbackComponent<AddToCollectionOptions, Collection>
@inject CollectionService CollectionService
@inject GameService GameService
@inject IMessageService MessageService
<Select
TItem="Collection"
TItemValue="Guid"
DataSource="@Collections"
@bind-Value="SelectedCollection"
LabelName="@nameof(Collection.Name)"
ValueName="@nameof(Collection.Id)"
Placeholder="Select a Collection"
DropdownRender="@DropdownRender"
OnSelectedItemChanged="OnSelectedItemChanged" />
@code {
ICollection<Collection> Collections = new List<Collection>();
Guid SelectedCollection;
string NewCollectionName;
protected override async Task OnInitializedAsync()
{
await LoadData();
}
private async Task LoadData()
{
Collections = (await CollectionService.Get()).OrderBy(c => c.Name).ToList();
}
private RenderFragment DropdownRender(RenderFragment originNode)
{
RenderFragment customDropdownRender =
@<Template>
<div>
@originNode
<Divider Style="margin: 4px 0"></Divider>
<div style="display: flex; flex-wrap: nowrap; padding: 8px">
<Input Style="flex: auto" @bind-Value="@NewCollectionName" />
<a style="flex: none; padding: 8px; display: block; cursor: pointer" @onclick="AddCollection">
<Icon Type="plus" Theme="outline"></Icon>
Add New Collection
</a>
</div>
</div>
</Template>
;
return customDropdownRender;
}
private async Task AddCollection(MouseEventArgs args)
{
try
{
if (!String.IsNullOrWhiteSpace(NewCollectionName))
{
await CollectionService.Add(new Collection()
{
Name = NewCollectionName
});
await LoadData();
MessageService.Success("Collection added!");
}
}
catch (Exception ex)
{
MessageService.Error("Could not add a new collection!");
}
}
private void OnSelectedItemChanged(Collection collection)
{
SelectedCollection = collection.Id;
}
public override async Task OnFeedbackOkAsync(ModalClosingEventArgs args)
{
var collection = await CollectionService.Get(SelectedCollection);
try
{
foreach (var gameId in Options.GameIds.Where(gid => collection.Games != null && !collection.Games.Any(g => g.Id == gid)))
{
var game = await GameService.Get(gameId);
collection.Games.Add(game);
}
await CollectionService.Update(collection);
MessageService.Success("Added to collection!");
}
catch (Exception ex)
{
MessageService.Error("Could not add to collection!");
}
await base.OkCancelRefWithResult!.OnOk(collection);
}
}

View File

@ -16,7 +16,7 @@
</Template>; </Template>;
} }
<Modal Visible="ModalVisible" Title="Game Metadata Lookup" Footer="@Footer"> <Modal Visible="ModalVisible" Title="Game Metadata Lookup" Footer="@Footer" Class="game-metadata-lookup-modal">
<Table <Table
@ref="ResultsTable" @ref="ResultsTable"
TItem="Game" TItem="Game"

View File

@ -17,6 +17,9 @@
<FilePicker @bind-Value="context.Path" ArchiveId="@ArchiveId" AllowDirectories="true" /> <FilePicker @bind-Value="context.Path" ArchiveId="@ArchiveId" AllowDirectories="true" />
} }
</PropertyColumn> </PropertyColumn>
<PropertyColumn Property="p => p.IsRegex" Title="Regex">
<Checkbox @bind-Checked="context.IsRegex" />
</PropertyColumn>
<ActionColumn> <ActionColumn>
<Space Style="display: flex; justify-content: end"> <Space Style="display: flex; justify-content: end">
<SpaceItem> <SpaceItem>

View File

@ -128,11 +128,11 @@
</div> </div>
<div data-panel="Scripts"> <div data-panel="Scripts">
<ScriptEditor @bind-Scripts="Game.Scripts" GameId="Game.Id" ArchiveId="@LatestArchiveId" AllowedTypes="new ScriptType[] { ScriptType.Install, ScriptType.Uninstall, ScriptType.NameChange, ScriptType.KeyChange }" /> <ScriptEditor GameId="Game.Id" ArchiveId="@LatestArchiveId" AllowedTypes="new ScriptType[] { ScriptType.Install, ScriptType.Uninstall, ScriptType.NameChange, ScriptType.KeyChange }" />
</div> </div>
<div data-panel="Archives"> <div data-panel="Archives">
<ArchiveEditor @bind-Archives="Game.Archives" GameId="Game.Id" /> <ArchiveEditor GameId="Game.Id" />
</div> </div>
} }
@ -161,6 +161,7 @@ else
[Parameter] public Guid Id { get; set; } [Parameter] public Guid Id { get; set; }
[Parameter] public string Panel { get; set; } [Parameter] public string Panel { get; set; }
bool Loaded = false;
bool Success; bool Success;
string[] Errors = { }; string[] Errors = { };
@ -206,8 +207,13 @@ else
}); });
} } } }
protected override async Task OnInitializedAsync() protected override async Task OnParametersSetAsync()
{ {
if (!Loaded)
await LoadData();
}
private async Task LoadData() {
if (Id == Guid.Empty) if (Id == Guid.Empty)
Game = new Game(); Game = new Game();
else else
@ -223,6 +229,8 @@ else
Description = r.Description, Description = r.Description,
Key = r.Id.ToString() Key = r.Id.ToString()
}); });
Loaded = true;
} }
private async Task Save() private async Task Save()
@ -269,7 +277,7 @@ else
Game.Tags = new List<Data.Models.Tag>(); Game.Tags = new List<Data.Models.Tag>();
if (result.IGDBMetadata.GameModes != null && result.IGDBMetadata.GameModes.Values != null) if (result.IGDBMetadata.GameModes != null && result.IGDBMetadata.GameModes.Values != null)
Game.Singleplayer = result.IGDBMetadata.GameModes.Values.Any(gm => gm.Name == "Singleplayer"); Game.Singleplayer = result.IGDBMetadata.GameModes.Values.Any(gm => gm.Name == "Single player");
if (result.IGDBMetadata.InvolvedCompanies != null && result.IGDBMetadata.InvolvedCompanies.Values != null) if (result.IGDBMetadata.InvolvedCompanies != null && result.IGDBMetadata.InvolvedCompanies.Values != null)
{ {

View File

@ -2,17 +2,28 @@
@using AntDesign.TableModels; @using AntDesign.TableModels;
@using LANCommander.Extensions; @using LANCommander.Extensions;
@using System.ComponentModel.DataAnnotations; @using System.ComponentModel.DataAnnotations;
@using LANCommander.Models
@using LANCommander.Pages.Games.Components
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage; @using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
@using Microsoft.EntityFrameworkCore; @using Microsoft.EntityFrameworkCore;
@using System.Web
@attribute [Authorize] @attribute [Authorize]
@inject GameService GameService @inject GameService GameService
@inject NavigationManager NavigationManager @inject NavigationManager NavigationManager
@inject ModalService ModalService
@inject IMessageService MessageService
<PageHeader Title="Games"> <PageHeader Title="Games" Subtitle="@Games.Count().ToString()">
<PageHeaderExtra> <PageHeaderExtra>
<Space Direction="DirectionVHType.Horizontal"> <Space Direction="DirectionVHType.Horizontal">
@if (Selected != null && Selected.Count() > 0)
{
<SpaceItem>
<Button OnClick="() => AddToCollection()" Type="@ButtonType.Primary">Add to Collection</Button>
</SpaceItem>
}
<SpaceItem> <SpaceItem>
<Search Placeholder="Search" @bind-Value="Search" BindOnInput DebounceMilliseconds="150" OnChange="() => LoadData()" /> <Search Placeholder="Search" @bind-Value="Search" BindOnInput DebounceMilliseconds="250" OnChange="SearchChanged" />
</SpaceItem> </SpaceItem>
<SpaceItem> <SpaceItem>
<Button OnClick="() => Add()" Type="@ButtonType.Primary">Add Game</Button> <Button OnClick="() => Add()" Type="@ButtonType.Primary">Add Game</Button>
@ -23,7 +34,8 @@
<TableColumnPicker @ref="Picker" Key="Games" @bind-Visible="ColumnPickerVisible" /> <TableColumnPicker @ref="Picker" Key="Games" @bind-Visible="ColumnPickerVisible" />
<Table TItem="Game" DataSource="@Games" Loading="@Loading" PageSize="25" Responsive> <Table TItem="Game" DataSource="@Games" @bind-SelectedRows="Selected" Loading="@Loading" PageSize="@PageSize" PageIndex="@PageIndex" OnPageIndexChange="PageIndexChanged" OnPageSizeChange="PageSizeChanged" Responsive>
<Selection Key="@(context.Id.ToString())" />
<Column TData="string" Title="Icon" Hidden="@(Picker.IsColumnHidden("Icon"))"> <Column TData="string" Title="Icon" Hidden="@(Picker.IsColumnHidden("Icon"))">
<Image Src="@GetIcon(context)" Height="32" Width="32" Preview="false"></Image> <Image Src="@GetIcon(context)" Height="32" Width="32" Preview="false"></Image>
</Column> </Column>
@ -120,27 +132,69 @@
bool Loading = true; bool Loading = true;
string Search = ""; string Search = "";
string Url;
bool Visibility = false; bool Visibility = false;
IEnumerable<Game> Selected;
TableColumnPicker Picker; TableColumnPicker Picker;
bool ColumnPickerVisible = false; bool ColumnPickerVisible = false;
protected override async Task OnAfterRenderAsync(bool firstRender) int PageIndex = 1;
int PageSize = 25;
protected override async Task OnInitializedAsync()
{ {
if (firstRender) Url = NavigationManager.Uri;
{ NavigationManager.LocationChanged += LocationChanged;
LoadData(); LoadTableParameter();
await LoadData();
Loading = false; Loading = false;
StateHasChanged();
}
} }
private async Task LoadData() private async Task LoadData()
{ {
Games = await GameService.Get(g => g.Title.ToLower().Contains(Search.ToLower().Trim()) || g.SortTitle.ToLower().Contains(Search.ToLower().Trim())).OrderBy(g => String.IsNullOrWhiteSpace(g.SortTitle) ? g.Title : g.SortTitle).ToListAsync(); Games = await GameService.Get(g => g.Title.ToLower().Contains(Search.ToLower().Trim()) || g.SortTitle.ToLower().Contains(Search.ToLower().Trim())).OrderBy(g => String.IsNullOrWhiteSpace(g.SortTitle) ? g.Title : g.SortTitle).ToListAsync();
await InvokeAsync(StateHasChanged);
}
private async void LocationChanged(object sender, LocationChangedEventArgs e)
{
Url = e.Location;
LoadTableParameter();
await LoadData();
}
private void LoadTableParameter()
{
var uri = NavigationManager.ToAbsoluteUri(Url);
var query = HttpUtility.ParseQueryString(uri.Query);
PageIndex = int.TryParse(query["Page"], out var index) ? index > 0 ? index : 1 : 1;
PageSize = int.TryParse(query["Size"], out var size) ? size > 0 ? size : 25 : 25;
if (query["Search"] != null)
Search = query["Search"];
else
Search = "";
}
private void PageIndexChanged(PaginationEventArgs args)
{
NavigationManager.NavigateTo($"Games?Page={args.Page}&Size={args.PageSize}{(Search != "" ? "&Search=" + Search : "")}");
}
private void PageSizeChanged(PaginationEventArgs args)
{
NavigationManager.NavigateTo($"Games?Page={args.Page}&Size={args.PageSize}{(Search != "" ? "&Search=" + Search : "")}");
}
private void SearchChanged()
{
NavigationManager.NavigateTo($"Games?Search={Search}");
} }
private string GetIcon(Game game) private string GetIcon(Game game)
@ -174,13 +228,45 @@
Loading = true; Loading = true;
await GameService.Delete(game); try
{
await GameService.Delete(game);
}
catch (Exception ex)
{
MessageService.Error("Could not delete the game!");
}
Games = await GameService.Get(x => true).OrderBy(g => String.IsNullOrWhiteSpace(g.SortTitle) ? g.Title : g.SortTitle).ToListAsync(); Games = await GameService.Get(x => true).OrderBy(g => String.IsNullOrWhiteSpace(g.SortTitle) ? g.Title : g.SortTitle).ToListAsync();
Loading = false; Loading = false;
} }
private async void AddToCollection()
{
var modalOptions = new ModalOptions()
{
Title = "Add to Collection",
Maximizable = false,
DefaultMaximized = false,
Closable = true,
OkText = "Add"
};
var options = new AddToCollectionOptions()
{
GameIds = Selected.Select(g => g.Id)
};
var modalRef = await ModalService.CreateModalAsync<AddToCollectionDialog, AddToCollectionOptions, Collection>(modalOptions, options);
modalRef.OnOk = async (collection) =>
{
Selected = null;
await LoadData();
};
}
private async Task OpenColumnPicker() private async Task OpenColumnPicker()
{ {
ColumnPickerVisible = true; ColumnPickerVisible = true;
@ -190,4 +276,9 @@
{ {
ColumnPickerVisible = false; ColumnPickerVisible = false;
} }
public void Dispose()
{
NavigationManager.LocationChanged -= LocationChanged;
}
} }

View File

@ -14,7 +14,7 @@
<div style="padding: 0 24px;"> <div style="padding: 0 24px;">
<Table TItem="GameSave" DataSource="@GameSaves"> <Table TItem="GameSave" DataSource="@GameSaves">
<PropertyColumn Property="s => s.Game.Title" Sortable /> <PropertyColumn Property="s => (s.Game == null ? String.Empty : s.Game.Title)" Sortable Title="Game" />
<PropertyColumn Property="s => s.CreatedOn" Format="MM/dd/yyyy hh:mm tt" Sortable /> <PropertyColumn Property="s => s.CreatedOn" Format="MM/dd/yyyy hh:mm tt" Sortable />
<ActionColumn Title="" Style="text-align: right; white-space: nowrap"> <ActionColumn Title="" Style="text-align: right; white-space: nowrap">
<Space Direction="DirectionVHType.Horizontal"> <Space Direction="DirectionVHType.Horizontal">
@ -45,7 +45,7 @@
User = await UserManager.FindByNameAsync(authState.User.Identity.Name); User = await UserManager.FindByNameAsync(authState.User.Identity.Name);
if (User != null) if (User != null)
GameSaves = User.GameSaves.OrderBy(s => s.Game.Title).ThenBy(s => s.CreatedOn).ToList(); GameSaves = User.GameSaves.OrderBy(s => s.Game?.Title).ThenBy(s => s.CreatedOn).ToList();
Loading = false; Loading = false;
} }

View File

@ -56,11 +56,11 @@
@if (Redistributable != null && Redistributable.Id != Guid.Empty) @if (Redistributable != null && Redistributable.Id != Guid.Empty)
{ {
<div data-panel="Scripts"> <div data-panel="Scripts">
<ScriptEditor @bind-Scripts="Redistributable.Scripts" RedistributableId="Redistributable.Id" ArchiveId="@LatestArchiveId" AllowedTypes="new ScriptType[] { ScriptType.Install, ScriptType.DetectInstall }" /> <ScriptEditor RedistributableId="Redistributable.Id" ArchiveId="@LatestArchiveId" AllowedTypes="new ScriptType[] { ScriptType.Install, ScriptType.DetectInstall }" />
</div> </div>
<div data-panel="Archives"> <div data-panel="Archives">
<ArchiveEditor @bind-Archives="Redistributable.Archives" RedistributableId="Redistributable.Id" /> <ArchiveEditor RedistributableId="Redistributable.Id" />
</div> </div>
} }
</div> </div>

View File

@ -39,7 +39,7 @@
<ChildContent> <ChildContent>
<Space Direction="DirectionVHType.Horizontal"> <Space Direction="DirectionVHType.Horizontal">
<SpaceItem> <SpaceItem>
<Button OnClick="() => Edit(context)">Edit</Button> <a href="/Redistributables/@(context.Id)" class="ant-btn ant-btn-primary">Edit</a>
</SpaceItem> </SpaceItem>
<SpaceItem> <SpaceItem>
<Popconfirm OnConfirm="() => Delete(context)" Title="Are you sure you want to delete this redistributable?"> <Popconfirm OnConfirm="() => Delete(context)" Title="Are you sure you want to delete this redistributable?">
@ -85,11 +85,6 @@
NavigationManager.NavigateTo("/Redistributables/Add"); NavigationManager.NavigateTo("/Redistributables/Add");
} }
private void Edit(Redistributable redistributable)
{
NavigationManager.NavigateTo($"/Redistributables/{redistributable.Id}/General");
}
private async Task Delete(Redistributable redistributable) private async Task Delete(Redistributable redistributable)
{ {
Redistributables = new List<Redistributable>(); Redistributables = new List<Redistributable>();

View File

@ -0,0 +1,144 @@
@page "/Settings/Roles"
@using LANCommander.Models;
@layout SettingsLayout
@inject RoleManager<Role> RoleManager
@inject UserManager<User> UserManager
@inject IMessageService MessageService
@inject NavigationManager NavigationManager
@attribute [Authorize(Roles = "Administrator")]
<PageHeader Title="Roles" Subtitle="@Roles.Count().ToString()">
<PageHeaderExtra>
<Space Direction="DirectionVHType.Horizontal">
<SpaceItem>
<Button OnClick="() => ShowNewRoleDialog()" Type="@ButtonType.Primary">Add Role</Button>
</SpaceItem>
</Space>
</PageHeaderExtra>
</PageHeader>
<div style="padding: 0 24px;">
<Table TItem="RoleViewModel" DataSource="@Roles" Loading="@(Loading)" Responsive>
<PropertyColumn Property="r => r.Name" Title="Name" />
<PropertyColumn Property="r => r.Collections" Title="Collections" />
<PropertyColumn Property="r => r.Users" Title="Users" />
<ActionColumn>
<Space Style="display: flex; justify-content: end">
<SpaceItem>
@if (context.Name != "Administrator")
{
<Popconfirm OnConfirm="() => DeleteRole(context)" Title="Are you sure you want to delete this role?">
<Button Icon="@IconType.Outline.Close" Type="@ButtonType.Text" Danger />
</Popconfirm>
}
else
{
<Tooltip Title="The administrator role cannot be deleted.">
<Button Icon="@IconType.Outline.Close" Type="@ButtonType.Text" Disabled />
</Tooltip>
}
</SpaceItem>
</Space>
</ActionColumn>
</Table>
</div>
<Modal Title="Add a Role" @bind-Visible="AddRoleDialogVisible" OnOk="AddRole" OnCancel="() => AddRoleDialogVisible = false">
<Form Model="NewRole">
<FormItem Label="Name">
<Input @bind-Value="@context.Name" />
</FormItem>
</Form>
</Modal>
@code {
ICollection<RoleViewModel> Roles { get; set; }
LANCommanderSettings Settings = SettingService.GetSettings();
bool Loading = true;
bool AddRoleDialogVisible = false;
RoleViewModel NewRole = new RoleViewModel();
protected override async Task OnInitializedAsync()
{
Roles = new List<RoleViewModel>();
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
await LoadData();
}
private async Task LoadData()
{
Roles = new List<RoleViewModel>();
foreach (var role in RoleManager.Roles)
{
var users = await UserManager.GetUsersInRoleAsync(role.Name);
Roles.Add(new RoleViewModel()
{
Name = role.Name,
Collections = role.Collections != null ? role.Collections.Count : 0,
Users = users != null ? users.Count : 0
});
}
Loading = false;
StateHasChanged();
}
private async Task DeleteRole(RoleViewModel roleViewModel)
{
var role = await RoleManager.FindByNameAsync(roleViewModel.Name);
if (role.Name == "Administrator")
{
await MessageService.Error("Cannot delete the administrator role!");
}
else
{
await RoleManager.DeleteAsync(role);
await LoadData();
await MessageService.Success($"Deleted {role.Name}!");
}
}
private void ShowNewRoleDialog()
{
NewRole = new RoleViewModel();
AddRoleDialogVisible = true;
}
private async Task AddRole()
{
if (await RoleManager.RoleExistsAsync(NewRole.Name))
{
MessageService.Error("A role with that name already exists!");
AddRoleDialogVisible = false;
return;
}
try
{
await RoleManager.CreateAsync(new Role()
{
Name = NewRole.Name
});
await LoadData();
MessageService.Success("Role added!");
}
catch (Exception ex)
{
MessageService.Error("Could not added role!");
}
}
}

View File

@ -7,6 +7,7 @@
<Menu Mode=@MenuMode.Inline Style="height: 100%"> <Menu Mode=@MenuMode.Inline Style="height: 100%">
<MenuItem RouterLink="/Settings/General">General</MenuItem> <MenuItem RouterLink="/Settings/General">General</MenuItem>
<MenuItem RouterLink="/Settings/Users">Users</MenuItem> <MenuItem RouterLink="/Settings/Users">Users</MenuItem>
<MenuItem RouterLink="/Settings/Roles">Roles</MenuItem>
<MenuItem RouterLink="/Settings/Authentication">Authentication</MenuItem> <MenuItem RouterLink="/Settings/Authentication">Authentication</MenuItem>
<MenuItem RouterLink="/Settings/UserSaves">User Saves</MenuItem> <MenuItem RouterLink="/Settings/UserSaves">User Saves</MenuItem>
<MenuItem RouterLink="/Settings/Archives">Archives</MenuItem> <MenuItem RouterLink="/Settings/Archives">Archives</MenuItem>

View File

@ -34,7 +34,7 @@
</ActionColumn> </ActionColumn>
</Table> </Table>
<ArchiveUploader @ref="Uploader" OnArchiveUploaded="OnArchiveUploaded" /> <ArchiveUploader @ref="Uploader" OnArchiveUploaded="LoadData" />
</div> </div>
@ -78,21 +78,7 @@
System.IO.File.Create(archiveFilePath).Close(); System.IO.File.Create(archiveFilePath).Close();
await Uploader.Open(archive); await Uploader.Open(archive.Id);
}
async Task OnArchiveUploaded(Archive archive)
{
try
{
await ArchiveService.Update(archive);
await LoadData();
}
catch (Exception ex)
{
await MessageService.Error("Archive could not be updated.");
}
} }
async Task Delete(Archive archive) async Task Delete(Archive archive)

View File

@ -40,7 +40,7 @@
<SpaceItem> <SpaceItem>
<Tooltip Title="Change Password"> <Tooltip Title="Change Password">
<Button Icon="@IconType.Outline.Key" Type="@ButtonType.Text" OnClick="() => ChangePassword(context)" /> <Button Icon="@IconType.Outline.Lock" Type="@ButtonType.Text" OnClick="() => ChangePassword(context)" />
</Tooltip> </Tooltip>
</SpaceItem> </SpaceItem>

View File

@ -133,6 +133,7 @@ namespace LANCommander
builder.Services.AddScoped<SettingService>(); builder.Services.AddScoped<SettingService>();
builder.Services.AddScoped<ArchiveService>(); builder.Services.AddScoped<ArchiveService>();
builder.Services.AddScoped<CategoryService>(); builder.Services.AddScoped<CategoryService>();
builder.Services.AddScoped<CollectionService>();
builder.Services.AddScoped<GameService>(); builder.Services.AddScoped<GameService>();
builder.Services.AddScoped<ScriptService>(); builder.Services.AddScoped<ScriptService>();
builder.Services.AddScoped<GenreService>(); builder.Services.AddScoped<GenreService>();

View File

@ -0,0 +1,12 @@
using LANCommander.Data;
using LANCommander.Data.Models;
namespace LANCommander.Services
{
public class CollectionService : BaseDatabaseService<Collection>
{
public CollectionService(DatabaseContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
{
}
}
}

View File

@ -44,7 +44,7 @@ namespace LANCommander.Services
public string GetSavePath(GameSave save) public string GetSavePath(GameSave save)
{ {
return Path.Combine(Settings.UserSaves.StoragePath, save.UserId.ToString(), $"{save.Id}.zip"); return Path.Combine(Settings.UserSaves.StoragePath, save.UserId.ToString(), $"{save.Id}");
} }
} }
} }

View File

@ -114,6 +114,7 @@ namespace LANCommander.Services
{ {
Id = p.Id, Id = p.Id,
Path = p.Path, Path = p.Path,
IsRegex = p.IsRegex,
Type = p.Type.ToString() Type = p.Type.ToString()
}); });
} }

View File

@ -9,6 +9,7 @@
@if (User != null && User.IsInRole("Administrator")) @if (User != null && User.IsInRole("Administrator"))
{ {
<MenuItem RouterLink="/Games">Games</MenuItem> <MenuItem RouterLink="/Games">Games</MenuItem>
<MenuItem RouterLink="/Collections">Collections</MenuItem>
<MenuItem RouterLink="/Redistributables">Redistributables</MenuItem> <MenuItem RouterLink="/Redistributables">Redistributables</MenuItem>
<MenuItem RouterLink="/Servers">Servers</MenuItem> <MenuItem RouterLink="/Servers">Servers</MenuItem>
<MenuItem RouterLink="/Files">Files</MenuItem> <MenuItem RouterLink="/Files">Files</MenuItem>

View File

@ -1,2 +1,2 @@
# Bounds are accessible by $Display.Width and $Display.Height # Bounds are accessible by $Display.Bounds.Width and $Display.Bounds.Height
$Display = Get-PrimaryDisplay $Display = Get-PrimaryDisplay

View File

@ -1,2 +1,2 @@
# Use regex to replace text within a file. Quotes are escaped by double quoting ("") # Use regex to replace text within a file. Quotes are escaped by double quoting ("")
Write-ReplaceContentInFile -Regex '^game.setPlayerName "(.+)"' -Replacement "game.setPlayerName ""$NewName""" -FilePath "$InstallDir\<File Path>" Write-ReplaceContentInFile -Pattern '^game.setPlayerName "(.+)"' -Substitution "game.setPlayerName ""$NewPlayerAlias""" -FilePath "$InstallDirectory\<File Path>"

View File

@ -1 +1 @@
$OldPlayerAlias $InstallDirectory

View File

@ -1 +1 @@
$NewName = $args[0] $NewPlayerAlias

View File

@ -1,4 +1 @@
$OldName = "" $OldPlayerAlias
if ($args[1]) {
$OldName = $args[1]
}

View File

@ -18,6 +18,11 @@
background: #141414; background: #141414;
} }
.ant-page-header-heading-title {
padding-bottom: 4px;
line-height: 26px;
}
label.ant-btn-icon-only { label.ant-btn-icon-only {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
@ -183,6 +188,14 @@ label.ant-btn-icon-only {
background: rgba(255, 255, 255, 0.03); background: rgba(255, 255, 255, 0.03);
} }
.game-metadata-lookup-modal .ant-modal-body {
padding: 0;
}
.game-metadata-lookup-modal tbody tr {
cursor: pointer;
}
.image-picker-images { .image-picker-images {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;