mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
#54 run multi snippets on multi servers
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -24,7 +24,7 @@ class ServerProvider extends BusyProvider {
|
||||
final ServersMap _servers = {};
|
||||
ServersMap get servers => _servers;
|
||||
final Order<String> _serverOrder = [];
|
||||
Order get serverOrder => _serverOrder;
|
||||
Order<String> get serverOrder => _serverOrder;
|
||||
final List<String> _tags = [];
|
||||
List<String> get tags => _tags;
|
||||
|
||||
@@ -283,4 +283,11 @@ class ServerProvider extends BusyProvider {
|
||||
}
|
||||
return await client.run(snippets.map((e) => e.script).join('&&')).string;
|
||||
}
|
||||
|
||||
Future<List<String?>> runSnippetsOnMulti(
|
||||
List<String> ids,
|
||||
List<Snippet> snippets,
|
||||
) async {
|
||||
return await Future.wait(ids.map((id) async => runSnippets(id, snippets)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<SnippetListPage> {
|
||||
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<SnippetListPage> {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _runSnippet(Snippet snippet) async {
|
||||
final provider = locator<ServerProvider>();
|
||||
final servers = await showDialog<List<Server>>(
|
||||
context: context,
|
||||
builder: (_) => TagPicker<Server>(
|
||||
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),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user