Skip to content

Commit

Permalink
Merge pull request #285 from Blazam-App/0.9.1-Gen
Browse files Browse the repository at this point in the history
Add Changed Entries Widget
  • Loading branch information
jacobsen9026 authored Apr 1, 2024
2 parents be15591 + e62153b commit 2ec5185
Show file tree
Hide file tree
Showing 19 changed files with 115 additions and 43 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>0.9.0</AssemblyVersion>
<Version>2024.04.01.1814</Version>
<Version>2024.04.01.1841</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<RootNamespace>BLAZAM</RootNamespace>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
Expand Down
2 changes: 1 addition & 1 deletion BLAZAM/Pages/API/Token.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public TokenModel(IDatabaseContext context)
public JsonResult OnGet()
{
JwtTokenHandler = new JwtSecurityTokenHandler();
var user = this.User.Identity.Name;
var user = this.User.Identity?.Name;
if (string.IsNullOrEmpty(user))
{
throw new InvalidOperationException("Name is not specified.");
Expand Down
4 changes: 2 additions & 2 deletions BLAZAM/Pages/Benchmark.razor
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ else
} *@
@code {
#nullable disable warnings
ActiveDirectoryContext ad;
//ActiveDirectoryContext ad;
bool Running = false;
bool adTree;
//bool adTree;
int runCount = 1;
int cycle;
double elapsed;
Expand Down
2 changes: 1 addition & 1 deletion BLAZAM/Pages/Configure/Fields.razor
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
}
async Task SaveChanges()
{
if (await Context.SaveChangesAsync() > 0)
if (Context != null && await Context.SaveChangesAsync() > 0)
{
SnackBarService.Success("Field Updated");
}
Expand Down
13 changes: 8 additions & 5 deletions BLAZAM/Pages/Configure/Templates.razor
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
</MudTooltip>
}

@if (Templates.Any(t => t.DeletedAt != null))
@if (Templates?.Any(t => t.DeletedAt != null)==true)
{
<MudTooltip Text="@AppLocalization["Restore templates"]">

Expand Down Expand Up @@ -227,10 +227,13 @@
}
private async Task DeleteTemplate()
{
SelectedTemplate.DeletedAt = DateTime.Now;
await Context.SaveChangesAsync();
SelectedTemplate = null;
await InvokeAsync(StateHasChanged);
if (SelectedTemplate != null)
{
SelectedTemplate.DeletedAt = DateTime.Now;
await Context.SaveChangesAsync();
SelectedTemplate = null;
await InvokeAsync(StateHasChanged);
}
}
private async void RestoreSelectedTemplates()
{
Expand Down
2 changes: 1 addition & 1 deletion BLAZAM/Pages/Error/UnhandledExceptionPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<MudPaper Class="overflow-auto mud-typography-nowrap">
Stack Trace: <br>
@(
(MarkupString)_error.StackTrace.Replace("\n", "<br><br>")
(MarkupString)_error.StackTrace?.Replace("\n", "<br><br>")
)
</MudPaper>
</MudCard>
Expand Down
2 changes: 1 addition & 1 deletion BLAZAM/Pages/Groups/CreateGroup.razor
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
{
LoadingData = true;
await InvokeAsync(StateHasChanged);
newGroup = parentOU.CreateGroup(newGroupName);
newGroup = parentOU?.CreateGroup(newGroupName);



Expand Down
6 changes: 3 additions & 3 deletions BLAZAM/Pages/Home.razor
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
{
try
{
MOTD = (MarkupString)Context?.AppSettings.FirstOrDefault().MOTD;
MOTD = (MarkupString)Context?.AppSettings.FirstOrDefault()?.MOTD;
}
catch
{
Expand All @@ -68,10 +68,10 @@
return true;
});
IJobStep step2 = new JobStep("Regular Step Fails", (step) => { Task.Delay(2000).Wait(); return false; });
IJobStep step3 = new JobStep("Regular Step Throws", (step) => { Task.Delay(2000).Wait(); throw new ApplicationException("Test exception"); return false; });
IJobStep step3 = new JobStep("Regular Step Throws", bool(step) => { Task.Delay(2000).Wait(); throw new ApplicationException("Test exception"); });
IJobStep step4 = new JobStep("Nested Step Passes", (step) => { Task.Delay(2000).Wait(); return true; });
IJobStep step5 = new JobStep("Nested Step Fails", (step) => { Task.Delay(2000).Wait(); return false; });
IJobStep step6 = new JobStep("Nested Step Throws", (step) => { Task.Delay(2000).Wait(); throw new ApplicationException("Test exception"); return false; });
IJobStep step6 = new JobStep("Nested Step Throws", bool(step) => { Task.Delay(2000).Wait(); throw new ApplicationException("Test exception"); });

job.Steps.Add(step1);
job.Steps.Add(step2);
Expand Down
28 changes: 12 additions & 16 deletions BLAZAM/Pages/Login.razor
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@

</MudElement>
</MudContainer>
<AppModal @ref=_mfaModal Title="MFA" Options="new(){ MaxWidth=MaxWidth.Large, FullWidth=true}">
<ChildContent>
<iframe class="w-100" style="height:70vh" src="@_modalUri"></iframe>
</ChildContent>
</AppModal>
<style>
.brand-icon {
position: fixed;
Expand All @@ -125,9 +120,8 @@
</style>

@code {
MudTextField<string>? _usernameTextField;
MudTextField<string>? _passwordTextField;
string? _modalUri;
MudTextField<string?> _usernameTextField;
MudTextField<string?> _passwordTextField;
bool attemptingSignIn = false;
string redirectUrl;
AppModal? _mfaModal;
Expand All @@ -154,8 +148,8 @@
{
attemptingSignIn = true;
await InvokeAsync(StateHasChanged);
LoginRequest? authenticationResult;
if (ValidateInput(out authenticationResult))
LoginRequest? authenticationResult=null;
if (ValidateInput(LoginRequest))
try
{
var response = await JSRuntime.InvokeAsync<string>("attemptSignIn", LoginRequest);
Expand Down Expand Up @@ -206,20 +200,22 @@
break;
case LoginResultStatus.OK:
attemptingSignIn = true;
if (!_mfaModal.IsShown)
{
Nav.NavigateTo(redirectUrl, true);
}

Nav.NavigateTo(redirectUrl, true);

break;
}

}

await InvokeAsync(StateHasChanged);
}
bool ValidateInput(out LoginRequest? validationResult)
bool ValidateInput(LoginRequest? validationResult)
{
validationResult = null;
if(validationResult == null)
{
validationResult = new();
}
if (LoginRequest.Valid || (ApplicationInfo.InDemoMode && !DemoCustomLogin)) return true;


Expand Down
2 changes: 1 addition & 1 deletion BLAZAM/Pages/OU/CreateOU.razor
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
{
LoadingData = true;
await InvokeAsync(StateHasChanged);
newOU = parentOU.CreateOU(newOUName);
newOU = parentOU?.CreateOU(newOUName);



Expand Down
2 changes: 1 addition & 1 deletion BLAZAM/Pages/OU/ViewOU.razor
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<UnsavedChangesPrompt SaveChanges="SaveChanges" DiscardChanges="DiscardChanges" />
}
@code {
IADOrganizationalUnit OU => DirectoryEntry as IADOrganizationalUnit;
IADOrganizationalUnit? OU => DirectoryEntry as IADOrganizationalUnit;
IADOrganizationalUnit? parentOU;
protected override async Task OnInitializedAsync()
{
Expand Down
6 changes: 3 additions & 3 deletions BLAZAM/Pages/Printers/ViewPrinter.razor
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@
{
try
{
Printer.Delete();
SnackBarService.Success(Printer.CanonicalName + " has been deleted.");
Printer?.Delete();
SnackBarService.Success(Printer?.CanonicalName + " has been deleted.");

Nav.NavigateTo("/search");

Expand All @@ -153,7 +153,7 @@
{
if (await MessageService.Confirm("Are you sure you want to save the changes?", "Save Changes"))
{
await Printer.CommitChangesAsync();
await Printer?.CommitChangesAsync();
EditMode = false;
Nav.WarnOnNavigation = false;
SnackBarService.Success("The changes made to this printer have been saved.");
Expand Down
2 changes: 1 addition & 1 deletion BLAZAM/Pages/Users/CreateUser.razor
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

@foreach (var template in Templates.Where(t => t.DeletedAt == null && t.Visible))
{
<MudButton OnClick=@(()=>{SetTemplate(template);}) Variant="Variant.Filled" Color="Color.Primary" Size="Size.Large">@template.Name</MudButton>
<MudButton OnClick=@(async()=>{await SetTemplate(template);}) Variant="Variant.Filled" Color="Color.Primary" Size="Size.Large">@template.Name</MudButton>

}
</FlexContainer>
Expand Down
2 changes: 1 addition & 1 deletion BLAZAM/Pages/Users/ViewUser.razor
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@

<DynamicMudInput T=string Label="@AppLocalization["Username"]"
@bind-Value="@User.SamAccountName"
Disabled=!User.NewEntry />
Disabled=@(User?.NewEntry==false) />
<AppCopyButton TextToCopy=@User.SamAccountName />

</MudStack>
Expand Down
2 changes: 1 addition & 1 deletion BLAZAM/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static void Main(string[] args)

builder.IntializeProperties();

_ = new Encryption(Configuration.GetValue<string>("EncryptionKey"));
_ = new Encryption(Configuration?.GetValue<string>("EncryptionKey"));

//Setup host logging so it can catch the earliest logs possible

Expand Down
4 changes: 2 additions & 2 deletions BLAZAMActiveDirectory/Searchers/ADSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ public async Task<List<IDirectoryEntryAdapter>> SearchAsync()

if (!Fields.CN.IsNullOrEmpty())
FilterQuery += $"(cn=*{Fields.CN}*)";
if (!Fields.Changed.IsNullOrEmpty())
FilterQuery += $"(whenChanged>={Fields.Changed})";
if (Fields.Changed != null)
FilterQuery += $"(whenChanged>={Fields.Changed.Value.ToString("yyyyMMddHHmmss.fZ")})";
if (Fields.Created != null)
FilterQuery += $"(whenCreated>={Fields.Created.Value.ToString("yyyyMMddHHmmss.fZ")})";
if (!Fields.SamAccountName.IsNullOrEmpty())
Expand Down
2 changes: 1 addition & 1 deletion BLAZAMActiveDirectory/Searchers/ADSearchFields.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class ADSearchFields

public DateTime? Created { get; set; }

public string? Changed { get; set; }
public DateTime? Changed { get; set; }

public string? PasswordLastSet { get; set; }

Expand Down
5 changes: 4 additions & 1 deletion BLAZAMGui/UI/AppModal.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
<DialogContent>
<CascadingValue Value="this">
<MudContainer Class="py-4 px-0">
@ChildContent
@if (IsShown)
{
@ChildContent
}

</MudContainer>
</CascadingValue>
Expand Down
70 changes: 70 additions & 0 deletions BLAZAMGui/UI/Dashboard/Widgets/ChangedEntriesWidget.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
@inherits Widget
@attribute [Authorize]

<MudDataGrid T="IDirectoryEntryAdapter"
Items="deletedObjects"
RowClick="@RowClicked"
RowClass="cursor-pointer"
Dense=true
Filterable=true
RowsPerPage="5"
FilterMode="DataGridFilterMode.Simple"
Loading=@LoadingData
Square=true
ColumnResizeMode="ResizeMode.Column"
Virtualize=true
Class="py-0"
SortMode="SortMode.Single">
<Columns>
<TemplateColumn Style="width:100px;" Title="Type">
<CellTemplate>
<MudIcon Icon="@context.Item.TypeIcon()" />
</CellTemplate>
</TemplateColumn>
<TemplateColumn Title="Name">
<CellTemplate>
<MudTooltip Text="@context.Item?.OU.ToPrettyOu()">
<MudText>@context.Item?.CanonicalName</MudText>
</MudTooltip>
</CellTemplate>
</TemplateColumn>
<PropertyColumn Property="x=>x.LastChanged" Title="Changed" />

</Columns>
<PagerContent>
<MudDataGridPager T="IDirectoryEntryAdapter" />
</PagerContent>
</MudDataGrid>


<MudOverlay Visible=LoadingData>
<MudProgressLinear Indeterminate=true />
</MudOverlay>
@code {
List<IDirectoryEntryAdapter> deletedObjects { get; set; } = new();

protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();

var search = new ADSearch();
search.Fields.Changed = DateTime.Now.AddDays(-1);
deletedObjects = await search.SearchAsync<DirectoryEntryAdapter, IDirectoryEntryAdapter>();
LoadingData = false;
await InvokeAsync(StateHasChanged);


}
void RowClicked(DataGridRowClickEventArgs<IDirectoryEntryAdapter> args)
{
if (args.Item != null)
{
GoTo(args.Item);
}
}

void GoTo(IDirectoryEntryAdapter args)
{
Nav.NavigateTo(args.SearchUri);
}
}

0 comments on commit 2ec5185

Please sign in to comment.