mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-11 10:29:39 +00:00
fix(volume): Change raw int to DiskSize object in volume endpoints
We already have an abstraction for size, there is no need to pass size value as raw numeric variables
This commit is contained in:
parent
aa1c04fdb8
commit
59d186a8af
|
@ -252,7 +252,10 @@ class DigitalOceanApi extends ServerProviderApi with VolumeProviderApi {
|
|||
}
|
||||
|
||||
@override
|
||||
Future<bool> resizeVolume(final ServerVolume volume, final int sizeGb) async {
|
||||
Future<bool> resizeVolume(
|
||||
final ServerVolume volume,
|
||||
final DiskSize size,
|
||||
) async {
|
||||
bool success = false;
|
||||
|
||||
final Response dbPostResponse;
|
||||
|
@ -263,7 +266,7 @@ class DigitalOceanApi extends ServerProviderApi with VolumeProviderApi {
|
|||
data: {
|
||||
'type': 'resize',
|
||||
'volume_name': volume.name,
|
||||
'size_gigabytes': sizeGb,
|
||||
'size_gigabytes': size.gibibyte,
|
||||
'region': region,
|
||||
},
|
||||
);
|
||||
|
|
|
@ -281,7 +281,10 @@ class HetznerApi extends ServerProviderApi with VolumeProviderApi {
|
|||
}
|
||||
|
||||
@override
|
||||
Future<bool> resizeVolume(final ServerVolume volume, final int sizeGb) async {
|
||||
Future<bool> resizeVolume(
|
||||
final ServerVolume volume,
|
||||
final DiskSize size,
|
||||
) async {
|
||||
bool success = false;
|
||||
|
||||
final Response dbPostResponse;
|
||||
|
@ -290,7 +293,7 @@ class HetznerApi extends ServerProviderApi with VolumeProviderApi {
|
|||
dbPostResponse = await client.post(
|
||||
'/volumes/$volume.id/actions/resize',
|
||||
data: {
|
||||
'size': sizeGb,
|
||||
'size': size.gibibyte,
|
||||
},
|
||||
);
|
||||
success = dbPostResponse.data['action']['status'].toString() != 'error';
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:selfprivacy/logic/api_maps/rest_maps/api_map.dart';
|
||||
import 'package:selfprivacy/logic/models/disk_size.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
||||
import 'package:selfprivacy/logic/models/price.dart';
|
||||
|
||||
|
@ -7,7 +8,7 @@ mixin VolumeProviderApi on ApiMap {
|
|||
Future<List<ServerVolume>> getVolumes({final String? status});
|
||||
Future<bool> attachVolume(final ServerVolume volume, final int serverId);
|
||||
Future<bool> detachVolume(final ServerVolume volume);
|
||||
Future<bool> resizeVolume(final ServerVolume volume, final int sizeGb);
|
||||
Future<bool> resizeVolume(final ServerVolume volume, final DiskSize size);
|
||||
Future<void> deleteVolume(final ServerVolume volume);
|
||||
Future<Price?> getPricePerGb();
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import 'package:selfprivacy/logic/api_maps/rest_maps/api_factory_settings.dart';
|
|||
import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/server_provider_factory.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/models/disk_size.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
||||
import 'package:selfprivacy/logic/models/disk_status.dart';
|
||||
import 'package:selfprivacy/logic/models/price.dart';
|
||||
|
@ -76,7 +77,7 @@ class ApiProviderVolumeCubit
|
|||
|
||||
Future<bool> resizeVolume(
|
||||
final DiskVolume volume,
|
||||
final int newSizeGb,
|
||||
final DiskSize newSize,
|
||||
final Function() callback,
|
||||
) async {
|
||||
getIt<NavigationService>().showSnackBar(
|
||||
|
@ -85,7 +86,7 @@ class ApiProviderVolumeCubit
|
|||
emit(state.copyWith(isResizing: true));
|
||||
final bool resized = await providerApi!.getVolumeProvider().resizeVolume(
|
||||
volume.providerVolume!,
|
||||
newSizeGb,
|
||||
newSize,
|
||||
);
|
||||
|
||||
if (!resized) {
|
||||
|
|
|
@ -153,7 +153,7 @@ class _ExtendingVolumePageState extends State<ExtendingVolumePage> {
|
|||
: () {
|
||||
context.read<ApiProviderVolumeCubit>().resizeVolume(
|
||||
widget.diskVolumeToResize,
|
||||
_currentSliderGbValue.round(),
|
||||
DiskSize.fromGibibyte(_currentSliderGbValue),
|
||||
context.read<ApiServerVolumeCubit>().reload,
|
||||
);
|
||||
Navigator.of(context).pushAndRemoveUntil(
|
||||
|
|
Loading…
Reference in a new issue