2023-03-22 14:38:18 +03:00
|
|
|
import 'package:auto_route/auto_route.dart';
|
2021-03-26 14:38:39 +01:00
|
|
|
import 'package:cubit_form/cubit_form.dart';
|
2022-05-18 13:39:11 +03:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
2021-03-26 14:38:39 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2021-04-10 05:04:23 +02:00
|
|
|
import 'package:selfprivacy/logic/common_enum/common_enum.dart';
|
2022-09-19 02:42:21 +03:00
|
|
|
import 'package:selfprivacy/logic/cubit/client_jobs/client_jobs_cubit.dart';
|
2022-11-12 21:29:06 +04:00
|
|
|
import 'package:selfprivacy/logic/cubit/metrics/metrics_cubit.dart';
|
2021-03-26 14:38:39 +01:00
|
|
|
import 'package:selfprivacy/logic/cubit/server_detailed_info/server_detailed_info_cubit.dart';
|
2022-05-18 13:39:11 +03:00
|
|
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
2022-09-15 19:57:26 +03:00
|
|
|
import 'package:selfprivacy/logic/cubit/server_volumes/server_volume_cubit.dart';
|
2022-09-15 02:31:25 +03:00
|
|
|
import 'package:selfprivacy/logic/models/auto_upgrade_settings.dart';
|
2022-09-19 02:42:21 +03:00
|
|
|
import 'package:selfprivacy/logic/models/job.dart';
|
2023-03-27 20:02:44 +03:00
|
|
|
import 'package:selfprivacy/ui/components/buttons/segmented_buttons.dart';
|
2023-04-05 13:33:53 +03:00
|
|
|
import 'package:selfprivacy/ui/components/cards/filled_card.dart';
|
2023-02-23 17:49:14 +03:00
|
|
|
import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart';
|
2021-03-26 14:38:39 +01:00
|
|
|
import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart';
|
2022-02-08 22:01:08 +01:00
|
|
|
import 'package:selfprivacy/ui/components/brand_loader/brand_loader.dart';
|
2022-09-18 16:24:17 +03:00
|
|
|
import 'package:selfprivacy/ui/components/list_tiles/list_tile_on_surface_variant.dart';
|
2022-10-20 22:23:55 +03:00
|
|
|
import 'package:selfprivacy/ui/pages/server_details/charts/cpu_chart.dart';
|
|
|
|
import 'package:selfprivacy/ui/pages/server_details/charts/network_charts.dart';
|
2022-09-16 00:08:14 +03:00
|
|
|
import 'package:selfprivacy/ui/pages/server_storage/storage_card.dart';
|
2023-03-27 20:02:44 +03:00
|
|
|
import 'package:selfprivacy/utils/breakpoints.dart';
|
2022-05-18 13:39:11 +03:00
|
|
|
import 'package:selfprivacy/utils/extensions/duration.dart';
|
2022-01-25 18:00:47 +01:00
|
|
|
import 'package:selfprivacy/utils/route_transitions/basic.dart';
|
|
|
|
import 'package:timezone/timezone.dart';
|
2022-05-18 13:39:11 +03:00
|
|
|
|
2022-09-15 18:40:02 +03:00
|
|
|
part 'charts/chart.dart';
|
2022-05-18 13:39:11 +03:00
|
|
|
part 'server_settings.dart';
|
|
|
|
part 'text_details.dart';
|
2022-02-07 08:53:13 +01:00
|
|
|
part 'time_zone/time_zone.dart';
|
2021-03-26 14:38:39 +01:00
|
|
|
|
|
|
|
var navigatorKey = GlobalKey<NavigatorState>();
|
|
|
|
|
2023-03-22 14:38:18 +03:00
|
|
|
@RoutePage()
|
2022-05-18 13:39:11 +03:00
|
|
|
class ServerDetailsScreen extends StatefulWidget {
|
2022-10-26 20:26:09 +04:00
|
|
|
const ServerDetailsScreen({super.key});
|
2021-03-26 14:38:39 +01:00
|
|
|
|
|
|
|
@override
|
2022-05-25 15:21:56 +03:00
|
|
|
State<ServerDetailsScreen> createState() => _ServerDetailsScreenState();
|
2021-03-26 14:38:39 +01:00
|
|
|
}
|
|
|
|
|
2022-05-18 13:39:11 +03:00
|
|
|
class _ServerDetailsScreenState extends State<ServerDetailsScreen>
|
2021-03-26 14:38:39 +01: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-06 01:40:34 +03:00
|
|
|
Widget build(final BuildContext context) {
|
|
|
|
final bool isReady = context.watch<ServerInstallationCubit>().state
|
2022-05-17 16:31:34 +03:00
|
|
|
is ServerInstallationFinished;
|
2022-09-15 19:57:26 +03:00
|
|
|
|
|
|
|
if (!isReady) {
|
|
|
|
return BrandHeroScreen(
|
|
|
|
heroIcon: BrandIcons.server,
|
2022-10-04 02:32:35 +03:00
|
|
|
heroTitle: 'server.card_title'.tr(),
|
2022-09-15 19:57:26 +03:00
|
|
|
heroSubtitle: 'not_ready_card.in_menu'.tr(),
|
|
|
|
children: const [],
|
|
|
|
);
|
|
|
|
}
|
2021-03-26 14:38:39 +01:00
|
|
|
|
2022-02-08 22:01:08 +01:00
|
|
|
return BlocProvider(
|
2022-09-16 11:06:27 +03:00
|
|
|
create: (final context) => context.read<ServerDetailsCubit>()..check(),
|
2022-09-15 19:57:26 +03:00
|
|
|
child: BrandHeroScreen(
|
2023-03-22 15:13:47 +03:00
|
|
|
hasFlashButton: true,
|
2022-09-15 19:57:26 +03:00
|
|
|
heroIcon: BrandIcons.server,
|
2022-10-04 02:32:35 +03:00
|
|
|
heroTitle: 'server.card_title'.tr(),
|
|
|
|
heroSubtitle: 'server.description'.tr(),
|
2022-09-15 19:57:26 +03:00
|
|
|
children: [
|
|
|
|
StorageCard(
|
2022-09-16 14:28:17 +03:00
|
|
|
diskStatus: context.watch<ApiServerVolumeCubit>().state.diskStatus,
|
2022-09-15 19:57:26 +03:00
|
|
|
),
|
2022-09-18 17:17:13 +03:00
|
|
|
const SizedBox(height: 16),
|
|
|
|
const _ServerSettings(),
|
2022-09-16 13:36:26 +03:00
|
|
|
const Divider(height: 32),
|
|
|
|
Text(
|
2022-10-04 02:32:35 +03:00
|
|
|
'server.resource_usage'.tr(),
|
2022-09-16 13:36:26 +03:00
|
|
|
style: Theme.of(context).textTheme.titleLarge,
|
|
|
|
),
|
|
|
|
const SizedBox(height: 8),
|
2022-09-15 19:57:26 +03:00
|
|
|
BlocProvider(
|
2022-11-12 21:29:06 +04:00
|
|
|
create: (final context) => MetricsCubit()..restart(),
|
2022-09-15 19:57:26 +03:00
|
|
|
child: _Chart(),
|
|
|
|
),
|
2022-09-18 17:17:13 +03:00
|
|
|
const SizedBox(height: 8),
|
2022-09-15 19:57:26 +03:00
|
|
|
_TextDetails(),
|
|
|
|
],
|
2021-06-08 20:52:44 +02:00
|
|
|
),
|
2021-03-26 14:38:39 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|