Update logic
This commit is contained in:
parent
375e874c0b
commit
42c442b145
@ -38,7 +38,7 @@ class _ConfigurationsScreenState extends State<ConfigurationsScreen> {
|
||||
return Align(
|
||||
alignment: AlignmentDirectional.topCenter,
|
||||
child: FutureBuilder(
|
||||
future: getConfigurations(appContext),
|
||||
future: getConfigurations(managerAppContext),
|
||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
var tempOutput = new List<ConfigurationDTO>.from(snapshot.data);
|
||||
@ -133,8 +133,8 @@ class _ConfigurationsScreenState extends State<ConfigurationsScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<ConfigurationDTO>> getConfigurations(dynamic appContext) async {
|
||||
List<ConfigurationDTO> configurations = await appContext.getContext().clientAPI.configurationApi.configurationGet();
|
||||
Future<List<ConfigurationDTO>> getConfigurations(ManagerAppContext managerAppContext) async {
|
||||
List<ConfigurationDTO> configurations = await managerAppContext.clientAPI.configurationApi.configurationGet(instanceId: managerAppContext.instanceId);
|
||||
//print("number of configurations " + configurations.length.toString());
|
||||
configurations.forEach((element) {
|
||||
//print(element);
|
||||
|
||||
@ -12,12 +12,17 @@ import 'package:managerapi/api.dart';
|
||||
|
||||
void showNewConfiguration(AppContext appContext, ValueChanged<bool> 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: 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)),
|
||||
@ -65,6 +70,7 @@ void showNewConfiguration(AppContext appContext, ValueChanged<bool> isImport, Bu
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
actions: <Widget>[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
|
||||
@ -137,7 +137,8 @@ Future<ResourceDTO> create(ResourceDTO resourceDTO, List<File> files, List<Platf
|
||||
// test if Correct url
|
||||
bool _validURL = Uri.parse(resourceDTO.data).isAbsolute;
|
||||
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);
|
||||
|
||||
return newResource;
|
||||
|
||||
@ -117,10 +117,6 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
|
||||
@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<LoginScreen> {
|
||||
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<AppContext>(context);
|
||||
Size size = MediaQuery.of(context).size;
|
||||
|
||||
initInstance(appContext.getContext());
|
||||
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: SingleChildScrollView(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user