Import / export config update
This commit is contained in:
parent
3765c1eacc
commit
cf7fd02599
@ -84,6 +84,7 @@ class _ImageInputContainerState extends State<ImageInputContainer> {
|
||||
future: getResource(resourceIdToShow, appContext),
|
||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
if (snapshot.data != null) {
|
||||
return Transform.scale(
|
||||
scale: isSmall ? size.aspectRatio * 0.5: size.aspectRatio * 0.9,
|
||||
child: AspectRatio(
|
||||
@ -93,6 +94,10 @@ class _ImageInputContainerState extends State<ImageInputContainer> {
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Text("No data");
|
||||
}
|
||||
|
||||
} else if (snapshot.connectionState == ConnectionState.none) {
|
||||
return Text("No data");
|
||||
} else {
|
||||
@ -137,9 +142,9 @@ class _ImageInputContainerState extends State<ImageInputContainer> {
|
||||
borderRadius: BorderRadius.circular(30.0),
|
||||
image: new DecorationImage(
|
||||
fit: widget.imageFit,
|
||||
image: new NetworkImage(
|
||||
image: resourceDTO.type != null ? new NetworkImage(
|
||||
resourceDTO.type == ResourceType.image ? appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resourceDTO.id : resourceDTO.data,
|
||||
),
|
||||
) : null,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:encrypt/encrypt.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:manager_app/Components/message_notification.dart';
|
||||
import 'package:manager_app/Models/session.dart';
|
||||
import 'package:manager_app/client.dart';
|
||||
@ -47,13 +49,10 @@ class FileHelper {
|
||||
return file.writeAsString(jsonEncode(exportConfigurationDTO.toJson()));
|
||||
}
|
||||
|
||||
Future<void> importConfiguration(String path, Client client, context) async {
|
||||
// Gets the file
|
||||
File file = File(path);
|
||||
|
||||
final contents = await file.readAsString();
|
||||
|
||||
ExportConfigurationDTO export = ExportConfigurationDTO.fromJson(jsonDecode(contents));
|
||||
Future<void> importConfiguration(FilePickerResult filePickerResult, String path, Client client, context) async {
|
||||
var fileTest = filePickerResult.files[0];
|
||||
String fileContent = utf8.decode(fileTest.bytes);
|
||||
ExportConfigurationDTO export = ExportConfigurationDTO.fromJson(jsonDecode(fileContent));
|
||||
try {
|
||||
String test = await client.configurationApi.configurationImport(export);
|
||||
if (test.contains("successfully")) {
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/painting.dart';
|
||||
import 'package:manager_app/Components/color_picker_input_container.dart';
|
||||
@ -19,6 +21,8 @@ import 'package:manager_app/constants.dart';
|
||||
import 'package:managerapi/api.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'dart:html' as html;
|
||||
|
||||
|
||||
class ConfigurationDetailScreen extends StatefulWidget {
|
||||
final String id;
|
||||
@ -82,9 +86,19 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
||||
// Export config
|
||||
Client clientAPI = appContext.getContext().clientAPI;
|
||||
ExportConfigurationDTO export = await clientAPI.configurationApi.configurationExport(configurationDTO.id);
|
||||
|
||||
if (kIsWeb) {
|
||||
html.AnchorElement anchorElement = new html.AnchorElement();
|
||||
var uri = (Uri.parse(appContext.getContext().clientAPI.resourceApi.apiClient.basePath+'/api/Configuration/${configurationDTO.id}/export'));
|
||||
anchorElement.href = uri.toString();
|
||||
anchorElement.download = '${configurationDTO.label}.json';
|
||||
anchorElement.click();
|
||||
} else {
|
||||
File test = await FileHelper().storeConfiguration(export);
|
||||
showNotification(Colors.green, kWhite, "L'export de la configuration a réussi, le document se trouve là : " + test.path, context, 3000);
|
||||
}
|
||||
} catch(e) {
|
||||
log(e);
|
||||
showNotification(kPrimaryColor, kWhite, "L'export de la configuration a échoué", context, null);
|
||||
}
|
||||
},
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
//import 'package:filepicker_windows/filepicker_windows.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:manager_app/Components/message_notification.dart';
|
||||
import 'package:manager_app/Components/rounded_button.dart';
|
||||
@ -40,9 +41,12 @@ void showNewConfiguration(AppContext appContext, ValueChanged<bool> isImport, Bu
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
String result = filePicker();
|
||||
FilePickerResult result = await FilePicker.platform.pickFiles();
|
||||
|
||||
//String result = filePicker();
|
||||
if (result != null) {
|
||||
await FileHelper().importConfiguration(result, appContext.getContext().clientAPI, mainContext);
|
||||
|
||||
await FileHelper().importConfiguration(result, null, appContext.getContext().clientAPI, mainContext);
|
||||
isImport(true);
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
63
pubspec.lock
63
pubspec.lock
@ -7,14 +7,14 @@ packages:
|
||||
name: args
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
version: "2.3.0"
|
||||
asn1lib:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: asn1lib
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
version: "1.1.0"
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -78,20 +78,27 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
csslib:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: csslib
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.17.1"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: cupertino_icons
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.3"
|
||||
version: "1.0.4"
|
||||
drag_and_drop_lists:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: drag_and_drop_lists
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.3.2"
|
||||
version: "0.3.2+2"
|
||||
encrypt:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -119,7 +126,7 @@ packages:
|
||||
name: file_picker
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.3.0"
|
||||
version: "4.5.1"
|
||||
flare_flutter:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -138,7 +145,7 @@ packages:
|
||||
name: flutter_colorpicker
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.6.0"
|
||||
version: "0.6.1"
|
||||
flutter_plugin_android_lifecycle:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -156,6 +163,13 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
html:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: html
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.15.0"
|
||||
http:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -225,7 +239,7 @@ packages:
|
||||
name: multiselect_formfield
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.6"
|
||||
version: "0.1.7"
|
||||
nested:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -260,14 +274,14 @@ packages:
|
||||
name: plugin_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
version: "2.1.2"
|
||||
pointycastle:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pointycastle
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.3.1"
|
||||
version: "3.5.2"
|
||||
provider:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -349,21 +363,42 @@ packages:
|
||||
name: video_player
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.14"
|
||||
version: "2.3.0"
|
||||
video_player_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: video_player_android
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.3.1"
|
||||
video_player_avfoundation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: video_player_avfoundation
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.3.1"
|
||||
video_player_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: video_player_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.1.0"
|
||||
version: "5.1.1"
|
||||
video_player_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: video_player_web
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.3"
|
||||
version: "2.0.7"
|
||||
win32:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.4.4"
|
||||
sdks:
|
||||
dart: ">=2.14.0 <3.0.0"
|
||||
flutter: ">=2.0.0"
|
||||
dart: ">=2.15.0 <3.0.0"
|
||||
flutter: ">=2.8.0"
|
||||
|
||||
@ -33,7 +33,7 @@ dependencies:
|
||||
convert: ^3.0.0
|
||||
collection: any
|
||||
#filepicker_windows: ^2.0.0
|
||||
file_picker: ^4.3.0
|
||||
file_picker: ^4.5.1
|
||||
flare_flutter: ^3.0.1
|
||||
#dart_vlc: ^0.0.6
|
||||
video_player: ^2.1.1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user