From b781f91d155f6cca0706eda410089b13cb8e29c3 Mon Sep 17 00:00:00 2001 From: Nico Date: Sat, 23 Mar 2024 14:15:44 +0100 Subject: [PATCH] added update sent. No idea if it works --- Todo.txt | 3 ++- lib/addCam/add_cam_main.dart | 19 +++++++++---------- lib/db_helper.dart | 8 ++++++++ 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Todo.txt b/Todo.txt index f9de3f7..ff0ddfc 100644 --- a/Todo.txt +++ b/Todo.txt @@ -1,6 +1,5 @@ todo: 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 abbaudat leer 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)) +keine ahnung obs funktioniert: +eintrg in db wenn http response (in sent column) not to do: diff --git a/lib/addCam/add_cam_main.dart b/lib/addCam/add_cam_main.dart index 0267428..76336df 100644 --- a/lib/addCam/add_cam_main.dart +++ b/lib/addCam/add_cam_main.dart @@ -262,6 +262,7 @@ class _AddCamMainState extends State { await saveFile(); // ignore: use_build_context_synchronously Navigator.pushNamedAndRemoveUntil( + // ignore: use_build_context_synchronously context, '/home', (route) => false); }, child: Text(AppLocalizations.of(context)!.saveasfile)) @@ -273,15 +274,8 @@ class _AddCamMainState extends State { void _httpRequest() async { Map place = getPlace(); -/* final response = await http.post( - Uri.parse('http://192.168.1.106/www.dbb-wolf.de/data/_app24.php'), - headers: { - 'Content-Type': 'application/json; charset=UTF-8', - }, - body: '{"test": "test"}' - ); */ - print(jsonEncode(place)); + // print(jsonEncode(place)); final dio = Dio(); final SharedPreferences prefs = await SharedPreferences.getInstance(); @@ -295,14 +289,19 @@ class _AddCamMainState extends State { data: jsonEncode(place)); } on DioException catch (e) { if (e.response?.statusCode == 500) { - print('-------------------------'); - print('code 500'); +/* print('-------------------------'); + print('code 500'); */ return; } } if (response.statusCode == 201) { print(response.statusCode); // TODO Hackal setzen + + + var placeDB = DBHelper(); + + placeDB.updateSent(); } else { print(response.statusCode); } diff --git a/lib/db_helper.dart b/lib/db_helper.dart index adac89a..660ba53 100644 --- a/lib/db_helper.dart +++ b/lib/db_helper.dart @@ -63,6 +63,13 @@ class DBHelper { ); } + // function to update the sent value + Future updateSent() async { + var placeDBClient = await placeDB; + + placeDBClient.update('place', true as Map, where: 'CID = ?', whereArgs: ['CID']); + } + // same thing as before but with templatews Future addTemplate(Map templates) async { var placeDBClient = await placeDB; @@ -95,6 +102,7 @@ class DBHelper { ); } + // get the finished entries from db Future>> getPlace() async { var placeDBClient = await placeDB;