mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2024-11-17 14:19:16 +00:00
feat(backups): Expose if the service can be backed up
This commit is contained in:
parent
62e906d1a4
commit
90ab4244f6
|
@ -254,6 +254,7 @@ type Service {
|
||||||
isMovable: Boolean!
|
isMovable: Boolean!
|
||||||
isRequired: Boolean!
|
isRequired: Boolean!
|
||||||
isEnabled: Boolean!
|
isEnabled: Boolean!
|
||||||
|
canBeBackedUp: Boolean!
|
||||||
status: ServiceStatusEnum!
|
status: ServiceStatusEnum!
|
||||||
url: String
|
url: String
|
||||||
dnsRecords: [DnsRecord!]
|
dnsRecords: [DnsRecord!]
|
||||||
|
|
|
@ -16,6 +16,7 @@ query AllServices {
|
||||||
isEnabled
|
isEnabled
|
||||||
isMovable
|
isMovable
|
||||||
isRequired
|
isRequired
|
||||||
|
canBeBackedUp
|
||||||
status
|
status
|
||||||
storageUsage {
|
storageUsage {
|
||||||
title
|
title
|
||||||
|
|
|
@ -101,7 +101,8 @@ class BackupsCubit extends ServerInstallationDependendCubit<BackupsState> {
|
||||||
}
|
}
|
||||||
await updateBackups();
|
await updateBackups();
|
||||||
getIt<NavigationService>().showSnackBar(
|
getIt<NavigationService>().showSnackBar(
|
||||||
'Backups repository is now initializing. It may take a while.');
|
'Backups repository is now initializing. It may take a while.',
|
||||||
|
);
|
||||||
|
|
||||||
emit(state.copyWith(preventActions: false));
|
emit(state.copyWith(preventActions: false));
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,10 @@ class ServicesState extends ServerInstallationDependendState {
|
||||||
final List<Service> services;
|
final List<Service> services;
|
||||||
final List<String> lockedServices;
|
final List<String> lockedServices;
|
||||||
|
|
||||||
|
List<Service> get servicesThatCanBeBackedUp => services.where(
|
||||||
|
(final service) => service.canBeBackedUp,
|
||||||
|
).toList();
|
||||||
|
|
||||||
bool isServiceLocked(final String serviceId) =>
|
bool isServiceLocked(final String serviceId) =>
|
||||||
lockedServices.contains(serviceId);
|
lockedServices.contains(serviceId);
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/services.graphql.
|
||||||
import 'package:selfprivacy/logic/models/disk_size.dart';
|
import 'package:selfprivacy/logic/models/disk_size.dart';
|
||||||
import 'package:selfprivacy/logic/models/json/dns_records.dart';
|
import 'package:selfprivacy/logic/models/json/dns_records.dart';
|
||||||
|
|
||||||
import '../api_maps/graphql_maps/schema/server_settings.graphql.dart';
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/server_settings.graphql.dart';
|
||||||
|
|
||||||
class Service {
|
class Service {
|
||||||
Service.fromGraphQL(final Query$AllServices$services$allServices service)
|
Service.fromGraphQL(final Query$AllServices$services$allServices service)
|
||||||
|
@ -17,6 +17,7 @@ class Service {
|
||||||
isEnabled: service.isEnabled,
|
isEnabled: service.isEnabled,
|
||||||
isRequired: service.isRequired,
|
isRequired: service.isRequired,
|
||||||
isMovable: service.isMovable,
|
isMovable: service.isMovable,
|
||||||
|
canBeBackedUp: service.canBeBackedUp,
|
||||||
status: ServiceStatus.fromGraphQL(service.status),
|
status: ServiceStatus.fromGraphQL(service.status),
|
||||||
storageUsage: ServiceStorageUsage(
|
storageUsage: ServiceStorageUsage(
|
||||||
used: DiskSize(byte: int.parse(service.storageUsage.usedSpace)),
|
used: DiskSize(byte: int.parse(service.storageUsage.usedSpace)),
|
||||||
|
@ -42,6 +43,7 @@ class Service {
|
||||||
required this.isEnabled,
|
required this.isEnabled,
|
||||||
required this.isRequired,
|
required this.isRequired,
|
||||||
required this.isMovable,
|
required this.isMovable,
|
||||||
|
required this.canBeBackedUp,
|
||||||
required this.status,
|
required this.status,
|
||||||
required this.storageUsage,
|
required this.storageUsage,
|
||||||
required this.svgIcon,
|
required this.svgIcon,
|
||||||
|
@ -75,6 +77,7 @@ class Service {
|
||||||
isEnabled: false,
|
isEnabled: false,
|
||||||
isRequired: false,
|
isRequired: false,
|
||||||
isMovable: false,
|
isMovable: false,
|
||||||
|
canBeBackedUp: false,
|
||||||
status: ServiceStatus.off,
|
status: ServiceStatus.off,
|
||||||
storageUsage: ServiceStorageUsage(
|
storageUsage: ServiceStorageUsage(
|
||||||
used: const DiskSize(byte: 0),
|
used: const DiskSize(byte: 0),
|
||||||
|
@ -91,6 +94,7 @@ class Service {
|
||||||
final bool isEnabled;
|
final bool isEnabled;
|
||||||
final bool isRequired;
|
final bool isRequired;
|
||||||
final bool isMovable;
|
final bool isMovable;
|
||||||
|
final bool canBeBackedUp;
|
||||||
final ServiceStatus status;
|
final ServiceStatus status;
|
||||||
final ServiceStorageUsage storageUsage;
|
final ServiceStorageUsage storageUsage;
|
||||||
final String svgIcon;
|
final String svgIcon;
|
||||||
|
|
|
@ -42,7 +42,7 @@ class _BackupDetailsPageState extends State<BackupDetailsPage>
|
||||||
final List<Backup> backups = context.watch<BackupsCubit>().state.backups;
|
final List<Backup> backups = context.watch<BackupsCubit>().state.backups;
|
||||||
final bool refreshing = context.watch<BackupsCubit>().state.refreshing;
|
final bool refreshing = context.watch<BackupsCubit>().state.refreshing;
|
||||||
final List<Service> services =
|
final List<Service> services =
|
||||||
context.watch<ServicesCubit>().state.services;
|
context.watch<ServicesCubit>().state.servicesThatCanBeBackedUp;
|
||||||
|
|
||||||
return BrandHeroScreen(
|
return BrandHeroScreen(
|
||||||
heroIcon: BrandIcons.save,
|
heroIcon: BrandIcons.save,
|
||||||
|
@ -73,7 +73,7 @@ class _BackupDetailsPageState extends State<BackupDetailsPage>
|
||||||
maxChildSize: 0.9,
|
maxChildSize: 0.9,
|
||||||
minChildSize: 0.4,
|
minChildSize: 0.4,
|
||||||
initialChildSize: 0.6,
|
initialChildSize: 0.6,
|
||||||
builder: (context, scrollController) =>
|
builder: (final context, final scrollController) =>
|
||||||
CreateBackupsModal(
|
CreateBackupsModal(
|
||||||
services: services,
|
services: services,
|
||||||
scrollController: scrollController,
|
scrollController: scrollController,
|
||||||
|
@ -202,9 +202,9 @@ class _BackupDetailsPageState extends State<BackupDetailsPage>
|
||||||
|
|
||||||
class CreateBackupsModal extends StatefulWidget {
|
class CreateBackupsModal extends StatefulWidget {
|
||||||
const CreateBackupsModal({
|
const CreateBackupsModal({
|
||||||
super.key,
|
|
||||||
required this.services,
|
required this.services,
|
||||||
required this.scrollController,
|
required this.scrollController,
|
||||||
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
final List<Service> services;
|
final List<Service> services;
|
||||||
|
@ -226,13 +226,17 @@ class _CreateBackupsModalState extends State<CreateBackupsModal> {
|
||||||
.read<ServerJobsCubit>()
|
.read<ServerJobsCubit>()
|
||||||
.state
|
.state
|
||||||
.backupJobList
|
.backupJobList
|
||||||
.where((final ServerJob job) =>
|
.where(
|
||||||
|
(final ServerJob job) =>
|
||||||
job.status == JobStatusEnum.running ||
|
job.status == JobStatusEnum.running ||
|
||||||
job.status == JobStatusEnum.created)
|
job.status == JobStatusEnum.created,
|
||||||
|
)
|
||||||
.map((final ServerJob job) => job.typeId.split('.')[1])
|
.map((final ServerJob job) => job.typeId.split('.')[1])
|
||||||
.toList();
|
.toList();
|
||||||
selectedServices.addAll(widget.services
|
selectedServices.addAll(
|
||||||
.where((final Service service) => !busyServices.contains(service.id)));
|
widget.services
|
||||||
|
.where((final Service service) => !busyServices.contains(service.id)),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -241,9 +245,11 @@ class _CreateBackupsModalState extends State<CreateBackupsModal> {
|
||||||
.watch<ServerJobsCubit>()
|
.watch<ServerJobsCubit>()
|
||||||
.state
|
.state
|
||||||
.backupJobList
|
.backupJobList
|
||||||
.where((final ServerJob job) =>
|
.where(
|
||||||
|
(final ServerJob job) =>
|
||||||
job.status == JobStatusEnum.running ||
|
job.status == JobStatusEnum.running ||
|
||||||
job.status == JobStatusEnum.created)
|
job.status == JobStatusEnum.created,
|
||||||
|
)
|
||||||
.map((final ServerJob job) => job.typeId.split('.')[1])
|
.map((final ServerJob job) => job.typeId.split('.')[1])
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
|
@ -253,7 +259,7 @@ class _CreateBackupsModalState extends State<CreateBackupsModal> {
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text(
|
Text(
|
||||||
'backup.create_new_select_headline'.tr(),
|
'backup.create_new_select_heading'.tr(),
|
||||||
style: Theme.of(context).textTheme.headlineSmall,
|
style: Theme.of(context).textTheme.headlineSmall,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
|
@ -265,8 +271,11 @@ class _CreateBackupsModalState extends State<CreateBackupsModal> {
|
||||||
if (value ?? true) {
|
if (value ?? true) {
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedServices.clear();
|
selectedServices.clear();
|
||||||
selectedServices.addAll(widget.services.where(
|
selectedServices.addAll(
|
||||||
(final service) => !busyServices.contains(service.id)));
|
widget.services.where(
|
||||||
|
(final service) => !busyServices.contains(service.id),
|
||||||
|
),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
selectedServices.clear();
|
selectedServices.clear();
|
||||||
|
@ -337,7 +346,7 @@ class _CreateBackupsModalState extends State<CreateBackupsModal> {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
'backup.create'.tr(),
|
'backup.start'.tr(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue