mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-14 05:52:51 +00:00
Added statistics settings
This commit is contained in:
parent
56943ec73d
commit
44d7da9977
13 changed files with 579 additions and 393 deletions
|
@ -4,6 +4,7 @@ import 'package:sentry_flutter/sentry_flutter.dart';
|
|||
|
||||
import 'package:adguard_home_manager/models/blocked_services.dart';
|
||||
import 'package:adguard_home_manager/models/querylog_config.dart';
|
||||
import 'package:adguard_home_manager/models/statistics_config.dart';
|
||||
import 'package:adguard_home_manager/models/dns_info.dart';
|
||||
import 'package:adguard_home_manager/models/encryption.dart';
|
||||
import 'package:adguard_home_manager/models/dhcp.dart';
|
||||
|
@ -881,4 +882,38 @@ class ApiClientV2 {
|
|||
content: result.body != null ? jsonDecode(result.body!) : null
|
||||
);
|
||||
}
|
||||
|
||||
Future<ApiResponse> getStatisticsConfig() async {
|
||||
final result = await HttpRequestClient.get(urlPath: '/stats/config', server: server);
|
||||
if (result.successful) {
|
||||
try {
|
||||
return ApiResponse(
|
||||
successful: true,
|
||||
content: StatisticsConfig.fromJson(jsonDecode(result.body!))
|
||||
);
|
||||
} catch (e, stackTrace) {
|
||||
Sentry.captureException(
|
||||
e,
|
||||
stackTrace: stackTrace,
|
||||
hint: Hint.withMap({ "statusCode": result.statusCode.toString() })
|
||||
);
|
||||
return const ApiResponse(successful: false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return const ApiResponse(successful: false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse> updateStatisticsSettings({
|
||||
required Map<String, dynamic> body
|
||||
}) async {
|
||||
final result = await HttpRequestClient.put(
|
||||
urlPath: '/stats/config/update',
|
||||
server: server,
|
||||
body: body
|
||||
);
|
||||
print(result.body);
|
||||
return ApiResponse(successful: result.successful);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue