Skip to content

Commit

Permalink
Merge pull request #645 from Blazam-App/v1-Dev
Browse files Browse the repository at this point in the history
Playwright test fix after notifications moved
  • Loading branch information
jacobsen9026 authored Nov 13, 2024
2 parents 58ac262 + bd1b85c commit edca13c
Show file tree
Hide file tree
Showing 9 changed files with 226 additions and 164 deletions.
2 changes: 1 addition & 1 deletion BLAZAM/BLAZAM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<ServerGarbageCollection>false</ServerGarbageCollection>
<AssemblyVersion>1.1.0</AssemblyVersion>
<Version>2024.11.11.2302</Version>
<Version>2024.11.13.1850</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<RootNamespace>BLAZAM</RootNamespace>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
Expand Down
51 changes: 4 additions & 47 deletions BLAZAM/updater/update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ $updateScript= {

if(!$global:iis){
Stop-Process -ID $global:processId -Force

Stop-Service -Name "Blazam" -Force -ErrorAction Continue
}

Start-Sleep -Seconds 15
Expand All @@ -74,56 +76,11 @@ $updateScript= {
Remove-Item -Path $global:destination\app_offline.htm -Force

if(!$global:iis){
Write-Host("Process path: " + $global:processFilePath)

if($global:processArguments -ne $null -and $global:processArguments -ne "")
{

Write-Host("Starting with arguments: " + $global:processArguments)
$restartedProcess = Start-Process -FilePath $global:processFilePath -ArgumentList $global:processArguments -WorkingDirectory $global:destination -PassThru
Start-Service -Name "Blazam" -ErrorAction Continue

}else{
$restartedProcess = Start-Process -FilePath $global:processFilePath -WorkingDirectory $global:destination -PassThru

}
Write-Host("Waiting 15 seconds for Application to restart")
Start-Sleep -Seconds 15
<#
Write-Host("Process Stats: "+($restartedProcess| Select-Object *))
if ($restartedProcess.ExitTime -eq $null -or $global:iis) {
Write-Host("Error: Web Application failed to restart rolling back changes")
#Perform Rollback Section
$restoreSource = $backupDirectory + "*"
Write-Host("Rolling back update")
Write-Host("Source: " + $restoreSource)
Write-Host("Destination: " + $global:destination)
Copy-Item -Path $restoreSource -Destination $backupDirectory -Recurse -Verbose -Force
Write-Host("Restarting ApplicationPool")
if($global:processArguments -ne $null -and $global:processArguments -ne "")
{
Write-Host("Starting with arguments: " + $global:processArguments)
$restartedProcess = Start-Process -FilePath $global:processFilePath -ArgumentList $global:processArguments -PassThru
}else{
$restartedProcess = Start-Process -FilePath $global:processFilePath -PassThru
}
#$runningSite | Start-IISSite
Write-Host("Waiting 15 seconds for Application to restart")
Start-Sleep -Seconds 15
if ($restartedProcess.ExitTime -eq $null) {
Write-Host("Error: Rollback performed, but application did not start! Oh no...")
}
else {
Write-Host("Rollback completed successfully")
}
Stop-Transcript
exit
}
#>

}


Expand Down
20 changes: 12 additions & 8 deletions BLAZAMGui/Layouts/UserNotificationsProvider.razor
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,22 @@

if (notifications != null && notifications.Select(n => n.User).Contains(UserState.Preferences))
{
Notifications = await Context.UserNotifications.Where(un => un.User.Id == UserState.Id && !un.IsRead).ToListAsync();
await InvokeAsync(StateHasChanged);
await LoadNotifications();

}
});

NotificationPublisher.OnNotificationDeleted += async () =>
{
Notifications = await Context.UserNotifications.Where(un => un.User.Id == UserState.Id && !un.IsRead).ToListAsync();

InvokeAsync(StateHasChanged);
await LoadNotifications();
};

