diff --git a/projects/IoTCenter/Controllers/AppController.cs b/projects/IoTCenter/Controllers/AppController.cs index 73fa2b02..416c40d5 100644 --- a/projects/IoTCenter/Controllers/AppController.cs +++ b/projects/IoTCenter/Controllers/AppController.cs @@ -25,6 +25,8 @@ namespace IoTCenter.Controllers { private readonly IConfiguration _configuration; private readonly IJwtHelper _jwtHelper; + private readonly IRepository _categoryRepo; + private readonly IRepository _productRepo; private readonly IRepository _nodeRepo; private readonly IRepository _sceneRepo; private readonly IRepository _sceneCommandRepo; @@ -35,6 +37,8 @@ namespace IoTCenter.Controllers public AppController(IConfiguration configuration, IJwtHelper jwtHelper, + IRepository categoryRepo, + IRepository productRepo, IRepository nodeRepo, IRepository sceneRepo, IRepository sceneCommandRepo, @@ -45,6 +49,8 @@ namespace IoTCenter.Controllers { this._configuration = configuration; this._jwtHelper = jwtHelper; + this._categoryRepo = categoryRepo; + this._productRepo = productRepo; this._nodeRepo = nodeRepo; this._sceneRepo = sceneRepo; this._sceneCommandRepo = sceneCommandRepo; @@ -60,13 +66,27 @@ namespace IoTCenter.Controllers return View(); } + public IActionResult GetProducts(string token) + { + var userName = this._jwtHelper.GetPayload(token)["UserName"].ToString(); + var model = this._productRepo.ReadOnlyTable().Select(o => new + { + o.Id, + o.Number, + o.Name, + o.Image, + DeviceCount = o.Devices.Count() + }).ToList(); + return Json(model); + } + public IActionResult GetNodes(string token) { var userName = this._jwtHelper.GetPayload(token)["UserName"].ToString(); var model = this._nodeRepo.ReadOnlyTable() .Include(o => o.Scenes) - .OrderBy(o=>o.DisplayOrder) - .ThenBy(o=>o.Name) + .OrderBy(o => o.DisplayOrder) + .ThenBy(o => o.Name) .Select(o => new { o.Id, @@ -75,7 +95,7 @@ namespace IoTCenter.Controllers o.Image, o.DisplayOrder, o.Scenes, - o.Devices.Count + DeviceCount = o.Devices.Count }) .ToList(); return Json(model); diff --git a/projects/IoTCenter/iotcenter.db b/projects/IoTCenter/iotcenter.db index 0ecdb1a4..1fdb9881 100644 Binary files a/projects/IoTCenter/iotcenter.db and b/projects/IoTCenter/iotcenter.db differ diff --git a/projects/IoTClient/Assets/StreamingAssets/IoT.Resources.csproj b/projects/IoTClient/Assets/StreamingAssets/IoT.Resources.csproj index 41857b7d..03684cc3 100644 --- a/projects/IoTClient/Assets/StreamingAssets/IoT.Resources.csproj +++ b/projects/IoTClient/Assets/StreamingAssets/IoT.Resources.csproj @@ -22,6 +22,8 @@ + + @@ -30,5 +32,13 @@ true PreserveNewest + + true + PreserveNewest + + + true + PreserveNewest + \ No newline at end of file diff --git a/projects/IoTClient/Assets/StreamingAssets/wwwroot/index.html b/projects/IoTClient/Assets/StreamingAssets/wwwroot/index.html index c0ee3fb9..bfce3b0a 100644 --- a/projects/IoTClient/Assets/StreamingAssets/wwwroot/index.html +++ b/projects/IoTClient/Assets/StreamingAssets/wwwroot/index.html @@ -13,9 +13,29 @@ - - menu + + + + + + + + + +
  • + +
    + {{n.Name}} + {{n.DeviceCount}} +
    + +
    +
  • +
    house @@ -34,6 +54,7 @@
    + @@ -41,6 +62,39 @@ + @@ -53,6 +62,41 @@ +