未確認だが問題回避のためプッシュ

This commit is contained in:
2024-04-09 01:58:25 +09:00
parent dd9dd0d087
commit 1b4073f690
59 changed files with 2384 additions and 410 deletions

View File

@ -1,6 +1,8 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:rogapp/model/auth_user.dart';
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import '../utils/const.dart';
@ -90,16 +92,35 @@ class AuthService {
String url = '$serverUrl/api/login/';
//print('++++++++$url');
//String url = 'http://localhost:8100/api/login/';
final http.Response response = await http.post(
Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body: jsonEncode(<String, String>{'email': email, 'password': password}),
);
try {
final http.Response response = await http.post(
Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body: jsonEncode(
<String, String>{'email': email, 'password': password}),
);
if (response.statusCode == 200) {
cats = json.decode(utf8.decode(response.bodyBytes));
if (response.statusCode == 200) {
cats = json.decode(utf8.decode(response.bodyBytes));
} else {
print('Login failed with status code: ${response.statusCode}');
cats = {};
}
} catch( e ){
print('Error in login: $e');
Get.snackbar("通信エラーがおきました", "サーバーと通信できませんでした");
Get.snackbar(
"通信エラーがおきました",
"サーバーと通信できませんでした",
icon: const Icon(
Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(seconds: 3),
backgroundColor: Colors.yellow,
);
cats = {};
}
return cats;
}

View File

@ -1,5 +1,5 @@
import 'dart:io';
//import 'package:device_info/device_info.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/foundation.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:device_info_plus/device_info_plus.dart';

View File

@ -9,7 +9,7 @@ class ErrorService {
final String errorMessage = error.toString();
final String stackTraceString = stackTrace.toString();
final String estimatedCause = _estimateErrorCause(errorMessage);
// final String deviceInfo = await _getDeviceInfo();
//final String deviceInfo = await _getDeviceInfo();
final Uri url = Uri.parse('https://rogaining.sumasen.net/report-error');
final response = await http.post(
@ -44,5 +44,17 @@ class ErrorService {
return '不明なエラー';
}
}
/*
// 2024-4-8 Akira: メモリ使用量のチェックのため追加 See #2810
//
static void reportMemoryError(String message, StackTrace stackTrace) async {
final errorDetails = FlutterErrorDetails(
exception: Exception(message),
stack: stackTrace,
);
await reportError(errorDetails.exception, errorDetails.stack ?? StackTrace.current, deviceInfo);
}
*/
}

View File

@ -114,64 +114,69 @@ class ExternalService {
//print("~~~~ before calling api 1 ~~~~");
final http.Response response = await http.post(
Uri.parse(url1),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Token $token'
},
// 'id', 'user', 'goalimage', 'goaltime', 'team_name', 'event_code','cp_number'
body: jsonEncode(<String, String>{
'user': userId.toString(),
'team_name': teamname,
'event_code': eventcode,
'checkinimage': im1_64,
'checkintime': checkinTime,
'cp_number': cp.toString()
}),
);
res = json.decode(utf8.decode(response.bodyBytes));
//print("~~~~ api1 result $res ~~~~");
//print("-----@@@@@ checkin $_res -----");
if (response.statusCode == 201) {
//print("~~~~ image from api1 ${res["checkinimage"].toString()} ~~~~");
//print('---- toekn is ${token} -----');
//print("~~~~ token is $token ~~~~");
//print("~~~~ before callling api2 ~~~~");
final http.Response response2 = await http.post(
Uri.parse(url),
try {
final http.Response response = await http.post(
Uri.parse(url1),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Token $token'
},
// 'id', 'user', 'goalimage', 'goaltime', 'team_name', 'event_code','cp_number'
body: jsonEncode(<String, String>{
'user': userId.toString(),
'team_name': teamname,
'event_code': eventcode,
'checkinimage': im1_64,
'checkintime': checkinTime,
'cp_number': cp.toString()
}),
);
res = json.decode(utf8.decode(response.bodyBytes));
//print("~~~~ api1 result $res ~~~~");
//print("-----@@@@@ checkin $_res -----");
if (response.statusCode == 201) {
//print("~~~~ image from api1 ${res["checkinimage"].toString()} ~~~~");
//print('---- toekn is ${token} -----');
//print("~~~~ token is $token ~~~~");
//print("~~~~ before callling api2 ~~~~");
final http.Response response2 = await http.post(
Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body: jsonEncode(<String, String>{
'team_name': teamname,
'cp_number': cp.toString(),
'event_code': eventcode,
'image': res["checkinimage"].toString().replaceAll(
'http://localhost:8100', 'http://rogaining.sumasen.net')
}),
);
var vv = jsonEncode(<String, String>{
'team_name': teamname,
'cp_number': cp.toString(),
'event_code': eventcode,
'image': res["checkinimage"].toString().replaceAll(
'http://localhost:8100', 'http://rogaining.sumasen.net')
}),
);
var vv = jsonEncode(<String, String>{
'team_name': teamname,
'cp_number': cp.toString(),
'event_code': eventcode,
'image': res["checkinimage"].toString().replaceAll(
'http://localhost:8100', 'http://rogaining.sumasen.net')
});
//print("~~~~ api 2 values $vv ~~~~");
//print("--json-- $vv");
//print("--- checnin response ${response2.statusCode}----");
if (response2.statusCode == 200) {
res = json.decode(utf8.decode(response2.bodyBytes));
//print('----checkin res _res : $res ----');
if (res["status"] == "ERROR") {
Get.snackbar("エラーがおきました", res["detail"]);
});
//print("~~~~ api 2 values $vv ~~~~");
//print("--json-- $vv");
//print("--- checnin response ${response2.statusCode}----");
if (response2.statusCode == 200) {
res = json.decode(utf8.decode(response2.bodyBytes));
//print('----checkin res _res : $res ----');
if (res["status"] == "ERROR") {
Get.snackbar("エラーがおきました", res["detail"]);
}
}
} else {
Get.snackbar("サーバーエラーがおきました", "サーバーと通信できませんでした");
}
} else {
Get.snackbar("エラーがおきました", "サーバーに更新できませんでした");
} catch( e ) {
print('Error in makeCheckpoint: $e');
Get.snackbar("通信エラーがおきました", "サーバーと通信できませんでした");
}
}
} else {