added update sent. No idea if it works

This commit is contained in:
Nico
2024-03-23 14:15:44 +01:00
parent d1ce04d2d0
commit b781f91d15
3 changed files with 19 additions and 11 deletions

View File

@@ -1,6 +1,5 @@
todo: todo:
maybe auch vorschläge aus templates in dropdown menüs anzeigen maybe auch vorschläge aus templates in dropdown menüs anzeigen
eintrag in db wenn http response (in sent column)
nachricht wenn einstellungen erfolgreich geändert nachricht wenn einstellungen erfolgreich geändert
abbaudat leer abbaudat leer
beim nächsten schritt als template beim nächsten schritt als template
@@ -25,6 +24,8 @@ textdateien auch an server senden
ausvon und ausbis fixen (falsches datum übergeben (20000-01-01)) ausvon und ausbis fixen (falsches datum übergeben (20000-01-01))
keine ahnung obs funktioniert:
eintrg in db wenn http response (in sent column)
not to do: not to do:

View File

@@ -262,6 +262,7 @@ class _AddCamMainState extends State<AddCamMain> {
await saveFile(); await saveFile();
// ignore: use_build_context_synchronously // ignore: use_build_context_synchronously
Navigator.pushNamedAndRemoveUntil( Navigator.pushNamedAndRemoveUntil(
// ignore: use_build_context_synchronously
context, '/home', (route) => false); context, '/home', (route) => false);
}, },
child: Text(AppLocalizations.of(context)!.saveasfile)) child: Text(AppLocalizations.of(context)!.saveasfile))
@@ -273,15 +274,8 @@ class _AddCamMainState extends State<AddCamMain> {
void _httpRequest() async { void _httpRequest() async {
Map<String, dynamic> place = getPlace(); Map<String, dynamic> place = getPlace();
/* final response = await http.post(
Uri.parse('http://192.168.1.106/www.dbb-wolf.de/data/_app24.php'),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body: '{"test": "test"}'
); */
print(jsonEncode(place)); // print(jsonEncode(place));
final dio = Dio(); final dio = Dio();
final SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs = await SharedPreferences.getInstance();
@@ -295,14 +289,19 @@ class _AddCamMainState extends State<AddCamMain> {
data: jsonEncode(place)); data: jsonEncode(place));
} on DioException catch (e) { } on DioException catch (e) {
if (e.response?.statusCode == 500) { if (e.response?.statusCode == 500) {
print('-------------------------'); /* print('-------------------------');
print('code 500'); print('code 500'); */
return; return;
} }
} }
if (response.statusCode == 201) { if (response.statusCode == 201) {
print(response.statusCode); print(response.statusCode);
// TODO Hackal setzen // TODO Hackal setzen
var placeDB = DBHelper();
placeDB.updateSent();
} else { } else {
print(response.statusCode); print(response.statusCode);
} }

View File

@@ -63,6 +63,13 @@ class DBHelper {
); );
} }
// function to update the sent value
Future<void> updateSent() async {
var placeDBClient = await placeDB;
placeDBClient.update('place', true as Map<String, Object?>, where: 'CID = ?', whereArgs: ['CID']);
}
// same thing as before but with templatews // same thing as before but with templatews
Future<void> addTemplate(Map<String, dynamic> templates) async { Future<void> addTemplate(Map<String, dynamic> templates) async {
var placeDBClient = await placeDB; var placeDBClient = await placeDB;
@@ -95,6 +102,7 @@ class DBHelper {
); );
} }
// get the finished entries from db // get the finished entries from db
Future<List<Map<String, dynamic>>> getPlace() async { Future<List<Map<String, dynamic>>> getPlace() async {
var placeDBClient = await placeDB; var placeDBClient = await placeDB;