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