Update logic
This commit is contained in:
parent
375e874c0b
commit
42c442b145
@ -38,7 +38,7 @@ class _ConfigurationsScreenState extends State<ConfigurationsScreen> {
|
|||||||
return Align(
|
return Align(
|
||||||
alignment: AlignmentDirectional.topCenter,
|
alignment: AlignmentDirectional.topCenter,
|
||||||
child: FutureBuilder(
|
child: FutureBuilder(
|
||||||
future: getConfigurations(appContext),
|
future: getConfigurations(managerAppContext),
|
||||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
var tempOutput = new List<ConfigurationDTO>.from(snapshot.data);
|
var tempOutput = new List<ConfigurationDTO>.from(snapshot.data);
|
||||||
@ -133,8 +133,8 @@ class _ConfigurationsScreenState extends State<ConfigurationsScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<ConfigurationDTO>> getConfigurations(dynamic appContext) async {
|
Future<List<ConfigurationDTO>> getConfigurations(ManagerAppContext managerAppContext) async {
|
||||||
List<ConfigurationDTO> configurations = await appContext.getContext().clientAPI.configurationApi.configurationGet();
|
List<ConfigurationDTO> configurations = await managerAppContext.clientAPI.configurationApi.configurationGet(instanceId: managerAppContext.instanceId);
|
||||||
//print("number of configurations " + configurations.length.toString());
|
//print("number of configurations " + configurations.length.toString());
|
||||||
configurations.forEach((element) {
|
configurations.forEach((element) {
|
||||||
//print(element);
|
//print(element);
|
||||||
|
|||||||
@ -12,57 +12,63 @@ import 'package:managerapi/api.dart';
|
|||||||
|
|
||||||
void showNewConfiguration(AppContext appContext, ValueChanged<bool> isImport, BuildContext context, BuildContext mainContext) {
|
void showNewConfiguration(AppContext appContext, ValueChanged<bool> isImport, BuildContext context, BuildContext mainContext) {
|
||||||
ConfigurationDTO configurationDTO = new ConfigurationDTO();
|
ConfigurationDTO configurationDTO = new ConfigurationDTO();
|
||||||
|
Size size = MediaQuery.of(mainContext).size;
|
||||||
|
|
||||||
showDialog(
|
showDialog(
|
||||||
builder: (BuildContext context) => AlertDialog(
|
builder: (BuildContext context) => AlertDialog(
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.all(Radius.circular(20.0))
|
borderRadius: BorderRadius.all(Radius.circular(20.0))
|
||||||
),
|
),
|
||||||
content: SingleChildScrollView(
|
content: SingleChildScrollView(
|
||||||
child: Column(
|
child: SizedBox(
|
||||||
children: [
|
width: size.width*0.3,
|
||||||
Text("Nouvelle configuration", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
|
height: size.height*0.3,
|
||||||
Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
StringInputContainer(
|
Text("Nouvelle configuration", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
|
||||||
label: "Nom :",
|
Column(
|
||||||
initialValue: configurationDTO.label,
|
children: [
|
||||||
onChanged: (value) {
|
StringInputContainer(
|
||||||
configurationDTO.label = value;
|
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
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
],
|
||||||
]
|
),
|
||||||
)
|
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: <Widget>[
|
actions: <Widget>[
|
||||||
|
|||||||
@ -137,7 +137,8 @@ Future<ResourceDTO> create(ResourceDTO resourceDTO, List<File> files, List<Platf
|
|||||||
// test if Correct url
|
// test if Correct url
|
||||||
bool _validURL = Uri.parse(resourceDTO.data).isAbsolute;
|
bool _validURL = Uri.parse(resourceDTO.data).isAbsolute;
|
||||||
if(_validURL) {
|
if(_validURL) {
|
||||||
ResourceDTO newResource = await appContext.getContext().clientAPI.resourceApi.resourceCreate(resourceDTO);
|
resourceDTO.instanceId = (appContext.getContext() as ManagerAppContext).instanceId;
|
||||||
|
ResourceDTO newResource = await (appContext.getContext() as ManagerAppContext).clientAPI.resourceApi.resourceCreate(resourceDTO);
|
||||||
showNotification(Colors.green, kWhite, 'La ressource a été créée avec succès', context, null);
|
showNotification(Colors.green, kWhite, 'La ressource a été créée avec succès', context, null);
|
||||||
|
|
||||||
return newResource;
|
return newResource;
|
||||||
|
|||||||
@ -117,10 +117,6 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
var url = window.location.href;
|
|
||||||
if(url.contains("fortsaintheribert")) {
|
|
||||||
this.pageTitle = "Fort de Saint Héribert";
|
|
||||||
}
|
|
||||||
this.isRememberMe = widget.session.rememberMe;
|
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.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;
|
//this.email = "test@email.be"; //widget.session.email;
|
||||||
@ -128,11 +124,37 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
super.initState();
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final appContext = Provider.of<AppContext>(context);
|
final appContext = Provider.of<AppContext>(context);
|
||||||
Size size = MediaQuery.of(context).size;
|
Size size = MediaQuery.of(context).size;
|
||||||
|
|
||||||
|
initInstance(appContext.getContext());
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Center(
|
body: Center(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user