From cab2a8423185b778f1ff2decd059d849d2bffcfa Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Wed, 11 Nov 2020 10:07:05 +0100 Subject: [PATCH] Fix changes --- Thermo.Active.Config/Config/DataModel.xml | 2 ++ .../Controllers/RedisController.cs | 15 +++++------ .../DTOModels/DTOMessageModel.cs | 5 ---- .../WebApi/CmsConnectController.cs | 25 +++++++++++++++++++ .../components/cmsconnect-info-dialog.vue | 2 +- .../app_modules_thermo/components/slider.ts | 10 ++++++++ .../app_modules_thermo/components/slider.vue | 1 + .../base-components/thermocamera.ts | 8 ++++++ .../riscaldi/components/show-riscaldi-info.ts | 8 +----- 9 files changed, 56 insertions(+), 20 deletions(-) diff --git a/Thermo.Active.Config/Config/DataModel.xml b/Thermo.Active.Config/Config/DataModel.xml index a2cdf20f..8a6ac85b 100644 --- a/Thermo.Active.Config/Config/DataModel.xml +++ b/Thermo.Active.Config/Config/DataModel.xml @@ -104,6 +104,8 @@ + + diff --git a/Thermo.Active.Database/Controllers/RedisController.cs b/Thermo.Active.Database/Controllers/RedisController.cs index 92c00809..1143bef6 100644 --- a/Thermo.Active.Database/Controllers/RedisController.cs +++ b/Thermo.Active.Database/Controllers/RedisController.cs @@ -15,7 +15,6 @@ namespace Thermo.Active.Database.Controllers private const string redisAlmIt = "AdpConf:Plc:Condition:It"; private const string redisAlmEn = "AdpConf:Plc:Condition:En"; private const string currentUserPath = "Machine:Hmi:User"; - private const string machineMessagePath = "Machine:Messages"; private const string machineStatusPath = "Machine:Status"; private const string machinePowerPath = "Machine:Power"; private const string machineAlarmPath = "Machine:Alarm"; @@ -34,6 +33,7 @@ namespace Thermo.Active.Database.Controllers private const string machineAxisLoad = "Machine:Axes:%NN%:Load"; private const string machineAxisName = "Machine:Axes:%NN%:Name"; private const string machineEventKpis = "Events:Kpis"; + private const string machineMessagePath = "Events:Messages"; public static void WriteProductionNotification(uint ProductionProcess, string Notification) { @@ -103,11 +103,6 @@ namespace Thermo.Active.Database.Controllers string redisHash = redUtil.man.redHash(currentActiveVersionPath); return redUtil.man.setRSV(redisHash, version.ToString()); } - public static bool SendMessage(DTOMessageModel message) - { - string redisHash = redUtil.man.redHash(machineMessagePath); - return redUtil.man.setJson(redisHash, message); - } public static bool WriteCurrentMachineStatus(string status) { @@ -181,7 +176,13 @@ namespace Thermo.Active.Database.Controllers redUtil.man.ListPush(redisHash, alarms); return true; } - + + public static bool SendMessage(string msg) + { + string redisHash = redUtil.man.redHash(machineMessagePath); + redUtil.man.ListPush(redisHash, msg); + return true; + } public static bool WriteCurrentAxisStatus(Dictionary axis) { diff --git a/Thermo.Active.Model/DTOModels/DTOMessageModel.cs b/Thermo.Active.Model/DTOModels/DTOMessageModel.cs index 05424e14..ad14286d 100644 --- a/Thermo.Active.Model/DTOModels/DTOMessageModel.cs +++ b/Thermo.Active.Model/DTOModels/DTOMessageModel.cs @@ -10,10 +10,5 @@ namespace Thermo.Active.Model.DTOModels public string Department { get; set; } - public DateTime TimeStamp { get; set; } - - public string UserId { get; set; } - - public Guid Id { get; set; } } } \ No newline at end of file diff --git a/Thermo.Active/Controllers/WebApi/CmsConnectController.cs b/Thermo.Active/Controllers/WebApi/CmsConnectController.cs index 1ec77b6f..9f1e4e97 100644 --- a/Thermo.Active/Controllers/WebApi/CmsConnectController.cs +++ b/Thermo.Active/Controllers/WebApi/CmsConnectController.cs @@ -3,11 +3,13 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Net; +using System.Security.Claims; using System.Web.Http; using TeamDev.SDK.MVVM; using Thermo.Active.CmsConnectGateway; using Thermo.Active.CmsConnectGateway.Events; using Thermo.Active.CmsConnectGateway.Exceptions; +using Thermo.Active.Database.Controllers; using Thermo.Active.Model.DTOModels; using static Thermo.Active.Model.Constants; @@ -238,5 +240,28 @@ namespace Thermo.Active.Controllers.WebApi } } + [Route("message"), HttpPost] + public IHttpActionResult sendMessages([FromBody][Required]DTOMessageModel message) + { + var identity = User.Identity as ClaimsIdentity; + // Find user id from the bearer token + var userId = identity.Claims.FirstOrDefault(c => c.Type == USER_ID_KEY); + if (userId == null) + return Unauthorized(); + + int userIdInt = Convert.ToInt32(userId.Value); + using (UsersController usersController = new UsersController()) + { + // Update database with new language + DTOMessageUserModel user = usersController.GetUserInfo(userIdInt); + String username = user.Username + " (" +user.FirstName + " " + user.LastName + ")"; + + var ts = DateTime.UtcNow.ToString("o"); + var a = "{\"v\": { \"userId\": \"" + username + "\", \"text\": \"" + message.Message + "\", \"resolutionHrs\": " + message.EstimateTime + ", \"department\": \"" + message.Department + "\"},\"ts\": \"" + ts + "\"}"; + RedisController.SendMessage(a); + } + return Ok(); + } + } } diff --git a/Thermo.Active/wwwroot/src/app_modules/machine/components/cmsconnect-info-dialog.vue b/Thermo.Active/wwwroot/src/app_modules/machine/components/cmsconnect-info-dialog.vue index 134d2004..56a756a8 100644 --- a/Thermo.Active/wwwroot/src/app_modules/machine/components/cmsconnect-info-dialog.vue +++ b/Thermo.Active/wwwroot/src/app_modules/machine/components/cmsconnect-info-dialog.vue @@ -211,7 +211,7 @@ :isEnrolled="cmsConnectActivationData().isEnrolled"> - + diff --git a/Thermo.Active/wwwroot/src/app_modules_thermo/components/slider.ts b/Thermo.Active/wwwroot/src/app_modules_thermo/components/slider.ts index 53372579..7f0cd0bf 100644 --- a/Thermo.Active/wwwroot/src/app_modules_thermo/components/slider.ts +++ b/Thermo.Active/wwwroot/src/app_modules_thermo/components/slider.ts @@ -5,6 +5,8 @@ import { Prop } from 'vue-property-decorator'; import { Hub } from "@/services"; import Numeric from "./numeric"; import { unitOfTime } from "moment"; +import { KeyboardHelper } from "@/app_modules_thermo/components/KeyboardHelper"; + @Component({ name: "slider" }) export default class Slider extends Vue { @@ -54,10 +56,18 @@ export default class Slider extends Vue { startIncrementTouch(event){ event.preventDefault(); this.startIncrement(); + KeyboardHelper.hideKeyboard(); + } + + touchSlider(event){ + KeyboardHelper.hideKeyboard(); + } + startDecrementTouch(event){ event.preventDefault(); this.startDecrement(); + KeyboardHelper.hideKeyboard(); } startIncrement() { diff --git a/Thermo.Active/wwwroot/src/app_modules_thermo/components/slider.vue b/Thermo.Active/wwwroot/src/app_modules_thermo/components/slider.vue index 9eb0cf50..07405c73 100644 --- a/Thermo.Active/wwwroot/src/app_modules_thermo/components/slider.vue +++ b/Thermo.Active/wwwroot/src/app_modules_thermo/components/slider.vue @@ -15,6 +15,7 @@ :max="this.value.range.max" :step="this.initalStep" v-model.number="actualvalue" + v-on:touchstart="touchSlider" type="range" />
diff --git a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/riscaldi/components/base-components/thermocamera.ts b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/riscaldi/components/base-components/thermocamera.ts index 0158c78b..113ab46c 100644 --- a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/riscaldi/components/base-components/thermocamera.ts +++ b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/riscaldi/components/base-components/thermocamera.ts @@ -48,7 +48,15 @@ export default class Thermocamera extends Vue { if(this.modeEnabled.checkpointHMI != this.modeEnabled.setpointHMI) this.$emit("enabChanged"); if(this.modeEnabled.setpointHMI == 1) + { store.state.warmers.tCamStatus.thermoCamMode = true; + store.state.warmers.channels.forEach(function(element, index){ + if (element.setpointHMI==0) + store.state.warmers.channels[index].tCamActive = false; + else + store.state.warmers.channels[index].tCamActive = true; + }); + } else store.state.warmers.tCamStatus.thermoCamMode = false; } diff --git a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/riscaldi/components/show-riscaldi-info.ts b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/riscaldi/components/show-riscaldi-info.ts index b37531f5..7c0b9d97 100644 --- a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/riscaldi/components/show-riscaldi-info.ts +++ b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/riscaldi/components/show-riscaldi-info.ts @@ -166,13 +166,7 @@ export default class ShowRiscaldamentoSuperioreInfo extends Vue { // recipeActions.setCurrent(store, this.recipe); this.isLoading = true; - if(this.warmersEdited){ - store.state.warmers.channels.forEach(function(element, index){ - if (element.setpointHMI==0) - store.state.warmers.channels[index].tCamActive = false; - else - store.state.warmers.channels[index].tCamActive = true; - }); + if(this.warmersEdited){ await warmersService.Update(store.state.warmers.channels.reduce((p, c) => { p[c.idChannel] = c.setpointHMI; return p; }, {})); } if(this.tempsEdited)