You've already forked onecmonitor
mirror of
https://github.com/akpaevj/onecmonitor.git
synced 2026-06-19 22:59:58 +02:00
Промежуточная
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -15,6 +15,7 @@ namespace OnecMonitor.Server
|
||||
public DbSet<TechLogSeance> TechLogSeances { get; set; }
|
||||
public DbSet<TechLogFilter> TechLogFilters { get; set; }
|
||||
public DbSet<V8Configuration> Configurations { get; set; }
|
||||
public DbSet<Credentials> Credentials { get; set; }
|
||||
public DbSet<InfoBase> InfoBases { get; set; }
|
||||
public DbSet<Cluster> Clusters { get; set; }
|
||||
public DbSet<UpdateInfoBaseTask> UpdateInfoBaseTasks { get; set; }
|
||||
|
||||
@@ -3,8 +3,8 @@ using OnecMonitor.Server.Models;
|
||||
using OnecMonitor.Server.ViewModels.Agents;
|
||||
using OnecMonitor.Server.ViewModels.Clusters;
|
||||
using OnecMonitor.Server.ViewModels.Configurations;
|
||||
using OnecMonitor.Server.ViewModels.Credentials;
|
||||
using OnecMonitor.Server.ViewModels.InfoBases;
|
||||
using OnecMonitor.Server.ViewModels.InfoBases.Index;
|
||||
using OnecMonitor.Server.ViewModels.TechLogSeances;
|
||||
using OnecMonitor.Server.ViewModels.UpdateInfoBaseTasks;
|
||||
|
||||
@@ -14,15 +14,34 @@ public class CommonProfile : Profile
|
||||
{
|
||||
public CommonProfile()
|
||||
{
|
||||
CreateMap<Agent, SelectableItem>()
|
||||
CreateMap<Agent, SelectableItemViewModel>()
|
||||
.ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.InstanceName))
|
||||
.ReverseMap();
|
||||
CreateMap<InfoBase, SelectableItem>().ReverseMap();
|
||||
CreateMap<Cluster, SelectableItem>().ReverseMap();
|
||||
CreateMap<LogTemplate, SelectableItem>().ReverseMap();
|
||||
CreateMap<V8Configuration, SelectableItem>()
|
||||
CreateMap<InfoBase, SelectableItemViewModel>().ReverseMap();
|
||||
CreateMap<Cluster, SelectableItemViewModel>().ReverseMap();
|
||||
CreateMap<LogTemplate, SelectableItemViewModel>().ReverseMap();
|
||||
CreateMap<Credentials, SelectableItemViewModel>().ReverseMap();
|
||||
CreateMap<V8Configuration, SelectableItemViewModel>()
|
||||
.ForMember(c => c.Name, opt => opt.MapFrom(src => $"{src.Name} ({src.Version})"))
|
||||
.ReverseMap();
|
||||
|
||||
CreateMap<Credentials, CredentialsListItemViewModel>()
|
||||
.ReverseMap()
|
||||
.ForMember(c => c.Id, i => i.Ignore());
|
||||
|
||||
CreateMap<Credentials, CredentialsEditViewModel>()
|
||||
.ReverseMap()
|
||||
.ForMember(c => c.Id, i => i.Ignore())
|
||||
.ForMember(c => c.InfoBases, i => i.Ignore())
|
||||
.ForMember(c => c.Clusters, i => i.Ignore());
|
||||
|
||||
CreateMap<V8Configuration, ConfigurationListItemViewModel>()
|
||||
.ReverseMap()
|
||||
.ForMember(c => c.Id, i => i.Ignore());
|
||||
|
||||
CreateMap<V8Configuration, ConfigurationEditViewModel>()
|
||||
.ReverseMap()
|
||||
.ForMember(c => c.Id, i => i.Ignore());
|
||||
|
||||
CreateMap<Cluster, ClusterEditViewModel>()
|
||||
.ReverseMap()
|
||||
@@ -45,7 +64,7 @@ public class CommonProfile : Profile
|
||||
.ForMember(c => c.Id, i => i.Ignore())
|
||||
.ForMember(c => c.Cluster, i => i.Ignore());
|
||||
|
||||
CreateMap<V8Configuration, ConfigurationViewModel>()
|
||||
CreateMap<V8Configuration, ConfigurationEditViewModel>()
|
||||
.ReverseMap()
|
||||
.ForMember(c => c.Id, i => i.Ignore());
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OnecMonitor.Server.Helpers;
|
||||
using OnecMonitor.Server.Models;
|
||||
using OnecMonitor.Server.Services;
|
||||
using OnecMonitor.Server.ViewModels;
|
||||
using OnecMonitor.Server.ViewModels.Agents;
|
||||
using OnecMonitor.Server.ViewModels.Agents.Index;
|
||||
|
||||
namespace OnecMonitor.Server.Controllers
|
||||
{
|
||||
@@ -65,7 +65,7 @@ namespace OnecMonitor.Server.Controllers
|
||||
IsConnected = agentConnection != null,
|
||||
InstalledPlatforms = installedPlatforms,
|
||||
Services = services,
|
||||
Clusters = mapper.Map<List<SelectableItem>>(agent.Clusters)
|
||||
Clusters = mapper.Map<List<SelectableItemViewModel>>(agent.Clusters)
|
||||
};
|
||||
|
||||
return View(await PrepareVewModel(vm, cancellationToken));
|
||||
@@ -81,24 +81,10 @@ namespace OnecMonitor.Server.Controllers
|
||||
if (model == null)
|
||||
return NotFound();
|
||||
|
||||
var clustersIds = vm.Clusters.Select(c => Guid.Parse(c.Id));
|
||||
|
||||
var newClusters = await appDbContext.Clusters
|
||||
.Where(c => clustersIds.Contains(c.Id))
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
// add new
|
||||
newClusters
|
||||
.Where(c => !model.Clusters.Contains(c))
|
||||
.ToList()
|
||||
.ForEach(model.Clusters.Add);
|
||||
// remove deleted
|
||||
model.Clusters
|
||||
.Where(c => !newClusters.Contains(c))
|
||||
.ToList()
|
||||
.ForEach(c => model.Clusters.Remove(c));
|
||||
await UiHelper.UpdateModelItems(appDbContext.Clusters, vm.Clusters, model.Clusters, cancellationToken);
|
||||
|
||||
await appDbContext.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
@@ -123,12 +109,12 @@ namespace OnecMonitor.Server.Controllers
|
||||
|
||||
private async Task<AgentEditViewModel> PrepareVewModel(AgentEditViewModel vm, CancellationToken cancellationToken)
|
||||
{
|
||||
var items = await appDbContext.Clusters.ToListAsync(cancellationToken);
|
||||
var selectList = items
|
||||
.Where(i => vm.Clusters.FirstOrDefault(c => i.Id.ToString() == c.Id) == null).ToList();
|
||||
|
||||
vm.AvailableClusters = mapper.Map<List<SelectableItem>>(selectList);
|
||||
|
||||
vm.AvailableClusters = await UiHelper.SelectableItemsFrom(
|
||||
appDbContext.Clusters,
|
||||
vm.Clusters,
|
||||
mapper,
|
||||
cancellationToken);
|
||||
|
||||
return vm;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using AutoMapper.QueryableExtensions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OnecMonitor.Server.Helpers;
|
||||
using OnecMonitor.Server.Models;
|
||||
using OnecMonitor.Server.Services;
|
||||
using OnecMonitor.Server.ViewModels;
|
||||
@@ -53,23 +54,8 @@ public class ClustersController(AppDbContext appDbContext, AgentsConnectionsMana
|
||||
appDbContext.Entry(model).State = EntityState.Added;
|
||||
|
||||
mapper.Map(vm, model);
|
||||
|
||||
var infoBasesIds = vm.InfoBases.Select(c => Guid.Parse(c.Id));
|
||||
|
||||
var newInfobases = await appDbContext.InfoBases
|
||||
.Where(c => infoBasesIds.Contains(c.Id))
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
// add new
|
||||
newInfobases
|
||||
.Where(c => !model.InfoBases.Contains(c))
|
||||
.ToList()
|
||||
.ForEach(model.InfoBases.Add);
|
||||
// remove deleted
|
||||
model.InfoBases
|
||||
.Where(c => !newInfobases.Contains(c))
|
||||
.ToList()
|
||||
.ForEach(c => model.InfoBases.Remove(c));
|
||||
|
||||
await UiHelper.UpdateModelItems(appDbContext.InfoBases, vm.InfoBases, model.InfoBases, cancellationToken);
|
||||
|
||||
await appDbContext.SaveChangesAsync(cancellationToken);
|
||||
|
||||
@@ -78,18 +64,23 @@ public class ClustersController(AppDbContext appDbContext, AgentsConnectionsMana
|
||||
|
||||
private async Task<ClusterEditViewModel> PrepareViewModel(ClusterEditViewModel vm, CancellationToken cancellationToken)
|
||||
{
|
||||
var agents = await appDbContext.Agents.ToListAsync(cancellationToken);
|
||||
vm.Agents = new SelectList(
|
||||
agents.Select(c => new { Id = c.Id.ToString(), Name = c.InstanceName }),
|
||||
nameof(Cluster.Id),
|
||||
nameof(Cluster.Name),
|
||||
vm.AgentId.ToString());
|
||||
vm.Credentials = await UiHelper.SelectListFrom(
|
||||
appDbContext.Credentials,
|
||||
i => i.Name,
|
||||
vm.CredentialsId,
|
||||
cancellationToken);
|
||||
|
||||
var items = await appDbContext.InfoBases.ToListAsync(cancellationToken);
|
||||
var selectList = items
|
||||
.Where(i => vm.InfoBases.FirstOrDefault(c => i.Id.ToString() == c.Id) == null).ToList();
|
||||
vm.Agents = await UiHelper.SelectListFrom(
|
||||
appDbContext.Agents,
|
||||
i => i.InstanceName,
|
||||
vm.AgentId,
|
||||
cancellationToken);
|
||||
|
||||
vm.AvailableInfoBases = mapper.Map<List<SelectableItem>>(selectList);
|
||||
vm.AvailableInfoBases = await UiHelper.SelectableItemsFrom(
|
||||
appDbContext.InfoBases,
|
||||
vm.InfoBases,
|
||||
mapper,
|
||||
cancellationToken);
|
||||
|
||||
return vm;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System.Runtime.InteropServices.JavaScript;
|
||||
using System.Text.Json;
|
||||
using AutoMapper;
|
||||
using AutoMapper.QueryableExtensions;
|
||||
using Microsoft.AspNetCore.Http.Extensions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -11,42 +13,29 @@ using OnecMonitor.Server.ViewModels.Configurations;
|
||||
|
||||
namespace OnecMonitor.Server.Controllers;
|
||||
|
||||
public class ConfigurationsController : Controller
|
||||
public class ConfigurationsController(AppDbContext appDbContext, IMapper mapper, IWebHostEnvironment webHostEnvironment) : Controller
|
||||
{
|
||||
private readonly AppDbContext _appDbContext;
|
||||
private readonly IWebHostEnvironment _env;
|
||||
|
||||
public ConfigurationsController(AppDbContext appDbContext, IWebHostEnvironment webHostEnvironment)
|
||||
{
|
||||
_appDbContext = appDbContext;
|
||||
_env = webHostEnvironment;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(new ConfigurationsIndexViewModel
|
||||
{
|
||||
Items = await _appDbContext.Configurations.Select(c => new ConfigurationViewModel
|
||||
{
|
||||
Id = c.Id,
|
||||
Name = c.Name,
|
||||
Version = c.Version,
|
||||
IsExtension = c.IsExtension
|
||||
}).ToListAsync()
|
||||
Items = await appDbContext.Configurations
|
||||
.ProjectTo<ConfigurationListItemViewModel>(mapper.ConfigurationProvider)
|
||||
.ToListAsync()
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Edit(Guid id)
|
||||
{
|
||||
if (id == Guid.Empty)
|
||||
return View(new ConfigurationViewModel());
|
||||
return View(new ConfigurationEditViewModel());
|
||||
|
||||
var item = await _appDbContext.Configurations.FindAsync(id);
|
||||
var item = await appDbContext.Configurations.FindAsync(id);
|
||||
|
||||
if (item == null)
|
||||
return NotFound();
|
||||
|
||||
return View(new ConfigurationViewModel
|
||||
return View(new ConfigurationEditViewModel
|
||||
{
|
||||
Id = item.Id,
|
||||
Name = item.Name,
|
||||
@@ -60,12 +49,12 @@ public class ConfigurationsController : Controller
|
||||
MultipartBodyLengthLimit = int.MaxValue,
|
||||
ValueLengthLimit = int.MaxValue)
|
||||
]
|
||||
public async Task<IActionResult> Save(Guid id, ConfigurationViewModel vm, CancellationToken cancellationToken)
|
||||
public async Task<IActionResult> Save(Guid id, ConfigurationEditViewModel vm, CancellationToken cancellationToken)
|
||||
{
|
||||
var isNew = id == Guid.Empty;
|
||||
|
||||
if (!isNew)
|
||||
ModelState.Remove(nameof(ConfigurationViewModel.File));
|
||||
ModelState.Remove(nameof(ConfigurationEditViewModel.File));
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
return View("Edit", vm);
|
||||
@@ -73,7 +62,7 @@ public class ConfigurationsController : Controller
|
||||
var model = isNew ? new V8Configuration
|
||||
{
|
||||
Id = Guid.NewGuid()
|
||||
} : await _appDbContext.Configurations.FindAsync([id], cancellationToken);
|
||||
} : await appDbContext.Configurations.FindAsync([id], cancellationToken);
|
||||
|
||||
if (model == null)
|
||||
return NotFound();
|
||||
@@ -82,7 +71,7 @@ public class ConfigurationsController : Controller
|
||||
{
|
||||
// save file
|
||||
var fileName = $"{vm.Name}_{vm.Version}{Path.GetExtension(vm.File.FileName)}";
|
||||
var path = Path.Combine(_env.ContentRootPath, "Data", fileName);
|
||||
var path = Path.Combine(webHostEnvironment.ContentRootPath, "Data", fileName);
|
||||
|
||||
if (System.IO.File.Exists(path))
|
||||
return View("Error", new ErrorViewModel { Message = $"File {path} already exists." });
|
||||
@@ -92,29 +81,29 @@ public class ConfigurationsController : Controller
|
||||
|
||||
model.DataPath = path;
|
||||
|
||||
await _appDbContext.Configurations.AddAsync(model, cancellationToken);
|
||||
await appDbContext.Configurations.AddAsync(model, cancellationToken);
|
||||
}
|
||||
|
||||
model.Name = vm.Name;
|
||||
model.Version = vm.Version;
|
||||
model.IsExtension = vm.IsExtension;
|
||||
|
||||
await _appDbContext.SaveChangesAsync(cancellationToken);
|
||||
await appDbContext.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Delete(Guid id, CancellationToken cancellationToken)
|
||||
{
|
||||
var item = await _appDbContext.Configurations.FindAsync(
|
||||
var item = await appDbContext.Configurations.FindAsync(
|
||||
[id],
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
if (System.IO.File.Exists(item!.DataPath))
|
||||
System.IO.File.Delete(item.DataPath);
|
||||
|
||||
_appDbContext.Configurations.Remove(item!);
|
||||
await _appDbContext.SaveChangesAsync(cancellationToken);
|
||||
appDbContext.Configurations.Remove(item!);
|
||||
await appDbContext.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
using AutoMapper;
|
||||
using AutoMapper.QueryableExtensions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OnecMonitor.Server.Helpers;
|
||||
using OnecMonitor.Server.Models;
|
||||
using OnecMonitor.Server.ViewModels.Clusters;
|
||||
using OnecMonitor.Server.ViewModels.Credentials;
|
||||
|
||||
namespace OnecMonitor.Server.Controllers;
|
||||
|
||||
public class CredentialsController(AppDbContext appDbContext, IMapper mapper) : Controller
|
||||
{
|
||||
public async Task<IActionResult> Index()
|
||||
=> View(await appDbContext.Credentials.ProjectTo<CredentialsListItemViewModel>(mapper.ConfigurationProvider).ToListAsync());
|
||||
|
||||
public async Task<IActionResult> Edit(Guid id, CancellationToken cancellationToken)
|
||||
{
|
||||
var vm = id != Guid.Empty
|
||||
? await appDbContext.Credentials
|
||||
.AsNoTracking()
|
||||
.Include(c => c.Clusters)
|
||||
.Include(c => c.InfoBases)
|
||||
.ProjectTo<CredentialsEditViewModel>(mapper.ConfigurationProvider)
|
||||
.FirstOrDefaultAsync(cancellationToken)
|
||||
: new CredentialsEditViewModel();
|
||||
|
||||
if (vm == null)
|
||||
return NotFound();
|
||||
|
||||
return View(await PrepareViewModel(vm, cancellationToken));
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Save(CredentialsEditViewModel vm, CancellationToken cancellationToken)
|
||||
{
|
||||
var isNew = vm.Id == Guid.Empty;
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
return View("Edit", await PrepareViewModel(vm, cancellationToken));
|
||||
|
||||
var model = isNew ? new Credentials()
|
||||
{
|
||||
Id = Guid.NewGuid()
|
||||
} : await appDbContext.Credentials
|
||||
.Include(c => c.InfoBases)
|
||||
.Include(c => c.Clusters)
|
||||
.FirstOrDefaultAsync(i => i.Id == vm.Id, cancellationToken);
|
||||
|
||||
if (model == null)
|
||||
return NotFound();
|
||||
|
||||
if (isNew)
|
||||
appDbContext.Entry(model).State = EntityState.Added;
|
||||
|
||||
mapper.Map(vm, model);
|
||||
|
||||
await UiHelper.UpdateModelItems(appDbContext.InfoBases, vm.InfoBases, model.InfoBases, cancellationToken);
|
||||
await UiHelper.UpdateModelItems(appDbContext.Clusters, vm.Clusters, model.Clusters, cancellationToken);
|
||||
|
||||
await appDbContext.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
private async Task<CredentialsEditViewModel> PrepareViewModel(CredentialsEditViewModel vm, CancellationToken cancellationToken)
|
||||
{
|
||||
vm.AvailableClusters = await UiHelper.SelectableItemsFrom(
|
||||
appDbContext.Clusters,
|
||||
vm.Clusters,
|
||||
mapper,
|
||||
cancellationToken);
|
||||
|
||||
vm.AvailableInfoBases = await UiHelper.SelectableItemsFrom(
|
||||
appDbContext.InfoBases,
|
||||
vm.InfoBases,
|
||||
mapper,
|
||||
cancellationToken);
|
||||
|
||||
return vm;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Delete(Guid id, CancellationToken cancellationToken)
|
||||
{
|
||||
var item = await appDbContext.Credentials.FindAsync(
|
||||
[id],
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
appDbContext.Entry(item!).State = EntityState.Deleted;
|
||||
await appDbContext.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,9 @@ using AutoMapper.QueryableExtensions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OnecMonitor.Server.Helpers;
|
||||
using OnecMonitor.Server.Models;
|
||||
using OnecMonitor.Server.ViewModels.InfoBases;
|
||||
using OnecMonitor.Server.ViewModels.InfoBases.Index;
|
||||
|
||||
namespace OnecMonitor.Server.Controllers;
|
||||
|
||||
@@ -31,7 +31,7 @@ public class InfoBasesController(AppDbContext appDbContext, IMapper mapper) : Co
|
||||
if (vm == null)
|
||||
return NotFound();
|
||||
|
||||
return View(await InitVewModel(vm, cancellationToken));
|
||||
return View(await PrepareViewModel(vm, cancellationToken));
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Save(Guid id, InfoBaseEditViewModel vm, CancellationToken cancellationToken)
|
||||
@@ -39,7 +39,7 @@ public class InfoBasesController(AppDbContext appDbContext, IMapper mapper) : Co
|
||||
var isNew = id == Guid.Empty;
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
return View("Edit", await InitVewModel(vm, cancellationToken));
|
||||
return View("Edit", await PrepareViewModel(vm, cancellationToken));
|
||||
|
||||
var model = isNew ? new InfoBase
|
||||
{
|
||||
@@ -59,14 +59,13 @@ public class InfoBasesController(AppDbContext appDbContext, IMapper mapper) : Co
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
private async Task<InfoBaseEditViewModel> InitVewModel(InfoBaseEditViewModel vm, CancellationToken cancellationToken)
|
||||
private async Task<InfoBaseEditViewModel> PrepareViewModel(InfoBaseEditViewModel vm, CancellationToken cancellationToken)
|
||||
{
|
||||
var clusters = await appDbContext.Clusters.ToListAsync(cancellationToken);
|
||||
vm.Clusters = new SelectList(
|
||||
clusters.Select(c => new { Id = c.Id.ToString(), Name = c.Name }),
|
||||
nameof(Cluster.Id),
|
||||
nameof(Cluster.Name),
|
||||
vm.ClusterId.ToString());
|
||||
vm.Clusters = await UiHelper.SelectListFrom(
|
||||
appDbContext.Clusters,
|
||||
i => i.Name,
|
||||
vm.ClusterId,
|
||||
cancellationToken);
|
||||
|
||||
return vm;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using OnecMonitor.Server.Services;
|
||||
using OnecMonitor.Server.ViewModels.TechLogSeances;
|
||||
using AutoMapper;
|
||||
using AutoMapper.QueryableExtensions;
|
||||
using OnecMonitor.Server.Helpers;
|
||||
|
||||
namespace OnecMonitor.Server.Controllers
|
||||
{
|
||||
@@ -219,19 +220,21 @@ namespace OnecMonitor.Server.Controllers
|
||||
return View(new LockWaitingGraphViewModel { Graph = graph });
|
||||
}
|
||||
|
||||
private async Task<TechLogSeanceEditViewModel> PrepareViewModel(TechLogSeanceEditViewModel viewModel, CancellationToken cancellationToken)
|
||||
private async Task<TechLogSeanceEditViewModel> PrepareViewModel(TechLogSeanceEditViewModel vm, CancellationToken cancellationToken)
|
||||
{
|
||||
var agents = await dbContext.Agents.ToListAsync(cancellationToken);
|
||||
var selectableAgents = agents
|
||||
.Where(i => viewModel.Agents.FirstOrDefault(c => i.Id.ToString() == c.Id) == null).ToList();
|
||||
viewModel.AvailableAgents = mapper.Map<List<SelectableItem>>(selectableAgents);
|
||||
vm.AvailableAgents = await UiHelper.SelectableItemsFrom(
|
||||
dbContext.Agents,
|
||||
vm.Agents,
|
||||
mapper,
|
||||
cancellationToken);
|
||||
|
||||
var templates = await dbContext.LogTemplates.ToListAsync(cancellationToken);
|
||||
var selectableTemplates = templates
|
||||
.Where(i => viewModel.Templates.FirstOrDefault(c => i.Id.ToString() == c.Id) == null).ToList();
|
||||
viewModel.AvailableTemplates = mapper.Map<List<SelectableItem>>(selectableTemplates);
|
||||
|
||||
return viewModel;
|
||||
vm.AvailableTemplates = await UiHelper.SelectableItemsFrom(
|
||||
dbContext.LogTemplates,
|
||||
vm.Templates,
|
||||
mapper,
|
||||
cancellationToken);
|
||||
|
||||
return vm;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,23 +7,26 @@ namespace OnecMonitor.Server.Helpers;
|
||||
|
||||
public static class UiHelper
|
||||
{
|
||||
public static async Task<SelectList> SelectListFrom<T1, T2>(
|
||||
public static async Task<SelectList> SelectListFrom<T1>(
|
||||
IQueryable<T1> items,
|
||||
Func<T1, string> textSelector,
|
||||
T2 selectedValue,
|
||||
CancellationToken cancellationToken) where T1 : DatabaseObject where T2 : struct
|
||||
Guid selectedValue,
|
||||
CancellationToken cancellationToken) where T1 : DatabaseObject
|
||||
{
|
||||
var list = await items.ToListAsync(cancellationToken);
|
||||
var selectListItems = list.Select(i => new { Id = i.Id.ToString(), Name = textSelector(i) }).ToList();
|
||||
selectListItems.Add(new { Id = Guid.Empty.ToString(), Name = "Please choose item" });
|
||||
|
||||
return new SelectList(
|
||||
list.Select(i => new { Id = i.Id.ToString(), Name = textSelector(i) }),
|
||||
selectListItems,
|
||||
"Id",
|
||||
"Name",
|
||||
selectedValue.ToString());
|
||||
}
|
||||
|
||||
public static async Task<List<SelectableItem>> SelectableItemsFrom<T1>(
|
||||
public static async Task<List<SelectableItemViewModel>> SelectableItemsFrom<T1>(
|
||||
IQueryable<T1> queryable,
|
||||
List<SelectableItem> selectedItems,
|
||||
List<SelectableItemViewModel> selectedItems,
|
||||
IMapper mapper,
|
||||
CancellationToken cancellationToken) where T1 : DatabaseObject
|
||||
{
|
||||
@@ -31,12 +34,12 @@ public static class UiHelper
|
||||
var availableItems = allItems
|
||||
.Where(i => selectedItems.FirstOrDefault(c => i.Id.ToString() == c.Id) == null).ToList();
|
||||
|
||||
return mapper.Map<List<SelectableItem>>(availableItems);
|
||||
return mapper.Map<List<SelectableItemViewModel>>(availableItems);
|
||||
}
|
||||
|
||||
public static async Task UpdateModelItems<T1>(
|
||||
IQueryable<T1> queryable,
|
||||
List<SelectableItem> vmItems,
|
||||
List<SelectableItemViewModel> vmItems,
|
||||
List<T1> modelItems,
|
||||
CancellationToken cancellationToken) where T1 : DatabaseObject
|
||||
{
|
||||
|
||||
+73
-9
@@ -10,7 +10,7 @@ using OnecMonitor.Server;
|
||||
namespace OnecMonitor.Server.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20250208192116_Initial")]
|
||||
[Migration("20250210112134_Initial")]
|
||||
partial class Initial
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@@ -75,6 +75,14 @@ namespace OnecMonitor.Server.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ClusterId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("CredentialsId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Host")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
@@ -92,27 +100,58 @@ namespace OnecMonitor.Server.Migrations
|
||||
|
||||
b.HasIndex("AgentId");
|
||||
|
||||
b.HasIndex("CredentialsId");
|
||||
|
||||
b.ToTable("Clusters");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OnecMonitor.Server.Models.Credentials", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("DefaultForClusters")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("DefaultV8Admin")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("User")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Credentials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OnecMonitor.Server.Models.InfoBase", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("AdminPassword")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("AdminUser")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ClusterId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("CredentialsId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("InfoBaseId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("InfoBaseName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
@@ -132,6 +171,8 @@ namespace OnecMonitor.Server.Migrations
|
||||
|
||||
b.HasIndex("ClusterId");
|
||||
|
||||
b.HasIndex("CredentialsId");
|
||||
|
||||
b.HasIndex("UpdateInfoBaseTaskId");
|
||||
|
||||
b.ToTable("InfoBases");
|
||||
@@ -332,7 +373,15 @@ namespace OnecMonitor.Server.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("OnecMonitor.Server.Models.Credentials", "Credentials")
|
||||
.WithMany("Clusters")
|
||||
.HasForeignKey("CredentialsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Agent");
|
||||
|
||||
b.Navigation("Credentials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OnecMonitor.Server.Models.InfoBase", b =>
|
||||
@@ -343,11 +392,19 @@ namespace OnecMonitor.Server.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("OnecMonitor.Server.Models.Credentials", "Credentials")
|
||||
.WithMany("InfoBases")
|
||||
.HasForeignKey("CredentialsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("OnecMonitor.Server.Models.UpdateInfoBaseTask", null)
|
||||
.WithMany("InfoBases")
|
||||
.HasForeignKey("UpdateInfoBaseTaskId");
|
||||
|
||||
b.Navigation("Cluster");
|
||||
|
||||
b.Navigation("Credentials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OnecMonitor.Server.Models.UpdateInfoBaseTask", b =>
|
||||
@@ -397,6 +454,13 @@ namespace OnecMonitor.Server.Migrations
|
||||
b.Navigation("InfoBases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OnecMonitor.Server.Models.Credentials", b =>
|
||||
{
|
||||
b.Navigation("Clusters");
|
||||
|
||||
b.Navigation("InfoBases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OnecMonitor.Server.Models.UpdateInfoBaseTask", b =>
|
||||
{
|
||||
b.Navigation("Extensions");
|
||||
+46
-3
@@ -22,6 +22,22 @@ namespace OnecMonitor.Server.Migrations
|
||||
table.PrimaryKey("PK_Agents", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Credentials",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<string>(type: "TEXT", nullable: false),
|
||||
Name = table.Column<string>(type: "TEXT", nullable: false),
|
||||
User = table.Column<string>(type: "TEXT", nullable: false),
|
||||
Password = table.Column<string>(type: "TEXT", nullable: false),
|
||||
DefaultForClusters = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||
DefaultV8Admin = table.Column<bool>(type: "INTEGER", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Credentials", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "LogTemplates",
|
||||
columns: table => new
|
||||
@@ -69,10 +85,12 @@ namespace OnecMonitor.Server.Migrations
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<string>(type: "TEXT", nullable: false),
|
||||
ClusterId = table.Column<string>(type: "TEXT", nullable: false),
|
||||
Name = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
|
||||
Host = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
|
||||
Port = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
AgentId = table.Column<string>(type: "TEXT", nullable: false)
|
||||
AgentId = table.Column<string>(type: "TEXT", nullable: false),
|
||||
CredentialsId = table.Column<string>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@@ -83,6 +101,12 @@ namespace OnecMonitor.Server.Migrations
|
||||
principalTable: "Agents",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Clusters_Credentials_CredentialsId",
|
||||
column: x => x.CredentialsId,
|
||||
principalTable: "Credentials",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@@ -174,11 +198,11 @@ namespace OnecMonitor.Server.Migrations
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<string>(type: "TEXT", nullable: false),
|
||||
InfoBaseId = table.Column<string>(type: "TEXT", nullable: false),
|
||||
Name = table.Column<string>(type: "TEXT", nullable: false),
|
||||
InfoBaseName = table.Column<string>(type: "TEXT", nullable: false),
|
||||
PublishAddress = table.Column<string>(type: "TEXT", nullable: false),
|
||||
AdminUser = table.Column<string>(type: "TEXT", nullable: false),
|
||||
AdminPassword = table.Column<string>(type: "TEXT", nullable: false),
|
||||
CredentialsId = table.Column<string>(type: "TEXT", nullable: false),
|
||||
ClusterId = table.Column<string>(type: "TEXT", nullable: false),
|
||||
UpdateInfoBaseTaskId = table.Column<string>(type: "TEXT", nullable: true)
|
||||
},
|
||||
@@ -191,6 +215,12 @@ namespace OnecMonitor.Server.Migrations
|
||||
principalTable: "Clusters",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_InfoBases_Credentials_CredentialsId",
|
||||
column: x => x.CredentialsId,
|
||||
principalTable: "Credentials",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_InfoBases_UpdateInfoBaseTasks_UpdateInfoBaseTaskId",
|
||||
column: x => x.UpdateInfoBaseTaskId,
|
||||
@@ -236,6 +266,11 @@ namespace OnecMonitor.Server.Migrations
|
||||
table: "Clusters",
|
||||
column: "AgentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Clusters_CredentialsId",
|
||||
table: "Clusters",
|
||||
column: "CredentialsId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Configurations_UpdateInfoBaseTaskId",
|
||||
table: "Configurations",
|
||||
@@ -246,6 +281,11 @@ namespace OnecMonitor.Server.Migrations
|
||||
table: "InfoBases",
|
||||
column: "ClusterId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_InfoBases_CredentialsId",
|
||||
table: "InfoBases",
|
||||
column: "CredentialsId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_InfoBases_UpdateInfoBaseTaskId",
|
||||
table: "InfoBases",
|
||||
@@ -315,6 +355,9 @@ namespace OnecMonitor.Server.Migrations
|
||||
migrationBuilder.DropTable(
|
||||
name: "Agents");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Credentials");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "UpdateInfoBaseTasks");
|
||||
|
||||
@@ -72,6 +72,14 @@ namespace OnecMonitor.Server.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ClusterId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("CredentialsId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Host")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
@@ -89,27 +97,58 @@ namespace OnecMonitor.Server.Migrations
|
||||
|
||||
b.HasIndex("AgentId");
|
||||
|
||||
b.HasIndex("CredentialsId");
|
||||
|
||||
b.ToTable("Clusters");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OnecMonitor.Server.Models.Credentials", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("DefaultForClusters")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("DefaultV8Admin")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("User")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Credentials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OnecMonitor.Server.Models.InfoBase", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("AdminPassword")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("AdminUser")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ClusterId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("CredentialsId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("InfoBaseId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("InfoBaseName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
@@ -129,6 +168,8 @@ namespace OnecMonitor.Server.Migrations
|
||||
|
||||
b.HasIndex("ClusterId");
|
||||
|
||||
b.HasIndex("CredentialsId");
|
||||
|
||||
b.HasIndex("UpdateInfoBaseTaskId");
|
||||
|
||||
b.ToTable("InfoBases");
|
||||
@@ -329,7 +370,15 @@ namespace OnecMonitor.Server.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("OnecMonitor.Server.Models.Credentials", "Credentials")
|
||||
.WithMany("Clusters")
|
||||
.HasForeignKey("CredentialsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Agent");
|
||||
|
||||
b.Navigation("Credentials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OnecMonitor.Server.Models.InfoBase", b =>
|
||||
@@ -340,11 +389,19 @@ namespace OnecMonitor.Server.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("OnecMonitor.Server.Models.Credentials", "Credentials")
|
||||
.WithMany("InfoBases")
|
||||
.HasForeignKey("CredentialsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("OnecMonitor.Server.Models.UpdateInfoBaseTask", null)
|
||||
.WithMany("InfoBases")
|
||||
.HasForeignKey("UpdateInfoBaseTaskId");
|
||||
|
||||
b.Navigation("Cluster");
|
||||
|
||||
b.Navigation("Credentials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OnecMonitor.Server.Models.UpdateInfoBaseTask", b =>
|
||||
@@ -394,6 +451,13 @@ namespace OnecMonitor.Server.Migrations
|
||||
b.Navigation("InfoBases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OnecMonitor.Server.Models.Credentials", b =>
|
||||
{
|
||||
b.Navigation("Clusters");
|
||||
|
||||
b.Navigation("InfoBases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OnecMonitor.Server.Models.UpdateInfoBaseTask", b =>
|
||||
{
|
||||
b.Navigation("Extensions");
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace OnecMonitor.Server.Models;
|
||||
|
||||
public class Cluster : DatabaseObject
|
||||
{
|
||||
public string ClusterId { get; set; } = null!;
|
||||
[MaxLength(100)]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[MaxLength(100)]
|
||||
@@ -13,5 +14,8 @@ public class Cluster : DatabaseObject
|
||||
public Guid AgentId { get; set; }
|
||||
public Agent Agent { get; set; } = null!;
|
||||
|
||||
public Guid CredentialsId { get; set; }
|
||||
public Credentials Credentials { get; set; } = null!;
|
||||
|
||||
public List<InfoBase> InfoBases { get; set; } = [];
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using OneSTools.Common.Platform;
|
||||
|
||||
namespace OnecMonitor.Server.Models;
|
||||
|
||||
public class Credentials : DatabaseObject
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string User { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public bool DefaultForClusters { get; set; } = false;
|
||||
public bool DefaultV8Admin { get; set; } = false;
|
||||
|
||||
public List<Cluster> Clusters { get; set; } = [];
|
||||
public List<InfoBase> InfoBases { get; set; } = [];
|
||||
}
|
||||
@@ -4,11 +4,13 @@ namespace OnecMonitor.Server.Models;
|
||||
|
||||
public class InfoBase : DatabaseObject
|
||||
{
|
||||
public string InfoBaseId { get; set; } = null!;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string InfoBaseName { get; set; } = string.Empty;
|
||||
public string PublishAddress { get; set; } = string.Empty;
|
||||
public string AdminUser { get; set; } = string.Empty;
|
||||
public string AdminPassword { get; set; } = string.Empty;
|
||||
|
||||
public Guid CredentialsId { get; set; }
|
||||
public Credentials Credentials { get; set; } = null!;
|
||||
|
||||
public Guid ClusterId { get; set; }
|
||||
public Cluster Cluster { get; set; } = null!;
|
||||
|
||||
@@ -13,6 +13,6 @@ public class AgentEditViewModel
|
||||
public List<V8Platform> InstalledPlatforms { get; set; } = [];
|
||||
public List<V8Service> Services { get; set; } = [];
|
||||
|
||||
public List<SelectableItem> Clusters { get; set; } = [];
|
||||
public List<SelectableItem> AvailableClusters { get; set; } = [];
|
||||
public List<SelectableItemViewModel> Clusters { get; set; } = [];
|
||||
public List<SelectableItemViewModel> AvailableClusters { get; set; } = [];
|
||||
}
|
||||
+6
-6
@@ -1,7 +1,7 @@
|
||||
namespace OnecMonitor.Server.ViewModels.Agents.Index
|
||||
{
|
||||
public class AgentsIndexViewModel
|
||||
{
|
||||
public List<AgentsListItemViewModel> Agents { get; set; } = new();
|
||||
}
|
||||
namespace OnecMonitor.Server.ViewModels.Agents
|
||||
{
|
||||
public class AgentsIndexViewModel
|
||||
{
|
||||
public List<AgentsListItemViewModel> Agents { get; set; } = new();
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -1,9 +1,9 @@
|
||||
namespace OnecMonitor.Server.ViewModels.Agents.Index
|
||||
{
|
||||
public class AgentsListItemViewModel
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string InstanceName { get; set; } = string.Empty;
|
||||
public bool IsConnected { get; set; }
|
||||
}
|
||||
namespace OnecMonitor.Server.ViewModels.Agents
|
||||
{
|
||||
public class AgentsListItemViewModel
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string InstanceName { get; set; } = string.Empty;
|
||||
public bool IsConnected { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -11,9 +11,12 @@ public class ClusterEditViewModel
|
||||
public string Host { get; set; } = string.Empty;
|
||||
public int Port { get; set; } = 1540;
|
||||
|
||||
public Guid CredentialsId { get; set; }
|
||||
[ValidateNever] public SelectList Credentials { get; set; } = null!;
|
||||
|
||||
public Guid AgentId { get; set; }
|
||||
[ValidateNever] public SelectList Agents { get; set; } = null!;
|
||||
|
||||
[ValidateNever] public List<SelectableItem> InfoBases { get; set; } = [];
|
||||
[ValidateNever] public List<SelectableItem> AvailableInfoBases { get; set; } = [];
|
||||
[ValidateNever] public List<SelectableItemViewModel> InfoBases { get; set; } = [];
|
||||
[ValidateNever] public List<SelectableItemViewModel> AvailableInfoBases { get; set; } = [];
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace OnecMonitor.Server.ViewModels.Configurations;
|
||||
|
||||
public class ConfigurationViewModel
|
||||
public class ConfigurationEditViewModel
|
||||
{
|
||||
public Guid Id { get; init; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace OnecMonitor.Server.ViewModels.Configurations;
|
||||
|
||||
public class ConfigurationListItemViewModel
|
||||
{
|
||||
public Guid Id { get; init; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Version { get; set; } = string.Empty;
|
||||
public bool IsExtension { get; set; }
|
||||
}
|
||||
@@ -2,5 +2,5 @@ namespace OnecMonitor.Server.ViewModels.Configurations;
|
||||
|
||||
public class ConfigurationsIndexViewModel
|
||||
{
|
||||
public List<ConfigurationViewModel> Items { get; init; } = [];
|
||||
public List<ConfigurationListItemViewModel> Items { get; init; } = [];
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||
using OnecMonitor.Server.Models;
|
||||
|
||||
namespace OnecMonitor.Server.ViewModels.Credentials;
|
||||
|
||||
public class CredentialsEditViewModel
|
||||
{
|
||||
public Guid Id { get; init; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string User { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public bool DefaultForClusters { get; set; } = false;
|
||||
public bool DefaultV8Admin { get; set; } = false;
|
||||
|
||||
[ValidateNever] public List<SelectableItemViewModel> InfoBases { get; set; } = [];
|
||||
[ValidateNever] public List<SelectableItemViewModel> AvailableInfoBases { get; set; } = [];
|
||||
|
||||
[ValidateNever] public List<SelectableItemViewModel> Clusters { get; set; } = [];
|
||||
[ValidateNever] public List<SelectableItemViewModel> AvailableClusters { get; set; } = [];
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace OnecMonitor.Server.ViewModels.Credentials;
|
||||
|
||||
public class CredentialsListItemViewModel
|
||||
{
|
||||
public Guid Id { get; init; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public bool DefaultForClusters { get; set; } = false;
|
||||
public bool DefaultV8Admin { get; set; } = false;
|
||||
}
|
||||
@@ -10,9 +10,9 @@ public class InfoBaseEditViewModel
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string InfoBaseName { get; set; } = string.Empty;
|
||||
public string PublishAddress { get; set; } = string.Empty;
|
||||
public string AdminUser { get; set; } = string.Empty;
|
||||
public string AdminPassword { get; set; } = string.Empty;
|
||||
|
||||
public Guid CredentialsId { get; set; }
|
||||
[ValidateNever] public SelectList Credentials { get; set; } = null!;
|
||||
public Guid ClusterId { get; set; }
|
||||
[ValidateNever] public SelectList Clusters { get; set; } = null!;
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace OnecMonitor.Server.ViewModels.InfoBases.Index;
|
||||
namespace OnecMonitor.Server.ViewModels.InfoBases;
|
||||
|
||||
public class InfoBaseListItemViewModel
|
||||
{
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace OnecMonitor.Server.ViewModels.InfoBases.Index;
|
||||
namespace OnecMonitor.Server.ViewModels.InfoBases;
|
||||
|
||||
public class InfoBasesIndexViewModel
|
||||
{
|
||||
@@ -5,5 +5,5 @@ namespace OnecMonitor.Server.ViewModels;
|
||||
|
||||
public record SelectItemDialogViewModel(
|
||||
string ItemsModelProperty,
|
||||
List<SelectableItem> Items,
|
||||
List<SelectableItem> AvailableItems);
|
||||
List<SelectableItemViewModel> Items,
|
||||
List<SelectableItemViewModel> AvailableItems);
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
namespace OnecMonitor.Server.Models;
|
||||
|
||||
public class SelectableItem
|
||||
public class SelectableItemViewModel
|
||||
{
|
||||
public string Id { get; set; } = string.Empty;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
@@ -13,13 +13,13 @@ namespace OnecMonitor.Server.ViewModels.TechLogSeances
|
||||
public DateTime StartDateTime { get; set; } = DateTime.MinValue;
|
||||
public int Duration { get; set; } = 15;
|
||||
|
||||
public List<SelectableItem> Templates { get; set; } = [];
|
||||
public List<SelectableItemViewModel> Templates { get; set; } = [];
|
||||
[ValidateNever]
|
||||
public List<SelectableItem> Agents { get; set; } = [];
|
||||
public List<SelectableItemViewModel> Agents { get; set; } = [];
|
||||
|
||||
[ValidateNever]
|
||||
public List<SelectableItem> AvailableTemplates { get; set; } = [];
|
||||
public List<SelectableItemViewModel> AvailableTemplates { get; set; } = [];
|
||||
[ValidateNever]
|
||||
public List<SelectableItem> AvailableAgents { get; set; } = [];
|
||||
public List<SelectableItemViewModel> AvailableAgents { get; set; } = [];
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -14,9 +14,9 @@ public class UpdateInfoBaseTaskEditViewModel
|
||||
public Guid ConfigurationId { get; set; }
|
||||
[ValidateNever] public SelectList Configurations { get; set; } = null!;
|
||||
|
||||
[ValidateNever] public List<SelectableItem> Extensions { get; set; } = [];
|
||||
[ValidateNever] public List<SelectableItem> AvailableExtensions { get; set; } = [];
|
||||
[ValidateNever] public List<SelectableItemViewModel> Extensions { get; set; } = [];
|
||||
[ValidateNever] public List<SelectableItemViewModel> AvailableExtensions { get; set; } = [];
|
||||
|
||||
public List<SelectableItem> InfoBases { get; set; } = [];
|
||||
[ValidateNever] public List<SelectableItem> AvailableInfoBases { get; set; } = [];
|
||||
public List<SelectableItemViewModel> InfoBases { get; set; } = [];
|
||||
[ValidateNever] public List<SelectableItemViewModel> AvailableInfoBases { get; set; } = [];
|
||||
}
|
||||
@@ -27,7 +27,7 @@
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Platforms</label>
|
||||
<label class="form-label">Installed platforms</label>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@using Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@using OnecMonitor.Server.ViewModels
|
||||
@using OnecMonitor.Server.ViewModels.Agents.Index;
|
||||
@using OnecMonitor.Server.ViewModels.Agents;
|
||||
@model AgentsIndexViewModel
|
||||
|
||||
@{
|
||||
|
||||
@@ -33,6 +33,12 @@
|
||||
<span asp-validation-for="Port" class="text-danger"></span>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" asp-for="CredentialsId">Credentials</label>
|
||||
<select asp-for="CredentialsId" class="form-control" asp-items="Model.Credentials"></select>
|
||||
<span asp-validation-for="CredentialsId" class="text-danger"></span>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" asp-for="AgentId">Agent</label>
|
||||
<select asp-for="AgentId" class="form-control" asp-items="Model.Agents"></select>
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
<h2 class="mb-3">Clusters</h2>
|
||||
|
||||
<div class="mb-3">
|
||||
<a class="btn btn-primary" asp-action="Edit" role="button">Add</a>
|
||||
<a class="btn btn-secondary" asp-action="UpdateClusters" role="button">Update clusters</a>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
@using OnecMonitor.Server.ViewModels.Configurations;
|
||||
@model ConfigurationViewModel
|
||||
@model ConfigurationEditViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Configuration";
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
@using Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@using OnecMonitor.Server.ViewModels
|
||||
@model OnecMonitor.Server.ViewModels.Credentials.CredentialsEditViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Credentials item";
|
||||
}
|
||||
|
||||
<h2 class="mb-3">Credentials item</h2>
|
||||
|
||||
<form method="post" asp-action="Save" style="height: 100%">
|
||||
<div class="mb-3">
|
||||
<button class="btn btn-primary" type="submit">Save</button>
|
||||
<button class="btn btn-secondary" onclick="history.back()" type="button">Back</button>
|
||||
</div>
|
||||
|
||||
<input type="text" hidden class="form-control" asp-for="Id" value="@Model.Id">
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" asp-for="Name">Name</label>
|
||||
<input type="text" class="form-control" asp-for="Name" value="@Model.Name">
|
||||
<span asp-validation-for="Name" class="text-danger"></span>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col">
|
||||
<label class="form-label" asp-for="User">User</label>
|
||||
<input type="text" class="form-control" asp-for="User" value="@Model.User">
|
||||
<span asp-validation-for="User" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="col">
|
||||
<label class="form-label" asp-for="Password">Password</label>
|
||||
<input type="password" class="form-control" asp-for="Password" value="@Model.Password">
|
||||
<span asp-validation-for="Password" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-check-label" asp-for="DefaultForClusters">Default for clusters</label>
|
||||
<input class="form-check-input" type="checkbox" asp-for="DefaultForClusters" checked="@Model.DefaultForClusters">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-check-label" asp-for="DefaultV8Admin">Default V8 admin</label>
|
||||
<input class="form-check-input" type="checkbox" asp-for="DefaultV8Admin" checked="@Model.DefaultV8Admin">
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col">
|
||||
@await Html.PartialAsync("SelectItemDialog", new SelectItemDialogViewModel(
|
||||
nameof(Model.InfoBases),
|
||||
Model.InfoBases,
|
||||
Model.AvailableInfoBases))
|
||||
</div>
|
||||
<div class="col">
|
||||
@await Html.PartialAsync("SelectItemDialog", new SelectItemDialogViewModel(
|
||||
nameof(Model.Clusters),
|
||||
Model.Clusters,
|
||||
Model.AvailableClusters))
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
@@ -0,0 +1,46 @@
|
||||
@using Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@using OnecMonitor.Server.ViewModels
|
||||
@model List<OnecMonitor.Server.ViewModels.Credentials.CredentialsListItemViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Credentials";
|
||||
}
|
||||
|
||||
<h2 class="mb-3">Credentials</h2>
|
||||
|
||||
<div class="mb-3">
|
||||
<a class="btn btn-secondary" asp-action="Edit" role="button">Add</a>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Default for clusters</th>
|
||||
<th>Default V8 admin</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>@item.Name</td>
|
||||
<td>@item.DefaultForClusters</td>
|
||||
<td>@item.DefaultV8Admin</td>
|
||||
<td class="text-center">
|
||||
<a class="btn btn-outline-secondary btn-sm" asp-action="Edit" asp-route-id="@item.Id">Edit</a>
|
||||
<a class="btn btn-outline-danger btn-sm" onclick="OM.openDeleteDialog('@item.Id', '@item.Name')">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@await Html.PartialAsync("DeleteDialog", new DeleteDialogViewModel
|
||||
{
|
||||
Controller = "Credentials",
|
||||
Action = "Delete"
|
||||
})
|
||||
@@ -26,24 +26,18 @@
|
||||
<span asp-validation-for="InfoBaseName" class="text-danger"></span>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" asp-for="AdminUser">Admin user</label>
|
||||
<input type="text" class="form-control" asp-for="AdminUser" value="@Model.AdminUser">
|
||||
<span asp-validation-for="AdminUser" class="text-danger"></span>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" asp-for="AdminPassword">Admin password</label>
|
||||
<input type="password" class="form-control" asp-for="AdminPassword" value="@Model.AdminPassword">
|
||||
<span asp-validation-for="AdminPassword" class="text-danger"></span>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" asp-for="PublishAddress">Publish address</label>
|
||||
<input type="text" class="form-control" asp-for="PublishAddress" value="@Model.PublishAddress">
|
||||
<span asp-validation-for="PublishAddress" class="text-danger"></span>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" asp-for="CredentialsId">Credentials</label>
|
||||
<select asp-for="CredentialsId" class="form-control" asp-items="Model.Credentials"></select>
|
||||
<span asp-validation-for="CredentialsId" class="text-danger"></span>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" asp-for="ClusterId">Cluster</label>
|
||||
<select asp-for="ClusterId" class="form-control" asp-items="Model.Clusters"></select>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
@using OnecMonitor.Server.ViewModels
|
||||
@model OnecMonitor.Server.ViewModels.InfoBases.Index.InfoBasesIndexViewModel
|
||||
@model OnecMonitor.Server.ViewModels.InfoBases.InfoBasesIndexViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "InfoBases";
|
||||
@@ -8,7 +8,7 @@
|
||||
<h2 class="mb-3">InfoBases</h2>
|
||||
|
||||
<div class="mb-3">
|
||||
<a class="btn btn-primary" asp-action="Edit" role="button">Add</a>
|
||||
<a class="btn btn-secondary" asp-action="UpdateInfoBases" role="button">Update infobases</a>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
@using Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@using OnecMonitor.Server.Helpers
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="en" data-bs-theme="dark">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
@@ -12,12 +12,12 @@
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row flex-nowrap">
|
||||
<div class="col-auto col-md-3 col-xl-2 px-sm-2 px-0 bg-dark">
|
||||
<div class="col-auto col-md-3 col-xl-2 px-sm-2 px-0 bg-dark-subtle">
|
||||
<div class="d-flex flex-column align-items-center align-items-sm-start px-3 pt-2 text-white min-vh-100">
|
||||
<a href="/" class="d-flex align-items-center pb-3 mb-md-0 me-md-auto text-white text-decoration-none">
|
||||
<a class="navbar-brand" asp-controller="Agents" asp-action="Index">
|
||||
<p class="fs-2 m-3">
|
||||
<span class="onec-text-yellow">Onec</span>Mon<span class="onec-text-yellow">i</span>tor
|
||||
<span class="text-primary">Onec</span>Mon<span class="text-primary">i</span>tor
|
||||
</p>
|
||||
</a>
|
||||
</a>
|
||||
@@ -35,6 +35,11 @@
|
||||
<span class="ms-1 d-none d-sm-inline">Service</span>
|
||||
</a>
|
||||
<ul class="collapse nav flex-column ms-1" id="infoBasesServiceSubMenu" data-bs-parent="#mainMenu">
|
||||
<li class="w-100">
|
||||
<a asp-controller="Credentials" asp-action="Index" class="nav-link text-white px-0">
|
||||
<span class="d-none d-sm-inline">Credentials</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="w-100">
|
||||
<a asp-controller="Clusters" asp-action="Index" class="nav-link text-white px-0">
|
||||
<span class="d-none d-sm-inline">Clusters</span>
|
||||
@@ -45,12 +50,12 @@
|
||||
<span class="d-none d-sm-inline">InfoBases</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<li class="w-100">
|
||||
<a asp-controller="Configurations" asp-action="Index" class="nav-link text-white px-0">
|
||||
<span class="d-none d-sm-inline">Configurations</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<li class="w-100">
|
||||
<a asp-controller="UpdateInfoBaseTasks" asp-action="Index" class="nav-link text-white px-0">
|
||||
<span class="d-none d-sm-inline">Update infobase tasks</span>
|
||||
</a>
|
||||
@@ -79,7 +84,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col py-3">
|
||||
<div class="container">
|
||||
<div class="container-fluid">
|
||||
<main role="main" class="pb-3">
|
||||
@RenderBody()
|
||||
</main>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@using Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@using OnecMonitor.Server.ViewModels
|
||||
@using OnecMonitor.Server.ViewModels.Agents.Index;
|
||||
@using OnecMonitor.Server.ViewModels.Agents;
|
||||
@model List<OnecMonitor.Server.ViewModels.UpdateInfoBaseTasks.UpdateInfoBaseTaskListItemViewModel>
|
||||
|
||||
@{
|
||||
|
||||
Binary file not shown.
@@ -67,6 +67,8 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="ViewModels\Agents\Index\" />
|
||||
<Folder Include="ViewModels\InfoBases\Index\" />
|
||||
<Folder Include="wwwroot\css\" />
|
||||
<Folder Include="wwwroot\dist\" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user