Skip to content

Commit

Permalink
Merge pull request #489 from Blazam-App/v1-Nightly
Browse files Browse the repository at this point in the history
V1 Release
  • Loading branch information
jacobsen9026 authored Aug 12, 2024
2 parents 7a7e5ef + 0fcde68 commit 0010a3a
Show file tree
Hide file tree
Showing 41 changed files with 403 additions and 310 deletions.
4 changes: 2 additions & 2 deletions BLAZAM.Tests/FileSystem/FileSystemBaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand Down
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.0.0</AssemblyVersion>
<Version>2024.08.09.1713</Version>
<Version>2024.08.12.2308</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<RootNamespace>BLAZAM</RootNamespace>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
Expand Down
4 changes: 2 additions & 2 deletions BLAZAM/Pages/Configure/Templates.razor
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@
List<TreeItemData<DirectoryTemplate>> treeData = new();

var rootTemplates = Templates.Where(t => t.ParentTemplate == null && t.DeletedAt == null).ToTreeItemData();

treeData = RecursiveFillTreeViewItems(treeData);
treeData = RecursiveFillTreeViewItems(rootTemplates);
return treeData;

}
Expand Down
3 changes: 2 additions & 1 deletion BLAZAM/Pages/Install/ADirectory.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
@{
}
<div>
<DirectorySettings SettingsSaved="@(()=>{directoryStatusPanel.ResetStatus();})" />
<DirectorySettings ShowStatusPanel=false SettingsSaved="@(()=>{directoryStatusPanel.ResetStatus();})" />

<ActiveDirectoryStatusPanel @ref=directoryStatusPanel DirectoryConnected="@(()=>{disableNext=false;})"/>
<br/>

<br/>
<MudButton Color="Color.Success" @onclick="ShowNext" Disabled="@disableNext">Proceed</MudButton>
</div>
Expand Down
7 changes: 4 additions & 3 deletions BLAZAM/Pages/Install/Install.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@page "/install/{selectedStep}"
@layout InstallLayout
@inherits AppComponentBase

@inject ApplicationManager ApplicationManager

<PageTitle>Install - Blazam</PageTitle>

Expand Down Expand Up @@ -97,7 +97,7 @@ else


}

async void UpdateStatuses()
{
Context = DbFactory.CreateDbContext();
Expand Down Expand Up @@ -130,7 +130,7 @@ else
completedSteps = 4;

await InvokeAsync(StateHasChanged);

}

}
Expand Down Expand Up @@ -178,6 +178,7 @@ else
var result = await Context.SaveChangesAsync();
ApplicationInfo.InstallationCompleted = true;
Nav.NavigateTo("/home", true);
ApplicationManager.Restart();
}
catch
{
Expand Down
2 changes: 1 addition & 1 deletion BLAZAM/Pages/Login.razor
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
}
catch (Exception ex)
{

Loggers.SystemLogger.Error("Error attempting logon {@Error}",ex);
SnackBarService.Info(ex.Message);
}

Expand Down
14 changes: 14 additions & 0 deletions BLAZAM/ProgramHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using BLAZAM.Session;
using Microsoft.AspNetCore.Authentication;
using System.Management;
using BLAZAM.Update.Services;

namespace BLAZAM.Server
{
Expand Down Expand Up @@ -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<UpdateService>();
context.Initialize();
}

}
catch (Exception ex)
{
Loggers.SystemLogger.Error(ex.Message + " {@Error}", ex);
}

}
}
Expand Down
2 changes: 1 addition & 1 deletion BLAZAM/updater/update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ Write-Host("Global Process Id: " + $global:processId);
Quit
}
#>
PerformBackup
#PerformBackup

ApplyUpdate

Expand Down
14 changes: 1 addition & 13 deletions BLAZAM/wwwroot/js/blazam.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
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 () {
Expand Down
2 changes: 1 addition & 1 deletion BLAZAMActiveDirectory/Interfaces/IDirectoryEntryAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public interface IDirectoryEntryAdapter : IDisposable
Task<IJob> CommitChangesAsync(IJob? commitJob = null);

/// <summary>
/// Resets the current entry state to it's inital state
/// Resets the current entry state to it's initial state
/// </summary>
void DiscardChanges();

Expand Down
24 changes: 24 additions & 0 deletions BLAZAMCommon/Data/ApplicationVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion BLAZAMCommon/Helpers/CommonHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 11 additions & 11 deletions BLAZAMFileSystem/FileSystemBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
/// <summary>
/// The full raw path to this file or directory
/// </summary>
public string Path { get; set; }
public string FullPath { get; set; }

/// <summary>
/// Indicates whether the executing identity has write permission to this directory or file
Expand All @@ -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;
}
Expand All @@ -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(FullPath + "\\test.txt");
// Attempt to create a test file within the directory.

using (File.Create(testFilePath))
Expand Down Expand Up @@ -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;
}
}
}
32 changes: 16 additions & 16 deletions BLAZAMFileSystem/SystemDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class SystemDirectory : FileSystemBase
{
public SystemDirectory(string path) : base(path)
{

FullPath = Path.GetFullPath(path + Path.DirectorySeparatorChar);
}
/// <summary>
/// All direct sub-directories of this directory
Expand All @@ -25,7 +25,7 @@ public List<SystemDirectory> SubDirectories
{
if (Exists)
{
foreach (var directory in Directory.GetDirectories(Path))
foreach (var directory in Directory.GetDirectories(FullPath))
{
dirs.Add(new SystemDirectory(directory));
}
Expand All @@ -37,15 +37,15 @@ public List<SystemDirectory> SubDirectories
}
catch (Exception ex)
{
Log.Error("Error getting directory files: " + Path, ex);
Log.Error("Error getting directory files: " + FullPath, ex);
}
return dirs;
}
}
/// <summary>
/// Indicates whether this directory currently exists
/// </summary>
public bool Exists => Directory.Exists(Path);
public bool Exists => Directory.Exists(FullPath);

/// <summary>
/// All direct sub-files of this directory
Expand All @@ -59,7 +59,7 @@ public List<SystemFile> Files
{
if (Exists)
{
foreach (var file in Directory.GetFiles(Path))
foreach (var file in Directory.GetFiles(FullPath))
{
files.Add(new SystemFile(file));
}
Expand All @@ -71,7 +71,7 @@ public List<SystemFile> Files
}
catch (Exception ex)
{
Log.Error("Error getting directory files: " + Path, ex);
Log.Error("Error getting directory files: " + FullPath, ex);
}
return files;
}
Expand All @@ -80,7 +80,7 @@ public List<SystemFile> Files
/// <summary>
/// The full directory name
/// </summary>
public string? Name => Path.Split("\\").Last();
public string? Name => FullPath.Split("\\").Last();

public void ClearDirectory()
{
Expand All @@ -100,32 +100,32 @@ public void ClearDirectory()
public bool CopyTo(SystemDirectory parentDirectory)
{
bool copyingDownTree = false;
if (parentDirectory.Path.Contains(Path))
if (parentDirectory.FullPath.Contains(FullPath))
{
copyingDownTree = true;
}

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;

Expand All @@ -140,15 +140,15 @@ public void Delete(bool recursive = false)
{
if (Exists)
{
Directory.Delete(Path, recursive);
Directory.Delete(FullPath, recursive);
}
}
/// <summary>
/// Creates the directory if it does not already exist
/// </summary>
public void EnsureCreated()
{
Directory.CreateDirectory(Path);
Directory.CreateDirectory(FullPath);
}
}
}
Loading

0 comments on commit 0010a3a

Please sign in to comment.