Skip to content
Snippets Groups Projects
Commit 4252ee6b authored by Maximilian Betz's avatar Maximilian Betz
Browse files

added label id prefix and rest url fields to configuration widget and datamodel

parent 6af74716
No related branches found
No related tags found
1 merge request!1Devices also Contact Based
......@@ -192,6 +192,7 @@ class _MyHomePageState extends State<Configuration> {
try {
futureCollections = connector.fetchCollections();
await futureCollections; //wait and catch error here!
// TODO: fallback to current collection from configuration.currentCollection in case the query fails of being offline.
setState(() {});
}catch(e){
......@@ -249,6 +250,34 @@ class _MyHomePageState extends State<Configuration> {
style: TextStyle(fontSize: 14)
),
const SizedBox(height: 50),
TextFormField(
keyboardType: TextInputType.text,
autofocus: false,
initialValue: configuration.labelConfig.prefix,
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: 'Label Prefix',
hintText: '',
),
onChanged: (value) {
configuration.labelConfig.prefix = value;
},
),
const SizedBox(height: 15.0),
TextFormField(
keyboardType: TextInputType.number,
autofocus: false,
initialValue: configuration.labelConfig.cnt.toString(),
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: 'Label count',
hintText: '',
),
onChanged: (value) {
configuration.labelConfig.cnt = value as int;
},
),
const SizedBox(height: 15.0),
TextFormField(
keyboardType: TextInputType.emailAddress,
autofocus: false,
......@@ -276,6 +305,20 @@ class _MyHomePageState extends State<Configuration> {
configuration.loginInformation.password = value;
},
),
const SizedBox(height: 15.0),
TextFormField(
keyboardType: TextInputType.text,
autofocus: false,
initialValue: configuration.restRequestUrl,
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: 'Label Prefix',
hintText: '',
),
onChanged: (value) {
configuration.restRequestUrl = value;
},
),
const SizedBox(height: 50),
FutureBuilder<List<Collection>>(
future: futureCollections,
......
......
......@@ -244,6 +244,25 @@ class EventType{
}
class LabelConfiguration{
int cnt;
String prefix;
LabelConfiguration(
this.cnt,
this.prefix
);
Map<String, dynamic> toJson() => {
"prefix": prefix,
"cnt": cnt
};
LabelConfiguration.fromJson(Map<String, dynamic> json)
: prefix = json['prefix'],
cnt = json['cnt'];
}
class SensorLogin{
String mail;
String password;
......@@ -273,6 +292,8 @@ abstract class ConfigurationStoreBase {
List<Device> devices = [];
List<EventType> eventTypes = [];
SensorLogin loginInformation = SensorLogin('', '');
LabelConfiguration labelConfig = LabelConfiguration(0, '');
String restRequestUrl = '';
bool initialized = false;
Map<String, dynamic> toMap() {
......@@ -282,6 +303,8 @@ abstract class ConfigurationStoreBase {
'devices': jsonEncode(devices),
'eventTypes': jsonEncode(eventTypes),
'initialized' : initialized,
'labelConfiguration' : jsonEncode(labelConfig),
'restRequestUrl' : restRequestUrl,
};
}
......@@ -314,6 +337,10 @@ abstract class ConfigurationStoreBase {
for (var element in dynList){
eventTypes.add(EventType.fromJson(element));
}
labelConfig = LabelConfiguration.fromJson(map['labelConfiguration']);
restRequestUrl = map['restRequestUrl'];
initialized = map['initialized'];
}
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment