Improve
This commit is contained in:
@@ -142,6 +142,9 @@ class ServerProvider extends BusyProvider {
|
|||||||
Future<void> updateServer(
|
Future<void> updateServer(
|
||||||
ServerPrivateInfo old, ServerPrivateInfo newSpi) async {
|
ServerPrivateInfo old, ServerPrivateInfo newSpi) async {
|
||||||
final idx = _servers.indexWhere((e) => e.info == old);
|
final idx = _servers.indexWhere((e) => e.info == old);
|
||||||
|
if (idx < 0) {
|
||||||
|
throw RangeError.index(idx, _servers);
|
||||||
|
}
|
||||||
_servers[idx].info = newSpi;
|
_servers[idx].info = newSpi;
|
||||||
_servers[idx].client = await genClient(newSpi);
|
_servers[idx].client = await genClient(newSpi);
|
||||||
locator<ServerStore>().update(old, newSpi);
|
locator<ServerStore>().update(old, newSpi);
|
||||||
@@ -199,7 +202,7 @@ class ServerProvider extends BusyProvider {
|
|||||||
/// lo: 45929941 269112 0 0 0 0 0 0 45929941 269112 0 0 0 0 0 0
|
/// lo: 45929941 269112 0 0 0 0 0 0 45929941 269112 0 0 0 0 0 0
|
||||||
/// eth0: 48481023 505772 0 0 0 0 0 0 36002262 202307 0 0 0 0 0 0
|
/// eth0: 48481023 505772 0 0 0 0 0 0 36002262 202307 0 0 0 0 0 0
|
||||||
/// 1635752901
|
/// 1635752901
|
||||||
Future<void> _getNetSpeed(ServerPrivateInfo spi, String raw) async {
|
void _getNetSpeed(ServerPrivateInfo spi, String raw) {
|
||||||
final info = _servers.firstWhere((e) => e.info == spi);
|
final info = _servers.firstWhere((e) => e.info == spi);
|
||||||
final split = raw.split('\n');
|
final split = raw.split('\n');
|
||||||
final deviceCount = split.length - 3;
|
final deviceCount = split.length - 3;
|
||||||
@@ -219,13 +222,11 @@ class ServerProvider extends BusyProvider {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _getSysVer(ServerPrivateInfo spi, String raw) async {
|
void _getSysVer(ServerPrivateInfo spi, String raw) {
|
||||||
final info = _servers.firstWhere((e) => e.info == spi);
|
final info = _servers.firstWhere((e) => e.info == spi);
|
||||||
final s = raw.split('=');
|
final s = raw.split('=');
|
||||||
if (s.length == 2) {
|
if (s.length == 2) {
|
||||||
info.status.sysVer = s[1].replaceAll('"', '').replaceFirst('\n', '');
|
info.status.sysVer = s[1].replaceAll('"', '').replaceFirst('\n', '');
|
||||||
} else {
|
|
||||||
info.status.sysVer = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@@ -241,7 +242,7 @@ class ServerProvider extends BusyProvider {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _getCPU(ServerPrivateInfo spi, String raw, String temp) async {
|
void _getCPU(ServerPrivateInfo spi, String raw, String temp) {
|
||||||
final info = _servers.firstWhere((e) => e.info == spi);
|
final info = _servers.firstWhere((e) => e.info == spi);
|
||||||
final List<CpuStatus> cpus = [];
|
final List<CpuStatus> cpus = [];
|
||||||
|
|
||||||
@@ -259,9 +260,7 @@ class ServerProvider extends BusyProvider {
|
|||||||
int.parse(matches[5]),
|
int.parse(matches[5]),
|
||||||
int.parse(matches[6])));
|
int.parse(matches[6])));
|
||||||
}
|
}
|
||||||
if (cpus.isEmpty) {
|
if (cpus.isNotEmpty) {
|
||||||
info.status.cpu2Status = emptyCpu2Status;
|
|
||||||
} else {
|
|
||||||
info.status.cpu2Status =
|
info.status.cpu2Status =
|
||||||
info.status.cpu2Status.update(cpus, _getCPUTemp(temp));
|
info.status.cpu2Status.update(cpus, _getCPUTemp(temp));
|
||||||
}
|
}
|
||||||
@@ -269,13 +268,13 @@ class ServerProvider extends BusyProvider {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _getUpTime(ServerPrivateInfo spi, String raw) async {
|
void _getUpTime(ServerPrivateInfo spi, String raw) {
|
||||||
_servers.firstWhere((e) => e.info == spi).status.uptime =
|
_servers.firstWhere((e) => e.info == spi).status.uptime =
|
||||||
raw.split('up ')[1].split(', ')[0];
|
raw.split('up ')[1].split(', ')[0];
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _getTcp(ServerPrivateInfo spi, String raw) async {
|
void _getTcp(ServerPrivateInfo spi, String raw) {
|
||||||
final info = _servers.firstWhere((e) => e.info == spi);
|
final info = _servers.firstWhere((e) => e.info == spi);
|
||||||
final lines = raw.split('\n');
|
final lines = raw.split('\n');
|
||||||
final idx = lines.lastWhere((element) => element.startsWith('Tcp:'),
|
final idx = lines.lastWhere((element) => element.startsWith('Tcp:'),
|
||||||
@@ -283,13 +282,11 @@ class ServerProvider extends BusyProvider {
|
|||||||
if (idx != '') {
|
if (idx != '') {
|
||||||
final vals = idx.split(RegExp(r'\s{1,}'));
|
final vals = idx.split(RegExp(r'\s{1,}'));
|
||||||
info.status.tcp = TcpStatus(vals[5].i, vals[6].i, vals[7].i, vals[8].i);
|
info.status.tcp = TcpStatus(vals[5].i, vals[6].i, vals[7].i, vals[8].i);
|
||||||
} else {
|
|
||||||
info.status.tcp = TcpStatus(0, 0, 0, 0);
|
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _getDisk(ServerPrivateInfo spi, String raw) async {
|
void _getDisk(ServerPrivateInfo spi, String raw) {
|
||||||
final info = _servers.firstWhere((e) => e.info == spi);
|
final info = _servers.firstWhere((e) => e.info == spi);
|
||||||
final list = <DiskInfo>[];
|
final list = <DiskInfo>[];
|
||||||
final items = raw.split('\n');
|
final items = raw.split('\n');
|
||||||
@@ -305,7 +302,7 @@ class ServerProvider extends BusyProvider {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _getMem(ServerPrivateInfo spi, String raw) async {
|
void _getMem(ServerPrivateInfo spi, String raw) {
|
||||||
final info = _servers.firstWhere((e) => e.info == spi);
|
final info = _servers.firstWhere((e) => e.info == spi);
|
||||||
for (var item in raw.split('\n')) {
|
for (var item in raw.split('\n')) {
|
||||||
if (item.contains('Mem:')) {
|
if (item.contains('Mem:')) {
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
class BuildData {
|
class BuildData {
|
||||||
static const String name = "ServerBox";
|
static const String name = "ServerBox";
|
||||||
static const int build = 88;
|
static const int build = 89;
|
||||||
static const String engine = "Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 77d935af4d (7 weeks ago) • 2021-12-16 08:37:33 -0800\nEngine • revision 890a5fca2e\nTools • Dart 2.15.1\n";
|
static const String engine =
|
||||||
static const String buildAt = "2022-02-04 18:44:51.481488";
|
"Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 77d935af4d (7 weeks ago) • 2021-12-16 08:37:33 -0800\nEngine • revision 890a5fca2e\nTools • Dart 2.15.1\n";
|
||||||
static const int modifications = 16;
|
static const String buildAt = "2022-02-04 18:52:49.141069";
|
||||||
|
static const int modifications = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,11 @@ class ServerStore extends PersistentStore {
|
|||||||
|
|
||||||
void update(ServerPrivateInfo old, ServerPrivateInfo newInfo) {
|
void update(ServerPrivateInfo old, ServerPrivateInfo newInfo) {
|
||||||
final ss = fetch();
|
final ss = fetch();
|
||||||
ss[index(old)] = newInfo;
|
final idx = index(old);
|
||||||
|
if (idx < 0) {
|
||||||
|
throw RangeError.index(idx, ss);
|
||||||
|
}
|
||||||
|
ss[idx] = newInfo;
|
||||||
box.put('servers', json.encode(ss));
|
box.put('servers', json.encode(ss));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,6 @@ class SettingStore extends PersistentStore {
|
|||||||
StoreProperty<int> get primaryColor =>
|
StoreProperty<int> get primaryColor =>
|
||||||
property('primaryColor', defaultValue: Colors.deepPurpleAccent.value);
|
property('primaryColor', defaultValue: Colors.deepPurpleAccent.value);
|
||||||
StoreProperty<int> get serverStatusUpdateInterval =>
|
StoreProperty<int> get serverStatusUpdateInterval =>
|
||||||
property('serverStatusUpdateInterval', defaultValue: 3);
|
property('serverStatusUpdateInterval', defaultValue: 2);
|
||||||
StoreProperty<int> get launchPage => property('launchPage', defaultValue: 0);
|
StoreProperty<int> get launchPage => property('launchPage', defaultValue: 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,8 +46,7 @@ class _PingPageState extends State<PingPage>
|
|||||||
padding: const EdgeInsets.symmetric(horizontal: 7),
|
padding: const EdgeInsets.symmetric(horizontal: 7),
|
||||||
child: Column(children: [
|
child: Column(children: [
|
||||||
const SizedBox(height: 13),
|
const SizedBox(height: 13),
|
||||||
buildInput(context, _textEditingController,
|
buildInput(context, _textEditingController, maxLines: 1),
|
||||||
maxLines: 1),
|
|
||||||
_buildControl(),
|
_buildControl(),
|
||||||
buildInput(context, _textEditingControllerResult),
|
buildInput(context, _textEditingControllerResult),
|
||||||
])),
|
])),
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ class _PrivateKeyListState extends State<StoredPrivateKeysPage> {
|
|||||||
itemCount: key.infos.length,
|
itemCount: key.infos.length,
|
||||||
itemExtent: 57,
|
itemExtent: 57,
|
||||||
itemBuilder: (context, idx) {
|
itemBuilder: (context, idx) {
|
||||||
return RoundRectCard(Padding(padding: roundRectCardPadding, child: Row(
|
return RoundRectCard(Padding(
|
||||||
|
padding: roundRectCardPadding,
|
||||||
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@@ -48,7 +50,8 @@ class _PrivateKeyListState extends State<StoredPrivateKeysPage> {
|
|||||||
style: _textStyle,
|
style: _textStyle,
|
||||||
))
|
))
|
||||||
],
|
],
|
||||||
),));
|
),
|
||||||
|
));
|
||||||
})
|
})
|
||||||
: const Center(child: Text('No saved private keys.'));
|
: const Center(child: Text('No saved private keys.'));
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -69,7 +69,9 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
|||||||
|
|
||||||
Widget _buildCPUView(ServerStatus ss) {
|
Widget _buildCPUView(ServerStatus ss) {
|
||||||
return RoundRectCard(
|
return RoundRectCard(
|
||||||
Padding(padding: roundRectCardPadding, child: SizedBox(
|
Padding(
|
||||||
|
padding: roundRectCardPadding,
|
||||||
|
child: SizedBox(
|
||||||
height: 12 * ss.cpu2Status.coresCount + 67,
|
height: 12 * ss.cpu2Status.coresCount + 67,
|
||||||
child: Column(children: [
|
child: Column(children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@@ -104,7 +106,8 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
|||||||
),
|
),
|
||||||
_buildCPUProgress(ss)
|
_buildCPUProgress(ss)
|
||||||
]),
|
]),
|
||||||
),),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +195,9 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
|||||||
final pColor = primaryColor;
|
final pColor = primaryColor;
|
||||||
final used = ss.memory.used / ss.memory.total;
|
final used = ss.memory.used / ss.memory.total;
|
||||||
final width = _media.size.width - 17 * 2 - 17 * 2;
|
final width = _media.size.width - 17 * 2 - 17 * 2;
|
||||||
return RoundRectCard(Padding(padding: roundRectCardPadding, child: SizedBox(
|
return RoundRectCard(Padding(
|
||||||
|
padding: roundRectCardPadding,
|
||||||
|
child: SizedBox(
|
||||||
height: 47,
|
height: 47,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
@@ -234,7 +239,8 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),));
|
),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildMemExplain(String value, Color color) {
|
Widget _buildMemExplain(String value, Color color) {
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ class _ServerPageState extends State<ServerPage>
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 11),
|
padding: const EdgeInsets.symmetric(horizontal: 7),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@@ -177,14 +177,14 @@ class _ServerPageState extends State<ServerPage>
|
|||||||
style: style),
|
style: style),
|
||||||
)
|
)
|
||||||
: Text(topRightStr, style: style, textScaleFactor: 1.0),
|
: Text(topRightStr, style: style, textScaleFactor: 1.0),
|
||||||
const SizedBox(
|
|
||||||
width: 13,
|
|
||||||
),
|
|
||||||
DropdownButtonHideUnderline(
|
DropdownButtonHideUnderline(
|
||||||
child: DropdownButton2(
|
child: DropdownButton2(
|
||||||
customButton: const Icon(
|
customButton: const Padding(
|
||||||
Icons.list_alt,
|
padding: EdgeInsets.only(left: 7),
|
||||||
size: 19,
|
child: Icon(
|
||||||
|
Icons.more_vert,
|
||||||
|
size: 17,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
customItemsIndexes: const [3],
|
customItemsIndexes: const [3],
|
||||||
customItemsHeight: 8,
|
customItemsHeight: 8,
|
||||||
|
|||||||
@@ -48,7 +48,9 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
|||||||
itemCount: key.snippets.length,
|
itemCount: key.snippets.length,
|
||||||
itemExtent: 57,
|
itemExtent: 57,
|
||||||
itemBuilder: (context, idx) {
|
itemBuilder: (context, idx) {
|
||||||
return RoundRectCard(Padding(padding: roundRectCardPadding, child: Row(
|
return RoundRectCard(Padding(
|
||||||
|
padding: roundRectCardPadding,
|
||||||
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@@ -59,7 +61,8 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
|||||||
Row(children: [
|
Row(children: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => AppRoute(
|
onPressed: () => AppRoute(
|
||||||
SnippetEditPage(snippet: key.snippets[idx]),
|
SnippetEditPage(
|
||||||
|
snippet: key.snippets[idx]),
|
||||||
'snippet edit page')
|
'snippet edit page')
|
||||||
.go(context),
|
.go(context),
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -81,7 +84,8 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
|||||||
))
|
))
|
||||||
])
|
])
|
||||||
],
|
],
|
||||||
),));
|
),
|
||||||
|
));
|
||||||
})
|
})
|
||||||
: const Center(child: Text('No saved snippets.'));
|
: const Center(child: Text('No saved snippets.'));
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user