diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index e3e57a0..0839ce7 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -574,7 +574,7 @@ "permissionNotGranted": "Permission not granted", "inputSearchTerm": "Input a search term.", "answers": "Answers", - "copyDomainClipboard": "Copy domain to clipboard", + "copyClipboard": "Copy to clipboard", "domainCopiedClipboard": "Domain copied to the clipboard", "clearDnsCache": "Clear DNS cache", "clearDnsCacheMessage": "Are you sure you want to clear the DNS cache?", diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index 7aa1e2a..0b6e09d 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -574,7 +574,7 @@ "permissionNotGranted": "Permiso no concedido", "inputSearchTerm": "Introduce un término de búsqueda.", "answers": "Respuestas", - "copyDomainClipboard": "Copiar dominio al portapapeles", + "copyClipboard": "Copiar al portapapeles", "domainCopiedClipboard": "Dominio copiado al portapapeles", "clearDnsCache": "Borrar caché de DNS", "clearDnsCacheMessage": "¿Estás seguro que deseas eliminar la caché de DNS?", diff --git a/lib/screens/home/top_items.dart b/lib/screens/home/top_items.dart index eec1e26..5883523 100644 --- a/lib/screens/home/top_items.dart +++ b/lib/screens/home/top_items.dart @@ -113,13 +113,14 @@ class TopItems extends StatelessWidget { ); } - void openOptionsModal(String domain) { + void openOptionsModal(String domain, String type) { showDialog( context: context, builder: (context) => TopItemsOptionsModal( isBlocked: getIsBlocked(), changeStatus: (String status) => blockUnblock(domain, status), copyToClipboard: () => copyDomainClipboard(domain), + type: type, ) ); } @@ -137,22 +138,33 @@ class TopItems extends StatelessWidget { return Material( color: Colors.transparent, child: InkWell( - onTap: type == 'topQueriedDomains' || type == 'topBlockedDomains' - ?() { - logsProvider.setSearchText(item.keys.toList()[0]); - logsProvider.setAppliedFilters( - AppliedFiters( - selectedResultStatus: 'all', - searchText: item.keys.toList()[0], - clients: null - ) - ); - appConfigProvider.setSelectedScreen(2); - } - : null, - onLongPress: type == 'topQueriedDomains' || type == 'topBlockedDomains' - ? () => openOptionsModal(item.keys.toList()[0]) - : null, + onTap: () { + if (type == 'topQueriedDomains' || type == 'topBlockedDomains') { + logsProvider.setSearchText(item.keys.toList()[0]); + logsProvider.setSelectedClients(null); + logsProvider.setAppliedFilters( + AppliedFiters( + selectedResultStatus: 'all', + searchText: item.keys.toList()[0], + clients: null + ) + ); + appConfigProvider.setSelectedScreen(2); + } + else if (type == 'topClients') { + logsProvider.setSearchText(null); + logsProvider.setSelectedClients([item.keys.toList()[0]]); + logsProvider.setAppliedFilters( + AppliedFiters( + selectedResultStatus: 'all', + searchText: null, + clients: [item.keys.toList()[0]] + ) + ); + appConfigProvider.setSelectedScreen(2); + } + }, + onLongPress: () => openOptionsModal(item.keys.toList()[0], type), child: Padding( padding: const EdgeInsets.symmetric( horizontal: 20, diff --git a/lib/screens/home/top_items_options_modal.dart b/lib/screens/home/top_items_options_modal.dart index 7b29e80..18c8f9e 100644 --- a/lib/screens/home/top_items_options_modal.dart +++ b/lib/screens/home/top_items_options_modal.dart @@ -7,12 +7,14 @@ class TopItemsOptionsModal extends StatelessWidget { final bool? isBlocked; final void Function(String status)? changeStatus; final void Function() copyToClipboard; + final String type; const TopItemsOptionsModal({ Key? key, this.isBlocked, this.changeStatus, required this.copyToClipboard, + required this.type }) : super(key: key); @override @@ -38,24 +40,26 @@ class TopItemsOptionsModal extends StatelessWidget { content: Column( mainAxisSize: MainAxisSize.min, children: [ - if (isBlocked == true && changeStatus != null) CustomListTileDialog( - title: AppLocalizations.of(context)!.unblock, - icon: Icons.check, - onTap: () { - Navigator.pop(context); - changeStatus!('unblock'); - }, - ), - if (isBlocked == false && changeStatus != null) CustomListTileDialog( - title: AppLocalizations.of(context)!.block, - icon: Icons.block, - onTap: () { - Navigator.pop(context); - changeStatus!('block'); - }, - ), + if (type == 'topQueriedDomains' || type == 'topBlockedDomains') ...[ + if (isBlocked == true && changeStatus != null) CustomListTileDialog( + title: AppLocalizations.of(context)!.unblock, + icon: Icons.check, + onTap: () { + Navigator.pop(context); + changeStatus!('unblock'); + }, + ), + if (isBlocked == false && changeStatus != null) CustomListTileDialog( + title: AppLocalizations.of(context)!.block, + icon: Icons.block, + onTap: () { + Navigator.pop(context); + changeStatus!('block'); + }, + ), + ], CustomListTileDialog( - title: AppLocalizations.of(context)!.copyDomainClipboard, + title: AppLocalizations.of(context)!.copyClipboard, icon: Icons.copy, onTap: () { Navigator.pop(context); diff --git a/lib/screens/logs/log_tile.dart b/lib/screens/logs/log_tile.dart index 203e3ad..ff7b058 100644 --- a/lib/screens/logs/log_tile.dart +++ b/lib/screens/logs/log_tile.dart @@ -90,7 +90,8 @@ class LogTile extends StatelessWidget { context: context, value: log.question.name, successMessage: AppLocalizations.of(context)!.domainCopiedClipboard - ) + ), + type: 'topQueriedDomains', // topQueriedDomains can also be used here. It's the same ) ); } diff --git a/lib/screens/logs/logs.dart b/lib/screens/logs/logs.dart index 05bf65f..5c4acde 100644 --- a/lib/screens/logs/logs.dart +++ b/lib/screens/logs/logs.dart @@ -97,10 +97,21 @@ class _LogsWidgetState extends State { if (loadingMore != null && loadingMore == true && widget.logsProvider.logsData != null) { LogsData newLogsData = result['data']; newLogsData.data = [...widget.logsProvider.logsData!.data, ...result['data'].data]; + if (widget.logsProvider.selectedClients != null) { + newLogsData.data = newLogsData.data.where( + (item) => widget.logsProvider.selectedClients!.contains(item.clientInfo!.name) + ).toList(); + } widget.logsProvider.setLogsData(newLogsData); } else { - widget.logsProvider.setLogsData(result['data']); + LogsData newLogsData = result['data']; + if (widget.logsProvider.selectedClients != null) { + newLogsData.data = newLogsData.data.where( + (item) => widget.logsProvider.selectedClients!.contains(item.clientInfo!.name) + ).toList(); + } + widget.logsProvider.setLogsData(newLogsData); } widget.logsProvider.setLoadStatus(1); } diff --git a/lib/screens/top_items/top_items.dart b/lib/screens/top_items/top_items.dart index 31708dd..efee2af 100644 --- a/lib/screens/top_items/top_items.dart +++ b/lib/screens/top_items/top_items.dart @@ -90,7 +90,7 @@ class _TopItemsScreenState extends State { ); } - void openOptionsModal(String domain) { + void openOptionsModal(String domain, String type) { showDialog( context: context, builder: (context) => TopItemsOptionsModal( @@ -100,7 +100,8 @@ class _TopItemsScreenState extends State { context: context, value: domain, successMessage: AppLocalizations.of(context)!.domainCopiedClipboard - ) + ), + type: type, ) ); } @@ -197,23 +198,38 @@ class _TopItemsScreenState extends State { } return CustomListTile( - onTap: widget.type == 'topQueriedDomains' || widget.type == 'topBlockedDomains' - ? () { - logsProvider.setSearchText(screenData[index].keys.toList()[0]); - logsProvider.setAppliedFilters( - AppliedFiters( - selectedResultStatus: 'all', - searchText: screenData[index].keys.toList()[0], - clients: null - ) - ); - Navigator.pop(context); - appConfigProvider.setSelectedScreen(2); - } - : null, - onLongPress: widget.type == 'topQueriedDomains' || widget.type == 'topBlockedDomains' - ? () => openOptionsModal(screenData[index].keys.toList()[0]) - : null, + onTap: () { + if (widget.type == 'topQueriedDomains' || widget.type == 'topBlockedDomains') { + logsProvider.setSearchText(screenData[index].keys.toList()[0]); + logsProvider.setSelectedClients(null); + logsProvider.setAppliedFilters( + AppliedFiters( + selectedResultStatus: 'all', + searchText: screenData[index].keys.toList()[0], + clients: null + ) + ); + appConfigProvider.setSelectedScreen(2); + Navigator.pop(context); + } + else if (widget.type == 'topClients') { + logsProvider.setSearchText(null); + logsProvider.setSelectedClients([screenData[index].keys.toList()[0]]); + logsProvider.setAppliedFilters( + AppliedFiters( + selectedResultStatus: 'all', + searchText: null, + clients: [screenData[index].keys.toList()[0]] + ) + ); + appConfigProvider.setSelectedScreen(2); + Navigator.pop(context); + } + }, + onLongPress: () => openOptionsModal( + screenData[index].keys.toList()[0], + widget.type + ), title: screenData[index].keys.toList()[0], trailing: Text( screenData[index].values.toList()[0].toString(),