Compare commits
No commits in common. "bbd4cc0eed28712c27c4284003027e89ff100fbc" and "9841c3f29ca28784f1c300323fb65ba6d4411f9e" have entirely different histories.
bbd4cc0eed
...
9841c3f29c
@ -74,9 +74,6 @@ private:
|
|||||||
[[nodiscard]] auto data_directory_exists(provider_type prov,
|
[[nodiscard]] auto data_directory_exists(provider_type prov,
|
||||||
std::string_view name) const -> bool;
|
std::string_view name) const -> bool;
|
||||||
|
|
||||||
void handle_delete_mount_location(const httplib::Request &req,
|
|
||||||
httplib::Response &res) const;
|
|
||||||
|
|
||||||
void handle_get_available_locations(httplib::Response &res) const;
|
void handle_get_available_locations(httplib::Response &res) const;
|
||||||
|
|
||||||
void handle_get_mount(const httplib::Request &req,
|
void handle_get_mount(const httplib::Request &req,
|
||||||
|
@ -168,10 +168,6 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server)
|
|||||||
: http_error_codes::internal_error;
|
: http_error_codes::internal_error;
|
||||||
});
|
});
|
||||||
|
|
||||||
server->Delete("/api/v1/mount_location", [this](auto &&req, auto &&res) {
|
|
||||||
handle_delete_mount_location(req, res);
|
|
||||||
});
|
|
||||||
|
|
||||||
server->Get("/api/v1/locations", [this](auto && /* req */, auto &&res) {
|
server->Get("/api/v1/locations", [this](auto && /* req */, auto &&res) {
|
||||||
handle_get_available_locations(res);
|
handle_get_available_locations(res);
|
||||||
});
|
});
|
||||||
@ -302,22 +298,6 @@ auto handlers::data_directory_exists(provider_type prov,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handlers::handle_delete_mount_location(const httplib::Request &req,
|
|
||||||
httplib::Response &res) const {
|
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
|
||||||
|
|
||||||
auto prov = provider_type_from_string(req.get_param_value("type"));
|
|
||||||
auto name = req.get_param_value("name");
|
|
||||||
|
|
||||||
if (not data_directory_exists(prov, name)) {
|
|
||||||
res.status = http_error_codes::not_found;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
config_->set_mount_location(prov, name, "");
|
|
||||||
res.status = http_error_codes::ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
void handlers::handle_get_available_locations(httplib::Response &res) const {
|
void handlers::handle_get_available_locations(httplib::Response &res) const {
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
constexpr const std::array<std::string_view, 26U> letters{
|
constexpr const std::array<std::string_view, 26U> letters{
|
||||||
|
@ -101,35 +101,6 @@ class Mount with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> clearMountLocation() async {
|
|
||||||
try {
|
|
||||||
mountConfig.path = "";
|
|
||||||
|
|
||||||
final auth = await _auth.createAuth();
|
|
||||||
final response = await http.delete(
|
|
||||||
Uri.parse(
|
|
||||||
Uri.encodeFull(
|
|
||||||
'${getBaseUri()}/api/v1/mount_location?auth=$auth&name=$name&type=$type',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.statusCode == 401) {
|
|
||||||
_auth.logoff();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response.statusCode == 404) {
|
|
||||||
_mountList?.reset();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return refresh();
|
|
||||||
} catch (e) {
|
|
||||||
debugPrint('$e');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<List<String>> getAvailableLocations() async {
|
Future<List<String>> getAvailableLocations() async {
|
||||||
try {
|
try {
|
||||||
final auth = await _auth.createAuth();
|
final auth = await _auth.createAuth();
|
||||||
|
@ -61,34 +61,19 @@ class _MountWidgetState extends State<MountWidget> {
|
|||||||
mount.provider,
|
mount.provider,
|
||||||
style: TextStyle(color: textColor, fontWeight: FontWeight.bold),
|
style: TextStyle(color: textColor, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
trailing: Row(
|
trailing: IconButton(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
icon: Icon(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mount.mounted == null
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
? Icons.hourglass_top
|
||||||
children: [
|
: mount.mounted!
|
||||||
if (mount.path.isNotEmpty &&
|
? Icons.toggle_on
|
||||||
mount.mounted != null &&
|
: Icons.toggle_off,
|
||||||
!mount.mounted!)
|
color:
|
||||||
IconButton(
|
mount.mounted ?? false
|
||||||
icon: const Icon(Icons.backspace),
|
? Color.fromARGB(255, 163, 96, 76)
|
||||||
color: subTextColor,
|
: subTextColor,
|
||||||
onPressed: () => mount.clearMountLocation(),
|
),
|
||||||
),
|
onPressed: _createMountHandler(context, mount),
|
||||||
IconButton(
|
|
||||||
icon: Icon(
|
|
||||||
mount.mounted == null
|
|
||||||
? Icons.hourglass_top
|
|
||||||
: mount.mounted!
|
|
||||||
? Icons.toggle_on
|
|
||||||
: Icons.toggle_off,
|
|
||||||
color:
|
|
||||||
mount.mounted ?? false
|
|
||||||
? Color.fromARGB(255, 163, 96, 76)
|
|
||||||
: subTextColor,
|
|
||||||
),
|
|
||||||
onPressed: _createMountHandler(context, mount),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user