diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 6d473e5..723c08a 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -748,5 +748,6 @@ "startTimeBeforeEndTime": "Start time must be before end time.", "noBlockingScheduleThisDevice": "There's no blocking schedule for this device.", "selectTimezone": "Select a timezone", - "selectClientsFiltersInfo": "Select the clients you want to display. If no clients are selected, all will be displayed." + "selectClientsFiltersInfo": "Select the clients you want to display. If no clients are selected, all will be displayed.", + "noDataThisSection": "There's no data for this section." } \ No newline at end of file diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index 8180d4b..837d9d7 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -748,5 +748,6 @@ "startTimeBeforeEndTime": "La hora de inicio debe ser anterior a la hora de fin.", "noBlockingScheduleThisDevice": "No hay programación de bloqueo para este dispositivo.", "selectTimezone": "Selecciona una zona horaria", - "selectClientsFiltersInfo": "Selecciona los clientes que quieres mostrar. Si no hay clientes seleccionados, se mostrarán todos." + "selectClientsFiltersInfo": "Selecciona los clientes que quieres mostrar. Si no hay clientes seleccionados, se mostrarán todos.", + "noDataThisSection": "No hay datos para esta sección." } \ No newline at end of file diff --git a/lib/models/dhcp.dart b/lib/models/dhcp.dart index 9e7f7ca..7953f47 100644 --- a/lib/models/dhcp.dart +++ b/lib/models/dhcp.dart @@ -1,11 +1,9 @@ import 'dart:convert'; class DhcpModel { - bool dhcpAvailable; List networkInterfaces; DhcpStatus? dhcpStatus; DhcpModel({ - required this.dhcpAvailable, required this.networkInterfaces, required this.dhcpStatus, }); @@ -83,8 +81,8 @@ class DhcpStatus { Map toJson() => { "interface_name": interfaceName, - "v4": v4 != null ? v4!.toJson() : null, - "v6": v6 != null ? v6!.toJson() : null, + "v4": v4?.toJson(), + "v6": v6?.toJson(), "leases": List.from(leases.map((x) => x)), "static_leases": List.from(staticLeases.map((x) => x)), "enabled": enabled, diff --git a/lib/models/server_status.dart b/lib/models/server_status.dart index b43dbd1..fb7c1b4 100644 --- a/lib/models/server_status.dart +++ b/lib/models/server_status.dart @@ -21,6 +21,7 @@ class ServerStatus { bool? safeSearchPixabay; bool? safeSearchYandex; bool? safeSearchYoutube; + bool dhcpAvailable; ServerStatus({ required this.stats, @@ -39,7 +40,8 @@ class ServerStatus { required this.safeSearchDuckduckgo, required this.safeSearchPixabay, required this.safeSearchYandex, - required this.safeSearchYoutube + required this.safeSearchYoutube, + required this.dhcpAvailable, }); factory ServerStatus.fromJson(Map json) => ServerStatus( @@ -64,5 +66,6 @@ class ServerStatus { safeSearchPixabay: json['safeSearch']['pixabay'], safeSearchYandex: json['safeSearch']['yandex'], safeSearchYoutube: json['safeSearch']['youtube'], + dhcpAvailable: json['status']['dhcp_available'] ); } \ No newline at end of file diff --git a/lib/screens/settings/dhcp/dhcp.dart b/lib/screens/settings/dhcp/dhcp.dart index 75d1856..a17d620 100644 --- a/lib/screens/settings/dhcp/dhcp.dart +++ b/lib/screens/settings/dhcp/dhcp.dart @@ -15,6 +15,7 @@ import 'package:adguard_home_manager/screens/settings/dhcp/dhcp_leases.dart'; import 'package:adguard_home_manager/screens/settings/dhcp/select_interface_modal.dart'; import 'package:adguard_home_manager/functions/desktop_mode.dart'; +import 'package:adguard_home_manager/providers/status_provider.dart'; import 'package:adguard_home_manager/functions/snackbar.dart'; import 'package:adguard_home_manager/constants/enums.dart'; import 'package:adguard_home_manager/providers/dhcp_provider.dart'; @@ -182,13 +183,15 @@ class _DhcpScreenState extends State { @override void initState() { - if (mounted) loadDhcpStatus(); + final statusProvider = Provider.of(context, listen: false); + if (mounted && statusProvider.serverStatus?.dhcpAvailable == true) loadDhcpStatus(); super.initState(); } @override Widget build(BuildContext context) { final serversProvider = Provider.of(context); + final statusProvider = Provider.of(context); final dhcpProvider = Provider.of(context); final appConfigProvider = Provider.of(context); @@ -353,11 +356,7 @@ class _DhcpScreenState extends State { }); } - if ( - dhcpProvider.loadStatus == LoadStatus.loaded && - dhcpProvider.dhcp != null && - dhcpProvider.dhcp!.dhcpAvailable == false - ) { + if (statusProvider.serverStatus?.dhcpAvailable != true) { return const DhcpNotAvailable(); } diff --git a/lib/services/api_client.dart b/lib/services/api_client.dart index b122a8c..0abb737 100644 --- a/lib/services/api_client.dart +++ b/lib/services/api_client.dart @@ -490,9 +490,6 @@ class ApiClientV2 { return ApiResponse( successful: true, content: DhcpModel( - dhcpAvailable: jsonDecode(results[1].body!)['message'] != null - ? false - : true, networkInterfaces: interfaces, dhcpStatus: jsonDecode(results[1].body!)['message'] != null ? null diff --git a/lib/services/http_requests.dart b/lib/services/http_requests.dart index 37a2cc8..2d001f2 100644 --- a/lib/services/http_requests.dart +++ b/lib/services/http_requests.dart @@ -1352,7 +1352,6 @@ class ApiClient { return { 'result': 'success', 'data': DhcpModel( - dhcpAvailable: true, networkInterfaces: interfaces, dhcpStatus: DhcpStatus.fromJson(jsonDecode(result[1]['body'])) )