Add remove mount capabilities to CLI and UI #62
This commit is contained in:
@@ -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();
|
||||
|
@@ -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;
|
||||
|
@@ -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),
|
||||
|
Reference in New Issue
Block a user