[ui] Implement provider test button #49
This commit is contained in:
parent
1880c50fd8
commit
5f50e0204a
@ -15,6 +15,7 @@
|
||||
* \#46 [bug] Changes to maximum cache size should be updated live
|
||||
* \#47 [bug] Windows-to-Linux remote mount is allowing directory rename when directory is not empty
|
||||
* \#48 [bug] Windows-to-Linux remote mount overlapped I/O is not detecting EOF for read operations
|
||||
* \#49 [ui] Implement provider test button
|
||||
|
||||
### Changes from v2.0.5-rc
|
||||
|
||||
|
@ -282,4 +282,27 @@ class Mount with ChangeNotifier {
|
||||
debugPrint('$e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> test() async {
|
||||
try {
|
||||
final auth = await _auth.createAuth();
|
||||
final response = await http.put(
|
||||
Uri.parse(
|
||||
Uri.encodeFull(
|
||||
'${getBaseUri()}/api/v1/test?auth=$auth&name=$name&type=$type&settings=${jsonEncode(mountConfig.settings)}',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (response.statusCode == 401) {
|
||||
_auth.logoff();
|
||||
}
|
||||
|
||||
return (response.statusCode == 200);
|
||||
} catch (e) {
|
||||
debugPrint('$e');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -113,8 +113,8 @@ class _AddMountScreenState extends State<AddMountScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_mount != null) const SizedBox(height: constants.padding),
|
||||
if (_mount != null)
|
||||
if (_mount != null) ...[
|
||||
const SizedBox(height: constants.padding),
|
||||
Expanded(
|
||||
child: Card(
|
||||
margin: EdgeInsets.all(0.0),
|
||||
@ -129,8 +129,7 @@ class _AddMountScreenState extends State<AddMountScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_mount != null) const SizedBox(height: constants.padding),
|
||||
if (_mount != null)
|
||||
const SizedBox(height: constants.padding),
|
||||
Row(
|
||||
children: [
|
||||
ElevatedButton.icon(
|
||||
@ -189,16 +188,15 @@ class _AddMountScreenState extends State<AddMountScreen> {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
if (_mountType == 'Sia' || _mountType == 'S3') ...[
|
||||
const SizedBox(width: constants.padding),
|
||||
ElevatedButton.icon(
|
||||
label: const Text('Test'),
|
||||
icon: const Icon(Icons.check),
|
||||
onPressed: () async {},
|
||||
),
|
||||
],
|
||||
const SizedBox(width: constants.padding),
|
||||
ElevatedButton.icon(
|
||||
label: const Text('Test'),
|
||||
icon: const Icon(Icons.check),
|
||||
onPressed: _handleProviderTest,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
},
|
||||
@ -234,6 +232,22 @@ class _AddMountScreenState extends State<AddMountScreen> {
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _handleProviderTest() async {
|
||||
if (_mount == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final success = await _mount!.test();
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
|
||||
displayErrorMessage(
|
||||
context,
|
||||
success ? "Success!" : "Provider settings are invalid!",
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void setState(VoidCallback fn) {
|
||||
if (!mounted) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user