From 9091bdfa7b98e9f0af8e07e4d43ecac68610a2b7 Mon Sep 17 00:00:00 2001 From: Thomas Fransolet Date: Fri, 6 Mar 2020 22:38:34 +0100 Subject: [PATCH] MC LayoutController, init PanelSection --- MyCore/Controllers/LayoutController.cs | 165 +++++++++++++++++++++++++ MyCore/Models/Layout/PanelSection.cs | 27 ++++ 2 files changed, 192 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..ec946f0 --- /dev/null +++ b/MyCore/Controllers/LayoutController.cs @@ -0,0 +1,165 @@ +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 panelSectionList = new List(); + + // Energy + PanelSection panelSectionEnergy = new PanelSection(); + panelSectionEnergy.Label = "Energy"; + panelSectionEnergy.Icon = "fas fa-seedling"; + panelSectionEnergy.DefaultRoute = "energy"; + panelSectionEnergy.Color = "green"; + + List panelSectionEnergyList = new List(); + PanelMenuItem panelMenuItemElectricity = new PanelMenuItem(); + panelMenuItemElectricity.Label = "Electricity"; + panelMenuItemElectricity.Icon = "fas fa-bolt"; + panelMenuItemElectricity.Route = "electricity"; + panelMenuItemElectricity.Color = "yellow"; + panelMenuItemElectricity.BadgeType = null; + panelMenuItemElectricity.BadgeValue = 0; + + PanelMenuItem panelMenuItemGas = new PanelMenuItem(); + panelMenuItemGas.Label = "Gas"; + panelMenuItemGas.Icon = "fas fa-burn"; + panelMenuItemGas.Route = "gas"; + panelMenuItemGas.Color = "orange"; + panelMenuItemGas.BadgeType = null; + panelMenuItemGas.BadgeValue = 0; + + PanelMenuItem panelMenuItemWater = new PanelMenuItem(); + panelMenuItemWater.Label = "Water"; + panelMenuItemWater.Icon = "fas fa-tint"; + panelMenuItemWater.Route = "water"; + panelMenuItemWater.Color = "blue"; + panelMenuItemWater.BadgeType = null; + panelMenuItemWater.BadgeValue = 0; + + panelSectionEnergyList.Add(panelMenuItemElectricity); + panelSectionEnergyList.Add(panelMenuItemGas); + panelSectionEnergyList.Add(panelMenuItemWater); + + panelSectionEnergy.Children = panelSectionEnergyList; + + // Security + PanelSection panelSectionSecurity = new PanelSection(); + panelSectionSecurity.Label = "Security"; + panelSectionSecurity.Icon = "fas fa-lock"; + panelSectionSecurity.Color = "yellow"; + panelSectionSecurity.DefaultRoute = "security"; + + List panelMenuItemSecurityList = new List(); + PanelMenuItem panelMenuItemAlarm = new PanelMenuItem(); + panelMenuItemAlarm.Label = "Alarm"; + panelMenuItemAlarm.Icon = "fas fa-bell"; + panelMenuItemAlarm.Color = "yellow"; + panelMenuItemAlarm.Route = "alarm"; + panelMenuItemAlarm.BadgeType = null; + panelMenuItemAlarm.BadgeValue = 0; + + PanelMenuItem panelMenuItemCamera = new PanelMenuItem(); + panelMenuItemCamera.Label = "Camera"; + panelMenuItemCamera.Icon = "fas fa-video"; + panelMenuItemCamera.Route = "camera"; + panelMenuItemCamera.Color = "black"; + panelMenuItemCamera.BadgeType = null; + panelMenuItemCamera.BadgeValue = 0; + + panelMenuItemSecurityList.Add(panelMenuItemAlarm); + panelMenuItemSecurityList.Add(panelMenuItemCamera); + + panelSectionSecurity.Children = panelMenuItemSecurityList; + + // Entertainment + PanelSection panelSectionEntertainment = new PanelSection(); + panelSectionEntertainment.Label = "Entertainment"; + panelSectionEntertainment.Icon = "fas fa-music"; + panelSectionEntertainment.Color = "blue"; + panelSectionEntertainment.DefaultRoute = "entertainment"; + + List panelMenuItemEntertainmentList = new List(); + PanelMenuItem panelMenuItemMusic = new PanelMenuItem(); + panelMenuItemMusic.Label = "Music"; + panelMenuItemMusic.Icon = "fas fa-music"; + panelMenuItemMusic.Route = "music"; + panelMenuItemMusic.Color = "black"; + panelMenuItemMusic.BadgeType = null; + panelMenuItemMusic.BadgeValue = 0; + + PanelMenuItem panelMenuItemTv = new PanelMenuItem(); + panelMenuItemTv.Label = "Tv"; + panelMenuItemTv.Icon = "fas fa-tv"; + panelMenuItemTv.Route = "tv"; + panelMenuItemTv.BadgeType = null; + panelMenuItemTv.BadgeValue = 0; + + panelMenuItemEntertainmentList.Add(panelMenuItemMusic); + panelMenuItemEntertainmentList.Add(panelMenuItemTv); + + panelSectionEntertainment.Children = panelMenuItemEntertainmentList; + + // Health + PanelSection panelSectionHealth = new PanelSection(); + panelSectionHealth.Label = "Health"; + panelSectionHealth.Icon = "fas fa-heartbeat"; + panelSectionHealth.DefaultRoute = "health"; + panelSectionHealth.Color = "#ff4c4c"; + + List panelSectionHealthList = new List(); + PanelMenuItem panelMenuItemMyBody = new PanelMenuItem(); + panelMenuItemMyBody.Label = "My body"; + panelMenuItemMyBody.Icon = "fas fa-user-alt"; + panelMenuItemMyBody.Route = "body"; + panelMenuItemMyBody.BadgeType = null; + panelMenuItemMyBody.BadgeValue = 0; + + PanelMenuItem panelMenuItemFitness = new PanelMenuItem(); + panelMenuItemFitness.Label = "Fitness"; + panelMenuItemFitness.Icon = "fas fa-running"; + panelMenuItemFitness.Route = "fitness"; + panelMenuItemFitness.BadgeType = null; + panelMenuItemFitness.BadgeValue = 0; + + panelSectionHealthList.Add(panelMenuItemMyBody); + panelSectionHealthList.Add(panelMenuItemFitness); + + panelSectionHealth.Children = panelSectionHealthList; + + + // panelSectionList + panelSectionList.Add(panelSectionEnergy); + panelSectionList.Add(panelSectionSecurity); + panelSectionList.Add(panelSectionEntertainment); + panelSectionList.Add(panelSectionHealth); + + return panelSectionList; + } + } +} diff --git a/MyCore/Models/Layout/PanelSection.cs b/MyCore/Models/Layout/PanelSection.cs new file mode 100644 index 0000000..f55faeb --- /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 string Color { get; set; } + public int BadgeValue { get; set; } + public string BadgeType { get; set; } + public List Children { get; set; } + } +}