Skip to content

Commit

Permalink
Merge pull request #141 from Blazam-App/Beta-Dev
Browse files Browse the repository at this point in the history
New Application Update presentation in Update settings
  • Loading branch information
jacobsen9026 authored Nov 9, 2023
2 parents 3fc8fa7 + 7d0df63 commit 0f8afe8
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 72 deletions.
3 changes: 2 additions & 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>0.8.4</AssemblyVersion>
<Version>2023.11.09.1349</Version>
<Version>2023.11.09.1641</Version>
<RootNamespace>BLAZAM</RootNamespace>
<GenerateDocumentationFile>False</GenerateDocumentationFile>

Expand Down Expand Up @@ -84,6 +84,7 @@
<ItemGroup>
<None Include="..\BLAZAMGui\UI\Chat\ChatMessage.razor" Link="ChatMessage.razor" />
<None Include="..\BLAZAMGui\UI\Inputs\ADAutoCompleteResult.razor" Link="ADAutoCompleteResult.razor" />
<None Include="..\BLAZAMGui\UI\Settings\AvailableUpdate.razor" Link="AvailableUpdate.razor" />
<None Include="..\BLAZAMGui\UI\Settings\Templates\AssignedTemplateGroup.razor" Link="AssignedTemplateGroup.razor" />
</ItemGroup>

Expand Down
53 changes: 53 additions & 0 deletions BLAZAMCommon/Data/ApplicationVersion.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Metadata.Ecma335;

namespace BLAZAM.Common.Data
{
/// <summary>
/// A representation of a version of the app.
///
/// </summary>
/// <remarks>
/// [0.8.4].[2023.11.09.1134]
/// <para>
///
/// [AssemblyVersion][Build Number]
/// </para>
/// </remarks>
public class ApplicationVersion : IComparable
{
public Version AssemblyVersion { get; private set; }
Expand Down Expand Up @@ -44,6 +56,47 @@ public ApplicationVersion(string fullVersionString)
BuildNumber = buildNumber;
}
}
/// <summary>
/// The UTC time of release for this version
/// </summary>
/// <remarks>
/// This is calculated from the build number
/// </remarks>
public DateTime ReleaseDate
{
get
{
DateTime release = DateTime.MinValue;
var buildNumberParts = BuildNumber.Split('.');
string year="";
string month="";
string day="";
string time="";
for (int x = 0; x < buildNumberParts.Length; x++)
{
switch (x)
{
case 0:
year = buildNumberParts[x];
break;
case 1:
month = buildNumberParts[x];

break;
case 2:
day = buildNumberParts[x];

break;
case 3:
time = buildNumberParts[x];
time=time.Insert(2, ":");
break;
}
}
DateTime.TryParse((month+"/"+day+"/"+year + " "+ time+" Z"), out release);
return release;
}
}

public override int GetHashCode()
{
Expand Down
157 changes: 86 additions & 71 deletions BLAZAMGui/UI/Settings/ManualApplicationUpdater.razor
Original file line number Diff line number Diff line change
Expand Up @@ -77,73 +77,80 @@
<h4>Update Available</h4>

}
<MudStack Row=true Class="w-100">

<MudCard Class="mud-theme-success">
<MudCardHeader Class="pb-0">Current Version</MudCardHeader>
<MudCardContent>
<MudText>@ApplicationInfo.RunningVersion</MudText>

</MudCardContent>
</MudCard>

<MudIcon class="align-middle" Icon="@Icons.Material.Filled.ArrowRightAlt" Size="Size.Large" />

<MudCard Class="mud-theme-info">
<MudCardHeader Class="pb-0">

<ChildContent>
Available Version
<MudIconButton Color="Color.Tertiary" Icon="@Icons.Material.Filled.QuestionMark" OnClick=@ShowReleaseNotes />

</ChildContent>

</MudCardHeader>
<MudCardContent>
@LatestAvailableVersion.Branch<br />
<MudText>@LatestAvailableVersion.Version</MudText>

