Compare commits
2 Commits
cc4991e211
...
4a598d00d1
Author | SHA1 | Date | |
---|---|---|---|
4a598d00d1 | |||
78037ed74f |
@ -210,12 +210,16 @@ void handlers::handle_get_mount_status(auto &&req, auto &&res) const {
|
|||||||
void handlers::handle_post_mount(auto &&req, auto &&res) const {
|
void handlers::handle_post_mount(auto &&req, auto &&res) const {
|
||||||
auto type = req.get_param_value("type");
|
auto type = req.get_param_value("type");
|
||||||
auto name = req.get_param_value("name");
|
auto name = req.get_param_value("name");
|
||||||
|
auto location = utils::path::absolute(req.get_param_value("location"));
|
||||||
auto unmount = utils::string::to_bool(req.get_param_value("unmount"));
|
auto unmount = utils::string::to_bool(req.get_param_value("unmount"));
|
||||||
auto prov = provider_type_from_string(type);
|
auto prov = provider_type_from_string(type);
|
||||||
|
|
||||||
if (unmount) {
|
if (unmount) {
|
||||||
read_process(prov, name, "-unmount");
|
read_process(prov, name, "-unmount");
|
||||||
|
} else {
|
||||||
|
read_process(prov, name, fmt::format("\"{}\"", location));
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status = http_error_codes::ok;
|
res.status = http_error_codes::ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,11 +48,11 @@ class Mount with ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> mount(bool unmount) async {
|
Future<void> mount(bool unmount, {String? location}) async {
|
||||||
await http.post(
|
await http.post(
|
||||||
Uri.parse(
|
Uri.parse(
|
||||||
Uri.encodeFull(
|
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();
|
return refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<String?> getMountLocation() async {
|
||||||
|
return "~/mnt/encrypt";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,30 +65,29 @@ class _MountWidgetState extends State<MountWidget> {
|
|||||||
),
|
),
|
||||||
onPressed:
|
onPressed:
|
||||||
_enabled
|
_enabled
|
||||||
? () {
|
? () async {
|
||||||
setState(() {
|
setState(() {
|
||||||
_enabled = false;
|
_enabled = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isActive) {
|
String? location;
|
||||||
mount
|
if (!isActive) {
|
||||||
.mount(isActive)
|
location = await mount.getMountLocation();
|
||||||
.then((_) {
|
if (location == null) {}
|
||||||
setState(() {
|
|
||||||
_enabled = true;
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catchError((_) {
|
|
||||||
setState(() {
|
|
||||||
_enabled = true;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(() {
|
mount
|
||||||
_enabled = true;
|
.mount(isActive, location: location)
|
||||||
});
|
.then((_) {
|
||||||
|
setState(() {
|
||||||
|
_enabled = true;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catchError((_) {
|
||||||
|
setState(() {
|
||||||
|
_enabled = true;
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user