diff --git a/.github/workflows/build-dev.yml b/.github/workflows/build-dev.yml index fa78a56d..557bb021 100644 --- a/.github/workflows/build-dev.yml +++ b/.github/workflows/build-dev.yml @@ -29,7 +29,7 @@ jobs: - name: Restore dependencies run: dotnet restore - name: Build application - run: dotnet publish -c Release -o bin/publish + run: dotnet publish -c Release -o bin/publish BLAZAM/BLAZAM.csproj - name: Test application run: dotnet test -c Release diff --git a/.github/workflows/build-nightly.yml b/.github/workflows/build-nightly.yml index 6febba33..a362c4d9 100644 --- a/.github/workflows/build-nightly.yml +++ b/.github/workflows/build-nightly.yml @@ -29,7 +29,7 @@ jobs: - name: Restore dependencies run: dotnet restore - name: Build application - run: dotnet publish -c Release -o bin/publish + run: dotnet publish -c Release -o bin/publish BLAZAM/BLAZAM.csproj - name: Test application run: dotnet test -c Release diff --git a/.github/workflows/deploy-demo.yml b/.github/workflows/deploy-demo.yml index c9f5e117..700ebfab 100644 --- a/.github/workflows/deploy-demo.yml +++ b/.github/workflows/deploy-demo.yml @@ -27,7 +27,7 @@ jobs: run: dotnet build --configuration Release - name: dotnet publish - run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp + run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp BLAZAM/BLAZAM.csproj - name: Upload artifact for deployment job uses: actions/upload-artifact@v2 diff --git a/.github/workflows/release-stable.yml b/.github/workflows/release-stable.yml index c62e2c97..a3ee6447 100644 --- a/.github/workflows/release-stable.yml +++ b/.github/workflows/release-stable.yml @@ -22,7 +22,7 @@ jobs: - name: Restore dependencies run: dotnet restore - name: Build application - run: dotnet publish -c Release -o bin\Publish + run: dotnet publish -c Release -o bin\Publish BLAZAM/BLAZAM.csproj - name: Set assembly version as environment variable shell: pwsh id: get_version diff --git a/.gitignore b/.gitignore index fed7c21a..6c3310d5 100644 --- a/.gitignore +++ b/.gitignore @@ -368,3 +368,5 @@ FodyWeavers.xsd /BLAZAM/appsettings.json /Setup/BLAZAM.msi /BLAZAM/database.db +/BLAZAM/database - Copy.db +/BLAZAM/export diff --git a/BLAZAM.Tests/BLAZAM.Tests.csproj b/BLAZAM.Tests/BLAZAM.Tests.csproj index 4d11dd6b..baa3353a 100644 --- a/BLAZAM.Tests/BLAZAM.Tests.csproj +++ b/BLAZAM.Tests/BLAZAM.Tests.csproj @@ -9,13 +9,13 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/BLAZAM.Tests/FileSystem/FileSystemBaseTests.cs b/BLAZAM.Tests/FileSystem/FileSystemBaseTests.cs new file mode 100644 index 00000000..f19c8946 --- /dev/null +++ b/BLAZAM.Tests/FileSystem/FileSystemBaseTests.cs @@ -0,0 +1,123 @@ +using BLAZAM.FileSystem; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.AccessControl; +using System.Text; +using System.Threading.Tasks; + +namespace BLAZAM.Tests.FileSystem +{ + public class FileSystemBaseTests + { + [Fact] + public void Constructor_ThrowsArgumentException_WhenPathIsNull() + { + // Arrange + string path = null; + + // Act and Assert + Assert.Throws(() => new FileSystemBase(path)); + } + + [Fact] + public void Constructor_ReplacesTempVariable_WhenPathContainsTemp() + { + // Arrange + string path = "%temp%\\test.txt"; + + // Act + var fileSystemBase = new FileSystemBase(path); + + // Assert + Assert.Equal(Path.GetTempPath() + "test.txt", fileSystemBase.Path); + } + + [Fact] + public void Constructor_SetsFullPath_WhenPathIsRelative() + { + // Arrange + string path = "..\\test.txt"; + + // Act + var fileSystemBase = new FileSystemBase(path); + + // Assert + Assert.Equal(Path.GetFullPath(path), fileSystemBase.Path); + } + + [Fact] + public void Writable_ReturnsTrue_WhenFileHasWritePermission() + { + // Arrange + string path = Path.GetTempFileName(); + var fileSystemBase = new FileSystemBase(path); + + // Act + bool writable = fileSystemBase.Writable; + + // Assert + Assert.True(writable); + + // Clean up + File.Delete(path); + } + //TODO Fix checking when no write permission + //[Fact] + //public void Writable_ReturnsFalse_WhenFileHasNoWritePermission() + //{ + // // Arrange + // string path = Path.GetTempFileName(); + // var fileSystemBase = new FileSystemBase(path); + + // // Deny write permission to the file + // var ac = new FileInfo(path).GetAccessControl(); + // ac.AddAccessRule(new FileSystemAccessRule(Environment.UserName, FileSystemRights.Write, AccessControlType.Deny)); + // new FileInfo(path).SetAccessControl(ac); + + // // Act + // bool writable = fileSystemBase.Writable; + + // // Assert + // Assert.False(writable); + + // // Clean up + // File.Delete(path); + //} + + [Fact] + public void GetHashCode_ReturnsPathHashCode() + { + // Arrange + string path = Path.GetTempFileName(); + var fileSystemBase = new FileSystemBase(path); + + // Act + int hashCode = fileSystemBase.GetHashCode(); + + // Assert + Assert.Equal(path.GetHashCode(), hashCode); + + // Clean up + File.Delete(path); + } + + [Fact] + public void ToString_ReturnsPath() + { + // Arrange + string path = Path.GetTempFileName(); + var fileSystemBase = new FileSystemBase(path); + + // Act + string toString = fileSystemBase.ToString(); + + // Assert + Assert.Equal(path, toString); + + // Clean up + File.Delete(path); + } + } + +} diff --git a/BLAZAM.Tests/Mocks/MockDirectoryModel.cs b/BLAZAM.Tests/Mocks/MockDirectoryModel.cs deleted file mode 100644 index c5748689..00000000 --- a/BLAZAM.Tests/Mocks/MockDirectoryModel.cs +++ /dev/null @@ -1,134 +0,0 @@ -using BLAZAM.Common.Data.ActiveDirectory; -using BLAZAM.Common.Data.ActiveDirectory.Interfaces; -using BLAZAM.Common.Data.ActiveDirectory.Models; -using BLAZAM.Common.Models.Database; -using System; -using System.Collections.Generic; -using System.DirectoryServices; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BLAZAM.Tests.Mocks -{ - internal class MockDirectoryModel : IDirectoryEntryAdapter - { - public string? SamAccountName - { - get => throw new NotImplementedException(); set => throw new NotImplementedException(); - } - public string? CanonicalName { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - public string? DN { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - public DateTime? Created { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - public DateTime? LastChanged { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - public byte[]? SID { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - public List? Classes { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - - public bool CanRead => throw new NotImplementedException(); - - public ActiveDirectoryObjectType ObjectType => throw new NotImplementedException(); - - public bool CanMove => throw new NotImplementedException(); - - public bool CanRename => throw new NotImplementedException(); - - public bool CanCreate => throw new NotImplementedException(); - - public bool CanDelete => throw new NotImplementedException(); - - public DirectoryEntry DirectoryEntry { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - public string? ADSPath { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - - public bool CanEdit => throw new NotImplementedException(); - - public string? OU => throw new NotImplementedException(); - - public bool HasUnsavedChanges => throw new NotImplementedException(); - - public bool NewEntry { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - - public string SearchUri => throw new NotImplementedException(); - - public AppEvent? OnModelCommited { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - public AppEvent? OnModelChanged { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - public Dictionary NewEntryProperties { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - - public IADOrganizationalUnit? LastKnownParent => throw new NotImplementedException(); - - public bool IsDeleted => throw new NotImplementedException(); - - public List Changes => throw new NotImplementedException(); - - public AppEvent OnDirectoryModelRenamed { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - - public bool CanEditField(ActiveDirectoryField field) - { - throw new NotImplementedException(); - } - - public bool CanReadField(ActiveDirectoryField field) - { - throw new NotImplementedException(); - } - - public DirectoryChangeResult CommitChanges() - { - throw new NotImplementedException(); - } - - public Task CommitChangesAsync() - { - throw new NotImplementedException(); - } - - public void Delete() - { - throw new NotImplementedException(); - } - - public void DiscardChanges() - { - throw new NotImplementedException(); - } - - public void Dispose() - { - throw new NotImplementedException(); - } - - public Task GetParent() - { - throw new NotImplementedException(); - } - - public bool Invoke(string method, object?[]? args = null) - { - throw new NotImplementedException(); - } - - public bool IsNewDirectoryEntry(IADOrganizationalUnit ou) - { - throw new NotImplementedException(); - } - - public bool MoveTo(IADOrganizationalUnit parentOUToMoveTo) - { - throw new NotImplementedException(); - } - - public Task Parse(DirectoryEntry result, IActiveDirectory directory) - { - throw new NotImplementedException(); - } - - public Task Parse(SearchResult result, IActiveDirectory directory) - { - throw new NotImplementedException(); - } - - public bool Rename(string newName) - { - throw new NotImplementedException(); - } - } -} diff --git a/BLAZAM.Tests/Mocks/Mock_HttpClientFactory.cs b/BLAZAM.Tests/Mocks/Mock_HttpClientFactory.cs index f184e235..892b9f4b 100644 --- a/BLAZAM.Tests/Mocks/Mock_HttpClientFactory.cs +++ b/BLAZAM.Tests/Mocks/Mock_HttpClientFactory.cs @@ -10,7 +10,8 @@ internal class Mock_HttpClientFactory : IHttpClientFactory { public HttpClient CreateClient(string name) { - return HttpClientFactory.Create(); + HttpClient client = new HttpClient(); + return client; } } } diff --git a/BLAZAM.Tests/Mocks/Mock_UpdateService.cs b/BLAZAM.Tests/Mocks/Mock_UpdateService.cs index 49617d7b..fecac495 100644 --- a/BLAZAM.Tests/Mocks/Mock_UpdateService.cs +++ b/BLAZAM.Tests/Mocks/Mock_UpdateService.cs @@ -1,7 +1,12 @@ -using BLAZAM.Server.Data.Services.Update; + +using BLAZAM.Common.Data; +using BLAZAM.FileSystem; +using BLAZAM.Update.Services; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; @@ -9,9 +14,15 @@ namespace BLAZAM.Tests.Mocks { internal class Mock_UpdateService : UpdateService { - public Mock_UpdateService() : base(new Mock_HttpClientFactory()) + public Mock_UpdateService() : base(new Mock_HttpClientFactory(), new() { - + ApplicationRoot = new SystemDirectory("C:\\temp"), + RunningProcess = Process.GetCurrentProcess(), + RunningVersion = new ApplicationVersion("0.0.1"), + TempDirectory = new SystemDirectory("C:\\temp") + },null) + { + SelectedBranch = "Stable"; } } diff --git a/BLAZAM.Tests/Updates/UpdateTests.cs b/BLAZAM.Tests/Updates/UpdateTests.cs index 0da5e222..8d7fd4b5 100644 --- a/BLAZAM.Tests/Updates/UpdateTests.cs +++ b/BLAZAM.Tests/Updates/UpdateTests.cs @@ -1,5 +1,6 @@ -using BLAZAM.Server.Data.Services.Update; + using BLAZAM.Tests.Mocks; +using BLAZAM.Update; using System; using System.Collections.Generic; using System.Linq; @@ -46,7 +47,7 @@ private async void Update_Stages_OK(ApplicationUpdate latest) private async void Update_Cleanup_OK(ApplicationUpdate latest) { - latest.CleanStaging(); + await latest.CleanStaging(); latest.UpdateFile.Delete(); Assert.True(!latest.UpdateFile.Exists); Assert.True(latest.UpdateStagingDirectory.Files.Count == 0); diff --git a/BLAZAM.Tests/Updates/VersionTests.cs b/BLAZAM.Tests/Updates/VersionTests.cs index 7b68dbe9..931502ff 100644 --- a/BLAZAM.Tests/Updates/VersionTests.cs +++ b/BLAZAM.Tests/Updates/VersionTests.cs @@ -1,5 +1,6 @@ -using BLAZAM.Server.Data; -using BLAZAM.Server.Data.Services.Update; +using BLAZAM.Common.Data; +using BLAZAM.Server.Data; +using BLAZAM.Update; using System; using System.Collections.Generic; using System.Linq; diff --git a/BLAZAM.sln b/BLAZAM.sln index 399a9b0f..49ffa459 100644 --- a/BLAZAM.sln +++ b/BLAZAM.sln @@ -16,6 +16,34 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BLAZAMCommon.Tests", "BLAZAMCommon.Tests\BLAZAMCommon.Tests.csproj", "{EBCFE03D-23E9-4C35-8223-0B3B223A02FF}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BLAZAMUpdate", "BlazamUpdate\BLAZAMUpdate.csproj", "{2D72790C-6804-42A3-AB08-CF4DB353E84F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BLAZAMLogger", "BLAZAMLoggers\BLAZAMLogger.csproj", "{A05B414A-78F3-45BB-A192-02970AD4529F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BLAZAMFileSystem", "BLAZAMFileSystem\BLAZAMFileSystem.csproj", "{23891100-FDC8-4D50-9AF9-9358036A46E2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BLAZAMDatabase", "BLAZAMDatabase\BLAZAMDatabase.csproj", "{3707415E-547B-48DD-A7FA-0A5F66377B90}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BLAZAMActiveDirectory", "BLAZAMActiveDirectory\BLAZAMActiveDirectory.csproj", "{E4520DEE-90AF-424B-B487-BE9FBE7177F0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BLAZAMSession", "BLAZAMSession\BLAZAMSession.csproj", "{4505F9A5-5337-4DDF-97C2-9B0AFCE9FB80}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BLAZAMNotifications", "BLAZAMNotifications\BLAZAMNotifications.csproj", "{621A84B2-EDDE-42B1-9BF1-51C77E173224}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BLAZAMGui", "BLAZAMGui\BLAZAMGui.csproj", "{67138FD9-931F-4B53-A0AE-882FE065774D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BLAZAMLocalization", "BLAZAMLocalization\BLAZAMLocalization.csproj", "{CB028E34-8D23-4F50-BA6A-B7CFC4A585E8}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BLAZAMServices", "BLAZAMServices\BLAZAMServices.csproj", "{294A1093-94F5-4088-BF26-06F5BF8E84C2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BLAZAMEmail", "BLAZAMEmail\BLAZAMEmail.csproj", "{9F4BB42E-61A6-4970-951C-883CAA0CA25D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BLAZAMEmailMessage", "BLAZAMEmailMessage\BLAZAMEmailMessage.csproj", "{FBA9638A-1A71-4587-AADD-1F133ACF8E1A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BLAZAMStatic", "BLAZAMStatic\BLAZAMStatic.csproj", "{FA69CB05-1C56-43CD-948B-28A6D8643713}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BLAZAMThemes", "BLAZAMThemes\BLAZAMThemes.csproj", "{DB29B0EB-D78C-4554-8512-FF4E54451D14}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -74,6 +102,174 @@ Global {EBCFE03D-23E9-4C35-8223-0B3B223A02FF}.Release|x64.Build.0 = Release|Any CPU {EBCFE03D-23E9-4C35-8223-0B3B223A02FF}.Release|x86.ActiveCfg = Release|Any CPU {EBCFE03D-23E9-4C35-8223-0B3B223A02FF}.Release|x86.Build.0 = Release|Any CPU + {2D72790C-6804-42A3-AB08-CF4DB353E84F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2D72790C-6804-42A3-AB08-CF4DB353E84F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2D72790C-6804-42A3-AB08-CF4DB353E84F}.Debug|x64.ActiveCfg = Debug|Any CPU + {2D72790C-6804-42A3-AB08-CF4DB353E84F}.Debug|x64.Build.0 = Debug|Any CPU + {2D72790C-6804-42A3-AB08-CF4DB353E84F}.Debug|x86.ActiveCfg = Debug|Any CPU + {2D72790C-6804-42A3-AB08-CF4DB353E84F}.Debug|x86.Build.0 = Debug|Any CPU + {2D72790C-6804-42A3-AB08-CF4DB353E84F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2D72790C-6804-42A3-AB08-CF4DB353E84F}.Release|Any CPU.Build.0 = Release|Any CPU + {2D72790C-6804-42A3-AB08-CF4DB353E84F}.Release|x64.ActiveCfg = Release|Any CPU + {2D72790C-6804-42A3-AB08-CF4DB353E84F}.Release|x64.Build.0 = Release|Any CPU + {2D72790C-6804-42A3-AB08-CF4DB353E84F}.Release|x86.ActiveCfg = Release|Any CPU + {2D72790C-6804-42A3-AB08-CF4DB353E84F}.Release|x86.Build.0 = Release|Any CPU + {A05B414A-78F3-45BB-A192-02970AD4529F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A05B414A-78F3-45BB-A192-02970AD4529F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A05B414A-78F3-45BB-A192-02970AD4529F}.Debug|x64.ActiveCfg = Debug|Any CPU + {A05B414A-78F3-45BB-A192-02970AD4529F}.Debug|x64.Build.0 = Debug|Any CPU + {A05B414A-78F3-45BB-A192-02970AD4529F}.Debug|x86.ActiveCfg = Debug|Any CPU + {A05B414A-78F3-45BB-A192-02970AD4529F}.Debug|x86.Build.0 = Debug|Any CPU + {A05B414A-78F3-45BB-A192-02970AD4529F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A05B414A-78F3-45BB-A192-02970AD4529F}.Release|Any CPU.Build.0 = Release|Any CPU + {A05B414A-78F3-45BB-A192-02970AD4529F}.Release|x64.ActiveCfg = Release|Any CPU + {A05B414A-78F3-45BB-A192-02970AD4529F}.Release|x64.Build.0 = Release|Any CPU + {A05B414A-78F3-45BB-A192-02970AD4529F}.Release|x86.ActiveCfg = Release|Any CPU + {A05B414A-78F3-45BB-A192-02970AD4529F}.Release|x86.Build.0 = Release|Any CPU + {23891100-FDC8-4D50-9AF9-9358036A46E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {23891100-FDC8-4D50-9AF9-9358036A46E2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {23891100-FDC8-4D50-9AF9-9358036A46E2}.Debug|x64.ActiveCfg = Debug|Any CPU + {23891100-FDC8-4D50-9AF9-9358036A46E2}.Debug|x64.Build.0 = Debug|Any CPU + {23891100-FDC8-4D50-9AF9-9358036A46E2}.Debug|x86.ActiveCfg = Debug|Any CPU + {23891100-FDC8-4D50-9AF9-9358036A46E2}.Debug|x86.Build.0 = Debug|Any CPU + {23891100-FDC8-4D50-9AF9-9358036A46E2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {23891100-FDC8-4D50-9AF9-9358036A46E2}.Release|Any CPU.Build.0 = Release|Any CPU + {23891100-FDC8-4D50-9AF9-9358036A46E2}.Release|x64.ActiveCfg = Release|Any CPU + {23891100-FDC8-4D50-9AF9-9358036A46E2}.Release|x64.Build.0 = Release|Any CPU + {23891100-FDC8-4D50-9AF9-9358036A46E2}.Release|x86.ActiveCfg = Release|Any CPU + {23891100-FDC8-4D50-9AF9-9358036A46E2}.Release|x86.Build.0 = Release|Any CPU + {3707415E-547B-48DD-A7FA-0A5F66377B90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3707415E-547B-48DD-A7FA-0A5F66377B90}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3707415E-547B-48DD-A7FA-0A5F66377B90}.Debug|x64.ActiveCfg = Debug|Any CPU + {3707415E-547B-48DD-A7FA-0A5F66377B90}.Debug|x64.Build.0 = Debug|Any CPU + {3707415E-547B-48DD-A7FA-0A5F66377B90}.Debug|x86.ActiveCfg = Debug|Any CPU + {3707415E-547B-48DD-A7FA-0A5F66377B90}.Debug|x86.Build.0 = Debug|Any CPU + {3707415E-547B-48DD-A7FA-0A5F66377B90}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3707415E-547B-48DD-A7FA-0A5F66377B90}.Release|Any CPU.Build.0 = Release|Any CPU + {3707415E-547B-48DD-A7FA-0A5F66377B90}.Release|x64.ActiveCfg = Release|Any CPU + {3707415E-547B-48DD-A7FA-0A5F66377B90}.Release|x64.Build.0 = Release|Any CPU + {3707415E-547B-48DD-A7FA-0A5F66377B90}.Release|x86.ActiveCfg = Release|Any CPU + {3707415E-547B-48DD-A7FA-0A5F66377B90}.Release|x86.Build.0 = Release|Any CPU + {E4520DEE-90AF-424B-B487-BE9FBE7177F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E4520DEE-90AF-424B-B487-BE9FBE7177F0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E4520DEE-90AF-424B-B487-BE9FBE7177F0}.Debug|x64.ActiveCfg = Debug|Any CPU + {E4520DEE-90AF-424B-B487-BE9FBE7177F0}.Debug|x64.Build.0 = Debug|Any CPU + {E4520DEE-90AF-424B-B487-BE9FBE7177F0}.Debug|x86.ActiveCfg = Debug|Any CPU + {E4520DEE-90AF-424B-B487-BE9FBE7177F0}.Debug|x86.Build.0 = Debug|Any CPU + {E4520DEE-90AF-424B-B487-BE9FBE7177F0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E4520DEE-90AF-424B-B487-BE9FBE7177F0}.Release|Any CPU.Build.0 = Release|Any CPU + {E4520DEE-90AF-424B-B487-BE9FBE7177F0}.Release|x64.ActiveCfg = Release|Any CPU + {E4520DEE-90AF-424B-B487-BE9FBE7177F0}.Release|x64.Build.0 = Release|Any CPU + {E4520DEE-90AF-424B-B487-BE9FBE7177F0}.Release|x86.ActiveCfg = Release|Any CPU + {E4520DEE-90AF-424B-B487-BE9FBE7177F0}.Release|x86.Build.0 = Release|Any CPU + {4505F9A5-5337-4DDF-97C2-9B0AFCE9FB80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4505F9A5-5337-4DDF-97C2-9B0AFCE9FB80}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4505F9A5-5337-4DDF-97C2-9B0AFCE9FB80}.Debug|x64.ActiveCfg = Debug|Any CPU + {4505F9A5-5337-4DDF-97C2-9B0AFCE9FB80}.Debug|x64.Build.0 = Debug|Any CPU + {4505F9A5-5337-4DDF-97C2-9B0AFCE9FB80}.Debug|x86.ActiveCfg = Debug|Any CPU + {4505F9A5-5337-4DDF-97C2-9B0AFCE9FB80}.Debug|x86.Build.0 = Debug|Any CPU + {4505F9A5-5337-4DDF-97C2-9B0AFCE9FB80}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4505F9A5-5337-4DDF-97C2-9B0AFCE9FB80}.Release|Any CPU.Build.0 = Release|Any CPU + {4505F9A5-5337-4DDF-97C2-9B0AFCE9FB80}.Release|x64.ActiveCfg = Release|Any CPU + {4505F9A5-5337-4DDF-97C2-9B0AFCE9FB80}.Release|x64.Build.0 = Release|Any CPU + {4505F9A5-5337-4DDF-97C2-9B0AFCE9FB80}.Release|x86.ActiveCfg = Release|Any CPU + {4505F9A5-5337-4DDF-97C2-9B0AFCE9FB80}.Release|x86.Build.0 = Release|Any CPU + {621A84B2-EDDE-42B1-9BF1-51C77E173224}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {621A84B2-EDDE-42B1-9BF1-51C77E173224}.Debug|Any CPU.Build.0 = Debug|Any CPU + {621A84B2-EDDE-42B1-9BF1-51C77E173224}.Debug|x64.ActiveCfg = Debug|Any CPU + {621A84B2-EDDE-42B1-9BF1-51C77E173224}.Debug|x64.Build.0 = Debug|Any CPU + {621A84B2-EDDE-42B1-9BF1-51C77E173224}.Debug|x86.ActiveCfg = Debug|Any CPU + {621A84B2-EDDE-42B1-9BF1-51C77E173224}.Debug|x86.Build.0 = Debug|Any CPU + {621A84B2-EDDE-42B1-9BF1-51C77E173224}.Release|Any CPU.ActiveCfg = Release|Any CPU + {621A84B2-EDDE-42B1-9BF1-51C77E173224}.Release|Any CPU.Build.0 = Release|Any CPU + {621A84B2-EDDE-42B1-9BF1-51C77E173224}.Release|x64.ActiveCfg = Release|Any CPU + {621A84B2-EDDE-42B1-9BF1-51C77E173224}.Release|x64.Build.0 = Release|Any CPU + {621A84B2-EDDE-42B1-9BF1-51C77E173224}.Release|x86.ActiveCfg = Release|Any CPU + {621A84B2-EDDE-42B1-9BF1-51C77E173224}.Release|x86.Build.0 = Release|Any CPU + {67138FD9-931F-4B53-A0AE-882FE065774D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {67138FD9-931F-4B53-A0AE-882FE065774D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {67138FD9-931F-4B53-A0AE-882FE065774D}.Debug|x64.ActiveCfg = Debug|Any CPU + {67138FD9-931F-4B53-A0AE-882FE065774D}.Debug|x64.Build.0 = Debug|Any CPU + {67138FD9-931F-4B53-A0AE-882FE065774D}.Debug|x86.ActiveCfg = Debug|Any CPU + {67138FD9-931F-4B53-A0AE-882FE065774D}.Debug|x86.Build.0 = Debug|Any CPU + {67138FD9-931F-4B53-A0AE-882FE065774D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {67138FD9-931F-4B53-A0AE-882FE065774D}.Release|Any CPU.Build.0 = Release|Any CPU + {67138FD9-931F-4B53-A0AE-882FE065774D}.Release|x64.ActiveCfg = Release|Any CPU + {67138FD9-931F-4B53-A0AE-882FE065774D}.Release|x64.Build.0 = Release|Any CPU + {67138FD9-931F-4B53-A0AE-882FE065774D}.Release|x86.ActiveCfg = Release|Any CPU + {67138FD9-931F-4B53-A0AE-882FE065774D}.Release|x86.Build.0 = Release|Any CPU + {CB028E34-8D23-4F50-BA6A-B7CFC4A585E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CB028E34-8D23-4F50-BA6A-B7CFC4A585E8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CB028E34-8D23-4F50-BA6A-B7CFC4A585E8}.Debug|x64.ActiveCfg = Debug|Any CPU + {CB028E34-8D23-4F50-BA6A-B7CFC4A585E8}.Debug|x64.Build.0 = Debug|Any CPU + {CB028E34-8D23-4F50-BA6A-B7CFC4A585E8}.Debug|x86.ActiveCfg = Debug|Any CPU + {CB028E34-8D23-4F50-BA6A-B7CFC4A585E8}.Debug|x86.Build.0 = Debug|Any CPU + {CB028E34-8D23-4F50-BA6A-B7CFC4A585E8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CB028E34-8D23-4F50-BA6A-B7CFC4A585E8}.Release|Any CPU.Build.0 = Release|Any CPU + {CB028E34-8D23-4F50-BA6A-B7CFC4A585E8}.Release|x64.ActiveCfg = Release|Any CPU + {CB028E34-8D23-4F50-BA6A-B7CFC4A585E8}.Release|x64.Build.0 = Release|Any CPU + {CB028E34-8D23-4F50-BA6A-B7CFC4A585E8}.Release|x86.ActiveCfg = Release|Any CPU + {CB028E34-8D23-4F50-BA6A-B7CFC4A585E8}.Release|x86.Build.0 = Release|Any CPU + {294A1093-94F5-4088-BF26-06F5BF8E84C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {294A1093-94F5-4088-BF26-06F5BF8E84C2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {294A1093-94F5-4088-BF26-06F5BF8E84C2}.Debug|x64.ActiveCfg = Debug|Any CPU + {294A1093-94F5-4088-BF26-06F5BF8E84C2}.Debug|x64.Build.0 = Debug|Any CPU + {294A1093-94F5-4088-BF26-06F5BF8E84C2}.Debug|x86.ActiveCfg = Debug|Any CPU + {294A1093-94F5-4088-BF26-06F5BF8E84C2}.Debug|x86.Build.0 = Debug|Any CPU + {294A1093-94F5-4088-BF26-06F5BF8E84C2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {294A1093-94F5-4088-BF26-06F5BF8E84C2}.Release|Any CPU.Build.0 = Release|Any CPU + {294A1093-94F5-4088-BF26-06F5BF8E84C2}.Release|x64.ActiveCfg = Release|Any CPU + {294A1093-94F5-4088-BF26-06F5BF8E84C2}.Release|x64.Build.0 = Release|Any CPU + {294A1093-94F5-4088-BF26-06F5BF8E84C2}.Release|x86.ActiveCfg = Release|Any CPU + {294A1093-94F5-4088-BF26-06F5BF8E84C2}.Release|x86.Build.0 = Release|Any CPU + {9F4BB42E-61A6-4970-951C-883CAA0CA25D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9F4BB42E-61A6-4970-951C-883CAA0CA25D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9F4BB42E-61A6-4970-951C-883CAA0CA25D}.Debug|x64.ActiveCfg = Debug|Any CPU + {9F4BB42E-61A6-4970-951C-883CAA0CA25D}.Debug|x64.Build.0 = Debug|Any CPU + {9F4BB42E-61A6-4970-951C-883CAA0CA25D}.Debug|x86.ActiveCfg = Debug|Any CPU + {9F4BB42E-61A6-4970-951C-883CAA0CA25D}.Debug|x86.Build.0 = Debug|Any CPU + {9F4BB42E-61A6-4970-951C-883CAA0CA25D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9F4BB42E-61A6-4970-951C-883CAA0CA25D}.Release|Any CPU.Build.0 = Release|Any CPU + {9F4BB42E-61A6-4970-951C-883CAA0CA25D}.Release|x64.ActiveCfg = Release|Any CPU + {9F4BB42E-61A6-4970-951C-883CAA0CA25D}.Release|x64.Build.0 = Release|Any CPU + {9F4BB42E-61A6-4970-951C-883CAA0CA25D}.Release|x86.ActiveCfg = Release|Any CPU + {9F4BB42E-61A6-4970-951C-883CAA0CA25D}.Release|x86.Build.0 = Release|Any CPU + {FBA9638A-1A71-4587-AADD-1F133ACF8E1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FBA9638A-1A71-4587-AADD-1F133ACF8E1A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FBA9638A-1A71-4587-AADD-1F133ACF8E1A}.Debug|x64.ActiveCfg = Debug|Any CPU + {FBA9638A-1A71-4587-AADD-1F133ACF8E1A}.Debug|x64.Build.0 = Debug|Any CPU + {FBA9638A-1A71-4587-AADD-1F133ACF8E1A}.Debug|x86.ActiveCfg = Debug|Any CPU + {FBA9638A-1A71-4587-AADD-1F133ACF8E1A}.Debug|x86.Build.0 = Debug|Any CPU + {FBA9638A-1A71-4587-AADD-1F133ACF8E1A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FBA9638A-1A71-4587-AADD-1F133ACF8E1A}.Release|Any CPU.Build.0 = Release|Any CPU + {FBA9638A-1A71-4587-AADD-1F133ACF8E1A}.Release|x64.ActiveCfg = Release|Any CPU + {FBA9638A-1A71-4587-AADD-1F133ACF8E1A}.Release|x64.Build.0 = Release|Any CPU + {FBA9638A-1A71-4587-AADD-1F133ACF8E1A}.Release|x86.ActiveCfg = Release|Any CPU + {FBA9638A-1A71-4587-AADD-1F133ACF8E1A}.Release|x86.Build.0 = Release|Any CPU + {FA69CB05-1C56-43CD-948B-28A6D8643713}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA69CB05-1C56-43CD-948B-28A6D8643713}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA69CB05-1C56-43CD-948B-28A6D8643713}.Debug|x64.ActiveCfg = Debug|Any CPU + {FA69CB05-1C56-43CD-948B-28A6D8643713}.Debug|x64.Build.0 = Debug|Any CPU + {FA69CB05-1C56-43CD-948B-28A6D8643713}.Debug|x86.ActiveCfg = Debug|Any CPU + {FA69CB05-1C56-43CD-948B-28A6D8643713}.Debug|x86.Build.0 = Debug|Any CPU + {FA69CB05-1C56-43CD-948B-28A6D8643713}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA69CB05-1C56-43CD-948B-28A6D8643713}.Release|Any CPU.Build.0 = Release|Any CPU + {FA69CB05-1C56-43CD-948B-28A6D8643713}.Release|x64.ActiveCfg = Release|Any CPU + {FA69CB05-1C56-43CD-948B-28A6D8643713}.Release|x64.Build.0 = Release|Any CPU + {FA69CB05-1C56-43CD-948B-28A6D8643713}.Release|x86.ActiveCfg = Release|Any CPU + {FA69CB05-1C56-43CD-948B-28A6D8643713}.Release|x86.Build.0 = Release|Any CPU + {DB29B0EB-D78C-4554-8512-FF4E54451D14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DB29B0EB-D78C-4554-8512-FF4E54451D14}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DB29B0EB-D78C-4554-8512-FF4E54451D14}.Debug|x64.ActiveCfg = Debug|Any CPU + {DB29B0EB-D78C-4554-8512-FF4E54451D14}.Debug|x64.Build.0 = Debug|Any CPU + {DB29B0EB-D78C-4554-8512-FF4E54451D14}.Debug|x86.ActiveCfg = Debug|Any CPU + {DB29B0EB-D78C-4554-8512-FF4E54451D14}.Debug|x86.Build.0 = Debug|Any CPU + {DB29B0EB-D78C-4554-8512-FF4E54451D14}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DB29B0EB-D78C-4554-8512-FF4E54451D14}.Release|Any CPU.Build.0 = Release|Any CPU + {DB29B0EB-D78C-4554-8512-FF4E54451D14}.Release|x64.ActiveCfg = Release|Any CPU + {DB29B0EB-D78C-4554-8512-FF4E54451D14}.Release|x64.Build.0 = Release|Any CPU + {DB29B0EB-D78C-4554-8512-FF4E54451D14}.Release|x86.ActiveCfg = Release|Any CPU + {DB29B0EB-D78C-4554-8512-FF4E54451D14}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/BLAZAM/5e4052c4-0bc0-407c-99bd-ba6dabbccc72.txt b/BLAZAM/5e4052c4-0bc0-407c-99bd-ba6dabbccc72.txt deleted file mode 100644 index 30d74d25..00000000 --- a/BLAZAM/5e4052c4-0bc0-407c-99bd-ba6dabbccc72.txt +++ /dev/null @@ -1 +0,0 @@ -test \ No newline at end of file diff --git a/BLAZAM/93e03b61-4a6b-4987-bb36-05a2869286c4.txt b/BLAZAM/93e03b61-4a6b-4987-bb36-05a2869286c4.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/BLAZAM/App.razor b/BLAZAM/App.razor index 9627c51b..2573b45b 100644 --- a/BLAZAM/App.razor +++ b/BLAZAM/App.razor @@ -1,19 +1,13 @@ -@using BLAZAM.Server.Shared.Layouts; -@using BLAZAM.Common.Data.ActiveDirectory.Interfaces; -@using BLAZAM.Server.Data.Services.Email; -@using System.Diagnostics; -@using BLAZAM.Server.Shared.UI.Themes; -@using Microsoft.AspNetCore.Authentication.Cookies; -@using Microsoft.Extensions.Options; + @inject IHttpContextAccessor context @inject IApplicationUserStateService userStateService -@**@ +@inject ICurrentUserStateService currentUser - + @@ -22,13 +16,12 @@ Authorizing... - @if (!context.User.Identity?.IsAuthenticated == true) + @if (context.User.Identity?.IsAuthenticated != true) { Login - + - @**@ } else { @@ -53,7 +46,6 @@ - @@ -65,37 +57,39 @@ -@* - *@ - - + -@**@ - @code { - - - ApplicationTheme activeTheme = new LightTheme(); + bool darkMode = false; + ApplicationTheme activeTheme = new BlueTheme(); protected override void OnInitialized() { base.OnInitialized(); - var userTheme = userStateService.CurrentUserState?.UserSettings?.Theme; - switch (userTheme) + try { - case "Light": - default: - activeTheme = new LightTheme(); - break; - case "Dark": - activeTheme = new DarkTheme(); - break; - - + var userTheme = currentUser.State.Preferences?.Theme; + switch (userTheme) + { + case "Blue": + default: + activeTheme = new BlueTheme(); + break; + case "Red": + activeTheme = new RedTheme(); + break; + + + } + darkMode = currentUser.State.Preferences?.DarkMode == true; + } + catch(Exception ex) + { + Loggers.SystemLogger.Error("Error while fetching user theme: {Message}", ex); } } diff --git a/BLAZAM/AppUserPageTracker.razor b/BLAZAM/AppUserPageTracker.razor deleted file mode 100644 index e8026c5a..00000000 --- a/BLAZAM/AppUserPageTracker.razor +++ /dev/null @@ -1,8 +0,0 @@ -@inject NavigationManager Nav -@inject IApplicationUserStateService UserStateService - -@{ - -} - - diff --git a/BLAZAM/BLAZAM - Backup (1).csproj b/BLAZAM/BLAZAM - Backup (1).csproj deleted file mode 100644 index 80a4cc61..00000000 --- a/BLAZAM/BLAZAM - Backup (1).csproj +++ /dev/null @@ -1,172 +0,0 @@ - - - - net6.0 - enable - enable - false - 0.6.7 - 2023.03.04.0027 - BLAZAM.Server - False - - - - - - - - - - - - - - - - - - - - - - Always - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - True - Resources.resx - - - True - True - AppLocalization.resx - - - True - True - SettingsLocalization.resx - - - True - True - UserLocalization.resx - - - - - - Never - - - PreserveNewest - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - - PublicResXFileCodeGenerator - - - PublicResXFileCodeGenerator - AppLocalization.Designer.cs - - - PublicResXFileCodeGenerator - SettingsLocalization.Designer.cs - - - PublicResXFileCodeGenerator - - - PublicResXFileCodeGenerator - UserLocalization.Designer.cs - - - - - - PreserveNewest - - - PreserveNewest - - - - - - diff --git a/BLAZAM/BLAZAM - Backup (2).csproj b/BLAZAM/BLAZAM - Backup (2).csproj deleted file mode 100644 index 4fc8dfb6..00000000 --- a/BLAZAM/BLAZAM - Backup (2).csproj +++ /dev/null @@ -1,173 +0,0 @@ - - - - net6.0 - enable - enable - false - 0.6.7 - 2023.03.11.1451 - BLAZAM.Server - False - - - - - - - - - - - - - - - - - - - - - - Always - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - True - Resources.resx - - - True - True - AppLocalization.resx - - - True - True - SettingsLocalization.resx - - - True - True - UserLocalization.resx - - - - - - Never - - - PreserveNewest - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - - PublicResXFileCodeGenerator - - - PublicResXFileCodeGenerator - AppLocalization.Designer.cs - - - PublicResXFileCodeGenerator - SettingsLocalization.Designer.cs - - - PublicResXFileCodeGenerator - - - PublicResXFileCodeGenerator - UserLocalization.Designer.cs - - - - - - PreserveNewest - - - PreserveNewest - - - - - - diff --git a/BLAZAM/BLAZAM - Backup (3).csproj b/BLAZAM/BLAZAM - Backup (3).csproj deleted file mode 100644 index 53570fb8..00000000 --- a/BLAZAM/BLAZAM - Backup (3).csproj +++ /dev/null @@ -1,169 +0,0 @@ - - - - net6.0 - enable - enable - false - 0.7.0 - 2023.03.17.1341 - BLAZAM.Server - False - - - - - - - - - - - - - - - - - - - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - True - Resources.resx - - - True - True - AppLocalization.resx - - - True - True - SettingsLocalization.resx - - - True - True - UserLocalization.resx - - - - - - PreserveNewest - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - - PublicResXFileCodeGenerator - - - PublicResXFileCodeGenerator - AppLocalization.Designer.cs - - - PublicResXFileCodeGenerator - SettingsLocalization.Designer.cs - - - PublicResXFileCodeGenerator - - - PublicResXFileCodeGenerator - UserLocalization.Designer.cs - - - - - - PreserveNewest - - - PreserveNewest - - - - - - diff --git a/BLAZAM/BLAZAM - Backup.csproj b/BLAZAM/BLAZAM - Backup.csproj index 30b6d710..607a6568 100644 --- a/BLAZAM/BLAZAM - Backup.csproj +++ b/BLAZAM/BLAZAM - Backup.csproj @@ -5,8 +5,8 @@ enable enable false - 0.6.6 - 2023.02.19.1601 + 0.7.5 + 2023.04.07.2256 BLAZAM.Server False @@ -29,9 +29,6 @@ - - Always - PreserveNewest @@ -44,20 +41,11 @@ - - - - - - - - - - + @@ -67,6 +55,7 @@ + all @@ -81,23 +70,27 @@ + + + + - + + - @@ -124,9 +117,6 @@ - - Never - PreserveNewest @@ -166,6 +156,6 @@ - + diff --git a/BLAZAM/BLAZAM.csproj b/BLAZAM/BLAZAM.csproj index 7f0456cf..d966d1e0 100644 --- a/BLAZAM/BLAZAM.csproj +++ b/BLAZAM/BLAZAM.csproj @@ -5,18 +5,18 @@ enable enable false - 0.7.5 - 2023.04.02.0019 - BLAZAM.Server + 0.8.2 + 2023.05.12.1934 + BLAZAM False - - - - + + + + @@ -25,6 +25,7 @@ + @@ -46,50 +47,60 @@ - + - - + + - - - - - - - + + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + - - - - - + + + - - + + - + - - - + + + + + + + + + + + + + + + @@ -98,21 +109,6 @@ True Resources.resx - - True - True - AppLocalization.resx - - - True - True - SettingsLocalization.resx - - - True - True - UserLocalization.resx - @@ -126,24 +122,6 @@ ResXFileCodeGenerator Resources.Designer.cs - - PublicResXFileCodeGenerator - - - PublicResXFileCodeGenerator - AppLocalization.Designer.cs - - - PublicResXFileCodeGenerator - SettingsLocalization.Designer.cs - - - PublicResXFileCodeGenerator - - - PublicResXFileCodeGenerator - UserLocalization.Designer.cs - diff --git a/BLAZAM/Data/ChatMessage.cs b/BLAZAM/Data/ChatMessage.cs deleted file mode 100644 index ad25896a..00000000 --- a/BLAZAM/Data/ChatMessage.cs +++ /dev/null @@ -1,16 +0,0 @@ -using BLAZAM.Common.Models.Database.User; - -namespace BLAZAM.Server.Data -{ - public class ChatMessage - { - public AppUser User { get; set; } - public DateTime Timestamp { get; private set; } - public string Message { get; set; } - public List SeenBy { get; set; } = new(); - public ChatMessage() - { - Timestamp = DateTime.UtcNow; - } - } -} diff --git a/BLAZAM/Data/Services/AppNavigationManager.cs b/BLAZAM/Data/Services/AppNavigationManager.cs deleted file mode 100644 index 76d12744..00000000 --- a/BLAZAM/Data/Services/AppNavigationManager.cs +++ /dev/null @@ -1,45 +0,0 @@ -using Microsoft.AspNetCore.Components; - -namespace BLAZAM.Server.Data.Services -{ - public class AppNavigationManager - { - NavigationManager NavigationManager { get; set; } - - public AppNavigationManager(NavigationManager navigationManager) - { - NavigationManager = navigationManager; - } - /// - /// Navigates to the specified URI. - /// - /// The destination URI. This can be absolute, or relative to the base URI - /// (as returned by ). - /// If true, bypasses client-side routing and forces the browser to load the new page from the server, whether or not the URI would normally be handled by the client-side router. - /// If true, replaces the current entry in the history stack. If false, appends the new entry to the history stack. - public void NavigateTo(string uri, bool forceLoad = false, bool replace = false) - { - NavigationManager.NavigateTo(uri, forceLoad, replace); - } - - /// - /// Gets or sets the current base URI. The is always represented as an absolute URI in string form with trailing slash. - /// Typically this corresponds to the 'href' attribute on the document's <base> element. - /// - /// - /// Setting will not trigger the event. - /// - public string BaseUri=>NavigationManager.BaseUri; - - - /// - /// Gets or sets the current URI. The is always represented as an absolute URI in string form. - /// - /// - /// Setting will not trigger the event. - /// - public string Uri => NavigationManager.BaseUri; - - - } -} diff --git a/BLAZAM/Data/Services/ApplicationUserState.cs b/BLAZAM/Data/Services/ApplicationUserState.cs deleted file mode 100644 index be87a02c..00000000 --- a/BLAZAM/Data/Services/ApplicationUserState.cs +++ /dev/null @@ -1,203 +0,0 @@ -using BLAZAM.Common.Data; -using BLAZAM.Common.Data.ActiveDirectory.Interfaces; -using BLAZAM.Common.Data.Database; -using BLAZAM.Common.Data.Services; -using BLAZAM.Common.Models.Database.User; -using Microsoft.AspNetCore.Authentication; -using Microsoft.EntityFrameworkCore; -using System.Security.Claims; - -namespace BLAZAM.Server.Data.Services -{ - /// - /// An application user state as managed by the - /// - /// - /// Holds the of the user defined from logging - /// in, and an impersonated claim if applied. - /// - /// It also holds the - /// if set, and through that, permissions can be applied. - /// - public class ApplicationUserState : IApplicationUserState - { - - public AppEvent OnSettingsChange { get; set; } - /// - /// The web user who is currently logged in - /// - public ClaimsPrincipal User { get; set; } - /// - /// The user who is impersonating this web user. It is optional, obviously. - /// - public ClaimsPrincipal? Impersonator { get; set; } - /// - /// The which also provided the applied permissions. - /// - public IADUser? DirectoryUser { get; set; } - /// - /// The last request time for this web user - /// - public DateTime LastAccessed { get; set; } = DateTime.UtcNow; - - public IList Messages { get; set; } = new List(); - - public IApplicationUserSessionCache Cache { get; set; } = new ApplicationUserSessionCache(); - - public AuthenticationTicket? Ticket { get; set; } - - public AppUser? userSettings { get; set; } - private readonly AppDatabaseFactory _dbFactory; - - public ApplicationUserState(AppDatabaseFactory factory) - { - _dbFactory = factory; - } - - - - - /// - /// Provides access to the user's settings in the database - /// - /// - /// Changes made to the returned object are not saved - /// until is called - /// - public AppUser? UserSettings - { - get - { - if (!User.Identity.IsAuthenticated) return null; - if (userSettings == null) - { - try - { - using var context = _dbFactory.CreateDbContext(); - userSettings = context.UserSettings.Where(us => us.UserGUID == User.FindFirstValue(ClaimTypes.Sid)).FirstOrDefault(); - if (userSettings == null) - { - userSettings = new AppUser(); - userSettings.UserGUID = User.FindFirstValue(ClaimTypes.Sid); - userSettings.Username = User.Identity?.Name; - context.UserSettings.Add(userSettings); - context.SaveChanges(); - - } - } - catch - { - - } - } - return userSettings; - } - } - /// - /// Saves the current state of the to the database - /// - /// - public async Task SaveUserSettings() - { - try - { - using var context = await _dbFactory.CreateDbContextAsync(); - var dbUserSettings = await context.UserSettings.Where(us => us.UserGUID == User.FindFirstValue(ClaimTypes.Sid)).FirstOrDefaultAsync(); - if (dbUserSettings != null) - { - dbUserSettings.Theme = this.UserSettings?.Theme; - dbUserSettings.SearchDisabledUsers = this.UserSettings.SearchDisabledUsers; - dbUserSettings.SearchDisabledComputers = this.UserSettings.SearchDisabledComputers; - OnSettingsChange?.Invoke(dbUserSettings); - - return (await context.SaveChangesAsync()) > 0; - } - - } - catch - { - - } - return false; - } - public bool IsSuperAdmin - { - get - { - if (User.Claims.Any(c => c.Type == ClaimTypes.Role && c.Value == UserRoles.SuperAdmin)) return true; - if (DirectoryUser != null) - return DirectoryUser.PermissionDelegates.Any(p => p.IsSuperAdmin); - return false; - } - } - /// - /// Returns the name of the user - /// - public string? Username - { - get - { - string? auditUsername = User.Identity?.Name; - - return auditUsername; - } - } - - public bool IsAuthenticated - { - get - { - try - { - return User.Identity.IsAuthenticated; - } - catch - { - return false; - } - } - } - - /// - /// Returns the combined names of the user, and if applicable, the impersonators username - /// with the structure "{username}[ impersonated by {impersonatorName}]" - /// - public string? AuditUsername - { - get - { - string? auditUsername = Username; - if (Impersonator != null) - { - auditUsername += " impersonated by " + Impersonator?.Identity?.Name; - } - return auditUsername; - } - } - - public string LastUri { get; set; } - - public override int GetHashCode() - { - return User.GetHashCode(); - } - public override bool Equals(object? obj) - { - if (obj is ApplicationUserState otherState) - { - - if (otherState.User.FindFirstValue(ClaimTypes.Sid) == this.User.FindFirstValue(ClaimTypes.Sid) - && otherState.User.FindFirstValue(ClaimTypes.Actor) == User.FindFirstValue(ClaimTypes.Actor)) - { - return true; - } - } - return false; - } - - public bool HasRole(string userRole) - { - return User.HasClaim(ClaimTypes.Role, userRole); - } - } -} \ No newline at end of file diff --git a/BLAZAM/Data/Services/LoginPermissionApplicator.cs b/BLAZAM/Data/Services/LoginPermissionApplicator.cs deleted file mode 100644 index 26875590..00000000 --- a/BLAZAM/Data/Services/LoginPermissionApplicator.cs +++ /dev/null @@ -1,54 +0,0 @@ -using BLAZAM.Common.Data.ActiveDirectory; -using BLAZAM.Common.Data.ActiveDirectory.Interfaces; -using BLAZAM.Common.Data.Database; -using BLAZAM.Common.Data.Services; -using BLAZAM.Common.Models.Database.Permissions; -using Microsoft.EntityFrameworkCore; -namespace BLAZAM.Server.Data.Services -{ - public class LoginPermissionApplicator - { - protected AppDatabaseFactory Factory { get; set; } - protected IActiveDirectory Directory { get; set; } - - public LoginPermissionApplicator(AppDatabaseFactory factory, IActiveDirectory directory) - { - Factory = factory; - Directory = directory; - directory.OnNewLoginUser += LoadPermissionsForNewLoginUser; - } - - private async void LoadPermissionsForNewLoginUser(IApplicationUserState value) - { - if (value.DirectoryUser != null) - await LoadPermissions(value.DirectoryUser); - - } - - - internal async Task LoadPermissions(IADUser user) - { - using (var Context = await Factory.CreateDbContextAsync()) - { - var cursor = await Context.PermissionDelegate.Include(pl => pl.PermissionsMaps).ToListAsync(); - foreach (var l in cursor) - { - - - var permissiondelegate = ActiveDirectoryContext.Instance.GetDirectoryModelBySid(l.DelegateSid); - if (permissiondelegate != null) - { - if (user.Equals(permissiondelegate) - || (permissiondelegate is IADGroup delegateGroup && user.IsAMemberOf(delegateGroup)) - ) - { - user.PermissionDelegates.Add(l); - user.PermissionMappings.AddRange(l.PermissionsMaps); - } - } - } - - } - } - } -} diff --git a/BLAZAM/Data/Services/Update/UpdateServiceBase.cs b/BLAZAM/Data/Services/Update/UpdateServiceBase.cs deleted file mode 100644 index f9db368f..00000000 --- a/BLAZAM/Data/Services/Update/UpdateServiceBase.cs +++ /dev/null @@ -1,105 +0,0 @@ -using BLAZAM.Common; -using Microsoft.TeamFoundation.Build.WebApi; -using Microsoft.VisualStudio.Services.Common; -using Microsoft.VisualStudio.Services.WebApi; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Octokit; -using System.Collections; -using System.Net; -using System.Net.Http.Formatting; -using System.Reflection; - -namespace BLAZAM.Server.Data.Services.Update -{ - public class UpdateServiceBase - { - - - - private MediaTypeFormatter m_formatter = new VssJsonMediaTypeFormatter(); - - protected Timer _updateCheckTimer; - - protected async Task ReadContentAsAsync(HttpResponseMessage response, CancellationToken cancellationToken = default) - { - CheckForDisposed(); - bool flag = IsJsonResponse(response); - bool isMismatchedContentType = false; - try - { - if (flag && typeof(IEnumerable).GetTypeInfo().IsAssignableFrom(typeof(T).GetTypeInfo()) && !typeof(byte[]).GetTypeInfo().IsAssignableFrom(typeof(T).GetTypeInfo()) && !typeof(JObject).GetTypeInfo().IsAssignableFrom(typeof(T).GetTypeInfo())) - { - return (await ReadJsonContentAsync>(response, cancellationToken).ConfigureAwait(continueOnCapturedContext: false)).Value; - } - - if (flag) - { - return await ReadJsonContentAsync(response, cancellationToken).ConfigureAwait(continueOnCapturedContext: false); - } - } - catch (JsonReaderException) - { - isMismatchedContentType = true; - } - - if (HasContent(response)) - { - return await HandleInvalidContentType(response, isMismatchedContentType).ConfigureAwait(continueOnCapturedContext: false); - } - - return default; - } - protected virtual async Task ReadJsonContentAsync(HttpResponseMessage response, CancellationToken cancellationToken = default) - { - return await response.Content.ReadAsAsync(new MediaTypeFormatter[1] { m_formatter }, cancellationToken).ConfigureAwait(continueOnCapturedContext: false); - } - - private void CheckForDisposed() - { - - } - - private async Task HandleInvalidContentType(HttpResponseMessage response, bool isMismatchedContentType) - { - string responseType = response.Content?.Headers?.ContentType?.MediaType ?? "Unknown"; - using Stream responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(continueOnCapturedContext: false); - using StreamReader streamReader = new StreamReader(responseStream); - char[] contentBuffer = new char[4096]; - int contentLength = 0; - for (int i = 0; i < 4; i++) - { - int num = await streamReader.ReadAsync(contentBuffer, i * 1024, 1024).ConfigureAwait(continueOnCapturedContext: false); - contentLength += num; - if (num < 1024) - { - break; - } - } - - throw new VssServiceResponseException(message: !isMismatchedContentType ? $"Invalid response content type: {responseType} Response Content: {new string(contentBuffer, 0, contentLength)}" : $"Mismatched response content type. {responseType} Response Content: {new string(contentBuffer, 0, contentLength)}", code: response.StatusCode, innerException: null); - } - private bool HasContent(HttpResponseMessage response) - { - if (response != null && response.StatusCode != HttpStatusCode.NoContent && response.RequestMessage?.Method != HttpMethod.Head && response.Content?.Headers != null && (!response.Content.Headers.ContentLength.HasValue || response.Content.Headers.ContentLength.HasValue && response.Content.Headers.ContentLength != 0)) - { - return true; - } - - return false; - } - private bool IsJsonResponse(HttpResponseMessage response) - { - if (HasContent(response) && response.Content.Headers != null && response.Content.Headers.ContentType != null && !string.IsNullOrEmpty(response.Content.Headers.ContentType!.MediaType)) - { - return string.Compare("application/json", response.Content.Headers.ContentType!.MediaType, StringComparison.OrdinalIgnoreCase) == 0; - } - - return false; - } - - - - - } -} \ No newline at end of file diff --git a/BLAZAM/GlobalUsings.cs b/BLAZAM/GlobalUsings.cs new file mode 100644 index 00000000..7079d615 --- /dev/null +++ b/BLAZAM/GlobalUsings.cs @@ -0,0 +1,5 @@ +global using BLAZAM.Logger; +global using BLAZAM.FileSystem; +global using BLAZAM.Helpers; +global using BLAZAM.Common.Exceptions; + diff --git a/BLAZAM/Middleware/ApplicationStatusRedirectMiddleware.cs b/BLAZAM/Middleware/ApplicationStatusRedirectMiddleware.cs index 6bb91845..7046392d 100644 --- a/BLAZAM/Middleware/ApplicationStatusRedirectMiddleware.cs +++ b/BLAZAM/Middleware/ApplicationStatusRedirectMiddleware.cs @@ -1,7 +1,8 @@ using BLAZAM.Common.Data; using BLAZAM.Common.Data.Database; -using BLAZAM.Server.Background; -using BLAZAM.Server.Pages.Error; +using BLAZAM.Database.Context; +using BLAZAM.Pages.Error; +using BLAZAM.Services.Background; using Microsoft.EntityFrameworkCore; namespace BLAZAM.Server.Middleware @@ -21,7 +22,7 @@ public ApplicationStatusRedirectMiddleware( _monitor = monitor; } - public async Task InvokeAsync(HttpContext context, AppDatabaseFactory factory) + public async Task InvokeAsync(HttpContext context, IAppDatabaseFactory factory) { intendedUri = context.Request.Path.ToUriComponent(); if (!InIgnoreList(intendedUri)) @@ -34,9 +35,8 @@ public async Task InvokeAsync(HttpContext context, AppDatabaseFactory factory) SendTo(context, "/"); break; case ServiceConnectionState.Up: - var appliedSeedMigration = factory.CreateDbContext().AppliedMigrations.Where(m => m.Contains("seed", StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); - var stagedSeedMigration = factory.CreateDbContext().PendingMigrations.Where(m => m.Contains("seed", StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); - if(appliedSeedMigration!=null && stagedSeedMigration !=null) + var dbcontext = factory.CreateDbContext(); + if(dbcontext.SeedMismatch) { Oops.ErrorMessage = "The application database is incompatible with this version of the application"; Oops.DetailsMessage = "The database seed is different from the current version of the application"; @@ -44,7 +44,7 @@ public async Task InvokeAsync(HttpContext context, AppDatabaseFactory factory) SendTo(context, "/oops"); } - if (!Program.InstallationCompleted) + if (!ApplicationInfo.installationCompleted) { SendTo(context,"/install"); } diff --git a/BLAZAM/Middleware/HttpsRedirectionMiddleware.cs b/BLAZAM/Middleware/HttpsRedirectionMiddleware.cs index 901e7b17..2778c70f 100644 --- a/BLAZAM/Middleware/HttpsRedirectionMiddleware.cs +++ b/BLAZAM/Middleware/HttpsRedirectionMiddleware.cs @@ -1,6 +1,4 @@ -using BLAZAM.Server.Background; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Caching.Memory; +using BLAZAM.Services.Background; namespace BLAZAM.Server.Middleware { diff --git a/BLAZAM/Middleware/UserStateMiddleware.cs b/BLAZAM/Middleware/UserStateMiddleware.cs new file mode 100644 index 00000000..2ac34448 --- /dev/null +++ b/BLAZAM/Middleware/UserStateMiddleware.cs @@ -0,0 +1,36 @@ +using BLAZAM.Common.Data.Services; +using BLAZAM.Session.Interfaces; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using System.Threading.Tasks; + +namespace BLAZAM.Server.Middleware +{ + /// + /// Captures the web browser's authentication cookie to populate the CurrentUserStateService + /// + public class UserStateMiddleware + { + private readonly RequestDelegate _next; + + public UserStateMiddleware(RequestDelegate next) + { + _next = next; + } + + public Task Invoke(HttpContext httpContext,ICurrentUserStateService currentUserStateService,IApplicationUserStateService userStateService) + { + currentUserStateService.State = userStateService.GetUserState(httpContext.User); + return _next(httpContext); + } + } + + // Extension method used to add the middleware to the HTTP request pipeline. + public static class UserStateMiddlewareExtensions + { + public static IApplicationBuilder UseUserStateMiddleware(this IApplicationBuilder builder) + { + return builder.UseMiddleware(); + } + } +} diff --git a/BLAZAM/MudMessageProvider.razor b/BLAZAM/MudMessageProvider.razor deleted file mode 100644 index fc82005a..00000000 --- a/BLAZAM/MudMessageProvider.razor +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/BLAZAM/MudPageProgressProvider.razor b/BLAZAM/MudPageProgressProvider.razor deleted file mode 100644 index e69de29b..00000000 diff --git a/BLAZAM/Pages/API/Auth/KeepAlive.cshtml.cs b/BLAZAM/Pages/API/Auth/KeepAlive.cshtml.cs index 4f9a0d86..549817db 100644 --- a/BLAZAM/Pages/API/Auth/KeepAlive.cshtml.cs +++ b/BLAZAM/Pages/API/Auth/KeepAlive.cshtml.cs @@ -1,5 +1,4 @@ -using BLAZAM.Common.Data.Services; -using BLAZAM.Common.Extensions; + using BLAZAM.Server.Data.Services; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; @@ -13,16 +12,18 @@ public class KeepAliveModel : PageModel public IActionResult OnGet() { - var test = HttpContext.SessionTimeout(); - if (HttpContext.User.Identity.IsAuthenticated) + var response = new Dictionary(); + if (HttpContext.User.Identity?.IsAuthenticated==true) HttpContext.SlideCookieExpiration(ApplicationUserStateService.Instance.GetUserState(HttpContext.User)); else { - var redirectResponse = new Dictionary() { { "expired", "true" } }; - return new JsonResult(redirectResponse); + response.Add("expired", "true"); + return new JsonResult(response); } - - return new OkResult(); + response.Add("expired", "false"); + return new JsonResult(response); + + //return new OkResult(); } diff --git a/BLAZAM/Pages/API/Auth/KeepAliveNew.cs b/BLAZAM/Pages/API/Auth/KeepAliveNew.cs deleted file mode 100644 index b5931bdf..00000000 --- a/BLAZAM/Pages/API/Auth/KeepAliveNew.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Microsoft.AspNetCore.Mvc; - -namespace BLAZAM.Server.Pages.API.Auth -{ - public class KeepAliveNew : Controller - { - public IActionResult Index() - { - return View(); - } - } -} diff --git a/BLAZAM/Pages/API/Token.cshtml.cs b/BLAZAM/Pages/API/Token.cshtml.cs index a0eb5f4c..c116db7a 100644 --- a/BLAZAM/Pages/API/Token.cshtml.cs +++ b/BLAZAM/Pages/API/Token.cshtml.cs @@ -1,6 +1,7 @@ +using BLAZAM.Common.Data; using BLAZAM.Common.Data.Database; -using BLAZAM.Common.Models.Database; -using BLAZAM.Common.Models.Database.User; +using BLAZAM.Database.Context; +using BLAZAM.Database.Models.User; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; @@ -32,7 +33,7 @@ public JsonResult OnGet() } var claims = new[] { new Claim(ClaimTypes.Name, user) }; - var credentials = new SigningCredentials(Program.TokenKey, SecurityAlgorithms.HmacSha256); + var credentials = new SigningCredentials(ApplicationInfo.tokenKey, SecurityAlgorithms.HmacSha256); var token = new JwtSecurityToken("ExampleServer", "ExampleClients", claims, expires: DateTime.Now.AddSeconds(60), signingCredentials: credentials); Token = JwtTokenHandler.WriteToken(token); var userSettings = Context.UserSettings.Where(u => u.UserGUID == this.User.Identity.Name).FirstOrDefault(); diff --git a/BLAZAM/Pages/API/ValidateUpdateToken.cshtml.cs b/BLAZAM/Pages/API/ValidateUpdateToken.cshtml.cs index acbfc655..62200d55 100644 --- a/BLAZAM/Pages/API/ValidateUpdateToken.cshtml.cs +++ b/BLAZAM/Pages/API/ValidateUpdateToken.cshtml.cs @@ -1,4 +1,5 @@ using BLAZAM.Server.Data.Services; +using BLAZAM.Services; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; diff --git a/BLAZAM/Pages/Benchmark.razor b/BLAZAM/Pages/Benchmark.razor index ee7c0518..9528fb3f 100644 --- a/BLAZAM/Pages/Benchmark.razor +++ b/BLAZAM/Pages/Benchmark.razor @@ -1,7 +1,7 @@ -@inject AppDatabaseFactory factory +@inject IAppDatabaseFactory factory @page "/benchmark" -@inject IActiveDirectory Dir +@inject IActiveDirectoryContext Dir

Benchmark

Number of cycles

@@ -15,7 +15,6 @@

User Bench

email: @userBench?.SamAccountName

- @code { #nullable disable warnings ActiveDirectoryContext ad; @@ -54,7 +53,7 @@ } - bool DirectoryTest(IActiveDirectory dir) + bool DirectoryTest(IActiveDirectoryContext dir) { bool result = false; diff --git a/BLAZAM/Pages/Browse.razor b/BLAZAM/Pages/Browse.razor new file mode 100644 index 00000000..7832a3e6 --- /dev/null +++ b/BLAZAM/Pages/Browse.razor @@ -0,0 +1,13 @@ +@page "/browse" +@attribute [Authorize] +

Browse

+ +@if (selectedEntry != null && selectedEntry is not IADOrganizationalUnit) +{ + + +} +@code { + + IDirectoryEntryAdapter? selectedEntry; +} diff --git a/BLAZAM/Pages/Computers/ComputerSessions.razor b/BLAZAM/Pages/Computers/ComputerSessions.razor deleted file mode 100644 index d3adc571..00000000 --- a/BLAZAM/Pages/Computers/ComputerSessions.razor +++ /dev/null @@ -1,137 +0,0 @@ -@inherits AppComponentBase -@if (sessionsErrorMessage == null) -{ - - @* - - - @fieldContext.User?.ToString() - - - - - @fieldContext.ConnectionState.ToString() - - - - - @fieldContext.ClientIPAddress?.ToString() - - - - - - - @fieldContext.ConnectTime.ToString() - - - - - @Math.Round((double)fieldContext.IdleTime?.TotalMinutes,0) mins - - - - - @if (fieldContext.ConnectionState.ToString() == "Active") - { - {DisconnectSession(fieldContext);})>Disconnect - } - {LogoffSession(fieldContext);})>Logoff - - - *@ -} -else -{ -
- @sessionsErrorMessage -
-} - - - -@code { - - - - [Parameter] - public IADComputer? Computer { get; set; } - - - - - - - string? sessionsErrorMessage; - Timer? t; - List sessions = new(); - List Sessions - { - get - { - - return sessions; - - - - } - set => sessions = value; - } - - - protected override void OnInitialized() - { - base.OnInitialized(); - t = new Timer(RefreshSessions, null, 1000, 10000); - - } - async void LogoffSession(IRemoteSession session) - { - - if (await MessageService.Confirm("Are you sure you want to log off " + session.User.ToString(), "Logoff User")) - { - session.Logoff(); - sessions.Remove(session); - } - - await InvokeAsync(StateHasChanged); - } - async void DisconnectSession(IRemoteSession session) - { - if (await MessageService.Confirm("Are you sure you want to disconnect " + session.User.ToString(), "Disconnect User")) - { - session.Disconnect(); - - } - await InvokeAsync(StateHasChanged); - } - - async void RefreshSessions(object? state) - { - try - { - sessions = await Computer.GetRemoteSessionsAsync(); - sessions.ForEach(s => - { - s.OnSessionDown += ((s) => - { - sessions.Remove(s); - }); - s.OnSessionUpdated += ((s) => - { - InvokeAsync(StateHasChanged); - }); - - }); - sessionsErrorMessage = null; - } - catch (AuthenticationException ex) - { - sessionsErrorMessage = ex.Message; - } - - await InvokeAsync(StateHasChanged); - } -} \ No newline at end of file diff --git a/BLAZAM/Pages/Computers/ViewComputer.razor b/BLAZAM/Pages/Computers/ViewComputer.razor index bb8aa1bf..72fc6af8 100644 --- a/BLAZAM/Pages/Computers/ViewComputer.razor +++ b/BLAZAM/Pages/Computers/ViewComputer.razor @@ -1,255 +1,234 @@ -@inherits DirectoryModelComponent +@using BLAZAM.Gui.UI.Computers +@inherits DirectoryEntryViewBase +@{ + string _fieldMudStackClasses = "flex-wrap gap-10"; +} @Computer?.CanonicalName +@if (Computer != null) +{ + - + + + - + - - - - - - - - - @Computer.CanonicalName - - - - - @DirectoryTools.PrettifyOu(Computer.OU) - - - - - - - - @switch (Computer.Online) - { - case true: - - - - break; - case false: - - - - break; - case null: - - - - break; - } - @if (Computer.LockedOut) + + + + + + + + + + + + + @if (MoveToModal?.IsShown == true) + { + + } + + + @if (RenameModal?.IsShown == true) + { + {Renamed(renamedUser);}) Computer="Computer" /> + } + + + + + + + +
+ + + + + + +
+ +
+ + + + + + + +
+ +
+ + @if (drives != null && drives.Count > 0) { - Account Locked + + + + + + + + @(context.Item.PercentUsed.Round(0).ToString() + "%") + + + + + + @(context.Item.Capacity.Round(0).ToString() + "GB") + + + + + + + } - - - - - - - - - - - - - - @if (Computer.CanEdit) - { - Edit... - } - @if (Computer.LockedOut && Computer.CanUnlock) - { - Unlock... - } - @if (Computer.CanAssign) - { - RefreshComputerGroups(); - Assign To... - } - @if (Computer.CanDisable) - { - Change Password... - } - @if (Computer.CanRename) - { - Rename... - } - @if (Computer.CanMove) - { - Move To... - } - @if (Computer.CanDelete) - { - Delete... - } - - - - + +
- - -
- - +
+ + - - @Computer.SamAccountName - - - - @if (drives != null && drives.Count > 0) - { -@* - - - - - - @Math.Round(fieldContext.UsedSpace,0) GB / @Math.Round(fieldContext.Capacity,0) GB - - - - - @{ - var bg = Color.Success; - switch (fieldContext.PercentUsed) - { - case > 85: - bg = Color.Error; - break; - case > 75: - bg = Color.Warning; - break; - - } - var percentString = (int)fieldContext.PercentUsed + "%"; - } - - - @percentString - - - - - - - - - *@ - } + - - +
+ @if (Computer.CanReadAnyCustomFields) + { +
+ @if (CustomFields != null) + { + @foreach (var field in CustomFields) + { + @if (Computer.CanReadField(field)) + { + + + } + } + } - - +
+ } - @if (Computer.HasUnsavedChanges) - { - - } + + +
+ @if (Computer.HasUnsavedChanges && !Computer.NewEntry) + { + + } +} + + + - -@code { - List drives; +@code { + List drives = new(); + IADComputer? Computer => DirectoryEntry as IADComputer; protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); + await InvokeAsync(StateHasChanged); if (Computer != null) { + Task.Run(async () => + { + drives = await Computer.GetDrivesAsync(); + + await RefreshEntryComponents(); + + }); + Task.Run(() => + { + var services = Computer.Services; + + RefreshEntryComponents(); + + }); - drives = await Computer.GetDrivesAsync(); - if (drives == null) - drives = new(); - await InvokeAsync(StateHasChanged); Computer.OnOnlineChanged += ((online) => { - InvokeAsync(StateHasChanged); + RefreshEntryComponents(); }); - await AuditLogger.Computer.Searched(Computer); } LoadingData = false; - await InvokeAsync(StateHasChanged); + await RefreshEntryComponents(); } async Task Unlock() { - if (await MessageService.Confirm("Are you sure you want to unlock " + Computer.CanonicalName + "?", "Unlock Computer")) + if (await MessageService.Confirm("Are you sure you want to unlock " + Computer?.CanonicalName + "?", "Unlock Computer")) { Computer.LockedOut = false; } } - - async void DiscardChanges() + protected override async void DiscardChanges() { if (await MessageService.Confirm("Are you sure you want to discard your changes?", "Discard Changes")) { Computer.DiscardChanges(); EditMode = false; - await InvokeAsync(StateHasChanged); + await RefreshEntryComponents(); } } async Task DeleteComputer() { - if (await MessageService.Confirm("Are you sure you want to delete " + Computer.CanonicalName + "?", "Delete Computer")) + if (await MessageService.Confirm("Are you sure you want to delete " + Computer?.CanonicalName + "?", "Delete Computer")) { try { Computer.Delete(); SnackBarService.Success(Computer.CanonicalName + " has been deleted.", "Computer Deleted"); - Computer = null; Nav.NavigateTo("/users/search"); } @@ -257,7 +236,7 @@ { SnackBarService.Error(ex.Message); } - await InvokeAsync(StateHasChanged); + await RefreshEntryComponents(); } } async void SaveChanges() @@ -267,7 +246,7 @@ await Computer.CommitChangesAsync(); EditMode = false; SnackBarService.Success("The changes made to this computer have been saved.", "Changes Saved"); - await InvokeAsync(StateHasChanged); + await RefreshEntryComponents(); } } diff --git a/BLAZAM/Pages/Configure/AddFieldModalContent.razor b/BLAZAM/Pages/Configure/AddFieldModalContent.razor new file mode 100644 index 00000000..b8007486 --- /dev/null +++ b/BLAZAM/Pages/Configure/AddFieldModalContent.razor @@ -0,0 +1,53 @@ +@inherits AppModalContent + + + + + +@foreach (var objectType in assignedObjectTypes) +{ + + +} + +@code{ + private CustomActiveDirectoryField newField = new(); + + + + private Dictionary assignedObjectTypes = new(); + + protected override void OnInitialized() + { + base.OnInitialized(); + Modal.OnYes = Add; + Modal.YesText = AppLocalization["Add"]; + foreach(var objectType in Enum.GetValues().Where(ot=>ot!=ActiveDirectoryObjectType.All)) + { + assignedObjectTypes.Add(objectType.ToString(), false); + } + } + [Parameter] + public EventCallback FieldCreated { get; set; } + + async void Add() + { + if (Context != null) + { + try + { + Context.CustomActiveDirectoryFields.Add(newField); + await Context.SaveChangesAsync(); + Close(); + + SnackBarService.Success("Field created"); + await FieldCreated.InvokeAsync(newField); + await InvokeAsync(StateHasChanged); + } + catch(Exception ex) + { + SnackBarService.Error(ex.Message); + } + } + } +} \ No newline at end of file diff --git a/BLAZAM/Pages/Configure/Audit.razor b/BLAZAM/Pages/Configure/Audit.razor index 17f2c537..4c7ba1fb 100644 --- a/BLAZAM/Pages/Configure/Audit.razor +++ b/BLAZAM/Pages/Configure/Audit.razor @@ -1,5 +1,7 @@ @page "/audit" @page "/audit/{ActiveTab}" +@using BLAZAM.Database.Models.Audit; + @attribute [Authorize(Roles = UserRoles.SuperAdmin)] @inherits TabbedAppComponentBase @@ -17,9 +19,11 @@ - ae.Timestamp)" Filterable="false" SortMode="@SortMode.Multiple" @@ -29,33 +33,45 @@ - + + + @context.Item.Target + + - + - - - @SettingsLocalization["Main"] - - - - - - + + @AppLocalization["Main"] + + + + + + ae.Timestamp.ToLocalTime().Date).Select(ae=>ae.Timestamp.ToLocalTime().ToString("M/d/yyyy")).ToArray()" + XAxisLabels="@(allDates.Select(d=>d.ToLocalTime().ToString("M/d")).ToArray())" Width="100%" Height="350px" ChartOptions="@LoginChartOptions"> - - ae.Timestamp)" Filterable="false" SortMode="@SortMode.Multiple" Groupable="false"> + + ae.Timestamp)" + Filterable="false" + SortMode="@SortMode.Multiple" + Groupable="false"> @@ -63,46 +79,57 @@ - + - - - @SettingsLocalization["Logins"] - - - - - + + + @AppLocalization["Logins"] + + + + + - + + - + - - - @SettingsLocalization["System"] - + + + @AppLocalization["System"] + - + - + @code { - List auditEntries = new(); + IEnumerable allDates; + List logonEntries = new(); + List auditEntries = new(); List systemAuditEntries = new(); List LoginSeries = new(); InterpolationOption _chartInterpolation = InterpolationOption.Straight; @@ -117,31 +144,40 @@ BaseUri = "/audit"; using (var context = await DbFactory.CreateDbContextAsync()) { - auditEntries = await context.LogonAuditLog.ToListAsync(); - auditEntries.AddRange(context.UserAuditLog.ToList()); - auditEntries.AddRange(context.GroupAuditLog.ToList()); - auditEntries.AddRange(context.OUAuditLog.ToList()); - auditEntries.AddRange(context.ComputerAuditLog.ToList()); + auditEntries = await context.DirectoryEntryAuditLogs.ToListAsync(); + logonEntries = await context.LogonAuditLog.ToListAsync(); systemAuditEntries = await context.SystemAuditLog.ToListAsync(); - loginChart.Data = auditEntries.Where(ae => ae.Action == "Login") - .GroupBy(ae => ae.Timestamp.Date) - .ToList() - .Select(g => Convert.ToDouble(g.Count())) - .ToArray(); - uniqueUsersChart.Data = auditEntries.Where(ae => ae.Action == "Login") - .GroupBy(ae => ae.Timestamp.Date) - .ToList() - .Select(g => Convert.ToDouble(g.DistinctBy(g => g.Username).Count())) - .ToArray(); + var endDate = DateTime.Today; + + var startDate = endDate.AddDays(-14); + allDates = Enumerable.Range(0, (int)(endDate - startDate).TotalDays + 1) + .Select(d => startDate.AddDays(d)); + + var loginCounts = from date in allDates + join ae in logonEntries.Where(ae => ae.Action == "Login") + on date equals ae.Timestamp.Date into grp + select (double)grp.Count(); + + var uniqueLoginCounts = from date in allDates + join ae in logonEntries.Where(ae => ae.Action == "Login") + on date equals ae.Timestamp.Date into grp + select (double)grp.DistinctBy(g => g.Username).Count(); + + + loginChart.Data = loginCounts.ToArray(); + uniqueUsersChart.Data = uniqueLoginCounts.ToArray(); + + + LoginSeries.Add(loginChart); LoginSeries.Add(uniqueUsersChart); } - + } public async Task ToggleLineMode(MouseEventArgs args) { diff --git a/BLAZAM/Pages/Configure/AuditHistoryChart.razor b/BLAZAM/Pages/Configure/AuditHistoryChart.razor new file mode 100644 index 00000000..3534c112 --- /dev/null +++ b/BLAZAM/Pages/Configure/AuditHistoryChart.razor @@ -0,0 +1,41 @@ + +@* +*@ +@code{ + + + [Parameter] + public List ChartSeries { get; set; } = new(); + [Parameter] + public ChartOptions ChartOptions { get; set; } = new() { InterpolationOption=InterpolationOption.EndSlope }; + [Parameter] + public DateTime EndDate { get; set; } = DateTime.Today; + + [Parameter] + public int Days { get; set; } = 14; + + /// + /// The height of the chart + /// + /// + /// Default is "350px" + /// + [Parameter] + public string Height { get; set; } = "350px"; + + IEnumerable allDates; + + protected override async Task OnInitializedAsync() + { + await base.OnInitializedAsync(); + + var startDate = EndDate.AddDays(-1*Days); + allDates = Enumerable.Range(0, (int)(EndDate - startDate).TotalDays + 1) + .Select(d => startDate.AddDays(d)); + } +} diff --git a/BLAZAM/Pages/Configure/FieldTypeSelect.razor b/BLAZAM/Pages/Configure/FieldTypeSelect.razor new file mode 100644 index 00000000..133041fe --- /dev/null +++ b/BLAZAM/Pages/Configure/FieldTypeSelect.razor @@ -0,0 +1,28 @@ +@inherits AppComponentBase + + @foreach (var fieldType in Enum.GetValues()) + { + @fieldType.ToString() + } + +@code{ + + [Parameter] + public Variant Variant{ get; set; } + + [Parameter] + public bool Disabled{ get; set; } + + private ActiveDirectoryFieldType value; + + [Parameter] + public ActiveDirectoryFieldType Value{ get=>value; set + { + if (this.value == value) return; + this.value = value; + ValueChanged.InvokeAsync(value); + } } + [Parameter] + + public EventCallback ValueChanged{ get; set; } +} \ No newline at end of file diff --git a/BLAZAM/Pages/Configure/Fields.razor b/BLAZAM/Pages/Configure/Fields.razor new file mode 100644 index 00000000..edf404a4 --- /dev/null +++ b/BLAZAM/Pages/Configure/Fields.razor @@ -0,0 +1,145 @@ +@page "/fields" +@using System.Collections.ObjectModel; +@inherits AppComponentBase +@attribute [Authorize(Roles = UserRoles.SuperAdmin)] + + + + Fields + + + + + + + + + + + + + + + + + + + + + + + @context.Item?.FieldType + + + + @foreach (var objectType in Enum.GetValues().Where(en => en != ActiveDirectoryObjectType.All)) + { + + + + + + + + + + } + + + 100000) + Size="@Size.Small" + Icon="@Icons.Material.Outlined.Delete" + OnClick="@(async()=>{await Delete(context.Item);})" /> + + + + + + + + +@code { + MudDataGrid? fieldGrid; + AppModal? addFieldModal; + List ADFields { get; set; } + + async Task> RefreshData(GridState currentState) + { + LoadingData = true; + await InvokeAsync(StateHasChanged); + ADFields = await Context.CustomActiveDirectoryFields.Where(x => x.DeletedAt == null).ToListAsync(); + LoadingData = false; + var data = new GridData(); + data.Items = ADFields; + data.TotalItems = ADFields.Count; + return data; + + } + async Task FieldCreated(CustomActiveDirectoryField newField) + { + await fieldGrid?.ReloadServerData(); + + } + async Task Delete(CustomActiveDirectoryField field) + { + if (await MessageService.Confirm("Are you sure you want to delete " + field.DisplayName + "?", "Delete " + field.DisplayName + "?")) + { + field.DeletedAt = DateTime.UtcNow; + if (await Context.SaveChangesAsync() > 0) + { + await fieldGrid?.ReloadServerData(); + + SnackBarService.Success(field.DisplayName + " deleted"); + } + else + SnackBarService.Warning(field.DisplayName + " could not be deleted"); + + } + + } + async Task SaveChanges() + { + if (await Context.SaveChangesAsync() > 0) + { + SnackBarService.Success("Field Updated"); + } + SnackBarService.Success("Field could nt be updated"); + + } + + void ToggleObjectType(CustomActiveDirectoryField field, ActiveDirectoryObjectType objectType, bool newValue) + { + //Handle remove to list + if (!newValue && field.ObjectTypes.Any(ot => ot.ObjectType.Equals(objectType))) + { + field.ObjectTypes.Remove(field.ObjectTypes.First(ot => ot.ObjectType.Equals(objectType))); + } + //Handle add to list + if (newValue && !field.ObjectTypes.Any(ot => ot.ObjectType.Equals(objectType))) + { + field.ObjectTypes.Add(new ActiveDirectoryFieldObjectType() { ActiveDirectoryFieldId = field.Id, ObjectType = objectType }); + } + + + } +} + diff --git a/BLAZAM/Pages/Configure/Permissions.razor b/BLAZAM/Pages/Configure/Permissions.razor index 4df61617..ad075b70 100644 --- a/BLAZAM/Pages/Configure/Permissions.razor +++ b/BLAZAM/Pages/Configure/Permissions.razor @@ -20,25 +20,25 @@ @if (Monitor.DirectoryConnected == ServiceConnectionState.Up) { - + } - @SettingsLocalization["Delegates"] + @AppLocalization["Delegates"] - + - @SettingsLocalization["Access Levels"] + @AppLocalization["Access Levels"] @@ -47,15 +47,15 @@ @if (Monitor.DirectoryConnected == ServiceConnectionState.Up) { - - + + } - @SettingsLocalization["Mappings"] + @AppLocalization["Mappings"] diff --git a/BLAZAM/Pages/Configure/Settings.razor b/BLAZAM/Pages/Configure/Settings.razor index d1de66f5..89368578 100644 --- a/BLAZAM/Pages/Configure/Settings.razor +++ b/BLAZAM/Pages/Configure/Settings.razor @@ -12,64 +12,64 @@ - + - @SettingsLocalization["Application"] + @AppLocalization["Application"] - + - @SettingsLocalization["Authentication"] + @AppLocalization["Authentication"] - + - @SettingsLocalization["Active Director"] + @AppLocalization["Active Directory"] - + - @SettingsLocalization["Email"] + @AppLocalization["Email"] - + - @SettingsLocalization["Update"] + @AppLocalization["Update"] - + - @SettingsLocalization["System"] + @AppLocalization["System"] diff --git a/BLAZAM/Pages/Configure/Templates.razor b/BLAZAM/Pages/Configure/Templates.razor index eaea993d..a0c6a005 100644 --- a/BLAZAM/Pages/Configure/Templates.razor +++ b/BLAZAM/Pages/Configure/Templates.razor @@ -1,4 +1,5 @@ @page "/templates" +@page "/templates/{TemplateIdParameter:int}" @inherits TemplateComponent @attribute [Authorize(Roles = UserRoles.SuperAdmin)] @@ -10,39 +11,49 @@ -
+ Templates -
+ - - - @if (Templates?.Count() > 0) - { - + Value="@SelectedTemplate" + ValueChanged="@((selected)=>{ + SelectedTemplate = selected; + Nav.NavigateTo("/templates/"+selected.Id); + })" /> - }else{ - + - + + + - - } @if (SelectedCategory != null && SelectedCategory != "All") { - {RenameModal.Show();}) Color="Color.Tertiary" StartIcon="@Icons.Material.Filled.ChangeCircle" /> + {RenameModal.Show();}) + Color="Color.Tertiary" + StartIcon="@Icons.Material.Filled.ChangeCircle" /> } @if (SelectedTemplate != null) { - {DuplicateTemplate(SelectedTemplate);}) Color="Color.Tertiary" StartIcon="@Icons.Material.Filled.FileCopy" /> + {await DuplicateTemplate(SelectedTemplate);}) Color="Color.Tertiary" StartIcon="@Icons.Material.Filled.FileCopy" /> } @@ -66,13 +77,13 @@ @code { + bool createFirstTemplateTooltipVisible; AppModal? RenameModal; string? newCategoryName; protected async Task DuplicateTemplate(DirectoryTemplate template) { SelectedTemplate = (DirectoryTemplate)template.Clone(); - await InvokeAsync(StateHasChanged); - Header?.OnRefreshRequested?.Invoke(); + await RefreshComponents(); } @@ -91,6 +102,22 @@ SelectedCategory = newCategoryName; await FetchTemplates(); RenameModal?.Hide(); - await InvokeAsync(StateHasChanged); + await RefreshComponents(); + + } + protected override async Task OnInitializedAsync() + { + await base.OnInitializedAsync(); + await RefreshComponents(); + if (Templates?.Count() < 1) + { + + await Task.Delay(1000); + createFirstTemplateTooltipVisible = true; + await RefreshComponents(); + + + + } } } diff --git a/BLAZAM/Pages/Download/Logs.cshtml.cs b/BLAZAM/Pages/Download/Logs.cshtml.cs index ef8f577e..82d91b69 100644 --- a/BLAZAM/Pages/Download/Logs.cshtml.cs +++ b/BLAZAM/Pages/Download/Logs.cshtml.cs @@ -1,6 +1,7 @@ using BLAZAM.Common; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; +using System.IO.Compression; namespace BLAZAM.Server.Pages.Download { @@ -8,8 +9,19 @@ public class LogsModel : PageModel { public IActionResult OnGet() { - var inMemZip = Loggers.GenerateZip(); + var inMemZip = GenerateZip(); return File(inMemZip.ToArray(),"application/zip"); } - } + + MemoryStream GenerateZip() + { + MemoryStream memoryStream = new MemoryStream(); + ZipArchive zip = new ZipArchive(memoryStream, ZipArchiveMode.Create); + // Recursively add files and subdirectories to the zip archive + //TODO make zip file + // zip.AddToZip(new SystemDirectory(LogPath),LogPath); + + return memoryStream; + } +} } diff --git a/BLAZAM/Pages/Error/DatabaseServerUnreachable.razor b/BLAZAM/Pages/Error/DatabaseServerUnreachable.razor index 8ec1d227..5ebb6314 100644 --- a/BLAZAM/Pages/Error/DatabaseServerUnreachable.razor +++ b/BLAZAM/Pages/Error/DatabaseServerUnreachable.razor @@ -1,7 +1,7 @@  @inject IDatabaseContext Context @code { - bool installed = Program.InstallationCompleted; + bool installed = ApplicationInfo.installationCompleted; }

Database Server is Unreachable

diff --git a/BLAZAM/Pages/Error/Oops.razor b/BLAZAM/Pages/Error/Oops.razor index 5ac8db3c..357ca8d2 100644 --- a/BLAZAM/Pages/Error/Oops.razor +++ b/BLAZAM/Pages/Error/Oops.razor @@ -1,35 +1,47 @@ @page "/oops" +@using BLAZAM.Gui.UI.Dev @layout ErrorLayout +@inject ApplicationInfo ApplicationInfo @inject IStringLocalizer Loc -@if (Program.IsDevelopment) -{ - -} + Oops -

@Loc["Oops"]

+ +

@Loc["Oops"]

-@if(Exception is null) -{ -
@ErrorMessage
-

@DetailsMessage

-

@HelpMessage

-} -else -{ -
@Exception.GetType().Name
-

@Exception.Message

-

@Exception.InnerException?.Message

-

@Exception.HelpLink

-} + @if (Exception is null) + { +
@ErrorMessage
+

@DetailsMessage

+

@HelpMessage

+ } + else + { +

@Exception.GetType().Name

+

@Exception.Message

+

@Exception.InnerException?.Message

+

@Exception.HelpLink

+ } + +

@Loc["Please report to"] your system administrator

+ + +
-

@Loc["Please report to"] your system administrator

@code { - public static string? ErrorMessage {get;set;} - public static string? DetailsMessage {get;set;} - public static string? HelpMessage {get;set;} - public static Exception Exception{ get; set; } + public static string? ErrorMessage { get; set; } + public static string? DetailsMessage { get; set; } + public static string? HelpMessage { get; set; } + public static Exception Exception { get; set; } + protected override void OnInitialized() + { + base.OnInitialized(); + if (AppDatabaseFactory.DatabaseCreationFailureReason != null) + { + Exception = AppDatabaseFactory.DatabaseCreationFailureReason; + } + } } diff --git a/BLAZAM/Pages/Error/UnhandledExceptionPage.razor b/BLAZAM/Pages/Error/UnhandledExceptionPage.razor index f6b9ea51..e268de5e 100644 --- a/BLAZAM/Pages/Error/UnhandledExceptionPage.razor +++ b/BLAZAM/Pages/Error/UnhandledExceptionPage.razor @@ -1,5 +1,7 @@ +@using BLAZAM.Email.Services; @inject EmailService email -@inject AppDatabaseFactory factory +@inject ApplicationInfo ApplicationInfo +@inject IAppDatabaseFactory factory @inject NavigationManager Nav Error @@ -21,7 +23,7 @@ -@if (Program.InDebugMode) +@if (ApplicationInfo.InDebugMode) { diff --git a/BLAZAM/Pages/Groups/CreateGroup.razor b/BLAZAM/Pages/Groups/CreateGroup.razor index 432c645f..5b4f25ce 100644 --- a/BLAZAM/Pages/Groups/CreateGroup.razor +++ b/BLAZAM/Pages/Groups/CreateGroup.razor @@ -77,10 +77,8 @@ - bool custom = false; string newGroupName; - bool collapseVisible = false; List templates; IADOrganizationalUnit? parentOU; IADGroup? newGroup; @@ -121,6 +119,6 @@ } async Task GroupCreated(IADGroup ou) { - AuditLogger.Group.Created(ou); + await AuditLogger.Group.Created(ou); } } diff --git a/BLAZAM/Pages/Groups/ViewGroup.razor b/BLAZAM/Pages/Groups/ViewGroup.razor index 4f12bd26..e5b8a0e2 100644 --- a/BLAZAM/Pages/Groups/ViewGroup.razor +++ b/BLAZAM/Pages/Groups/ViewGroup.razor @@ -1,6 +1,4 @@ -@inject IStringLocalizer Loc -@inject IStringLocalizer ULoc -@inherits DirectoryModelComponent +@inherits DirectoryEntryViewBase @Group?.CanonicalName @@ -9,61 +7,18 @@ - - - - - - - @Group.CanonicalName - - - - - @DirectoryTools.PrettifyOu(Group.OU) - - - - - - - - - - - - @if (Group.CanEdit) - { - Edit... - } - Add Group Member... - @if (Group.CanAssign) - { - RefreshGroupGroupsAsync(); - Assign To... - } - - @if (Group.CanRename) - { - Rename... - - } - @if (Group.CanMove) - { - Move To... - } - @if (Group.CanDelete) - { - Delete... - } - - - - - - + + - + + @@ -88,42 +43,27 @@ +
+ + + +
- - - - - - - - +
+ - +
- - - - - - - - @if (Group.HasMembers) - { -
- +
+ -
- if (Group.Members.Where(m => !m.CanRead).Count() > 0) - { - - The group has more members you don't have access to - - } - } +
+ + @@ -133,7 +73,7 @@ } - +
@@ -141,28 +81,10 @@ AppModal? AssignMemberModal; - List Members = new(); - + IADGroup Group => DirectoryEntry as IADGroup; - protected override async Task OnInitializedAsync() - { - await base.OnInitializedAsync(); - if (!Group.NewEntry) - await AuditLogger.Group.Searched(Group); - } - - async void DiscardChanges() - { - if (await MessageService.Confirm("Are you sure you want to discard your changes?", "Discard Changes")) - { - Group.DiscardChanges(); - EditMode = false; - await InvokeAsync(StateHasChanged); - - } - - } + async void SaveChanges() { @@ -189,7 +111,7 @@ Group.Delete(); SnackBarService.Success(Group.CanonicalName + " has been deleted.", "Group Deleted"); - Group = null; + //Group = null; Nav.NavigateTo("/groups/search"); } diff --git a/BLAZAM/Pages/Home.razor b/BLAZAM/Pages/Home.razor index 2608187a..fa04b04e 100644 --- a/BLAZAM/Pages/Home.razor +++ b/BLAZAM/Pages/Home.razor @@ -1,9 +1,7 @@ @attribute [Authorize] @inherits AppComponentBase @page "/Home" -@using BLAZAM.Server.Shared.UI.Dashboard.Widgets; -@using BLAZAM.Common.Data.ActiveDirectory.Interfaces; -@using BLAZAM.Server.Data.Services.Email; +@using BLAZAM.Gui.UI.Dashboard @{ string testValue=""; @@ -13,61 +11,21 @@ @if (MOTD.HasValue && MOTD.Value.ToString() != "") { - + @MOTD.Value } - - - + - - - - - - - - - - - - @context.Name - {RemoveWidget(context);}) Style="right:10px;top:15px; position:absolute;" /> - - - - - - - - - - @code { +@code { MarkupString? MOTD; - MudDropContainer? widgetContainer; - List widgets = new List(); - protected override Task OnInitializedAsync() { - widgets = new List(Widgets.Available(UserStateService.CurrentUserState)); try { MOTD = (MarkupString)Context.AppSettings.FirstOrDefault().MOTD; @@ -79,17 +37,6 @@ return base.OnInitializedAsync(); } - private Task ItemDropped(MudItemDropInfo dropItem) - { - dropItem.Item.Slot = dropItem.DropzoneIdentifier; - return Task.CompletedTask; - } - async Task RemoveWidget(Widget widget) - { - widgets.Remove(widget); - widgetContainer.Refresh(); - await InvokeAsync(StateHasChanged); - - } + } \ No newline at end of file diff --git a/BLAZAM/Pages/Index.razor b/BLAZAM/Pages/Index.razor index 6fbf7e41..88ec9198 100644 --- a/BLAZAM/Pages/Index.razor +++ b/BLAZAM/Pages/Index.razor @@ -2,8 +2,9 @@ @layout MinLayout @inject NavigationManager NavManager -@inject AppDatabaseFactory DbFactory +@inject IAppDatabaseFactory DbFactory @inject ConnMonitor tester +@inject ApplicationInfo ApplicationInfo @inject IStringLocalizer Localizer

@Localizer["ApplicationStarting"] @@ -16,7 +17,7 @@ { while (NavManager.ToBaseRelativePath(NavManager.Uri) == "") { - if (Program.InstallationCompleted) + if (ApplicationInfo.InstallationCompleted) { if (tester.AppReady == ServiceConnectionState.Up) { diff --git a/BLAZAM/Pages/Install/ADirectory.razor b/BLAZAM/Pages/Install/ADirectory.razor index 7ab8cfdd..15226973 100644 --- a/BLAZAM/Pages/Install/ADirectory.razor +++ b/BLAZAM/Pages/Install/ADirectory.razor @@ -1,16 +1,15 @@ @page "/install/directory" @layout InstallLayout @inherits AppComponentBase -@inject NavigationManager Nav; @{ }
- + - +

- Proceed + Proceed
@code { @@ -48,6 +47,7 @@ private void ShowNext() { disableNext = false; + StepCompleted.InvokeAsync(); InvokeAsync(StateHasChanged); } diff --git a/BLAZAM/Pages/Install/Application.razor b/BLAZAM/Pages/Install/Application.razor index 04ae2dad..b82c43fe 100644 --- a/BLAZAM/Pages/Install/Application.razor +++ b/BLAZAM/Pages/Install/Application.razor @@ -11,10 +11,10 @@ Please configure the required application settings - @SettingsLocalization["Application Name"] + @AppLocalization["Application Name"] - + diff --git a/BLAZAM/Pages/Install/Authentication.razor b/BLAZAM/Pages/Install/Authentication.razor index fdeca19e..a04312d3 100644 --- a/BLAZAM/Pages/Install/Authentication.razor +++ b/BLAZAM/Pages/Install/Authentication.razor @@ -2,8 +2,6 @@ @using System.Net @using System.Diagnostics @using Microsoft.EntityFrameworkCore; -@using BLAZAM.Common.Data.ActiveDirectory.Interfaces; -@using BLAZAM.Server.Data.Services.Email; @layout InstallLayout @inherits ValidatedForm @@ -19,7 +17,7 @@ - @SettingsLocalization["Username"] + @AppLocalization["Username"] @@ -27,23 +25,30 @@ - @SettingsLocalization["Password"] + @AppLocalization["Password"] - @SettingsLocalization["Password"] + @AppLocalization["Password"] - + @@ -57,14 +62,17 @@ [Parameter] public EventCallback StepCompleted { get; set; } - public string adminPassword = ""; - string confirmedPassword; - AuthenticationSettings settings=new(); + AuthenticationSettings settings = new(); protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); settings = await Context.AuthenticationSettings.FirstOrDefaultAsync(); + + if (settings !=null && settings.AdminPassword == "password") + settings.AdminPassword = ""; + + await InvokeAsync(StateHasChanged); } @@ -77,20 +85,17 @@ if (settings.Id == 0) Context.AuthenticationSettings.Add(settings); + settings.AdminPassword = EncryptionService.EncryptObject(settings.AdminPasswordConfirmed); await Context.SaveChangesAsync(); - StepCompleted.InvokeAsync(); + await StepCompleted.InvokeAsync(); } catch (Exception ex) { - MessageService.Error(ex.Message + " " + ex.InnerException?.Message); - + await MessageService.Error(ex.Message + " " + ex.InnerException?.Message); + } await InvokeAsync(StateHasChanged); } - //async void Matches(ValidatorEventArgs e) - //{ - // e.Status = ((adminPassword.Equals(e.Value as string)) ? ValidationStatus.Success : ValidationStatus.Error); - //} } diff --git a/BLAZAM/Pages/Install/Install.razor b/BLAZAM/Pages/Install/Install.razor index 632a799a..372cc403 100644 --- a/BLAZAM/Pages/Install/Install.razor +++ b/BLAZAM/Pages/Install/Install.razor @@ -85,7 +85,7 @@ else protected override void OnInitialized() { base.OnInitialized(); - if (Program.InstallationCompleted) + if (ApplicationInfo.InstallationCompleted) Nav.NavigateTo("/"); } @@ -97,17 +97,7 @@ else } - /* - private bool NavigationAllowed(StepNavigationContext context) - { - if (context.NextStepIndex > _step) - { - return false; - } - - return true; - } - */ + async void UpdateStatuses() { Context = DbFactory.CreateDbContext(); @@ -140,23 +130,7 @@ else completedSteps = 4; await InvokeAsync(StateHasChanged); - //check permissions - /* - PermissionDelegate currentSettings = Context.PermissionDelegate.FirstOrDefault(); - if (currentSettings != null) - { - - if (Context.Status == DatabaseContext.ConnectionStatus.OK) - { - _step = 5; - selectedStep = "5"; - - //NavManager.NavigateTo("/"); - } - - - } - */ + } } @@ -187,11 +161,7 @@ else _completedSteps = 6; UpdateStatuses(); } - private void RecheckWritable() - { - Program.CheckWritablePathPermissions(); - UpdateStatuses(); - } + private async void FinalizeInstall() { try @@ -206,7 +176,7 @@ else } (await Context.AppSettings.FirstOrDefaultAsync()).InstallationCompleted = true; var result = await Context.SaveChangesAsync(); - Program.InstallationCompleted = true; + ApplicationInfo.InstallationCompleted = true; Nav.NavigateTo("/home", true); } catch diff --git a/BLAZAM/Pages/Install/InstallDatabase.razor b/BLAZAM/Pages/Install/InstallDatabase.razor index 87de7c27..cdb32f18 100644 --- a/BLAZAM/Pages/Install/InstallDatabase.razor +++ b/BLAZAM/Pages/Install/InstallDatabase.razor @@ -1,4 +1,3 @@ -@using Microsoft.EntityFrameworkCore @layout InstallLayout @inherits AppComponentBase @{ @@ -29,22 +28,22 @@ The database is ready to install. Type - @Context.ConnectionString?.DatabaseType + @Context?.ConnectionString?.DatabaseType Server - @Context.ConnectionString?.ServerAddress + @Context?.ConnectionString?.ServerAddress Port - @Context.ConnectionString?.ServerPort + @Context?.ConnectionString?.ServerPort Database - @Context.ConnectionString?.Database + @Context?.ConnectionString?.Database @@ -87,7 +86,7 @@ else await InvokeAsync(StateHasChanged); try { - if (await Program.ApplyDatabaseMigrations(true)) + if (await DbFactory.ApplyDatabaseMigrations(true)) { Completed = true; await InvokeAsync(StepCompleted.InvokeAsync); @@ -97,7 +96,7 @@ else } catch (Exception ex) { - MessageService.Error(ex.Message, ex.GetType().FullName); + await MessageService.Error(ex.Message, ex.GetType().FullName); } await InvokeAsync(StateHasChanged); diff --git a/BLAZAM/Pages/Login.razor b/BLAZAM/Pages/Login.razor index 60155d90..b7a3cc96 100644 --- a/BLAZAM/Pages/Login.razor +++ b/BLAZAM/Pages/Login.razor @@ -1,11 +1,12 @@ @page "/login" -@using BLAZAM.Common.Data; -@using BLAZAM.Common.Data.ActiveDirectory.Interfaces; -@using BLAZAM.Server.Data.Services.Email; +@using BLAZAM.Static; + @inherits ValidatedForm @inject IJSRuntime JSRuntime @layout LoginLayout -@{ +@if (attemptingSignIn) +{ + } @@ -23,8 +24,8 @@