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

Add an Export button for Devices list #1483

Merged
merged 23 commits into from
Nov 18, 2022

Conversation

audserraCGI
Copy link
Contributor

@audserraCGI audserraCGI commented Oct 28, 2022

Description

What's new?

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Tests
  • Other

@codecov
Copy link

codecov bot commented Oct 28, 2022

Codecov Report

Base: 89.70% // Head: 89.74% // Increases project coverage by +0.04% 🎉

Coverage data is based on head (782b92a) compared to base (634f85a).
Patch coverage: 91.96% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1483      +/-   ##
==========================================
+ Coverage   89.70%   89.74%   +0.04%     
==========================================
  Files         256      259       +3     
  Lines        8011     8123     +112     
==========================================
+ Hits         7186     7290     +104     
- Misses        825      833       +8     
Impacted Files Coverage Δ
...b.Portal.Client/Pages/Devices/DeviceListPage.razor 58.20% <0.00%> (-2.73%) ⬇️
...zureIoTHub.Portal.Server/Services/DeviceService.cs 100.00% <ø> (ø)
...Hub.Portal.Server/Services/LoRaWanDeviceService.cs 100.00% <ø> (ø)
...zureIoTHub.Portal.Domain/Options/LoRaWANOptions.cs 25.00% <25.00%> (ø)
...THub.Portal.Client/Services/DeviceClientService.cs 100.00% <100.00%> (ø)
....Portal.Server/Controllers/v1.0/AdminController.cs 100.00% <100.00%> (ø)
...zureIoTHub.Portal.Server/Managers/ExportManager.cs 100.00% <100.00%> (ø)
...al.Server/Services/DeviceModelPropertiesService.cs 100.00% <100.00%> (ø)
...ub.Portal.Server/Services/ExternalDeviceService.cs 90.78% <100.00%> (+0.24%) ⬆️
...THub.Portal.Domain/Entities/DeviceModelProperty.cs 100.00% <0.00%> (+16.66%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@kbeaugrand kbeaugrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

Globally 2 things:

  • I think this might be only an option in an Admin menu instead of the device list page...
  • The best for us might to use the Device registry as the source to export regardless of the device kind

@audserraCGI audserraCGI changed the title WIP : Add an Import and an Export button for Devices list Add an Export button for Devices list Nov 9, 2022
@audserraCGI audserraCGI force-pushed the add_import_and_export_devices_feature branch from 2d89b51 to f709df8 Compare November 10, 2022 11:15
@kbeaugrand kbeaugrand force-pushed the add_import_and_export_devices_feature branch 2 times, most recently from 4c14030 to fab8fb0 Compare November 15, 2022 13:00
@audserraCGI audserraCGI force-pushed the add_import_and_export_devices_feature branch 2 times, most recently from 63156d2 to e34964d Compare November 15, 2022 14:38
Comment on lines +87 to +106
foreach (var item in list)
{
var deviceObject = JsonNode.Parse(item)!;

csvWriter.WriteField(deviceObject["deviceId"].ToString(), true);
csvWriter.WriteField(deviceObject["tags"]["deviceName"]?.ToString(), true);
csvWriter.WriteField(deviceObject["tags"]["modelId"]);

foreach (var tag in tags)
{
csvWriter.WriteField(string.Format(CultureInfo.InvariantCulture, $"{deviceObject!["tags"][tag]}"));
}

foreach (var property in properties)
{
csvWriter.WriteField(string.Format(CultureInfo.InvariantCulture, $"{deviceObject!["desired"][property]}"));
}

await csvWriter.NextRecordAsync();
}

Check notice

Code scanning / CodeQL

Missed opportunity to use Select

This foreach loop immediately [maps its iteration variable to another variable](1) - consider mapping the sequence explicitly using '.Select(...)'.
@audserraCGI audserraCGI force-pushed the add_import_and_export_devices_feature branch from 8921ecf to 293e671 Compare November 18, 2022 10:50
@audserraCGI audserraCGI marked this pull request as ready for review November 18, 2022 15:11
@audserraCGI audserraCGI requested a review from a team as a code owner November 18, 2022 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Add an Import and an Export button for Devices list
3 participants