Skip to content

Commit

Permalink
Add alert details modal. Fix GetEffectiveTheme.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Apr 17, 2021
1 parent 4120faa commit c9a9e60
Show file tree
Hide file tree
Showing 17 changed files with 3,766 additions and 18 deletions.
6 changes: 4 additions & 2 deletions Agent/Services/PSCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public ScriptResult WriteInput(string input)
.Concat(debugOut)
.Concat(verboseOut);

var errorAndWarningOut = errorOut.Concat(warningOut).ToArray();


return new ScriptResult()
{
Expand All @@ -105,9 +107,9 @@ public ScriptResult WriteInput(string input)
ScriptInput = input,
Shell = Shared.Enums.ScriptingShell.PSCore,
StandardOutput = standardOut.ToArray(),
ErrorOutput = errorOut.Concat(warningOut).ToArray(),
ErrorOutput = errorAndWarningOut,
RunTime = sw.Elapsed,
HadErrors = _powershell.HadErrors
HadErrors = _powershell.HadErrors || errorAndWarningOut.Any()
};
}
}
Expand Down
1 change: 1 addition & 0 deletions Remotely.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Agent", "Agent\Agent.csproj
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utilities", "Utilities", "{2CAC9A2B-1402-465F-83F8-958B4E081CA3}"
ProjectSection(SolutionItems) = preProject
Utilities\Add-Migration.ps1 = Utilities\Add-Migration.ps1
Utilities\Example_Apache_Config.txt = Utilities\Example_Apache_Config.txt
Utilities\Example_Nginx_Config.txt = Utilities\Example_Nginx_Config.txt
Utilities\Get-PSCommands.ps1 = Utilities\Get-PSCommands.ps1
Expand Down
3 changes: 2 additions & 1 deletion Server/API/ScriptResultsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public async Task<ScriptResult> Post([FromBody] ScriptResult result)
{
await _dataService.AddAlert(result.DeviceID,
result.OrganizationID,
$"Alert triggered while running script {savedScript.Name}.");
$"Alert triggered while running script {savedScript.Name}.",
string.Join("\n", result.ErrorOutput));
}

if (savedScript.SendEmailOnError)
Expand Down
22 changes: 18 additions & 4 deletions Server/Components/AlertsFrame.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@inherits AuthComponentBase
@attribute [Authorize]
@inject IDataService DataService
@inject IModalService ModalService

<button id="alertsButton" class="btn btn-info" @onclick="ToggleOpen">
<span class="oi oi-bell"></span>
Expand All @@ -25,13 +26,21 @@
<div @key="alert.ID" id="@alert.ID" class="card border-primary mb-3 mr-2 ml-2">
<div class="card-header">@alert.CreatedOn.ToString()</div>
<div class="card-body">
@if (!string.IsNullOrWhiteSpace(alert.Device?.DeviceName))
<h6 class="card-title">@alert.Device?.DeviceName</h6>

<p class="card-text">@alert.Message</p>

@if (!string.IsNullOrWhiteSpace(alert.Details))
{
<h6 class="card-title">@alert.Device.DeviceName</h6>
<div class="small">
<button class="btn btn-link" @onclick="() => ShowAlertDetails(alert)">
View Details
</button>
</div>
}
<p class="card-text">@alert.Message</p>

<div class="text-right">
<button alert="@alert.ID"
<button alert="@alert.ID"
class="btn btn-sm btn-secondary alert-dismiss-button"
type="button"
@onclick="()=> { _ = ClearAlert(alert); }">
Expand Down Expand Up @@ -82,6 +91,11 @@
}
}

private void ShowAlertDetails(Alert alert)
{
ModalService.ShowModal($"Alert Details for {alert.Device?.DeviceName}", alert.Details.Split('\n'));
}

private void ToggleOpen()
{
_isOpen = !_isOpen;
Expand Down

0 comments on commit c9a9e60

Please sign in to comment.