mirror of
https://bitbucket.org/myhomie/mycorerepository.git
synced 2025-12-06 09:41:19 +00:00
Add Layout Controller
This commit is contained in:
parent
8c0468a22e
commit
b84b9a2513
64
MyCore/Controllers/LayoutController.cs
Normal file
64
MyCore/Controllers/LayoutController.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
27
MyCore/Models/Layout/PanelSection.cs
Normal file
27
MyCore/Models/Layout/PanelSection.cs
Normal 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; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user