Add remove mount capabilities to CLI and UI #62

This commit is contained in:
2025-10-05 13:15:48 -05:00
parent f09ec24092
commit b78782875d
3 changed files with 35 additions and 0 deletions

View File

@@ -282,6 +282,29 @@ class Mount with ChangeNotifier {
_isRefreshing = false;
}
Future<void> remove() async {
try {
final auth = await _auth.createAuth();
final response = await http.delete(
Uri.parse(
Uri.encodeFull(
'${getBaseUri()}/api/v1/remove_mount?auth=$auth&name=$name&type=$type}',
),
),
);
if (response.statusCode == 401) {
_auth.logoff();
}
if (response.statusCode == 200) {
_mountList?.remove(name, type);
}
} catch (e) {
debugPrint('$e');
}
}
Future<void> setValue(String key, String value) async {
try {
final auth = await _auth.createAuth();

View File

@@ -182,6 +182,11 @@ class MountList with ChangeNotifier {
notifyListeners();
}
void remove(String name, String type) {
_mountList.removeWhere((mount) => mount.name == name && mount.type == type);
notifyListeners();
}
Future<void> reset() async {
if (_mountList.isEmpty) {
return;

View File

@@ -89,6 +89,13 @@ class _MountWidgetState extends State<MountWidget>
],
),
),
if (!mounted)
AppIconButtonFramed(
icon: Icons.delete,
onTap: () async {
return mount.remove();
},
),
AppToggleButtonFramed(
mounted: mount.mounted,
onPressed: _createMountHandler(context, mount),