From b7b8d33bd92e79787abded8ac2a921172f253bee Mon Sep 17 00:00:00 2001 From: Junyuan Feng Date: Tue, 8 Feb 2022 19:04:55 +0800 Subject: [PATCH] Fix update server info failed. Display temp&uptime --- lib/data/res/build_data.dart | 8 ++++---- lib/view/page/server/edit.dart | 14 ++++++++++---- lib/view/page/server/tab.dart | 14 +++++++++++++- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index f72b31a3..1edce1e3 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,8 +2,8 @@ class BuildData { static const String name = "ServerBox"; - static const int build = 90; - static const String engine = "Flutter 2.10.0 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 5f105a6ca7 (6 days ago) • 2022-02-01 14:15:42 -0800\nEngine • revision 776efd2034\nTools • Dart 2.16.0 • DevTools 2.9.2\n"; - static const String buildAt = "2022-02-08 16:48:52.440919"; - static const int modifications = 5; + static const int build = 91; + static const String engine = "Flutter 2.10.0 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 5f105a6ca7 (7 days ago) • 2022-02-01 14:15:42 -0800\nEngine • revision 776efd2034\nTools • Dart 2.16.0 • DevTools 2.9.2\n"; + static const String buildAt = "2022-02-08 19:01:55.450937"; + static const int modifications = 3; } diff --git a/lib/view/page/server/edit.dart b/lib/view/page/server/edit.dart index 2464c9f1..fcb7e2e4 100644 --- a/lib/view/page/server/edit.dart +++ b/lib/view/page/server/edit.dart @@ -8,6 +8,7 @@ import 'package:toolbox/data/model/server/server_private_info.dart'; import 'package:toolbox/data/provider/private_key.dart'; import 'package:toolbox/data/provider/server.dart'; import 'package:toolbox/data/res/color.dart'; +import 'package:toolbox/data/store/private_key.dart'; import 'package:toolbox/locator.dart'; import 'package:toolbox/view/page/private_key/edit.dart'; import 'package:toolbox/view/widget/input_decoration.dart'; @@ -34,7 +35,7 @@ class _ServerEditPageState extends State with AfterLayoutMixin { bool usePublicKey = false; int _pubKeyIndex = -1; - late PrivateKeyInfo _keyInfo; + PrivateKeyInfo? _keyInfo; @override void initState() { @@ -188,10 +189,15 @@ class _ServerEditPageState extends State with AfterLayoutMixin { if (portController.text == '') { portController.text = '22'; } + + if (widget.spi != null && widget.spi!.pubKeyId != null) { + _keyInfo ??= locator().get(widget.spi!.pubKeyId!); + } + final authorization = usePublicKey ? { - "privateKey": _keyInfo.privateKey, - "passphrase": _keyInfo.password + "privateKey": _keyInfo!.privateKey, + "passphrase": _keyInfo!.password } : passwordController.text; final spi = ServerPrivateInfo( @@ -200,7 +206,7 @@ class _ServerEditPageState extends State with AfterLayoutMixin { port: int.parse(portController.text), user: usernameController.text, authorization: authorization, - pubKeyId: usePublicKey ? _keyInfo.id : null); + pubKeyId: usePublicKey ? _keyInfo!.id : null); if (widget.spi == null) { _serverProvider.addServer(spi); diff --git a/lib/view/page/server/tab.dart b/lib/view/page/server/tab.dart index 3824e979..6a8f1fa1 100644 --- a/lib/view/page/server/tab.dart +++ b/lib/view/page/server/tab.dart @@ -293,7 +293,19 @@ class _ServerPageState extends State case ServerConnectionState.disconnected: return 'Disconnected'; case ServerConnectionState.connected: - return temp == '' ? (upTime == '' ? 'Loading...' : upTime) : temp; + if (temp == '') { + if (upTime == '') { + return 'Loading...'; + } else { + return upTime; + } + } else { + if (upTime == '') { + return temp; + } else { + return '$temp | $upTime'; + } + } case ServerConnectionState.connecting: return 'Connecting...'; case ServerConnectionState.failed: