mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-23 09:16:54 +00:00
fix: Do not hide period selector from the memory usage page
This commit is contained in:
parent
4246b50a24
commit
51b6e0ab41
|
@ -144,7 +144,8 @@
|
||||||
"unsupported": "You can't view resource usage charts without the server provider token.",
|
"unsupported": "You can't view resource usage charts without the server provider token.",
|
||||||
"system": "System",
|
"system": "System",
|
||||||
"ssh_users": "SSH users",
|
"ssh_users": "SSH users",
|
||||||
"ram_usage": "Average usage: {average}. Maximum: {max}."
|
"ram_usage": "Average usage: {average}. Maximum: {max}.",
|
||||||
|
"failed_to_load_memory_metrics": "Couldn't load memory usage data. This might be a connection issue, or there is not enough data yet."
|
||||||
},
|
},
|
||||||
"server": {
|
"server": {
|
||||||
"card_title": "Server",
|
"card_title": "Server",
|
||||||
|
|
|
@ -33,92 +33,97 @@ class _MemoryUsageByServiceContents extends StatelessWidget {
|
||||||
final Period period = cubit.state.period;
|
final Period period = cubit.state.period;
|
||||||
final MetricsState state = cubit.state;
|
final MetricsState state = cubit.state;
|
||||||
|
|
||||||
|
final List<Widget> children = [];
|
||||||
|
|
||||||
if (state is MetricsUnsupported ||
|
if (state is MetricsUnsupported ||
|
||||||
(state is MetricsLoaded && state.memoryMetrics == null)) {
|
(state is MetricsLoaded && state.memoryMetrics == null)) {
|
||||||
return BrandHeroScreen(
|
children.addAll([
|
||||||
heroTitle: 'resource_chart.memory'.tr(),
|
Center(
|
||||||
children: [
|
child: Center(
|
||||||
Center(
|
child: Padding(
|
||||||
child: Center(
|
padding: const EdgeInsets.symmetric(vertical: 32.0),
|
||||||
child: EmptyPagePlaceholder(
|
child: EmptyPagePlaceholder(
|
||||||
title: 'basis.error'.tr(),
|
title: 'basis.error'.tr(),
|
||||||
|
description:
|
||||||
|
'resource_chart.failed_to_load_memory_metrics'.tr(),
|
||||||
iconData: Icons.error_outline_outlined,
|
iconData: Icons.error_outline_outlined,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
);
|
]);
|
||||||
}
|
}
|
||||||
if (state is MetricsLoading) {
|
if (state is MetricsLoading) {
|
||||||
return BrandHeroScreen(
|
children.addAll([
|
||||||
heroTitle: 'resource_chart.memory'.tr(),
|
const Center(
|
||||||
children: const [
|
child: Padding(
|
||||||
Center(
|
padding: EdgeInsets.symmetric(vertical: 32.0),
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
final averageUsageByServices =
|
if (state is MetricsLoaded && state.memoryMetrics != null) {
|
||||||
(state as MetricsLoaded).memoryMetrics!.averageMetricsByService;
|
final averageUsageByServices =
|
||||||
final maxUsageByServices = state.memoryMetrics!.maxMetricsByService;
|
state.memoryMetrics!.averageMetricsByService;
|
||||||
|
final maxUsageByServices = state.memoryMetrics!.maxMetricsByService;
|
||||||
|
|
||||||
// For each service, gather average and max usages
|
// For each service, gather average and max usages
|
||||||
final List<Widget> children = [];
|
for (final slice in averageUsageByServices.keys.sorted()) {
|
||||||
for (final slice in averageUsageByServices.keys.sorted()) {
|
final DiskSize averageUsage =
|
||||||
final DiskSize averageUsage =
|
DiskSize(byte: averageUsageByServices[slice]?.toInt() ?? 0);
|
||||||
DiskSize(byte: averageUsageByServices[slice]?.toInt() ?? 0);
|
final DiskSize maxUsage =
|
||||||
final DiskSize maxUsage =
|
DiskSize(byte: maxUsageByServices[slice]?.toInt() ?? 0);
|
||||||
DiskSize(byte: maxUsageByServices[slice]?.toInt() ?? 0);
|
String? serviceName;
|
||||||
String? serviceName;
|
Widget? icon;
|
||||||
Widget? icon;
|
if (slice == 'system') {
|
||||||
if (slice == 'system') {
|
serviceName = 'resource_chart.system'.tr();
|
||||||
serviceName = 'resource_chart.system'.tr();
|
icon = const Icon(BrandIcons.server);
|
||||||
icon = const Icon(BrandIcons.server);
|
} else if (slice == 'user') {
|
||||||
} else if (slice == 'user') {
|
serviceName = 'resource_chart.ssh_users'.tr();
|
||||||
serviceName = 'resource_chart.ssh_users'.tr();
|
icon = const Icon(BrandIcons.terminal);
|
||||||
icon = const Icon(BrandIcons.terminal);
|
} else {
|
||||||
} else {
|
final service = context
|
||||||
final service = context
|
.read<ServicesBloc>()
|
||||||
.read<ServicesBloc>()
|
.state
|
||||||
.state
|
.getServiceById(slice.replaceAll('_', '-'));
|
||||||
.getServiceById(slice.replaceAll('_', '-'));
|
serviceName = service?.displayName ?? slice;
|
||||||
serviceName = service?.displayName ?? slice;
|
icon = service?.svgIcon != null
|
||||||
icon = service?.svgIcon != null
|
? SvgPicture.string(
|
||||||
? SvgPicture.string(
|
service!.svgIcon,
|
||||||
service!.svgIcon,
|
width: 22.0,
|
||||||
width: 22.0,
|
height: 24.0,
|
||||||
height: 24.0,
|
colorFilter: ColorFilter.mode(
|
||||||
colorFilter: ColorFilter.mode(
|
Theme.of(context).colorScheme.onBackground,
|
||||||
Theme.of(context).colorScheme.onBackground,
|
BlendMode.srcIn,
|
||||||
BlendMode.srcIn,
|
),
|
||||||
),
|
)
|
||||||
)
|
: const Icon(BrandIcons.box);
|
||||||
: const Icon(BrandIcons.box);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (serviceName == slice &&
|
if (serviceName == slice &&
|
||||||
averageUsage.byte == 0 &&
|
averageUsage.byte == 0 &&
|
||||||
maxUsage.byte == 0) {
|
maxUsage.byte == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
children.add(
|
children.add(
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(serviceName),
|
title: Text(serviceName),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
'resource_chart.ram_usage'.tr(
|
'resource_chart.ram_usage'.tr(
|
||||||
namedArgs: {
|
namedArgs: {
|
||||||
'average': averageUsage.toString(),
|
'average': averageUsage.toString(),
|
||||||
'max': maxUsage.toString(),
|
'max': maxUsage.toString(),
|
||||||
},
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
dense: true,
|
||||||
|
leading: icon,
|
||||||
),
|
),
|
||||||
dense: true,
|
);
|
||||||
leading: icon,
|
}
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return BrandHeroScreen(
|
return BrandHeroScreen(
|
||||||
|
|
|
@ -32,10 +32,12 @@ class _BasicEnumConfigItemState extends State<BasicEnumConfigItem> {
|
||||||
DropdownMenuItem<String>(
|
DropdownMenuItem<String>(
|
||||||
value: widget.configItem.value,
|
value: widget.configItem.value,
|
||||||
enabled: false,
|
enabled: false,
|
||||||
child: Text(widget.configItem.value,
|
child: Text(
|
||||||
style: Theme.of(context).textTheme.titleMedium!.copyWith(
|
widget.configItem.value,
|
||||||
color: Theme.of(context).colorScheme.error.withOpacity(0.7),
|
style: Theme.of(context).textTheme.titleMedium!.copyWith(
|
||||||
)),
|
color: Theme.of(context).colorScheme.error.withOpacity(0.7),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue