From 6d61bce88460329137ee467dda5873d957bbf43b Mon Sep 17 00:00:00 2001 From: astankovmi Date: Wed, 8 Jul 2026 16:19:15 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20wi?= =?UTF-8?q?zard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Strela/Controllers/ObjectController.cs | 6 +- Strela/Models/DeviceItem.cs | 19 +- Strela/Models/DeviceType.cs | 1 + Strela/Models/ObjectItem.cs | 2 +- Visor/Visor/Components/Layout/SideMenu.razor | 21 +- Visor/Visor/Models/DeviceItems.cs | 27 ++ Visor/Visor/Models/DeviceTypeItems.cs | 9 + .../Pages/Setting/Objects/AddObjects.razor | 2 +- Visor/Visor/Pages/Setting/Wizard.razor | 314 ++++++++++++++++++ 9 files changed, 371 insertions(+), 30 deletions(-) create mode 100644 Visor/Visor/Models/DeviceItems.cs create mode 100644 Visor/Visor/Models/DeviceTypeItems.cs create mode 100644 Visor/Visor/Pages/Setting/Wizard.razor diff --git a/Strela/Controllers/ObjectController.cs b/Strela/Controllers/ObjectController.cs index 12dbdee..5dd3343 100644 --- a/Strela/Controllers/ObjectController.cs +++ b/Strela/Controllers/ObjectController.cs @@ -17,16 +17,12 @@ public class ObjectController : ControllerBase //=========================== GET =================================// [HttpGet("GetObject")] - [ProducesResponseType>(StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status204NoContent)] public IActionResult GetList() { using (var db = new SQLiteService()) { var oi = db.ObjectItems.ToList(); - //if (oi.Count != 0) return Ok(oi); - //else return NoContent(); } } @@ -65,7 +61,7 @@ public class ObjectController : ControllerBase { using (var db = new SQLiteService()) { - db.ObjectItems.Add(o);//.Where(u => u.Name == name).FirstOrDefault(); + db.ObjectItems.Add(o); db.SaveChanges(); return Created(); } diff --git a/Strela/Models/DeviceItem.cs b/Strela/Models/DeviceItem.cs index 59d5bc3..609de2b 100644 --- a/Strela/Models/DeviceItem.cs +++ b/Strela/Models/DeviceItem.cs @@ -10,17 +10,18 @@ public string? Location { get; set; } public List? ListDevices { get; set; } public DeviceType? DeviceType { get; set; } + public ObjectItem? DeviceObject { get; set; } public int ConnectedToSwitchId { get; set; } public int ConnectedToPortOnSwitch { get; set; } } - - //Unknown = 0, - //SwitchCore = 1, - //SwitchAccess = 2, - //Camera = 3, - //Server = 4, - //WorkStation = 5, - //PDU_AVR = 6, - + + //Unknown = 0, + //SwitchCore = 1, + //SwitchAccess = 2, + //Camera = 3, + //Server = 4, + //WorkStation = 5, + //PDU_AVR = 6, + } diff --git a/Strela/Models/DeviceType.cs b/Strela/Models/DeviceType.cs index bd6cbcb..61b58a6 100644 --- a/Strela/Models/DeviceType.cs +++ b/Strela/Models/DeviceType.cs @@ -4,5 +4,6 @@ { public int Id { get; set; } public string Name { get; set; } + public string? Description { get; set; } } } diff --git a/Strela/Models/ObjectItem.cs b/Strela/Models/ObjectItem.cs index fcc9892..18ae19f 100644 --- a/Strela/Models/ObjectItem.cs +++ b/Strela/Models/ObjectItem.cs @@ -4,6 +4,6 @@ { public int Id { get; set; } public string NameObject { get; set; } = "Unknown"; - public string DescriptionObject { get; set; } = string.Empty; + public string? DescriptionObject { get; set; } = null; } } diff --git a/Visor/Visor/Components/Layout/SideMenu.razor b/Visor/Visor/Components/Layout/SideMenu.razor index cb7a259..528e02e 100644 --- a/Visor/Visor/Components/Layout/SideMenu.razor +++ b/Visor/Visor/Components/Layout/SideMenu.razor @@ -32,25 +32,18 @@ - @* + - - - - Apps - - - - Todo - - - + + + Wizard + - *@ + @code { private bool pagesBarVisible = false; - RenderFragment customIcon =@; + RenderFragment customIcon = @; } \ No newline at end of file diff --git a/Visor/Visor/Models/DeviceItems.cs b/Visor/Visor/Models/DeviceItems.cs new file mode 100644 index 0000000..9d7f8ef --- /dev/null +++ b/Visor/Visor/Models/DeviceItems.cs @@ -0,0 +1,27 @@ +namespace Visor.Models +{ + public class DeviceItems + { + public int Id { get; set; } + public string? Ip { get; set; } + public string? Mac { get; set; } + public string? Description { get; set; } + public string? Name { get; set; } + public string? Location { get; set; } + public List? ListDevices { get; set; } + public DeviceTypeItems? DeviceType { get; set; } + public ObjectItems? DeviceObject { get; set; } + public int ConnectedToSwitchId { get; set; } + public int ConnectedToPortOnSwitch { get; set; } + + } + + //Unknown = 0, + //SwitchCore = 1, + //SwitchAccess = 2, + //Camera = 3, + //Server = 4, + //WorkStation = 5, + //PDU_AVR = 6, + +} diff --git a/Visor/Visor/Models/DeviceTypeItems.cs b/Visor/Visor/Models/DeviceTypeItems.cs new file mode 100644 index 0000000..61efbdc --- /dev/null +++ b/Visor/Visor/Models/DeviceTypeItems.cs @@ -0,0 +1,9 @@ +namespace Visor.Models +{ + public class DeviceTypeItems + { + public int Id { get; set; } + public string Name { get; set; } + public string? Description { get; set; } = null; + } +} diff --git a/Visor/Visor/Pages/Setting/Objects/AddObjects.razor b/Visor/Visor/Pages/Setting/Objects/AddObjects.razor index fb70b41..c273ae3 100644 --- a/Visor/Visor/Pages/Setting/Objects/AddObjects.razor +++ b/Visor/Visor/Pages/Setting/Objects/AddObjects.razor @@ -161,7 +161,7 @@ Id - Объект @foreach (var item in listObjects) { diff --git a/Visor/Visor/Pages/Setting/Wizard.razor b/Visor/Visor/Pages/Setting/Wizard.razor new file mode 100644 index 0000000..e20c50b --- /dev/null +++ b/Visor/Visor/Pages/Setting/Wizard.razor @@ -0,0 +1,314 @@ +@page "/setting/wizard" +@using Visor.Models +

