added clear mount location

This commit is contained in:
Scott E. Graves 2025-03-24 12:57:47 -05:00
parent 9841c3f29c
commit 89507bd0bd
2 changed files with 51 additions and 13 deletions

View File

@ -253,4 +253,33 @@ class Mount with ChangeNotifier {
debugPrint('$e'); debugPrint('$e');
} }
} }
Future<void> clearPath() 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');
}
}
} }

View File

@ -61,19 +61,28 @@ class _MountWidgetState extends State<MountWidget> {
mount.provider, mount.provider,
style: TextStyle(color: textColor, fontWeight: FontWeight.bold), style: TextStyle(color: textColor, fontWeight: FontWeight.bold),
), ),
trailing: IconButton( trailing: Row(
icon: Icon( children: [
mount.mounted == null if (mount.mounted != null && !mount.mounted!)
? Icons.hourglass_top IconButton(
: mount.mounted! icon: Icon(Icons.clear),
? Icons.toggle_on onPressed: () => mount.clearPath(),
: Icons.toggle_off, ),
color: IconButton(
mount.mounted ?? false icon: Icon(
? Color.fromARGB(255, 163, 96, 76) mount.mounted == null
: subTextColor, ? Icons.hourglass_top
), : mount.mounted!
onPressed: _createMountHandler(context, mount), ? Icons.toggle_on
: Icons.toggle_off,
color:
mount.mounted ?? false
? Color.fromARGB(255, 163, 96, 76)
: subTextColor,
),
onPressed: _createMountHandler(context, mount),
),
],
), ),
); );
}, },