From 1bd673a1647ede271e6d16c88ef25983535a349d Mon Sep 17 00:00:00 2001 From: Junyuan Feng Date: Wed, 25 May 2022 13:10:30 +0800 Subject: [PATCH] fix #3 - server edit page display bugs, include userPubKey and pubKeyIdx --- ios/Runner.xcodeproj/project.pbxproj | 12 +++++----- lib/core/build_mode.dart | 2 +- lib/core/provider_base.dart | 5 ---- lib/data/provider/app.dart | 11 --------- lib/data/provider/docker.dart | 32 +++++--------------------- lib/data/res/build_data.dart | 6 ++--- lib/data/service/app.dart | 5 ---- lib/view/page/server/edit.dart | 9 +++----- macos/Runner.xcodeproj/project.pbxproj | 12 +++++----- 9 files changed, 25 insertions(+), 69 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 4a88d634..914a78e3 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -354,7 +354,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 145; + CURRENT_PROJECT_VERSION = 146; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -362,7 +362,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.145; + MARKETING_VERSION = 1.0.146; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -484,7 +484,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 145; + CURRENT_PROJECT_VERSION = 146; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -492,7 +492,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.145; + MARKETING_VERSION = 1.0.146; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -508,7 +508,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 145; + CURRENT_PROJECT_VERSION = 146; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -516,7 +516,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.145; + MARKETING_VERSION = 1.0.146; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/lib/core/build_mode.dart b/lib/core/build_mode.dart index 413ba1e2..7fb28efb 100644 --- a/lib/core/build_mode.dart +++ b/lib/core/build_mode.dart @@ -6,7 +6,7 @@ enum _BuildMode { profile, } -_BuildMode _buildMode = (() { +final _buildMode = (() { if (const bool.fromEnvironment('dart.vm.product')) { return _BuildMode.release; } diff --git a/lib/core/provider_base.dart b/lib/core/provider_base.dart index d1ade13a..974dbabe 100644 --- a/lib/core/provider_base.dart +++ b/lib/core/provider_base.dart @@ -9,11 +9,6 @@ class ProviderBase with ChangeNotifier { } } -enum ProviderState { - idle, - busy, -} - class BusyProvider extends ProviderBase { bool _isBusy = false; bool get isBusy => _isBusy; diff --git a/lib/data/provider/app.dart b/lib/data/provider/app.dart index 0632e079..7c9ac521 100644 --- a/lib/data/provider/app.dart +++ b/lib/data/provider/app.dart @@ -1,20 +1,9 @@ import 'package:toolbox/core/provider_base.dart'; -import 'package:toolbox/data/service/app.dart'; class AppProvider extends BusyProvider { - Map? _notify; - Map? get notify => _notify; int? _newestBuild; int? get newestBuild => _newestBuild; - Future loadData() async { - setBusyState(true); - final service = AppService(); - _notify = await service.getNotify(); - setBusyState(false); - notifyListeners(); - } - void setNewestBuild(int build) { _newestBuild = build; notifyListeners(); diff --git a/lib/data/provider/docker.dart b/lib/data/provider/docker.dart index 7d58de78..da0a639c 100644 --- a/lib/data/provider/docker.dart +++ b/lib/data/provider/docker.dart @@ -66,42 +66,22 @@ class DockerProvider extends BusyProvider { } } - Future stop(String id) async { + Future _do(String id, String cmd) async { setBusyState(); if (client == null) { error = 'no client'; setBusyState(false); return false; } - final result = await client!.run('docker stop $id').string; + final result = await client!.run(cmd).string; await refresh(); setBusyState(false); return result.contains(id); } - Future start(String id) async { - setBusyState(); - if (client == null) { - error = 'no client'; - setBusyState(false); - return false; - } - final result = await client!.run('docker start $id').string; - await refresh(); - setBusyState(false); - return result.contains(id); - } + Future stop(String id) async => await _do(id, 'docker stop $id'); - Future delete(String id) async { - setBusyState(); - if (client == null) { - error = 'no client'; - setBusyState(false); - return false; - } - final result = await client!.run('docker rm $id').string; - await refresh(); - setBusyState(false); - return result.contains(id); - } + Future start(String id) async => await _do(id, 'docker start $id'); + + Future delete(String id) async => await _do(id, 'docker rm $id'); } diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index fdc113a9..03042b21 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,9 +2,9 @@ class BuildData { static const String name = "ServerBox"; - static const int build = 145; + static const int build = 146; static const String engine = "Flutter 3.0.1 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision fb57da5f94 (4 days ago) • 2022-05-19 15:50:29 -0700\nEngine • revision caaafc5604\nTools • Dart 2.17.1 • DevTools 2.12.2\n"; - static const String buildAt = "2022-05-24 13:29:00.556031"; - static const int modifications = 4; + static const String buildAt = "2022-05-24 13:44:07.002192"; + static const int modifications = 0; } diff --git a/lib/data/service/app.dart b/lib/data/service/app.dart index 9f240949..b1c97813 100644 --- a/lib/data/service/app.dart +++ b/lib/data/service/app.dart @@ -3,11 +3,6 @@ import 'package:toolbox/data/model/app/update.dart'; import 'package:toolbox/data/res/url.dart'; class AppService { - Future getNotify() async { - final resp = await Dio().get('$baseUrl/notify.json'); - return resp.data; - } - Future getUpdate() async { final resp = await Dio().get('$baseUrl/update.json'); return AppUpdate.fromJson(resp.data); diff --git a/lib/view/page/server/edit.dart b/lib/view/page/server/edit.dart index 14ced5ec..5c3a6980 100644 --- a/lib/view/page/server/edit.dart +++ b/lib/view/page/server/edit.dart @@ -44,7 +44,7 @@ class _ServerEditPageState extends State with AfterLayoutMixin { bool usePublicKey = false; - int _pubKeyIndex = -1; + int? _pubKeyIndex; PrivateKeyInfo? _keyInfo; @override @@ -151,7 +151,7 @@ class _ServerEditPageState extends State with AfterLayoutMixin { ? Consumer(builder: (_, key, __) { for (var item in key.infos) { if (item.id == widget.spi?.pubKeyId) { - _pubKeyIndex = key.infos.indexOf(item); + _pubKeyIndex ??= key.infos.indexOf(item); } } final tiles = key.infos @@ -255,12 +255,9 @@ class _ServerEditPageState extends State with AfterLayoutMixin { ipController.text = widget.spi?.ip ?? ''; portController.text = (widget.spi?.port ?? 22).toString(); usernameController.text = widget.spi?.user ?? ''; - if (widget.spi?.pwd is String) { + if (widget.spi?.pubKeyId == null) { passwordController.text = widget.spi?.pwd ?? ''; } else { - final auth = widget.spi?.pwd as Map; - passwordController.text = auth['passphrase']; - keyController.text = auth['privateKey']; usePublicKey = true; } setState(() {}); diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index b5621a16..77b23e8e 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -420,14 +420,14 @@ CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 145; + CURRENT_PROJECT_VERSION = 146; DEVELOPMENT_TEAM = BA88US33G6; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = 1.0.145; + MARKETING_VERSION = 1.0.146; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; @@ -550,14 +550,14 @@ CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 145; + CURRENT_PROJECT_VERSION = 146; DEVELOPMENT_TEAM = BA88US33G6; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = 1.0.145; + MARKETING_VERSION = 1.0.146; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -574,14 +574,14 @@ CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 145; + CURRENT_PROJECT_VERSION = 146; DEVELOPMENT_TEAM = BA88US33G6; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = 1.0.145; + MARKETING_VERSION = 1.0.146; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0;