From 999e6c4b0e7077707ba665c38bfbd38c43b3e0b2 Mon Sep 17 00:00:00 2001 From: Thomas Fransolet Date: Sun, 25 Jul 2021 01:51:56 +0200 Subject: [PATCH] bugs fix + update service generation --- lib/Components/multi_select_container.dart | 28 ++++-- .../Section/SubSection/Map/map_config.dart | 7 +- .../Section/section_detail_screen.dart | 16 ++-- .../configuration_detail_screen.dart | 2 +- .../new_configuration_popup.dart | 3 +- .../Configurations/new_section_popup.dart | 2 +- manager_api/.openapi-generator/FILES | 6 +- manager_api/README.md | 4 +- manager_api/doc/DeviceDTO.md | 2 + manager_api/doc/DeviceDetailDTO.md | 2 + manager_api/doc/MapDTO.md | 2 +- manager_api/doc/MapTypeApp.md | 14 +++ manager_api/doc/PlayerMessageDTO.md | 16 ++++ manager_api/doc/SectionApi.md | 40 +++++++++ manager_api/lib/api.dart | 3 +- manager_api/lib/api/section_api.dart | 52 ++++++++++++ manager_api/lib/api_client.dart | 6 +- manager_api/lib/api_helper.dart | 4 +- manager_api/lib/model/device_detail_dto.dart | 22 ++++- manager_api/lib/model/device_dto.dart | 26 +++++- manager_api/lib/model/map_dto.dart | 4 +- manager_api/lib/model/map_type_app.dart | 85 +++++++++++++++++++ manager_api/lib/model/player_message_dto.dart | 80 +++++++++++++++++ manager_api/swagger.yaml | 32 ++++++- manager_api/test/map_type_app_test.dart | 20 +++++ manager_api/test/player_message_dto_test.dart | 31 +++++++ 26 files changed, 470 insertions(+), 39 deletions(-) create mode 100644 manager_api/doc/MapTypeApp.md create mode 100644 manager_api/doc/PlayerMessageDTO.md create mode 100644 manager_api/lib/model/map_type_app.dart create mode 100644 manager_api/lib/model/player_message_dto.dart create mode 100644 manager_api/test/map_type_app_test.dart create mode 100644 manager_api/test/player_message_dto_test.dart diff --git a/lib/Components/multi_select_container.dart b/lib/Components/multi_select_container.dart index 3745434..c7d0f6f 100644 --- a/lib/Components/multi_select_container.dart +++ b/lib/Components/multi_select_container.dart @@ -1,12 +1,15 @@ import 'package:flutter/material.dart'; import 'package:manager_app/constants.dart'; +import 'message_notification.dart'; + class MultiSelectContainer extends StatelessWidget { final Color color; final String label; final List values; final List initialValue; final bool isMultiple; + final bool isAtLeastOne; final ValueChanged> onChanged; const MultiSelectContainer({ Key key, @@ -15,6 +18,7 @@ class MultiSelectContainer extends StatelessWidget { this.values, this.initialValue, this.isMultiple, + this.isAtLeastOne = false, this.onChanged, }) : super(key: key); @@ -36,6 +40,7 @@ class MultiSelectContainer extends StatelessWidget { values, initialValue, isMultiple, + isAtLeastOne, onSelectionChanged: (selectedList) { onChanged(selectedList); }, @@ -53,10 +58,12 @@ class MultiSelectChip extends StatefulWidget { final List selectedValues; final Function(List) onSelectionChanged; // +added final bool isMultiple; + final bool isAtLeastOne; MultiSelectChip( this.values, this.selectedValues, this.isMultiple, + this.isAtLeastOne, {this.onSelectionChanged} // +added ); @override @@ -74,17 +81,20 @@ class _MultiSelectChipState extends State { selectedColor: kPrimaryColor, onSelected: (selected) { setState(() { - if (widget.isMultiple) { - widget.selectedValues.contains(item) - ? widget.selectedValues.remove(item) - : widget.selectedValues.add(item); - widget.onSelectionChanged(widget.selectedValues); + if (widget.isAtLeastOne && widget.selectedValues.length == 1 && widget.selectedValues[0] == item) { + showNotification(Colors.orange, kWhite, 'Au moins une valeur doit être sélectionnée', context); } else { - widget.selectedValues.clear(); - widget.selectedValues.add(item); - widget.onSelectionChanged(widget.selectedValues); + if (widget.isMultiple) { + widget.selectedValues.contains(item) + ? widget.selectedValues.remove(item) + : widget.selectedValues.add(item); + widget.onSelectionChanged(widget.selectedValues); + } else { + widget.selectedValues.clear(); + widget.selectedValues.add(item); + widget.onSelectionChanged(widget.selectedValues); + } } - // +added }); }, ), diff --git a/lib/Screens/Configurations/Section/SubSection/Map/map_config.dart b/lib/Screens/Configurations/Section/SubSection/Map/map_config.dart index 456fcec..40eb66d 100644 --- a/lib/Screens/Configurations/Section/SubSection/Map/map_config.dart +++ b/lib/Screens/Configurations/Section/SubSection/Map/map_config.dart @@ -36,10 +36,13 @@ class _MapConfigState extends State { @override void initState() { super.initState(); - mapDTO = MapDTO.fromJson(json.decode(widget.initialValue)); List test = new List.from(mapDTO.points); mapDTO.points = test; + + if (mapDTO.mapType == null) { + mapDTO.mapType = MapTypeApp.hybrid; + } } @override @@ -77,7 +80,7 @@ class _MapConfigState extends State { values: map_types, onChanged: (value) { var tempOutput = new List.from(value); - mapDTO.mapType = MapType.fromJson(tempOutput[0]); + mapDTO.mapType = MapTypeApp.fromJson(tempOutput[0]); widget.onChanged(jsonEncode(mapDTO).toString()); }, ), diff --git a/lib/Screens/Configurations/Section/section_detail_screen.dart b/lib/Screens/Configurations/Section/section_detail_screen.dart index fa1d8c7..6a9ee46 100644 --- a/lib/Screens/Configurations/Section/section_detail_screen.dart +++ b/lib/Screens/Configurations/Section/section_detail_screen.dart @@ -78,17 +78,17 @@ class _SectionDetailScreenState extends State { Padding( padding: const EdgeInsets.all(8.0), child: Icon( - getSectionIcon(sectionDTO.type), + sectionDTO != null ? getSectionIcon(sectionDTO.type) : Icons.add, color: kPrimaryColor, size: 25, ), ), - Text(sectionDTO.label, style: TextStyle(fontSize: 30, fontWeight: FontWeight.w400)), + Text(sectionDTO != null ? sectionDTO.label : "", style: TextStyle(fontSize: 30, fontWeight: FontWeight.w400)), ], ), Padding( padding: const EdgeInsets.all(5.0), - child: Text(DateFormat('dd/MM/yyyy').format(sectionDTO.dateCreation), style: TextStyle(fontSize: 15, fontWeight: FontWeight.w200)), + child: Text(sectionDTO != null ? DateFormat('dd/MM/yyyy').format(sectionDTO.dateCreation) : "", style: TextStyle(fontSize: 15, fontWeight: FontWeight.w200)), ), ], ), @@ -138,14 +138,14 @@ class _SectionDetailScreenState extends State { children: [ StringInputContainer( label: "Nom :", - initialValue: sectionDTO.label, + initialValue: sectionDTO != null ? sectionDTO.label : "", onChanged: (value) { sectionDTO.label = value; }, ), ImageInputContainer( label: "Image :", - initialValue: sectionDTO.imageId, + initialValue: sectionDTO != null ? sectionDTO.imageId : "", color: kPrimaryColor, onChanged: (ResourceDTO resource) { print("received value in grant older"); @@ -163,7 +163,7 @@ class _SectionDetailScreenState extends State { label: "Titre :", modalLabel: "Titre", color: kPrimaryColor, - initialValue: sectionDTO.title, + initialValue: sectionDTO != null ? sectionDTO.title : [], onGetResult: (value) { if (sectionDTO.title != value) { sectionDTO.title = value; @@ -176,7 +176,7 @@ class _SectionDetailScreenState extends State { label: "Description :", modalLabel: "Description", color: kPrimaryColor, - initialValue: sectionDTO.description, + initialValue: sectionDTO != null ? sectionDTO.description : [], onGetResult: (value) { if (sectionDTO.description != value) { sectionDTO.description = value; @@ -200,7 +200,7 @@ class _SectionDetailScreenState extends State { width: size.width * 0.8, child: Padding( padding: const EdgeInsets.all(10.0), - child: getSpecificData(sectionDTO, appContext), + child: sectionDTO != null ? getSpecificData(sectionDTO, appContext) : null, ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(30), diff --git a/lib/Screens/Configurations/configuration_detail_screen.dart b/lib/Screens/Configurations/configuration_detail_screen.dart index a0d31b5..16a5cdd 100644 --- a/lib/Screens/Configurations/configuration_detail_screen.dart +++ b/lib/Screens/Configurations/configuration_detail_screen.dart @@ -133,6 +133,7 @@ class _ConfigurationDetailScreenState extends State { initialValue: configurationDTO.languages != null ? configurationDTO.languages: [], values: languages, isMultiple: true, + isAtLeastOne: true, onChanged: (value) { var tempOutput = new List.from(value); configurationDTO.languages = tempOutput; @@ -317,7 +318,6 @@ class _ConfigurationDetailScreenState extends State { Future> getSections(ConfigurationDTO configurationDTO, Client client) async { print("getSections"); - print(configurationDTO.id); List sections = await client.sectionApi.sectionGetFromConfiguration(configurationDTO.id); print(sections); sections.sort((a, b) => a.order.compareTo(b.order)); diff --git a/lib/Screens/Configurations/new_configuration_popup.dart b/lib/Screens/Configurations/new_configuration_popup.dart index 8ea87d5..65f2264 100644 --- a/lib/Screens/Configurations/new_configuration_popup.dart +++ b/lib/Screens/Configurations/new_configuration_popup.dart @@ -78,7 +78,6 @@ void showNewConfiguration(AppContext appContext, BuildContext context) { void create(ConfigurationDTO configurationDTO, AppContext appContext, context) async { if (configurationDTO.label != null) { - Navigator.of(context).pop(); ConfigurationDTO newConfiguration = await appContext.getContext().clientAPI.configurationApi.configurationCreate(configurationDTO); ManagerAppContext managerAppContext = appContext.getContext(); @@ -86,5 +85,7 @@ void create(ConfigurationDTO configurationDTO, AppContext appContext, context) a appContext.setContext(managerAppContext); showNotification(Colors.green, kWhite, 'La configuration a été créée avec succès', context); + + Navigator.of(context).pop(); } } \ No newline at end of file diff --git a/lib/Screens/Configurations/new_section_popup.dart b/lib/Screens/Configurations/new_section_popup.dart index a95519f..49a3b5a 100644 --- a/lib/Screens/Configurations/new_section_popup.dart +++ b/lib/Screens/Configurations/new_section_popup.dart @@ -98,7 +98,6 @@ void showNewSection(String configurationId, AppContext appContext, BuildContext void create(SectionDTO sectionDTO, AppContext appContext, BuildContext context, bool isSubSection, Function sendSubSection) async { if (sectionDTO.label != null) { - Navigator.of(context).pop(); SectionDTO newSection = await appContext.getContext().clientAPI.sectionApi.sectionCreate(sectionDTO); if (!isSubSection) { @@ -112,5 +111,6 @@ void create(SectionDTO sectionDTO, AppContext appContext, BuildContext context, } else { sendSubSection(newSection); } + Navigator.of(context).pop(); } } \ No newline at end of file diff --git a/manager_api/.openapi-generator/FILES b/manager_api/.openapi-generator/FILES index 1e85bb0..5767340 100644 --- a/manager_api/.openapi-generator/FILES +++ b/manager_api/.openapi-generator/FILES @@ -13,8 +13,9 @@ doc/ImageDTO.md doc/ImageGeoPoint.md doc/LoginDTO.md doc/MapDTO.md -doc/MapType.md +doc/MapTypeApp.md doc/MenuDTO.md +doc/PlayerMessageDTO.md doc/ResourceApi.md doc/ResourceDTO.md doc/ResourceDetailDTO.md @@ -55,8 +56,9 @@ lib/model/image_dto.dart lib/model/image_geo_point.dart lib/model/login_dto.dart lib/model/map_dto.dart -lib/model/map_type.dart +lib/model/map_type_app.dart lib/model/menu_dto.dart +lib/model/player_message_dto.dart lib/model/resource_detail_dto.dart lib/model/resource_dto.dart lib/model/resource_type.dart diff --git a/manager_api/README.md b/manager_api/README.md index ab85a8a..269c300 100644 --- a/manager_api/README.md +++ b/manager_api/README.md @@ -96,6 +96,7 @@ Class | Method | HTTP request | Description *SectionApi* | [**sectionGetSliderDTO**](doc\/SectionApi.md#sectiongetsliderdto) | **GET** /api/Section/SliderDTO | *SectionApi* | [**sectionGetVideoDTO**](doc\/SectionApi.md#sectiongetvideodto) | **GET** /api/Section/VideoDTO | *SectionApi* | [**sectionGetWebDTO**](doc\/SectionApi.md#sectiongetwebdto) | **GET** /api/Section/WebDTO | +*SectionApi* | [**sectionPlayerMessageDTO**](doc\/SectionApi.md#sectionplayermessagedto) | **GET** /api/Section/PlayerMessageDTO | *SectionApi* | [**sectionUpdate**](doc\/SectionApi.md#sectionupdate) | **PUT** /api/Section | *SectionApi* | [**sectionUpdateOrder**](doc\/SectionApi.md#sectionupdateorder) | **PUT** /api/Section/order | *UserApi* | [**userCreateUser**](doc\/UserApi.md#usercreateuser) | **POST** /api/User | @@ -116,8 +117,9 @@ Class | Method | HTTP request | Description - [ImageGeoPoint](doc\/ImageGeoPoint.md) - [LoginDTO](doc\/LoginDTO.md) - [MapDTO](doc\/MapDTO.md) - - [MapType](doc\/MapType.md) + - [MapTypeApp](doc\/MapTypeApp.md) - [MenuDTO](doc\/MenuDTO.md) + - [PlayerMessageDTO](doc\/PlayerMessageDTO.md) - [ResourceDTO](doc\/ResourceDTO.md) - [ResourceDetailDTO](doc\/ResourceDetailDTO.md) - [ResourceType](doc\/ResourceType.md) diff --git a/manager_api/doc/DeviceDTO.md b/manager_api/doc/DeviceDTO.md index 0004f9f..62df565 100644 --- a/manager_api/doc/DeviceDTO.md +++ b/manager_api/doc/DeviceDTO.md @@ -9,6 +9,7 @@ import 'package:managerapi/api.dart'; Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **id** | **String** | | [optional] +**identifier** | **String** | | [optional] **name** | **String** | | [optional] **ipAddressWLAN** | **String** | | [optional] **ipAddressETH** | **String** | | [optional] @@ -16,6 +17,7 @@ Name | Type | Description | Notes **configuration** | **String** | | [optional] **connected** | **bool** | | [optional] **dateCreation** | [**DateTime**](DateTime.md) | | [optional] +**dateUpdate** | [**DateTime**](DateTime.md) | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/manager_api/doc/DeviceDetailDTO.md b/manager_api/doc/DeviceDetailDTO.md index fa40fcd..4968995 100644 --- a/manager_api/doc/DeviceDetailDTO.md +++ b/manager_api/doc/DeviceDetailDTO.md @@ -9,6 +9,7 @@ import 'package:managerapi/api.dart'; Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **id** | **String** | | [optional] +**identifier** | **String** | | [optional] **name** | **String** | | [optional] **ipAddressWLAN** | **String** | | [optional] **ipAddressETH** | **String** | | [optional] @@ -16,6 +17,7 @@ Name | Type | Description | Notes **configuration** | **String** | | [optional] **connected** | **bool** | | [optional] **dateCreation** | [**DateTime**](DateTime.md) | | [optional] +**dateUpdate** | [**DateTime**](DateTime.md) | | [optional] **connectionLevel** | **String** | | [optional] **lastConnectionLevel** | [**DateTime**](DateTime.md) | | [optional] **batteryLevel** | **String** | | [optional] diff --git a/manager_api/doc/MapDTO.md b/manager_api/doc/MapDTO.md index 107bd50..656bd08 100644 --- a/manager_api/doc/MapDTO.md +++ b/manager_api/doc/MapDTO.md @@ -9,7 +9,7 @@ import 'package:managerapi/api.dart'; Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **zoom** | **int** | | [optional] -**mapType** | [**MapType**](MapType.md) | | [optional] +**mapType** | [**MapTypeApp**](MapTypeApp.md) | | [optional] **points** | [**List**](GeoPointDTO.md) | | [optional] [default to const []] **iconResourceId** | **String** | | [optional] **iconSource** | **String** | | [optional] diff --git a/manager_api/doc/MapTypeApp.md b/manager_api/doc/MapTypeApp.md new file mode 100644 index 0000000..4d1d1a4 --- /dev/null +++ b/manager_api/doc/MapTypeApp.md @@ -0,0 +1,14 @@ +# managerapi.model.MapTypeApp + +## Load the model package +```dart +import 'package:managerapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/manager_api/doc/PlayerMessageDTO.md b/manager_api/doc/PlayerMessageDTO.md new file mode 100644 index 0000000..0f07218 --- /dev/null +++ b/manager_api/doc/PlayerMessageDTO.md @@ -0,0 +1,16 @@ +# managerapi.model.PlayerMessageDTO + +## Load the model package +```dart +import 'package:managerapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**configChanged** | **bool** | | [optional] +**isDeleted** | **bool** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/manager_api/doc/SectionApi.md b/manager_api/doc/SectionApi.md index f65ea2e..aecedef 100644 --- a/manager_api/doc/SectionApi.md +++ b/manager_api/doc/SectionApi.md @@ -21,6 +21,7 @@ Method | HTTP request | Description [**sectionGetSliderDTO**](SectionApi.md#sectiongetsliderdto) | **GET** /api/Section/SliderDTO | [**sectionGetVideoDTO**](SectionApi.md#sectiongetvideodto) | **GET** /api/Section/VideoDTO | [**sectionGetWebDTO**](SectionApi.md#sectiongetwebdto) | **GET** /api/Section/WebDTO | +[**sectionPlayerMessageDTO**](SectionApi.md#sectionplayermessagedto) | **GET** /api/Section/PlayerMessageDTO | [**sectionUpdate**](SectionApi.md#sectionupdate) | **PUT** /api/Section | [**sectionUpdateOrder**](SectionApi.md#sectionupdateorder) | **PUT** /api/Section/order | @@ -517,6 +518,45 @@ This endpoint does not need any parameter. [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **sectionPlayerMessageDTO** +> PlayerMessageDTO sectionPlayerMessageDTO() + + + +### Example +```dart +import 'package:managerapi/api.dart'; +// TODO Configure OAuth2 access token for authorization: bearer +//defaultApiClient.getAuthentication('bearer').accessToken = 'YOUR_ACCESS_TOKEN'; + +final api_instance = SectionApi(); + +try { + final result = api_instance.sectionPlayerMessageDTO(); + print(result); +} catch (e) { + print('Exception when calling SectionApi->sectionPlayerMessageDTO: $e\n'); +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**PlayerMessageDTO**](PlayerMessageDTO.md) + +### Authorization + +[bearer](../README.md#bearer) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **sectionUpdate** > SectionDTO sectionUpdate(sectionDTO) diff --git a/manager_api/lib/api.dart b/manager_api/lib/api.dart index a984d28..ad57cca 100644 --- a/manager_api/lib/api.dart +++ b/manager_api/lib/api.dart @@ -43,8 +43,9 @@ part 'model/image_dto.dart'; part 'model/image_geo_point.dart'; part 'model/login_dto.dart'; part 'model/map_dto.dart'; -part 'model/map_type.dart'; +part 'model/map_type_app.dart'; part 'model/menu_dto.dart'; +part 'model/player_message_dto.dart'; part 'model/resource_dto.dart'; part 'model/resource_detail_dto.dart'; part 'model/resource_type.dart'; diff --git a/manager_api/lib/api/section_api.dart b/manager_api/lib/api/section_api.dart index ace0a5f..caace06 100644 --- a/manager_api/lib/api/section_api.dart +++ b/manager_api/lib/api/section_api.dart @@ -716,6 +716,58 @@ class SectionApi { return Future.value(null); } + /// Performs an HTTP 'GET /api/Section/PlayerMessageDTO' operation and returns the [Response]. + Future sectionPlayerMessageDTOWithHttpInfo() async { + final path = r'/api/Section/PlayerMessageDTO'; + + Object postBody; + + final queryParams = []; + final headerParams = {}; + final formParams = {}; + + final contentTypes = []; + final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; + final authNames = ['bearer']; + + if ( + nullableContentType != null && + nullableContentType.toLowerCase().startsWith('multipart/form-data') + ) { + bool hasFields = false; + final mp = MultipartRequest(null, null); + if (hasFields) { + postBody = mp; + } + } else { + } + + return await apiClient.invokeAPI( + path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + nullableContentType, + authNames, + ); + } + + Future sectionPlayerMessageDTO() async { + final response = await sectionPlayerMessageDTOWithHttpInfo(); + if (response.statusCode >= HttpStatus.badRequest) { + throw ApiException(response.statusCode, _decodeBodyBytes(response)); + } + // When a remote server returns no body with a status of 204, we shall not decode it. + // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" + // FormatException when trying to decode an empty string. + if (response.body != null && response.statusCode != HttpStatus.noContent) { + return apiClient.deserialize(_decodeBodyBytes(response), 'PlayerMessageDTO') as PlayerMessageDTO; + } + return Future.value(null); + } + /// Performs an HTTP 'PUT /api/Section' operation and returns the [Response]. /// Parameters: /// diff --git a/manager_api/lib/api_client.dart b/manager_api/lib/api_client.dart index 86c28f2..4fe0d20 100644 --- a/manager_api/lib/api_client.dart +++ b/manager_api/lib/api_client.dart @@ -174,11 +174,13 @@ class ApiClient { return LoginDTO.fromJson(value); case 'MapDTO': return MapDTO.fromJson(value); - case 'MapType': - return MapTypeTypeTransformer().decode(value); + case 'MapTypeApp': + return MapTypeAppTypeTransformer().decode(value); case 'MenuDTO': return MenuDTO.fromJson(value); + case 'PlayerMessageDTO': + return PlayerMessageDTO.fromJson(value); case 'ResourceDTO': return ResourceDTO.fromJson(value); case 'ResourceDetailDTO': diff --git a/manager_api/lib/api_helper.dart b/manager_api/lib/api_helper.dart index 563f194..1f73cef 100644 --- a/manager_api/lib/api_helper.dart +++ b/manager_api/lib/api_helper.dart @@ -58,8 +58,8 @@ String parameterToString(dynamic value) { if (value is DateTime) { return value.toUtc().toIso8601String(); } - if (value is MapType) { - return MapTypeTypeTransformer().encode(value).toString(); + if (value is MapTypeApp) { + return MapTypeAppTypeTransformer().encode(value).toString(); } if (value is ResourceType) { return ResourceTypeTypeTransformer().encode(value).toString(); diff --git a/manager_api/lib/model/device_detail_dto.dart b/manager_api/lib/model/device_detail_dto.dart index f936a30..f8b686c 100644 --- a/manager_api/lib/model/device_detail_dto.dart +++ b/manager_api/lib/model/device_detail_dto.dart @@ -13,6 +13,7 @@ class DeviceDetailDTO { /// Returns a new [DeviceDetailDTO] instance. DeviceDetailDTO({ this.id, + this.identifier, this.name, this.ipAddressWLAN, this.ipAddressETH, @@ -20,6 +21,7 @@ class DeviceDetailDTO { this.configuration, this.connected, this.dateCreation, + this.dateUpdate, this.connectionLevel, this.lastConnectionLevel, this.batteryLevel, @@ -28,6 +30,8 @@ class DeviceDetailDTO { String id; + String identifier; + String name; String ipAddressWLAN; @@ -42,6 +46,8 @@ class DeviceDetailDTO { DateTime dateCreation; + DateTime dateUpdate; + String connectionLevel; DateTime lastConnectionLevel; @@ -53,6 +59,7 @@ class DeviceDetailDTO { @override bool operator ==(Object other) => identical(this, other) || other is DeviceDetailDTO && other.id == id && + other.identifier == identifier && other.name == name && other.ipAddressWLAN == ipAddressWLAN && other.ipAddressETH == ipAddressETH && @@ -60,6 +67,7 @@ class DeviceDetailDTO { other.configuration == configuration && other.connected == connected && other.dateCreation == dateCreation && + other.dateUpdate == dateUpdate && other.connectionLevel == connectionLevel && other.lastConnectionLevel == lastConnectionLevel && other.batteryLevel == batteryLevel && @@ -68,6 +76,7 @@ class DeviceDetailDTO { @override int get hashCode => (id == null ? 0 : id.hashCode) + + (identifier == null ? 0 : identifier.hashCode) + (name == null ? 0 : name.hashCode) + (ipAddressWLAN == null ? 0 : ipAddressWLAN.hashCode) + (ipAddressETH == null ? 0 : ipAddressETH.hashCode) + @@ -75,19 +84,23 @@ class DeviceDetailDTO { (configuration == null ? 0 : configuration.hashCode) + (connected == null ? 0 : connected.hashCode) + (dateCreation == null ? 0 : dateCreation.hashCode) + + (dateUpdate == null ? 0 : dateUpdate.hashCode) + (connectionLevel == null ? 0 : connectionLevel.hashCode) + (lastConnectionLevel == null ? 0 : lastConnectionLevel.hashCode) + (batteryLevel == null ? 0 : batteryLevel.hashCode) + (lastBatteryLevel == null ? 0 : lastBatteryLevel.hashCode); @override - String toString() => 'DeviceDetailDTO[id=$id, name=$name, ipAddressWLAN=$ipAddressWLAN, ipAddressETH=$ipAddressETH, configurationId=$configurationId, configuration=$configuration, connected=$connected, dateCreation=$dateCreation, connectionLevel=$connectionLevel, lastConnectionLevel=$lastConnectionLevel, batteryLevel=$batteryLevel, lastBatteryLevel=$lastBatteryLevel]'; + String toString() => 'DeviceDetailDTO[id=$id, identifier=$identifier, name=$name, ipAddressWLAN=$ipAddressWLAN, ipAddressETH=$ipAddressETH, configurationId=$configurationId, configuration=$configuration, connected=$connected, dateCreation=$dateCreation, dateUpdate=$dateUpdate, connectionLevel=$connectionLevel, lastConnectionLevel=$lastConnectionLevel, batteryLevel=$batteryLevel, lastBatteryLevel=$lastBatteryLevel]'; Map toJson() { final json = {}; if (id != null) { json[r'id'] = id; } + if (identifier != null) { + json[r'identifier'] = identifier; + } if (name != null) { json[r'name'] = name; } @@ -109,6 +122,9 @@ class DeviceDetailDTO { if (dateCreation != null) { json[r'dateCreation'] = dateCreation.toUtc().toIso8601String(); } + if (dateUpdate != null) { + json[r'dateUpdate'] = dateUpdate.toUtc().toIso8601String(); + } if (connectionLevel != null) { json[r'connectionLevel'] = connectionLevel; } @@ -130,6 +146,7 @@ class DeviceDetailDTO { ? null : DeviceDetailDTO( id: json[r'id'], + identifier: json[r'identifier'], name: json[r'name'], ipAddressWLAN: json[r'ipAddressWLAN'], ipAddressETH: json[r'ipAddressETH'], @@ -139,6 +156,9 @@ class DeviceDetailDTO { dateCreation: json[r'dateCreation'] == null ? null : DateTime.parse(json[r'dateCreation']), + dateUpdate: json[r'dateUpdate'] == null + ? null + : DateTime.parse(json[r'dateUpdate']), connectionLevel: json[r'connectionLevel'], lastConnectionLevel: json[r'lastConnectionLevel'] == null ? null diff --git a/manager_api/lib/model/device_dto.dart b/manager_api/lib/model/device_dto.dart index ff51a82..19a5677 100644 --- a/manager_api/lib/model/device_dto.dart +++ b/manager_api/lib/model/device_dto.dart @@ -13,6 +13,7 @@ class DeviceDTO { /// Returns a new [DeviceDTO] instance. DeviceDTO({ this.id, + this.identifier, this.name, this.ipAddressWLAN, this.ipAddressETH, @@ -20,10 +21,13 @@ class DeviceDTO { this.configuration, this.connected, this.dateCreation, + this.dateUpdate, }); String id; + String identifier; + String name; String ipAddressWLAN; @@ -38,36 +42,45 @@ class DeviceDTO { DateTime dateCreation; + DateTime dateUpdate; + @override bool operator ==(Object other) => identical(this, other) || other is DeviceDTO && other.id == id && + other.identifier == identifier && other.name == name && other.ipAddressWLAN == ipAddressWLAN && other.ipAddressETH == ipAddressETH && other.configurationId == configurationId && other.configuration == configuration && other.connected == connected && - other.dateCreation == dateCreation; + other.dateCreation == dateCreation && + other.dateUpdate == dateUpdate; @override int get hashCode => (id == null ? 0 : id.hashCode) + + (identifier == null ? 0 : identifier.hashCode) + (name == null ? 0 : name.hashCode) + (ipAddressWLAN == null ? 0 : ipAddressWLAN.hashCode) + (ipAddressETH == null ? 0 : ipAddressETH.hashCode) + (configurationId == null ? 0 : configurationId.hashCode) + (configuration == null ? 0 : configuration.hashCode) + (connected == null ? 0 : connected.hashCode) + - (dateCreation == null ? 0 : dateCreation.hashCode); + (dateCreation == null ? 0 : dateCreation.hashCode) + + (dateUpdate == null ? 0 : dateUpdate.hashCode); @override - String toString() => 'DeviceDTO[id=$id, name=$name, ipAddressWLAN=$ipAddressWLAN, ipAddressETH=$ipAddressETH, configurationId=$configurationId, configuration=$configuration, connected=$connected, dateCreation=$dateCreation]'; + String toString() => 'DeviceDTO[id=$id, identifier=$identifier, name=$name, ipAddressWLAN=$ipAddressWLAN, ipAddressETH=$ipAddressETH, configurationId=$configurationId, configuration=$configuration, connected=$connected, dateCreation=$dateCreation, dateUpdate=$dateUpdate]'; Map toJson() { final json = {}; if (id != null) { json[r'id'] = id; } + if (identifier != null) { + json[r'identifier'] = identifier; + } if (name != null) { json[r'name'] = name; } @@ -89,6 +102,9 @@ class DeviceDTO { if (dateCreation != null) { json[r'dateCreation'] = dateCreation.toUtc().toIso8601String(); } + if (dateUpdate != null) { + json[r'dateUpdate'] = dateUpdate.toUtc().toIso8601String(); + } return json; } @@ -98,6 +114,7 @@ class DeviceDTO { ? null : DeviceDTO( id: json[r'id'], + identifier: json[r'identifier'], name: json[r'name'], ipAddressWLAN: json[r'ipAddressWLAN'], ipAddressETH: json[r'ipAddressETH'], @@ -107,6 +124,9 @@ class DeviceDTO { dateCreation: json[r'dateCreation'] == null ? null : DateTime.parse(json[r'dateCreation']), + dateUpdate: json[r'dateUpdate'] == null + ? null + : DateTime.parse(json[r'dateUpdate']), ); static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => diff --git a/manager_api/lib/model/map_dto.dart b/manager_api/lib/model/map_dto.dart index 40c624c..f8e229d 100644 --- a/manager_api/lib/model/map_dto.dart +++ b/manager_api/lib/model/map_dto.dart @@ -21,7 +21,7 @@ class MapDTO { int zoom; - MapType mapType; + MapTypeApp mapType; List points; @@ -74,7 +74,7 @@ class MapDTO { ? null : MapDTO( zoom: json[r'zoom'], - mapType: MapType.fromJson(json[r'mapType']), + mapType: MapTypeApp.fromJson(json[r'mapType']), points: GeoPointDTO.listFromJson(json[r'points']), iconResourceId: json[r'iconResourceId'], iconSource: json[r'iconSource'], diff --git a/manager_api/lib/model/map_type_app.dart b/manager_api/lib/model/map_type_app.dart new file mode 100644 index 0000000..893968e --- /dev/null +++ b/manager_api/lib/model/map_type_app.dart @@ -0,0 +1,85 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// +// @dart=2.0 + +// ignore_for_file: unused_element, unused_import +// ignore_for_file: always_put_required_named_parameters_first +// ignore_for_file: lines_longer_than_80_chars + +part of openapi.api; + + +class MapTypeApp { + /// Instantiate a new enum with the provided [value]. + const MapTypeApp._(this.value); + + /// The underlying value of this enum member. + final String value; + + @override + String toString() => value; + + String toJson() => value; + + static const none = MapTypeApp._(r'none'); + static const normal = MapTypeApp._(r'normal'); + static const satellite = MapTypeApp._(r'satellite'); + static const terrain = MapTypeApp._(r'terrain'); + static const hybrid = MapTypeApp._(r'hybrid'); + + /// List of all possible values in this [enum][MapTypeApp]. + static const values = [ + none, + normal, + satellite, + terrain, + hybrid, + ]; + + static MapTypeApp fromJson(dynamic value) => + MapTypeAppTypeTransformer().decode(value); + + static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => + json == null || json.isEmpty + ? true == emptyIsNull ? null : [] + : json + .map((value) => MapTypeApp.fromJson(value)) + .toList(growable: true == growable); +} + +/// Transformation class that can [encode] an instance of [MapTypeApp] to String, +/// and [decode] dynamic data back to [MapTypeApp]. +class MapTypeAppTypeTransformer { + const MapTypeAppTypeTransformer._(); + + factory MapTypeAppTypeTransformer() => _instance ??= MapTypeAppTypeTransformer._(); + + String encode(MapTypeApp data) => data.value; + + /// Decodes a [dynamic value][data] to a MapTypeApp. + /// + /// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully, + /// then null is returned. However, if [allowNull] is false and the [dynamic value][data] + /// cannot be decoded successfully, then an [UnimplementedError] is thrown. + /// + /// The [allowNull] is very handy when an API changes and a new enum value is added or removed, + /// and users are still using an old app with the old code. + MapTypeApp decode(dynamic data, {bool allowNull}) { + switch (data) { + case r'none': return MapTypeApp.none; + case r'normal': return MapTypeApp.normal; + case r'satellite': return MapTypeApp.satellite; + case r'terrain': return MapTypeApp.terrain; + case r'hybrid': return MapTypeApp.hybrid; + default: + if (allowNull == false) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } + return null; + } + + /// Singleton [MapTypeAppTypeTransformer] instance. + static MapTypeAppTypeTransformer _instance; +} diff --git a/manager_api/lib/model/player_message_dto.dart b/manager_api/lib/model/player_message_dto.dart new file mode 100644 index 0000000..0341a99 --- /dev/null +++ b/manager_api/lib/model/player_message_dto.dart @@ -0,0 +1,80 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// +// @dart=2.0 + +// ignore_for_file: unused_element, unused_import +// ignore_for_file: always_put_required_named_parameters_first +// ignore_for_file: lines_longer_than_80_chars + +part of openapi.api; + +class PlayerMessageDTO { + /// Returns a new [PlayerMessageDTO] instance. + PlayerMessageDTO({ + this.configChanged, + this.isDeleted, + }); + + bool configChanged; + + bool isDeleted; + + @override + bool operator ==(Object other) => identical(this, other) || other is PlayerMessageDTO && + other.configChanged == configChanged && + other.isDeleted == isDeleted; + + @override + int get hashCode => + (configChanged == null ? 0 : configChanged.hashCode) + + (isDeleted == null ? 0 : isDeleted.hashCode); + + @override + String toString() => 'PlayerMessageDTO[configChanged=$configChanged, isDeleted=$isDeleted]'; + + Map toJson() { + final json = {}; + if (configChanged != null) { + json[r'configChanged'] = configChanged; + } + if (isDeleted != null) { + json[r'isDeleted'] = isDeleted; + } + return json; + } + + /// Returns a new [PlayerMessageDTO] instance and imports its values from + /// [json] if it's non-null, null if [json] is null. + static PlayerMessageDTO fromJson(Map json) => json == null + ? null + : PlayerMessageDTO( + configChanged: json[r'configChanged'], + isDeleted: json[r'isDeleted'], + ); + + static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => + json == null || json.isEmpty + ? true == emptyIsNull ? null : [] + : json.map((v) => PlayerMessageDTO.fromJson(v)).toList(growable: true == growable); + + static Map mapFromJson(Map json) { + final map = {}; + if (json != null && json.isNotEmpty) { + json.forEach((String key, dynamic v) => map[key] = PlayerMessageDTO.fromJson(v)); + } + return map; + } + + // maps a json object with a list of PlayerMessageDTO-objects as value to a dart map + static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + final map = >{}; + if (json != null && json.isNotEmpty) { + json.forEach((String key, dynamic v) { + map[key] = PlayerMessageDTO.listFromJson(v, emptyIsNull: emptyIsNull, growable: growable); + }); + } + return map; + } +} + diff --git a/manager_api/swagger.yaml b/manager_api/swagger.yaml index adc429b..e6e57ee 100644 --- a/manager_api/swagger.yaml +++ b/manager_api/swagger.yaml @@ -1018,6 +1018,20 @@ paths: $ref: '#/components/schemas/MenuDTO' security: - bearer: [] + /api/Section/PlayerMessageDTO: + get: + tags: + - Section + operationId: Section_PlayerMessageDTO + responses: + '200': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/PlayerMessageDTO' + security: + - bearer: [] /api/User: get: tags: @@ -1298,6 +1312,9 @@ components: id: type: string nullable: true + identifier: + type: string + nullable: true name: type: string nullable: true @@ -1318,6 +1335,9 @@ components: dateCreation: type: string format: date-time + dateUpdate: + type: string + format: date-time DeviceDetailDTO: allOf: - $ref: '#/components/schemas/DeviceDTO' @@ -1460,7 +1480,7 @@ components: type: integer format: int32 mapType: - $ref: '#/components/schemas/MapType' + $ref: '#/components/schemas/MapTypeApp' points: type: array nullable: true @@ -1472,7 +1492,7 @@ components: iconSource: type: string nullable: true - MapType: + MapTypeApp: type: string description: '' x-enumNames: @@ -1580,6 +1600,14 @@ components: nullable: true items: $ref: '#/components/schemas/SectionDTO' + PlayerMessageDTO: + type: object + additionalProperties: false + properties: + configChanged: + type: boolean + isDeleted: + type: boolean User: type: object additionalProperties: false diff --git a/manager_api/test/map_type_app_test.dart b/manager_api/test/map_type_app_test.dart new file mode 100644 index 0000000..4145313 --- /dev/null +++ b/manager_api/test/map_type_app_test.dart @@ -0,0 +1,20 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// +// @dart=2.0 + +// ignore_for_file: unused_element, unused_import +// ignore_for_file: always_put_required_named_parameters_first +// ignore_for_file: lines_longer_than_80_chars + +import 'package:managerapi/api.dart'; +import 'package:test/test.dart'; + +// tests for MapTypeApp +void main() { + + group('test MapTypeApp', () { + + }); + +} diff --git a/manager_api/test/player_message_dto_test.dart b/manager_api/test/player_message_dto_test.dart new file mode 100644 index 0000000..c5d631c --- /dev/null +++ b/manager_api/test/player_message_dto_test.dart @@ -0,0 +1,31 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// +// @dart=2.0 + +// ignore_for_file: unused_element, unused_import +// ignore_for_file: always_put_required_named_parameters_first +// ignore_for_file: lines_longer_than_80_chars + +import 'package:managerapi/api.dart'; +import 'package:test/test.dart'; + +// tests for PlayerMessageDTO +void main() { + final instance = PlayerMessageDTO(); + + group('test PlayerMessageDTO', () { + // bool configChanged + test('to test the property `configChanged`', () async { + // TODO + }); + + // bool isDeleted + test('to test the property `isDeleted`', () async { + // TODO + }); + + + }); + +}