@LatestAvailableVersion.Release.ReleaseTime?.ToLocalTime().DateTime<br />
@if (ApplicationInfo.InDebugMode)
{
<MudButton Disabled=@(AutoUpdateService.IsUpdatedScheduled) OnClick=TestAutoUpdate Color="Color.Success">Test Auto Update</MudButton>

<br />
<MudTimeline TimelineAlign="TimelineAlign.Default">
<MudTimelineItem Color="Color.Info" Size="Size.Small">
<ItemOpposite>
@{
DateTime firstRelease = DateTime.Parse("March 4, 2023");
}
<MudButton Color=Color.Success OnClick="ApplyUpdate">Apply Update</MudButton>


</MudCardContent>
</MudCard>
<MudText Color="Color.Info" Typo="Typo.h5">
@firstRelease.ToString("MMMM d, yyyy")</MudText>
</ItemOpposite>
<ItemContent>
<MudCard Class="pa-3">
<MudText Color="Color.Info" Typo="Typo.h6" GutterBottom="true">First Release</MudText>
<MudText Class="pa-6">Blazam Beta 0.6.7 released.</MudText>
</MudCard>
</ItemContent>
</MudTimelineItem>
<MudTimelineItem Color="Color.Success" Size="Size.Small" TimelineAlign="TimelineAlign.End">
<ItemOpposite>
<MudText Color="Color.Success" Typo="Typo.h5">@ApplicationInfo.runningVersion.ReleaseDate.ToString("MMMM d, yyyy")</MudText>
</ItemOpposite>
<ItemContent>
<MudCard Class="pa-3">

<MudText Color="Color.Success" Typo="Typo.h6" GutterBottom="true">Current Version</MudText>
<MudText Class="pa-6">@ApplicationInfo.runningVersion</MudText>
</MudCard>
</ItemContent>
</MudTimelineItem>
<MudTimelineItem Color="Color.Error" Size="Size.Small">
<ItemOpposite>
<MudText Color="Color.Error" Typo="Typo.h5">@LatestAvailableVersion.Version.ReleaseDate.ToString("MMMM d, yyyy")</MudText>
</ItemOpposite>
<ItemContent>
<MudCard Class="pa-3">

<MudText Color="Color.Error" Typo="Typo.h6" GutterBottom="true">Available Update</MudText>
<MudExpansionPanels Elevation=0 DisableBorders=true>
<MudExpansionPanel Text="@LatestAvailableVersion.Version.ToString()">
<MudMarkdown OverrideHeaderTypo=ConvertHeaders Value="@LatestAvailableVersion.Release.ReleaseNotes" />
</MudExpansionPanel>
</MudExpansionPanels>
<MudButton Class="mx-6" Variant=Variant.Filled Color=Color.Success OnClick="ApplyUpdate">Apply Update</MudButton>
@if (ApplicationInfo.InDebugMode)
{
<MudButton Class="mx-6" Disabled=@(AutoUpdateService.IsUpdatedScheduled) OnClick=TestAutoUpdate Color="Color.Success">Test Auto Update</MudButton>


}
</MudCard>
@* <AvailableUpdate Update=@LatestAvailableVersion OnApply="ApplyUpdate"/>*@
</ItemContent>
</MudTimelineItem>
</MudTimeline>

</MudStack>
@if (AutoUpdateService.IsUpdatedScheduled)
{
<MudButton OnClick=@(()=>{AutoUpdateService.Cancel();}) Color="Color.Error">Cancel Auto Update</MudButton>
}
}
if (LatestAvailableVersion != null && !LatestAvailableVersion.Newer)
{
<MudIcon Class="d-inline" Icon="@Icons.Material.Filled.Check" Color="Color.Success"/>
<MudText Class="d-inline">Application is up to date</MudText>
<MudIcon Class="d-inline" Icon="@Icons.Material.Filled.Check" Color="Color.Success" />
<MudText Class="d-inline">Application is up to date</MudText>
}
break;

}
}
}

@if (Monitor.DatabaseUpdatePending)
{
<MudText>A database update needs to be applied</MudText>
<MudButton Color=Color.Primary OnClick="UpdateDB">Update</MudButton>
}
<AppModal Title=@(LatestAvailableVersion?.Version+" Release Notes") @ref="@_releaseNotesModal">
<ReleaseNotesModalContent Update="LatestAvailableVersion" />
</AppModal>



@code {
AppModal? _releaseNotesModal;
ApplicationUpdate? LatestAvailableVersion { get; set; }

UpdateStage updateStage = UpdateStage.None;
Expand Down Expand Up @@ -171,6 +178,31 @@
LoadingData = false;
await InvokeAsync(StateHasChanged);
}

private Typo ConvertHeaders(Typo from)
{
switch (from)
{
case Typo.h1:
return Typo.h3;

case Typo.h2:
return Typo.h4;
case Typo.h3:
return Typo.h5;
case Typo.h4:
return Typo.h6;

case Typo.h5:
return Typo.h6;

case Typo.h6:
return Typo.h6;
default:
return from;
}
}

async Task ApplyUpdate()
{
if (LatestAvailableVersion == null)
Expand Down Expand Up @@ -236,37 +268,20 @@
updateStage = UpdateStage.None;

}
void TestAutoUpdate()
{
if (LatestAvailableVersion != null)
AutoUpdateService.ScheduleUpdate(DateTime.Now.TimeOfDay + TimeSpan.FromSeconds(30), LatestAvailableVersion);
}

async void UpdateDownloadPercentage(FileProgress? progress)
{

DownladProgress = progress;
await InvokeAsync(StateHasChanged);

}
protected void UpdateDB()
{
Task.Run(async () =>
{

await InvokeAsync(StateHasChanged);
if (await DbFactory.ApplyDatabaseMigrations())
{
}

await InvokeAsync(StateHasChanged);

});
}

void ShowReleaseNotes()
void TestAutoUpdate()
{
_releaseNotesModal?.Show();
//MessageService.Info(LatestAvailableVersion.Release.ReleaseNotes, LatestAvailableVersion.Version + " Release Notes");
if (LatestAvailableVersion != null)
AutoUpdateService.ScheduleUpdate(DateTime.Now.TimeOfDay + TimeSpan.FromSeconds(60), LatestAvailableVersion);
}


}

0 comments on commit 0f8afe8

Please sign in to comment.