From 5dd1877a4bea613ff6a98eb6edea21fc5fe77fe1 Mon Sep 17 00:00:00 2001 From: ben salim Date: Fri, 19 Aug 2022 11:36:35 +0200 Subject: [PATCH] remove udeless code --- .../Pages/EdgeModels/EdgeModelDetailPageTest.cs | 2 +- .../Pages/EdgeModels/CreateEdgeModelsPage.razor | 8 ++++---- .../Pages/EdgeModels/EdgeModelDetailPage.razor | 12 ++++++------ .../Pages/EdgeModels/EdgeModule/ModuleDialog.razor | 2 +- .../Server/Helpers/ConfigHelper.cs | 4 ++-- .../Server/Services/ConfigService.cs | 10 ---------- .../Shared/Models/v1.0/IoTEdgeModule/ConfigModule.cs | 11 ++++++----- .../v1.0/IoTEdgeModule/EdgeAgentPropertiesDesired.cs | 7 +++++++ .../v1.0/IoTEdgeModule/EdgeHubPropertiesDesired.cs | 5 +++++ 9 files changed, 32 insertions(+), 29 deletions(-) diff --git a/src/AzureIoTHub.Portal.Tests.Unit/Client/Pages/EdgeModels/EdgeModelDetailPageTest.cs b/src/AzureIoTHub.Portal.Tests.Unit/Client/Pages/EdgeModels/EdgeModelDetailPageTest.cs index 340bd8336..783ab9f2b 100644 --- a/src/AzureIoTHub.Portal.Tests.Unit/Client/Pages/EdgeModels/EdgeModelDetailPageTest.cs +++ b/src/AzureIoTHub.Portal.Tests.Unit/Client/Pages/EdgeModels/EdgeModelDetailPageTest.cs @@ -75,7 +75,7 @@ public void ClickOnSaveChangesShouldUpdateTheData() _ = this.mockSnackbarService .Setup(c => c.Add($"Edge model successfully updated.", Severity.Success, null)) - .Returns((Snackbar)null); + .Returns(value: null); var cut = RenderComponent(ComponentParameter.CreateParameter("ModelID", this.mockEdgeModleId)); diff --git a/src/AzureIoTHub.Portal/Client/Pages/EdgeModels/CreateEdgeModelsPage.razor b/src/AzureIoTHub.Portal/Client/Pages/EdgeModels/CreateEdgeModelsPage.razor index 52f8b52a3..ff9dd2289 100644 --- a/src/AzureIoTHub.Portal/Client/Pages/EdgeModels/CreateEdgeModelsPage.razor +++ b/src/AzureIoTHub.Portal/Client/Pages/EdgeModels/CreateEdgeModelsPage.razor @@ -77,20 +77,20 @@ - Module Name + Module name Image URI See detail Delete - + - + - Edit + Detail diff --git a/src/AzureIoTHub.Portal/Client/Pages/EdgeModels/EdgeModelDetailPage.razor b/src/AzureIoTHub.Portal/Client/Pages/EdgeModels/EdgeModelDetailPage.razor index 6b3a0bc49..920a58f11 100644 --- a/src/AzureIoTHub.Portal/Client/Pages/EdgeModels/EdgeModelDetailPage.razor +++ b/src/AzureIoTHub.Portal/Client/Pages/EdgeModels/EdgeModelDetailPage.razor @@ -83,20 +83,20 @@ - Module Name - Image uri + Module name + Image URI See detail Delete - + - + - Edit + Detail @@ -245,7 +245,7 @@ var parameters = new DialogParameters(); parameters.Add("module", module); - DialogOptions options = new DialogOptions() { MaxWidth = MaxWidth.Medium, FullWidth = true, CloseButton = true }; + DialogOptions options = new DialogOptions() { MaxWidth = MaxWidth.Small, FullWidth = true, CloseButton = true }; if (!string.IsNullOrWhiteSpace(module.ModuleName)) { diff --git a/src/AzureIoTHub.Portal/Client/Pages/EdgeModels/EdgeModule/ModuleDialog.razor b/src/AzureIoTHub.Portal/Client/Pages/EdgeModels/EdgeModule/ModuleDialog.razor index ae6a1c147..d3bc3c1ca 100644 --- a/src/AzureIoTHub.Portal/Client/Pages/EdgeModels/EdgeModule/ModuleDialog.razor +++ b/src/AzureIoTHub.Portal/Client/Pages/EdgeModels/EdgeModule/ModuleDialog.razor @@ -10,7 +10,7 @@ diff --git a/src/AzureIoTHub.Portal/Server/Helpers/ConfigHelper.cs b/src/AzureIoTHub.Portal/Server/Helpers/ConfigHelper.cs index 4c2d93405..2190be346 100644 --- a/src/AzureIoTHub.Portal/Server/Helpers/ConfigHelper.cs +++ b/src/AzureIoTHub.Portal/Server/Helpers/ConfigHelper.cs @@ -246,12 +246,12 @@ public static Dictionary> GenerateModulesCon var configModule = new ConfigModule { Type = "docker", - Status = module.Status, + Status = "running", Settings = new ModuleSettings() { Image = module.ImageURI }, - Version = module.Version, + Version = "1.0", RestarPolicy = "always", EnvironmentVariables = new Dictionary() }; diff --git a/src/AzureIoTHub.Portal/Server/Services/ConfigService.cs b/src/AzureIoTHub.Portal/Server/Services/ConfigService.cs index f1ceae9d8..67f8f87d2 100644 --- a/src/AzureIoTHub.Portal/Server/Services/ConfigService.cs +++ b/src/AzureIoTHub.Portal/Server/Services/ConfigService.cs @@ -100,16 +100,6 @@ public async Task> GetConfigModuleList(string modelId) moduleList.Add(newModule); } } - - // Adds system modules to the list of modules - //if (modObject.TryGetValue("systemModules", out var systemModulesToken)) - //{ - // foreach (var sm in systemModulesToken.Values()) - // { - // var newModule = ConfigHelper.CreateGatewayModule(config, sm); - // moduleList.Add(newModule); - // } - //} } return moduleList; diff --git a/src/AzureIoTHub.Portal/Shared/Models/v1.0/IoTEdgeModule/ConfigModule.cs b/src/AzureIoTHub.Portal/Shared/Models/v1.0/IoTEdgeModule/ConfigModule.cs index 692a6cc7f..dce9dbdd4 100644 --- a/src/AzureIoTHub.Portal/Shared/Models/v1.0/IoTEdgeModule/ConfigModule.cs +++ b/src/AzureIoTHub.Portal/Shared/Models/v1.0/IoTEdgeModule/ConfigModule.cs @@ -8,15 +8,19 @@ namespace AzureIoTHub.Portal.Shared.Models.v10.IoTEdgeModule public class ConfigModule { + [JsonProperty(PropertyName = "settings")] public ModuleSettings Settings { get; set; } + [JsonProperty(PropertyName = "type")] public string Type { get; set; } [JsonProperty(PropertyName = "env")] public IDictionary? EnvironmentVariables { get; set; } + [JsonProperty(PropertyName = "status")] public string? Status { get; set; } + [JsonProperty(PropertyName = "restarPolicy")] public string? RestarPolicy { get; set; } public string? Version { get; set; } @@ -29,14 +33,11 @@ public ConfigModule() public class ModuleSettings { + [JsonProperty(PropertyName = "image")] public string Image { get; set; } + [JsonProperty(PropertyName = "createOptions")] public string CreateOptions { get; set; } - - public ModuleSettings() - { - CreateOptions = "{ }"; - } } public class EnvironmentVariable diff --git a/src/AzureIoTHub.Portal/Shared/Models/v1.0/IoTEdgeModule/EdgeAgentPropertiesDesired.cs b/src/AzureIoTHub.Portal/Shared/Models/v1.0/IoTEdgeModule/EdgeAgentPropertiesDesired.cs index f01072678..d9864f18a 100644 --- a/src/AzureIoTHub.Portal/Shared/Models/v1.0/IoTEdgeModule/EdgeAgentPropertiesDesired.cs +++ b/src/AzureIoTHub.Portal/Shared/Models/v1.0/IoTEdgeModule/EdgeAgentPropertiesDesired.cs @@ -8,12 +8,16 @@ namespace AzureIoTHub.Portal.Shared.Models.v10.IoTEdgeModule public class EdgeAgentPropertiesDesired { + [JsonProperty(PropertyName = "modules")] public IDictionary Modules { get; set; } + [JsonProperty(PropertyName = "runtime")] public Runtime Runtime { get; set; } + [JsonProperty(PropertyName = "shemaVersion")] public string SchemaVersion { get; set; } + [JsonProperty(PropertyName = "systemModules")] public SystemModules SystemModules { get; set; } public EdgeAgentPropertiesDesired() @@ -27,8 +31,10 @@ public EdgeAgentPropertiesDesired() public class Runtime { + [JsonProperty(PropertyName = "settings")] public RuntimeSettings Settings { get; set; } + [JsonProperty(PropertyName = "type")] public string Type { get; set; } public Runtime() @@ -40,6 +46,7 @@ public Runtime() public class RuntimeSettings { + [JsonProperty(PropertyName = "minDockerVersion")] public string MinDockerVersion { get; set; } public RuntimeSettings() diff --git a/src/AzureIoTHub.Portal/Shared/Models/v1.0/IoTEdgeModule/EdgeHubPropertiesDesired.cs b/src/AzureIoTHub.Portal/Shared/Models/v1.0/IoTEdgeModule/EdgeHubPropertiesDesired.cs index 34b8a7095..0c77c41cf 100644 --- a/src/AzureIoTHub.Portal/Shared/Models/v1.0/IoTEdgeModule/EdgeHubPropertiesDesired.cs +++ b/src/AzureIoTHub.Portal/Shared/Models/v1.0/IoTEdgeModule/EdgeHubPropertiesDesired.cs @@ -4,13 +4,17 @@ namespace AzureIoTHub.Portal.Shared.Models.v10.IoTEdgeModule { using System.Collections.Generic; + using Newtonsoft.Json; public class EdgeHubPropertiesDesired { + [JsonProperty(PropertyName = "routes")] public IDictionary Routes { get; set; } + [JsonProperty(PropertyName = "shemaVersion")] public string SchemaVersion { get; set; } + [JsonProperty(PropertyName = "storeAndForwardConfiguration")] public StoreAndForwardConfiguration StoreAndForwardConfiguration { get; set; } public EdgeHubPropertiesDesired() @@ -23,6 +27,7 @@ public EdgeHubPropertiesDesired() public class StoreAndForwardConfiguration { + [JsonProperty(PropertyName = "timeToLiveSecs")] public int TimeToLiveSecs { get; set; } public StoreAndForwardConfiguration()