2023-03-22 11:38:18 +00:00
|
|
|
import 'package:auto_route/auto_route.dart';
|
2022-05-18 10:39:11 +00:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
2021-03-26 13:38:39 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2024-03-05 15:10:15 +00:00
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
2024-02-01 14:30:06 +00:00
|
|
|
import 'package:selfprivacy/logic/bloc/volumes/volumes_bloc.dart';
|
2021-04-10 03:04:23 +00:00
|
|
|
import 'package:selfprivacy/logic/common_enum/common_enum.dart';
|
2022-11-12 17:29:06 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/metrics/metrics_cubit.dart';
|
2021-03-26 13:38:39 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/server_detailed_info/server_detailed_info_cubit.dart';
|
2022-05-18 10:39:11 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
2024-08-06 15:25:05 +00:00
|
|
|
import 'package:selfprivacy/logic/models/disk_status.dart';
|
|
|
|
import 'package:selfprivacy/logic/models/metrics.dart';
|
|
|
|
import 'package:selfprivacy/theming/harmonized_basic_colors.dart';
|
2021-03-26 13:38:39 +00:00
|
|
|
import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart';
|
2024-01-31 05:14:23 +00:00
|
|
|
import 'package:selfprivacy/ui/components/buttons/segmented_buttons.dart';
|
|
|
|
import 'package:selfprivacy/ui/components/cards/filled_card.dart';
|
2022-09-18 13:24:17 +00:00
|
|
|
import 'package:selfprivacy/ui/components/list_tiles/list_tile_on_surface_variant.dart';
|
2024-01-31 05:14:23 +00:00
|
|
|
import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart';
|
2022-10-20 19:23:55 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/server_details/charts/cpu_chart.dart';
|
2024-08-02 14:37:00 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/server_details/charts/disk_charts.dart';
|
2024-07-30 04:13:56 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/server_details/charts/memory_chart.dart';
|
2022-10-20 19:23:55 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/server_details/charts/network_charts.dart';
|
2022-09-15 21:08:14 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/server_storage/storage_card.dart';
|
2024-03-05 15:10:15 +00:00
|
|
|
import 'package:selfprivacy/ui/router/router.dart';
|
2022-05-18 10:39:11 +00:00
|
|
|
|
2022-09-15 15:40:02 +00:00
|
|
|
part 'charts/chart.dart';
|
2022-05-18 10:39:11 +00:00
|
|
|
part 'text_details.dart';
|
2021-03-26 13:38:39 +00:00
|
|
|
|
|
|
|
var navigatorKey = GlobalKey<NavigatorState>();
|
|
|
|
|
2023-03-22 11:38:18 +00:00
|
|
|
@RoutePage()
|
2022-05-18 10:39:11 +00:00
|
|
|
class ServerDetailsScreen extends StatefulWidget {
|
2022-10-26 16:26:09 +00:00
|
|
|
const ServerDetailsScreen({super.key});
|
2021-03-26 13:38:39 +00:00
|
|
|
|
|
|
|
@override
|
2022-05-25 12:21:56 +00:00
|
|
|
State<ServerDetailsScreen> createState() => _ServerDetailsScreenState();
|
2021-03-26 13:38:39 +00:00
|
|
|
}
|
|
|
|
|
2022-05-18 10:39:11 +00:00
|
|
|
class _ServerDetailsScreenState extends State<ServerDetailsScreen>
|
2021-03-26 13:38:39 +00:00
|
|
|
with SingleTickerProviderStateMixin {
|
|
|
|
late TabController tabController;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
tabController.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
tabController = TabController(length: 2, vsync: this);
|
|
|
|
tabController.addListener(() {
|
|
|
|
setState(() {});
|
|
|
|
});
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
2022-06-05 22:40:34 +00:00
|
|
|
Widget build(final BuildContext context) {
|
|
|
|
final bool isReady = context.watch<ServerInstallationCubit>().state
|
2022-05-17 13:31:34 +00:00
|
|
|
is ServerInstallationFinished;
|
2022-09-15 16:57:26 +00:00
|
|
|
|
|
|
|
if (!isReady) {
|
|
|
|
return BrandHeroScreen(
|
|
|
|
heroIcon: BrandIcons.server,
|
2022-10-03 23:32:35 +00:00
|
|
|
heroTitle: 'server.card_title'.tr(),
|
2022-09-15 16:57:26 +00:00
|
|
|
heroSubtitle: 'not_ready_card.in_menu'.tr(),
|
|
|
|
children: const [],
|
|
|
|
);
|
|
|
|
}
|
2021-03-26 13:38:39 +00:00
|
|
|
|
2024-07-30 01:15:17 +00:00
|
|
|
return BrandHeroScreen(
|
|
|
|
hasFlashButton: true,
|
|
|
|
heroIcon: BrandIcons.server,
|
|
|
|
heroTitle: 'server.card_title'.tr(),
|
|
|
|
heroSubtitle: 'server.description'.tr(),
|
|
|
|
children: [
|
|
|
|
StorageCard(
|
|
|
|
diskStatus: context.watch<VolumesBloc>().state.diskStatus,
|
|
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
ListTile(
|
|
|
|
title: Text('server.settings'.tr()),
|
|
|
|
leading: const Icon(BrandIcons.settings),
|
|
|
|
onTap: () => context.pushRoute(const ServerSettingsRoute()),
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
title: Text('server.logs'.tr()),
|
|
|
|
leading: const Icon(Icons.manage_search_outlined),
|
|
|
|
onTap: () => context.pushRoute(ServerLogsRoute()),
|
|
|
|
),
|
|
|
|
const Divider(height: 32),
|
|
|
|
Text(
|
|
|
|
'server.resource_usage'.tr(),
|
|
|
|
style: Theme.of(context).textTheme.titleLarge,
|
|
|
|
),
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
BlocProvider(
|
|
|
|
create: (final context) => MetricsCubit()..restart(),
|
|
|
|
child: _Chart(),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
_TextDetails(),
|
|
|
|
],
|
2021-03-26 13:38:39 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|