2
0
mirror of https://github.com/inventree/inventree-app.git synced 2026-03-11 12:45:00 +00:00

Check server state (#782)

This commit is contained in:
Oliver
2026-02-27 23:03:25 +11:00
committed by GitHub
parent 958067a3f9
commit 5339d6acc0
3 changed files with 57 additions and 6 deletions

View File

@@ -298,6 +298,9 @@ class _ProfileEditState extends State<ProfileEditWidget> {
String name = "";
String server = "";
bool? serverStatus;
bool serverChecking = false;
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -411,6 +414,49 @@ class _ProfileEditState extends State<ProfileEditWidget> {
return null;
},
),
Divider(),
SizedBox(
width: double.infinity,
child: ElevatedButton.icon(
label: Text(L10().connectionCheck),
icon: serverStatus == true
? Icon(TablerIcons.circle_check, color: COLOR_SUCCESS)
: serverStatus == false
? Icon(TablerIcons.circle_x, color: COLOR_DANGER)
: Icon(TablerIcons.question_mark, color: COLOR_WARNING),
onPressed: serverChecking
? null
: () async {
if (serverChecking) {
return;
}
if (!formKey.currentState!.validate()) {
return;
}
if (mounted) {
setState(() {
serverStatus = null;
serverChecking = true;
});
}
formKey.currentState!.save();
InvenTreeAPI().checkServer(server: server).then((
result,
) {
if (mounted) {
setState(() {
serverStatus = result;
serverChecking = false;
});
}
});
},
),
),
],
),
padding: EdgeInsets.all(16),