2022-05-18 10:39:11 +00:00
|
|
|
part of 'server_details_screen.dart';
|
2021-03-26 13:38:39 +00:00
|
|
|
|
2022-09-14 23:31:25 +00:00
|
|
|
class _ServerSettings extends StatefulWidget {
|
2022-09-15 16:57:26 +00:00
|
|
|
const _ServerSettings();
|
2021-03-26 13:38:39 +00:00
|
|
|
|
2022-09-14 23:31:25 +00:00
|
|
|
@override
|
|
|
|
State<_ServerSettings> createState() => _ServerSettingsState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ServerSettingsState extends State<_ServerSettings> {
|
|
|
|
bool? allowAutoUpgrade;
|
|
|
|
bool? rebootAfterUpgrade;
|
2022-09-18 23:42:21 +00:00
|
|
|
bool? didSomethingChange;
|
2022-09-14 23:31:25 +00:00
|
|
|
|
2021-03-26 13:38:39 +00:00
|
|
|
@override
|
2022-06-05 22:40:34 +00:00
|
|
|
Widget build(final BuildContext context) {
|
|
|
|
final serverDetailsState = context.watch<ServerDetailsCubit>().state;
|
2022-02-08 21:01:08 +00:00
|
|
|
if (serverDetailsState is ServerDetailsNotReady) {
|
2022-09-12 17:38:22 +00:00
|
|
|
return Text('basis.loading'.tr());
|
2022-02-08 21:01:08 +00:00
|
|
|
} else if (serverDetailsState is! Loaded) {
|
|
|
|
return BrandLoader.horizontal();
|
|
|
|
}
|
2022-09-14 23:31:25 +00:00
|
|
|
if (allowAutoUpgrade == null || rebootAfterUpgrade == null) {
|
|
|
|
allowAutoUpgrade = serverDetailsState.autoUpgradeSettings.enable;
|
|
|
|
rebootAfterUpgrade = serverDetailsState.autoUpgradeSettings.allowReboot;
|
|
|
|
}
|
|
|
|
|
2022-09-18 23:42:21 +00:00
|
|
|
didSomethingChange ??= false;
|
|
|
|
|
2022-09-15 16:57:26 +00:00
|
|
|
return Column(
|
2021-03-26 13:38:39 +00:00
|
|
|
children: [
|
2022-09-18 14:17:13 +00:00
|
|
|
SwitchListTile(
|
|
|
|
value: allowAutoUpgrade ?? false,
|
|
|
|
onChanged: (final switched) {
|
2022-09-18 23:42:21 +00:00
|
|
|
if (didSomethingChange == false) {
|
|
|
|
context.read<JobsCubit>().addJob(
|
2022-10-03 23:32:35 +00:00
|
|
|
RebuildServerJob(title: 'jobs.upgrade_server'.tr()),
|
2022-09-18 23:42:21 +00:00
|
|
|
);
|
|
|
|
}
|
2022-09-14 23:31:25 +00:00
|
|
|
context
|
|
|
|
.read<ServerDetailsCubit>()
|
|
|
|
.repository
|
|
|
|
.setAutoUpgradeSettings(
|
|
|
|
AutoUpgradeSettings(
|
|
|
|
enable: switched,
|
|
|
|
allowReboot: rebootAfterUpgrade ?? false,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
setState(() {
|
|
|
|
allowAutoUpgrade = switched;
|
2022-09-18 23:42:21 +00:00
|
|
|
didSomethingChange = true;
|
2022-09-14 23:31:25 +00:00
|
|
|
});
|
|
|
|
},
|
2022-10-03 23:32:35 +00:00
|
|
|
title: Text('server.allow_autoupgrade'.tr()),
|
2022-09-18 14:17:13 +00:00
|
|
|
subtitle: Text(
|
2022-10-03 23:32:35 +00:00
|
|
|
'server.allow_autoupgrade_hint'.tr(),
|
2021-03-26 13:38:39 +00:00
|
|
|
),
|
2022-09-18 14:17:13 +00:00
|
|
|
activeColor: Theme.of(context).colorScheme.primary,
|
2021-03-26 13:38:39 +00:00
|
|
|
),
|
2022-09-18 14:17:13 +00:00
|
|
|
SwitchListTile(
|
|
|
|
value: rebootAfterUpgrade ?? false,
|
|
|
|
onChanged: (final switched) {
|
2022-09-18 23:42:21 +00:00
|
|
|
if (didSomethingChange == false) {
|
|
|
|
context.read<JobsCubit>().addJob(
|
2022-10-03 23:32:35 +00:00
|
|
|
RebuildServerJob(title: 'jobs.upgrade_server'.tr()),
|
2022-09-18 23:42:21 +00:00
|
|
|
);
|
|
|
|
}
|
2022-09-14 23:31:25 +00:00
|
|
|
context
|
|
|
|
.read<ServerDetailsCubit>()
|
|
|
|
.repository
|
|
|
|
.setAutoUpgradeSettings(
|
|
|
|
AutoUpgradeSettings(
|
|
|
|
enable: allowAutoUpgrade ?? false,
|
|
|
|
allowReboot: switched,
|
|
|
|
),
|
|
|
|
);
|
2022-09-18 14:17:13 +00:00
|
|
|
setState(() {
|
|
|
|
rebootAfterUpgrade = switched;
|
2022-09-18 23:42:21 +00:00
|
|
|
didSomethingChange = true;
|
2022-09-18 14:17:13 +00:00
|
|
|
});
|
2022-09-14 23:31:25 +00:00
|
|
|
},
|
2022-10-03 23:32:35 +00:00
|
|
|
title: Text('server.reboot_after_upgrade'.tr()),
|
2022-09-18 14:17:13 +00:00
|
|
|
subtitle: Text(
|
2022-10-03 23:32:35 +00:00
|
|
|
'server.reboot_after_upgrade_hint'.tr(),
|
2021-03-26 13:38:39 +00:00
|
|
|
),
|
2022-09-18 14:17:13 +00:00
|
|
|
activeColor: Theme.of(context).colorScheme.primary,
|
2021-03-26 13:38:39 +00:00
|
|
|
),
|
2022-09-18 14:17:13 +00:00
|
|
|
ListTile(
|
2022-10-03 23:32:35 +00:00
|
|
|
title: Text('server.server_timezone'.tr()),
|
2022-09-18 14:17:13 +00:00
|
|
|
subtitle: Text(
|
|
|
|
serverDetailsState.serverTimezone.toString(),
|
|
|
|
),
|
2022-01-25 17:00:47 +00:00
|
|
|
onTap: () {
|
2022-09-18 23:42:21 +00:00
|
|
|
if (didSomethingChange == false) {
|
|
|
|
context.read<JobsCubit>().addJob(
|
2022-10-03 23:32:35 +00:00
|
|
|
RebuildServerJob(title: 'jobs.upgrade_server'.tr()),
|
2022-09-18 23:42:21 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
setState(() {
|
|
|
|
didSomethingChange = true;
|
|
|
|
});
|
2022-09-14 23:31:25 +00:00
|
|
|
Navigator.of(context).push(
|
|
|
|
materialRoute(
|
|
|
|
const SelectTimezone(),
|
|
|
|
),
|
|
|
|
);
|
2022-01-25 17:00:47 +00:00
|
|
|
},
|
2021-03-26 13:38:39 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|