selfprivacy.org.app/lib/ui/pages/server_details/server_details_screen.dart

105 lines
3.7 KiB
Dart
Raw Normal View History

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