refactor
This commit is contained in:
parent
2496679165
commit
7607fe68e2
@ -101,6 +101,35 @@ 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();
|
||||||
@ -253,33 +282,4 @@ 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');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ class _MountWidgetState extends State<MountWidget> {
|
|||||||
if (mount.mounted != null && !mount.mounted!)
|
if (mount.mounted != null && !mount.mounted!)
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.clear),
|
icon: Icon(Icons.clear),
|
||||||
onPressed: () => mount.clearPath(),
|
onPressed: () => mount.clearMountLocation(),
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user