From 09c8cc7cfdf3e60fdc7e0eda29fc368021efa951 Mon Sep 17 00:00:00 2001 From: Thomas Fransolet Date: Wed, 24 Jan 2024 17:08:06 +0100 Subject: [PATCH] Added JsonUrl (to test) --- lib/Components/fetch_resource_icon.dart | 2 + .../upload_online_resources_container.dart | 4 +- .../SubSection/Agenda/agenda_config.dart | 2 +- lib/Screens/Main/components/body.dart | 3 +- .../Resources/get_element_for_resource.dart | 3 ++ lib/api/openApiTest.dart | 12 ++++++ lib/api/swagger.yaml | 16 +++++++- lib/constants.dart | 3 +- manager_api_new/doc/ConfigurationDTO.md | 3 ++ manager_api_new/doc/ExportConfigurationDTO.md | 3 ++ .../lib/model/configuration_dto.dart | 41 ++++++++++++++++++- .../lib/model/export_configuration_dto.dart | 41 ++++++++++++++++++- manager_api_new/lib/model/resource_type.dart | 8 +++- 13 files changed, 131 insertions(+), 10 deletions(-) diff --git a/lib/Components/fetch_resource_icon.dart b/lib/Components/fetch_resource_icon.dart index f805de1..e2035fc 100644 --- a/lib/Components/fetch_resource_icon.dart +++ b/lib/Components/fetch_resource_icon.dart @@ -17,6 +17,8 @@ IconData getResourceIcon(elementType) { return Icons.picture_as_pdf_outlined; case ResourceType.Json: return Icons.file_present_outlined; + case ResourceType.JsonUrl: + return Icons.file_present_rounded; } return Icons.announcement; } \ No newline at end of file diff --git a/lib/Components/upload_online_resources_container.dart b/lib/Components/upload_online_resources_container.dart index 698f724..39eef8a 100644 --- a/lib/Components/upload_online_resources_container.dart +++ b/lib/Components/upload_online_resources_container.dart @@ -105,12 +105,12 @@ class _UploadOnlineResourceContainerState extends State { return ResourceInputContainer( label: "Fichier JSON :", initialValue: agendaDTO.resourceId == null ? '': agendaDTO.resourceId, - inResourceTypes: [ResourceType.Json], + inResourceTypes: [ResourceType.Json, ResourceType.JsonUrl], onChanged: (ResourceDTO resourceDTO) { agendaDTO.resourceUrl = resourceDTO.url; agendaDTO.resourceId = resourceDTO.id; diff --git a/lib/Screens/Main/components/body.dart b/lib/Screens/Main/components/body.dart index caca357..4f0e6cb 100644 --- a/lib/Screens/Main/components/body.dart +++ b/lib/Screens/Main/components/body.dart @@ -221,7 +221,8 @@ class _BodyState extends State { ResourceType.Video, ResourceType.VideoUrl, ResourceType.Pdf, - ResourceType.Json + ResourceType.Json, + ResourceType.JsonUrl ] ) ); diff --git a/lib/Screens/Resources/get_element_for_resource.dart b/lib/Screens/Resources/get_element_for_resource.dart index a8fff6b..46aed19 100644 --- a/lib/Screens/Resources/get_element_for_resource.dart +++ b/lib/Screens/Resources/get_element_for_resource.dart @@ -101,6 +101,9 @@ getElementForResource(dynamic resourceDTO, AppContext appContext) { case ResourceType.Json: return Text("Fichier json - aucune visualisation possible"); + + case ResourceType.JsonUrl: + return SelectableText(resourceDTO.url!); } } diff --git a/lib/api/openApiTest.dart b/lib/api/openApiTest.dart index 1e1b816..055e815 100644 --- a/lib/api/openApiTest.dart +++ b/lib/api/openApiTest.dart @@ -9,6 +9,18 @@ import 'package:openapi_generator_annotations/openapi_generator_annotations.dart outputDirectory: 'manager_api_new') class Example extends OpenapiGeneratorConfig {} + +/*@Openapi( + additionalProperties: + DioProperties(pubName: 'manager_api_new', pubAuthor: 'Fransolet Thomas'), + inputSpec: + InputSpec(path: 'lib/api/swagger.yaml'), + generatorName: Generator.dart, + runSourceGenOnOutput: true, + outputDirectory: 'manager_api_new', +) +class Example {}*/ + /* RUN >flutter pub run build_runner build --delete-conflicting-outputs diff --git a/lib/api/swagger.yaml b/lib/api/swagger.yaml index f8d3bde..b88b613 100644 --- a/lib/api/swagger.yaml +++ b/lib/api/swagger.yaml @@ -1814,6 +1814,15 @@ components: weatherCity: type: string nullable: true + weatherUpdatedDate: + type: string + format: date-time + nullable: true + weatherResult: + type: string + nullable: true + isWeather: + type: boolean isDate: type: boolean isHour: @@ -1975,6 +1984,7 @@ components: 4 = Audio 5 = PDF 6 = JSON + 7 = JSONUrl x-enumNames: - Image - Video @@ -1983,6 +1993,7 @@ components: - Audio - PDF - JSON + - JSONUrl enum: - 0 - 1 @@ -1991,6 +2002,7 @@ components: - 4 - 5 - 6 + - 7 DeviceDTO: type: object additionalProperties: false @@ -2322,7 +2334,9 @@ components: type: string nullable: true resourceType: - $ref: '#/components/schemas/ResourceType' + nullable: true + oneOf: + - $ref: '#/components/schemas/ResourceType' resourceUrl: type: string nullable: true diff --git a/lib/constants.dart b/lib/constants.dart index 2bdb036..7f5467e 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -26,7 +26,8 @@ List resource_types = [ ResourceTypeModel(label: "Vidéo url", type: ResourceType.VideoUrl), ResourceTypeModel(label: "Audio", type: ResourceType.Audio), ResourceTypeModel(label: "PDF", type: ResourceType.Pdf), - ResourceTypeModel(label: "JSON", type: ResourceType.Json) + ResourceTypeModel(label: "JSON", type: ResourceType.Json), + ResourceTypeModel(label: "JSON url", type: ResourceType.JsonUrl) ]; // "video url" , "video", {"label": "image"}, "image url", "audio" /* diff --git a/manager_api_new/doc/ConfigurationDTO.md b/manager_api_new/doc/ConfigurationDTO.md index 1399473..7aeb23e 100644 --- a/manager_api_new/doc/ConfigurationDTO.md +++ b/manager_api_new/doc/ConfigurationDTO.md @@ -25,6 +25,9 @@ Name | Type | Description | Notes **loaderImageId** | **String** | | [optional] **loaderImageUrl** | **String** | | [optional] **weatherCity** | **String** | | [optional] +**weatherUpdatedDate** | [**DateTime**](DateTime.md) | | [optional] +**weatherResult** | **String** | | [optional] +**isWeather** | **bool** | | [optional] **isDate** | **bool** | | [optional] **isHour** | **bool** | | [optional] diff --git a/manager_api_new/doc/ExportConfigurationDTO.md b/manager_api_new/doc/ExportConfigurationDTO.md index ecfd8cf..d71c385 100644 --- a/manager_api_new/doc/ExportConfigurationDTO.md +++ b/manager_api_new/doc/ExportConfigurationDTO.md @@ -25,6 +25,9 @@ Name | Type | Description | Notes **loaderImageId** | **String** | | [optional] **loaderImageUrl** | **String** | | [optional] **weatherCity** | **String** | | [optional] +**weatherUpdatedDate** | [**DateTime**](DateTime.md) | | [optional] +**weatherResult** | **String** | | [optional] +**isWeather** | **bool** | | [optional] **isDate** | **bool** | | [optional] **isHour** | **bool** | | [optional] **sections** | [**List**](SectionDTO.md) | | [optional] [default to const []] diff --git a/manager_api_new/lib/model/configuration_dto.dart b/manager_api_new/lib/model/configuration_dto.dart index 074ab24..810ef02 100644 --- a/manager_api_new/lib/model/configuration_dto.dart +++ b/manager_api_new/lib/model/configuration_dto.dart @@ -30,6 +30,9 @@ class ConfigurationDTO { this.loaderImageId, this.loaderImageUrl, this.weatherCity, + this.weatherUpdatedDate, + this.weatherResult, + this.isWeather, this.isDate, this.isHour, }); @@ -92,6 +95,18 @@ class ConfigurationDTO { String? weatherCity; + DateTime? weatherUpdatedDate; + + String? weatherResult; + + /// + /// Please note: This property should have been non-nullable! Since the specification file + /// does not include a default value (using the "default:" property), however, the generated + /// source code must fall back to having a nullable type. + /// Consider adding a "default:" property in the specification file to hide this note. + /// + bool? isWeather; + /// /// Please note: This property should have been non-nullable! Since the specification file /// does not include a default value (using the "default:" property), however, the generated @@ -127,6 +142,9 @@ class ConfigurationDTO { other.loaderImageId == loaderImageId && other.loaderImageUrl == loaderImageUrl && other.weatherCity == weatherCity && + other.weatherUpdatedDate == weatherUpdatedDate && + other.weatherResult == weatherResult && + other.isWeather == isWeather && other.isDate == isDate && other.isHour == isHour; @@ -150,11 +168,14 @@ class ConfigurationDTO { (loaderImageId == null ? 0 : loaderImageId!.hashCode) + (loaderImageUrl == null ? 0 : loaderImageUrl!.hashCode) + (weatherCity == null ? 0 : weatherCity!.hashCode) + + (weatherUpdatedDate == null ? 0 : weatherUpdatedDate!.hashCode) + + (weatherResult == null ? 0 : weatherResult!.hashCode) + + (isWeather == null ? 0 : isWeather!.hashCode) + (isDate == null ? 0 : isDate!.hashCode) + (isHour == null ? 0 : isHour!.hashCode); @override - String toString() => 'ConfigurationDTO[id=$id, label=$label, title=$title, imageId=$imageId, imageSource=$imageSource, primaryColor=$primaryColor, secondaryColor=$secondaryColor, languages=$languages, dateCreation=$dateCreation, isMobile=$isMobile, isTablet=$isTablet, isOffline=$isOffline, instanceId=$instanceId, sectionIds=$sectionIds, loaderImageId=$loaderImageId, loaderImageUrl=$loaderImageUrl, weatherCity=$weatherCity, isDate=$isDate, isHour=$isHour]'; + String toString() => 'ConfigurationDTO[id=$id, label=$label, title=$title, imageId=$imageId, imageSource=$imageSource, primaryColor=$primaryColor, secondaryColor=$secondaryColor, languages=$languages, dateCreation=$dateCreation, isMobile=$isMobile, isTablet=$isTablet, isOffline=$isOffline, instanceId=$instanceId, sectionIds=$sectionIds, loaderImageId=$loaderImageId, loaderImageUrl=$loaderImageUrl, weatherCity=$weatherCity, weatherUpdatedDate=$weatherUpdatedDate, weatherResult=$weatherResult, isWeather=$isWeather, isDate=$isDate, isHour=$isHour]'; Map toJson() { final json = {}; @@ -243,6 +264,21 @@ class ConfigurationDTO { } else { json[r'weatherCity'] = null; } + if (this.weatherUpdatedDate != null) { + json[r'weatherUpdatedDate'] = this.weatherUpdatedDate!.toUtc().toIso8601String(); + } else { + json[r'weatherUpdatedDate'] = null; + } + if (this.weatherResult != null) { + json[r'weatherResult'] = this.weatherResult; + } else { + json[r'weatherResult'] = null; + } + if (this.isWeather != null) { + json[r'isWeather'] = this.isWeather; + } else { + json[r'isWeather'] = null; + } if (this.isDate != null) { json[r'isDate'] = this.isDate; } else { @@ -296,6 +332,9 @@ class ConfigurationDTO { loaderImageId: mapValueOfType(json, r'loaderImageId'), loaderImageUrl: mapValueOfType(json, r'loaderImageUrl'), weatherCity: mapValueOfType(json, r'weatherCity'), + weatherUpdatedDate: mapDateTime(json, r'weatherUpdatedDate', ''), + weatherResult: mapValueOfType(json, r'weatherResult'), + isWeather: mapValueOfType(json, r'isWeather'), isDate: mapValueOfType(json, r'isDate'), isHour: mapValueOfType(json, r'isHour'), ); diff --git a/manager_api_new/lib/model/export_configuration_dto.dart b/manager_api_new/lib/model/export_configuration_dto.dart index 4efa6a3..34ffbc1 100644 --- a/manager_api_new/lib/model/export_configuration_dto.dart +++ b/manager_api_new/lib/model/export_configuration_dto.dart @@ -30,6 +30,9 @@ class ExportConfigurationDTO { this.loaderImageId, this.loaderImageUrl, this.weatherCity, + this.weatherUpdatedDate, + this.weatherResult, + this.isWeather, this.isDate, this.isHour, this.sections = const [], @@ -94,6 +97,18 @@ class ExportConfigurationDTO { String? weatherCity; + DateTime? weatherUpdatedDate; + + String? weatherResult; + + /// + /// Please note: This property should have been non-nullable! Since the specification file + /// does not include a default value (using the "default:" property), however, the generated + /// source code must fall back to having a nullable type. + /// Consider adding a "default:" property in the specification file to hide this note. + /// + bool? isWeather; + /// /// Please note: This property should have been non-nullable! Since the specification file /// does not include a default value (using the "default:" property), however, the generated @@ -133,6 +148,9 @@ class ExportConfigurationDTO { other.loaderImageId == loaderImageId && other.loaderImageUrl == loaderImageUrl && other.weatherCity == weatherCity && + other.weatherUpdatedDate == weatherUpdatedDate && + other.weatherResult == weatherResult && + other.isWeather == isWeather && other.isDate == isDate && other.isHour == isHour && other.sections == sections && @@ -158,13 +176,16 @@ class ExportConfigurationDTO { (loaderImageId == null ? 0 : loaderImageId!.hashCode) + (loaderImageUrl == null ? 0 : loaderImageUrl!.hashCode) + (weatherCity == null ? 0 : weatherCity!.hashCode) + + (weatherUpdatedDate == null ? 0 : weatherUpdatedDate!.hashCode) + + (weatherResult == null ? 0 : weatherResult!.hashCode) + + (isWeather == null ? 0 : isWeather!.hashCode) + (isDate == null ? 0 : isDate!.hashCode) + (isHour == null ? 0 : isHour!.hashCode) + (sections == null ? 0 : sections!.hashCode) + (resources == null ? 0 : resources!.hashCode); @override - String toString() => 'ExportConfigurationDTO[id=$id, label=$label, title=$title, imageId=$imageId, imageSource=$imageSource, primaryColor=$primaryColor, secondaryColor=$secondaryColor, languages=$languages, dateCreation=$dateCreation, isMobile=$isMobile, isTablet=$isTablet, isOffline=$isOffline, instanceId=$instanceId, sectionIds=$sectionIds, loaderImageId=$loaderImageId, loaderImageUrl=$loaderImageUrl, weatherCity=$weatherCity, isDate=$isDate, isHour=$isHour, sections=$sections, resources=$resources]'; + String toString() => 'ExportConfigurationDTO[id=$id, label=$label, title=$title, imageId=$imageId, imageSource=$imageSource, primaryColor=$primaryColor, secondaryColor=$secondaryColor, languages=$languages, dateCreation=$dateCreation, isMobile=$isMobile, isTablet=$isTablet, isOffline=$isOffline, instanceId=$instanceId, sectionIds=$sectionIds, loaderImageId=$loaderImageId, loaderImageUrl=$loaderImageUrl, weatherCity=$weatherCity, weatherUpdatedDate=$weatherUpdatedDate, weatherResult=$weatherResult, isWeather=$isWeather, isDate=$isDate, isHour=$isHour, sections=$sections, resources=$resources]'; Map toJson() { final json = {}; @@ -253,6 +274,21 @@ class ExportConfigurationDTO { } else { json[r'weatherCity'] = null; } + if (this.weatherUpdatedDate != null) { + json[r'weatherUpdatedDate'] = this.weatherUpdatedDate!.toUtc().toIso8601String(); + } else { + json[r'weatherUpdatedDate'] = null; + } + if (this.weatherResult != null) { + json[r'weatherResult'] = this.weatherResult; + } else { + json[r'weatherResult'] = null; + } + if (this.isWeather != null) { + json[r'isWeather'] = this.isWeather; + } else { + json[r'isWeather'] = null; + } if (this.isDate != null) { json[r'isDate'] = this.isDate; } else { @@ -316,6 +352,9 @@ class ExportConfigurationDTO { loaderImageId: mapValueOfType(json, r'loaderImageId'), loaderImageUrl: mapValueOfType(json, r'loaderImageUrl'), weatherCity: mapValueOfType(json, r'weatherCity'), + weatherUpdatedDate: mapDateTime(json, r'weatherUpdatedDate', ''), + weatherResult: mapValueOfType(json, r'weatherResult'), + isWeather: mapValueOfType(json, r'isWeather'), isDate: mapValueOfType(json, r'isDate'), isHour: mapValueOfType(json, r'isHour'), sections: SectionDTO.listFromJson(json[r'sections']), diff --git a/manager_api_new/lib/model/resource_type.dart b/manager_api_new/lib/model/resource_type.dart index 8cc1f79..cfde41e 100644 --- a/manager_api_new/lib/model/resource_type.dart +++ b/manager_api_new/lib/model/resource_type.dart @@ -10,7 +10,7 @@ part of openapi.api; -/// 0 = Image 1 = Video 2 = ImageUrl 3 = VideoUrl 4 = Audio 5 = PDF 6 = JSON +/// 0 = Image 1 = Video 2 = ImageUrl 3 = VideoUrl 4 = Audio 5 = PDF 6 = JSON 7 = JSONUrl class ResourceType { /// Instantiate a new enum with the provided [value]. const ResourceType._(this.value); @@ -30,6 +30,7 @@ class ResourceType { static const Audio = ResourceType._(4); static const Pdf = ResourceType._(5); static const Json = ResourceType._(6); + static const JsonUrl = ResourceType._(7); /// List of all possible values in this [enum][ResourceType]. static const values = [ @@ -39,7 +40,8 @@ class ResourceType { VideoUrl, Audio, Pdf, - Json + Json, + JsonUrl ]; static ResourceType? fromJson(dynamic value) => ResourceTypeTypeTransformer().decode(value); @@ -86,6 +88,7 @@ class ResourceTypeTypeTransformer { case "Audio": return ResourceType.Audio; case "PDF": return ResourceType.Pdf; case "JSON": return ResourceType.Json; + case "JSONUrl": return ResourceType.JsonUrl; default: if (!allowNull) { throw ArgumentError('Unknown enum value to decode: $data'); @@ -101,6 +104,7 @@ class ResourceTypeTypeTransformer { case 4: return ResourceType.Audio; case 5: return ResourceType.Pdf; case 6: return ResourceType.Json; + case 7: return ResourceType.JsonUrl; default: if (!allowNull) { throw ArgumentError('Unknown enum value to decode: $data');