new & opt
new: `net` total in & out bytes opt: i18n for `ssh` opt: disk path ignore
This commit is contained in:
@@ -245,7 +245,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
Widget _buildDiskView(ServerStatus ss) {
|
||||
final clone = ss.disk.toList();
|
||||
for (var item in ss.disk) {
|
||||
if (ignorePath.any((ele) => item.loc.contains(ele))) {
|
||||
if (_ignorePath.any((ele) => item.path.startsWith(ele))) {
|
||||
clone.remove(item);
|
||||
}
|
||||
}
|
||||
@@ -316,10 +316,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: const [
|
||||
Icon(
|
||||
Icons.device_hub,
|
||||
size: 17,
|
||||
),
|
||||
Icon(Icons.device_hub, size: 17),
|
||||
Icon(Icons.arrow_downward, size: 17),
|
||||
Icon(Icons.arrow_upward, size: 17),
|
||||
],
|
||||
@@ -328,39 +325,42 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
}
|
||||
|
||||
Widget _buildNetSpeedItem(NetSpeed ns, String device) {
|
||||
final width = (_media.size.width - 34 - 34) / 3;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 3),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: _media.size.width / 4,
|
||||
child: Text(device, style: textSize11, textScaleFactor: 1.0)),
|
||||
SizedBox(
|
||||
width: _media.size.width / 4,
|
||||
child: Text(ns.speedIn(device: device),
|
||||
style: textSize11,
|
||||
textAlign: TextAlign.center,
|
||||
textScaleFactor: 1.0),
|
||||
width: width,
|
||||
child: Text(
|
||||
device,
|
||||
style: textSize11,
|
||||
textScaleFactor: 1.0,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: _media.size.width / 4,
|
||||
child: Text(ns.speedOut(device: device),
|
||||
style: textSize11,
|
||||
textAlign: TextAlign.right,
|
||||
textScaleFactor: 1.0),
|
||||
width: width,
|
||||
child: Text(
|
||||
'${ns.speedIn(device: device)}\n${ns.totalIn(device: device)}',
|
||||
style: textSize11,
|
||||
textAlign: TextAlign.center,
|
||||
textScaleFactor: 0.87,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: width,
|
||||
child: Text(
|
||||
'${ns.speedOut(device: device)}\n${ns.totalOut(device: device)}',
|
||||
style: textSize11,
|
||||
textAlign: TextAlign.right,
|
||||
textScaleFactor: 0.87,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static const ignorePath = [
|
||||
'/run',
|
||||
'/sys',
|
||||
'/dev/shm',
|
||||
'/snap',
|
||||
'/var/lib/docker',
|
||||
'/dev/tty'
|
||||
];
|
||||
static const _ignorePath = ['udev', 'tmpfs', 'devtmpfs'];
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/generated/l10n.dart';
|
||||
import 'package:xterm/xterm.dart';
|
||||
|
||||
import '../../core/utils/ui.dart';
|
||||
@@ -35,8 +36,9 @@ class _SSHPageState extends State<SSHPage> {
|
||||
final TerminalController _terminalController = TerminalController();
|
||||
final ContextMenuController _menuController = ContextMenuController();
|
||||
late TextStyle _menuTextStyle;
|
||||
late S _s;
|
||||
|
||||
var isDark = false;
|
||||
var _isDark = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -47,9 +49,10 @@ class _SSHPageState extends State<SSHPage> {
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
isDark = isDarkMode(context);
|
||||
_isDark = isDarkMode(context);
|
||||
_media = MediaQuery.of(context);
|
||||
_menuTextStyle = TextStyle(color: contentColor.resolve(context));
|
||||
_s = S.of(context);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -78,15 +81,8 @@ class _SSHPageState extends State<SSHPage> {
|
||||
session.write(utf8.encode(data) as Uint8List);
|
||||
};
|
||||
|
||||
session.stdout
|
||||
.cast<List<int>>()
|
||||
.transform(const Utf8Decoder())
|
||||
.listen(_terminal.write);
|
||||
|
||||
session.stderr
|
||||
.cast<List<int>>()
|
||||
.transform(const Utf8Decoder())
|
||||
.listen(_terminal.write);
|
||||
_listen(session.stdout);
|
||||
_listen(session.stderr);
|
||||
|
||||
await session.done;
|
||||
if (mounted) {
|
||||
@@ -94,9 +90,16 @@ class _SSHPageState extends State<SSHPage> {
|
||||
}
|
||||
}
|
||||
|
||||
void _listen(Stream<Uint8List> stream) {
|
||||
stream
|
||||
.cast<List<int>>()
|
||||
.transform(const Utf8Decoder())
|
||||
.listen(_terminal.write);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final termTheme = isDark ? termDarkTheme : termLightTheme;
|
||||
final termTheme = _isDark ? termDarkTheme : termLightTheme;
|
||||
return Scaffold(
|
||||
backgroundColor: termTheme.background,
|
||||
body: _buildBody(termTheme),
|
||||
@@ -118,7 +121,7 @@ class _SSHPageState extends State<SSHPage> {
|
||||
deleteDetection: Platform.isIOS,
|
||||
onTapUp: _onTapUp,
|
||||
autofocus: true,
|
||||
keyboardAppearance: isDark ? Brightness.dark : Brightness.light,
|
||||
keyboardAppearance: _isDark ? Brightness.dark : Brightness.light,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -170,7 +173,7 @@ class _SSHPageState extends State<SSHPage> {
|
||||
final child = item.icon != null
|
||||
? Icon(
|
||||
item.icon,
|
||||
color: isDark ? Colors.white : Colors.black,
|
||||
color: _isDark ? Colors.white : Colors.black,
|
||||
size: 17,
|
||||
)
|
||||
: Text(
|
||||
@@ -296,7 +299,7 @@ class _SSHPageState extends State<SSHPage> {
|
||||
children: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
'Copy',
|
||||
_s.copy,
|
||||
style: _menuTextStyle,
|
||||
),
|
||||
onPressed: () {
|
||||
|
||||
Reference in New Issue
Block a user