mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-14 05:52:51 +00:00
Show name logs when available
This commit is contained in:
parent
d02a859412
commit
8ca59d26c7
7 changed files with 208 additions and 165 deletions
|
@ -71,6 +71,18 @@ class LogTile extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
String logClient() {
|
||||
if (appConfigProvider.showIpLogs == true) {
|
||||
return log.client;
|
||||
}
|
||||
else if (log.clientInfo != null && log.clientInfo!.name != "") {
|
||||
return log.clientInfo!.name;
|
||||
}
|
||||
else {
|
||||
return log.client;
|
||||
}
|
||||
}
|
||||
|
||||
if (width > 1100 && !(useAlwaysNormalTile == true)) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
|
@ -110,7 +122,7 @@ class LogTile extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
if (log.client.length <= 15 && appConfigProvider.showNameTimeLogs == false) Row(
|
||||
if (log.client.length <= 15 && appConfigProvider.showTimeLogs == false) Row(
|
||||
children: [
|
||||
...[
|
||||
Icon(
|
||||
|
@ -118,10 +130,10 @@ class LogTile extends StatelessWidget {
|
|||
size: 16,
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(
|
||||
child: Text(
|
||||
log.client,
|
||||
logClient(),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
|
@ -132,14 +144,14 @@ class LogTile extends StatelessWidget {
|
|||
),
|
||||
)
|
||||
],
|
||||
const SizedBox(width: 15),
|
||||
const SizedBox(width: 16),
|
||||
...[
|
||||
Icon(
|
||||
Icons.schedule_rounded,
|
||||
size: 16,
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(
|
||||
child: Text(
|
||||
convertTimestampLocalTimezone(log.time, 'HH:mm:ss'),
|
||||
|
@ -153,7 +165,7 @@ class LogTile extends StatelessWidget {
|
|||
],
|
||||
],
|
||||
),
|
||||
if (log.client.length > 15 || appConfigProvider.showNameTimeLogs == true) Column(
|
||||
if (log.client.length > 15 || appConfigProvider.showTimeLogs == true) Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
|
@ -162,10 +174,10 @@ class LogTile extends StatelessWidget {
|
|||
size: 16,
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(
|
||||
child: Text(
|
||||
log.client,
|
||||
logClient(),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
|
@ -175,29 +187,6 @@ class LogTile extends StatelessWidget {
|
|||
)
|
||||
],
|
||||
),
|
||||
if (appConfigProvider.showNameTimeLogs == true && log.clientInfo != null && log.clientInfo!.name != '') ...[
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.badge_rounded,
|
||||
size: 16,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
Flexible(
|
||||
child: Text(
|
||||
log.clientInfo!.name,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
fontSize: 13
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
|
@ -206,7 +195,7 @@ class LogTile extends StatelessWidget {
|
|||
size: 16,
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
const SizedBox(width: 8),
|
||||
SizedBox(
|
||||
child: Text(
|
||||
convertTimestampLocalTimezone(log.time, 'HH:mm:ss'),
|
||||
|
@ -219,7 +208,7 @@ class LogTile extends StatelessWidget {
|
|||
)
|
||||
],
|
||||
),
|
||||
if (appConfigProvider.showNameTimeLogs == true && log.elapsedMs != '') ...[
|
||||
if (appConfigProvider.showTimeLogs == true && log.elapsedMs != '') ...[
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
|
@ -228,7 +217,7 @@ class LogTile extends StatelessWidget {
|
|||
size: 16,
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
const SizedBox(width: 8),
|
||||
SizedBox(
|
||||
child: Text(
|
||||
"${double.parse(log.elapsedMs).toStringAsFixed(2)} ms",
|
||||
|
@ -285,7 +274,7 @@ class LogTile extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
if (log.client.length <= 15 && appConfigProvider.showNameTimeLogs == false) Row(
|
||||
if (log.client.length <= 15 && appConfigProvider.showTimeLogs == false) Row(
|
||||
children: [
|
||||
...[
|
||||
Icon(
|
||||
|
@ -293,10 +282,10 @@ class LogTile extends StatelessWidget {
|
|||
size: 16,
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(
|
||||
child: Text(
|
||||
log.client,
|
||||
logClient(),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
|
@ -307,14 +296,14 @@ class LogTile extends StatelessWidget {
|
|||
),
|
||||
)
|
||||
],
|
||||
const SizedBox(width: 15),
|
||||
const SizedBox(width: 16),
|
||||
...[
|
||||
Icon(
|
||||
Icons.schedule_rounded,
|
||||
size: 16,
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(
|
||||
child: Text(
|
||||
convertTimestampLocalTimezone(log.time, 'HH:mm:ss'),
|
||||
|
@ -328,7 +317,7 @@ class LogTile extends StatelessWidget {
|
|||
],
|
||||
],
|
||||
),
|
||||
if (log.client.length > 15 || appConfigProvider.showNameTimeLogs == true) Column(
|
||||
if (log.client.length > 15 || appConfigProvider.showTimeLogs == true) Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
|
@ -337,10 +326,10 @@ class LogTile extends StatelessWidget {
|
|||
size: 16,
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(
|
||||
child: Text(
|
||||
log.client,
|
||||
logClient(),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
|
@ -350,73 +339,54 @@ class LogTile extends StatelessWidget {
|
|||
)
|
||||
],
|
||||
),
|
||||
if (appConfigProvider.showNameTimeLogs == true && log.clientInfo != null && log.clientInfo!.name != '') ...[
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.badge_rounded,
|
||||
size: 16,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
Flexible(
|
||||
child: Text(
|
||||
log.clientInfo!.name,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
fontSize: 13
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.schedule_rounded,
|
||||
size: 16,
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
SizedBox(
|
||||
child: Text(
|
||||
convertTimestampLocalTimezone(log.time, 'HH:mm:ss'),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.schedule_rounded,
|
||||
size: 16,
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
fontSize: 13
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
SizedBox(
|
||||
child: Text(
|
||||
convertTimestampLocalTimezone(log.time, 'HH:mm:ss'),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
fontSize: 13
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
if (appConfigProvider.showTimeLogs == true && log.elapsedMs != '') ...[
|
||||
const SizedBox(width: 16),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.timer,
|
||||
size: 16,
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
SizedBox(
|
||||
child: Text(
|
||||
"${double.parse(log.elapsedMs).toStringAsFixed(2)} ms",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
fontSize: 13
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
),
|
||||
if (appConfigProvider.showNameTimeLogs == true && log.elapsedMs != '') ...[
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.timer,
|
||||
size: 16,
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
SizedBox(
|
||||
child: Text(
|
||||
"${double.parse(log.elapsedMs).toStringAsFixed(2)} ms",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
fontSize: 13
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
|
|
|
@ -330,7 +330,7 @@ class _LogsWidgetState extends State<LogsWidget> {
|
|||
),
|
||||
);
|
||||
}
|
||||
else {
|
||||
else if (logsProvider.logsData!.data[index].question.name != null) {
|
||||
return LogTile(
|
||||
log: logsProvider.logsData!.data[index],
|
||||
index: index,
|
||||
|
@ -349,6 +349,9 @@ class _LogsWidgetState extends State<LogsWidget> {
|
|||
}
|
||||
);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
)
|
||||
: Center(
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:adguard_home_manager/functions/snackbar.dart';
|
||||
import 'package:adguard_home_manager/widgets/section_label.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:store_checker/store_checker.dart';
|
||||
|
@ -31,42 +33,23 @@ class _GeneralSettingsState extends State<GeneralSettings> {
|
|||
Widget build(BuildContext context) {
|
||||
final appConfigProvider = Provider.of<AppConfigProvider>(context);
|
||||
|
||||
Future updateHideZeroValues(bool newStatus) async {
|
||||
final result = await appConfigProvider.setHideZeroValues(newStatus);
|
||||
Future updateSettings({
|
||||
required bool newStatus,
|
||||
required Future Function(bool) function
|
||||
}) async {
|
||||
final result = await function(newStatus);
|
||||
if (result == true) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(AppLocalizations.of(context)!.settingsUpdatedSuccessfully),
|
||||
backgroundColor: Colors.green,
|
||||
)
|
||||
showSnacbkar(
|
||||
appConfigProvider: appConfigProvider,
|
||||
label: AppLocalizations.of(context)!.settingsUpdatedSuccessfully,
|
||||
color: Colors.green
|
||||
);
|
||||
}
|
||||
else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(AppLocalizations.of(context)!.cannotUpdateSettings),
|
||||
backgroundColor: Colors.red,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future updateShowNameTimeLogs(bool newStatus) async {
|
||||
final result = await appConfigProvider.setShowNameTimeLogs(newStatus);
|
||||
if (result == true) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(AppLocalizations.of(context)!.settingsUpdatedSuccessfully),
|
||||
backgroundColor: Colors.green,
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(AppLocalizations.of(context)!.cannotUpdateSettings),
|
||||
backgroundColor: Colors.red,
|
||||
)
|
||||
showSnacbkar(
|
||||
appConfigProvider: appConfigProvider,
|
||||
label: AppLocalizations.of(context)!.cannotUpdateSettings,
|
||||
color: Colors.red
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -150,15 +133,45 @@ class _GeneralSettingsState extends State<GeneralSettings> {
|
|||
),
|
||||
SliverList.list(
|
||||
children: [
|
||||
SectionLabel(label: AppLocalizations.of(context)!.home),
|
||||
CustomListTile(
|
||||
icon: Icons.exposure_zero_rounded,
|
||||
title: AppLocalizations.of(context)!.hideZeroValues,
|
||||
subtitle: AppLocalizations.of(context)!.hideZeroValuesDescription,
|
||||
trailing: Switch(
|
||||
value: appConfigProvider.hideZeroValues,
|
||||
onChanged: updateHideZeroValues,
|
||||
onChanged: (value) => updateSettings(
|
||||
newStatus: value,
|
||||
function: appConfigProvider.setHideZeroValues
|
||||
),
|
||||
),
|
||||
onTap: () => updateSettings(
|
||||
newStatus: !appConfigProvider.hideZeroValues,
|
||||
function: appConfigProvider.setHideZeroValues
|
||||
),
|
||||
padding: const EdgeInsets.only(
|
||||
top: 10,
|
||||
bottom: 10,
|
||||
left: 16,
|
||||
right: 10
|
||||
)
|
||||
),
|
||||
SectionLabel(label: AppLocalizations.of(context)!.logs),
|
||||
CustomListTile(
|
||||
icon: Icons.timer_rounded,
|
||||
title: AppLocalizations.of(context)!.timeLogs,
|
||||
subtitle: AppLocalizations.of(context)!.timeLogsDescription,
|
||||
trailing: Switch(
|
||||
value: appConfigProvider.showTimeLogs,
|
||||
onChanged: (value) => updateSettings(
|
||||
newStatus: value,
|
||||
function: appConfigProvider.setshowTimeLogs
|
||||
),
|
||||
),
|
||||
onTap: () => updateSettings(
|
||||
newStatus: !appConfigProvider.showTimeLogs,
|
||||
function: appConfigProvider.setshowTimeLogs
|
||||
),
|
||||
onTap: () => updateHideZeroValues(!appConfigProvider.hideZeroValues),
|
||||
padding: const EdgeInsets.only(
|
||||
top: 10,
|
||||
bottom: 10,
|
||||
|
@ -168,13 +181,19 @@ class _GeneralSettingsState extends State<GeneralSettings> {
|
|||
),
|
||||
CustomListTile(
|
||||
icon: Icons.more,
|
||||
title: AppLocalizations.of(context)!.nameTimeLogs,
|
||||
subtitle: AppLocalizations.of(context)!.nameTimeLogsDescription,
|
||||
title: AppLocalizations.of(context)!.ipLogs,
|
||||
subtitle: AppLocalizations.of(context)!.ipLogsDescription,
|
||||
trailing: Switch(
|
||||
value: appConfigProvider.showNameTimeLogs,
|
||||
onChanged: updateShowNameTimeLogs,
|
||||
value: appConfigProvider.showIpLogs,
|
||||
onChanged: (value) => updateSettings(
|
||||
newStatus: value,
|
||||
function: appConfigProvider.setShowIpLogs
|
||||
),
|
||||
),
|
||||
onTap: () => updateSettings(
|
||||
newStatus: !appConfigProvider.showIpLogs,
|
||||
function: appConfigProvider.setShowIpLogs
|
||||
),
|
||||
onTap: () => updateShowNameTimeLogs(!appConfigProvider.showNameTimeLogs),
|
||||
padding: const EdgeInsets.only(
|
||||
top: 10,
|
||||
bottom: 10,
|
||||
|
@ -188,14 +207,17 @@ class _GeneralSettingsState extends State<GeneralSettings> {
|
|||
appConfigProvider.installationSource == Source.IS_INSTALLED_FROM_LOCAL_SOURCE) ||
|
||||
appConfigProvider.installationSource == Source.UNKNOWN
|
||||
)
|
||||
) CustomListTile(
|
||||
icon: Icons.system_update_rounded,
|
||||
title: AppLocalizations.of(context)!.appUpdates,
|
||||
subtitle: appConfigProvider.appUpdatesAvailable != null
|
||||
? AppLocalizations.of(context)!.updateAvailable
|
||||
: AppLocalizations.of(context)!.usingLatestVersion,
|
||||
trailing: generateAppUpdateStatus()
|
||||
)
|
||||
) ...[
|
||||
SectionLabel(label: AppLocalizations.of(context)!.application),
|
||||
CustomListTile(
|
||||
icon: Icons.system_update_rounded,
|
||||
title: AppLocalizations.of(context)!.appUpdates,
|
||||
subtitle: appConfigProvider.appUpdatesAvailable != null
|
||||
? AppLocalizations.of(context)!.updateAvailable
|
||||
: AppLocalizations.of(context)!.usingLatestVersion,
|
||||
trailing: generateAppUpdateStatus()
|
||||
)
|
||||
]
|
||||
],
|
||||
)
|
||||
],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue