mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-04 23:24:20 +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());
|
||||
}
|
||||
if (response.parsedData!.rebootSystem.success) {
|
||||
time = DateTime.now();
|
||||
time = DateTime.now().toUtc();
|
||||
}
|
||||
} catch (e) {
|
||||
print(e);
|
||||
|
|
|
@ -248,7 +248,7 @@ class ServerApi extends GraphQLApiMap
|
|||
final GraphQLClient client = await getClient();
|
||||
|
||||
final input = Input$RecoveryKeyLimitsInput(
|
||||
expirationDate: expirationDate,
|
||||
expirationDate: expirationDate?.toUtc(),
|
||||
uses: numberOfUses,
|
||||
);
|
||||
final variables = Variables$Mutation$GetNewRecoveryApiKey(
|
||||
|
|
|
@ -360,21 +360,14 @@ class HetznerApi extends RestApiMap {
|
|||
return GenericResult(success: true, data: pricing);
|
||||
}
|
||||
|
||||
Future<GenericResult<List<HetznerVolume>>> getVolumes({
|
||||
final String? status,
|
||||
}) async {
|
||||
Future<GenericResult<List<HetznerVolume>>> getVolumes() async {
|
||||
final List<HetznerVolume> volumes = [];
|
||||
|
||||
Response? getVolumesResonse;
|
||||
Response? getVolumesResponse;
|
||||
final Dio client = await getClient();
|
||||
try {
|
||||
getVolumesResonse = await client.get(
|
||||
'/volumes',
|
||||
queryParameters: {
|
||||
'status': status,
|
||||
},
|
||||
);
|
||||
for (final volume in getVolumesResonse.data['volumes']) {
|
||||
getVolumesResponse = await client.get('/volumes');
|
||||
for (final volume in getVolumesResponse.data['volumes']) {
|
||||
volumes.add(HetznerVolume.fromJson(volume));
|
||||
}
|
||||
} catch (e) {
|
||||
|
@ -391,8 +384,8 @@ class HetznerApi extends RestApiMap {
|
|||
return GenericResult(
|
||||
data: volumes,
|
||||
success: true,
|
||||
code: getVolumesResonse.statusCode,
|
||||
message: getVolumesResonse.statusMessage,
|
||||
code: getVolumesResponse.statusCode,
|
||||
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/info_box/info_box.dart';
|
||||
import 'package:selfprivacy/ui/layouts/responsive_layout_with_infobox.dart';
|
||||
import 'package:selfprivacy/utils/ui_helpers.dart';
|
||||
|
||||
class ServerTypePicker extends StatefulWidget {
|
||||
const ServerTypePicker({
|
||||
|
@ -329,7 +330,7 @@ class SelectTypePage extends StatelessWidget {
|
|||
'initializing.choose_server_type_payment_per_month'
|
||||
.tr(
|
||||
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)
|
||||
|
@ -370,8 +371,10 @@ class SelectTypePage extends StatelessWidget {
|
|||
'initializing.choose_server_type_payment_server'
|
||||
.tr(
|
||||
args: [
|
||||
type.price.value
|
||||
.toString(),
|
||||
UiHelpers
|
||||
.formatWithPrecision(
|
||||
type.price.value,
|
||||
),
|
||||
],
|
||||
),
|
||||
style: Theme.of(context)
|
||||
|
@ -401,7 +404,10 @@ class SelectTypePage extends StatelessWidget {
|
|||
'initializing.choose_server_type_payment_storage'
|
||||
.tr(
|
||||
args: [
|
||||
storagePrice.toString(),
|
||||
UiHelpers
|
||||
.formatWithPrecision(
|
||||
storagePrice,
|
||||
),
|
||||
],
|
||||
),
|
||||
style: Theme.of(context)
|
||||
|
@ -432,8 +438,10 @@ class SelectTypePage extends StatelessWidget {
|
|||
'initializing.choose_server_type_payment_ip'
|
||||
.tr(
|
||||
args: [
|
||||
publicIpPrice
|
||||
.toString(),
|
||||
UiHelpers
|
||||
.formatWithPrecision(
|
||||
publicIpPrice,
|
||||
),
|
||||
],
|
||||
),
|
||||
style: Theme.of(context)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:intl/intl.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.
|
||||
|
@ -5,4 +6,14 @@ import 'package:selfprivacy/logic/cubit/server_installation/server_installation_
|
|||
class UiHelpers {
|
||||
static String getDomainName(final ServerInstallationState config) =>
|
||||
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