Compare commits
No commits in common. "e886940999ed3196359030340816139702baf491" and "7d1574d0425bb7e2bbe77e4d6255eadcc1033519" have entirely different histories.
e886940999
...
7d1574d042
@ -64,10 +64,9 @@ private:
|
|||||||
|
|
||||||
void handle_get_mount_status(auto &&req, auto &&res) const;
|
void handle_get_mount_status(auto &&req, auto &&res) const;
|
||||||
|
|
||||||
void handle_post_mount(auto &&req, auto &&res) const;
|
[[nodiscard]] static auto read_process(provider_type prov,
|
||||||
|
std::string_view name,
|
||||||
static auto read_process(provider_type prov, std::string_view name,
|
std::string_view command)
|
||||||
std::string_view command)
|
|
||||||
-> std::vector<std::string>;
|
-> std::vector<std::string>;
|
||||||
};
|
};
|
||||||
} // namespace repertory::ui
|
} // namespace repertory::ui
|
||||||
|
@ -83,9 +83,6 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server)
|
|||||||
handle_get_mount_status(req, res);
|
handle_get_mount_status(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
server->Post("/api/v1/mount",
|
|
||||||
[this](auto &&req, auto &&res) { handle_post_mount(req, res); });
|
|
||||||
|
|
||||||
event_system::instance().start();
|
event_system::instance().start();
|
||||||
|
|
||||||
static std::atomic<httplib::Server *> this_server{server_};
|
static std::atomic<httplib::Server *> this_server{server_};
|
||||||
@ -203,18 +200,6 @@ void handlers::handle_get_mount_status(auto &&req, auto &&res) const {
|
|||||||
res.status = http_error_codes::ok;
|
res.status = http_error_codes::ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handlers::handle_post_mount(auto &&req, auto &&res) const {
|
|
||||||
auto type = req.get_param_value("type");
|
|
||||||
auto name = req.get_param_value("name");
|
|
||||||
auto unmount = utils::string::to_bool(req.get_param_value("unmount"));
|
|
||||||
auto prov = provider_type_from_string(type);
|
|
||||||
|
|
||||||
if (unmount) {
|
|
||||||
read_process(prov, name, "-unmount");
|
|
||||||
}
|
|
||||||
res.status = http_error_codes::ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto handlers::read_process(provider_type prov, std::string_view name,
|
auto handlers::read_process(provider_type prov, std::string_view name,
|
||||||
std::string_view command)
|
std::string_view command)
|
||||||
-> std::vector<std::string> {
|
-> std::vector<std::string> {
|
||||||
|
@ -48,18 +48,6 @@ class Mount with ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> mount(bool unmount) async {
|
|
||||||
await http.post(
|
|
||||||
Uri.parse(
|
|
||||||
Uri.encodeFull(
|
|
||||||
'${Uri.base.origin}/api/v1/mount?unmount=$unmount&name=$name&type=$type',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
return refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> refresh() async {
|
Future<void> refresh() async {
|
||||||
await _fetch();
|
await _fetch();
|
||||||
return _fetchStatus();
|
return _fetchStatus();
|
||||||
|
@ -14,7 +14,6 @@ class MountWidget extends StatefulWidget {
|
|||||||
|
|
||||||
class _MountWidgetState extends State<MountWidget> {
|
class _MountWidgetState extends State<MountWidget> {
|
||||||
Timer? _timer;
|
Timer? _timer;
|
||||||
bool _enabled = true;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -58,27 +57,7 @@ class _MountWidgetState extends State<MountWidget> {
|
|||||||
mount.state,
|
mount.state,
|
||||||
color: isActive ? Colors.blue : Colors.grey,
|
color: isActive ? Colors.blue : Colors.grey,
|
||||||
),
|
),
|
||||||
onPressed:
|
onPressed: () {},
|
||||||
_enabled
|
|
||||||
? () async {
|
|
||||||
setState(() {
|
|
||||||
_enabled = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (isActive) {
|
|
||||||
mount.mount(isActive).then((_) {
|
|
||||||
setState(() {
|
|
||||||
_enabled = true;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
_enabled = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user