Skip to content

Commit

Permalink
Story 2067: Refactor thing type (#2095)
Browse files Browse the repository at this point in the history
* Remove thing types entities

* Remove thing types repositories

* Remove thing types repositories interfaces

* Remove InsertAngGetIdAsync

* Add repos DeviceModelRepository and LabelRepository on uof

* Add AWS external service to manage aws iot

* Remove aws automappers

* Remove ThingTypeService

* Add AwsDeviceModelService

* Remove Aws thing type controller

* Update SyncThingTypesJob

* Add ef migration to remove thing types entities

* Update device model base controller to return device model dto on create

* Revert DeviceModelSearch component

* Revert DeviceModel pages

* Remove Thing Type client service

* Remove thing type validator

* Remove references to thing type client service

* Update CreateDeviceModel method

* Update unit tests after deletion of thing types references

* Add delete labels before delete device model on aws device model service

* Fix code scan warning on test Execute_SyncNewAndExistingAndDepprecatedThingTypes_DeviceModelsSynced

* Add unit tests on AwsDeviceModelService

* Update unit test SaveAsyncTest

* Update exceptions on AwsExternalDeviceService

* Fix unit test name

* Add unit tests on AwsExternalDeviceService

* Remove unused declaration on test CreateDeviceModel_ExistingThingType_ResourceAlreadyExistsExceptionIsThrown

* Remove IExternalDeviceServiceV2

* Move IExternalDeviceServiceV2 methods to IExternalDeviceService

* Implement IExternalDeviceService

* Update AwsDeviceModelService to use IExternalDeviceService

* Update unit tests on aws to use IExternalDeviceService

* Remove repositories from UnitOfWork

* Revert unit tests on UnitOfWorkTests

* Add unit tests on ExternalDeviceServiceTests
  • Loading branch information
hocinehacherouf authored and kbeaugrand committed Jun 20, 2023
1 parent 96e7e9a commit 1002ac1
Show file tree
Hide file tree
Showing 73 changed files with 3,108 additions and 4,512 deletions.
55 changes: 0 additions & 55 deletions src/AzureIoTHub.Portal.Application/Mappers/AWS/ThingTypeProfile.cs

This file was deleted.

This file was deleted.

This file was deleted.

66 changes: 42 additions & 24 deletions src/AzureIoTHub.Portal.Application/Mappers/DeviceModelProfile.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,42 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Application.Mappers
{
using AutoMapper;
using AzureIoTHub.Portal.Domain.Entities;
using Models.v10;
using Models.v10.LoRaWAN;

public class DeviceModelProfile : Profile
{
public DeviceModelProfile()
{
_ = CreateMap<DeviceModelDto, DeviceModel>()
.ForMember(dest => dest.Id, opts => opts.MapFrom(src => src.ModelId))
.ReverseMap();

_ = CreateMap<LoRaDeviceModelDto, DeviceModel>()
.ForMember(dest => dest.Id, opts => opts.MapFrom(src => src.ModelId))
.ReverseMap();
}
}
}
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Application.Mappers
{
using Amazon.IoT.Model;
using AutoMapper;
using AzureIoTHub.Portal.Domain.Entities;
using AzureIoTHub.Portal.Domain.Shared;
using Models.v10;
using Models.v10.LoRaWAN;

public class DeviceModelProfile : Profile
{
public DeviceModelProfile()
{
_ = CreateMap<DeviceModelDto, DeviceModel>()
.ForMember(dest => dest.Id, opts => opts.MapFrom(src => src.ModelId))
.ReverseMap();

_ = CreateMap<LoRaDeviceModelDto, DeviceModel>()
.ForMember(dest => dest.Id, opts => opts.MapFrom(src => src.ModelId))
.ReverseMap();

_ = CreateMap<DeviceModelDto, ExternalDeviceModelDto>()
.ForMember(dest => dest.Name, opts => opts.MapFrom(src => src.Name))
.ForMember(dest => dest.Description, opts => opts.MapFrom(src => src.Description));

_ = CreateMap<ExternalDeviceModelDto, CreateThingTypeRequest>()
.ForMember(dest => dest.ThingTypeName, opts => opts.MapFrom(src => src.Name))
.ForMember(dest => dest.ThingTypeProperties, opts => opts.MapFrom(src => new ThingTypeProperties
{
ThingTypeDescription = src.Description
}));

_ = CreateMap<DescribeThingTypeResponse, DeviceModel>()
.ForMember(dest => dest.Id, opts => opts.MapFrom(src => src.ThingTypeId))
.ForMember(dest => dest.Name, opts => opts.MapFrom(src => src.ThingTypeName))
.ForMember(dest => dest.Description, opts => opts.MapFrom(src => src.ThingTypeProperties.ThingTypeDescription ?? string.Empty));
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public interface IDeviceModelService<TListItem, TModel>

Task<TModel> GetDeviceModel(string deviceModelId);

Task CreateDeviceModel(TModel deviceModel);
Task<TModel> CreateDeviceModel(TModel deviceModel);

Task UpdateDeviceModel(TModel deviceModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ namespace AzureIoTHub.Portal.Application.Services
using System.Threading.Tasks;
using Models.v10;
using Microsoft.Azure.Devices;
using Microsoft.Azure.Devices.Shared;

using Microsoft.Azure.Devices.Shared;
using AzureIoTHub.Portal.Domain.Shared;

public interface IExternalDeviceService
{
Task<ExternalDeviceModelDto> CreateDeviceModel(ExternalDeviceModelDto deviceModel);

Task DeleteDeviceModel(ExternalDeviceModelDto deviceModel);

Task<Device> GetDevice(string deviceId);

Task<Twin> GetDeviceTwin(string deviceId);
Expand Down
12 changes: 8 additions & 4 deletions src/AzureIoTHub.Portal.Client/AzureIoTHub.Portal.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Components\AWS\**" />
<Content Remove="Components\AWS\**" />
<EmbeddedResource Remove="Components\AWS\**" />
<None Remove="Components\AWS\**" />
<TypeScriptCompile Remove="Components\AWS\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="ChartJs.Blazor.Fork" Version="2.0.2" />
Expand Down Expand Up @@ -39,9 +47,5 @@
<ItemGroup>
<ProjectReference Include="..\AzureIoTHub.Portal.Shared\AzureIoTHub.Portal.Shared.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Components\AWS\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
@using AzureIoTHub.Portal.Models.v10;

@inject PortalSettings Portal;

<MudExpansionPanels>
<MudExpansionPanels>
<MudExpansionPanel Text="Search panel">
<MudGrid>
<MudItem xs="12" md="6">
@if (Portal.CloudProvider.Equals("Azure"))
{
<MudTextField @bind-Value="searchText" Placeholder="Device Model Name / Device Model Description" id="searchText"></MudTextField>

}
else
{
<MudTextField @bind-Value="searchText" Placeholder="Thing Type Name / Description / Tags / Searchable Attributes" id="searchText"></MudTextField>

}
<MudTextField @bind-Value="searchText" Placeholder="Device Model Name / Device Model Description" id="searchText"></MudTextField>
</MudItem>

<MudItem xs="12">
Expand All @@ -29,24 +16,24 @@
</MudExpansionPanels>

@code {
[Parameter]
public EventCallback<DeviceModelSearchInfo> OnSearch { get; set; }

private string? searchText = string.Empty;

private async Task Search()
{
[Parameter]
public EventCallback<DeviceModelSearchInfo> OnSearch { get; set; }

private string? searchText = string.Empty;

private async Task Search()
{
var searchInfo = new DeviceModelSearchInfo
{
SearchText = searchText
};
await OnSearch.InvokeAsync(searchInfo);
}

private async Task Reset()
{
searchText = string.Empty;

await Search();
};
await OnSearch.InvokeAsync(searchInfo);
}

private async Task Reset()
{
searchText = string.Empty;

await Search();
}
}
}
Loading

0 comments on commit 1002ac1

Please sign in to comment.