2024-03-05 15:10:15 +00:00
|
|
|
part of 'server_settings_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;
|
2024-03-09 16:30:43 +00:00
|
|
|
bool? enableSsh;
|
|
|
|
bool? allowPasswordAuthentication;
|
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;
|
|
|
|
}
|
|
|
|
|
2024-03-09 16:30:43 +00:00
|
|
|
if (enableSsh == null || allowPasswordAuthentication == null) {
|
|
|
|
enableSsh = serverDetailsState.sshSettings.enable;
|
|
|
|
allowPasswordAuthentication =
|
|
|
|
serverDetailsState.sshSettings.passwordAuthentication;
|
|
|
|
}
|
|
|
|
|
2022-09-15 16:57:26 +00:00
|
|
|
return Column(
|
2021-03-26 13:38:39 +00:00
|
|
|
children: [
|
2024-03-13 15:20:50 +00:00
|
|
|
SwitchListTile.adaptive(
|
2022-09-18 14:17:13 +00:00
|
|
|
value: allowAutoUpgrade ?? false,
|
|
|
|
onChanged: (final switched) {
|
2022-10-07 17:50:18 +00:00
|
|
|
context.read<JobsCubit>().addJob(
|
2024-02-20 16:33:24 +00:00
|
|
|
ChangeAutoUpgradeSettingsJob(
|
2022-09-14 23:31:25 +00:00
|
|
|
allowReboot: rebootAfterUpgrade ?? false,
|
2024-02-20 16:33:24 +00:00
|
|
|
enable: switched,
|
2022-09-14 23:31:25 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
setState(() {
|
|
|
|
allowAutoUpgrade = switched;
|
|
|
|
});
|
|
|
|
},
|
2024-02-20 16:33:24 +00:00
|
|
|
title: Text(
|
|
|
|
'server.allow_autoupgrade'.tr(),
|
|
|
|
style: TextStyle(
|
|
|
|
fontStyle: allowAutoUpgrade !=
|
|
|
|
serverDetailsState.autoUpgradeSettings.enable
|
|
|
|
? FontStyle.italic
|
|
|
|
: FontStyle.normal,
|
|
|
|
),
|
|
|
|
),
|
2022-09-18 14:17:13 +00:00
|
|
|
subtitle: Text(
|
2022-10-03 23:32:35 +00:00
|
|
|
'server.allow_autoupgrade_hint'.tr(),
|
2024-02-20 16:33:24 +00:00
|
|
|
style: TextStyle(
|
|
|
|
fontStyle: allowAutoUpgrade !=
|
|
|
|
serverDetailsState.autoUpgradeSettings.enable
|
|
|
|
? FontStyle.italic
|
|
|
|
: FontStyle.normal,
|
|
|
|
),
|
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
|
|
|
),
|
2024-03-13 15:20:50 +00:00
|
|
|
SwitchListTile.adaptive(
|
2022-09-18 14:17:13 +00:00
|
|
|
value: rebootAfterUpgrade ?? false,
|
|
|
|
onChanged: (final switched) {
|
2022-10-07 17:50:18 +00:00
|
|
|
context.read<JobsCubit>().addJob(
|
2024-02-20 16:33:24 +00:00
|
|
|
ChangeAutoUpgradeSettingsJob(
|
2022-09-14 23:31:25 +00:00
|
|
|
allowReboot: switched,
|
2024-02-20 16:33:24 +00:00
|
|
|
enable: allowAutoUpgrade ?? false,
|
2022-09-14 23:31:25 +00:00
|
|
|
),
|
|
|
|
);
|
2022-09-18 14:17:13 +00:00
|
|
|
setState(() {
|
|
|
|
rebootAfterUpgrade = switched;
|
|
|
|
});
|
2022-09-14 23:31:25 +00:00
|
|
|
},
|
2024-02-20 16:33:24 +00:00
|
|
|
title: Text(
|
|
|
|
'server.reboot_after_upgrade'.tr(),
|
|
|
|
style: TextStyle(
|
|
|
|
fontStyle: rebootAfterUpgrade !=
|
|
|
|
serverDetailsState.autoUpgradeSettings.allowReboot
|
|
|
|
? FontStyle.italic
|
|
|
|
: FontStyle.normal,
|
|
|
|
),
|
|
|
|
),
|
2022-09-18 14:17:13 +00:00
|
|
|
subtitle: Text(
|
2022-10-03 23:32:35 +00:00
|
|
|
'server.reboot_after_upgrade_hint'.tr(),
|
2024-02-20 16:33:24 +00:00
|
|
|
style: TextStyle(
|
|
|
|
fontStyle: rebootAfterUpgrade !=
|
|
|
|
serverDetailsState.autoUpgradeSettings.allowReboot
|
|
|
|
? FontStyle.italic
|
|
|
|
: FontStyle.normal,
|
|
|
|
),
|
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-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
|
|
|
),
|
2024-03-13 15:20:50 +00:00
|
|
|
SwitchListTile.adaptive(
|
2024-03-09 16:30:43 +00:00
|
|
|
value: enableSsh ?? true,
|
|
|
|
onChanged: (final switched) {
|
|
|
|
context.read<JobsCubit>().addJob(
|
|
|
|
ChangeSshSettingsJob(
|
|
|
|
enable: switched,
|
|
|
|
passwordAuthentication:
|
|
|
|
allowPasswordAuthentication ?? false,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
setState(() {
|
|
|
|
enableSsh = switched;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
title: Text(
|
|
|
|
'server.enable_ssh'.tr(),
|
|
|
|
style: TextStyle(
|
|
|
|
fontStyle: enableSsh != serverDetailsState.sshSettings.enable
|
|
|
|
? FontStyle.italic
|
|
|
|
: FontStyle.normal,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
subtitle: Text(
|
|
|
|
'server.enable_ssh_hint'.tr(),
|
|
|
|
style: TextStyle(
|
|
|
|
fontStyle: enableSsh != serverDetailsState.sshSettings.enable
|
|
|
|
? FontStyle.italic
|
|
|
|
: FontStyle.normal,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
activeColor: Theme.of(context).colorScheme.primary,
|
|
|
|
),
|
2024-03-13 15:20:50 +00:00
|
|
|
SwitchListTile.adaptive(
|
2024-03-09 16:30:43 +00:00
|
|
|
value: allowPasswordAuthentication ?? false,
|
|
|
|
onChanged: (final switched) {
|
|
|
|
context.read<JobsCubit>().addJob(
|
|
|
|
ChangeSshSettingsJob(
|
|
|
|
enable: enableSsh ?? true,
|
|
|
|
passwordAuthentication: switched,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
setState(() {
|
|
|
|
allowPasswordAuthentication = switched;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
title: Text(
|
|
|
|
'server.allow_password_authentication'.tr(),
|
|
|
|
style: TextStyle(
|
|
|
|
fontStyle: allowPasswordAuthentication !=
|
|
|
|
serverDetailsState.sshSettings.passwordAuthentication
|
|
|
|
? FontStyle.italic
|
|
|
|
: FontStyle.normal,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
subtitle: Text(
|
|
|
|
'server.allow_password_authentication_hint'.tr(),
|
|
|
|
style: TextStyle(
|
|
|
|
fontStyle: allowPasswordAuthentication !=
|
|
|
|
serverDetailsState.sshSettings.passwordAuthentication
|
|
|
|
? FontStyle.italic
|
|
|
|
: FontStyle.normal,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
activeColor: Theme.of(context).colorScheme.primary,
|
|
|
|
),
|
2021-03-26 13:38:39 +00:00
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|