diff --git a/android/app/build.gradle b/android/app/build.gradle index 4a7c544..2896c0e 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -33,7 +33,6 @@ android { } defaultConfig { - // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "be.mdlf.manager_app" minSdkVersion 16 targetSdkVersion 30 diff --git a/lib/Components/fetch_resource_icon.dart b/lib/Components/fetch_resource_icon.dart new file mode 100644 index 0000000..10722e4 --- /dev/null +++ b/lib/Components/fetch_resource_icon.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; +import 'package:managerapi/api.dart'; + +IconData getResourceIcon(elementType) { + print(elementType); + switch(elementType) { + case ResourceType.image: + return Icons.image; + break; + case ResourceType.imageUrl: + return Icons.image_search; // art_track + break; + case ResourceType.video: + return Icons.slow_motion_video; + break; + case ResourceType.videoUrl: + return Icons.ondemand_video_sharp; + break; + } + return Icons.announcement; +} \ No newline at end of file diff --git a/lib/Components/vlc_viewer.dart b/lib/Components/vlc_viewer.dart new file mode 100644 index 0000000..bda1337 --- /dev/null +++ b/lib/Components/vlc_viewer.dart @@ -0,0 +1,739 @@ +import 'dart:io'; +import 'dart:convert'; +import 'package:flutter/material.dart'; +import 'package:dart_vlc/dart_vlc.dart'; + +class DartVLC extends StatefulWidget { + final Media file; + const DartVLC({ + Key key, + this.file, + }) : super(key: key); + + @override + _DartVLCState createState() => _DartVLCState(); +} + +class _DartVLCState extends State { + Player player = Player( + id: 0, + videoWidth: 480, + videoHeight: 360, + ); + MediaType mediaType = MediaType.file; + CurrentState current = new CurrentState(); + PositionState position = new PositionState(); + PlaybackState playback = new PlaybackState(); + GeneralState general = new GeneralState(); + List medias = []; + List devices = []; + TextEditingController controller = new TextEditingController(); + TextEditingController metasController = new TextEditingController(); + Media metasMedia; + + @override + void initState() { + super.initState(); + if (this.mounted) { + this.medias.add(widget.file); + + this.player.open( + new Playlist( + medias: this.medias, + playlistMode: + PlaylistMode.loop), + ); + + /*this.player.currentStream.listen((current) { + this.setState(() => this.current = current); + }); + this.player.positionStream.listen((position) { + this.setState(() => this.position = position); + }); + this.player.playbackStream.listen((playback) { + this.setState(() => this.playback = playback); + }); + this.player.generateStream.listen((general) { + this.setState(() => this.general = general); + });*/ + } + } + + @override + Future didChangeDependencies() async { + super.didChangeDependencies(); + //this.devices = await Devices.all; + this.setState(() {}); + } + + @override + Widget build(BuildContext context) { + return Video( + playerId: 0, + width: 640, + height: 480, + volumeThumbColor: Colors.blue, + volumeActiveColor: Colors.blue, + ); + + /*Scaffold( + body: ListView( + shrinkWrap: true, + padding: EdgeInsets.all(4.0), + children: [ + Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Card( + clipBehavior: Clip.antiAlias, + elevation: 2.0, + child: Video( + playerId: 0, + width: 640, + height: 480, + volumeThumbColor: Colors.blue, + volumeActiveColor: Colors.blue, + ), + ), + ], + ), + Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.all(10.0), + child: Container( + margin: EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Playlist creation.'), + Divider( + height: 8.0, + color: Colors.transparent, + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + child: TextField( + controller: this.controller, + cursorWidth: 1.0, + autofocus: true, + style: TextStyle( + fontSize: 14.0, + ), + decoration: InputDecoration.collapsed( + hintStyle: TextStyle( + fontSize: 14.0, + ), + hintText: + 'Media resource location.', + ), + ), + ), + Container( + width: 152.0, + child: DropdownButton( + value: this.mediaType, + onChanged: (mediaType) => this + .setState(() => + this.mediaType = mediaType), + items: [ + DropdownMenuItem( + value: MediaType.file, + child: Text( + MediaType.file.toString(), + style: TextStyle( + fontSize: 14.0, + ), + ), + ), + DropdownMenuItem( + value: MediaType.network, + child: Text( + MediaType.network.toString(), + style: TextStyle( + fontSize: 14.0, + ), + ), + ), + DropdownMenuItem( + value: MediaType.asset, + child: Text( + MediaType.asset.toString(), + style: TextStyle( + fontSize: 14.0, + ), + ), + ), + ], + ), + ), + Padding( + padding: EdgeInsets.only(left: 10.0), + child: ElevatedButton( + onPressed: () async { + if (this.mediaType == + MediaType.file) { + this.medias.add( + await Media.file(new File( + controller.text)), + ); + } else if (this.mediaType == + MediaType.network) { + this.medias.add( + await Media.network( + controller.text), + ); + } else if (this.mediaType == + MediaType.asset) { + this.medias.add( + await Media.asset( + controller.text), + ); + } + this.setState(() {}); + }, + child: Text( + 'Add', + style: TextStyle( + fontSize: 14.0, + ), + ), + ), + ), + ], + ), + Divider( + height: 12.0, + ), + Divider( + height: 8.0, + color: Colors.transparent, + ), + Text('Playlist'), + ] + + this + .medias + .map( + (media) => ListTile( + title: Text( + media.resource, + style: TextStyle( + fontSize: 14.0, + ), + ), + subtitle: Text( + media.mediaType.toString(), + style: TextStyle( + fontSize: 14.0, + ), + ), + ), + ) + .toList() + + [ + Divider( + height: 8.0, + color: Colors.transparent, + ), + Row( + children: [ + ElevatedButton( + onPressed: () => this.setState(() { + this.player.open( + new Playlist( + medias: this.medias, + playlistMode: + PlaylistMode.loop), + ); + }), + child: Text( + 'Open', + style: TextStyle( + fontSize: 14.0, + ), + ), + ), + SizedBox(width: 12.0), + ElevatedButton( + onPressed: () => this.setState(() { + this.medias.clear(); + }), + child: Text( + 'Clear', + style: TextStyle( + fontSize: 14.0, + ), + ), + ), + ], + ), + ], + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.all(4.0), + child: Container( + margin: EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Playback event listeners.'), + Divider( + height: 12.0, + color: Colors.transparent, + ), + Divider( + height: 12.0, + ), + Text('Playback position.'), + Divider( + height: 8.0, + color: Colors.transparent, + ), + Slider( + min: 0, + max: this + .position + .duration + .inMilliseconds + .toDouble(), + value: this + .position + .position + .inMilliseconds + .toDouble(), + onChanged: (double position) { + this.player.seek( + Duration( + milliseconds: position.toInt()), + ); + }, + ), + Text('Event streams.'), + Divider( + height: 8.0, + color: Colors.transparent, + ), + Table( + children: [ + TableRow(children: [ + Text('player.general.volume'), + Text('${this.general.volume}') + ]), + TableRow(children: [ + Text('player.general.rate'), + Text('${this.general.rate}') + ]), + TableRow(children: [ + Text('player.position.position'), + Text('${this.position.position}') + ]), + TableRow(children: [ + Text('player.position.duration'), + Text('${this.position.duration}') + ]), + TableRow(children: [ + Text('player.playback.isCompleted'), + Text('${this.playback.isCompleted}') + ]), + TableRow(children: [ + Text('player.playback.isPlaying'), + Text('${this.playback.isPlaying}') + ]), + TableRow(children: [ + Text('player.playback.isSeekable'), + Text('${this.playback.isSeekable}') + ]), + TableRow(children: [ + Text('player.current.index'), + Text('${this.current.index}') + ]), + TableRow(children: [ + Text('player.current.media'), + Text('${this.current.media}') + ]), + TableRow(children: [ + Text('player.current.medias'), + Text('${this.current.medias}') + ]), + ], + ), + ], + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.all(4.0), + child: Container( + margin: EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Playback devices.'), + Divider( + height: 12.0, + color: Colors.transparent, + ), + Divider( + height: 12.0, + ), + ] + + this + .devices + .map( + (device) => new ListTile( + title: Text( + device.name, + style: TextStyle( + fontSize: 14.0, + ), + ), + subtitle: Text( + device.id, + style: TextStyle( + fontSize: 14.0, + ), + ), + onTap: () => + this.player.setDevice(device), + ), + ) + .toList(), + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.all(4.0), + child: Container( + margin: EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Metas parsing.'), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + child: TextField( + controller: this.metasController, + cursorWidth: 1.0, + autofocus: true, + style: TextStyle( + fontSize: 14.0, + ), + decoration: InputDecoration.collapsed( + hintStyle: TextStyle( + fontSize: 14.0, + ), + hintText: 'Media resource location.', + ), + ), + ), + Container( + width: 152.0, + child: DropdownButton( + value: this.mediaType, + onChanged: (mediaType) => this.setState( + () => this.mediaType = mediaType), + items: [ + DropdownMenuItem( + value: MediaType.file, + child: Text( + MediaType.file.toString(), + style: TextStyle( + fontSize: 14.0, + ), + ), + ), + DropdownMenuItem( + value: MediaType.network, + child: Text( + MediaType.network.toString(), + style: TextStyle( + fontSize: 14.0, + ), + ), + ), + DropdownMenuItem( + value: MediaType.asset, + child: Text( + MediaType.asset.toString(), + style: TextStyle( + fontSize: 14.0, + ), + ), + ), + ], + ), + ), + Padding( + padding: EdgeInsets.only(left: 16.0), + child: ElevatedButton( + onPressed: () async { + if (this.mediaType == MediaType.file) { + this.metasMedia = await Media.file( + new File( + this.metasController.text), + parse: true); + } else if (this.mediaType == + MediaType.network) { + this.metasMedia = await Media.network( + this.metasController.text, + parse: true); + } else if (this.mediaType == + MediaType.asset) { + this.metasMedia = await Media.asset( + this.metasController.text, + parse: true); + } + this.setState(() {}); + }, + child: Text( + 'Parse', + style: TextStyle( + fontSize: 14.0, + ), + ), + ), + ), + ], + ), + Divider( + height: 12.0, + ), + Divider( + height: 8.0, + color: Colors.transparent, + ), + Text( + JsonEncoder.withIndent(' ') + .convert(this.metasMedia?.metas), + ), + ], + ), + ), + ), + ], + ), + ), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Card( + elevation: 2.0, + margin: EdgeInsets.all(4.0), + child: Container( + margin: EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Playback controls.'), + Divider( + height: 8.0, + color: Colors.transparent, + ), + Row( + children: [ + ElevatedButton( + onPressed: () => this.player.play(), + child: Text( + 'play', + style: TextStyle( + fontSize: 14.0, + ), + ), + ), + SizedBox(width: 12.0), + ElevatedButton( + onPressed: () => this.player.pause(), + child: Text( + 'pause', + style: TextStyle( + fontSize: 14.0, + ), + ), + ), + SizedBox(width: 12.0), + ElevatedButton( + onPressed: () => this.player.playOrPause(), + child: Text( + 'playOrPause', + style: TextStyle( + fontSize: 14.0, + ), + ), + ), + SizedBox(width: 12.0), + ElevatedButton( + onPressed: () => this.player.stop(), + child: Text( + 'stop', + style: TextStyle( + fontSize: 14.0, + ), + ), + ), + SizedBox(width: 12.0), + ElevatedButton( + onPressed: () => this.player.next(), + child: Text( + 'next', + style: TextStyle( + fontSize: 14.0, + ), + ), + ), + SizedBox(width: 12.0), + ElevatedButton( + onPressed: () => this.player.back(), + child: Text( + 'back', + style: TextStyle( + fontSize: 14.0, + ), + ), + ), + ], + ), + Divider( + height: 12.0, + color: Colors.transparent, + ), + Divider( + height: 12.0, + ), + Text('Volume control.'), + Divider( + height: 8.0, + color: Colors.transparent, + ), + Slider( + min: 0.0, + max: 1.0, + value: this.player.general.volume ?? 0.5, + onChanged: (volume) { + this.player.setVolume(volume); + this.setState(() {}); + }, + ), + Text('Playback rate control.'), + Divider( + height: 8.0, + color: Colors.transparent, + ), + Slider( + min: 0.5, + max: 1.5, + value: this.player.general.rate ?? 0.5, + onChanged: (rate) { + this.player.setRate(rate); + this.setState(() {}); + }, + ), + ], + ), + ), + ), + Card( + elevation: 2.0, + margin: EdgeInsets.all(4.0), + child: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only(left: 16.0, top: 16.0), + alignment: Alignment.topLeft, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Playlist manipulation.'), + Divider( + height: 12.0, + color: Colors.transparent, + ), + Divider( + height: 12.0, + ), + ], + ), + ), + Container( + height: 456.0, + child: ReorderableListView( + shrinkWrap: true, + onReorder: + (int initialIndex, int finalIndex) async { + /// 🙏🙏🙏 + /// https://github.com/flutter/flutter/issues/24786 + /// https://stackoverflow.com/a/54164333/12825435 + if (finalIndex > this.current.medias.length) + finalIndex = this.current.medias.length; + if (initialIndex < finalIndex) finalIndex--; + + await this + .player + .move(initialIndex, finalIndex); + this.setState(() {}); + }, + scrollDirection: Axis.vertical, + padding: + const EdgeInsets.symmetric(vertical: 8.0), + children: List.generate( + this.current.medias.length, + (int index) => new ListTile( + key: Key(index.toString()), + leading: Text( + index.toString(), + style: TextStyle(fontSize: 14.0), + ), + title: Text( + this.current.medias[index].resource, + style: TextStyle(fontSize: 14.0), + ), + subtitle: Text( + this + .current + .medias[index] + .mediaType + .toString(), + style: TextStyle(fontSize: 14.0), + ), + ), + growable: true, + ), + ), + ), + ], + ), + ), + ), + ], + ), + ), + ], + ) + ], + ), + );*/ + } +} \ No newline at end of file diff --git a/lib/Screens/Resources/new_resource_popup.dart b/lib/Screens/Resources/new_resource_popup.dart new file mode 100644 index 0000000..085c505 --- /dev/null +++ b/lib/Screens/Resources/new_resource_popup.dart @@ -0,0 +1,137 @@ +import 'dart:io'; + +import 'package:manager_app/Screens/Resources/upload_image.dart'; +import 'package:flutter/material.dart'; +import 'package:manager_app/Components/message_notification.dart'; +import 'package:manager_app/Components/rounded_button.dart'; +import 'package:manager_app/Components/string_input_container.dart'; +import 'package:manager_app/Models/managerContext.dart'; +import 'package:manager_app/app_context.dart'; +import 'package:manager_app/constants.dart'; +import 'package:managerapi/api.dart'; + +import 'package:http/http.dart' as http; + +void showNewResource(AppContext appContext, BuildContext context) { + ResourceDetailDTO resourceDetailDTO = new ResourceDetailDTO(); + var fileName; + File fileToSend; + showDialog( + builder: (BuildContext context) => AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(20.0)) + ), + content: Container( + width: 400, + child: SingleChildScrollView( + child: Column( + children: [ + Text("Nouvelle ressource", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)), + Column( + children: [ + StringContainer( + label: "Nom :", + initialValue: resourceDetailDTO.label, + onChanged: (value) { + resourceDetailDTO.label = value; + }, + ), + if (fileName != null) new Text(fileName), + ], + ), + UploadImageContainer( + onChanged: (File file) { + print("ONCHANGED image"); + print(file.path); + fileToSend = file; + resourceDetailDTO.type = ResourceType.image; + } + ), + ], + ), + ), + ), + actions: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Align( + alignment: AlignmentDirectional.bottomEnd, + child: Container( + width: 175, + height: 70, + child: RoundedButton( + text: "Annuler", + icon: Icons.undo, + color: kSecond, + press: () { + Navigator.of(context).pop(); + }, + fontSize: 20, + ), + ), + ), + Align( + alignment: AlignmentDirectional.bottomEnd, + child: Container( + width: 150, + height: 70, + child: RoundedButton( + text: "Créer", + icon: Icons.check, + color: kPrimaryColor, + textColor: kWhite, + press: () { + create(resourceDetailDTO, fileToSend, appContext, context); + }, + fontSize: 20, + ), + ), + ), + ], + ), + ], + ), context: context + ); +} + +void create(ResourceDetailDTO resourceDetailDTO, File file, AppContext appContext, context) async { + if (resourceDetailDTO.label != null) { + Navigator.of(context).pop(); + + print(resourceDetailDTO.type); + if(resourceDetailDTO.type == ResourceType.image || resourceDetailDTO.type == ResourceType.video) { + var request = http.MultipartRequest('POST', Uri.parse(appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/upload")); + request.files.add( + await http.MultipartFile( + 'picture', + file.readAsBytes().asStream(), + file.lengthSync(), + filename: file.path.toString().split("/").last + ) + ); + + // Todo Add header with bearer token (get via managercontext - token value) + //request.headers.addEntries(newEntries) + + request.fields['label'] = resourceDetailDTO.label; + request.fields['type'] = ResourceType.image.toString(); + + var res = await request.send(); + + print("RESULT"); + print(res.statusCode); + // TODO add message if status code not ok + + } else { + ResourceDetailDTO newResource = await appContext.getContext().clientAPI.resourceApi.resourceCreate(resourceDetailDTO); + } + + // To refresh only (UGLY COOOOODE) + ManagerAppContext managerAppContext = appContext.getContext(); + appContext.setContext(managerAppContext); + + showNotification(Colors.green, kWhite, 'La ressource a été créée avec succès', context); + } +} + diff --git a/lib/Screens/Resources/new_ressource_popup.dart b/lib/Screens/Resources/new_ressource_popup.dart deleted file mode 100644 index f488d2d..0000000 --- a/lib/Screens/Resources/new_ressource_popup.dart +++ /dev/null @@ -1,124 +0,0 @@ -import 'package:file_picker/file_picker.dart'; -import 'package:filepicker_windows/filepicker_windows.dart'; -import 'package:flutter/material.dart'; -import 'package:manager_app/Components/message_notification.dart'; -import 'package:manager_app/Components/rounded_button.dart'; -import 'package:manager_app/Components/string_input_container.dart'; -import 'package:manager_app/Models/managerContext.dart'; -import 'package:manager_app/app_context.dart'; -import 'package:manager_app/constants.dart'; -import 'package:managerapi/api.dart'; - -void showNewRessource(AppContext appContext, BuildContext context) { - RessourceDetailDTO ressourceDetailDTO = new RessourceDetailDTO(); - dynamic url = null; - showDialog( - builder: (BuildContext context) => AlertDialog( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(20.0)) - ), - content: SingleChildScrollView( - child: Column( - children: [ - Text("Nouvelle ressource", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)), - Column( - children: [ - StringContainer( - label: "Nom :", - initialValue: ressourceDetailDTO.label, - onChanged: (value) { - ressourceDetailDTO.label = value; - }, - ), - if (url != null) Image.network(url) - ], - ), - InkWell( - onTap: () async { - print("onTap upload"); - final file = OpenFilePicker() - ..filterSpecification = { - 'Images (*.jpg; *.png)': '*.jpg;*.png', - 'Video (*.mp4)': '*.mp4', - 'All Files': '*.*' - } - ..defaultFilterIndex = 0 - ..title = 'Sélectionner un fichier'; - - final result = file.getFile(); - if (result != null) { - print(result.path); - print(result.uri); - - // Read the file. - dynamic contents = await result.readAsBytes(); - print(contents); - - url = result.path; - - } - }, - child: Text("UPLOAD !"), - ), - ], - ), - ), - actions: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Align( - alignment: AlignmentDirectional.bottomEnd, - child: Container( - width: 175, - height: 70, - child: RoundedButton( - text: "Annuler", - icon: Icons.undo, - color: kSecond, - press: () { - Navigator.of(context).pop(); - }, - fontSize: 20, - ), - ), - ), - Align( - alignment: AlignmentDirectional.bottomEnd, - child: Container( - width: 150, - height: 70, - child: RoundedButton( - text: "Créer", - icon: Icons.check, - color: kPrimaryColor, - textColor: kWhite, - press: () { - create(ressourceDetailDTO, appContext, context); - }, - fontSize: 20, - ), - ), - ), - ], - ), - ], - ), context: context - ); -} - -void create(RessourceDetailDTO ressourceDetailDTO, AppContext appContext, context) async { - if (ressourceDetailDTO.label != null) { - Navigator.of(context).pop(); - - RessourceDetailDTO newRessource = await appContext.getContext().clientAPI.ressourceApi.ressourceCreate(ressourceDetailDTO); - print("newRessource"); - print(newRessource); - - // To refresh only (UGLY COOOOODE) - ManagerAppContext managerAppContext = appContext.getContext(); - appContext.setContext(managerAppContext); - - showNotification(Colors.green, kWhite, 'La ressource a été créée avec succès', context); - } -} \ No newline at end of file diff --git a/lib/Screens/Resources/resources_screen.dart b/lib/Screens/Resources/resources_screen.dart index beb8698..1da0d98 100644 --- a/lib/Screens/Resources/resources_screen.dart +++ b/lib/Screens/Resources/resources_screen.dart @@ -1,8 +1,10 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; +import 'package:manager_app/Components/fetch_resource_icon.dart'; +import 'package:manager_app/Components/fetch_section_icon.dart'; import 'package:manager_app/Models/managerContext.dart'; -import 'package:manager_app/Screens/Resources/new_ressource_popup.dart'; -import 'package:manager_app/Screens/Resources/show_ressource_popup.dart'; +import 'package:manager_app/Screens/Resources/new_resource_popup.dart'; +import 'package:manager_app/Screens/Resources/show_resource_popup.dart'; import 'package:manager_app/app_context.dart'; import 'package:manager_app/constants.dart'; import 'package:managerapi/api.dart'; @@ -29,8 +31,8 @@ class _ResourcesScreenState extends State { future: getResources(appContext), builder: (context, AsyncSnapshot snapshot) { if (snapshot.connectionState == ConnectionState.done) { - var tempOutput = new List.from(snapshot.data); - tempOutput.add(RessourceDTO(id: null)); + var tempOutput = new List.from(snapshot.data); + tempOutput.add(ResourceDTO(id: null)); return bodyGrid(tempOutput, size, appContext); } else if (snapshot.connectionState == ConnectionState.none) { return Text("No data"); @@ -47,16 +49,16 @@ class _ResourcesScreenState extends State { Widget bodyGrid(data, Size size, AppContext appContext) { return GridView.builder( shrinkWrap: true, - gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 8), + gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 6), itemCount: data.length, itemBuilder: (BuildContext context, int index) { return // User Picture InkWell( onTap: () { if (data[index].id == null) { - showNewRessource(appContext, context); + showNewResource(appContext, context); } else { - showRessource(data[index], appContext, context); + showResource(data[index], appContext, context, size); } }, child: Container( @@ -65,7 +67,7 @@ class _ResourcesScreenState extends State { margin: EdgeInsets.symmetric(vertical: 15, horizontal: 15), child: Align( alignment: Alignment.center, - child: getElement(data[index], size) + child: getElement(data[index], size, appContext) ), ), ); @@ -73,26 +75,35 @@ class _ResourcesScreenState extends State { ); } - getElement(RessourceDTO ressource, Size size) { - if (ressource.id != null) { + getElement(ResourceDTO resource, Size size, AppContext appContext) { + if (resource.id != null) { return Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Align( - alignment: Alignment.centerLeft, + alignment: Alignment.center, child: AutoSizeText( - ressource.label, - style: new TextStyle(fontSize: 25), + resource.label == null ? "" : resource.label, + style: new TextStyle(fontSize: 20), maxLines: 1, ), ), + Container( + height: size.height *0.08, + child: Center( + child: Image.network( + appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id, + fit:BoxFit.fill + ), + ), + ), Align( alignment: Alignment.bottomRight, - child: AutoSizeText( - ressource.type.toString(), - style: new TextStyle(fontSize: 18, fontFamily: ""), - maxLines: 1, + child: Icon( + getResourceIcon(resource.type), + color: kPrimaryColor, + size: 25, ), ), ], @@ -107,9 +118,9 @@ class _ResourcesScreenState extends State { } } -boxDecoration(RessourceDTO ressourceDTO) { +boxDecoration(ResourceDTO resourceDTO) { return BoxDecoration( - color: ressourceDTO.id == null ? Colors.lightGreen : kTextLightColor, + color: resourceDTO.id == null ? Colors.lightGreen : kTextLightColor, shape: BoxShape.rectangle, borderRadius: BorderRadius.circular(25.0), boxShadow: [ @@ -123,11 +134,8 @@ boxDecoration(RessourceDTO ressourceDTO) { ); } -Future> getResources(dynamic appContext) async { - List ressources = await appContext.getContext().clientAPI.ressourceApi.ressourceGet(); - print("number of ressources " + ressources.length.toString()); - ressources.forEach((element) { - print(element); - }); - return ressources; +Future> getResources(dynamic appContext) async { + List resources = await appContext.getContext().clientAPI.resourceApi.resourceGet(); + print(resources); + return resources; } diff --git a/lib/Screens/Resources/show_resource_popup.dart b/lib/Screens/Resources/show_resource_popup.dart new file mode 100644 index 0000000..1698b41 --- /dev/null +++ b/lib/Screens/Resources/show_resource_popup.dart @@ -0,0 +1,106 @@ +import 'package:flutter/material.dart'; +import 'package:manager_app/Components/confirmation_dialog.dart'; +import 'package:manager_app/Components/message_notification.dart'; +import 'package:manager_app/Components/rounded_button.dart'; +import 'package:manager_app/Models/managerContext.dart'; +import 'package:manager_app/app_context.dart'; +import 'package:manager_app/constants.dart'; +import 'package:managerapi/api.dart'; +import 'package:intl/intl.dart'; + +void showResource(ResourceDTO resourceDTO,AppContext appContext, BuildContext context, Size size) { + showDialog( + builder: (BuildContext context) => AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(20.0)) + ), + content: SingleChildScrollView( + child: Column( + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + resourceDTO.label == null ? "" : resourceDTO.label, + style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)), + ), + Container( + height: size.height *0.6, + child: Center( + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(30), + border: Border.all(width: 3, color: kSecond) + ), + child: Padding( + padding: const EdgeInsets.all(10.0), + child: Image.network( + appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resourceDTO.id, + fit:BoxFit.scaleDown + ), + ), + ), + ), + ), + ], + ), + ), + actions: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Align( + alignment: AlignmentDirectional.bottomEnd, + child: Container( + width: 175, + height: 70, + child: RoundedButton( + text: "Retour", + icon: Icons.undo, + color: kSecond, + press: () { + Navigator.of(context).pop(); + }, + fontSize: 20, + ), + ), + ), + Align( + alignment: AlignmentDirectional.bottomEnd, + child: Container( + width: 200, + height: 70, + child: RoundedButton( + text: "Supprimer", + icon: Icons.delete, + color: kPrimaryColor, + textColor: kWhite, + press: () { + delete(resourceDTO, appContext, context); + }, + fontSize: 20, + ), + ), + ), + ], + ), + ], + ), context: context + ); +} + +Future delete(ResourceDTO resourceDTO, AppContext appContext, context) async { + showConfirmationDialog( + "Êtes-vous sûr de vouloir supprimer cette ressource ?", + () {}, + () async { + await appContext.getContext().clientAPI.resourceApi.resourceDelete(resourceDTO.id); + // just to refresh + ManagerAppContext managerAppContext = appContext.getContext(); + appContext.setContext(managerAppContext); + Navigator.of(context).pop(); + + showNotification(Colors.green, kWhite, 'La ressource a été supprimée avec succès', context); + }, + context + ); +} diff --git a/lib/Screens/Resources/show_ressource_popup.dart b/lib/Screens/Resources/show_ressource_popup.dart deleted file mode 100644 index 5a4f7b8..0000000 --- a/lib/Screens/Resources/show_ressource_popup.dart +++ /dev/null @@ -1,81 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:manager_app/Components/rounded_button.dart'; -import 'package:manager_app/app_context.dart'; -import 'package:manager_app/constants.dart'; -import 'package:managerapi/api.dart'; -import 'package:intl/intl.dart'; - -void showRessource(RessourceDTO ressourceDTO,AppContext appContext, BuildContext context) { - showDialog( - builder: (BuildContext context) => AlertDialog( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(20.0)) - ), - content: SingleChildScrollView( - child: Column( - children: [ - Text(ressourceDTO.label, style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)), - Text('TODO CHARGE IMAGE'), - Text("TODO SHOW IMAGE OR VIDEO") - ], - ), - ), - actions: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Align( - alignment: AlignmentDirectional.bottomEnd, - child: Container( - width: 175, - height: 70, - child: RoundedButton( - text: "Retour", - icon: Icons.undo, - color: kSecond, - press: () { - Navigator.of(context).pop(); - }, - fontSize: 20, - ), - ), - ), - Align( - alignment: AlignmentDirectional.bottomEnd, - child: Container( - width: 200, - height: 70, - child: RoundedButton( - text: "Supprimer", - icon: Icons.delete, - color: kPrimaryColor, - textColor: kWhite, - press: () { - delete(ressourceDTO, appContext, context); - }, - fontSize: 20, - ), - ), - ), - ], - ), - ], - ), context: context - ); -} - -void delete(RessourceDTO ressourceDTO, AppContext appContext, context) async { - if (ressourceDTO.label != null) { - Navigator.of(context).pop(); - - //RessourceDetailDTO newRessource = await appContext.getContext().clientAPI.ressourceApi.ressourceCreate(ressourceDetailDTO); - print("TODO DELETE"); - /*print(newRessource); - - // To refresh only (UGLY COOOOODE) - ManagerAppContext managerAppContext = appContext.getContext(); - appContext.setContext(managerAppContext); - - showNotification(Colors.green, kWhite, 'La ressource a été créée avec succès', context);*/ - } -} \ No newline at end of file diff --git a/lib/Screens/Resources/upload_image.dart b/lib/Screens/Resources/upload_image.dart new file mode 100644 index 0000000..4806582 --- /dev/null +++ b/lib/Screens/Resources/upload_image.dart @@ -0,0 +1,170 @@ +import 'dart:io'; +import 'dart:convert'; +import 'package:dart_vlc/dart_vlc.dart'; +import 'package:manager_app/Components/vlc_viewer.dart'; +import 'package:manager_app/constants.dart'; +import 'package:path/path.dart'; +import 'package:async/async.dart'; +import 'package:http/http.dart' as http; +import 'package:filepicker_windows/filepicker_windows.dart'; +import 'package:flutter/material.dart'; + +class UploadImageContainer extends StatefulWidget { + final ValueChanged onChanged; + const UploadImageContainer({ + Key key, + this.onChanged, + }) : super(key: key); + + @override + _UploadImageContainerState createState() => _UploadImageContainerState(); +} + +class _UploadImageContainerState extends State with SingleTickerProviderStateMixin { + var filePath; + File fileToShow; + + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Container( + width: 500, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + if (fileToShow == null) InkWell( + onTap: () async { + filePicker(); + }, + child: Container( + decoration: BoxDecoration( + color: kPrimaryColor, + borderRadius: BorderRadius.circular(15) + ), + child: Padding( + padding: const EdgeInsets.only(left: 25.0, right: 25.0, top: 15.0, bottom: 15.0), + child: Text( + "Ajouter un fichier", + style: new TextStyle(color: kWhite), + ), + ) + ), + ), + if (fileToShow != null) + Container( + margin: EdgeInsets.all(8.0), + child: Card( + color: kBackgroundColor, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(8.0))), + child: InkWell( + onTap: () async { + filePicker(); + }, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + ClipRRect( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8.0), + topRight: Radius.circular(8.0), + ), + child: showFile() + ), + ListTile( + title: Text(getFileName(filePath)), + subtitle: Text(filePath), + ), + ], + ), + ), + ), + ), + ], + ), + ); + } + + String getFileName(filePath) { + return (filePath.toString().split('\\').last); + } + + void filePicker() { + final file = OpenFilePicker() + ..filterSpecification = { + 'Images (*.jpg; *.png)': '*.jpg;*.png', + 'Video (*.mp4)': '*.mp4', + 'All Files': '*.*' + } + ..defaultFilterIndex = 0 + ..title = 'Sélectionner un fichier'; + + final result = file.getFile(); + + if (result != null) { + + setState(() { + filePath = result.path; + fileToShow = result; + widget.onChanged(result); + }); + } + } + + showFile() { + if (getFileName(filePath).contains(".mp4")) { + + return FutureBuilder( + future: loadFile(fileToShow), + builder: (context, AsyncSnapshot snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + return Container( + height: 300, + child: DartVLC(file: snapshot.data) + ); + } else if (snapshot.connectionState == ConnectionState.none) { + return Text("No data"); + } else { + return Center(child: Container(height: 200, child: Text('LOADING TODO FRAISE'))); + } + } + ); + + + + /*await Media.file(widget.file)*/ + } else { + return Image.file( + fileToShow, + height: 200, + fit:BoxFit.scaleDown + ); + } + } + + loadFile(File fileToShow) async { + return await Media.file(fileToShow); + } +} + +Upload(File imageFile) async { + var stream = new http.ByteStream(DelegatingStream.typed(imageFile.openRead())); + var length = await imageFile.length(); + + var uri = Uri.parse("upload URL TEST"); + + var request = new http.MultipartRequest("POST", uri); + var multipartFile = new http.MultipartFile('file', stream, length, + filename: basename(imageFile.path)); + //contentType: new MediaType('image', 'png')); + + request.files.add(multipartFile); + var response = await request.send(); + print(response.statusCode); + response.stream.transform(utf8.decoder).listen((value) { + print(value); + }); +} \ No newline at end of file diff --git a/lib/Screens/login_screen.dart b/lib/Screens/login_screen.dart index e1b9fe4..b49da9f 100644 --- a/lib/Screens/login_screen.dart +++ b/lib/Screens/login_screen.dart @@ -84,9 +84,9 @@ class _LoginScreenState extends State { SectionDTO section = await clientAPI.sectionApi.sectionGetDetail("60916249494b9eaf283b44f7"); print(section); - List ressources = await clientAPI.ressourceApi.ressourceGet(); - print("number of ressources " + ressources.length.toString()); - ressources.forEach((element) { + List resources = await clientAPI.resourceApi.resourceGet(); + print("number of resources " + resources.length.toString()); + resources.forEach((element) { print(element); }); diff --git a/lib/client.dart b/lib/client.dart index 44b1d8b..84b5974 100644 --- a/lib/client.dart +++ b/lib/client.dart @@ -17,8 +17,8 @@ class Client { SectionApi _sectionApi; SectionApi get sectionApi => _sectionApi; - RessourceApi _ressourceApi; - RessourceApi get ressourceApi => _ressourceApi; + ResourceApi _resourceApi; + ResourceApi get resourceApi => _resourceApi; DeviceApi _deviceApi; DeviceApi get deviceApi => _deviceApi; @@ -26,12 +26,12 @@ class Client { Client() { _apiClient = ApiClient( basePath: "http://192.168.31.96"); - //basePath: "http://localhost:25049"); + //basePath: "https://localhost:44339"); _authenticationApi = AuthenticationApi(_apiClient); _userApi = UserApi(_apiClient); _configurationApi = ConfigurationApi(_apiClient); _sectionApi = SectionApi(_apiClient); - _ressourceApi = RessourceApi(_apiClient); + _resourceApi = ResourceApi(_apiClient); _deviceApi = DeviceApi(_apiClient); } } \ No newline at end of file diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index e71a16d..0e8ad7e 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -6,6 +6,10 @@ #include "generated_plugin_registrant.h" +#include void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) dart_vlc_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "DartVlcPlugin"); + dart_vlc_plugin_register_with_registrar(dart_vlc_registrar); } diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 51436ae..0ec9fa0 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + dart_vlc ) set(PLUGIN_BUNDLED_LIBRARIES) diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index cf98146..7ce0a99 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -7,6 +7,8 @@ import FlutterMacOS import Foundation +import path_provider_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) } diff --git a/manager_api/.openapi-generator/FILES b/manager_api/.openapi-generator/FILES index 087bb94..b36a968 100644 --- a/manager_api/.openapi-generator/FILES +++ b/manager_api/.openapi-generator/FILES @@ -9,10 +9,10 @@ doc/DeviceDTO.md doc/DeviceDetailDTO.md doc/DeviceDetailDTOAllOf.md doc/LoginDTO.md -doc/RessourceApi.md -doc/RessourceDTO.md -doc/RessourceDetailDTO.md -doc/RessourceType.md +doc/ResourceApi.md +doc/ResourceDTO.md +doc/ResourceDetailDTO.md +doc/ResourceType.md doc/SectionApi.md doc/SectionDTO.md doc/SectionType.md @@ -26,7 +26,7 @@ lib/api.dart lib/api/authentication_api.dart lib/api/configuration_api.dart lib/api/device_api.dart -lib/api/ressource_api.dart +lib/api/resource_api.dart lib/api/section_api.dart lib/api/user_api.dart lib/api_client.dart @@ -42,9 +42,9 @@ lib/model/device_detail_dto.dart lib/model/device_detail_dto_all_of.dart lib/model/device_dto.dart lib/model/login_dto.dart -lib/model/ressource_detail_dto.dart -lib/model/ressource_dto.dart -lib/model/ressource_type.dart +lib/model/resource_detail_dto.dart +lib/model/resource_dto.dart +lib/model/resource_type.dart lib/model/section_dto.dart lib/model/section_type.dart lib/model/token_dto.dart @@ -52,4 +52,4 @@ lib/model/translation_dto.dart lib/model/user.dart lib/model/user_detail_dto.dart pubspec.yaml -test/translation_dto_test.dart +test/resource_type_test.dart diff --git a/manager_api/README.md b/manager_api/README.md index a5bf932..177d9d0 100644 --- a/manager_api/README.md +++ b/manager_api/README.md @@ -76,12 +76,13 @@ Class | Method | HTTP request | Description *DeviceApi* | [**deviceGet**](doc\/DeviceApi.md#deviceget) | **GET** /api/Device | *DeviceApi* | [**deviceGetDetail**](doc\/DeviceApi.md#devicegetdetail) | **GET** /api/Device/{id}/detail | *DeviceApi* | [**deviceUpdate**](doc\/DeviceApi.md#deviceupdate) | **PUT** /api/Device | -*RessourceApi* | [**ressourceCreate**](doc\/RessourceApi.md#ressourcecreate) | **POST** /api/Ressource | -*RessourceApi* | [**ressourceDelete**](doc\/RessourceApi.md#ressourcedelete) | **DELETE** /api/Ressource/{id} | -*RessourceApi* | [**ressourceGet**](doc\/RessourceApi.md#ressourceget) | **GET** /api/Ressource | -*RessourceApi* | [**ressourceGetDetail**](doc\/RessourceApi.md#ressourcegetdetail) | **GET** /api/Ressource/{id}/detail | -*RessourceApi* | [**ressourceShow**](doc\/RessourceApi.md#ressourceshow) | **GET** /api/Ressource/{id} | -*RessourceApi* | [**ressourceUpdate**](doc\/RessourceApi.md#ressourceupdate) | **PUT** /api/Ressource | +*ResourceApi* | [**resourceCreate**](doc\/ResourceApi.md#resourcecreate) | **POST** /api/Resource | +*ResourceApi* | [**resourceDelete**](doc\/ResourceApi.md#resourcedelete) | **DELETE** /api/Resource/{id} | +*ResourceApi* | [**resourceGet**](doc\/ResourceApi.md#resourceget) | **GET** /api/Resource | +*ResourceApi* | [**resourceGetDetail**](doc\/ResourceApi.md#resourcegetdetail) | **GET** /api/Resource/{id}/detail | +*ResourceApi* | [**resourceShow**](doc\/ResourceApi.md#resourceshow) | **GET** /api/Resource/{id} | +*ResourceApi* | [**resourceUpdate**](doc\/ResourceApi.md#resourceupdate) | **PUT** /api/Resource | +*ResourceApi* | [**resourceUpload**](doc\/ResourceApi.md#resourceupload) | **POST** /api/Resource/upload | *SectionApi* | [**sectionCreate**](doc\/SectionApi.md#sectioncreate) | **POST** /api/Section | *SectionApi* | [**sectionDelete**](doc\/SectionApi.md#sectiondelete) | **DELETE** /api/Section/{id} | *SectionApi* | [**sectionDeleteAllForConfiguration**](doc\/SectionApi.md#sectiondeleteallforconfiguration) | **DELETE** /api/Section/configuration/{id} | @@ -104,9 +105,9 @@ Class | Method | HTTP request | Description - [DeviceDetailDTO](doc\/DeviceDetailDTO.md) - [DeviceDetailDTOAllOf](doc\/DeviceDetailDTOAllOf.md) - [LoginDTO](doc\/LoginDTO.md) - - [RessourceDTO](doc\/RessourceDTO.md) - - [RessourceDetailDTO](doc\/RessourceDetailDTO.md) - - [RessourceType](doc\/RessourceType.md) + - [ResourceDTO](doc\/ResourceDTO.md) + - [ResourceDetailDTO](doc\/ResourceDetailDTO.md) + - [ResourceType](doc\/ResourceType.md) - [SectionDTO](doc\/SectionDTO.md) - [SectionType](doc\/SectionType.md) - [TokenDTO](doc\/TokenDTO.md) diff --git a/manager_api/doc/ResourceApi.md b/manager_api/doc/ResourceApi.md new file mode 100644 index 0000000..c7a88e8 --- /dev/null +++ b/manager_api/doc/ResourceApi.md @@ -0,0 +1,319 @@ +# managerapi.api.ResourceApi + +## Load the API package +```dart +import 'package:managerapi/api.dart'; +``` + +All URIs are relative to *http://192.168.31.96* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**resourceCreate**](ResourceApi.md#resourcecreate) | **POST** /api/Resource | +[**resourceDelete**](ResourceApi.md#resourcedelete) | **DELETE** /api/Resource/{id} | +[**resourceGet**](ResourceApi.md#resourceget) | **GET** /api/Resource | +[**resourceGetDetail**](ResourceApi.md#resourcegetdetail) | **GET** /api/Resource/{id}/detail | +[**resourceShow**](ResourceApi.md#resourceshow) | **GET** /api/Resource/{id} | +[**resourceUpdate**](ResourceApi.md#resourceupdate) | **PUT** /api/Resource | +[**resourceUpload**](ResourceApi.md#resourceupload) | **POST** /api/Resource/upload | + + +# **resourceCreate** +> ResourceDetailDTO resourceCreate(resourceDetailDTO) + + + +### 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 = ResourceApi(); +final resourceDetailDTO = ResourceDetailDTO(); // ResourceDetailDTO | + +try { + final result = api_instance.resourceCreate(resourceDetailDTO); + print(result); +} catch (e) { + print('Exception when calling ResourceApi->resourceCreate: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **resourceDetailDTO** | [**ResourceDetailDTO**](ResourceDetailDTO.md)| | + +### Return type + +[**ResourceDetailDTO**](ResourceDetailDTO.md) + +### Authorization + +[bearer](../README.md#bearer) + +### HTTP request headers + + - **Content-Type**: application/json + - **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) + +# **resourceDelete** +> String resourceDelete(id) + + + +### 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 = ResourceApi(); +final id = id_example; // String | + +try { + final result = api_instance.resourceDelete(id); + print(result); +} catch (e) { + print('Exception when calling ResourceApi->resourceDelete: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **id** | **String**| | + +### Return type + +**String** + +### 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) + +# **resourceGet** +> List resourceGet() + + + +### 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 = ResourceApi(); + +try { + final result = api_instance.resourceGet(); + print(result); +} catch (e) { + print('Exception when calling ResourceApi->resourceGet: $e\n'); +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**List**](ResourceDTO.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) + +# **resourceGetDetail** +> ResourceDetailDTO resourceGetDetail(id) + + + +### 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 = ResourceApi(); +final id = id_example; // String | + +try { + final result = api_instance.resourceGetDetail(id); + print(result); +} catch (e) { + print('Exception when calling ResourceApi->resourceGetDetail: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **id** | **String**| | + +### Return type + +[**ResourceDetailDTO**](ResourceDetailDTO.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) + +# **resourceShow** +> MultipartFile resourceShow(id) + + + +### 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 = ResourceApi(); +final id = id_example; // String | + +try { + final result = api_instance.resourceShow(id); + print(result); +} catch (e) { + print('Exception when calling ResourceApi->resourceShow: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **id** | **String**| | + +### Return type + +[**MultipartFile**](MultipartFile.md) + +### Authorization + +[bearer](../README.md#bearer) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/octet-stream, 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) + +# **resourceUpdate** +> ResourceDetailDTO resourceUpdate(resourceDetailDTO) + + + +### 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 = ResourceApi(); +final resourceDetailDTO = ResourceDetailDTO(); // ResourceDetailDTO | + +try { + final result = api_instance.resourceUpdate(resourceDetailDTO); + print(result); +} catch (e) { + print('Exception when calling ResourceApi->resourceUpdate: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **resourceDetailDTO** | [**ResourceDetailDTO**](ResourceDetailDTO.md)| | + +### Return type + +[**ResourceDetailDTO**](ResourceDetailDTO.md) + +### Authorization + +[bearer](../README.md#bearer) + +### HTTP request headers + + - **Content-Type**: application/json + - **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) + +# **resourceUpload** +> String resourceUpload(label, type) + + + +### 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 = ResourceApi(); +final label = label_example; // String | +final type = type_example; // String | + +try { + final result = api_instance.resourceUpload(label, type); + print(result); +} catch (e) { + print('Exception when calling ResourceApi->resourceUpload: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **label** | **String**| | [optional] + **type** | **String**| | [optional] + +### Return type + +**String** + +### Authorization + +[bearer](../README.md#bearer) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **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) + diff --git a/manager_api/doc/ResourceDTO.md b/manager_api/doc/ResourceDTO.md new file mode 100644 index 0000000..a41da03 --- /dev/null +++ b/manager_api/doc/ResourceDTO.md @@ -0,0 +1,17 @@ +# managerapi.model.ResourceDTO + +## Load the model package +```dart +import 'package:managerapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **String** | | [optional] +**type** | [**ResourceType**](ResourceType.md) | | [optional] +**label** | **String** | | [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/ResourceDetailDTO.md b/manager_api/doc/ResourceDetailDTO.md new file mode 100644 index 0000000..12a7f7d --- /dev/null +++ b/manager_api/doc/ResourceDetailDTO.md @@ -0,0 +1,19 @@ +# managerapi.model.ResourceDetailDTO + +## Load the model package +```dart +import 'package:managerapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **String** | | [optional] +**type** | [**ResourceType**](ResourceType.md) | | [optional] +**label** | **String** | | [optional] +**dateCreation** | [**DateTime**](DateTime.md) | | [optional] +**data** | **String** | | [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/ResourceType.md b/manager_api/doc/ResourceType.md new file mode 100644 index 0000000..05e673f --- /dev/null +++ b/manager_api/doc/ResourceType.md @@ -0,0 +1,14 @@ +# managerapi.model.ResourceType + +## 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/lib/api.dart b/manager_api/lib/api.dart index b9111e6..6e419e0 100644 --- a/manager_api/lib/api.dart +++ b/manager_api/lib/api.dart @@ -30,7 +30,7 @@ part 'auth/http_bearer_auth.dart'; part 'api/authentication_api.dart'; part 'api/configuration_api.dart'; part 'api/device_api.dart'; -part 'api/ressource_api.dart'; +part 'api/resource_api.dart'; part 'api/section_api.dart'; part 'api/user_api.dart'; @@ -39,9 +39,9 @@ part 'model/device_dto.dart'; part 'model/device_detail_dto.dart'; part 'model/device_detail_dto_all_of.dart'; part 'model/login_dto.dart'; -part 'model/ressource_dto.dart'; -part 'model/ressource_detail_dto.dart'; -part 'model/ressource_type.dart'; +part 'model/resource_dto.dart'; +part 'model/resource_detail_dto.dart'; +part 'model/resource_type.dart'; part 'model/section_dto.dart'; part 'model/section_type.dart'; part 'model/token_dto.dart'; diff --git a/manager_api/lib/api/resource_api.dart b/manager_api/lib/api/resource_api.dart new file mode 100644 index 0000000..60376c1 --- /dev/null +++ b/manager_api/lib/api/resource_api.dart @@ -0,0 +1,467 @@ +// +// 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 ResourceApi { + ResourceApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient; + + final ApiClient apiClient; + + /// Performs an HTTP 'POST /api/Resource' operation and returns the [Response]. + /// Parameters: + /// + /// * [ResourceDetailDTO] resourceDetailDTO (required): + Future resourceCreateWithHttpInfo(ResourceDetailDTO resourceDetailDTO) async { + // Verify required params are set. + if (resourceDetailDTO == null) { + throw ApiException(HttpStatus.badRequest, 'Missing required param: resourceDetailDTO'); + } + + final path = r'/api/Resource'; + + Object postBody = resourceDetailDTO; + + final queryParams = []; + final headerParams = {}; + final formParams = {}; + + final contentTypes = ['application/json']; + 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, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + nullableContentType, + authNames, + ); + } + + /// Parameters: + /// + /// * [ResourceDetailDTO] resourceDetailDTO (required): + Future resourceCreate(ResourceDetailDTO resourceDetailDTO) async { + final response = await resourceCreateWithHttpInfo(resourceDetailDTO); + 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), 'ResourceDetailDTO') as ResourceDetailDTO; + } + return Future.value(null); + } + + /// Performs an HTTP 'DELETE /api/Resource/{id}' operation and returns the [Response]. + /// Parameters: + /// + /// * [String] id (required): + Future resourceDeleteWithHttpInfo(String id) async { + // Verify required params are set. + if (id == null) { + throw ApiException(HttpStatus.badRequest, 'Missing required param: id'); + } + + final path = r'/api/Resource/{id}' + .replaceAll('{' + 'id' + '}', id.toString()); + + 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, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + nullableContentType, + authNames, + ); + } + + /// Parameters: + /// + /// * [String] id (required): + Future resourceDelete(String id) async { + final response = await resourceDeleteWithHttpInfo(id); + 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), 'String') as String; + } + return Future.value(null); + } + + /// Performs an HTTP 'GET /api/Resource' operation and returns the [Response]. + Future resourceGetWithHttpInfo() async { + final path = r'/api/Resource'; + + 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> resourceGet() async { + final response = await resourceGetWithHttpInfo(); + 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), 'List') as List) + .cast() + .toList(growable: false); + } + return Future>.value(null); + } + + /// Performs an HTTP 'GET /api/Resource/{id}/detail' operation and returns the [Response]. + /// Parameters: + /// + /// * [String] id (required): + Future resourceGetDetailWithHttpInfo(String id) async { + // Verify required params are set. + if (id == null) { + throw ApiException(HttpStatus.badRequest, 'Missing required param: id'); + } + + final path = r'/api/Resource/{id}/detail' + .replaceAll('{' + 'id' + '}', id.toString()); + + 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, + ); + } + + /// Parameters: + /// + /// * [String] id (required): + Future resourceGetDetail(String id) async { + final response = await resourceGetDetailWithHttpInfo(id); + 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), 'ResourceDetailDTO') as ResourceDetailDTO; + } + return Future.value(null); + } + + /// Performs an HTTP 'GET /api/Resource/{id}' operation and returns the [Response]. + /// Parameters: + /// + /// * [String] id (required): + Future resourceShowWithHttpInfo(String id) async { + // Verify required params are set. + if (id == null) { + throw ApiException(HttpStatus.badRequest, 'Missing required param: id'); + } + + final path = r'/api/Resource/{id}' + .replaceAll('{' + 'id' + '}', id.toString()); + + 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, + ); + } + + /// Parameters: + /// + /// * [String] id (required): + Future resourceShow(String id) async { + final response = await resourceShowWithHttpInfo(id); + 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), 'MultipartFile') as MultipartFile; + } + return Future.value(null); + } + + /// Performs an HTTP 'PUT /api/Resource' operation and returns the [Response]. + /// Parameters: + /// + /// * [ResourceDetailDTO] resourceDetailDTO (required): + Future resourceUpdateWithHttpInfo(ResourceDetailDTO resourceDetailDTO) async { + // Verify required params are set. + if (resourceDetailDTO == null) { + throw ApiException(HttpStatus.badRequest, 'Missing required param: resourceDetailDTO'); + } + + final path = r'/api/Resource'; + + Object postBody = resourceDetailDTO; + + final queryParams = []; + final headerParams = {}; + final formParams = {}; + + final contentTypes = ['application/json']; + 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, + 'PUT', + queryParams, + postBody, + headerParams, + formParams, + nullableContentType, + authNames, + ); + } + + /// Parameters: + /// + /// * [ResourceDetailDTO] resourceDetailDTO (required): + Future resourceUpdate(ResourceDetailDTO resourceDetailDTO) async { + final response = await resourceUpdateWithHttpInfo(resourceDetailDTO); + 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), 'ResourceDetailDTO') as ResourceDetailDTO; + } + return Future.value(null); + } + + /// Performs an HTTP 'POST /api/Resource/upload' operation and returns the [Response]. + /// Parameters: + /// + /// * [String] label: + /// + /// * [String] type: + Future resourceUploadWithHttpInfo({ String label, String type }) async { + // Verify required params are set. + + final path = r'/api/Resource/upload'; + + Object postBody; + + final queryParams = []; + final headerParams = {}; + final formParams = {}; + + final contentTypes = ['multipart/form-data']; + 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 (label != null) { + hasFields = true; + mp.fields[r'label'] = parameterToString(label); + } + if (type != null) { + hasFields = true; + mp.fields[r'type'] = parameterToString(type); + } + if (hasFields) { + postBody = mp; + } + } else { + if (label != null) { + formParams[r'label'] = parameterToString(label); + } + if (type != null) { + formParams[r'type'] = parameterToString(type); + } + } + + return await apiClient.invokeAPI( + path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + nullableContentType, + authNames, + ); + } + + /// Parameters: + /// + /// * [String] label: + /// + /// * [String] type: + Future resourceUpload({ String label, String type }) async { + final response = await resourceUploadWithHttpInfo( label: label, type: type ); + 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), 'String') as String; + } + return Future.value(null); + } +} diff --git a/manager_api/lib/api_client.dart b/manager_api/lib/api_client.dart index 3b5ae6c..82cea5c 100644 --- a/manager_api/lib/api_client.dart +++ b/manager_api/lib/api_client.dart @@ -166,12 +166,12 @@ class ApiClient { return DeviceDetailDTOAllOf.fromJson(value); case 'LoginDTO': return LoginDTO.fromJson(value); - case 'RessourceDTO': - return RessourceDTO.fromJson(value); - case 'RessourceDetailDTO': - return RessourceDetailDTO.fromJson(value); - case 'RessourceType': - return RessourceTypeTypeTransformer().decode(value); + case 'ResourceDTO': + return ResourceDTO.fromJson(value); + case 'ResourceDetailDTO': + return ResourceDetailDTO.fromJson(value); + case 'ResourceType': + return ResourceTypeTypeTransformer().decode(value); case 'SectionDTO': return SectionDTO.fromJson(value); diff --git a/manager_api/lib/api_helper.dart b/manager_api/lib/api_helper.dart index 43dbbcd..c443313 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 RessourceType) { - return RessourceTypeTypeTransformer().encode(value).toString(); + if (value is ResourceType) { + return ResourceTypeTypeTransformer().encode(value).toString(); } if (value is SectionType) { return SectionTypeTypeTransformer().encode(value).toString(); diff --git a/manager_api/lib/model/resource_detail_dto.dart b/manager_api/lib/model/resource_detail_dto.dart new file mode 100644 index 0000000..106fc52 --- /dev/null +++ b/manager_api/lib/model/resource_detail_dto.dart @@ -0,0 +1,109 @@ +// +// 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 ResourceDetailDTO { + /// Returns a new [ResourceDetailDTO] instance. + ResourceDetailDTO({ + this.id, + this.type, + this.label, + this.dateCreation, + this.data, + }); + + String id; + + ResourceType type; + + String label; + + DateTime dateCreation; + + String data; + + @override + bool operator ==(Object other) => identical(this, other) || other is ResourceDetailDTO && + other.id == id && + other.type == type && + other.label == label && + other.dateCreation == dateCreation && + other.data == data; + + @override + int get hashCode => + (id == null ? 0 : id.hashCode) + + (type == null ? 0 : type.hashCode) + + (label == null ? 0 : label.hashCode) + + (dateCreation == null ? 0 : dateCreation.hashCode) + + (data == null ? 0 : data.hashCode); + + @override + String toString() => 'ResourceDetailDTO[id=$id, type=$type, label=$label, dateCreation=$dateCreation, data=$data]'; + + Map toJson() { + final json = {}; + if (id != null) { + json[r'id'] = id; + } + if (type != null) { + json[r'type'] = type; + } + if (label != null) { + json[r'label'] = label; + } + if (dateCreation != null) { + json[r'dateCreation'] = dateCreation.toUtc().toIso8601String(); + } + if (data != null) { + json[r'data'] = data; + } + return json; + } + + /// Returns a new [ResourceDetailDTO] instance and imports its values from + /// [json] if it's non-null, null if [json] is null. + static ResourceDetailDTO fromJson(Map json) => json == null + ? null + : ResourceDetailDTO( + id: json[r'id'], + type: ResourceType.fromJson(json[r'type']), + label: json[r'label'], + dateCreation: json[r'dateCreation'] == null + ? null + : DateTime.parse(json[r'dateCreation']), + data: json[r'data'], + ); + + static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => + json == null || json.isEmpty + ? true == emptyIsNull ? null : [] + : json.map((v) => ResourceDetailDTO.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] = ResourceDetailDTO.fromJson(v)); + } + return map; + } + + // maps a json object with a list of ResourceDetailDTO-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] = ResourceDetailDTO.listFromJson(v, emptyIsNull: emptyIsNull, growable: growable); + }); + } + return map; + } +} + diff --git a/manager_api/lib/model/resource_dto.dart b/manager_api/lib/model/resource_dto.dart new file mode 100644 index 0000000..e069989 --- /dev/null +++ b/manager_api/lib/model/resource_dto.dart @@ -0,0 +1,89 @@ +// +// 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 ResourceDTO { + /// Returns a new [ResourceDTO] instance. + ResourceDTO({ + this.id, + this.type, + this.label, + }); + + String id; + + ResourceType type; + + String label; + + @override + bool operator ==(Object other) => identical(this, other) || other is ResourceDTO && + other.id == id && + other.type == type && + other.label == label; + + @override + int get hashCode => + (id == null ? 0 : id.hashCode) + + (type == null ? 0 : type.hashCode) + + (label == null ? 0 : label.hashCode); + + @override + String toString() => 'ResourceDTO[id=$id, type=$type, label=$label]'; + + Map toJson() { + final json = {}; + if (id != null) { + json[r'id'] = id; + } + if (type != null) { + json[r'type'] = type; + } + if (label != null) { + json[r'label'] = label; + } + return json; + } + + /// Returns a new [ResourceDTO] instance and imports its values from + /// [json] if it's non-null, null if [json] is null. + static ResourceDTO fromJson(Map json) => json == null + ? null + : ResourceDTO( + id: json[r'id'], + type: ResourceType.fromJson(json[r'type']), + label: json[r'label'], + ); + + static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => + json == null || json.isEmpty + ? true == emptyIsNull ? null : [] + : json.map((v) => ResourceDTO.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] = ResourceDTO.fromJson(v)); + } + return map; + } + + // maps a json object with a list of ResourceDTO-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] = ResourceDTO.listFromJson(v, emptyIsNull: emptyIsNull, growable: growable); + }); + } + return map; + } +} + diff --git a/manager_api/lib/model/resource_type.dart b/manager_api/lib/model/resource_type.dart new file mode 100644 index 0000000..cb501a3 --- /dev/null +++ b/manager_api/lib/model/resource_type.dart @@ -0,0 +1,82 @@ +// +// 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 ResourceType { + /// Instantiate a new enum with the provided [value]. + const ResourceType._(this.value); + + /// The underlying value of this enum member. + final String value; + + @override + String toString() => value; + + String toJson() => value; + + static const image = ResourceType._(r'Image'); + static const video = ResourceType._(r'Video'); + static const imageUrl = ResourceType._(r'ImageUrl'); + static const videoUrl = ResourceType._(r'VideoUrl'); + + /// List of all possible values in this [enum][ResourceType]. + static const values = [ + image, + video, + imageUrl, + videoUrl, + ]; + + static ResourceType fromJson(dynamic value) => + ResourceTypeTypeTransformer().decode(value); + + static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => + json == null || json.isEmpty + ? true == emptyIsNull ? null : [] + : json + .map((value) => ResourceType.fromJson(value)) + .toList(growable: true == growable); +} + +/// Transformation class that can [encode] an instance of [ResourceType] to String, +/// and [decode] dynamic data back to [ResourceType]. +class ResourceTypeTypeTransformer { + const ResourceTypeTypeTransformer._(); + + factory ResourceTypeTypeTransformer() => _instance ??= ResourceTypeTypeTransformer._(); + + String encode(ResourceType data) => data.value; + + /// Decodes a [dynamic value][data] to a ResourceType. + /// + /// 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. + ResourceType decode(dynamic data, {bool allowNull}) { + switch (data) { + case r'Image': return ResourceType.image; + case r'Video': return ResourceType.video; + case r'ImageUrl': return ResourceType.imageUrl; + case r'VideoUrl': return ResourceType.videoUrl; + default: + if (allowNull == false) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } + return null; + } + + /// Singleton [ResourceTypeTypeTransformer] instance. + static ResourceTypeTypeTransformer _instance; +} diff --git a/manager_api/swagger.yaml b/manager_api/swagger.yaml index 1e4ca1b..4428a95 100644 --- a/manager_api/swagger.yaml +++ b/manager_api/swagger.yaml @@ -350,11 +350,11 @@ paths: type: string security: - bearer: [] - /api/Ressource: + /api/Resource: get: tags: - - Ressource - operationId: Ressource_Get + - Resource + operationId: Resource_Get responses: '200': description: '' @@ -363,7 +363,7 @@ paths: schema: type: array items: - $ref: '#/components/schemas/RessourceDTO' + $ref: '#/components/schemas/ResourceDTO' '500': description: '' content: @@ -374,14 +374,14 @@ paths: - bearer: [] post: tags: - - Ressource - operationId: Ressource_Create + - Resource + operationId: Resource_Create requestBody: - x-name: newRessource + x-name: newResource content: application/json: schema: - $ref: '#/components/schemas/RessourceDetailDTO' + $ref: '#/components/schemas/ResourceDetailDTO' required: true x-position: 1 responses: @@ -390,7 +390,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/RessourceDetailDTO' + $ref: '#/components/schemas/ResourceDetailDTO' '400': description: '' content: @@ -413,14 +413,14 @@ paths: - bearer: [] put: tags: - - Ressource - operationId: Ressource_Update + - Resource + operationId: Resource_Update requestBody: - x-name: updatedRessource + x-name: updatedResource content: application/json: schema: - $ref: '#/components/schemas/RessourceDetailDTO' + $ref: '#/components/schemas/ResourceDetailDTO' required: true x-position: 1 responses: @@ -429,7 +429,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/RessourceDetailDTO' + $ref: '#/components/schemas/ResourceDetailDTO' '400': description: '' content: @@ -450,11 +450,11 @@ paths: type: string security: - bearer: [] - '/api/Ressource/{id}/detail': + '/api/Resource/{id}/detail': get: tags: - - Ressource - operationId: Ressource_GetDetail + - Resource + operationId: Resource_GetDetail parameters: - name: id in: path @@ -469,7 +469,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/RessourceDetailDTO' + $ref: '#/components/schemas/ResourceDetailDTO' '404': description: '' content: @@ -482,11 +482,11 @@ paths: application/json: schema: type: string - '/api/Ressource/{id}': + '/api/Resource/{id}': get: tags: - - Ressource - operationId: Ressource_Show + - Resource + operationId: Resource_Show parameters: - name: id in: path @@ -517,8 +517,8 @@ paths: type: string delete: tags: - - Ressource - operationId: Ressource_Delete + - Resource + operationId: Resource_Delete parameters: - name: id in: path @@ -554,6 +554,41 @@ paths: type: string security: - bearer: [] + /api/Resource/upload: + post: + tags: + - Resource + operationId: Resource_Upload + requestBody: + content: + multipart/form-data: + schema: + properties: + label: + type: string + nullable: true + type: + type: string + nullable: true + responses: + '200': + description: '' + content: + application/json: + schema: + type: string + '404': + description: '' + content: + application/json: + schema: + type: string + '500': + description: '' + content: + application/json: + schema: + type: string /api/Section: get: tags: @@ -1146,7 +1181,7 @@ components: lastBatteryLevel: type: string format: date-time - RessourceDTO: + ResourceDTO: type: object additionalProperties: false properties: @@ -1154,11 +1189,11 @@ components: type: string nullable: true type: - $ref: '#/components/schemas/RessourceType' + $ref: '#/components/schemas/ResourceType' label: type: string nullable: true - RessourceType: + ResourceType: type: string description: '' x-enumNames: @@ -1171,7 +1206,7 @@ components: - Video - ImageUrl - VideoUrl - RessourceDetailDTO: + ResourceDetailDTO: type: object additionalProperties: false properties: @@ -1179,7 +1214,7 @@ components: type: string nullable: true type: - $ref: '#/components/schemas/RessourceType' + $ref: '#/components/schemas/ResourceType' label: type: string nullable: true @@ -1343,8 +1378,8 @@ tags: description: Configuration management - name: Device description: Device management - - name: Ressource - description: Ressource management + - name: Resource + description: Resource management - name: Section description: Section management - name: User diff --git a/manager_api/test/resource_api_test.dart b/manager_api/test/resource_api_test.dart new file mode 100644 index 0000000..802d665 --- /dev/null +++ b/manager_api/test/resource_api_test.dart @@ -0,0 +1,55 @@ +// +// 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 ResourceApi +void main() { + final instance = ResourceApi(); + + group('tests for ResourceApi', () { + //Future resourceCreate(ResourceDetailDTO resourceDetailDTO) async + test('test resourceCreate', () async { + // TODO + }); + + //Future resourceDelete(String id) async + test('test resourceDelete', () async { + // TODO + }); + + //Future> resourceGet() async + test('test resourceGet', () async { + // TODO + }); + + //Future resourceGetDetail(String id) async + test('test resourceGetDetail', () async { + // TODO + }); + + //Future resourceShow(String id) async + test('test resourceShow', () async { + // TODO + }); + + //Future resourceUpdate(ResourceDetailDTO resourceDetailDTO) async + test('test resourceUpdate', () async { + // TODO + }); + + //Future resourceUpload(ResourceDetailDTO resourceDetailDTO) async + test('test resourceUpload', () async { + // TODO + }); + + }); +} diff --git a/manager_api/test/resource_detail_dto_test.dart b/manager_api/test/resource_detail_dto_test.dart new file mode 100644 index 0000000..4f2b4fe --- /dev/null +++ b/manager_api/test/resource_detail_dto_test.dart @@ -0,0 +1,46 @@ +// +// 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 ResourceDetailDTO +void main() { + final instance = ResourceDetailDTO(); + + group('test ResourceDetailDTO', () { + // String id + test('to test the property `id`', () async { + // TODO + }); + + // RessourceType type + test('to test the property `type`', () async { + // TODO + }); + + // String label + test('to test the property `label`', () async { + // TODO + }); + + // DateTime dateCreation + test('to test the property `dateCreation`', () async { + // TODO + }); + + // String data + test('to test the property `data`', () async { + // TODO + }); + + + }); + +} diff --git a/manager_api/test/resource_dto_test.dart b/manager_api/test/resource_dto_test.dart new file mode 100644 index 0000000..e48820d --- /dev/null +++ b/manager_api/test/resource_dto_test.dart @@ -0,0 +1,36 @@ +// +// 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 ResourceDTO +void main() { + final instance = ResourceDTO(); + + group('test ResourceDTO', () { + // String id + test('to test the property `id`', () async { + // TODO + }); + + // RessourceType type + test('to test the property `type`', () async { + // TODO + }); + + // String label + test('to test the property `label`', () async { + // TODO + }); + + + }); + +} diff --git a/manager_api/test/resource_type_test.dart b/manager_api/test/resource_type_test.dart new file mode 100644 index 0000000..d96076b --- /dev/null +++ b/manager_api/test/resource_type_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 ResourceType +void main() { + + group('test ResourceType', () { + + }); + +} diff --git a/pubspec.lock b/pubspec.lock index 7386a11..a410f63 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -8,6 +8,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.5.0" + audio_video_progress_bar: + dependency: transitive + description: + name: audio_video_progress_bar + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.2" auto_size_text: dependency: "direct main" description: @@ -64,6 +71,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.3" + dart_vlc: + dependency: "direct main" + description: + name: dart_vlc + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.6" fake_async: dependency: transitive description: @@ -78,13 +92,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.0" - file_picker: - dependency: "direct main" + file: + dependency: transitive description: - name: file_picker + name: file url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "6.1.0" filepicker_windows: dependency: "direct main" description: @@ -104,13 +118,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.4.0" - flutter_plugin_android_lifecycle: - dependency: transitive - description: - name: flutter_plugin_android_lifecycle - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" flutter_test: dependency: "direct dev" description: flutter @@ -198,6 +205,41 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" + path_provider: + dependency: transitive + description: + name: path_provider + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + path_provider_macos: + dependency: transitive + description: + name: path_provider_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" pedantic: dependency: transitive description: @@ -205,6 +247,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.11.0" + platform: + dependency: transitive + description: + name: platform + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" plugin_platform_interface: dependency: transitive description: @@ -212,6 +261,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" + process: + dependency: transitive + description: + name: process + url: "https://pub.dartlang.org" + source: hosted + version: "4.2.1" provider: dependency: "direct main" description: @@ -287,6 +343,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.0" + video_player: + dependency: "direct main" + description: + name: video_player + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + video_player_platform_interface: + dependency: transitive + description: + name: video_player_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "4.1.0" + video_player_web: + dependency: transitive + description: + name: video_player_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" win32: dependency: transitive description: @@ -294,6 +371,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.5" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0" sdks: dart: ">=2.12.0 <3.0.0" - flutter: ">=1.20.0" + flutter: ">=2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index f2deb10..497f46d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -33,6 +33,8 @@ dependencies: convert: ^3.0.0 collection: any filepicker_windows: ^2.0.0 + dart_vlc: ^0.0.6 + video_player: ^2.1.1 managerapi: path: manager_api diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 8b6d468..869167c 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,6 +6,9 @@ #include "generated_plugin_registrant.h" +#include void RegisterPlugins(flutter::PluginRegistry* registry) { + DartVlcPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("DartVlcPlugin")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 4d10c25..8385b22 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + dart_vlc ) set(PLUGIN_BUNDLED_LIBRARIES)