fix test
display mountpoints in gui
This commit is contained in:
parent
6991e730d8
commit
c1d51d31cc
@ -59,7 +59,7 @@ class _DiskPageState extends State<DiskPage> {
|
|||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Provider.of<BreadCrumbController>(context, listen: false)
|
Provider.of<BreadCrumbController>(context, listen: false)
|
||||||
.pushPage(const DiskInfoPage(), data[idx].name);
|
.pushPage(DiskInfoPage(disk: data[idx]), data[idx].name);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -6,8 +6,9 @@ part 'disk.g.dart';
|
|||||||
class Disk {
|
class Disk {
|
||||||
String name;
|
String name;
|
||||||
int size;
|
int size;
|
||||||
|
List<String> mountpoints;
|
||||||
|
|
||||||
Disk(this.name, this.size);
|
Disk(this.name, this.size, this.mountpoints);
|
||||||
factory Disk.fromJson(Map<String, dynamic> json) => _$DiskFromJson(json);
|
factory Disk.fromJson(Map<String, dynamic> json) => _$DiskFromJson(json);
|
||||||
Map<String, dynamic> toJson() => _$DiskToJson(this);
|
Map<String, dynamic> toJson() => _$DiskToJson(this);
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,11 @@ part of 'disk.dart';
|
|||||||
Disk _$DiskFromJson(Map<String, dynamic> json) => Disk(
|
Disk _$DiskFromJson(Map<String, dynamic> json) => Disk(
|
||||||
json['name'] as String,
|
json['name'] as String,
|
||||||
json['size'] as int,
|
json['size'] as int,
|
||||||
|
(json['mountpoints'] as List<dynamic>).map((e) => e as String).toList(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$DiskToJson(Disk instance) => <String, dynamic>{
|
Map<String, dynamic> _$DiskToJson(Disk instance) => <String, dynamic>{
|
||||||
'name': instance.name,
|
'name': instance.name,
|
||||||
'size': instance.size,
|
'size': instance.size,
|
||||||
|
'mountpoints': instance.mountpoints,
|
||||||
};
|
};
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:raid_manager/utils/file_formatter.dart';
|
||||||
|
|
||||||
import '../breadcrumb_page/breadcrumb_controller.dart';
|
import '../breadcrumb_page/breadcrumb_controller.dart';
|
||||||
|
import '../types/disk.dart';
|
||||||
|
|
||||||
class DiskInfoPage extends StatefulWidget {
|
class DiskInfoPage extends StatefulWidget {
|
||||||
const DiskInfoPage({Key? key}) : super(key: key);
|
const DiskInfoPage({Key? key, required this.disk}) : super(key: key);
|
||||||
|
final Disk disk;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<DiskInfoPage> createState() => _DiskInfoPageState();
|
State<DiskInfoPage> createState() => _DiskInfoPageState();
|
||||||
@ -14,8 +17,14 @@ class _DiskInfoPageState extends State<DiskInfoPage> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const Text("Mysupercool page"),
|
Text("Name:",style: Theme.of(context).textTheme.labelMedium),
|
||||||
|
Text(widget.disk.name,style: Theme.of(context).textTheme.labelMedium),
|
||||||
|
Text("Size:",style: Theme.of(context).textTheme.labelMedium),
|
||||||
|
Text(widget.disk.size.readableFileSize(),style: Theme.of(context).textTheme.labelMedium),
|
||||||
|
Text("Mountpoints:",style: Theme.of(context).textTheme.labelMedium),
|
||||||
|
Text(widget.disk.mountpoints.toString(),style: Theme.of(context).textTheme.labelMedium),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Provider.of<BreadCrumbController>(context, listen: false)
|
Provider.of<BreadCrumbController>(context, listen: false)
|
||||||
|
@ -186,6 +186,6 @@ mod tests {
|
|||||||
{"name":"/dev/nvme0n1", "maj:min":"259:0", "rm":false, "size":1000204886016, "ro":false, "type":"disk", "mountpoint":"/media/hdd3"}
|
{"name":"/dev/nvme0n1", "maj:min":"259:0", "rm":false, "size":1000204886016, "ro":false, "type":"disk", "mountpoint":"/media/hdd3"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
"#.to_string())).to_string(), r#"[{"name":"/dev/sda","size":120034123776},{"name":"/dev/sdb","size":3000592982016},{"name":"/dev/sdc","size":3000592982016},{"name":"/dev/sdd","size":4000787030016},{"name":"/dev/sde","size":240057409536},{"name":"/dev/sdf","size":120034123776},{"name":"/dev/sdg","size":3000592982016},{"name":"/dev/nvme0n1","size":1000204886016}]"#);
|
"#.to_string())).to_string(), r#"[{"mountpoints":[],"name":"/dev/sda","size":120034123776},{"mountpoints":[],"name":"/dev/sdb","size":3000592982016},{"mountpoints":[],"name":"/dev/sdc","size":3000592982016},{"mountpoints":[],"name":"/dev/sdd","size":4000787030016},{"mountpoints":["/media/hdd1"],"name":"/dev/sde","size":240057409536},{"mountpoints":["/media/hdd2"],"name":"/dev/sdf","size":120034123776},{"mountpoints":[],"name":"/dev/sdg","size":3000592982016},{"mountpoints":["/media/hdd3"],"name":"/dev/nvme0n1","size":1000204886016}]"#);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user