From 30a5477961bc1c1a3cabeb8359da88f8e1df1685 Mon Sep 17 00:00:00 2001 From: Nicola Carminati Date: Wed, 8 Aug 2018 12:09:48 +0200 Subject: [PATCH] Added tranlsation in Heads Names --- Step.Config/Config/headsConfig.xml | 15 ++++++++++++--- Step.Config/Config/headsConfigValidator.xsd | 18 +++++++++++++++++- Step.Model/ConfigModels/HeadsConfigModel.cs | 5 +++-- Step.Model/Constants.cs | 1 + .../WebApi/ConfigurationController.cs | 2 +- Step/Controllers/WebApi/LanguageController.cs | 15 ++++++++++++++- Step/wwwroot/src/components/production.vue | 2 +- Step/wwwroot/src/modules/mheads.vue | 2 +- 8 files changed, 50 insertions(+), 10 deletions(-) diff --git a/Step.Config/Config/headsConfig.xml b/Step.Config/Config/headsConfig.xml index f9820c95..31fc9e02 100644 --- a/Step.Config/Config/headsConfig.xml +++ b/Step.Config/Config/headsConfig.xml @@ -1,19 +1,28 @@  - Testa 1 + + Testa Spindle A + Head Spindle A + SPINDLE 55 80 - Testa 2 + + Testa AWJ B + Head AWJ B + AWJ 55 80 - Testa 3 + + Testa WJ C + Head WJ C + WJ 55 80 diff --git a/Step.Config/Config/headsConfigValidator.xsd b/Step.Config/Config/headsConfigValidator.xsd index 72af6110..0588b2da 100644 --- a/Step.Config/Config/headsConfigValidator.xsd +++ b/Step.Config/Config/headsConfigValidator.xsd @@ -8,7 +8,14 @@ - + + + + + + + + @@ -36,4 +43,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/Step.Model/ConfigModels/HeadsConfigModel.cs b/Step.Model/ConfigModels/HeadsConfigModel.cs index c8fad081..85ce6cf6 100644 --- a/Step.Model/ConfigModels/HeadsConfigModel.cs +++ b/Step.Model/ConfigModels/HeadsConfigModel.cs @@ -1,13 +1,14 @@ -using static Step.Model.Constants; +using System.Collections.Generic; +using static Step.Model.Constants; namespace Step.Model.ConfigModels { public class HeadsConfigModel { public int Id; - public string Name; public HEAD_TYPE Type; public short WarningLimit; public short AlarmLimit; + public Dictionary LocalizedNames { get; set; } } } diff --git a/Step.Model/Constants.cs b/Step.Model/Constants.cs index 564538d4..1788a138 100644 --- a/Step.Model/Constants.cs +++ b/Step.Model/Constants.cs @@ -164,6 +164,7 @@ namespace Step.Model public const string MAINTENANCE_PREFIX_ID = "maint_"; public const string MAINTENANCE_DESC_PREFIX_ID = "maint_desc_"; public const string SOFTKEY_PREFIX_ID = "softkey_"; + public const string SOFTKEY_HEAD_ID = "Head_"; public const string ALARM_PREFIX = "alarm_"; public static class FUNCTIONALITY_NAMES diff --git a/Step/Controllers/WebApi/ConfigurationController.cs b/Step/Controllers/WebApi/ConfigurationController.cs index dc6c6044..1a5e4b77 100644 --- a/Step/Controllers/WebApi/ConfigurationController.cs +++ b/Step/Controllers/WebApi/ConfigurationController.cs @@ -83,7 +83,7 @@ namespace Step.Controllers.WebApi List heads = HeadsConfig.Select(x => new DTOHeadsConfigModel() { Id = x.Id, - Name = x.Name, + Name = "Head "+ x.Id, Type = x.Type.ToString() }).ToList(); diff --git a/Step/Controllers/WebApi/LanguageController.cs b/Step/Controllers/WebApi/LanguageController.cs index 45f0ccd1..b673f6ea 100644 --- a/Step/Controllers/WebApi/LanguageController.cs +++ b/Step/Controllers/WebApi/LanguageController.cs @@ -38,12 +38,15 @@ namespace Step.Controllers.WebApi Dictionary maintenance = GetLocalizeMaintenanceName(language); Dictionary softKeys = GetLocalizedSoftKeysNames(language); Dictionary alarms = GetPlcAlarmsTranslations(language); + Dictionary heads = GetLocalizedHeadsNames(language); + // Concat maintenances dictionary with translations dictionary translations = translations.Concat(maintenance).ToDictionary(x => x.Key, x => x.Value); translations = translations.Concat(softKeys).ToDictionary(x => x.Key, x => x.Value); translations = translations.Concat(alarms).ToDictionary(x => x.Key, x => x.Value); - + translations = translations.Concat(heads).ToDictionary(x => x.Key, x => x.Value); + if (translations == null) return InternalServerError(); @@ -78,6 +81,16 @@ namespace Step.Controllers.WebApi x => SOFTKEY_PREFIX_ID + x.Id.ToString(), // PREFIX + softkey Id x => GetValueFromLocalizationList(x.LocalizedNames, language, "SoftKey_" + x.Id) ); + } + + + private static Dictionary GetLocalizedHeadsNames(string language) + { + return HeadsConfig + .ToDictionary( + x => SOFTKEY_HEAD_ID + x.Id.ToString(), // PREFIX + softkey Id + x => GetValueFromLocalizationList(x.LocalizedNames, language, "Head_" + x.Id) + ); } private static string GetValueFromLocalizationList(Dictionary localizedNames, string language, string defaultString) diff --git a/Step/wwwroot/src/components/production.vue b/Step/wwwroot/src/components/production.vue index de2414e3..7507af51 100644 --- a/Step/wwwroot/src/components/production.vue +++ b/Step/wwwroot/src/components/production.vue @@ -41,7 +41,7 @@
-
-