diff --git a/misc/docs/images/dashboard_admin_custom.png b/misc/docs/images/dashboard_admin_custom.png index 6897b4b..0169a66 100644 Binary files a/misc/docs/images/dashboard_admin_custom.png and b/misc/docs/images/dashboard_admin_custom.png differ diff --git a/misc/docs/images/dashboard_anonymous_custom.png b/misc/docs/images/dashboard_anonymous_custom.png index 8ef4d27..cf34c38 100644 Binary files a/misc/docs/images/dashboard_anonymous_custom.png and b/misc/docs/images/dashboard_anonymous_custom.png differ diff --git a/src/LanBackup.WebApp/ClientApp/app/components/app/app.component.css b/src/LanBackup.WebApp/ClientApp/app/components/app/app.component.css index 48b2036..5dc964c 100644 --- a/src/LanBackup.WebApp/ClientApp/app/components/app/app.component.css +++ b/src/LanBackup.WebApp/ClientApp/app/components/app/app.component.css @@ -71,3 +71,31 @@ body { top:45%; position:relative; } + + + +.statusIcon{ + width: 10px; + height: 10px; + border:1px solid #444; + margin-top: 3px; +} +/*idle*/ +.statusIcon_0 { + background-color: lightgray; +} + +/*starting*/ +.statusIcon_1 { + background-color: lightgreen; +} + +/*copy folders files*/ +.statusIcon_2, .statusIcon_3{ + background-color: forestgreen; +} + +/*error*/ +.statusIcon_4 { + background-color: firebrick; +} \ No newline at end of file diff --git a/src/LanBackup.WebApp/ClientApp/app/components/dashboard/dashboard.component.html b/src/LanBackup.WebApp/ClientApp/app/components/dashboard/dashboard.component.html index ad33faa..5c9d3ac 100644 --- a/src/LanBackup.WebApp/ClientApp/app/components/dashboard/dashboard.component.html +++ b/src/LanBackup.WebApp/ClientApp/app/components/dashboard/dashboard.component.html @@ -26,10 +26,10 @@ - - + + - + @@ -39,7 +39,7 @@ - +
Computer IPConfig IDComputer IPConfig ID StatusStatus Progress Last Report
{{agent.ip}} {{agent.configurationId ? agent.configurationId : '---'}}{{agent.statusType}}
{{agent.statusDescription}} diff --git a/src/LanBackup.WebApp/Models/Telemetry/ITelemetryLogger.cs b/src/LanBackup.WebApp/Models/Telemetry/ITelemetryLogger.cs index 69eb7bd..a6379a7 100644 --- a/src/LanBackup.WebApp/Models/Telemetry/ITelemetryLogger.cs +++ b/src/LanBackup.WebApp/Models/Telemetry/ITelemetryLogger.cs @@ -6,5 +6,7 @@ namespace LanBackup.WebApp.Models.Telemetry { void TrackException(Exception ex); void TrackEvent(string v); + + bool IsEnabled { get; set; } } } diff --git a/src/LanBackup.WebApp/Models/Telemetry/TelemetryLogger.cs b/src/LanBackup.WebApp/Models/Telemetry/TelemetryLogger.cs index 2092111..ebf8ebf 100644 --- a/src/LanBackup.WebApp/Models/Telemetry/TelemetryLogger.cs +++ b/src/LanBackup.WebApp/Models/Telemetry/TelemetryLogger.cs @@ -7,19 +7,36 @@ namespace LanBackup.WebApp.Models.Telemetry { private TelemetryClient _telemetryClient; + private bool isEnabled; + public bool IsEnabled + { + get + { + return isEnabled; + } + + set + { + isEnabled = value; + } + } + public TelemetryLogger(TelemetryClient telemetryClient) { this._telemetryClient = telemetryClient; + this.IsEnabled = telemetryClient.IsEnabled(); } public void TrackEvent(string eventmsg) { - this._telemetryClient.TrackEvent(eventmsg); + if(this.IsEnabled) + this._telemetryClient.TrackEvent(eventmsg); } public void TrackException(Exception ex) { - this._telemetryClient.TrackException(ex); + if(this.IsEnabled) + this._telemetryClient.TrackException(ex); } } diff --git a/src/LanBackup.WebApp/Startup.cs b/src/LanBackup.WebApp/Startup.cs index f820c0c..ff3ee8b 100644 --- a/src/LanBackup.WebApp/Startup.cs +++ b/src/LanBackup.WebApp/Startup.cs @@ -7,7 +7,6 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using LanBackup.WebApp.Data; -using Microsoft.EntityFrameworkCore; using LanBackup.DataCore; using LanBackup.WebApp.Models; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; @@ -21,11 +20,9 @@ using LanBackup.WebApp.Hubs; using LanBackup.WebApp.Middleware; using System.Linq; using AutoMapper; -using LanBackup.ModelsCore; -using LanBackup.WebApp.Models.DTO; using LanBackup.WebApp.Controllers; -using Microsoft.AspNetCore.Http; using LanBackup.WebApp.Models.Telemetry; +using Microsoft.ApplicationInsights.Extensibility; namespace LanBackup.WebApp { @@ -33,6 +30,7 @@ namespace LanBackup.WebApp { public const string AuthenticationSchemeName = "MyAuthScheme"; + private bool isApplicationInsightEnabled = false; public Startup(IHostingEnvironment env) { @@ -52,6 +50,8 @@ namespace LanBackup.WebApp builder.AddEnvironmentVariables(); Configuration = builder.Build(); + this.isApplicationInsightEnabled = Configuration.GetSection("AppSettings").GetValue("InstrumentationEnabled"); + } public IConfigurationRoot Configuration { get; } @@ -62,6 +62,7 @@ namespace LanBackup.WebApp //AppInsighttelemetry services.AddApplicationInsightsTelemetry(Configuration); + TelemetryConfiguration.Active.DisableTelemetry = !Configuration.GetSection("AppSettings").GetValue("InstrumentationEnabled"); //conf telemetry logger services.AddSingleton(); @@ -138,7 +139,8 @@ namespace LanBackup.WebApp loggerFactory.AddFile(Configuration["FileLogging:Path"]); // Add Application Insights monitoring to the request pipeline as a very first middleware. - app.UseApplicationInsightsRequestTelemetry(); + if(this.isApplicationInsightEnabled) + app.UseApplicationInsightsRequestTelemetry(); //conf CORS app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()); @@ -162,7 +164,8 @@ namespace LanBackup.WebApp app.UseExceptionHandler("/Home/Error"); } // Add Application Insights exceptions handling to the request pipeline. - after error page and any other error handling middleware: - app.UseApplicationInsightsExceptionTelemetry(); + if(this.isApplicationInsightEnabled) + app.UseApplicationInsightsExceptionTelemetry(); app.UseStaticFiles(); @@ -206,8 +209,6 @@ namespace LanBackup.WebApp - - RolesData.SeedDbWithData(app.ApplicationServices).Wait(); } diff --git a/src/LanBackup.WebApp/Views/Shared/_Layout.cshtml b/src/LanBackup.WebApp/Views/Shared/_Layout.cshtml index 019148b..94d1f92 100644 --- a/src/LanBackup.WebApp/Views/Shared/_Layout.cshtml +++ b/src/LanBackup.WebApp/Views/Shared/_Layout.cshtml @@ -22,7 +22,6 @@ function setClientSetting(setting, val) { clientSettings[setting] = val; - clientSettings.admin_email = val; } setClientSetting('admin_email', '@ClientConfiguration.Instance.ClientSettings.AdminEmail'); setClientSetting('instrumentationEnabled', '@ClientConfiguration.Instance.ClientSettings.InstrumentationEnabled'); diff --git a/src/LanBackup.WebApp/appsettings.json b/src/LanBackup.WebApp/appsettings.json index 7da27ba..d8a8b98 100644 --- a/src/LanBackup.WebApp/appsettings.json +++ b/src/LanBackup.WebApp/appsettings.json @@ -4,6 +4,9 @@ "InstrumentationEnabled": false, "InstrumentationKey": "YOUR_OWN_KEY" }, + "AppSettings": { + "InstrumentationEnabled": false + }, "ConnectionStrings": { "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-LanBackup.WebApp-d5f6c3b5-64d7-4d41-8000-1e69f75536f7;Trusted_Connection=True;MultipleActiveResultSets=true", "BackupsConnectionString": "Server=(localdb)\\mssqllocaldb;Database=BackupsLAN;Trusted_Connection=True;" diff --git a/test/LanBackup.WebApp.Tests/Mock/MockTelemetry.cs b/test/LanBackup.WebApp.Tests/Mock/MockTelemetry.cs index 4b9bef2..4fc089d 100644 --- a/test/LanBackup.WebApp.Tests/Mock/MockTelemetry.cs +++ b/test/LanBackup.WebApp.Tests/Mock/MockTelemetry.cs @@ -5,6 +5,20 @@ namespace LanBackup.WebApp.Tests.IntegrationTests { internal class MockTelemetry : ITelemetryLogger { + private bool isEnabled; + public bool IsEnabled + { + get + { + return isEnabled; + } + + set + { + isEnabled = value; + } + } + public void TrackEvent(string eventmsg) { //DO NOTHING