mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-04-23 15:29:13 +00:00
Fixed dhcp not available
This commit is contained in:
parent
300738ca14
commit
dd927bbd25
7 changed files with 15 additions and 17 deletions
|
@ -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."
|
||||
}
|
|
@ -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."
|
||||
}
|
|
@ -1,11 +1,9 @@
|
|||
import 'dart:convert';
|
||||
class DhcpModel {
|
||||
bool dhcpAvailable;
|
||||
List<NetworkInterface> networkInterfaces;
|
||||
DhcpStatus? dhcpStatus;
|
||||
|
||||
DhcpModel({
|
||||
required this.dhcpAvailable,
|
||||
required this.networkInterfaces,
|
||||
required this.dhcpStatus,
|
||||
});
|
||||
|
@ -83,8 +81,8 @@ class DhcpStatus {
|
|||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"interface_name": interfaceName,
|
||||
"v4": v4 != null ? v4!.toJson() : null,
|
||||
"v6": v6 != null ? v6!.toJson() : null,
|
||||
"v4": v4?.toJson(),
|
||||
"v6": v6?.toJson(),
|
||||
"leases": List<Lease>.from(leases.map((x) => x)),
|
||||
"static_leases": List<Lease>.from(staticLeases.map((x) => x)),
|
||||
"enabled": enabled,
|
||||
|
|
|
@ -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<String, dynamic> 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']
|
||||
);
|
||||
}
|
|
@ -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<DhcpScreen> {
|
|||
|
||||
@override
|
||||
void initState() {
|
||||
if (mounted) loadDhcpStatus();
|
||||
final statusProvider = Provider.of<StatusProvider>(context, listen: false);
|
||||
if (mounted && statusProvider.serverStatus?.dhcpAvailable == true) loadDhcpStatus();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final serversProvider = Provider.of<ServersProvider>(context);
|
||||
final statusProvider = Provider.of<StatusProvider>(context);
|
||||
final dhcpProvider = Provider.of<DhcpProvider>(context);
|
||||
final appConfigProvider = Provider.of<AppConfigProvider>(context);
|
||||
|
||||
|
@ -353,11 +356,7 @@ class _DhcpScreenState extends State<DhcpScreen> {
|
|||
});
|
||||
}
|
||||
|
||||
if (
|
||||
dhcpProvider.loadStatus == LoadStatus.loaded &&
|
||||
dhcpProvider.dhcp != null &&
|
||||
dhcpProvider.dhcp!.dhcpAvailable == false
|
||||
) {
|
||||
if (statusProvider.serverStatus?.dhcpAvailable != true) {
|
||||
return const DhcpNotAvailable();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1352,7 +1352,6 @@ class ApiClient {
|
|||
return {
|
||||
'result': 'success',
|
||||
'data': DhcpModel(
|
||||
dhcpAvailable: true,
|
||||
networkInterfaces: interfaces,
|
||||
dhcpStatus: DhcpStatus.fromJson(jsonDecode(result[1]['body']))
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue