new: iperf

This commit is contained in:
lollipopkit
2024-01-21 18:53:17 +08:00
parent 50d6ed919b
commit 1434556e0b
34 changed files with 432 additions and 117 deletions

View File

@@ -1,30 +1,44 @@
import 'package:flutter/material.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:toolbox/core/extension/context/locale.dart';
enum ServerTabMenu {
part 'server_func.g.dart';
@HiveType(typeId: 6)
enum ServerFuncBtn {
@HiveField(0)
terminal,
@HiveField(1)
sftp,
@HiveField(2)
container,
@HiveField(3)
process,
@HiveField(4)
pkg,
@HiveField(5)
snippet,
@HiveField(6)
iperf,
;
IconData get icon => switch (this) {
ServerTabMenu.sftp => Icons.insert_drive_file,
ServerTabMenu.snippet => Icons.code,
ServerTabMenu.pkg => Icons.system_security_update,
ServerTabMenu.container => Icons.view_agenda,
ServerTabMenu.process => Icons.list_alt_outlined,
ServerTabMenu.terminal => Icons.terminal,
};
sftp => Icons.insert_drive_file,
snippet => Icons.code,
pkg => Icons.system_security_update,
container => Icons.view_agenda,
process => Icons.list_alt_outlined,
terminal => Icons.terminal,
iperf => Icons.speed,
};
String get toStr => switch (this) {
ServerTabMenu.sftp => 'SFTP',
ServerTabMenu.snippet => l10n.snippet,
ServerTabMenu.pkg => l10n.pkg,
ServerTabMenu.container => l10n.container,
ServerTabMenu.process => l10n.process,
ServerTabMenu.terminal => l10n.terminal,
};
}
sftp => 'SFTP',
snippet => l10n.snippet,
pkg => l10n.pkg,
container => l10n.container,
process => l10n.process,
terminal => l10n.terminal,
iperf => 'iperf',
};
}

View File

@@ -0,0 +1,71 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'server_func.dart';
// **************************************************************************
// TypeAdapterGenerator
// **************************************************************************
class ServerFuncBtnAdapter extends TypeAdapter<ServerFuncBtn> {
@override
final int typeId = 6;
@override
ServerFuncBtn read(BinaryReader reader) {
switch (reader.readByte()) {
case 0:
return ServerFuncBtn.terminal;
case 1:
return ServerFuncBtn.sftp;
case 2:
return ServerFuncBtn.container;
case 3:
return ServerFuncBtn.process;
case 4:
return ServerFuncBtn.pkg;
case 5:
return ServerFuncBtn.snippet;
case 6:
return ServerFuncBtn.iperf;
default:
return ServerFuncBtn.terminal;
}
}
@override
void write(BinaryWriter writer, ServerFuncBtn obj) {
switch (obj) {
case ServerFuncBtn.terminal:
writer.writeByte(0);
break;
case ServerFuncBtn.sftp:
writer.writeByte(1);
break;
case ServerFuncBtn.container:
writer.writeByte(2);
break;
case ServerFuncBtn.process:
writer.writeByte(3);
break;
case ServerFuncBtn.pkg:
writer.writeByte(4);
break;
case ServerFuncBtn.snippet:
writer.writeByte(5);
break;
case ServerFuncBtn.iperf:
writer.writeByte(6);
break;
}
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is ServerFuncBtnAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}

View File

@@ -140,9 +140,13 @@ class ServerProvider extends ChangeNotifier {
static final refreshKey = GlobalKey<RefreshIndicatorState>();
Future<void> startAutoRefresh() async {
final duration = Stores.setting.serverStatusUpdateInterval.fetch();
var duration = Stores.setting.serverStatusUpdateInterval.fetch();
stopAutoRefresh();
if (duration == 0) return;
if (duration < 0 || duration > 10 || duration == 1) {
duration = 3;
Loggers.app.warning('Invalid duration: $duration, use default 3');
}
refreshKey.currentState?.show();
_timer = Timer.periodic(Duration(seconds: duration), (_) async {
await refreshData();

View File

@@ -2,9 +2,9 @@
class BuildData {
static const String name = "ServerBox";
static const int build = 712;
static const String engine = "3.16.7";
static const String buildAt = "2024-01-21 15:41:48";
static const int modifications = 5;
static const int script = 35;
static const int build = 715;
static const String engine = "3.16.8";
static const String buildAt = "2024-01-21 18:14:00";
static const int modifications = 20;
static const int script = 36;
}

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:toolbox/core/persistant_store.dart';
import 'package:toolbox/core/utils/platform/base.dart';
import 'package:toolbox/data/model/app/menu/server_func.dart';
import '../model/app/net_view.dart';
import '../res/default.dart';
@@ -208,6 +209,15 @@ class SettingStore extends PersistentStore {
/// Whether collapse UI items by default
late final collapseUIDefault = property('collapseUIDefault', true);
late final serverFuncBtns = listProperty<ServerFuncBtn>('serverBtns', [
ServerFuncBtn.terminal,
ServerFuncBtn.sftp,
ServerFuncBtn.container,
ServerFuncBtn.process,
ServerFuncBtn.pkg,
ServerFuncBtn.snippet,
]);
// Never show these settings for users
//
// ------BEGIN------