mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-02-01 05:45:04 +01:00
Simply implement snippet running.
This commit is contained in:
@@ -5,5 +5,11 @@ class Memory {
|
||||
int shared;
|
||||
int cache;
|
||||
int avail;
|
||||
Memory({required this.total, required this.used, required this.free, required this.shared, required this.cache, required this.avail});
|
||||
Memory(
|
||||
{required this.total,
|
||||
required this.used,
|
||||
required this.free,
|
||||
required this.shared,
|
||||
required this.cache,
|
||||
required this.avail});
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import 'package:toolbox/data/model/server/disk_info.dart';
|
||||
import 'package:toolbox/data/model/server/server.dart';
|
||||
import 'package:toolbox/data/model/server/server_private_info.dart';
|
||||
import 'package:toolbox/data/model/server/server_status.dart';
|
||||
import 'package:toolbox/data/model/server/snippet.dart';
|
||||
import 'package:toolbox/data/model/server/tcp_status.dart';
|
||||
import 'package:toolbox/data/store/server.dart';
|
||||
import 'package:toolbox/data/store/setting.dart';
|
||||
@@ -290,4 +291,8 @@ class ServerProvider extends BusyProvider {
|
||||
}
|
||||
return emptyMemory;
|
||||
}
|
||||
|
||||
Future<String?> runSnippet(int idx, Snippet snippet) {
|
||||
return _servers[idx].client.execute(snippet.script);
|
||||
}
|
||||
}
|
||||
|
||||
32
lib/data/provider/snippet.dart
Normal file
32
lib/data/provider/snippet.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
import 'package:toolbox/core/provider_base.dart';
|
||||
import 'package:toolbox/data/model/server/snippet.dart';
|
||||
import 'package:toolbox/data/store/snippet.dart';
|
||||
import 'package:toolbox/locator.dart';
|
||||
|
||||
class SnippetProvider extends BusyProvider {
|
||||
List<Snippet> get snippets => _snippets;
|
||||
late List<Snippet> _snippets;
|
||||
|
||||
void loadData() {
|
||||
_snippets = locator<SnippetStore>().fetch();
|
||||
}
|
||||
|
||||
void addInfo(Snippet snippet) {
|
||||
_snippets.add(snippet);
|
||||
locator<SnippetStore>().put(snippet);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void delInfo(Snippet snippet) {
|
||||
_snippets.removeWhere((e) => e.name == snippet.name);
|
||||
locator<SnippetStore>().delete(snippet);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void updateInfo(Snippet old, Snippet newOne) {
|
||||
final idx = _snippets.indexWhere((e) => e.name == old.name);
|
||||
_snippets[idx] = newOne;
|
||||
locator<SnippetStore>().update(old, newOne);
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,9 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ToolBox";
|
||||
static const int build = 60;
|
||||
static const String engine = "Flutter 2.5.3 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 18116933e7 (3 weeks ago) • 2021-10-15 10:46:35 -0700\nEngine • revision d3ea636dc5\nTools • Dart 2.14.4\n";
|
||||
static const String buildAt = "2021-11-02 20:36:41.010803";
|
||||
static const int modifications = 2;
|
||||
static const int build = 61;
|
||||
static const String engine =
|
||||
"Flutter 2.5.3 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 18116933e7 (3 weeks ago) • 2021-10-15 10:46:35 -0700\nEngine • revision d3ea636dc5\nTools • Dart 2.14.4\n";
|
||||
static const String buildAt = "2021-11-05 12:58:33.427838";
|
||||
static const int modifications = 15;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user