Implement ServerJobCard
parent
37d5ee9913
commit
6014e385bc
|
@ -5,7 +5,6 @@ import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/server_pro
|
|||
import 'package:selfprivacy/logic/common_enum/common_enum.dart';
|
||||
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
||||
import 'package:selfprivacy/logic/models/json/server_disk_volume.dart';
|
||||
import 'package:selfprivacy/ui/pages/server_storage/disk_status.dart';
|
||||
|
||||
part 'provider_volume_state.dart';
|
||||
|
@ -54,14 +53,18 @@ class ApiProviderVolumeCubit
|
|||
emit(ApiProviderVolumeState(volumes, LoadingStatus.success));
|
||||
}
|
||||
|
||||
Future<void> attachVolume(final ServerVolume volume) async {
|
||||
Future<void> attachVolume(final DiskVolume volume) async {
|
||||
final ServerHostingDetails server = getIt<ApiConfigModel>().serverDetails!;
|
||||
await providerApi!.getVolumeProvider().attachVolume(volume.id, server.id);
|
||||
await providerApi!
|
||||
.getVolumeProvider()
|
||||
.attachVolume(volume.providerVolume!.id, server.id);
|
||||
refresh();
|
||||
}
|
||||
|
||||
Future<void> detachVolume(final ServerVolume volume) async {
|
||||
await providerApi!.getVolumeProvider().detachVolume(volume.id);
|
||||
Future<void> detachVolume(final DiskVolume volume) async {
|
||||
await providerApi!
|
||||
.getVolumeProvider()
|
||||
.detachVolume(volume.providerVolume!.id);
|
||||
refresh();
|
||||
}
|
||||
|
||||
|
@ -86,11 +89,14 @@ class ApiProviderVolumeCubit
|
|||
Future<void> createVolume() async {
|
||||
final ServerVolume? volume =
|
||||
await providerApi!.getVolumeProvider().createVolume();
|
||||
await attachVolume(volume!);
|
||||
|
||||
final diskVolume = DiskVolume();
|
||||
diskVolume.providerVolume = volume;
|
||||
await attachVolume(diskVolume);
|
||||
|
||||
await Future.delayed(const Duration(seconds: 10));
|
||||
|
||||
await ServerApi().mountVolume(volume.name);
|
||||
await ServerApi().mountVolume(volume!.name);
|
||||
refresh();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import 'package:selfprivacy/ui/components/brand_button/brand_button.dart';
|
|||
import 'package:selfprivacy/ui/components/brand_cards/brand_cards.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_loader/brand_loader.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_text/brand_text.dart';
|
||||
import 'package:selfprivacy/ui/components/jobs_content/server_job_card.dart';
|
||||
|
||||
class JobsContent extends StatelessWidget {
|
||||
const JobsContent({final super.key});
|
||||
|
@ -117,7 +118,15 @@ class JobsContent extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
...widgets
|
||||
...widgets,
|
||||
const SizedBox(height: 8),
|
||||
const Divider(),
|
||||
const SizedBox(height: 8),
|
||||
...state.serverJobList.map(
|
||||
(final job) => ServerJobCard(
|
||||
serverJob: job,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:selfprivacy/logic/models/json/server_job.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_cards/brand_cards.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_linear_indicator/brand_linear_indicator.dart';
|
||||
|
||||
class ServerJobCard extends StatelessWidget {
|
||||
const ServerJobCard({
|
||||
required final this.serverJob,
|
||||
final super.key,
|
||||
});
|
||||
|
||||
final ServerJob serverJob;
|
||||
|
||||
@override
|
||||
Widget build(final BuildContext context) => GestureDetector(
|
||||
child: BrandCards.big(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
serverJob.name,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
Text(
|
||||
serverJob.description,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
BrandLinearIndicator(
|
||||
value: serverJob.progress == null
|
||||
? 0.0
|
||||
: serverJob.progress! / 100.0,
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
backgroundColor: Theme.of(context).colorScheme.surfaceVariant,
|
||||
height: 7.0,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue