fix: Do not hide period selector from the memory usage page

This commit is contained in:
Inex Code 2024-07-30 16:48:30 +03:00
parent 4246b50a24
commit 51b6e0ab41
3 changed files with 80 additions and 72 deletions

View file

@ -144,7 +144,8 @@
"unsupported": "You can't view resource usage charts without the server provider token.",
"system": "System",
"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": {
"card_title": "Server",

View file

@ -33,39 +33,43 @@ class _MemoryUsageByServiceContents extends StatelessWidget {
final Period period = cubit.state.period;
final MetricsState state = cubit.state;
final List<Widget> children = [];
if (state is MetricsUnsupported ||
(state is MetricsLoaded && state.memoryMetrics == null)) {
return BrandHeroScreen(
heroTitle: 'resource_chart.memory'.tr(),
children: [
children.addAll([
Center(
child: Center(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 32.0),
child: EmptyPagePlaceholder(
title: 'basis.error'.tr(),
description:
'resource_chart.failed_to_load_memory_metrics'.tr(),
iconData: Icons.error_outline_outlined,
),
),
),
],
);
),
]);
}
if (state is MetricsLoading) {
return BrandHeroScreen(
heroTitle: 'resource_chart.memory'.tr(),
children: const [
Center(
children.addAll([
const Center(
child: Padding(
padding: EdgeInsets.symmetric(vertical: 32.0),
child: CircularProgressIndicator(),
),
],
);
),
]);
}
if (state is MetricsLoaded && state.memoryMetrics != null) {
final averageUsageByServices =
(state as MetricsLoaded).memoryMetrics!.averageMetricsByService;
state.memoryMetrics!.averageMetricsByService;
final maxUsageByServices = state.memoryMetrics!.maxMetricsByService;
// For each service, gather average and max usages
final List<Widget> children = [];
for (final slice in averageUsageByServices.keys.sorted()) {
final DiskSize averageUsage =
DiskSize(byte: averageUsageByServices[slice]?.toInt() ?? 0);
@ -120,6 +124,7 @@ class _MemoryUsageByServiceContents extends StatelessWidget {
),
);
}
}
return BrandHeroScreen(
heroTitle: 'resource_chart.memory'.tr(),

View file

@ -32,10 +32,12 @@ class _BasicEnumConfigItemState extends State<BasicEnumConfigItem> {
DropdownMenuItem<String>(
value: widget.configItem.value,
enabled: false,
child: Text(widget.configItem.value,
child: Text(
widget.configItem.value,
style: Theme.of(context).textTheme.titleMedium!.copyWith(
color: Theme.of(context).colorScheme.error.withOpacity(0.7),
)),
),
),
),
);
}