mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
Will display the exception of Server Connection
This commit is contained in:
@@ -37,7 +37,8 @@ class ServerStatus {
|
|||||||
List<DiskInfo> disk;
|
List<DiskInfo> disk;
|
||||||
TcpStatus tcp;
|
TcpStatus tcp;
|
||||||
NetSpeed netSpeed;
|
NetSpeed netSpeed;
|
||||||
|
String? failedInfo;
|
||||||
|
|
||||||
ServerStatus(this.cpu2Status, this.memory, this.sysVer, this.uptime,
|
ServerStatus(this.cpu2Status, this.memory, this.sysVer, this.uptime,
|
||||||
this.disk, this.tcp, this.netSpeed);
|
this.disk, this.tcp, this.netSpeed, {this.failedInfo});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ class ServerProvider extends BusyProvider {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_servers[idx].connectionState = ServerConnectionState.failed;
|
_servers[idx].connectionState = ServerConnectionState.failed;
|
||||||
|
_servers[idx].status.failedInfo = e.toString().split(', ')[1];
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
logger.warning(e);
|
logger.warning(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ class _ServerPageState extends State<ServerPage>
|
|||||||
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 12),
|
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 12),
|
||||||
textScaleFactor: 1.0,
|
textScaleFactor: 1.0,
|
||||||
),
|
),
|
||||||
Text(getTopRightStr(cs, ss.cpu2Status.temp, ss.uptime),
|
Text(getTopRightStr(cs, ss.cpu2Status.temp, ss.uptime, ss.failedInfo),
|
||||||
textScaleFactor: 1.0,
|
textScaleFactor: 1.0,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: _theme.textTheme.bodyText1!.color!.withAlpha(100),
|
color: _theme.textTheme.bodyText1!.color!.withAlpha(100),
|
||||||
@@ -149,7 +149,7 @@ class _ServerPageState extends State<ServerPage>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
String getTopRightStr(ServerConnectionState cs, String temp, String upTime) {
|
String getTopRightStr(ServerConnectionState cs, String temp, String upTime, String? failedInfo) {
|
||||||
switch (cs) {
|
switch (cs) {
|
||||||
case ServerConnectionState.disconnected:
|
case ServerConnectionState.disconnected:
|
||||||
return 'Disconnected';
|
return 'Disconnected';
|
||||||
@@ -158,7 +158,7 @@ class _ServerPageState extends State<ServerPage>
|
|||||||
case ServerConnectionState.connecting:
|
case ServerConnectionState.connecting:
|
||||||
return 'Connecting...';
|
return 'Connecting...';
|
||||||
case ServerConnectionState.failed:
|
case ServerConnectionState.failed:
|
||||||
return 'Failed';
|
return failedInfo ?? 'Failed';
|
||||||
default:
|
default:
|
||||||
return 'Unknown State';
|
return 'Unknown State';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
|||||||
final result = await locator<ServerProvider>()
|
final result = await locator<ServerProvider>()
|
||||||
.runSnippet(_selectedIndex, snippet);
|
.runSnippet(_selectedIndex, snippet);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
showRoundDialog(context, 'Result', Text(result), [
|
showRoundDialog(context, 'Result', Text(result, style: const TextStyle(fontSize: 13)), [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
child: const Text('Close'))
|
child: const Text('Close'))
|
||||||
|
|||||||
Reference in New Issue
Block a user