UserState = CurrentUser.State;
await InvokeAsync(StateHasChanged);
if (UserState != null)
UserState.OnSettingsChanged += async () =>
{
Notifications = await Context.UserNotifications.Where(un => un.User.Id == UserState.Id && !un.IsRead).ToListAsync();

InvokeAsync(StateHasChanged);
await LoadNotifications();
};

Notifications = await Context.UserNotifications.Where(un => un.User.Id == UserState.Id && !un.IsRead).ToListAsync();
Expand All @@ -72,4 +67,13 @@
// });
}
private async Task LoadNotifications()
{
var context = await DbFactory.CreateDbContextAsync();
lock (Notifications)
{
Notifications = context.UserNotifications.Where(un => un.User.Id == UserState.Id && !un.IsRead).ToList();
}
await InvokeAsync(StateHasChanged);
}
}
16 changes: 13 additions & 3 deletions BLAZAMGui/UI/Settings/AvailableUpdate.razor
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,22 @@
<MudMarkdown OverrideHeaderTypo=ConvertHeaders Value="@Update.Release.ReleaseNotes" />
</MudExpansionPanel>
</MudExpansionPanels>
@if (Update.Newer && Update.PassesPrerequisiteChecks)
@if ((Update.Newer || ApplicationInfo.InDebugMode) && Update.PassesPrerequisiteChecks)
{
<MudButton Class="mx-6" Variant=Variant.Filled Color=Color.Success OnClick="(()=>{OnApply.InvokeAsync();})">Apply Update</MudButton>
<MudButton Class="mx-6"
Variant=Variant.Filled
Color=Color.Success
OnClick="(()=>{OnApply.InvokeAsync();})">
@AppLocalization["Apply Update"]
</MudButton>
@if (ApplicationInfo.InDebugMode)
{
<MudButton Class="mx-6" Disabled=@(AutoUpdateService.IsUpdatedScheduled) OnClick="(()=>{OnSchedule.InvokeAsync();})" Color="Color.Success">Test Auto Update</MudButton>
<MudButton Class="mx-6"
Disabled=@(AutoUpdateService.IsUpdatedScheduled)
OnClick="(()=>{OnSchedule.InvokeAsync();})"
Color="Color.Success">
Test Auto Update
</MudButton>


}
Expand Down
16 changes: 12 additions & 4 deletions BLAZAMGui/UI/Settings/ManualApplicationUpdater.razor
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@
default:


<MudTimeline TimelineAlign="TimelineAlign.Default" TimelinePosition="TimelinePosition.Top" Style="max-height:600px;" Class="overflow-y-auto">
<MudTimeline TimelineAlign="TimelineAlign.Default"
TimelinePosition="TimelinePosition.Top"
Style="max-height:600px;"
Class="overflow-y-auto">
@{
int i = 0;
}
Expand All @@ -76,7 +79,11 @@
<MudCard Class="pa-3">


<MudButton Class="mx-6" OnClick="(()=>{ShowAllUpdates=!ShowAllUpdates;})" Color="Color.Success">@(ShowAllUpdates == false ? "Show Previous Updates" : "Hide Previous Updates")</MudButton>
<MudButton Class="mx-6"
OnClick="(()=>{ShowAllUpdates=!ShowAllUpdates;})"
Color="Color.Success">
@(ShowAllUpdates == false ? "Show Previous Updates" : "Hide Previous Updates")
</MudButton>



Expand All @@ -90,7 +97,7 @@

@if (ShowAllUpdates)
{
@foreach (var update in UpdateService.AvailableUpdates.Where(x => x.Version<=ApplicationInfo.RunningVersion).OrderBy(x => x.Version))
@foreach (var update in UpdateService.AvailableUpdates.Where(x => x.Version <= ApplicationInfo.RunningVersion).OrderBy(x => x.Version))
{


Expand All @@ -100,6 +107,7 @@

}
}

@if (UpdateService.NewestAvailableUpdate != null)
{
if (UpdateService.NewestAvailableUpdate.Version.NewerThan(ApplicationInfo.RunningVersion))
Expand All @@ -119,7 +127,7 @@
</MudTimelineItem>
}
}

