Add Layout Controller

This commit is contained in:
Thomas Fransolet 2020-03-06 17:09:57 +01:00
parent 8c0468a22e
commit b84b9a2513
2 changed files with 91 additions and 0 deletions

View File

@ -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
/// <summary>
/// It's a test ! :)
/// </summary>
[AllowAnonymous]
[HttpGet("panelSection")]
public ActionResult<IEnumerable<PanelSection>> Get()
{
List<PanelSection> panelSectionToSend = new List<PanelSection>();
PanelSection panelSection = new PanelSection();
panelSection.Label = "System";
panelSection.Icon = "System";
panelSection.Color = "System";
panelSection.DefaultRoute = "System";
List<PanelMenuItem> panelMenuItemList = new List<PanelMenuItem>();
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;
}
}
}

View File

@ -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<PanelMenuItem> 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<PanelMenuItem> Children { get; set; }
}
}