2023-04-12 23:26:50 +02:00
|
|
|
import 'package:adguard_home_manager/functions/time_server_disabled.dart';
|
2022-10-22 03:16:08 +02:00
|
|
|
import 'package:adguard_home_manager/models/clients.dart';
|
2022-09-27 12:43:25 +02:00
|
|
|
import 'package:adguard_home_manager/models/dns_statistics.dart';
|
2022-12-31 17:11:57 +01:00
|
|
|
import 'package:adguard_home_manager/models/filtering_status.dart';
|
2022-09-27 12:43:25 +02:00
|
|
|
|
|
|
|
class ServerStatus {
|
2022-09-27 14:29:36 +02:00
|
|
|
int loadStatus;
|
|
|
|
ServerStatusData? data;
|
|
|
|
|
|
|
|
ServerStatus({
|
|
|
|
required this.loadStatus,
|
|
|
|
this.data
|
|
|
|
});
|
|
|
|
}
|
|
|
|
class ServerStatusData {
|
2022-09-27 12:43:25 +02:00
|
|
|
final DnsStatistics stats;
|
2022-10-22 03:16:08 +02:00
|
|
|
final List<Client> clients;
|
2022-12-31 17:11:57 +01:00
|
|
|
final FilteringStatus filteringStatus;
|
2023-04-12 23:26:50 +02:00
|
|
|
int timeGeneralDisabled;
|
|
|
|
DateTime? disabledUntil;
|
2022-09-27 22:49:58 +02:00
|
|
|
bool generalEnabled;
|
|
|
|
bool filteringEnabled;
|
|
|
|
bool safeSearchEnabled;
|
|
|
|
bool safeBrowsingEnabled;
|
|
|
|
bool parentalControlEnabled;
|
2022-09-27 12:43:25 +02:00
|
|
|
|
2022-09-27 22:49:58 +02:00
|
|
|
ServerStatusData({
|
2022-09-27 12:43:25 +02:00
|
|
|
required this.stats,
|
2022-10-22 03:16:08 +02:00
|
|
|
required this.clients,
|
2022-12-31 17:11:57 +01:00
|
|
|
required this.filteringStatus,
|
2023-04-12 23:26:50 +02:00
|
|
|
required this.timeGeneralDisabled,
|
|
|
|
this.disabledUntil,
|
2022-09-27 12:43:25 +02:00
|
|
|
required this.generalEnabled,
|
|
|
|
required this.filteringEnabled,
|
|
|
|
required this.safeSearchEnabled,
|
|
|
|
required this.safeBrowsingEnabled,
|
|
|
|
required this.parentalControlEnabled
|
|
|
|
});
|
|
|
|
|
2022-09-27 14:29:36 +02:00
|
|
|
factory ServerStatusData.fromJson(Map<String, dynamic> json) => ServerStatusData(
|
2022-09-27 12:43:25 +02:00
|
|
|
stats: DnsStatistics.fromJson(json['stats']),
|
2022-10-22 03:16:08 +02:00
|
|
|
clients: json["clients"] != null ? List<Client>.from(json["clients"].map((x) => Client.fromJson(x))) : [],
|
2022-09-27 12:43:25 +02:00
|
|
|
generalEnabled: json['generalEnabled']['protection_enabled'],
|
2023-04-12 23:26:50 +02:00
|
|
|
timeGeneralDisabled: json['generalEnabled']['protection_disabled_duration'] ?? 0,
|
|
|
|
disabledUntil: json['generalEnabled']['protection_disabled_duration'] > 0
|
|
|
|
? generateTimeDeadline(json['generalEnabled']['protection_disabled_duration'])
|
|
|
|
: null ,
|
2022-12-31 17:11:57 +01:00
|
|
|
filteringStatus: FilteringStatus.fromJson(json['filtering']),
|
|
|
|
filteringEnabled: json['filtering']['enabled'],
|
2022-09-27 12:43:25 +02:00
|
|
|
safeSearchEnabled: json['safeSearchEnabled']['enabled'],
|
|
|
|
safeBrowsingEnabled: json['safeBrowsingEnabled']['enabled'],
|
|
|
|
parentalControlEnabled: json['parentalControlEnabled']['enabled']
|
|
|
|
);
|
|
|
|
}
|