mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-06 16:14:15 +00:00
Merge branch 'master' into 'lints'
This commit is contained in:
commit
8dc5847c6c
|
@ -29,7 +29,7 @@ mixin ServerActionsApi on GraphQLApiMap {
|
||||||
print(response.exception.toString());
|
print(response.exception.toString());
|
||||||
}
|
}
|
||||||
if (response.parsedData!.rebootSystem.success) {
|
if (response.parsedData!.rebootSystem.success) {
|
||||||
time = DateTime.now();
|
time = DateTime.now().toUtc();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
|
|
|
@ -248,7 +248,7 @@ class ServerApi extends GraphQLApiMap
|
||||||
final GraphQLClient client = await getClient();
|
final GraphQLClient client = await getClient();
|
||||||
|
|
||||||
final input = Input$RecoveryKeyLimitsInput(
|
final input = Input$RecoveryKeyLimitsInput(
|
||||||
expirationDate: expirationDate,
|
expirationDate: expirationDate?.toUtc(),
|
||||||
uses: numberOfUses,
|
uses: numberOfUses,
|
||||||
);
|
);
|
||||||
final variables = Variables$Mutation$GetNewRecoveryApiKey(
|
final variables = Variables$Mutation$GetNewRecoveryApiKey(
|
||||||
|
|
|
@ -360,21 +360,14 @@ class HetznerApi extends RestApiMap {
|
||||||
return GenericResult(success: true, data: pricing);
|
return GenericResult(success: true, data: pricing);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<GenericResult<List<HetznerVolume>>> getVolumes({
|
Future<GenericResult<List<HetznerVolume>>> getVolumes() async {
|
||||||
final String? status,
|
|
||||||
}) async {
|
|
||||||
final List<HetznerVolume> volumes = [];
|
final List<HetznerVolume> volumes = [];
|
||||||
|
|
||||||
Response? getVolumesResonse;
|
Response? getVolumesResponse;
|
||||||
final Dio client = await getClient();
|
final Dio client = await getClient();
|
||||||
try {
|
try {
|
||||||
getVolumesResonse = await client.get(
|
getVolumesResponse = await client.get('/volumes');
|
||||||
'/volumes',
|
for (final volume in getVolumesResponse.data['volumes']) {
|
||||||
queryParameters: {
|
|
||||||
'status': status,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
for (final volume in getVolumesResonse.data['volumes']) {
|
|
||||||
volumes.add(HetznerVolume.fromJson(volume));
|
volumes.add(HetznerVolume.fromJson(volume));
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -391,8 +384,8 @@ class HetznerApi extends RestApiMap {
|
||||||
return GenericResult(
|
return GenericResult(
|
||||||
data: volumes,
|
data: volumes,
|
||||||
success: true,
|
success: true,
|
||||||
code: getVolumesResonse.statusCode,
|
code: getVolumesResponse.statusCode,
|
||||||
message: getVolumesResonse.statusMessage,
|
message: getVolumesResponse.statusMessage,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import 'package:selfprivacy/logic/models/server_type.dart';
|
||||||
import 'package:selfprivacy/ui/components/buttons/brand_button.dart';
|
import 'package:selfprivacy/ui/components/buttons/brand_button.dart';
|
||||||
import 'package:selfprivacy/ui/components/info_box/info_box.dart';
|
import 'package:selfprivacy/ui/components/info_box/info_box.dart';
|
||||||
import 'package:selfprivacy/ui/layouts/responsive_layout_with_infobox.dart';
|
import 'package:selfprivacy/ui/layouts/responsive_layout_with_infobox.dart';
|
||||||
|
import 'package:selfprivacy/utils/ui_helpers.dart';
|
||||||
|
|
||||||
class ServerTypePicker extends StatefulWidget {
|
class ServerTypePicker extends StatefulWidget {
|
||||||
const ServerTypePicker({
|
const ServerTypePicker({
|
||||||
|
@ -329,7 +330,7 @@ class SelectTypePage extends StatelessWidget {
|
||||||
'initializing.choose_server_type_payment_per_month'
|
'initializing.choose_server_type_payment_per_month'
|
||||||
.tr(
|
.tr(
|
||||||
args: [
|
args: [
|
||||||
'${(type.price.value + storagePrice + publicIpPrice).toStringAsFixed(4)} ${type.price.currency.shortcode}',
|
'${UiHelpers.formatWithPrecision(type.price.value + storagePrice + publicIpPrice)} ${type.price.currency.shortcode}',
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
|
@ -370,8 +371,10 @@ class SelectTypePage extends StatelessWidget {
|
||||||
'initializing.choose_server_type_payment_server'
|
'initializing.choose_server_type_payment_server'
|
||||||
.tr(
|
.tr(
|
||||||
args: [
|
args: [
|
||||||
type.price.value
|
UiHelpers
|
||||||
.toString(),
|
.formatWithPrecision(
|
||||||
|
type.price.value,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
|
@ -401,7 +404,10 @@ class SelectTypePage extends StatelessWidget {
|
||||||
'initializing.choose_server_type_payment_storage'
|
'initializing.choose_server_type_payment_storage'
|
||||||
.tr(
|
.tr(
|
||||||
args: [
|
args: [
|
||||||
storagePrice.toString(),
|
UiHelpers
|
||||||
|
.formatWithPrecision(
|
||||||
|
storagePrice,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
|
@ -432,8 +438,10 @@ class SelectTypePage extends StatelessWidget {
|
||||||
'initializing.choose_server_type_payment_ip'
|
'initializing.choose_server_type_payment_ip'
|
||||||
.tr(
|
.tr(
|
||||||
args: [
|
args: [
|
||||||
publicIpPrice
|
UiHelpers
|
||||||
.toString(),
|
.formatWithPrecision(
|
||||||
|
publicIpPrice,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
|
|
||||||
/// it's ui helpers use only for ui components, don't use for logic components.
|
/// it's ui helpers use only for ui components, don't use for logic components.
|
||||||
|
@ -5,4 +6,14 @@ import 'package:selfprivacy/logic/cubit/server_installation/server_installation_
|
||||||
class UiHelpers {
|
class UiHelpers {
|
||||||
static String getDomainName(final ServerInstallationState config) =>
|
static String getDomainName(final ServerInstallationState config) =>
|
||||||
config.isDomainSelected ? config.serverDomain!.domainName : 'example.com';
|
config.isDomainSelected ? config.serverDomain!.domainName : 'example.com';
|
||||||
|
|
||||||
|
static String formatWithPrecision(
|
||||||
|
final double value, {
|
||||||
|
final int fraction = 2,
|
||||||
|
}) {
|
||||||
|
final NumberFormat formatter = NumberFormat();
|
||||||
|
formatter.minimumFractionDigits = 0;
|
||||||
|
formatter.maximumFractionDigits = fraction;
|
||||||
|
return formatter.format(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue