diff --git a/lib/Screens/Configurations/configurations_screen.dart b/lib/Screens/Configurations/configurations_screen.dart index 6901ec5..e18b3e9 100644 --- a/lib/Screens/Configurations/configurations_screen.dart +++ b/lib/Screens/Configurations/configurations_screen.dart @@ -38,7 +38,7 @@ class _ConfigurationsScreenState extends State { return Align( alignment: AlignmentDirectional.topCenter, child: FutureBuilder( - future: getConfigurations(appContext), + future: getConfigurations(managerAppContext), builder: (context, AsyncSnapshot snapshot) { if (snapshot.connectionState == ConnectionState.done) { var tempOutput = new List.from(snapshot.data); @@ -133,8 +133,8 @@ class _ConfigurationsScreenState extends State { } } -Future> getConfigurations(dynamic appContext) async { - List configurations = await appContext.getContext().clientAPI.configurationApi.configurationGet(); +Future> getConfigurations(ManagerAppContext managerAppContext) async { + List configurations = await managerAppContext.clientAPI.configurationApi.configurationGet(instanceId: managerAppContext.instanceId); //print("number of configurations " + configurations.length.toString()); configurations.forEach((element) { //print(element); diff --git a/lib/Screens/Configurations/new_configuration_popup.dart b/lib/Screens/Configurations/new_configuration_popup.dart index a31d2b7..e916dff 100644 --- a/lib/Screens/Configurations/new_configuration_popup.dart +++ b/lib/Screens/Configurations/new_configuration_popup.dart @@ -12,57 +12,63 @@ import 'package:managerapi/api.dart'; void showNewConfiguration(AppContext appContext, ValueChanged isImport, BuildContext context, BuildContext mainContext) { ConfigurationDTO configurationDTO = new ConfigurationDTO(); + Size size = MediaQuery.of(mainContext).size; + showDialog( builder: (BuildContext context) => AlertDialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(20.0)) ), content: SingleChildScrollView( - child: Column( - children: [ - Text("Nouvelle configuration", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)), - Column( - children: [ - StringInputContainer( - label: "Nom :", - initialValue: configurationDTO.label, - onChanged: (value) { - configurationDTO.label = value; - }, - ), - ], - ), - Text("ou"), - Column( - children: [ - Padding( - padding: const EdgeInsets.only(bottom: 5.0), - child: Text("Importer", style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300)), - ), - InkWell( - onTap: () async { - FilePickerResult result = await FilePicker.platform.pickFiles(); - - //String result = filePicker(); - if (result != null) { - - await FileHelper().importConfiguration(result, null, appContext.getContext().clientAPI, mainContext); - isImport(true); - Navigator.of(context).pop(); - } - }, - child: Padding( - padding: const EdgeInsets.all(10.0), - child: Icon( - Icons.file_upload, - color: kPrimaryColor, - size: 30 - ), + child: SizedBox( + width: size.width*0.3, + height: size.height*0.3, + child: Column( + children: [ + Text("Nouvelle configuration", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)), + Column( + children: [ + StringInputContainer( + label: "Nom :", + initialValue: configurationDTO.label, + onChanged: (value) { + configurationDTO.label = value; + }, ), - ) - ] - ) - ], + ], + ), + Text("ou"), + Column( + children: [ + Padding( + padding: const EdgeInsets.only(bottom: 5.0), + child: Text("Importer", style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300)), + ), + InkWell( + onTap: () async { + FilePickerResult result = await FilePicker.platform.pickFiles(); + + //String result = filePicker(); + if (result != null) { + + await FileHelper().importConfiguration(result, null, appContext.getContext().clientAPI, mainContext); + isImport(true); + Navigator.of(context).pop(); + } + }, + child: Padding( + padding: const EdgeInsets.all(10.0), + child: Icon( + Icons.file_upload, + color: kPrimaryColor, + size: 30 + ), + ), + ) + ] + ) + ], + ), ), ), actions: [ diff --git a/lib/Screens/Resources/resources_screen.dart b/lib/Screens/Resources/resources_screen.dart index a113dc9..99417d7 100644 --- a/lib/Screens/Resources/resources_screen.dart +++ b/lib/Screens/Resources/resources_screen.dart @@ -137,7 +137,8 @@ Future create(ResourceDTO resourceDTO, List files, List { @override void initState() { - var url = window.location.href; - if(url.contains("fortsaintheribert")) { - this.pageTitle = "Fort de Saint Héribert"; - } this.isRememberMe = widget.session.rememberMe; this.host = "https://api.mymuseum.be"; // "http://localhost:5000" //widget.session.host; // MDLF "http://192.168.1.19:8089" // "https://api.mymuseum.be" //this.email = "test@email.be"; //widget.session.email; @@ -128,11 +124,37 @@ class _LoginScreenState extends State { super.initState(); } + ManagerAppContext initInstance(ManagerAppContext managerAppContext) { + var url = window.location.href; + if(!url.contains("localhost")) { + var urlParts = url.split('.'); + if(urlParts.length > 0) { + var subdomain = urlParts[0].replaceAll('https://', ''); + switch(subdomain) { + case "manager": + this.pageTitle = "MyMuseum"; + break; + case "fortsaintheribert": + this.pageTitle = "Fort de Saint Héribert"; + break; + } + } else { + print("subdomain not found"); + } + } else { + print("localhost.. set mymuseum instance by default"); + } + + return managerAppContext; + } + @override Widget build(BuildContext context) { final appContext = Provider.of(context); Size size = MediaQuery.of(context).size; + initInstance(appContext.getContext()); + return Scaffold( body: Center( child: SingleChildScrollView(