mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-04-21 06:19:10 +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.",
|
"startTimeBeforeEndTime": "Start time must be before end time.",
|
||||||
"noBlockingScheduleThisDevice": "There's no blocking schedule for this device.",
|
"noBlockingScheduleThisDevice": "There's no blocking schedule for this device.",
|
||||||
"selectTimezone": "Select a timezone",
|
"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.",
|
"startTimeBeforeEndTime": "La hora de inicio debe ser anterior a la hora de fin.",
|
||||||
"noBlockingScheduleThisDevice": "No hay programación de bloqueo para este dispositivo.",
|
"noBlockingScheduleThisDevice": "No hay programación de bloqueo para este dispositivo.",
|
||||||
"selectTimezone": "Selecciona una zona horaria",
|
"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';
|
import 'dart:convert';
|
||||||
class DhcpModel {
|
class DhcpModel {
|
||||||
bool dhcpAvailable;
|
|
||||||
List<NetworkInterface> networkInterfaces;
|
List<NetworkInterface> networkInterfaces;
|
||||||
DhcpStatus? dhcpStatus;
|
DhcpStatus? dhcpStatus;
|
||||||
|
|
||||||
DhcpModel({
|
DhcpModel({
|
||||||
required this.dhcpAvailable,
|
|
||||||
required this.networkInterfaces,
|
required this.networkInterfaces,
|
||||||
required this.dhcpStatus,
|
required this.dhcpStatus,
|
||||||
});
|
});
|
||||||
|
@ -83,8 +81,8 @@ class DhcpStatus {
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
"interface_name": interfaceName,
|
"interface_name": interfaceName,
|
||||||
"v4": v4 != null ? v4!.toJson() : null,
|
"v4": v4?.toJson(),
|
||||||
"v6": v6 != null ? v6!.toJson() : null,
|
"v6": v6?.toJson(),
|
||||||
"leases": List<Lease>.from(leases.map((x) => x)),
|
"leases": List<Lease>.from(leases.map((x) => x)),
|
||||||
"static_leases": List<Lease>.from(staticLeases.map((x) => x)),
|
"static_leases": List<Lease>.from(staticLeases.map((x) => x)),
|
||||||
"enabled": enabled,
|
"enabled": enabled,
|
||||||
|
|
|
@ -21,6 +21,7 @@ class ServerStatus {
|
||||||
bool? safeSearchPixabay;
|
bool? safeSearchPixabay;
|
||||||
bool? safeSearchYandex;
|
bool? safeSearchYandex;
|
||||||
bool? safeSearchYoutube;
|
bool? safeSearchYoutube;
|
||||||
|
bool dhcpAvailable;
|
||||||
|
|
||||||
ServerStatus({
|
ServerStatus({
|
||||||
required this.stats,
|
required this.stats,
|
||||||
|
@ -39,7 +40,8 @@ class ServerStatus {
|
||||||
required this.safeSearchDuckduckgo,
|
required this.safeSearchDuckduckgo,
|
||||||
required this.safeSearchPixabay,
|
required this.safeSearchPixabay,
|
||||||
required this.safeSearchYandex,
|
required this.safeSearchYandex,
|
||||||
required this.safeSearchYoutube
|
required this.safeSearchYoutube,
|
||||||
|
required this.dhcpAvailable,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory ServerStatus.fromJson(Map<String, dynamic> json) => ServerStatus(
|
factory ServerStatus.fromJson(Map<String, dynamic> json) => ServerStatus(
|
||||||
|
@ -64,5 +66,6 @@ class ServerStatus {
|
||||||
safeSearchPixabay: json['safeSearch']['pixabay'],
|
safeSearchPixabay: json['safeSearch']['pixabay'],
|
||||||
safeSearchYandex: json['safeSearch']['yandex'],
|
safeSearchYandex: json['safeSearch']['yandex'],
|
||||||
safeSearchYoutube: json['safeSearch']['youtube'],
|
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/screens/settings/dhcp/select_interface_modal.dart';
|
||||||
|
|
||||||
import 'package:adguard_home_manager/functions/desktop_mode.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/functions/snackbar.dart';
|
||||||
import 'package:adguard_home_manager/constants/enums.dart';
|
import 'package:adguard_home_manager/constants/enums.dart';
|
||||||
import 'package:adguard_home_manager/providers/dhcp_provider.dart';
|
import 'package:adguard_home_manager/providers/dhcp_provider.dart';
|
||||||
|
@ -182,13 +183,15 @@ class _DhcpScreenState extends State<DhcpScreen> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
if (mounted) loadDhcpStatus();
|
final statusProvider = Provider.of<StatusProvider>(context, listen: false);
|
||||||
|
if (mounted && statusProvider.serverStatus?.dhcpAvailable == true) loadDhcpStatus();
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final serversProvider = Provider.of<ServersProvider>(context);
|
final serversProvider = Provider.of<ServersProvider>(context);
|
||||||
|
final statusProvider = Provider.of<StatusProvider>(context);
|
||||||
final dhcpProvider = Provider.of<DhcpProvider>(context);
|
final dhcpProvider = Provider.of<DhcpProvider>(context);
|
||||||
final appConfigProvider = Provider.of<AppConfigProvider>(context);
|
final appConfigProvider = Provider.of<AppConfigProvider>(context);
|
||||||
|
|
||||||
|
@ -353,11 +356,7 @@ class _DhcpScreenState extends State<DhcpScreen> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (statusProvider.serverStatus?.dhcpAvailable != true) {
|
||||||
dhcpProvider.loadStatus == LoadStatus.loaded &&
|
|
||||||
dhcpProvider.dhcp != null &&
|
|
||||||
dhcpProvider.dhcp!.dhcpAvailable == false
|
|
||||||
) {
|
|
||||||
return const DhcpNotAvailable();
|
return const DhcpNotAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -490,9 +490,6 @@ class ApiClientV2 {
|
||||||
return ApiResponse(
|
return ApiResponse(
|
||||||
successful: true,
|
successful: true,
|
||||||
content: DhcpModel(
|
content: DhcpModel(
|
||||||
dhcpAvailable: jsonDecode(results[1].body!)['message'] != null
|
|
||||||
? false
|
|
||||||
: true,
|
|
||||||
networkInterfaces: interfaces,
|
networkInterfaces: interfaces,
|
||||||
dhcpStatus: jsonDecode(results[1].body!)['message'] != null
|
dhcpStatus: jsonDecode(results[1].body!)['message'] != null
|
||||||
? null
|
? null
|
||||||
|
|
|
@ -1352,7 +1352,6 @@ class ApiClient {
|
||||||
return {
|
return {
|
||||||
'result': 'success',
|
'result': 'success',
|
||||||
'data': DhcpModel(
|
'data': DhcpModel(
|
||||||
dhcpAvailable: true,
|
|
||||||
networkInterfaces: interfaces,
|
networkInterfaces: interfaces,
|
||||||
dhcpStatus: DhcpStatus.fromJson(jsonDecode(result[1]['body']))
|
dhcpStatus: DhcpStatus.fromJson(jsonDecode(result[1]['body']))
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue