mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-23 17:26:35 +00:00
chore: resolve ui conflicts and make it build
This commit is contained in:
parent
3b49805c9c
commit
4aa13dd63a
|
@ -3,7 +3,6 @@ import 'dart:async';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:selfprivacy/config/get_it_config.dart';
|
import 'package:selfprivacy/config/get_it_config.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server_api.dart';
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server_api.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/api_controller.dart';
|
|
||||||
import 'package:selfprivacy/logic/common_enum/common_enum.dart';
|
import 'package:selfprivacy/logic/common_enum/common_enum.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/models/disk_size.dart';
|
import 'package:selfprivacy/logic/models/disk_size.dart';
|
||||||
|
@ -36,7 +35,7 @@ class ApiProviderVolumeCubit
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _refetch() async {
|
Future<void> _refetch() async {
|
||||||
if (ApiController.currentVolumeProviderApiFactory == null) {
|
if (ProvidersController.currentServerProvider == null) {
|
||||||
return emit(const ApiProviderVolumeState([], LoadingStatus.error, false));
|
return emit(const ApiProviderVolumeState([], LoadingStatus.error, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,22 @@
|
||||||
import 'package:selfprivacy/config/get_it_config.dart';
|
import 'package:selfprivacy/config/get_it_config.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server_api.dart';
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server_api.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/api_controller.dart';
|
|
||||||
import 'package:selfprivacy/logic/models/auto_upgrade_settings.dart';
|
import 'package:selfprivacy/logic/models/auto_upgrade_settings.dart';
|
||||||
import 'package:selfprivacy/logic/models/server_metadata.dart';
|
import 'package:selfprivacy/logic/models/server_metadata.dart';
|
||||||
import 'package:selfprivacy/logic/models/timezone_settings.dart';
|
import 'package:selfprivacy/logic/models/timezone_settings.dart';
|
||||||
|
import 'package:selfprivacy/logic/providers/providers_controller.dart';
|
||||||
|
|
||||||
class ServerDetailsRepository {
|
class ServerDetailsRepository {
|
||||||
ServerApi server = ServerApi();
|
ServerApi server = ServerApi();
|
||||||
|
|
||||||
Future<ServerDetailsRepositoryDto> load() async {
|
Future<ServerDetailsRepositoryDto> load() async {
|
||||||
final serverProviderApi = ApiController.currentServerProviderApiFactory;
|
final serverProviderApi = ProvidersController.currentServerProvider;
|
||||||
final settings = await server.getSystemSettings();
|
final settings = await server.getSystemSettings();
|
||||||
final serverId = getIt<ApiConfigModel>().serverDetails!.id;
|
final serverId = getIt<ApiConfigModel>().serverDetails!.id;
|
||||||
final metadata =
|
final metadata = await serverProviderApi?.getMetadata(serverId);
|
||||||
await serverProviderApi!.getServerProvider().getMetadata(serverId);
|
|
||||||
|
|
||||||
return ServerDetailsRepositoryDto(
|
return ServerDetailsRepositoryDto(
|
||||||
autoUpgradeSettings: settings.autoUpgradeSettings,
|
autoUpgradeSettings: settings.autoUpgradeSettings,
|
||||||
metadata: metadata,
|
metadata: metadata!.data,
|
||||||
serverTimezone: TimeZoneSettings.fromString(
|
serverTimezone: TimeZoneSettings.fromString(
|
||||||
settings.timezone,
|
settings.timezone,
|
||||||
),
|
),
|
||||||
|
|
|
@ -61,16 +61,7 @@ class ServerInstallationRepository {
|
||||||
if (serverProvider != null ||
|
if (serverProvider != null ||
|
||||||
(serverDetails != null &&
|
(serverDetails != null &&
|
||||||
serverDetails.provider != ServerProviderType.unknown)) {
|
serverDetails.provider != ServerProviderType.unknown)) {
|
||||||
ApiController.initServerProviderApiFactory(
|
ProvidersController.initServerProvider(
|
||||||
ServerProviderSettings(
|
|
||||||
provider: serverProvider ?? serverDetails!.provider,
|
|
||||||
location: location,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
// All current providers support volumes
|
|
||||||
// so it's safe to hardcode for now
|
|
||||||
ApiController.initVolumeProviderApiFactory(
|
|
||||||
ServerProviderSettings(
|
ServerProviderSettings(
|
||||||
provider: serverProvider ?? serverDetails!.provider,
|
provider: serverProvider ?? serverDetails!.provider,
|
||||||
location: location,
|
location: location,
|
||||||
|
@ -250,8 +241,7 @@ class ServerInstallationRepository {
|
||||||
}) async {
|
}) async {
|
||||||
final DnsProviderApi dnsProviderApi =
|
final DnsProviderApi dnsProviderApi =
|
||||||
ApiController.currentDnsProviderApiFactory!.getDnsProvider();
|
ApiController.currentDnsProviderApiFactory!.getDnsProvider();
|
||||||
final ServerProviderApi serverApi =
|
final serverProvider = ProvidersController.currentServerProvider!;
|
||||||
ApiController.currentServerProviderApiFactory!.getServerProvider();
|
|
||||||
|
|
||||||
void showDomainErrorPopUp(final String error) {
|
void showDomainErrorPopUp(final String error) {
|
||||||
showPopUpAlert(
|
showPopUpAlert(
|
||||||
|
@ -260,8 +250,8 @@ class ServerInstallationRepository {
|
||||||
cancelButtonOnPressed: onCancel,
|
cancelButtonOnPressed: onCancel,
|
||||||
actionButtonTitle: 'basis.delete'.tr(),
|
actionButtonTitle: 'basis.delete'.tr(),
|
||||||
actionButtonOnPressed: () async {
|
actionButtonOnPressed: () async {
|
||||||
await serverApi.deleteServer(
|
await serverProvider.deleteServer(
|
||||||
domainName: domain.domainName,
|
domain.domainName,
|
||||||
);
|
);
|
||||||
onCancel();
|
onCancel();
|
||||||
},
|
},
|
||||||
|
@ -299,16 +289,6 @@ class ServerInstallationRepository {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final GenericResult createReverseResult = await serverApi.createReverseDns(
|
|
||||||
serverDetails: serverDetails,
|
|
||||||
domain: domain,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!createReverseResult.success) {
|
|
||||||
showDomainErrorPopUp(errorMessage);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,9 +566,7 @@ class ServerInstallationRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<ServerBasicInfo>> getServersOnProviderAccount() async =>
|
Future<List<ServerBasicInfo>> getServersOnProviderAccount() async =>
|
||||||
ApiController.currentServerProviderApiFactory!
|
(await ProvidersController.currentServerProvider!.getServers()).data;
|
||||||
.getServerProvider()
|
|
||||||
.getServers();
|
|
||||||
|
|
||||||
Future<void> saveServerDetails(
|
Future<void> saveServerDetails(
|
||||||
final ServerHostingDetails serverDetails,
|
final ServerHostingDetails serverDetails,
|
||||||
|
@ -681,12 +659,10 @@ class ServerInstallationRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> deleteServer(final ServerDomain serverDomain) async {
|
Future<bool> deleteServer(final ServerDomain serverDomain) async {
|
||||||
final GenericResult<bool> deletionResult = await ApiController
|
final deletionResult =
|
||||||
.currentServerProviderApiFactory!
|
await ProvidersController.currentServerProvider!.deleteServer(
|
||||||
.getServerProvider()
|
serverDomain.domainName,
|
||||||
.deleteServer(
|
);
|
||||||
domainName: serverDomain.domainName,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!deletionResult.success) {
|
if (!deletionResult.success) {
|
||||||
getIt<NavigationService>()
|
getIt<NavigationService>()
|
||||||
|
@ -694,12 +670,6 @@ class ServerInstallationRepository {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!deletionResult.data) {
|
|
||||||
getIt<NavigationService>()
|
|
||||||
.showSnackBar('modals.server_deletion_error'.tr());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
await box.put(BNames.hasFinalChecked, false);
|
await box.put(BNames.hasFinalChecked, false);
|
||||||
await box.put(BNames.isServerStarted, false);
|
await box.put(BNames.isServerStarted, false);
|
||||||
await box.put(BNames.isServerResetedFirstTime, false);
|
await box.put(BNames.isServerResetedFirstTime, false);
|
||||||
|
|
|
@ -5,6 +5,8 @@ import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
||||||
import 'package:selfprivacy/logic/models/launch_installation_data.dart';
|
import 'package:selfprivacy/logic/models/launch_installation_data.dart';
|
||||||
import 'package:selfprivacy/logic/models/metrics.dart';
|
import 'package:selfprivacy/logic/models/metrics.dart';
|
||||||
import 'package:selfprivacy/logic/models/price.dart';
|
import 'package:selfprivacy/logic/models/price.dart';
|
||||||
|
import 'package:selfprivacy/logic/models/server_basic_info.dart';
|
||||||
|
import 'package:selfprivacy/logic/models/server_metadata.dart';
|
||||||
import 'package:selfprivacy/logic/models/server_provider_location.dart';
|
import 'package:selfprivacy/logic/models/server_provider_location.dart';
|
||||||
import 'package:selfprivacy/logic/models/server_type.dart';
|
import 'package:selfprivacy/logic/models/server_type.dart';
|
||||||
|
|
||||||
|
@ -12,12 +14,17 @@ export 'package:selfprivacy/logic/api_maps/generic_result.dart';
|
||||||
export 'package:selfprivacy/logic/models/launch_installation_data.dart';
|
export 'package:selfprivacy/logic/models/launch_installation_data.dart';
|
||||||
|
|
||||||
abstract class ServerProvider {
|
abstract class ServerProvider {
|
||||||
|
Future<GenericResult<List<ServerBasicInfo>>> getServers();
|
||||||
Future<GenericResult<bool>> trySetServerLocation(final String location);
|
Future<GenericResult<bool>> trySetServerLocation(final String location);
|
||||||
Future<GenericResult<bool>> tryInitApiByToken(final String token);
|
Future<GenericResult<bool>> tryInitApiByToken(final String token);
|
||||||
Future<GenericResult<List<ServerProviderLocation>>> getAvailableLocations();
|
Future<GenericResult<List<ServerProviderLocation>>> getAvailableLocations();
|
||||||
Future<GenericResult<List<ServerType>>> getServerTypes({
|
Future<GenericResult<List<ServerType>>> getServerTypes({
|
||||||
required final ServerProviderLocation location,
|
required final ServerProviderLocation location,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Future<GenericResult<CallbackDialogueBranching?>> deleteServer(
|
||||||
|
final String hostname,
|
||||||
|
);
|
||||||
Future<GenericResult<CallbackDialogueBranching?>> launchInstallation(
|
Future<GenericResult<CallbackDialogueBranching?>> launchInstallation(
|
||||||
final LaunchInstallationData installationData,
|
final LaunchInstallationData installationData,
|
||||||
);
|
);
|
||||||
|
@ -42,5 +49,8 @@ abstract class ServerProvider {
|
||||||
final int serverId,
|
final int serverId,
|
||||||
);
|
);
|
||||||
Future<GenericResult<bool>> detachVolume(final ServerVolume volume);
|
Future<GenericResult<bool>> detachVolume(final ServerVolume volume);
|
||||||
|
Future<GenericResult<List<ServerMetadataEntity>>> getMetadata(
|
||||||
|
final int serverId,
|
||||||
|
);
|
||||||
GenericResult<bool> get success => GenericResult(success: true, data: true);
|
GenericResult<bool> get success => GenericResult(success: true, data: true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,6 +209,7 @@ class HetznerServerProvider extends ServerProvider {
|
||||||
return GenericResult(success: true, data: servers);
|
return GenericResult(success: true, data: servers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
Future<GenericResult<List<ServerMetadataEntity>>> getMetadata(
|
Future<GenericResult<List<ServerMetadataEntity>>> getMetadata(
|
||||||
final int serverId,
|
final int serverId,
|
||||||
) async {
|
) async {
|
||||||
|
@ -573,6 +574,7 @@ class HetznerServerProvider extends ServerProvider {
|
||||||
return GenericResult(success: true, data: null);
|
return GenericResult(success: true, data: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
Future<GenericResult<CallbackDialogueBranching?>> deleteServer(
|
Future<GenericResult<CallbackDialogueBranching?>> deleteServer(
|
||||||
final String hostname,
|
final String hostname,
|
||||||
) async {
|
) async {
|
||||||
|
|
|
@ -10,8 +10,7 @@
|
||||||
part of 'router.dart';
|
part of 'router.dart';
|
||||||
|
|
||||||
abstract class _$RootRouter extends RootStackRouter {
|
abstract class _$RootRouter extends RootStackRouter {
|
||||||
_$RootRouter([GlobalKey<NavigatorState>? navigatorKey])
|
_$RootRouter([GlobalKey<NavigatorState>? navigatorKey]) : super(navigatorKey: navigatorKey);
|
||||||
: super(navigatorKey: navigatorKey);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final Map<String, PageFactory> pagesMap = {
|
final Map<String, PageFactory> pagesMap = {
|
||||||
|
|
Loading…
Reference in a new issue