added clear mount location
This commit is contained in:
parent
9841c3f29c
commit
89507bd0bd
@ -253,4 +253,33 @@ class Mount with ChangeNotifier {
|
||||
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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,19 +61,28 @@ class _MountWidgetState extends State<MountWidget> {
|
||||
mount.provider,
|
||||
style: TextStyle(color: textColor, fontWeight: FontWeight.bold),
|
||||
),
|
||||
trailing: 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),
|
||||
trailing: Row(
|
||||
children: [
|
||||
if (mount.mounted != null && !mount.mounted!)
|
||||
IconButton(
|
||||
icon: Icon(Icons.clear),
|
||||
onPressed: () => mount.clearPath(),
|
||||
),
|
||||
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