fix: Replace hard reset from server provider with direct server reboot

pull/269/head
NaiJi ✨ 2023-08-02 18:08:23 -03:00
parent 11e745f822
commit ffe923ef13
3 changed files with 18 additions and 10 deletions

View File

@ -20,15 +20,23 @@ mixin ServerActionsApi on GraphQLApiMap {
return result; return result;
} }
Future<bool> reboot() async { Future<GenericResult<DateTime?>> reboot() async {
DateTime? time;
try { try {
final GraphQLClient client = await getClient(); final GraphQLClient client = await getClient();
return await _commonBoolRequest( final response = await client.mutate$RunSystemRebuild();
() async => client.mutate$RebootSystem(), if (response.hasException) {
); print(response.exception.toString());
}
if (response.parsedData!.runSystemRebuild.success) {
time = DateTime.now();
}
} catch (e) { } catch (e) {
return false; print(e);
return GenericResult(data: time, success: false);
} }
return GenericResult(data: time, success: true);
} }
Future<bool> pullConfigurationUpdate() async { Future<bool> pullConfigurationUpdate() async {

View File

@ -54,8 +54,8 @@ class JobsCubit extends Cubit<JobsState> {
Future<void> rebootServer() async { Future<void> rebootServer() async {
emit(JobsStateLoading()); emit(JobsStateLoading());
final bool isSuccessful = await api.reboot(); final rebootResult = await api.reboot();
if (isSuccessful) { if (rebootResult.success && rebootResult.data != null) {
getIt<NavigationService>().showSnackBar('jobs.reboot_success'.tr()); getIt<NavigationService>().showSnackBar('jobs.reboot_success'.tr());
} else { } else {
getIt<NavigationService>().showSnackBar('jobs.reboot_failed'.tr()); getIt<NavigationService>().showSnackBar('jobs.reboot_failed'.tr());

View File

@ -254,12 +254,12 @@ class ServerInstallationRepository {
Future<ServerHostingDetails> restart() async { Future<ServerHostingDetails> restart() async {
final server = getIt<ApiConfigModel>().serverDetails!; final server = getIt<ApiConfigModel>().serverDetails!;
final result = await ProvidersController.currentServerProvider!.restart( final result = await ServerApi().reboot();
server.id,
);
if (result.success && result.data != null) { if (result.success && result.data != null) {
server.copyWith(startTime: result.data); server.copyWith(startTime: result.data);
} else {
getIt<NavigationService>().showSnackBar('jobs.reboot_failed'.tr());
} }
return server; return server;