@if (UpdateService.IncompatibleUpdates.Count > 0)
{
var latestIncompatibleUpdate = UpdateService.IncompatibleUpdates.Where(x => x.Newer).OrderByDescending(x => x.Release.ReleaseTime).FirstOrDefault();
Expand Down
44 changes: 26 additions & 18 deletions BLAZAMGui/UI/Settings/Permissions/EditAccessLevel.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
<MudStack Row=true>
@if (!Self)
{
<MudTextField Disabled=@(WorkingModel.Id==1) Label="@AppLocalization["Name"]" @bind-Value=WorkingModel.Name
/>
<MudTextField Disabled=@(WorkingModel.Id==1)
Label="@AppLocalization["Name"]"
@bind-Value=WorkingModel.Name />
}
@if (!Self)
{
Expand Down Expand Up @@ -70,20 +71,20 @@

}
</MudSelect>
<AppCloseButton Disabled=@(WorkingModel.Id==1)
Tooltip=@AppLocalization["Remove"]
OnClick="()=>RemoveObjectTypeAccess(objectMap)" />


<AppCloseButton Disabled=@(WorkingModel.Id==1)
Tooltip=@AppLocalization["Remove"]
OnClick="()=>RemoveObjectTypeAccess(objectMap)" />
}
</MudCardHeader>
<MudCardContent>



@if (objectMap.ObjectType == ActiveDirectoryObjectType.User
&& objectMap.ObjectAccessLevelId != ObjectAccessLevels.Deny.Id
&& !Self)
@if (objectMap.ObjectType == ActiveDirectoryObjectType.User
&& objectMap.ObjectAccessLevelId != ObjectAccessLevels.Deny.Id
&& !Self)
{
<MudSwitch T=bool
UncheckedColor="Color.Error"
Expand Down Expand Up @@ -240,21 +241,28 @@
</MudCard>

}

</FlexContainer>

@{
string buttonLabel = AppLocalization["Create Access Level"];
if (Model.Id > 0)
buttonLabel = AppLocalization["Update Access Level"];
}
<MudButton Disabled=@(SaveDisabled || WorkingModel.Id==1) Color=Color.Success Margin=Margin.IsAuto.OnX OnClick="SaveAccessLevel">@buttonLabel</MudButton>
<MudButton Disabled=@(SaveDisabled || WorkingModel.Id==1)
Color=Color.Success
OnClick="SaveAccessLevel">@buttonLabel</MudButton>
@if (WorkingModel.Id != 0 && !Self)
{
<MudButton Disabled=@(WorkingModel.Id==1) Color=Color.Error Margin=Margin.IsAuto.OnX OnClick="@(()=>{_deleteModal.ShowAsync();})">@AppLocalization["Delete Access Level"]</MudButton>
<AppModal Width="MaxWidth.Medium" @ref=_deleteModal Title="@AppLocalization["Confirm deletion"]">
<DeleteAccessLevelModalContent AccessLevel="Model" OnConfirm="@(()=>{DeleteAccessLevel();})"/>
</AppModal>
<MudButton Disabled=@(WorkingModel.Id==1)
Color=Color.Error
OnClick="@(()=>{_deleteModal.ShowAsync();})">@AppLocalization["Delete Access Level"]</MudButton>
<AppModal Width="MaxWidth.Medium"
@ref=_deleteModal
Title="@AppLocalization["Confirm deletion"]">
<DeleteAccessLevelModalContent AccessLevel="Model"
OnConfirm="@(()=>{DeleteAccessLevel();})" />
</AppModal>
}

@code {
Expand All @@ -265,7 +273,7 @@
[Parameter]
public bool Self { get; set; }


AppModal? _deleteModal;

bool ShowFields
Expand Down Expand Up @@ -338,7 +346,7 @@
SnackBarService.Success(WorkingModel.Name + " has been updated");


if (addition&& !Self)
if (addition && !Self)
WorkingModel = new();
await LevelsChanged.InvokeAsync();

Expand Down
Loading

0 comments on commit edca13c

Please sign in to comment.