mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
opt.: snippet result
This commit is contained in:
@@ -11,6 +11,7 @@ import 'package:toolbox/view/page/private_key/list.dart';
|
||||
import 'package:toolbox/view/page/server/detail.dart';
|
||||
import 'package:toolbox/view/page/setting/android.dart';
|
||||
import 'package:toolbox/view/page/setting/ios.dart';
|
||||
import 'package:toolbox/view/page/snippet/result.dart';
|
||||
import 'package:toolbox/view/page/ssh_term.dart';
|
||||
import 'package:toolbox/view/page/setting/virt_key.dart';
|
||||
import 'package:toolbox/view/page/storage/local.dart';
|
||||
@@ -207,4 +208,13 @@ class AppRoute {
|
||||
static AppRoute androidSettings({Key? key}) {
|
||||
return AppRoute(AndroidSettingsPage(key: key), 'android_setting');
|
||||
}
|
||||
|
||||
static AppRoute snippetResult({Key? key, required Map<String, String?> results}) {
|
||||
return AppRoute(
|
||||
SnippetResultPage(
|
||||
key: key,
|
||||
results: results,
|
||||
),
|
||||
'snippet_result');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,12 +45,3 @@ class Snippet implements TagPickable {
|
||||
@override
|
||||
String get tagName => name;
|
||||
}
|
||||
|
||||
/// Snippet for installing ServerBoxMonitor
|
||||
const installSBM = Snippet(
|
||||
name: 'Install ServerBoxMonitor',
|
||||
script:
|
||||
'curl -fsSL https://raw.githubusercontent.com/lollipopkit/server_box_monitor/main/install.sh | sh -s -- install',
|
||||
tags: ['ServerBoxMonitor'],
|
||||
note: 'One click script to install ServerBoxMonitor',
|
||||
);
|
||||
|
||||
@@ -26,20 +26,9 @@ class SnippetProvider extends ChangeNotifier {
|
||||
Stores.setting.snippetOrder.put(order);
|
||||
}
|
||||
}
|
||||
_addInternal();
|
||||
_updateTags();
|
||||
}
|
||||
|
||||
void _addInternal() {
|
||||
if (!Stores.first.iSSBM.fetch() ||
|
||||
_snippets.any((e) => e.name == installSBM.name)) {
|
||||
return;
|
||||
}
|
||||
_snippets.add(installSBM);
|
||||
Stores.snippet.put(installSBM);
|
||||
Stores.first.iSSBM.put(false);
|
||||
}
|
||||
|
||||
void _updateTags() {
|
||||
_tags.clear();
|
||||
final tags = <String>{};
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 599;
|
||||
static const int build = 601;
|
||||
static const String engine = "3.13.7";
|
||||
static const String buildAt = "2023-10-15 21:24:51";
|
||||
static const String buildAt = "2023-10-17 20:28:10";
|
||||
static const int modifications = 4;
|
||||
static const int script = 21;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,6 @@ import 'package:toolbox/core/persistant_store.dart';
|
||||
class FirstStore extends PersistentStore<bool> {
|
||||
FirstStore() : super('first');
|
||||
|
||||
/// Add Snippet `Install ServerBoxMonitor`
|
||||
late final iSSBM = StoreProperty(box, 'installMonitorSnippet', true);
|
||||
|
||||
/// Show tip of suspend
|
||||
late final showSuspendTip = StoreProperty(box, 'showSuspendTip', true);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import 'package:toolbox/core/extension/order.dart';
|
||||
import 'package:toolbox/data/res/provider.dart';
|
||||
import 'package:toolbox/data/res/store.dart';
|
||||
|
||||
import '../../../core/utils/misc.dart';
|
||||
import '../../../data/model/server/server.dart';
|
||||
import '../../../data/model/server/snippet.dart';
|
||||
import '../../../data/res/ui.dart';
|
||||
@@ -135,23 +134,15 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
return;
|
||||
}
|
||||
final ids = servers.map((e) => e.spi.id).toList();
|
||||
final names = servers.map((e) => e.spi.name).toList();
|
||||
final results = await Pros.server.runSnippetsMulti(ids, [snippet]);
|
||||
if (results.isNotEmpty) {
|
||||
// SERVER_NAME: RESULT
|
||||
final result = Map.fromIterables(
|
||||
ids,
|
||||
names,
|
||||
results,
|
||||
).entries.map((e) => '${e.key}:\n${e.value}').join('\n');
|
||||
context.showRoundDialog(
|
||||
title: Text(l10n.result),
|
||||
child: Text(result),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => copy2Clipboard(result),
|
||||
child: Text(l10n.copy),
|
||||
)
|
||||
],
|
||||
);
|
||||
AppRoute.snippetResult(results: result).go(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
47
lib/view/page/snippet/result.dart
Normal file
47
lib/view/page/snippet/result.dart
Normal file
@@ -0,0 +1,47 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toolbox/core/extension/context/locale.dart';
|
||||
import 'package:toolbox/view/widget/cardx.dart';
|
||||
import 'package:toolbox/view/widget/custom_appbar.dart';
|
||||
import 'package:toolbox/view/widget/expand_tile.dart';
|
||||
|
||||
class SnippetResultPage extends StatelessWidget {
|
||||
final Map<String, String?> results;
|
||||
|
||||
const SnippetResultPage({super.key, required this.results});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: CustomAppBar(
|
||||
title: Text(l10n.result),
|
||||
),
|
||||
body: _buildBody(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBody() {
|
||||
return Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 17),
|
||||
itemCount: results.length,
|
||||
itemBuilder: (_, index) {
|
||||
final key = results.keys.elementAt(index);
|
||||
final value = results[key];
|
||||
return CardX(
|
||||
ExpandTile(
|
||||
initiallyExpanded: results.length == 1,
|
||||
title: Text(key),
|
||||
children: [
|
||||
Text(
|
||||
value ?? '',
|
||||
textAlign: TextAlign.start,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user