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!
|
||||
isRequired: Boolean!
|
||||
isEnabled: Boolean!
|
||||
canBeBackedUp: Boolean!
|
||||
status: ServiceStatusEnum!
|
||||
url: String
|
||||
dnsRecords: [DnsRecord!]
|
||||
|
|
|
@ -16,6 +16,7 @@ query AllServices {
|
|||
isEnabled
|
||||
isMovable
|
||||
isRequired
|
||||
canBeBackedUp
|
||||
status
|
||||
storageUsage {
|
||||
title
|
||||
|
|
|
@ -101,7 +101,8 @@ class BackupsCubit extends ServerInstallationDependendCubit<BackupsState> {
|
|||
}
|
||||
await updateBackups();
|
||||
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));
|
||||
}
|
||||
|
|
|
@ -12,6 +12,10 @@ class ServicesState extends ServerInstallationDependendState {
|
|||
final List<Service> services;
|
||||
final List<String> lockedServices;
|
||||
|
||||
List<Service> get servicesThatCanBeBackedUp => services.where(
|
||||
(final service) => service.canBeBackedUp,
|
||||
).toList();
|
||||
|
||||
bool isServiceLocked(final String 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/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 {
|
||||
Service.fromGraphQL(final Query$AllServices$services$allServices service)
|
||||
|
@ -17,6 +17,7 @@ class Service {
|
|||
isEnabled: service.isEnabled,
|
||||
isRequired: service.isRequired,
|
||||
isMovable: service.isMovable,
|
||||
canBeBackedUp: service.canBeBackedUp,
|
||||
status: ServiceStatus.fromGraphQL(service.status),
|
||||
storageUsage: ServiceStorageUsage(
|
||||
used: DiskSize(byte: int.parse(service.storageUsage.usedSpace)),
|
||||
|
@ -42,6 +43,7 @@ class Service {
|
|||
required this.isEnabled,
|
||||
required this.isRequired,
|
||||
required this.isMovable,
|
||||
required this.canBeBackedUp,
|
||||
required this.status,
|
||||
required this.storageUsage,
|
||||
required this.svgIcon,
|
||||
|
@ -75,6 +77,7 @@ class Service {
|
|||
isEnabled: false,
|
||||
isRequired: false,
|
||||
isMovable: false,
|
||||
canBeBackedUp: false,
|
||||
status: ServiceStatus.off,
|
||||
storageUsage: ServiceStorageUsage(
|
||||
used: const DiskSize(byte: 0),
|
||||
|
@ -91,6 +94,7 @@ class Service {
|
|||
final bool isEnabled;
|
||||
final bool isRequired;
|
||||
final bool isMovable;
|
||||
final bool canBeBackedUp;
|
||||
final ServiceStatus status;
|
||||
final ServiceStorageUsage storageUsage;
|
||||
final String svgIcon;
|
||||
|
|
|
@ -42,7 +42,7 @@ class _BackupDetailsPageState extends State<BackupDetailsPage>
|
|||
final List<Backup> backups = context.watch<BackupsCubit>().state.backups;
|
||||
final bool refreshing = context.watch<BackupsCubit>().state.refreshing;
|
||||
final List<Service> services =
|
||||
context.watch<ServicesCubit>().state.services;
|
||||
context.watch<ServicesCubit>().state.servicesThatCanBeBackedUp;
|
||||
|
||||
return BrandHeroScreen(
|
||||
heroIcon: BrandIcons.save,
|
||||
|
@ -73,7 +73,7 @@ class _BackupDetailsPageState extends State<BackupDetailsPage>
|
|||
maxChildSize: 0.9,
|
||||
minChildSize: 0.4,
|
||||
initialChildSize: 0.6,
|
||||
builder: (context, scrollController) =>
|
||||
builder: (final context, final scrollController) =>
|
||||
CreateBackupsModal(
|
||||
services: services,
|
||||
scrollController: scrollController,
|
||||
|
@ -202,9 +202,9 @@ class _BackupDetailsPageState extends State<BackupDetailsPage>
|
|||
|
||||
class CreateBackupsModal extends StatefulWidget {
|
||||
const CreateBackupsModal({
|
||||
super.key,
|
||||
required this.services,
|
||||
required this.scrollController,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final List<Service> services;
|
||||
|
@ -226,13 +226,17 @@ class _CreateBackupsModalState extends State<CreateBackupsModal> {
|
|||
.read<ServerJobsCubit>()
|
||||
.state
|
||||
.backupJobList
|
||||
.where((final ServerJob job) =>
|
||||
.where(
|
||||
(final ServerJob job) =>
|
||||
job.status == JobStatusEnum.running ||
|
||||
job.status == JobStatusEnum.created)
|
||||
job.status == JobStatusEnum.created,
|
||||
)
|
||||
.map((final ServerJob job) => job.typeId.split('.')[1])
|
||||
.toList();
|
||||
selectedServices.addAll(widget.services
|
||||
.where((final Service service) => !busyServices.contains(service.id)));
|
||||
selectedServices.addAll(
|
||||
widget.services
|
||||
.where((final Service service) => !busyServices.contains(service.id)),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -241,9 +245,11 @@ class _CreateBackupsModalState extends State<CreateBackupsModal> {
|
|||
.watch<ServerJobsCubit>()
|
||||
.state
|
||||
.backupJobList
|
||||
.where((final ServerJob job) =>
|
||||
.where(
|
||||
(final ServerJob job) =>
|
||||
job.status == JobStatusEnum.running ||
|
||||
job.status == JobStatusEnum.created)
|
||||
job.status == JobStatusEnum.created,
|
||||
)
|
||||
.map((final ServerJob job) => job.typeId.split('.')[1])
|
||||
.toList();
|
||||
|
||||
|
@ -253,7 +259,7 @@ class _CreateBackupsModalState extends State<CreateBackupsModal> {
|
|||
children: [
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'backup.create_new_select_headline'.tr(),
|
||||
'backup.create_new_select_heading'.tr(),
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
|
@ -265,8 +271,11 @@ class _CreateBackupsModalState extends State<CreateBackupsModal> {
|
|||
if (value ?? true) {
|
||||
setState(() {
|
||||
selectedServices.clear();
|
||||
selectedServices.addAll(widget.services.where(
|
||||
(final service) => !busyServices.contains(service.id)));
|
||||
selectedServices.addAll(
|
||||
widget.services.where(
|
||||
(final service) => !busyServices.contains(service.id),
|
||||
),
|
||||
);
|
||||
});
|
||||
} else {
|
||||
selectedServices.clear();
|
||||
|
@ -337,7 +346,7 @@ class _CreateBackupsModalState extends State<CreateBackupsModal> {
|
|||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(
|
||||
'backup.create'.tr(),
|
||||
'backup.start'.tr(),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue