Added client queries and statistics settings

This commit is contained in:
Juan Gilsanz Polo 2023-12-11 21:49:47 +01:00
parent c3530f17ab
commit cc12a8504e
6 changed files with 69 additions and 7 deletions

View file

@ -702,5 +702,9 @@
"useCustomIpEdnsDescription": "Allow to use custom IP for EDNS",
"sortingOptions": "Sorting options",
"fromHighestToLowest": "From highest to lowest",
"fromLowestToHighest": "From lowest to highest"
"fromLowestToHighest": "From lowest to highest",
"queryLogsAndStatistics": "Query logs and statistics",
"ignoreClientQueryLog": "Ignore this client in query log",
"ignoreClientStatistics": "Ignore this client in statistics",
"savingChanges": "Saving changes..."
}

View file

@ -702,5 +702,9 @@
"useCustomIpEdnsDescription": "Permitir usar IP personalizada para EDNS",
"sortingOptions": "Opciones de ordenación",
"fromHighestToLowest": "De mayor a menor",
"fromLowestToHighest": "De menor a mayor"
"fromLowestToHighest": "De menor a mayor",
"queryLogsAndStatistics": "Registro de consultas y estadísticas",
"ignoreClientQueryLog": "Ignorar este cliente en el registro de consultas",
"ignoreClientStatistics": "Ignorar este cliente en las estadísticas",
"savingChanges": "Guardando cambios..."
}

View file

