From b84b9a2513c650c3b63a515329860981929802d3 Mon Sep 17 00:00:00 2001 From: Thomas Fransolet Date: Fri, 6 Mar 2020 17:09:57 +0100 Subject: [PATCH] Add Layout Controller --- MyCore/Controllers/LayoutController.cs | 64 ++++++++++++++++++++++++++ MyCore/Models/Layout/PanelSection.cs | 27 +++++++++++ 2 files changed, 91 insertions(+) create mode 100644 MyCore/Controllers/LayoutController.cs create mode 100644 MyCore/Models/Layout/PanelSection.cs diff --git a/MyCore/Controllers/LayoutController.cs b/MyCore/Controllers/LayoutController.cs new file mode 100644 index 0000000..ecafd07 --- /dev/null +++ b/MyCore/Controllers/LayoutController.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using MQTTnet; +using MQTTnet.Client; +using MQTTnet.Server; +using MyCore.Models; +using MyCore.Models.Layout; +using MyCore.Services; +using static MyCore.Services.OddService; + +namespace MyCore.Controllers +{ + [Authorize(Roles = "User")] + [Route("api/layout")] + [ApiController] + public class LayoutController : ControllerBase + { + + // GET api/values + /// + /// It's a test ! :) + /// + [AllowAnonymous] + [HttpGet("panelSection")] + public ActionResult> Get() + { + List panelSectionToSend = new List(); + PanelSection panelSection = new PanelSection(); + panelSection.Label = "System"; + panelSection.Icon = "System"; + panelSection.Color = "System"; + panelSection.DefaultRoute = "System"; + + List panelMenuItemList = new List(); + PanelMenuItem panelMenuItem1 = new PanelMenuItem(); + panelMenuItem1.Label = "About"; + panelMenuItem1.Route = "/system/summary"; + panelMenuItem1.Icon = "fa-question-circle"; + panelMenuItem1.BadgeValue = 0; + panelMenuItem1.BadgeType = null; + panelMenuItem1.Children = null; + + PanelMenuItem panelMenuItem2 = new PanelMenuItem(); + panelMenuItem2.Label = "Events"; + panelMenuItem2.Route = "/system/events"; + panelMenuItem2.Icon = "fa-file-text"; + panelMenuItem2.BadgeValue = 0; + panelMenuItem2.BadgeType = null; + panelMenuItem2.Children = null; + + panelMenuItemList.Add(panelMenuItem1); + panelMenuItemList.Add(panelMenuItem2); + + panelSection.Children = panelMenuItemList; + + panelSectionToSend.Add(panelSection); + return panelSectionToSend; + } + } +} diff --git a/MyCore/Models/Layout/PanelSection.cs b/MyCore/Models/Layout/PanelSection.cs new file mode 100644 index 0000000..07179a1 --- /dev/null +++ b/MyCore/Models/Layout/PanelSection.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace MyCore.Models.Layout +{ + public class PanelSection + { + public string Label { get; set; } + public string Icon { get; set; } + public string Color { get; set; } + public string DefaultRoute { get; set; } + public List Children { get; set; } + } + + public class PanelMenuItem + { + public string Label { get; set; } + public string Route { get; set; } + public string Icon { get; set; } + public int BadgeValue { get; set; } + public string BadgeType { get; set; } + public List Children { get; set; } + } + +}