added mount support
This commit is contained in:
@ -48,11 +48,11 @@ class Mount with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> mount(bool unmount) async {
|
||||
Future<void> mount(bool unmount, {String? location}) async {
|
||||
await http.post(
|
||||
Uri.parse(
|
||||
Uri.encodeFull(
|
||||
'${Uri.base.origin}/api/v1/mount?unmount=$unmount&name=$name&type=$type',
|
||||
'${Uri.base.origin}/api/v1/mount?unmount=$unmount&name=$name&type=$type&location=$location',
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -76,4 +76,8 @@ class Mount with ChangeNotifier {
|
||||
|
||||
return refresh();
|
||||
}
|
||||
|
||||
Future<String?> getMountLocation() async {
|
||||
return "~/mnt/encrypt";
|
||||
}
|
||||
}
|
||||
|
@ -65,30 +65,29 @@ class _MountWidgetState extends State<MountWidget> {
|
||||
),
|
||||
onPressed:
|
||||
_enabled
|
||||
? () {
|
||||
? () async {
|
||||
setState(() {
|
||||
_enabled = false;
|
||||
});
|
||||
|
||||
if (isActive) {
|
||||
mount
|
||||
.mount(isActive)
|
||||
.then((_) {
|
||||
setState(() {
|
||||
_enabled = true;
|
||||
});
|
||||
})
|
||||
.catchError((_) {
|
||||
setState(() {
|
||||
_enabled = true;
|
||||
});
|
||||
});
|
||||
return;
|
||||
String? location;
|
||||
if (!isActive) {
|
||||
location = await mount.getMountLocation();
|
||||
if (location == null) {}
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_enabled = true;
|
||||
});
|
||||
mount
|
||||
.mount(isActive, location: location)
|
||||
.then((_) {
|
||||
setState(() {
|
||||
_enabled = true;
|
||||
});
|
||||
})
|
||||
.catchError((_) {
|
||||
setState(() {
|
||||
_enabled = true;
|
||||
});
|
||||
});
|
||||
}
|
||||
: null,
|
||||
),
|
||||
|
Reference in New Issue
Block a user