Wizard

+ + + + Объекты + Типы + Устройства + Итог + + + + + + + + Введите название объекта. Например: VNK, SPB... + + + + + + + Введите текстовое описание объекта + + + + + + + + + + + + + + # + Название объекта + Описание объекта + + + + @foreach (var item in list_obj) + { + + @item.Id + @item.NameObject + @item.DescriptionObject + + } + +
+
+
+ + + + + + Введите название типа. Например: Server, Switch... + + + + + + + Введите текстовое описание типа устройства + + + + + + + + + + + + + + # + Тип устройства + Описание типа устройств + + + + @foreach (var item in list_type) + { + + @item.Id + @item.Name + @item.Description + + } + +
+
+
+ + + + + Добавление устройства + + + + + IP + + + + + + + + MAC + + + + + + + + Название + + + + + + + + Описание + + + + + + + + Место установки + + + + + + + + Тип устройства + + + + + + + + Объект + + + + + + + + Подключен к + + + + + + + + + + + Порт подключения + + + + + + + + + + + + Итог + +
+
+
+ + +
+ +@code { + private Steps stepsRef; + private ObjectItems obj_item; + private DeviceTypeItems type_item; + private DeviceItems dev_item; + + private List list_obj = new(); + private List list_type = new(); + private static List list_dev = new(); + private List list_switch = new(); + + private string email, nextButton = "Далее"; + private string selectedStep = "1"; + + private int id_type, id_obj, id_dev, num_port; + private string obj_name, obj_desc; + private string type_name, type_desc; + + private string dev_ip, dev_mac, dev_desc, dev_name, dev_loc; + + + private Task NavigationAllowed(StepNavigationContext context) + { + if (context.CurrentStepIndex == 3 && context.NextStepIndex == 4) + { + nextButton = "Сохранить"; + //return Task.FromResult(true); + } + if (context.CurrentStepIndex == 4 && context.NextStepIndex > 4) + { + //return Task.FromResult(false); + } + if (context.CurrentStepIndex == 4 && context.NextStepIndex < 4) + { + nextButton = "Далее"; + } + + return Task.FromResult(true); + } + + private void RefreshListSwitch() + { + list_switch = list_dev.Where(s => s.DeviceType.Name.Contains("Switch")).ToList(); + if (list_switch.Count == 0) + id_dev = 0; + } + + private void AddNewObject() + { + obj_item = new() + { + NameObject = obj_name, + DescriptionObject = obj_desc, + Id = list_obj.Count + 1 + }; + list_obj.Add(obj_item); + obj_name = string.Empty; + obj_desc = string.Empty; + } + private void AddNewType() + { + type_item = new() + { + Name = type_name, + Description = type_desc, + Id = list_type.Count + 1 + }; + list_type.Add(type_item); + type_name = string.Empty; + type_desc = string.Empty; + } + private void AddNewDev() + { + dev_item = new() + { + Id = list_type.Count + 1, + Ip = dev_ip, + Mac = dev_mac, + Description = dev_desc, + Name = dev_name, + Location = dev_loc, + DeviceType = list_type.SingleOrDefault(t => t.Id == id_type), + DeviceObject = list_obj.SingleOrDefault(o => o.Id == id_obj) + }; + list_dev.Add(dev_item); + type_name = string.Empty; + type_desc = string.Empty; + } +}