refactor: Apply formatting

This commit is contained in:
NaiJi 2022-10-18 05:38:26 +00:00
parent bb846b08c1
commit ea85ce6064
6 changed files with 24 additions and 37 deletions

View file

@ -194,7 +194,8 @@ class DigitalOceanApi extends ServerProviderApi with VolumeProviderApi {
} }
@override @override
Future<bool> attachVolume(final ServerVolume volume, final int serverId) async { Future<bool> attachVolume(
final ServerVolume volume, final int serverId) async {
bool success = false; bool success = false;
final Response dbPostResponse; final Response dbPostResponse;
@ -311,8 +312,7 @@ class DigitalOceanApi extends ServerProviderApi with VolumeProviderApi {
final int serverId = serverCreateResponse.data['server']['id']; final int serverId = serverCreateResponse.data['server']['id'];
final ServerVolume? newVolume = await createVolume(); final ServerVolume? newVolume = await createVolume();
final bool attachedVolume = final bool attachedVolume = await attachVolume(newVolume!, serverId);
await attachVolume(newVolume!, serverId);
if (attachedVolume) { if (attachedVolume) {
serverDetails = ServerHostingDetails( serverDetails = ServerHostingDetails(
@ -367,10 +367,12 @@ class DigitalOceanApi extends ServerProviderApi with VolumeProviderApi {
final Dio client = await getClient(); final Dio client = await getClient();
try { try {
await client.post('/droplets/${server.id}/actions', await client.post(
data: { '/droplets/${server.id}/actions',
'type': 'reboot', data: {
},); 'type': 'reboot',
},
);
} catch (e) { } catch (e) {
print(e); print(e);
} finally { } finally {
@ -386,10 +388,11 @@ class DigitalOceanApi extends ServerProviderApi with VolumeProviderApi {
final Dio client = await getClient(); final Dio client = await getClient();
try { try {
await client.post('/droplets/${server.id}/actions', await client.post(
data: { '/droplets/${server.id}/actions',
'type': 'power_on', data: {
}, 'type': 'power_on',
},
); );
} catch (e) { } catch (e) {
print(e); print(e);

View file

@ -229,7 +229,8 @@ class HetznerApi extends ServerProviderApi with VolumeProviderApi {
} }
@override @override
Future<bool> attachVolume(final ServerVolume volume, final int serverId) async { Future<bool> attachVolume(
final ServerVolume volume, final int serverId) async {
bool success = false; bool success = false;
final Response dbPostResponse; final Response dbPostResponse;

View file

@ -7,16 +7,10 @@ import 'package:selfprivacy/logic/cubit/forms/validations/validations.dart';
class ProviderFormCubit extends FormCubit { class ProviderFormCubit extends FormCubit {
ProviderFormCubit(this.serverInstallationCubit) { ProviderFormCubit(this.serverInstallationCubit) {
final RegExp regExp =
serverInstallationCubit.getServerProviderApiTokenValidation();
apiKey = FieldCubit( apiKey = FieldCubit(
initalValue: '', initalValue: '',
validations: [ validations: [
RequiredStringValidation('validations.required'.tr()), RequiredStringValidation('validations.required'.tr()),
ValidationModel<String>(
regExp.hasMatch,
'validations.invalid_format'.tr(),
),
LengthStringNotEqualValidation(64) LengthStringNotEqualValidation(64)
], ],
); );

View file

@ -71,9 +71,7 @@ class ApiProviderVolumeCubit
} }
Future<void> detachVolume(final DiskVolume volume) async { Future<void> detachVolume(final DiskVolume volume) async {
await providerApi! await providerApi!.getVolumeProvider().detachVolume(volume.providerVolume!);
.getVolumeProvider()
.detachVolume(volume.providerVolume!);
refresh(); refresh();
} }
@ -135,9 +133,7 @@ class ApiProviderVolumeCubit
} }
Future<void> deleteVolume(final DiskVolume volume) async { Future<void> deleteVolume(final DiskVolume volume) async {
await providerApi! await providerApi!.getVolumeProvider().deleteVolume(volume.providerVolume!);
.getVolumeProvider()
.deleteVolume(volume.providerVolume!);
refresh(); refresh();
} }

View file

@ -141,13 +141,13 @@ class InitializingPage extends StatelessWidget {
} }
Widget _stepServerProviderToken( Widget _stepServerProviderToken(
final ServerInstallationCubit serverInstallationCubit) => final ServerInstallationCubit serverInstallationCubit,
ServerProviderPicker( ) =>
serverInstallationCubit: serverInstallationCubit, const ServerProviderPicker();
);
Widget _stepServerType( Widget _stepServerType(
final ServerInstallationCubit serverInstallationCubit) => final ServerInstallationCubit serverInstallationCubit,
) =>
ServerTypePicker( ServerTypePicker(
serverInstallationCubit: serverInstallationCubit, serverInstallationCubit: serverInstallationCubit,
); );

View file

@ -11,12 +11,9 @@ import 'package:selfprivacy/ui/components/brand_md/brand_md.dart';
class ServerProviderPicker extends StatefulWidget { class ServerProviderPicker extends StatefulWidget {
const ServerProviderPicker({ const ServerProviderPicker({
required this.serverInstallationCubit,
super.key, super.key,
}); });
final ServerInstallationCubit serverInstallationCubit;
@override @override
State<ServerProviderPicker> createState() => _ServerProviderPickerState(); State<ServerProviderPicker> createState() => _ServerProviderPickerState();
} }
@ -40,7 +37,6 @@ class _ServerProviderPickerState extends State<ServerProviderPicker> {
case ServerProvider.hetzner: case ServerProvider.hetzner:
return ProviderInputDataPage( return ProviderInputDataPage(
serverInstallationCubit: widget.serverInstallationCubit,
providerInfo: ProviderPageInfo( providerInfo: ProviderPageInfo(
providerType: ServerProvider.hetzner, providerType: ServerProvider.hetzner,
pathToHow: 'hetzner_how', pathToHow: 'hetzner_how',
@ -53,7 +49,6 @@ class _ServerProviderPickerState extends State<ServerProviderPicker> {
case ServerProvider.digitalOcean: case ServerProvider.digitalOcean:
return ProviderInputDataPage( return ProviderInputDataPage(
serverInstallationCubit: widget.serverInstallationCubit,
providerInfo: ProviderPageInfo( providerInfo: ProviderPageInfo(
providerType: ServerProvider.digitalOcean, providerType: ServerProvider.digitalOcean,
pathToHow: 'hetzner_how', pathToHow: 'hetzner_how',
@ -82,17 +77,15 @@ class ProviderPageInfo {
class ProviderInputDataPage extends StatelessWidget { class ProviderInputDataPage extends StatelessWidget {
const ProviderInputDataPage({ const ProviderInputDataPage({
required this.providerInfo, required this.providerInfo,
required this.serverInstallationCubit,
super.key, super.key,
}); });
final ProviderPageInfo providerInfo; final ProviderPageInfo providerInfo;
final ServerInstallationCubit serverInstallationCubit;
@override @override
Widget build(final BuildContext context) => BlocProvider( Widget build(final BuildContext context) => BlocProvider(
create: (final context) => ProviderFormCubit( create: (final context) => ProviderFormCubit(
serverInstallationCubit, context.watch<ServerInstallationCubit>(),
), ),
child: Builder( child: Builder(
builder: (final context) { builder: (final context) {