From f4695f8b2e797f365b84142db901ddf87fe13dfa Mon Sep 17 00:00:00 2001 From: Chris Jacobsen Date: Sat, 10 Aug 2024 16:02:34 -0400 Subject: [PATCH 01/18] Reconnect on save during installation wizard --- BLAZAM/BLAZAM.csproj | 2 +- BLAZAM/Pages/Install/ADirectory.razor | 1 + BLAZAMGui/UI/Settings/ActiveDirectoryStatusPanel.razor | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/BLAZAM/BLAZAM.csproj b/BLAZAM/BLAZAM.csproj index 63184ea6..2c845b84 100644 --- a/BLAZAM/BLAZAM.csproj +++ b/BLAZAM/BLAZAM.csproj @@ -6,7 +6,7 @@ enable false 1.0.0 - 2024.08.09.1713 + 2024.08.10.2001 false BLAZAM False diff --git a/BLAZAM/Pages/Install/ADirectory.razor b/BLAZAM/Pages/Install/ADirectory.razor index 2ae4ce10..65a7d137 100644 --- a/BLAZAM/Pages/Install/ADirectory.razor +++ b/BLAZAM/Pages/Install/ADirectory.razor @@ -8,6 +8,7 @@
+
Proceed diff --git a/BLAZAMGui/UI/Settings/ActiveDirectoryStatusPanel.razor b/BLAZAMGui/UI/Settings/ActiveDirectoryStatusPanel.razor index 9bd24ac1..b624ef62 100644 --- a/BLAZAMGui/UI/Settings/ActiveDirectoryStatusPanel.razor +++ b/BLAZAMGui/UI/Settings/ActiveDirectoryStatusPanel.razor @@ -110,7 +110,7 @@ public void ResetStatus() { //Directory = DirectoryFactory.CreateActiveDirectoryContext(); - //Directory.ConnectAsync(); + Directory.ConnectAsync(); _portStatus = false; _credStatus = false; showProgress = true; From f6091d6f31b21ccef355793886cbf4226ae25495 Mon Sep 17 00:00:00 2001 From: Chris Jacobsen Date: Sat, 10 Aug 2024 16:19:20 -0400 Subject: [PATCH 02/18] Remove unnecessary JS code --- BLAZAM/BLAZAM.csproj | 2 +- BLAZAM/Pages/Login.razor | 2 +- BLAZAM/wwwroot/js/blazam.js | 12 ------------ 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/BLAZAM/BLAZAM.csproj b/BLAZAM/BLAZAM.csproj index 2c845b84..e214b959 100644 --- a/BLAZAM/BLAZAM.csproj +++ b/BLAZAM/BLAZAM.csproj @@ -6,7 +6,7 @@ enable false 1.0.0 - 2024.08.10.2001 + 2024.08.10.2006 false BLAZAM False diff --git a/BLAZAM/Pages/Login.razor b/BLAZAM/Pages/Login.razor index a42c2d5e..0ebc4f7a 100644 --- a/BLAZAM/Pages/Login.razor +++ b/BLAZAM/Pages/Login.razor @@ -158,7 +158,7 @@ } catch (Exception ex) { - + Loggers.SystemLogger.Error("Error attempting logon {@Error}",ex); SnackBarService.Info(ex.Message); } diff --git a/BLAZAM/wwwroot/js/blazam.js b/BLAZAM/wwwroot/js/blazam.js index 087a3995..e524d6a3 100644 --- a/BLAZAM/wwwroot/js/blazam.js +++ b/BLAZAM/wwwroot/js/blazam.js @@ -21,23 +21,11 @@ window.updateCookieExpiration = async () => { }; window.attemptSignIn = async (loginReq) => { - //Get the form from the current page - var form = document.querySelector("form"); - var formData = new FormData(); for (var key in loginReq) { formData.append(key, loginReq[key]); } - //Load the form data - //for (var x = 0; x < form.length; x++) { - //console.log(form[x].name); - //console.log(form[x].value); - // formData.append(form[x].name,form[x].value) - //} - //var data = Array.from(formData); - //console.log(data); - var xhr = new XMLHttpRequest(); var response = await new Promise((resolve, reject) => { xhr.onreadystatechange = function () { From 5b16a3313a06097af42a63da26e6ee45e70d2f60 Mon Sep 17 00:00:00 2001 From: Chris Jacobsen Date: Sat, 10 Aug 2024 17:41:57 -0400 Subject: [PATCH 03/18] Update Test --- BLAZAM/BLAZAM.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BLAZAM/BLAZAM.csproj b/BLAZAM/BLAZAM.csproj index e214b959..46416dc8 100644 --- a/BLAZAM/BLAZAM.csproj +++ b/BLAZAM/BLAZAM.csproj @@ -6,7 +6,7 @@ enable false 1.0.0 - 2024.08.10.2006 + 2024.08.10.2141 false BLAZAM False From 6856d9dd70eeb030da2b76d82172675dc0e0f4fb Mon Sep 17 00:00:00 2001 From: Chris Jacobsen Work Date: Sat, 10 Aug 2024 23:07:38 -0400 Subject: [PATCH 04/18] Fix for update credential check failing --- BLAZAM/BLAZAM.csproj | 2 +- BLAZAM/wwwroot/js/blazam.js | 2 +- BLAZAMFileSystem/FileSystemBase.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/BLAZAM/BLAZAM.csproj b/BLAZAM/BLAZAM.csproj index 46416dc8..7fcb2d8a 100644 --- a/BLAZAM/BLAZAM.csproj +++ b/BLAZAM/BLAZAM.csproj @@ -6,7 +6,7 @@ enable false 1.0.0 - 2024.08.10.2141 + 2024.08.11.0305 false BLAZAM False diff --git a/BLAZAM/wwwroot/js/blazam.js b/BLAZAM/wwwroot/js/blazam.js index e524d6a3..4461489f 100644 --- a/BLAZAM/wwwroot/js/blazam.js +++ b/BLAZAM/wwwroot/js/blazam.js @@ -21,7 +21,7 @@ window.updateCookieExpiration = async () => { }; window.attemptSignIn = async (loginReq) => { - + formData = new FormData(); for (var key in loginReq) { formData.append(key, loginReq[key]); } diff --git a/BLAZAMFileSystem/FileSystemBase.cs b/BLAZAMFileSystem/FileSystemBase.cs index 33a7a6e4..7b6ef719 100644 --- a/BLAZAMFileSystem/FileSystemBase.cs +++ b/BLAZAMFileSystem/FileSystemBase.cs @@ -46,7 +46,7 @@ public virtual bool Writable { //if (!directoryInfo.Exists) throw new DirectoryNotFoundException("Directory " + Path + " does not exist!"); - testFilePath = Path + "test.txt"; + testFilePath = System.IO.Path.GetFullPath(Path + "\\test.txt"); // Attempt to create a test file within the directory. using (File.Create(testFilePath)) From 42306c15c75385e152f08c245ae92d99f6fe8cac Mon Sep 17 00:00:00 2001 From: Chris Jacobsen Date: Sun, 11 Aug 2024 09:52:03 -0400 Subject: [PATCH 05/18] Fixes for Template tree view and editing --- BLAZAM/BLAZAM.csproj | 2 +- BLAZAM/Pages/Configure/Templates.razor | 4 ++-- BLAZAMGui/Layouts/AppUserButton.razor | 5 +++++ BLAZAMGui/UI/Inputs/MudSelectList.razor | 22 +++++++++++++++++-- .../Outputs/TemplateInheritanceTreeView.razor | 8 +++---- .../Templates/EditDirectoryTemplate.razor | 12 ++++++---- BLAZAMThemes/BlueTheme.cs | 3 ++- BLAZAMThemes/GreenTheme.cs | 8 ++++--- BLAZAMThemes/OrangeTheme.cs | 2 ++ BLAZAMThemes/RedTheme.cs | 2 ++ 10 files changed, 51 insertions(+), 17 deletions(-) diff --git a/BLAZAM/BLAZAM.csproj b/BLAZAM/BLAZAM.csproj index 7fcb2d8a..4a5aa2ac 100644 --- a/BLAZAM/BLAZAM.csproj +++ b/BLAZAM/BLAZAM.csproj @@ -6,7 +6,7 @@ enable false 1.0.0 - 2024.08.11.0305 + 2024.08.11.1350 false BLAZAM False diff --git a/BLAZAM/Pages/Configure/Templates.razor b/BLAZAM/Pages/Configure/Templates.razor index de016443..8d5c0189 100644 --- a/BLAZAM/Pages/Configure/Templates.razor +++ b/BLAZAM/Pages/Configure/Templates.razor @@ -226,8 +226,8 @@ List> treeData = new(); var rootTemplates = Templates.Where(t => t.ParentTemplate == null && t.DeletedAt == null).ToTreeItemData(); - - treeData = RecursiveFillTreeViewItems(treeData); + + treeData = RecursiveFillTreeViewItems(rootTemplates); return treeData; } diff --git a/BLAZAMGui/Layouts/AppUserButton.razor b/BLAZAMGui/Layouts/AppUserButton.razor index f565d22f..eec6799a 100644 --- a/BLAZAMGui/Layouts/AppUserButton.razor +++ b/BLAZAMGui/Layouts/AppUserButton.razor @@ -105,6 +105,11 @@ if (username is null || username.IsNullOrEmpty()) return "background-color:#0c13a7"; int usernameHash = username.GetAppHashCode(); byte[] usernameHashBytes = Helpers.ByteHelpers.ToByteArray(usernameHash, (int?)3); + for(int x = 0; x < usernameHashBytes.Length; x++) + { + if (usernameHashBytes[x] > 200) + usernameHashBytes[x] = 200; + } string hexColor = "background-color:#"; hexColor += Convert.ToHexString(usernameHashBytes.Take(3).ToArray()); return hexColor; diff --git a/BLAZAMGui/UI/Inputs/MudSelectList.razor b/BLAZAMGui/UI/Inputs/MudSelectList.razor index 5f4926b2..c0bcb35a 100644 --- a/BLAZAMGui/UI/Inputs/MudSelectList.razor +++ b/BLAZAMGui/UI/Inputs/MudSelectList.razor @@ -1,6 +1,12 @@ @inherits MudSelect @typeparam T - +@if (Adornment == Adornment.Start) + { + + } + - + @if (Adornment == Adornment.End) + { + if (!AdornmentIcon.IsNullOrEmpty()) + { + + } + } + @code { private MudMenu? _selectMenu; diff --git a/BLAZAMGui/UI/Outputs/TemplateInheritanceTreeView.razor b/BLAZAMGui/UI/Outputs/TemplateInheritanceTreeView.razor index df0cd246..2b8c5666 100644 --- a/BLAZAMGui/UI/Outputs/TemplateInheritanceTreeView.razor +++ b/BLAZAMGui/UI/Outputs/TemplateInheritanceTreeView.razor @@ -12,13 +12,13 @@ SelectedValueChanged=SelectedTemplateChanged MaxHeight="400px"> - - + + CategoryAdded="@(async(newCategory)=>{ + DirectoryTemplate.Category=newCategory; + categories.Add(newCategory); + await InvokeAsync(StateHasChanged); + })" /> - @if(DirectoryTemplate.EffectiveSendWelcomeEmail==true && DirectoryTemplate.EffectiveAskForAlternateEmail!=true && + @if (DirectoryTemplate.EffectiveSendWelcomeEmail == true && DirectoryTemplate.EffectiveAskForAlternateEmail != true && (DirectoryTemplate.EffectiveFieldValues.Any(fv => fv.Field.Id == ActiveDirectoryFields.Mail.Id) && !DirectoryTemplate.EffectiveFieldValues.First(fv => fv.Field.Id == ActiveDirectoryFields.Mail.Id).Value.IsNullOrEmpty())) { @@ -445,7 +449,7 @@ await ParentTemplateChanged(null); { if (_template == value) return; - if (Context != null) + if (Context != null && value.Id>0) value = Context?.DirectoryTemplates.First(dt => dt.Id == value.Id); _template = value; originalTemplate = value; diff --git a/BLAZAMThemes/BlueTheme.cs b/BLAZAMThemes/BlueTheme.cs index 64fedc59..cbb0ebc9 100644 --- a/BLAZAMThemes/BlueTheme.cs +++ b/BLAZAMThemes/BlueTheme.cs @@ -21,6 +21,7 @@ public BlueTheme() lightPalette.Dark = "#001529"; lightPalette.Primary = "#2261d3"; lightPalette.Secondary = "#40449D"; + lightPalette.DrawerIcon = "#5889B3"; @@ -32,7 +33,7 @@ public BlueTheme() darkPalette.DrawerBackground = "#0f141e"; darkPalette.DrawerText = "#c7c7c7"; darkPalette.Secondary = "#519BD4"; - + darkPalette.DrawerIcon = "#95A8B8"; } diff --git a/BLAZAMThemes/GreenTheme.cs b/BLAZAMThemes/GreenTheme.cs index c8f57497..df2ddfb9 100644 --- a/BLAZAMThemes/GreenTheme.cs +++ b/BLAZAMThemes/GreenTheme.cs @@ -15,14 +15,15 @@ public GreenTheme() lightPalette.ActionDefault = "#9AC3A1"; - lightPalette.AppbarBackground = "#22D340"; + lightPalette.AppbarBackground = "#1BB836"; lightPalette.DrawerBackground = "#CFDCD0"; lightPalette.DrawerText = "#0F1E12"; lightPalette.Dark = "#002902"; - lightPalette.Primary = "#22D340"; - lightPalette.Secondary = "#0CA726"; + lightPalette.Primary = "#1CBE38"; + lightPalette.Secondary = "#0A9B22"; + lightPalette.DrawerIcon = "#95B899"; darkPalette.TextSecondary = "#7EA782"; @@ -36,6 +37,7 @@ public GreenTheme() darkPalette.DrawerText = "#c7c7c7"; darkPalette.Secondary = "#51D470"; + darkPalette.DrawerIcon = "#95B899"; diff --git a/BLAZAMThemes/OrangeTheme.cs b/BLAZAMThemes/OrangeTheme.cs index 31e38634..6ef9549a 100644 --- a/BLAZAMThemes/OrangeTheme.cs +++ b/BLAZAMThemes/OrangeTheme.cs @@ -23,6 +23,7 @@ public OrangeTheme() lightPalette.Primary = "#D39322"; lightPalette.Secondary = "#A76F0C"; + lightPalette.DrawerIcon = "#B8AB95"; darkPalette.TextSecondary = "#A7967E"; @@ -37,6 +38,7 @@ public OrangeTheme() darkPalette.Secondary = "#D49C51"; + darkPalette.DrawerIcon = "#B8AB95"; } diff --git a/BLAZAMThemes/RedTheme.cs b/BLAZAMThemes/RedTheme.cs index e42df941..e0b7b156 100644 --- a/BLAZAMThemes/RedTheme.cs +++ b/BLAZAMThemes/RedTheme.cs @@ -19,6 +19,7 @@ public RedTheme() lightPalette.Primary = "#D32222"; lightPalette.Secondary = "#A70C0C"; + lightPalette.DrawerIcon = "#B89595"; darkPalette.TextSecondary = "#A77E86"; darkPalette.ActionDefault = "#B17B7E"; @@ -30,6 +31,7 @@ public RedTheme() darkPalette.DrawerBackground = "#1E0F0F"; darkPalette.Secondary = "#D45151"; + darkPalette.DrawerIcon = "#B89595"; } From 64859ef6e4743213705a21bf6a9dc447cc2596ee Mon Sep 17 00:00:00 2001 From: Chris Jacobsen Date: Sun, 11 Aug 2024 11:17:24 -0400 Subject: [PATCH 06/18] Add operator functions to ApplicationVersion --- BLAZAMCommon/Data/ApplicationVersion.cs | 24 +++++++++++++++++++ .../Settings/ManualApplicationUpdater.razor | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/BLAZAMCommon/Data/ApplicationVersion.cs b/BLAZAMCommon/Data/ApplicationVersion.cs index 9501cbc7..9b70d743 100644 --- a/BLAZAMCommon/Data/ApplicationVersion.cs +++ b/BLAZAMCommon/Data/ApplicationVersion.cs @@ -154,6 +154,30 @@ public bool NewerThan(ApplicationVersion version) return CompareTo(version) > 0; } + public static bool operator !=(ApplicationVersion version1, ApplicationVersion version2) + { + return version1.CompareTo(version2) != 0; + } + public static bool operator ==(ApplicationVersion version1, ApplicationVersion version2) + { + return version1.CompareTo(version2) == 0; + } + public static bool operator >=(ApplicationVersion version1, ApplicationVersion version2) + { + return version1.CompareTo(version2) >= 0; + } + public static bool operator <=(ApplicationVersion version1, ApplicationVersion version2) + { + return version1.CompareTo(version2) <= 0; + } + public static bool operator <(ApplicationVersion version1, ApplicationVersion version2) + { + return version1.CompareTo(version2) < 0; + } + public static bool operator >(ApplicationVersion version1, ApplicationVersion version2) + { + return version1.CompareTo(version2) > 0; + } public bool OlderThan(ApplicationVersion version) { return CompareTo(version) < 0; diff --git a/BLAZAMGui/UI/Settings/ManualApplicationUpdater.razor b/BLAZAMGui/UI/Settings/ManualApplicationUpdater.razor index 4f624041..aa322d7e 100644 --- a/BLAZAMGui/UI/Settings/ManualApplicationUpdater.razor +++ b/BLAZAMGui/UI/Settings/ManualApplicationUpdater.razor @@ -90,7 +90,7 @@ @if (ShowAllUpdates) { - @foreach (var update in UpdateService.AvailableUpdates.Where(x => x.Version.OlderThan(ApplicationInfo.RunningVersion)).OrderBy(x => x.Version)) + @foreach (var update in UpdateService.AvailableUpdates.Where(x => x.Version<=ApplicationInfo.RunningVersion).OrderBy(x => x.Version)) { From 41c2edd99a3703c81cb264e9b6adee1f68e40561 Mon Sep 17 00:00:00 2001 From: Chris Jacobsen Date: Sun, 11 Aug 2024 11:17:51 -0400 Subject: [PATCH 07/18] Remove memory leak --- BLAZAMGui/Layouts/AppUserButton.razor | 13 +++++++--- .../Layouts/UserNotificationPopover.razor | 25 ++++++++----------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/BLAZAMGui/Layouts/AppUserButton.razor b/BLAZAMGui/Layouts/AppUserButton.razor index eec6799a..a37cd516 100644 --- a/BLAZAMGui/Layouts/AppUserButton.razor +++ b/BLAZAMGui/Layouts/AppUserButton.razor @@ -8,9 +8,9 @@ var avatarBgColor = GenerateAvatarColor(UserState?.Username); } - @if (UserState?.Notifications?.Count > 0) + @if (Notifications?.Count > 0) { - + } @@ -25,7 +25,7 @@ @CurrentUser.Username - @if (UserState?.Notifications?.Count > 0) + @if (Notifications.Count > 0) { Notifications } @@ -76,7 +76,7 @@ [CascadingParameter] public MainLayout mainLayout { get; set; } - + IList Notifications = new List(); private IApplicationUserState UserState; protected override void OnInitialized() { @@ -84,9 +84,14 @@ NotificationPublisher.OnNotificationPublished += ((notifications) => { if (notifications.Select(n => n.User).Contains(UserState.Preferences)) + { + Notifications = UserState.Notifications; + + } InvokeAsync(StateHasChanged); }); UserState = CurrentUser.State; + Notifications = UserState.Notifications; if (UserState != null) UserState.OnSettingsChanged += (settings) => { diff --git a/BLAZAMGui/Layouts/UserNotificationPopover.razor b/BLAZAMGui/Layouts/UserNotificationPopover.razor index 9031b118..b8f70dda 100644 --- a/BLAZAMGui/Layouts/UserNotificationPopover.razor +++ b/BLAZAMGui/Layouts/UserNotificationPopover.razor @@ -1,16 +1,6 @@ @inherits AppComponentBase -@{ - var messages = 0; - try - { - messages = UserState.Notifications?.Count??0; - } - catch - { - - } -} -@if (messages > 0) + +@if (messages.Count > 0) { - @foreach (var notification in UserState.Notifications) + @foreach (var notification in messages) { { @@ -48,10 +38,15 @@ @code { private bool _open; - + private IList messages = new List(); protected override void OnInitialized(){ base.OnInitialized(); - NotificationPublisher.OnNotificationPublished += (notification) => { InvokeAsync(StateHasChanged); }; + messages = UserState.Notifications; + + NotificationPublisher.OnNotificationPublished += (notification) => { + messages = UserState.Notifications; + InvokeAsync(StateHasChanged); + }; } [Parameter] From 3720090988a298d832b4735e89d5d322ae1e3d10 Mon Sep 17 00:00:00 2001 From: Chris Jacobsen Date: Sun, 11 Aug 2024 11:18:17 -0400 Subject: [PATCH 08/18] Cache all widget data --- .../Widgets/ChangedEntriesWidget.razor | 6 +++++- .../Widgets/DeletedEntriesWidget.razor | 7 +++++-- .../Widgets/DisabledUsersWidget.razor | 7 +++++-- .../Dashboard/Widgets/FavoritesWidget.razor | 19 ++++++++++--------- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/BLAZAMGui/UI/Dashboard/Widgets/ChangedEntriesWidget.razor b/BLAZAMGui/UI/Dashboard/Widgets/ChangedEntriesWidget.razor index bcc87f2b..a81dd60f 100644 --- a/BLAZAMGui/UI/Dashboard/Widgets/ChangedEntriesWidget.razor +++ b/BLAZAMGui/UI/Dashboard/Widgets/ChangedEntriesWidget.razor @@ -48,7 +48,11 @@ @code { - List changdEntries { get; set; } = new(); + List changdEntries + { + get => CurrentUser.State.Cache.Get>(this.GetType()); + set => CurrentUser.State.Cache.Set(this.GetType(), value); + } protected override async Task OnInitializedAsync() { diff --git a/BLAZAMGui/UI/Dashboard/Widgets/DeletedEntriesWidget.razor b/BLAZAMGui/UI/Dashboard/Widgets/DeletedEntriesWidget.razor index 8486b658..4d97fe00 100644 --- a/BLAZAMGui/UI/Dashboard/Widgets/DeletedEntriesWidget.razor +++ b/BLAZAMGui/UI/Dashboard/Widgets/DeletedEntriesWidget.razor @@ -41,8 +41,11 @@ @code { - List deletedObjects { get; set; } = new(); - + List deletedObjects + { + get => CurrentUser.State.Cache.Get>(this.GetType()); + set => CurrentUser.State.Cache.Set(this.GetType(), value); + } protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); diff --git a/BLAZAMGui/UI/Dashboard/Widgets/DisabledUsersWidget.razor b/BLAZAMGui/UI/Dashboard/Widgets/DisabledUsersWidget.razor index 8ead42a3..c7ddf8b5 100644 --- a/BLAZAMGui/UI/Dashboard/Widgets/DisabledUsersWidget.razor +++ b/BLAZAMGui/UI/Dashboard/Widgets/DisabledUsersWidget.razor @@ -22,8 +22,11 @@ @code { - List LockedUsers = new(); - + List LockedUsers + { + get => CurrentUser.State.Cache.Get>(this.GetType()); + set => CurrentUser.State.Cache.Set(this.GetType(), value); + } protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); diff --git a/BLAZAMGui/UI/Dashboard/Widgets/FavoritesWidget.razor b/BLAZAMGui/UI/Dashboard/Widgets/FavoritesWidget.razor index 693841e4..23a9ae7d 100644 --- a/BLAZAMGui/UI/Dashboard/Widgets/FavoritesWidget.razor +++ b/BLAZAMGui/UI/Dashboard/Widgets/FavoritesWidget.razor @@ -47,26 +47,27 @@ @code { - List FavoriteEntries { get; set; } = new(); - + List FavoriteEntries + { + get => CurrentUser.State.Cache.Get>(this.GetType()); + set => CurrentUser.State.Cache.Set(this.GetType(), value); + } protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); await Task.Run(() => { + var favorites = new List(); foreach (var entry in CurrentUser.State.Preferences.FavoriteEntries) { IDirectoryEntryAdapter match = Directory.GetDirectoryEntryByDN(entry.DN); - if (match == null) - { - - } - else if (match.CanRead) + if (match != null && match.CanRead) { - FavoriteEntries.Add(match); + favorites.Add(match); } - } + } + FavoriteEntries = favorites; LoadingData = false; InvokeAsync(StateHasChanged); From 64bbdab332e6c557a8c69a9c0a46822ee29bf21c Mon Sep 17 00:00:00 2001 From: Chris Jacobsen Date: Sun, 11 Aug 2024 11:18:38 -0400 Subject: [PATCH 09/18] Add string keyed cache --- BLAZAMSession/ApplicationUserSessionCache.cs | 22 ++++++++++++++++--- .../IApplicationUserSessionCache.cs | 3 +++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/BLAZAMSession/ApplicationUserSessionCache.cs b/BLAZAMSession/ApplicationUserSessionCache.cs index 48ae1e30..5411131c 100644 --- a/BLAZAMSession/ApplicationUserSessionCache.cs +++ b/BLAZAMSession/ApplicationUserSessionCache.cs @@ -6,13 +6,14 @@ namespace BLAZAM.Server.Data.Services public class ApplicationUserSessionCache : IApplicationUserSessionCache { - private Dictionary _cache = new Dictionary(); + private Dictionary _typeCache = new Dictionary(); + private Dictionary _stringCache = new Dictionary(); public T Get(Type key) where T : new() { try { - return _cache.Keys.Contains(key) ? (T)_cache[key] : new T(); + return _typeCache.Keys.Contains(key) ? (T)_typeCache[key] : new T(); } catch { @@ -22,8 +23,23 @@ public class ApplicationUserSessionCache : IApplicationUserSessionCache public void Set(Type key, object value) { - _cache[key] = value; + _typeCache[key] = value; + } + public T Get(string key) where T : new() + { + try + { + return _stringCache.Keys.Contains(key) ? (T)_stringCache[key] : new T(); + } + catch + { + return new T(); + } } + public void Set(string key, object value) + { + _stringCache[key] = value; + } } } \ No newline at end of file diff --git a/BLAZAMSession/Interfaces/IApplicationUserSessionCache.cs b/BLAZAMSession/Interfaces/IApplicationUserSessionCache.cs index b7f029b7..796860c0 100644 --- a/BLAZAMSession/Interfaces/IApplicationUserSessionCache.cs +++ b/BLAZAMSession/Interfaces/IApplicationUserSessionCache.cs @@ -10,5 +10,8 @@ public interface IApplicationUserSessionCache /// The cached data, or a new instance of the data type if no data is cached. T Get(Type key) where T : new(); void Set(Type key, object value); + + T Get(string key) where T : new(); + void Set(string key, object value); } } \ No newline at end of file From 44ff05019ff3be7009e44022270e4694d260aea9 Mon Sep 17 00:00:00 2001 From: Chris Jacobsen Date: Sun, 11 Aug 2024 11:20:26 -0400 Subject: [PATCH 10/18] Add 60 second wait for reboot step in update job --- BLAZAMUpdate/ApplicationUpdate.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/BLAZAMUpdate/ApplicationUpdate.cs b/BLAZAMUpdate/ApplicationUpdate.cs index 2f3fcf3c..dbd8c05e 100644 --- a/BLAZAMUpdate/ApplicationUpdate.cs +++ b/BLAZAMUpdate/ApplicationUpdate.cs @@ -188,7 +188,7 @@ public IJob GetUpdateJob() var stagingCheckStep = new JobStep("Check prepared files", (step) => { return UpdateStagingDirectory.Exists; }); var bakupStep = new JobStep("Create backup", Backup); var updateUpdaterStep = new JobStep("Apply Files", InitiateFileCopy); - var waitForRestart = new JobStep("Wait for completion...",Wait); + var waitForRestart = new JobStep("Wait for completion...", Wait); updateJob.AddStep(cleanDownloadStep); updateJob.AddStep(downloadStep); updateJob.AddStep(cleanStageStep); @@ -196,6 +196,7 @@ public IJob GetUpdateJob() updateJob.AddStep(stagingCheckStep); updateJob.AddStep(bakupStep); updateJob.AddStep(updateUpdaterStep); + updateJob.AddStep(waitForRestart); return updateJob; @@ -210,12 +211,11 @@ public IJob GetUpdateJob() } private async Task Wait(JobStep? step) { - while (true) - { - await Task.Delay(1000); - } + + await Task.Delay(60000); + return false; } - private async Task InitiateFileCopy(JobStep? step) + private async Task InitiateFileCopy(JobStep? step) { //All prerequisites met From f7e9a2e64b80ec9af26ed17a8d0eba896f68e401 Mon Sep 17 00:00:00 2001 From: Chris Jacobsen Date: Sun, 11 Aug 2024 11:20:51 -0400 Subject: [PATCH 11/18] Enclose all settings references in null check --- BLAZAMGui/UI/Settings/SystemSettings.razor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BLAZAMGui/UI/Settings/SystemSettings.razor b/BLAZAMGui/UI/Settings/SystemSettings.razor index 1f430666..cea4b2cf 100644 --- a/BLAZAMGui/UI/Settings/SystemSettings.razor +++ b/BLAZAMGui/UI/Settings/SystemSettings.razor @@ -21,7 +21,7 @@ - } + @@ -50,7 +50,7 @@ @bind-Value="@settings.SendDeveloperAnalytics" /> - + } @AppLocalization["Logging"] From da8c5ff23e7d4d2511050971f255e9d5a3ca485f Mon Sep 17 00:00:00 2001 From: Chris Jacobsen Date: Sun, 11 Aug 2024 11:21:05 -0400 Subject: [PATCH 12/18] Increment build --- BLAZAM/BLAZAM.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BLAZAM/BLAZAM.csproj b/BLAZAM/BLAZAM.csproj index 4a5aa2ac..5b714540 100644 --- a/BLAZAM/BLAZAM.csproj +++ b/BLAZAM/BLAZAM.csproj @@ -6,7 +6,7 @@ enable false 1.0.0 - 2024.08.11.1350 + 2024.08.11.1513 false BLAZAM False From 600c52042c71713dae2b5b3e740ef2ff2e29807f Mon Sep 17 00:00:00 2001 From: Chris Jacobsen Date: Sun, 11 Aug 2024 12:36:13 -0400 Subject: [PATCH 13/18] Fixes for paths --- .../FileSystem/FileSystemBaseTests.cs | 4 +-- BLAZAM/BLAZAM.csproj | 4 +-- BLAZAM/updater/update.ps1 | 2 +- BLAZAMCommon/Helpers/CommonHelpers.cs | 2 +- BLAZAMFileSystem/FileSystemBase.cs | 22 ++++++------- BLAZAMFileSystem/SystemDirectory.cs | 32 +++++++++---------- BLAZAMFileSystem/SystemFile.cs | 26 +++++++-------- BLAZAMGui/UI/Settings/AvailableUpdate.razor | 4 +++ BLAZAMGui/UI/Settings/DatabaseStatus.razor | 2 +- BLAZAMUpdate/ApplicationUpdate.cs | 8 ++--- BLAZAMUpdate/Services/AutoUpdateService.cs | 2 +- 11 files changed, 56 insertions(+), 52 deletions(-) diff --git a/BLAZAM.Tests/FileSystem/FileSystemBaseTests.cs b/BLAZAM.Tests/FileSystem/FileSystemBaseTests.cs index 1ef0d422..377b975c 100644 --- a/BLAZAM.Tests/FileSystem/FileSystemBaseTests.cs +++ b/BLAZAM.Tests/FileSystem/FileSystemBaseTests.cs @@ -32,7 +32,7 @@ public void Constructor_ReplacesTempVariable_WhenPathContainsTemp() var fileSystemBase = new FileSystemBase(path); // Assert - Assert.Equal(Path.GetTempPath() + "test.txt", fileSystemBase.Path); + Assert.Equal(Path.GetTempPath() + "test.txt", fileSystemBase.FullPath); } [Fact] @@ -45,7 +45,7 @@ public void Constructor_SetsFullPath_WhenPathIsRelative() var fileSystemBase = new FileSystemBase(path); // Assert - Assert.Equal(Path.GetFullPath(path), fileSystemBase.Path); + Assert.Equal(Path.GetFullPath(path), fileSystemBase.FullPath); } [Fact] diff --git a/BLAZAM/BLAZAM.csproj b/BLAZAM/BLAZAM.csproj index 5b714540..d9d9e112 100644 --- a/BLAZAM/BLAZAM.csproj +++ b/BLAZAM/BLAZAM.csproj @@ -1,4 +1,4 @@ - + net8.0 @@ -6,7 +6,7 @@ enable false 1.0.0 - 2024.08.11.1513 + 2024.08.11.1633 false BLAZAM False diff --git a/BLAZAM/updater/update.ps1 b/BLAZAM/updater/update.ps1 index 50193308..21b141c4 100644 --- a/BLAZAM/updater/update.ps1 +++ b/BLAZAM/updater/update.ps1 @@ -245,7 +245,7 @@ Write-Host("Global Process Id: " + $global:processId); Quit } #> - PerformBackup + #PerformBackup ApplyUpdate diff --git a/BLAZAMCommon/Helpers/CommonHelpers.cs b/BLAZAMCommon/Helpers/CommonHelpers.cs index a23de290..bcd4718c 100644 --- a/BLAZAMCommon/Helpers/CommonHelpers.cs +++ b/BLAZAMCommon/Helpers/CommonHelpers.cs @@ -131,7 +131,7 @@ public static void AddToZip(this ZipArchive archive, SystemDirectory directory, { using FileStream fs = file.OpenReadStream(); // Create an entry for each file with its relative path - ZipArchiveEntry entry = archive.CreateEntry(directory.Path.Replace(basePath, "") + file.Name + file.Extension); + ZipArchiveEntry entry = archive.CreateEntry(directory.FullPath.Replace(basePath, "") + file.Name + file.Extension); // Copy the file contents to the entry stream diff --git a/BLAZAMFileSystem/FileSystemBase.cs b/BLAZAMFileSystem/FileSystemBase.cs index 7b6ef719..8e52503b 100644 --- a/BLAZAMFileSystem/FileSystemBase.cs +++ b/BLAZAMFileSystem/FileSystemBase.cs @@ -12,15 +12,15 @@ public FileSystemBase(string path) if (path is null) throw new ArgumentException("path parameter should not be null"); - path = path.Replace("%temp%", System.IO.Path.GetTempPath()); - Path = System.IO.Path.GetFullPath(path); - if (Path==null || Path=="") - Path = path; + path = path.Replace("%temp%", Path.GetTempPath()); + FullPath = Path.GetFullPath(path); + if (FullPath==null || FullPath=="") + FullPath = path; } /// /// The full raw path to this file or directory /// - public string Path { get; set; } + public string FullPath { get; set; } /// /// Indicates whether the executing identity has write permission to this directory or file @@ -32,11 +32,11 @@ public virtual bool Writable string? testFilePath = null; try { - var directoryInfo = new DirectoryInfo(Path); - var fileInfo = new FileInfo(Path); + var directoryInfo = new DirectoryInfo(FullPath); + var fileInfo = new FileInfo(FullPath); if (fileInfo.Exists) { - using (File.Open(Path, FileMode.Open, FileAccess.Write, FileShare.ReadWrite)) + using (File.Open(FullPath, FileMode.Open, FileAccess.Write, FileShare.ReadWrite)) { return true; } @@ -46,7 +46,7 @@ public virtual bool Writable { //if (!directoryInfo.Exists) throw new DirectoryNotFoundException("Directory " + Path + " does not exist!"); - testFilePath = System.IO.Path.GetFullPath(Path + "\\test.txt"); + testFilePath = System.IO.Path.GetFullPath(FullPath + "\\test.txt"); // Attempt to create a test file within the directory. using (File.Create(testFilePath)) @@ -88,12 +88,12 @@ public virtual bool Writable public override int GetHashCode() { - return Path.GetHashCode(); + return FullPath.GetHashCode(); } public override string? ToString() { - return Path; + return FullPath; } } } \ No newline at end of file diff --git a/BLAZAMFileSystem/SystemDirectory.cs b/BLAZAMFileSystem/SystemDirectory.cs index 6f819f83..51440a40 100644 --- a/BLAZAMFileSystem/SystemDirectory.cs +++ b/BLAZAMFileSystem/SystemDirectory.cs @@ -11,7 +11,7 @@ public class SystemDirectory : FileSystemBase { public SystemDirectory(string path) : base(path) { - + FullPath = Path.GetFullPath(path + Path.DirectorySeparatorChar); } /// /// All direct sub-directories of this directory @@ -25,7 +25,7 @@ public List SubDirectories { if (Exists) { - foreach (var directory in Directory.GetDirectories(Path)) + foreach (var directory in Directory.GetDirectories(FullPath)) { dirs.Add(new SystemDirectory(directory)); } @@ -37,7 +37,7 @@ public List SubDirectories } catch (Exception ex) { - Log.Error("Error getting directory files: " + Path, ex); + Log.Error("Error getting directory files: " + FullPath, ex); } return dirs; } @@ -45,7 +45,7 @@ public List SubDirectories /// /// Indicates whether this directory currently exists /// - public bool Exists => Directory.Exists(Path); + public bool Exists => Directory.Exists(FullPath); /// /// All direct sub-files of this directory @@ -59,7 +59,7 @@ public List Files { if (Exists) { - foreach (var file in Directory.GetFiles(Path)) + foreach (var file in Directory.GetFiles(FullPath)) { files.Add(new SystemFile(file)); } @@ -71,7 +71,7 @@ public List Files } catch (Exception ex) { - Log.Error("Error getting directory files: " + Path, ex); + Log.Error("Error getting directory files: " + FullPath, ex); } return files; } @@ -80,7 +80,7 @@ public List Files /// /// The full directory name /// - public string? Name => Path.Split("\\").Last(); + public string? Name => FullPath.Split("\\").Last(); public void ClearDirectory() { @@ -100,7 +100,7 @@ public void ClearDirectory() public bool CopyTo(SystemDirectory parentDirectory) { bool copyingDownTree = false; - if (parentDirectory.Path.Contains(Path)) + if (parentDirectory.FullPath.Contains(FullPath)) { copyingDownTree = true; } @@ -108,24 +108,24 @@ public bool CopyTo(SystemDirectory parentDirectory) if (Exists) { - var directories = Directory.GetDirectories(Path, "*", SearchOption.AllDirectories).AsEnumerable(); + var directories = Directory.GetDirectories(FullPath, "*", SearchOption.AllDirectories).AsEnumerable(); if (copyingDownTree) - directories = directories.Where(d => !d.Contains(parentDirectory.Path)); + directories = directories.Where(d => !d.Contains(parentDirectory.FullPath)); //Now Create all of the directories foreach (string dirPath in directories) { - Directory.CreateDirectory(dirPath.Replace(Path, parentDirectory.Path)); + Directory.CreateDirectory(dirPath.Replace(FullPath, parentDirectory.FullPath)); } - var files = Directory.GetFiles(Path, "*.*", SearchOption.AllDirectories).AsEnumerable(); + var files = Directory.GetFiles(FullPath, "*.*", SearchOption.AllDirectories).AsEnumerable(); if (copyingDownTree) - files = files.Where(f => !f.Contains(parentDirectory.Path)); + files = files.Where(f => !f.Contains(parentDirectory.FullPath)); //Copy all the files & Replaces any files with the same name foreach (string newPath in files) { - File.Copy(newPath, newPath.Replace(Path, parentDirectory.Path), true); + File.Copy(newPath, newPath.Replace(FullPath, parentDirectory.FullPath), true); } return true; @@ -140,7 +140,7 @@ public void Delete(bool recursive = false) { if (Exists) { - Directory.Delete(Path, recursive); + Directory.Delete(FullPath, recursive); } } /// @@ -148,7 +148,7 @@ public void Delete(bool recursive = false) /// public void EnsureCreated() { - Directory.CreateDirectory(Path); + Directory.CreateDirectory(FullPath); } } } diff --git a/BLAZAMFileSystem/SystemFile.cs b/BLAZAMFileSystem/SystemFile.cs index c05a1b42..8191f51c 100644 --- a/BLAZAMFileSystem/SystemFile.cs +++ b/BLAZAMFileSystem/SystemFile.cs @@ -9,32 +9,32 @@ public class SystemFile : FileSystemBase public SystemFile(string path) : base(path) { } - public bool Exists => File.Exists(Path); + public bool Exists => File.Exists(FullPath); - public string Name => System.IO.Path.GetFileNameWithoutExtension(Path); - public string Extension => System.IO.Path.GetExtension(Path); - public SystemDirectory ParentDirectory => new SystemDirectory(System.IO.Path.GetDirectoryName(Path)); + public string Name => System.IO.Path.GetFileNameWithoutExtension(FullPath); + public string Extension => System.IO.Path.GetExtension(FullPath); + public SystemDirectory ParentDirectory => new SystemDirectory(System.IO.Path.GetDirectoryName(FullPath)); public async Task ReadAllBytesAsync() { - return await File.ReadAllBytesAsync(Path); + return await File.ReadAllBytesAsync(FullPath); } public byte[] ReadAllBytes() { - return File.ReadAllBytes(Path); + return File.ReadAllBytes(FullPath); } public string ReadAllText() { - return File.ReadAllText(Path); + return File.ReadAllText(FullPath); } public bool WriteAllText(string? text) { - File.WriteAllText(Path, text); + File.WriteAllText(FullPath, text); return true; } - public DateTime LastModified { get => File.GetLastWriteTime(Path); } + public DateTime LastModified { get => File.GetLastWriteTime(FullPath); } public TimeSpan SinceLastModified { get => DateTime.Now - LastModified; } /// @@ -54,12 +54,12 @@ public override bool Writable public void Delete() { - File.Delete(Path); + File.Delete(FullPath); } public FileStream OpenReadStream() { - return new FileStream(Path, FileMode.Open, FileAccess.Read, FileShare.None, bufferSize: 4096, useAsync: true); + return new FileStream(FullPath, FileMode.Open, FileAccess.Read, FileShare.None, bufferSize: 4096, useAsync: true); } /// /// Returns an opened stream reader to this file @@ -67,7 +67,7 @@ public FileStream OpenReadStream() /// public FileStream OpenWriteStream() { - return new FileStream(Path, FileMode.Create, FileAccess.Write, FileShare.None, bufferSize: 4096, useAsync: true); + return new FileStream(FullPath, FileMode.Create, FileAccess.Write, FileShare.None, bufferSize: 4096, useAsync: true); } /// @@ -87,7 +87,7 @@ private void Create() { ParentDirectory.EnsureCreated(); } - var stream = new FileStream(Path, FileMode.OpenOrCreate, FileAccess.Read, FileShare.None, bufferSize: 4096, useAsync: true); + var stream = new FileStream(FullPath, FileMode.OpenOrCreate, FileAccess.Read, FileShare.None, bufferSize: 4096, useAsync: true); stream.Close(); } } diff --git a/BLAZAMGui/UI/Settings/AvailableUpdate.razor b/BLAZAMGui/UI/Settings/AvailableUpdate.razor index a0138939..8864fb28 100644 --- a/BLAZAMGui/UI/Settings/AvailableUpdate.razor +++ b/BLAZAMGui/UI/Settings/AvailableUpdate.razor @@ -37,6 +37,10 @@ @Update.PrequisiteMessage } + @if(ApplicationInfo.InDebugMode && CurrentUser.State.IsSuperAdmin) + { + @Update.UpdateCommand + } diff --git a/BLAZAMGui/UI/Settings/DatabaseStatus.razor b/BLAZAMGui/UI/Settings/DatabaseStatus.razor index cb19a013..91ab22a8 100644 --- a/BLAZAMGui/UI/Settings/DatabaseStatus.razor +++ b/BLAZAMGui/UI/Settings/DatabaseStatus.razor @@ -80,7 +80,7 @@ { ZipArchive exportZip = new ZipArchive(memoryStream, ZipArchiveMode.Create); var exportDir = new SystemDirectory("export"); - exportZip.AddToZip(exportDir, exportDir.Path); + exportZip.AddToZip(exportDir, exportDir.FullPath); memoryStream.SaveTo(new SystemFile("export/" + DatabaseCache.ApplicationSettings.AppName + "-" + DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss") + ".zip")); return true; diff --git a/BLAZAMUpdate/ApplicationUpdate.cs b/BLAZAMUpdate/ApplicationUpdate.cs index dbd8c05e..5bced2cc 100644 --- a/BLAZAMUpdate/ApplicationUpdate.cs +++ b/BLAZAMUpdate/ApplicationUpdate.cs @@ -239,7 +239,7 @@ private async Task InitiateFileCopy(JobStep? step) catch (Exception ex) { Loggers.UpdateLogger?.Error("Error applying update: {@Error}", ex); - + throw new ApplicationUpdateException("Error trying to apply update files", ex); } return false; } @@ -290,8 +290,8 @@ private bool ApplyFiles() - SystemDirectory updaterDirFromStagedUpdate = new SystemDirectory(UpdateStagingDirectory.Path + "\\updater\\"); - SystemDirectory updaterDir = new SystemDirectory(_applicationRootDirectory.Path + "updater\\"); + SystemDirectory updaterDirFromStagedUpdate = new SystemDirectory(UpdateStagingDirectory.FullPath + "updater\\"); + SystemDirectory updaterDir = new SystemDirectory(_applicationRootDirectory.FullPath + "updater\\"); updaterDirFromStagedUpdate.CopyTo(updaterDir); //File.Copy(UpdateStagingDirectory + "\\updater\\", _applicationRootDirectory + "updater\\", true); Loggers.UpdateLogger?.Information("Updater updated"); @@ -410,7 +410,7 @@ public async Task ExtractFiles(JobStep? step) try { var zip = new ZipArchive(streamToReadFrom); - zip.ExtractToDirectory(UpdateStagingDirectory.Path, true); + zip.ExtractToDirectory(UpdateStagingDirectory.FullPath, true); Loggers.UpdateLogger?.Debug(UpdateFile + " unzipped successfully to " + UpdateStagingDirectory); return true; diff --git a/BLAZAMUpdate/Services/AutoUpdateService.cs b/BLAZAMUpdate/Services/AutoUpdateService.cs index e4c38c95..f7660692 100644 --- a/BLAZAMUpdate/Services/AutoUpdateService.cs +++ b/BLAZAMUpdate/Services/AutoUpdateService.cs @@ -172,7 +172,7 @@ private void CleanDirectories(object? state) } catch (Exception ex) { - Loggers.UpdateLogger.Error("Other error cleaning staging files {Directory}{@Error}", dir.Path, ex); + Loggers.UpdateLogger.Error("Other error cleaning staging files {Directory}{@Error}", dir.FullPath, ex); //file.Delete(); } } From 6390fe6cc4889f7e4b2f228d4adcc81d15d9eb98 Mon Sep 17 00:00:00 2001 From: Chris Jacobsen Date: Sun, 11 Aug 2024 12:45:01 -0400 Subject: [PATCH 14/18] Update test --- BLAZAM/BLAZAM.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BLAZAM/BLAZAM.csproj b/BLAZAM/BLAZAM.csproj index d9d9e112..8ee0974c 100644 --- a/BLAZAM/BLAZAM.csproj +++ b/BLAZAM/BLAZAM.csproj @@ -1,4 +1,4 @@ - + net8.0 @@ -6,7 +6,7 @@ enable false 1.0.0 - 2024.08.11.1633 + 2024.08.11.1644 false BLAZAM False From c78d5d6efebb0555445aa4c8077b5d1c7e886e02 Mon Sep 17 00:00:00 2001 From: Chris Jacobsen Date: Sun, 11 Aug 2024 23:55:01 -0400 Subject: [PATCH 15/18] Another update test --- BLAZAM/BLAZAM.csproj | 2 +- BLAZAMGui/UI/Settings/Permissions/TestComponent.razor | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) delete mode 100644 BLAZAMGui/UI/Settings/Permissions/TestComponent.razor diff --git a/BLAZAM/BLAZAM.csproj b/BLAZAM/BLAZAM.csproj index 8ee0974c..f1f692e7 100644 --- a/BLAZAM/BLAZAM.csproj +++ b/BLAZAM/BLAZAM.csproj @@ -6,7 +6,7 @@ enable false 1.0.0 - 2024.08.11.1644 + 2024.08.12.0302 false BLAZAM False diff --git a/BLAZAMGui/UI/Settings/Permissions/TestComponent.razor b/BLAZAMGui/UI/Settings/Permissions/TestComponent.razor deleted file mode 100644 index 39dc46e1..00000000 --- a/BLAZAMGui/UI/Settings/Permissions/TestComponent.razor +++ /dev/null @@ -1,9 +0,0 @@ -@inherits AppModalContentBase -

TestComponent

- -@code { - protected override void OnInitialized() - { - base.OnInitialized(); - } -} From 0e302c3289d591527e5e08228c7cea0b1a1fb7b7 Mon Sep 17 00:00:00 2001 From: Chris Jacobsen Date: Mon, 12 Aug 2024 17:23:29 -0400 Subject: [PATCH 16/18] Restart app after finalizing install --- BLAZAM/Pages/Install/Install.razor | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/BLAZAM/Pages/Install/Install.razor b/BLAZAM/Pages/Install/Install.razor index 372cc403..97a9f2c0 100644 --- a/BLAZAM/Pages/Install/Install.razor +++ b/BLAZAM/Pages/Install/Install.razor @@ -2,7 +2,7 @@ @page "/install/{selectedStep}" @layout InstallLayout @inherits AppComponentBase - +@inject ApplicationManager ApplicationManager Install - Blazam @@ -97,7 +97,7 @@ else } - + async void UpdateStatuses() { Context = DbFactory.CreateDbContext(); @@ -130,7 +130,7 @@ else completedSteps = 4; await InvokeAsync(StateHasChanged); - + } } @@ -178,6 +178,7 @@ else var result = await Context.SaveChangesAsync(); ApplicationInfo.InstallationCompleted = true; Nav.NavigateTo("/home", true); + ApplicationManager.Restart(); } catch { From 5b0e8722098a1fee9712177c0f61021a0f875f25 Mon Sep 17 00:00:00 2001 From: Chris Jacobsen Date: Mon, 12 Aug 2024 18:57:54 -0400 Subject: [PATCH 17/18] Minor UI changs --- BLAZAM/BLAZAM.csproj | 2 +- BLAZAM/Pages/Install/ADirectory.razor | 2 +- BLAZAM/ProgramHelpers.cs | 14 ++ .../Interfaces/IDirectoryEntryAdapter.cs | 2 +- .../Settings/ActiveDirectoryStatusPanel.razor | 125 ++++++-------- BLAZAMGui/UI/Settings/DirectorySettings.razor | 157 ++++++++++-------- .../UI/Users/RenameUserModalContent.razor | 42 ++--- BLAZAMUpdate/Services/UpdateService.cs | 20 ++- 8 files changed, 192 insertions(+), 172 deletions(-) diff --git a/BLAZAM/BLAZAM.csproj b/BLAZAM/BLAZAM.csproj index f1f692e7..6f7494ff 100644 --- a/BLAZAM/BLAZAM.csproj +++ b/BLAZAM/BLAZAM.csproj @@ -6,7 +6,7 @@ enable false 1.0.0 - 2024.08.12.0302 + 2024.08.12.2250 false BLAZAM False diff --git a/BLAZAM/Pages/Install/ADirectory.razor b/BLAZAM/Pages/Install/ADirectory.razor index 65a7d137..457010da 100644 --- a/BLAZAM/Pages/Install/ADirectory.razor +++ b/BLAZAM/Pages/Install/ADirectory.razor @@ -4,7 +4,7 @@ @{ }
- +
diff --git a/BLAZAM/ProgramHelpers.cs b/BLAZAM/ProgramHelpers.cs index db0bfce8..db2b37b9 100644 --- a/BLAZAM/ProgramHelpers.cs +++ b/BLAZAM/ProgramHelpers.cs @@ -18,6 +18,7 @@ using BLAZAM.Session; using Microsoft.AspNetCore.Authentication; using System.Management; +using BLAZAM.Update.Services; namespace BLAZAM.Server { @@ -354,6 +355,19 @@ private static void PreloadServices() { Loggers.SystemLogger.Error(ex.Message + " {@Error}", ex); } + try + { + if (ApplicationInfo.installationCompleted) + { + var context = Program.AppInstance.Services.GetRequiredService(); + context.Initialize(); + } + + } + catch (Exception ex) + { + Loggers.SystemLogger.Error(ex.Message + " {@Error}", ex); + } } } diff --git a/BLAZAMActiveDirectory/Interfaces/IDirectoryEntryAdapter.cs b/BLAZAMActiveDirectory/Interfaces/IDirectoryEntryAdapter.cs index c5611f19..4047fffb 100644 --- a/BLAZAMActiveDirectory/Interfaces/IDirectoryEntryAdapter.cs +++ b/BLAZAMActiveDirectory/Interfaces/IDirectoryEntryAdapter.cs @@ -261,7 +261,7 @@ public interface IDirectoryEntryAdapter : IDisposable Task CommitChangesAsync(IJob? commitJob = null); /// - /// Resets the current entry state to it's inital state + /// Resets the current entry state to it's initial state /// void DiscardChanges(); diff --git a/BLAZAMGui/UI/Settings/ActiveDirectoryStatusPanel.razor b/BLAZAMGui/UI/Settings/ActiveDirectoryStatusPanel.razor index b624ef62..6f4f0aae 100644 --- a/BLAZAMGui/UI/Settings/ActiveDirectoryStatusPanel.razor +++ b/BLAZAMGui/UI/Settings/ActiveDirectoryStatusPanel.razor @@ -1,9 +1,44 @@ @using System.DirectoryServices; @inherits AppComponentBase - + - @AppLocalization["Active Directory Connection Status"] - + + @AppLocalization["Active Directory Connection Status"] + + + + + + @AppLocalization["Server Port Open"] + + + + + + + @AppLocalization["Credentials OK"] + + + + + + + + @AppLocalization["Connected"] + + + + + + + + @AppLocalization["Connection Type"] + + + + + @if (showProgress) { @@ -12,78 +47,10 @@ } - - @AppLocalization["Server Port Open"] - - - - - - @AppLocalization["Credentials OK"] - - - - - @AppLocalization["Connected"] - - - - - - - @AppLocalization["Connection Type"] - - - - - - @* - @if (_credStatus) - { - var firstDC = Directory.DomainControllers.FirstOrDefault(); - if(firstDC!=null){ - - - Domain - @firstDC.Domain.Name - - - - Domain Mode - @firstDC.Domain.DomainMode - - - - Domain Level - @firstDC.Domain.DomainModeLevel - - - - Primary Domain Controller - @firstDC.Domain.PdcRoleOwner - - - - Domain - @Directory.DomainControllers.FirstOrDefault()?.Domain.Forest.RootDomain.Name - - - } - else - { - Could not reach Domain Controllers directly from application server. Please check DNS. - } - - } - *@ @code { -#nullable disable warnings + #nullable disable warnings [Parameter] public EventCallback DirectoryConnected { get; set; } @@ -194,6 +161,18 @@ }); } + private bool? GetConnectionTypeStatus() + { + if (Directory.Status != DirectoryConnectionStatus.OK) return false; + return Directory.AppRootDirectoryEntry != null && ( + Directory.AppRootDirectoryEntry.AuthenticationType.Equals(AuthenticationTypes.Encryption) || + Directory.AppRootDirectoryEntry.AuthenticationType.Equals(AuthenticationTypes.SecureSocketsLayer) || + Directory.AppRootDirectoryEntry.AuthenticationType.Equals(AuthenticationTypes.Secure)); + } + private string? GetConnectionType() + { - + if (Directory.Status != DirectoryConnectionStatus.OK) return null; + return Directory.AppRootDirectoryEntry?.AuthenticationType.ToString(); + } } diff --git a/BLAZAMGui/UI/Settings/DirectorySettings.razor b/BLAZAMGui/UI/Settings/DirectorySettings.razor index d1657dc6..40a3c02f 100644 --- a/BLAZAMGui/UI/Settings/DirectorySettings.razor +++ b/BLAZAMGui/UI/Settings/DirectorySettings.razor @@ -5,142 +5,161 @@ @AppLocalization["Active Directory Settings"] + + + - - + - @if (ApplicationInfo.InDemoMode && UserStateService.CurrentUsername == "Demo") - { + @if (ApplicationInfo.InDemoMode && UserStateService.CurrentUsername == "Demo") + { - - } - else - { + + } + else + { - + - + - } + } - - + + - @{ - string helperText = "The default port of 389 is the recommended port to use."; - } + @{ + string helperText = "The default port of 389 is the recommended port to use."; + } - @* - TODO Add this as a popover - - - *@ + @* + TODO Add this as a popover + + + *@ - @if (ApplicationInfo.InDemoMode && UserStateService.CurrentUsername == "Demo") - { - + @if (ApplicationInfo.InDemoMode && UserStateService.CurrentUsername == "Demo") + { + - } - else - { + } + else + { - + - } + } + + + + + + + - + - + - - + - + - + - + - + - + - + + - - + - + + - - + - + + - + - + Save Changes - + + + @if (ShowStatusPanel) + { + + + + + + + } + - - Save Changes - @code { - #nullable disable warnings +#nullable disable warnings ADSettings settings = new ADSettings(); bool _insert; + [Parameter] + public bool ShowStatusPanel { get; set; } = true; string passwordInDb; protected override async Task OnInitializedAsync() diff --git a/BLAZAMGui/UI/Users/RenameUserModalContent.razor b/BLAZAMGui/UI/Users/RenameUserModalContent.razor index 4f840991..39d8c956 100644 --- a/BLAZAMGui/UI/Users/RenameUserModalContent.razor +++ b/BLAZAMGui/UI/Users/RenameUserModalContent.razor @@ -1,50 +1,54 @@ @inherits AppModalContent @if (User != null && _privateUserInstance != null) { - - + + + - - + - - - - - - + - - @if (User.CanEditField(ActiveDirectoryFields.SAMAccountName)) - { + + - - } - @if (User.CanEditField(ActiveDirectoryFields.Mail)) - { + @if (User.CanEditField(ActiveDirectoryFields.SAMAccountName)) + { - + - } + + } + @if (User.CanEditField(ActiveDirectoryFields.Mail)) + { + + + + + + + } + + } else { diff --git a/BLAZAMUpdate/Services/UpdateService.cs b/BLAZAMUpdate/Services/UpdateService.cs index 75008cc6..e623117a 100644 --- a/BLAZAMUpdate/Services/UpdateService.cs +++ b/BLAZAMUpdate/Services/UpdateService.cs @@ -50,12 +50,16 @@ public UpdateService(IHttpClientFactory _clientFactory, ApplicationInfo applicat { _dbFactory = dbFactory; httpClientFactory = _clientFactory; - _updateCheckTimer = new Timer(CheckForUpdate, null, TimeSpan.FromSeconds(20), TimeSpan.FromHours(1)); _applicationInfo = applicationInfo; AppLocalization = appLocalization; } + public void Initialize() + { + _updateCheckTimer = new Timer(CheckForUpdate, null, TimeSpan.FromSeconds(20), TimeSpan.FromHours(1)); + + } /// - /// Polls Github for the latest release in the selected branch + /// Polls GitHub for the latest release in the selected branch /// /// /// Also collects all stable releases for changelogs. @@ -72,13 +76,13 @@ public UpdateService(IHttpClientFactory _clientFactory, ApplicationInfo applicat return NewestAvailableUpdate; } - catch (Octokit.RateLimitExceededException ex) + catch (RateLimitExceededException ex) { throw ex; } catch (Exception ex) { - Loggers.UpdateLogger.Error("An error occured while getting latest update {@Error}", ex); + Loggers.UpdateLogger.Error("An error occurred while getting latest update {@Error}", ex); } return null; @@ -86,7 +90,7 @@ public UpdateService(IHttpClientFactory _clientFactory, ApplicationInfo applicat private async Task GetReleases() { - //Create a github client to get api data from repo + //Create a GitHub client to get api data from repo Release? latestBranchRelease = null; Release? latestStableRelease = null; @@ -114,8 +118,8 @@ private async Task GetReleases() { //Get the release filename to prepare a version object var fn = Path.GetFileNameWithoutExtension(release?.Assets.FirstOrDefault()?.Name); - //Create that version object if (fn == null) continue; + //Create that update object try { AvailableUpdates.Add(EncapsulateUpdate(release, ApplicationReleaseBranches.Stable)); @@ -133,9 +137,9 @@ private async Task GetReleases() { if (release != null) { - //Get the release filename to prepare a version object + //Get the release filename to check that the release zip exists var fn = Path.GetFileNameWithoutExtension(release?.Assets.FirstOrDefault()?.Name); - //Create that version object + //Create that update object if (fn == null) continue; try { From 9275d30f830517f28b0b67c5402a84e44a613356 Mon Sep 17 00:00:00 2001 From: Chris Jacobsen Date: Mon, 12 Aug 2024 19:08:38 -0400 Subject: [PATCH 18/18] Update Test --- BLAZAM/BLAZAM.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BLAZAM/BLAZAM.csproj b/BLAZAM/BLAZAM.csproj index 6f7494ff..836ed4d0 100644 --- a/BLAZAM/BLAZAM.csproj +++ b/BLAZAM/BLAZAM.csproj @@ -6,7 +6,7 @@ enable false 1.0.0 - 2024.08.12.2250 + 2024.08.12.2308 false BLAZAM False