Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Story 2067: Refactor thing type #2095

Merged
merged 36 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5018d36
Remove thing types entities
hocinehacherouf May 21, 2023
03a4210
Remove thing types repositories
hocinehacherouf May 21, 2023
6eb748e
Remove thing types repositories interfaces
hocinehacherouf May 21, 2023
db33b69
Remove InsertAngGetIdAsync
hocinehacherouf May 21, 2023
83b9af1
Add repos DeviceModelRepository and LabelRepository on uof
hocinehacherouf May 21, 2023
7af7597
Add AWS external service to manage aws iot
hocinehacherouf May 21, 2023
88433f3
Remove aws automappers
hocinehacherouf May 21, 2023
a31b8e8
Remove ThingTypeService
hocinehacherouf May 21, 2023
70b32e9
Add AwsDeviceModelService
hocinehacherouf May 21, 2023
88a74ec
Remove Aws thing type controller
hocinehacherouf May 21, 2023
421c51f
Update SyncThingTypesJob
hocinehacherouf May 21, 2023
febfdbb
Add ef migration to remove thing types entities
hocinehacherouf May 21, 2023
e52190c
Update device model base controller to return device model dto on create
hocinehacherouf May 21, 2023
14f2c1d
Revert DeviceModelSearch component
hocinehacherouf May 21, 2023
d887349
Revert DeviceModel pages
hocinehacherouf May 21, 2023
3eb82f3
Remove Thing Type client service
hocinehacherouf May 21, 2023
50f3f73
Remove thing type validator
hocinehacherouf May 21, 2023
d11be4e
Remove references to thing type client service
hocinehacherouf May 21, 2023
9f4d290
Update CreateDeviceModel method
hocinehacherouf May 21, 2023
ddcce86
Update unit tests after deletion of thing types references
hocinehacherouf May 21, 2023
3255f4f
Add delete labels before delete device model on aws device model service
hocinehacherouf May 21, 2023
746edb4
Fix code scan warning on test Execute_SyncNewAndExistingAndDepprecate…
hocinehacherouf May 21, 2023
7a34cf8
Add unit tests on AwsDeviceModelService
hocinehacherouf May 21, 2023
7aaaf75
Update unit test SaveAsyncTest
hocinehacherouf May 21, 2023
56766ef
Update exceptions on AwsExternalDeviceService
hocinehacherouf May 21, 2023
c469fdf
Fix unit test name
hocinehacherouf May 21, 2023
7ca1cc0
Add unit tests on AwsExternalDeviceService
hocinehacherouf May 21, 2023
3b15ca9
Remove unused declaration on test CreateDeviceModel_ExistingThingType…
hocinehacherouf May 22, 2023
9d1f324
Remove IExternalDeviceServiceV2
hocinehacherouf May 22, 2023
4b2d3dd
Move IExternalDeviceServiceV2 methods to IExternalDeviceService
hocinehacherouf May 22, 2023
7af0b37
Implement IExternalDeviceService
hocinehacherouf May 22, 2023
e8de6bd
Update AwsDeviceModelService to use IExternalDeviceService
hocinehacherouf May 22, 2023
82e542b
Update unit tests on aws to use IExternalDeviceService
hocinehacherouf May 22, 2023
eab8beb
Remove repositories from UnitOfWork
hocinehacherouf May 22, 2023
34a529f
Revert unit tests on UnitOfWorkTests
hocinehacherouf May 22, 2023
91f9653
Add unit tests on ExternalDeviceServiceTests
hocinehacherouf May 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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
@@ -0,0 +1,15 @@
// 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.Services
{
using System.Threading.Tasks;
using AzureIoTHub.Portal.Domain.Shared;

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

Task DeleteDeviceModel(ExternalDeviceModelDto deviceModel);
}
}
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