Skip to content

Commit

Permalink
Merge branch 'beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
JGeek00 committed Jul 11, 2023
2 parents ca4bfd3 + 2fed0e5 commit 264c885
Show file tree
Hide file tree
Showing 19 changed files with 617 additions and 171 deletions.
23 changes: 22 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -630,5 +630,26 @@
"combinedChartDescription": "Combine all charts into one",
"statistics": "Statistics",
"errorLoadFilters": "Error when loading filters.",
"clientRemovedSuccessfully": "Client removed successfully."
"clientRemovedSuccessfully": "Client removed successfully.",
"editRewriteRule": "Edit rewrite rule",
"dnsRewriteRuleUpdated": "DNS rewrite rule updated successfully",
"dnsRewriteRuleNotUpdated": "DNS rewrite rule could not be updated",
"updatingRule": "Updating rule...",
"serverUpdateNeeded": "Server update needed",
"updateYourServer": "Update your AdGuard Home server to {version} or greater to use this feature.",
"january": "January",
"february": "February",
"march": "March",
"april": "April",
"may": "May",
"june": "June",
"july": "July",
"august": "August",
"september": "September",
"october": "October",
"november": "November",
"december": "December",
"malwarePhising": "Malware/phising",
"queries": "Queries",
"adultSites": "Adult sites"
}
23 changes: 22 additions & 1 deletion lib/l10n/app_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -630,5 +630,26 @@
"combinedChartDescription": "Combina todos los gráficos en uno solo",
"statistics": "Estadísticas",
"errorLoadFilters": "Error al cargar los filtros.",
"clientRemovedSuccessfully": "Cliente eliminado correctamente."
"clientRemovedSuccessfully": "Cliente eliminado correctamente.",
"editRewriteRule": "Editar reescritura DNS",
"dnsRewriteRuleUpdated": "Regla de reescritura DNS actualizada correctamente",
"dnsRewriteRuleNotUpdated": "La regla de reescritura DNS no ha podido ser actualizada",
"updatingRule": "Actualizando regla...",
"serverUpdateNeeded": "Actualización del servidor necesaria",
"updateYourServer": "Actualiza tu servidor AdGuard Home a {version} para utilizar esta funcionalidad.",
"january": "Enero",
"february": "Febrero",
"march": "Marzo",
"april": "Abril",
"may": "Mayo",
"june": "Junio",
"july": "Julio",
"august": "Agosto",
"september": "Septiembre",
"october": "Octubre",
"november": "Noviembre",
"december": "Diciembre",
"malwarePhising": "Malware/phising",
"queries": "Peticiones",
"adultSites": "Sitios de adultos"
}
2 changes: 1 addition & 1 deletion lib/models/dhcp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ DhcpStatus dhcpStatusFromJson(String str) => DhcpStatus.fromJson(json.decode(str
String dhcpStatusToJson(DhcpStatus data) => json.encode(data.toJson());

class DhcpStatus {
String interfaceName;
String? interfaceName;
IpVersion v4;
IpVersion v6;
List<Lease> leases;
Expand Down
4 changes: 2 additions & 2 deletions lib/models/dns_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class DnsInfo {
bool ednsCsEnabled;
bool dnssecEnabled;
bool disableIpv6;
String upstreamMode;
String? upstreamMode;
int cacheSize;
int cacheTtlMin;
int cacheTtlMax;
Expand Down Expand Up @@ -46,7 +46,7 @@ class DnsInfo {
factory DnsInfo.fromJson(Map<String, dynamic> json) => DnsInfo(
upstreamDns: json["upstream_dns"] != null ? List<String>.from(json["upstream_dns"].map((x) => x)) : [],
upstreamDnsFile: json["upstream_dns_file"],
bootstrapDns: List<String>.from(json["bootstrap_dns"].map((x) => x)),
bootstrapDns: json["bootstrap_dns"] != null ? List<String>.from(json["bootstrap_dns"].map((x) => x)) : [],
protectionEnabled: json["protection_enabled"],
ratelimit: json["ratelimit"],
blockingMode: json["blocking_mode"],
Expand Down
27 changes: 27 additions & 0 deletions lib/providers/rewrite_rules_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,33 @@ class RewriteRulesProvider with ChangeNotifier {
}
}

Future<bool> editDnsRewrite(RewriteRules newRule, RewriteRules oldRule) async {
final result = await _serversProvider!.apiClient!.updateRewriteRule(
body: {
"target": {
"answer": oldRule.answer,
"domain": oldRule.domain
},
"update": {
"answer": newRule.answer,
"domain": newRule.domain
}
}
);

if (result['result'] == 'success') {
List<RewriteRules> data = rewriteRules!;
final index = data.indexOf(oldRule);
data[index] = newRule;
setRewriteRulesData(data);
return true;
}
else {
notifyListeners();
return false;
}
}

Future<bool> deleteDnsRewrite(RewriteRules rule) async {
final result = await _serversProvider!.apiClient!.deleteDnsRewriteRule(
data: {
Expand Down
22 changes: 14 additions & 8 deletions lib/screens/home/chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,32 @@ class HomeChart extends StatelessWidget {
final String primaryValue;
final String secondaryValue;
final Color color;
final int hoursInterval;

const HomeChart({
Key? key,
required this.data,
required this.label,
required this.primaryValue,
required this.secondaryValue,
required this.color
required this.color,
required this.hoursInterval
}) : super(key: key);

@override
Widget build(BuildContext context) {
final appConfigProvider = Provider.of<AppConfigProvider>(context);

bool isEmpty = true;
for (int item in data) {
if (item > 0) {
isEmpty = false;
break;
}
}
final bool isEmpty = data.any((i) => i == 0);

if (!(appConfigProvider.hideZeroValues == true && isEmpty == true)) {
List<DateTime> dateTimes = [];
DateTime currentDate = DateTime.now().subtract(Duration(hours: hoursInterval*data.length+1));
for (var i = 0; i < data.length; i++) {
currentDate = currentDate.add(Duration(hours: hoursInterval));
dateTimes.add(currentDate);
}

return Column(
children: [
Padding(
Expand Down Expand Up @@ -109,6 +112,9 @@ class HomeChart extends StatelessWidget {
child: CustomLineChart(
data: data,
color: color,
dates: dateTimes,
daysInterval: hoursInterval == 24,
context: context,
)
),
],
Expand Down
17 changes: 16 additions & 1 deletion lib/screens/home/combined_chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CombinedChartData {
required this.totalQueries,
this.blockedFilters,
this.replacedSafeBrowsing,
this.replacedParental
this.replacedParental,
});
}

Expand Down Expand Up @@ -149,6 +149,15 @@ class CombinedHomeChart extends StatelessWidget {
);
}

final hoursInterval = statusProvider.serverStatus!.stats.timeUnits == "days" ? 24 : 1;

List<DateTime> dateTimes = [];
DateTime currentDate = DateTime.now().subtract(Duration(hours: hoursInterval*statusProvider.serverStatus!.stats.dnsQueries.length+1));
for (var i = 0; i < statusProvider.serverStatus!.stats.dnsQueries.length; i++) {
currentDate = currentDate.add(Duration(hours: hoursInterval));
dateTimes.add(currentDate);
}

if (width > 700) {
return Column(
children: [
Expand All @@ -170,6 +179,9 @@ class CombinedHomeChart extends StatelessWidget {
width: double.maxFinite,
child: CustomCombinedLineChart(
inputData: data,
context: context,
dates: dateTimes,
daysInterval: hoursInterval == 24,
),
),
),
Expand Down Expand Up @@ -241,6 +253,9 @@ class CombinedHomeChart extends StatelessWidget {
width: double.maxFinite,
child: CustomCombinedLineChart(
inputData: data,
context: context,
dates: dateTimes,
daysInterval: hoursInterval == 24,
),
),
const SizedBox(height: 16),
Expand Down
4 changes: 4 additions & 0 deletions lib/screens/home/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class _HomeState extends State<Home> {
primaryValue: intFormat(statusProvider.serverStatus!.stats.numDnsQueries, Platform.localeName),
secondaryValue: "${doubleFormat(statusProvider.serverStatus!.stats.avgProcessingTime*1000, Platform.localeName)} ms",
color: Colors.blue,
hoursInterval: statusProvider.serverStatus!.stats.timeUnits == "days" ? 24 : 1,
),
),
FractionallySizedBox(
Expand All @@ -141,6 +142,7 @@ class _HomeState extends State<Home> {
primaryValue: intFormat(statusProvider.serverStatus!.stats.numBlockedFiltering, Platform.localeName),
secondaryValue: "${statusProvider.serverStatus!.stats.numDnsQueries > 0 ? doubleFormat((statusProvider.serverStatus!.stats.numBlockedFiltering/statusProvider.serverStatus!.stats.numDnsQueries)*100, Platform.localeName) : 0}%",
color: Colors.red,
hoursInterval: statusProvider.serverStatus!.stats.timeUnits == "days" ? 24 : 1,
),
),
FractionallySizedBox(
Expand All @@ -151,6 +153,7 @@ class _HomeState extends State<Home> {
primaryValue: intFormat(statusProvider.serverStatus!.stats.numReplacedSafebrowsing, Platform.localeName),
secondaryValue: "${statusProvider.serverStatus!.stats.numDnsQueries > 0 ? doubleFormat((statusProvider.serverStatus!.stats.numReplacedSafebrowsing/statusProvider.serverStatus!.stats.numDnsQueries)*100, Platform.localeName) : 0}%",
color: Colors.green,
hoursInterval: statusProvider.serverStatus!.stats.timeUnits == "days" ? 24 : 1,
),
),
FractionallySizedBox(
Expand All @@ -161,6 +164,7 @@ class _HomeState extends State<Home> {
primaryValue: intFormat(statusProvider.serverStatus!.stats.numReplacedParental, Platform.localeName),
secondaryValue: "${statusProvider.serverStatus!.stats.numDnsQueries > 0 ? doubleFormat((statusProvider.serverStatus!.stats.numReplacedParental/statusProvider.serverStatus!.stats.numDnsQueries)*100, Platform.localeName) : 0}%",
color: Colors.orange,
hoursInterval: statusProvider.serverStatus!.stats.timeUnits == "days" ? 24 : 1,
),
),
],
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/logs/logs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class _LogsState extends State<Logs> {
tooltip: AppLocalizations.of(context)!.filters,
)
: const SizedBox(),
IconButton(
if (statusProvider.serverStatus != null) IconButton(
tooltip: AppLocalizations.of(context)!.settings,
onPressed: () => {
if (width > 700 || !(Platform.isAndroid || Platform.isIOS)) {
Expand Down
4 changes: 2 additions & 2 deletions lib/screens/settings/dhcp/dhcp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class _DhcpScreenState extends State<DhcpScreen> {
final dhcpProvider = Provider.of<DhcpProvider>(context, listen: false);
if (dhcpProvider.dhcp != null) {
setState(() {
if (dhcpProvider.dhcp!.dhcpStatus.interfaceName != '') {
selectedInterface = dhcpProvider.dhcp!.networkInterfaces.firstWhere((iface) => iface.name == dhcpProvider.dhcp!.dhcpStatus.interfaceName);
if (dhcpProvider.dhcp!.dhcpStatus.interfaceName != null && dhcpProvider.dhcp!.dhcpStatus.interfaceName != '') {
try {selectedInterface = dhcpProvider.dhcp!.networkInterfaces.firstWhere((iface) => iface.name == dhcpProvider.dhcp!.dhcpStatus.interfaceName);} catch (_) {}
enabled = dhcpProvider.dhcp!.dhcpStatus.enabled;
ipv4StartRangeController.text = dhcpProvider.dhcp!.dhcpStatus.v4.rangeStart;
ipv4EndRangeController.text = dhcpProvider.dhcp!.dhcpStatus.v4.rangeEnd ?? '';
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/settings/dns/upstream_dns.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class _UpstreamDnsScreenState extends State<UpstreamDnsScreen> {
});
}
}
upstreamMode = dnsProvider.dnsInfo!.upstreamMode;
upstreamMode = dnsProvider.dnsInfo!.upstreamMode ?? "";
validValues = true;
super.initState();
}
Expand Down
Loading

0 comments on commit 264c885

Please sign in to comment.