mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
opt.: custom diskIgnorePath
This commit is contained in:
@@ -299,6 +299,12 @@ abstract class S {
|
||||
/// **'Disconnected'**
|
||||
String get disconnected;
|
||||
|
||||
/// No description provided for @diskIgnorePath.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Ignore path for disk'**
|
||||
String get diskIgnorePath;
|
||||
|
||||
/// No description provided for @dl2Local.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
|
||||
@@ -106,6 +106,9 @@ class SDe extends S {
|
||||
@override
|
||||
String get disconnected => 'Disconnected';
|
||||
|
||||
@override
|
||||
String get diskIgnorePath => 'Pfad für Platte ignorieren';
|
||||
|
||||
@override
|
||||
String dl2Local(Object fileName) {
|
||||
return 'Datei \"$fileName\" herunterladen?';
|
||||
|
||||
@@ -106,6 +106,9 @@ class SEn extends S {
|
||||
@override
|
||||
String get disconnected => 'Disconnected';
|
||||
|
||||
@override
|
||||
String get diskIgnorePath => 'Ignore path for disk';
|
||||
|
||||
@override
|
||||
String dl2Local(Object fileName) {
|
||||
return 'Download $fileName to local?';
|
||||
|
||||
@@ -106,6 +106,9 @@ class SZh extends S {
|
||||
@override
|
||||
String get disconnected => '连接断开';
|
||||
|
||||
@override
|
||||
String get diskIgnorePath => '忽略的磁盘路径';
|
||||
|
||||
@override
|
||||
String dl2Local(Object fileName) {
|
||||
return '下载 $fileName 到本地?';
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
final _seperator = RegExp(' +');
|
||||
|
||||
class DockerPsItem {
|
||||
late String containerId;
|
||||
late String image;
|
||||
@@ -7,11 +9,18 @@ class DockerPsItem {
|
||||
late String ports;
|
||||
late String name;
|
||||
|
||||
DockerPsItem(this.containerId, this.image, this.command, this.created,
|
||||
this.status, this.ports, this.name);
|
||||
DockerPsItem(
|
||||
this.containerId,
|
||||
this.image,
|
||||
this.command,
|
||||
this.created,
|
||||
this.status,
|
||||
this.ports,
|
||||
this.name,
|
||||
);
|
||||
|
||||
DockerPsItem.fromRawString(String rawString) {
|
||||
List<String> parts = rawString.split(RegExp(' +'));
|
||||
List<String> parts = rawString.split(_seperator);
|
||||
parts = parts.map((e) => e.trim()).toList();
|
||||
|
||||
containerId = parts[0];
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import '../../../core/extension/stringx.dart';
|
||||
import '../../res/misc.dart';
|
||||
|
||||
///
|
||||
/// Code generated by jsonToDartModel https://ashamp.github.io/jsonToDartModel/
|
||||
///
|
||||
class ConnStatus {
|
||||
/*
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ enum Dist {
|
||||
alpine,
|
||||
rocky;
|
||||
|
||||
String? get iconPath {
|
||||
String get iconPath {
|
||||
return 'assets/linux/$name.png';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,10 @@ import 'package:toolbox/core/persistant_store.dart';
|
||||
import 'package:toolbox/core/utils/platform.dart';
|
||||
|
||||
class SettingStore extends PersistentStore {
|
||||
StoreProperty<int> get primaryColor =>
|
||||
property('primaryColor', defaultValue: Colors.pink.value);
|
||||
StoreProperty<int> get primaryColor => property(
|
||||
'primaryColor',
|
||||
defaultValue: const Color.fromARGB(255, 145, 58, 31).value,
|
||||
);
|
||||
|
||||
StoreProperty<int> get serverStatusUpdateInterval =>
|
||||
property('serverStatusUpdateInterval', defaultValue: 3);
|
||||
@@ -47,4 +49,15 @@ class SettingStore extends PersistentStore {
|
||||
// SSH term font size
|
||||
StoreProperty<double> get termFontSize =>
|
||||
property('termFontSize', defaultValue: 13);
|
||||
|
||||
/// Server detail disk ignore path
|
||||
StoreProperty<List<String>> get diskIgnorePath =>
|
||||
property('diskIgnorePath', defaultValue: [
|
||||
'udev',
|
||||
'tmpfs',
|
||||
'devtmpfs',
|
||||
'overlay',
|
||||
'run',
|
||||
'none',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
"decode": "Decode",
|
||||
"delete": "Löschen",
|
||||
"disconnected": "Disconnected",
|
||||
"diskIgnorePath": "Pfad für Platte ignorieren",
|
||||
"dl2Local": "Datei \"{fileName}\" herunterladen?",
|
||||
"dockerEditHost": "DOCKER_HOST bearbeiten",
|
||||
"dockerEmptyRunningItems": "Keine aktiven Container.\n\nWomöglich wird die Umgebungsvariable DOCKER_HOST nicht richtig erkannt. Du kannst sie finden, indem du `echo $DOCKER_HOST` im Terminal ausführst.",
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
"decode": "Decode",
|
||||
"delete": "Delete",
|
||||
"disconnected": "Disconnected",
|
||||
"diskIgnorePath": "Ignore path for disk",
|
||||
"dl2Local": "Download {fileName} to local?",
|
||||
"dockerEditHost": "Edit DOCKER_HOST",
|
||||
"dockerEmptyRunningItems": "No running container. \nIt may be that the env DOCKER_HOST is not read correctly. You can found it by running `echo $DOCKER_HOST` in terminal.",
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
"decode": "解码",
|
||||
"delete": "删除",
|
||||
"disconnected": "连接断开",
|
||||
"diskIgnorePath": "忽略的磁盘路径",
|
||||
"dl2Local": "下载 {fileName} 到本地?",
|
||||
"dockerEditHost": "编辑 DOCKER_HOST",
|
||||
"dockerEmptyRunningItems": "没有正在运行的容器。\n这可能是因为环境变量 DOCKER_HOST 没有被正确读取。你可以通过在终端内运行 `echo $DOCKER_HOST` 来获取。",
|
||||
|
||||
@@ -27,14 +27,13 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late MediaQueryData _media;
|
||||
late S _s;
|
||||
bool _showDistLogo = true;
|
||||
final _setting = locator<SettingStore>();
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_media = MediaQuery.of(context);
|
||||
_s = S.of(context)!;
|
||||
_showDistLogo = locator<SettingStore>().showDistLogo.fetch()!;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -76,7 +75,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
}
|
||||
|
||||
Widget _buildLinuxIcon(String sysVer) {
|
||||
if (!_showDistLogo) return placeholder;
|
||||
if (!_setting.showDistLogo.fetch()!) return placeholder;
|
||||
final iconPath = sysVer.dist?.iconPath;
|
||||
if (iconPath == null) return placeholder;
|
||||
return ConstrainedBox(
|
||||
@@ -262,13 +261,13 @@ 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.path.startsWith(ele))) {
|
||||
clone.remove(item);
|
||||
ss.disk.removeWhere((e) {
|
||||
for (final ingorePath in _setting.diskIgnorePath.fetch()!) {
|
||||
if (e.path.startsWith(ingorePath)) return true;
|
||||
}
|
||||
}
|
||||
final children = clone
|
||||
return false;
|
||||
});
|
||||
final children = ss.disk
|
||||
.map((disk) => Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 3),
|
||||
child: Column(
|
||||
@@ -344,14 +343,14 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
}
|
||||
|
||||
Widget _buildNetSpeedItem(NetSpeed ns, String device) {
|
||||
final width = (_media.size.width - 34 - 34) / 3;
|
||||
final width = (_media.size.width - 34 - 34) / 2.9;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 3),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: width,
|
||||
width: width / 1.2,
|
||||
child: Text(
|
||||
device,
|
||||
style: textSize11,
|
||||
@@ -364,7 +363,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
'${ns.speedIn(device: device)} | ${ns.totalIn(device: device)}',
|
||||
style: textSize11,
|
||||
textAlign: TextAlign.center,
|
||||
textScaleFactor: 0.9,
|
||||
textScaleFactor: 0.87,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
@@ -373,7 +372,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
'${ns.speedOut(device: device)} | ${ns.totalOut(device: device)}',
|
||||
style: textSize11,
|
||||
textAlign: TextAlign.right,
|
||||
textScaleFactor: 0.9,
|
||||
textScaleFactor: 0.87,
|
||||
),
|
||||
)
|
||||
],
|
||||
@@ -393,7 +392,10 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
Icon(Icons.arrow_downward, size: 17),
|
||||
],
|
||||
),
|
||||
const Padding(padding: EdgeInsets.symmetric(vertical: 3), child: Divider(height: 7),),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 3),
|
||||
child: Divider(height: 7),
|
||||
),
|
||||
];
|
||||
children.addAll(ss.temps.devices.map((key) => Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
@@ -415,6 +417,4 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
child: Column(children: children),
|
||||
));
|
||||
}
|
||||
|
||||
static const _ignorePath = ['udev', 'tmpfs', 'devtmpfs'];
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -135,6 +136,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
_buildDistLogoSwitch(),
|
||||
_buildUpdateInterval(),
|
||||
_buildMaxRetry(),
|
||||
_buildDiskIgnorePath(),
|
||||
].map((e) => RoundRectCard(e)).toList(),
|
||||
);
|
||||
}
|
||||
@@ -568,4 +570,30 @@ class _SettingPageState extends State<SettingPage> {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDiskIgnorePath() {
|
||||
final paths = _setting.diskIgnorePath.fetch()!;
|
||||
return ListTile(
|
||||
title: Text(_s.diskIgnorePath),
|
||||
trailing: Text(_s.edit, style: textSize15,),
|
||||
onTap: () {
|
||||
showRoundDialog(context: context, child: Input(
|
||||
controller: TextEditingController(text: json.encode(paths)),
|
||||
label: 'JSON',
|
||||
type: TextInputType.visiblePassword,
|
||||
maxLines: 3,
|
||||
onSubmitted: (p0) {
|
||||
try {
|
||||
final list = List<String>.from(json.decode(p0));
|
||||
_setting.diskIgnorePath.put(list);
|
||||
context.pop();
|
||||
showSnackBar(context, Text(_s.success));
|
||||
} catch (e) {
|
||||
showSnackBar(context, Text(e.toString()));
|
||||
}
|
||||
},
|
||||
));
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user