@ -87,6 +87,8 @@ class Client {
final bool useGlobalBlockedServices;
final bool useGlobalSettings;
final SafeSearch? safeSearch;
final bool? ignoreQuerylog;
final bool? ignoreStatistics;
Client({
required this.name,
@ -100,6 +102,8 @@ class Client {
required this.useGlobalBlockedServices,
required this.useGlobalSettings,
required this.safeSearch,
required this.ignoreQuerylog,
required this.ignoreStatistics,
});
factory Client.fromJson(Map<String, dynamic> json) => Client(
@ -115,7 +119,9 @@ class Client {
useGlobalSettings: json["use_global_settings"],
safeSearch: json["safe_search"] != null
? SafeSearch.fromJson(json["safe_search"])
: null
: null,
ignoreQuerylog: json["ignore_querylog"],
ignoreStatistics: json["ignore_statistics"]
);
Map<String, dynamic> toJson() => {
@ -130,5 +136,7 @@ class Client {
"safe_search": safeSearch,
"use_global_blocked_services": useGlobalBlockedServices,
"use_global_settings": useGlobalSettings,
"ignore_querylog": ignoreQuerylog,
"ignore_statistics": ignoreStatistics,
};
}

View file

@ -29,13 +29,13 @@ class AddedList extends StatefulWidget {
final bool splitView;
const AddedList({
Key? key,
super.key,
required this.scrollController,
required this.data,
required this.onClientSelected,
this.selectedClient,
required this.splitView
}) : super(key: key);
});
@override
State<AddedList> createState() => _AddedListState();
@ -75,7 +75,7 @@ class _AddedListState extends State<AddedList> {
void confirmEditClient(Client client) async {
ProcessModal processModal = ProcessModal();
processModal.open(AppLocalizations.of(context)!.addingClient);
processModal.open(AppLocalizations.of(context)!.savingChanges);
final result = await clientsProvider.editClient(client);

View file

@ -1,5 +1,6 @@
import 'dart:io';
import 'package:adguard_home_manager/widgets/custom_switch_list_tile.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
@ -45,6 +46,10 @@ class ClientForm extends StatelessWidget {
final void Function(bool) updateEnableSafeSearch;
final void Function(SafeSearch) updateSafeSearch;
final void Function(bool) updateUseGlobalSettingsServices;
final bool ignoreClientQueryLog;
final void Function(bool) updateIgnoreClientQueryLog;
final bool ignoreClientStatistics;
final void Function(bool) updateIgnoreClientStatistics;
const ClientForm({
super.key,
@ -75,6 +80,10 @@ class ClientForm extends StatelessWidget {
required this.updateEnableSafeSearch,
required this.updateSafeSearch,
required this.updateUseGlobalSettingsServices,
required this.ignoreClientQueryLog,
required this.ignoreClientStatistics,
required this.updateIgnoreClientQueryLog,
required this.updateIgnoreClientStatistics,
});
@override
@ -217,6 +226,28 @@ class ClientForm extends StatelessWidget {
)
: null,
),
SectionLabel(
label: AppLocalizations.of(context)!.queryLogsAndStatistics,
padding: const EdgeInsets.all(24),
),
CustomSwitchListTile(
title: AppLocalizations.of(context)!.ignoreClientQueryLog,
value: ignoreClientQueryLog,
onChanged: updateIgnoreClientQueryLog,
padding: const EdgeInsets.symmetric(
horizontal: 24,
vertical: 4
),
),
CustomSwitchListTile(
title: AppLocalizations.of(context)!.ignoreClientStatistics,
value: ignoreClientStatistics,
onChanged: updateIgnoreClientStatistics,
padding: const EdgeInsets.symmetric(
horizontal: 24,
vertical: 4
),
),
SectionLabel(
label: AppLocalizations.of(context)!.blockedServices,
padding: const EdgeInsets.all(24),

View file

@ -73,6 +73,9 @@ class _ClientScreenState extends State<ClientScreen> {
List<ControllerListItem> upstreamServers = [];
bool _ignoreClientQueryLog = false;
bool _ignoreClientStatistics = false;
void enableDisableGlobalSettingsFiltering() {
if (useGlobalSettingsFiltering == true) {
setState(() {
@ -120,6 +123,8 @@ class _ClientScreenState extends State<ClientScreen> {
id: uuid.v4(),
controller: TextEditingController(text: e)
)).toList();
_ignoreClientQueryLog = widget.client!.ignoreQuerylog ?? false;
_ignoreClientStatistics = widget.client!.ignoreStatistics ?? false;
}
super.initState();
}
@ -140,7 +145,9 @@ class _ClientScreenState extends State<ClientScreen> {
useGlobalBlockedServices: useGlobalSettingsServices,
blockedServices: blockedServices,
upstreams: List<String>.from(upstreamServers.map((e) => e.controller.text)),
tags: selectedTags
tags: selectedTags,
ignoreQuerylog: _ignoreClientQueryLog,
ignoreStatistics: _ignoreClientStatistics
);
widget.onConfirm(client);
}
@ -214,6 +221,10 @@ class _ClientScreenState extends State<ClientScreen> {
updateEnableSafeSearch: (v) => setState(() => enableSafeSearch = v),
updateSafeSearch: (v) => setState(() => safeSearch = v),
updateUseGlobalSettingsServices: (v) => setState(() => useGlobalSettingsServices = v),
ignoreClientQueryLog: _ignoreClientQueryLog,
ignoreClientStatistics: _ignoreClientStatistics,
updateIgnoreClientQueryLog: (v) => setState(() => _ignoreClientQueryLog = v),
updateIgnoreClientStatistics: (v) => setState(() => _ignoreClientStatistics = v),
),
),
),
@ -281,6 +292,10 @@ class _ClientScreenState extends State<ClientScreen> {
updateEnableSafeSearch: (v) => setState(() => enableSafeSearch = v),
updateSafeSearch: (v) => setState(() => safeSearch = v),
updateUseGlobalSettingsServices: (v) => setState(() => useGlobalSettingsServices = v),
ignoreClientQueryLog: _ignoreClientQueryLog,
ignoreClientStatistics: _ignoreClientStatistics,
updateIgnoreClientQueryLog: (v) => setState(() => _ignoreClientQueryLog = v),
updateIgnoreClientStatistics: (v) => setState(() => _ignoreClientStatistics = v),
),
)
],