mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-08 00:51:20 +00:00
Merge pull request 'fix: Replace hard reset from server provider with direct server reboot' (#269) from soft-reset into master
Reviewed-on: https://git.selfprivacy.org/SelfPrivacy/selfprivacy.org.app/pulls/269 Reviewed-by: Inex Code <inex.code@selfprivacy.org>
This commit is contained in:
commit
7db7cd79b0
|
@ -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$RebootSystem();
|
||||||
() async => client.mutate$RebootSystem(),
|
if (response.hasException) {
|
||||||
);
|
print(response.exception.toString());
|
||||||
|
}
|
||||||
|
if (response.parsedData!.rebootSystem.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 {
|
||||||
|
|
|
@ -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());
|
||||||
|
|
|
@ -260,12 +260,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;
|
||||||
|
|
Loading…
Reference in a new issue