Add ResourceHub for real-time updates and implement web dashboard with REST API
- Created ResourceHub.cs for SignalR group management. - Developed a modern web dashboard using Tailwind CSS for responsive design. - Implemented real-time updates with SignalR for CPU, Memory, GPU, and Network usage. - Added REST API endpoints for resource information and process management. - Integrated process management features to view and terminate high-usage processes. - Enhanced UI with loading spinners, notifications, and responsive tables. - Included performance charts for historical CPU and Memory usage. - Configured Swagger UI for API documentation. - Established security features including process kill restrictions and API key authentication.
This commit is contained in:
+56
-15
@@ -3,29 +3,70 @@ using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using ResourceMonitorService.Hubs;
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
public class Startup
|
||||
namespace ResourceMonitorService
|
||||
{
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
public class Startup
|
||||
{
|
||||
// Add services to the container
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
// Add MVC services
|
||||
services.AddControllers()
|
||||
.AddNewtonsoftJson(); // For JSON serialization
|
||||
|
||||
// Add SignalR for real-time updates
|
||||
services.AddSignalR();
|
||||
|
||||
// Add CORS for API access
|
||||
services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy("AllowAll", builder =>
|
||||
{
|
||||
builder.AllowAnyOrigin()
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader();
|
||||
});
|
||||
});
|
||||
|
||||
// Add Swagger for API documentation
|
||||
services.AddEndpointsApiExplorer();
|
||||
services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Resource Monitor API", Version = "v1" });
|
||||
});
|
||||
}
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
endpoints.MapGet("/", async context =>
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
await context.Response.WriteAsync("Hello World!");
|
||||
app.UseDeveloperExceptionPage();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Resource Monitor API V1");
|
||||
});
|
||||
}
|
||||
|
||||
// Serve static files (CSS, JS, images)
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseRouting();
|
||||
app.UseCors("AllowAll");
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
// Map API controllers
|
||||
endpoints.MapControllers();
|
||||
|
||||
// Map SignalR hub
|
||||
endpoints.MapHub<ResourceHub>("/resourceHub");
|
||||
|
||||
// Default route to index.html
|
||||
endpoints.MapFallbackToFile("index.html");
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user