diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index cbfb8eb6..5b70fbfd 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -360,7 +360,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 372; + CURRENT_PROJECT_VERSION = 373; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -368,7 +368,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.372; + MARKETING_VERSION = 1.0.373; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -491,7 +491,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 372; + CURRENT_PROJECT_VERSION = 373; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -499,7 +499,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.372; + MARKETING_VERSION = 1.0.373; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -516,7 +516,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 372; + CURRENT_PROJECT_VERSION = 373; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -524,7 +524,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.372; + MARKETING_VERSION = 1.0.373; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/lib/data/provider/server.dart b/lib/data/provider/server.dart index 7e403bac..0fcbb38e 100644 --- a/lib/data/provider/server.dart +++ b/lib/data/provider/server.dart @@ -24,7 +24,7 @@ class ServerProvider extends BusyProvider { final ServersMap _servers = {}; ServersMap get servers => _servers; final Order _serverOrder = []; - Order get serverOrder => _serverOrder; + Order get serverOrder => _serverOrder; final List _tags = []; List get tags => _tags; @@ -283,4 +283,11 @@ class ServerProvider extends BusyProvider { } return await client.run(snippets.map((e) => e.script).join('&&')).string; } + + Future> runSnippetsOnMulti( + List ids, + List snippets, + ) async { + return await Future.wait(ids.map((id) async => runSnippets(id, snippets))); + } } diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index ac6b58c3..d2c6e712 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 = 372; + static const int build = 373; static const String engine = "3.10.5"; - static const String buildAt = "2023-07-07 21:09:39.978447"; + static const String buildAt = "2023-07-08 00:12:27.058306"; static const int modifications = 2; } diff --git a/lib/view/page/snippet/list.dart b/lib/view/page/snippet/list.dart index 8ac5b484..b42b1a4c 100644 --- a/lib/view/page/snippet/list.dart +++ b/lib/view/page/snippet/list.dart @@ -2,10 +2,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:provider/provider.dart'; import 'package:toolbox/core/extension/order.dart'; +import 'package:toolbox/data/model/server/server.dart'; +import 'package:toolbox/data/provider/server.dart'; import 'package:toolbox/view/widget/tag/switcher.dart'; +import '../../../core/utils/misc.dart'; +import '../../../core/utils/ui.dart'; +import '../../../data/model/server/snippet.dart'; import '../../../data/store/setting.dart'; import '../../../locator.dart'; +import '../../widget/tag/picker.dart'; import '/core/route.dart'; import '/data/provider/snippet.dart'; import 'edit.dart'; @@ -90,12 +96,21 @@ class _SnippetListPageState extends State { overflow: TextOverflow.ellipsis, maxLines: 1, ), - trailing: IconButton( - onPressed: () => AppRoute( - SnippetEditPage(snippet: snippet), - 'snippet edit page', - ).go(context), - icon: const Icon(Icons.edit), + trailing: Row( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + onPressed: () => AppRoute( + SnippetEditPage(snippet: snippet), + 'snippet edit page', + ).go(context), + icon: const Icon(Icons.edit), + ), + IconButton( + onPressed: () => _runSnippet(snippet), + icon: const Icon(Icons.play_arrow), + ), + ], ), ), key: ValueKey(snippet.name), @@ -105,4 +120,40 @@ class _SnippetListPageState extends State { }, ); } + + Future _runSnippet(Snippet snippet) async { + final provider = locator(); + final servers = await showDialog>( + context: context, + builder: (_) => TagPicker( + items: provider.servers.values.toList(), + containsTag: (t, tag) => t.spi.tags?.contains(tag) ?? false, + tags: provider.tags.toSet(), + name: (t) => t.spi.id, + ), + ); + if (servers == null) { + return; + } + final ids = servers.map((e) => e.spi.id).toList(); + final results = await provider.runSnippetsOnMulti(ids, [snippet]); + if (results.isNotEmpty) { + // SERVER_NAME: RESULT + final result = Map.fromIterables( + ids, + results, + ).entries.map((e) => '${e.key}:\n${e.value}').join('\n'); + showRoundDialog( + context: context, + title: Text(_s.result), + child: Text(result), + actions: [ + TextButton( + onPressed: () => copy2Clipboard(result), + child: Text(_s.copy), + ) + ], + ); + } + } } diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index a2b55260..73abda91 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -475,9 +475,9 @@ baseConfigurationReference = C1C758C41C4E208965A68933 /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 372; + CURRENT_PROJECT_VERSION = 373; GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0.372; + MARKETING_VERSION = 1.0.373; PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -490,9 +490,9 @@ baseConfigurationReference = 15AF97DF993E8968098D6EBE /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 372; + CURRENT_PROJECT_VERSION = 373; GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0.372; + MARKETING_VERSION = 1.0.373; PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -505,9 +505,9 @@ baseConfigurationReference = 7CFA7DE7FABA75685DFB6948 /* Pods-RunnerTests.profile.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 372; + CURRENT_PROJECT_VERSION = 373; GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0.372; + MARKETING_VERSION = 1.0.373; PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0;