This commit is contained in:
lollipopkit
2023-05-26 17:01:52 +08:00
parent c1c009863d
commit 20ef9d4575
28 changed files with 126 additions and 149 deletions

View File

@@ -11,14 +11,14 @@ class Backup {
final List<PrivateKeyInfo> keys;
final Map<String, String> dockerHosts;
Backup(
this.version,
this.date,
this.spis,
this.snippets,
this.keys,
this.dockerHosts,
);
Backup({
required this.version,
required this.date,
required this.spis,
required this.snippets,
required this.keys,
required this.dockerHosts,
});
Backup.fromJson(Map<String, dynamic> json)
: version = json['version'] as int,

View File

@@ -4,6 +4,7 @@ enum ErrFrom {
docker,
sftp,
ssh,
status;
}
abstract class Err<T> {
@@ -25,4 +26,9 @@ enum DockerErrType {
class DockerErr extends Err<DockerErrType> {
DockerErr({required DockerErrType type, String? message})
: super(from: ErrFrom.docker, type: type, message: message);
@override
String toString() {
return 'DockerErr<$type>: $message';
}
}

View File

@@ -1,16 +1,10 @@
class PathWithPrefix {
late String _prefixPath;
final String _prefixPath;
String _path = '/';
String? _prePath;
String get path => _prefixPath + _path;
PathWithPrefix(String prefixPath) {
if (prefixPath.endsWith('/')) {
_prefixPath = prefixPath.substring(0, prefixPath.length - 1);
} else {
_prefixPath = prefixPath;
}
}
PathWithPrefix(String prefixPath) : _prefixPath = _trimSuffix(prefixPath);
void update(String newPath) {
_prePath = _path;
@@ -36,3 +30,10 @@ class PathWithPrefix {
return true;
}
}
String _trimSuffix(String prefixPath) {
if (prefixPath.endsWith('/')) {
return prefixPath.substring(0, prefixPath.length - 1);
}
return prefixPath;
}

View File

@@ -2,26 +2,17 @@ import '../../../core/extension/stringx.dart';
import '../../res/misc.dart';
class ConnStatus {
/*
{
"maxConn": 0,
"active": 1,
"passive": 2,
"fail": 3
}
*/
final int maxConn;
final int active;
final int passive;
final int fail;
late int maxConn;
late int active;
late int passive;
late int fail;
ConnStatus(
this.maxConn,
this.active,
this.passive,
this.fail,
);
ConnStatus({
required this.maxConn,
required this.active,
required this.passive,
required this.fail,
});
}
ConnStatus? parseConn(String raw) {
@@ -30,7 +21,12 @@ ConnStatus? parseConn(String raw) {
orElse: () => '');
if (idx != '') {
final vals = idx.split(numReg);
return ConnStatus(vals[5].i, vals[6].i, vals[7].i, vals[8].i);
return ConnStatus(
maxConn: vals[5].i,
active: vals[6].i,
passive: vals[7].i,
fail: vals[8].i,
);
}
return null;
}

View File

@@ -1,21 +1,21 @@
import '../../res/misc.dart';
class DiskInfo {
late String path;
late String loc;
late int usedPercent;
late String used;
late String size;
late String avail;
final String path;
final String loc;
final int usedPercent;
final String used;
final String size;
final String avail;
DiskInfo(
this.path,
this.loc,
this.usedPercent,
this.used,
this.size,
this.avail,
);
DiskInfo({
required this.path,
required this.loc,
required this.usedPercent,
required this.used,
required this.size,
required this.avail,
});
}
List<DiskInfo> parseDisk(String raw) {
@@ -37,12 +37,12 @@ List<DiskInfo> parseDisk(String raw) {
pathCache = '';
}
list.add(DiskInfo(
vals[0],
vals[5],
int.parse(vals[4].replaceFirst('%', '')),
vals[2],
vals[1],
vals[3],
path: vals[0],
loc: vals[5],
usedPercent: int.parse(vals[4].replaceFirst('%', '')),
used: vals[2],
size: vals[1],
avail: vals[3],
));
}
return list;

View File

@@ -1,8 +1,8 @@
class Memory {
int total;
int free;
int cache;
int avail;
final int total;
final int free;
final int cache;
final int avail;
Memory({
required this.total,

View File

@@ -1,5 +1,3 @@
import 'dart:convert';
import 'package:hive_flutter/hive_flutter.dart';
part 'private_key_info.g.dart';
@@ -31,15 +29,3 @@ class PrivateKeyInfo {
return data;
}
}
List<PrivateKeyInfo> getPrivateKeyInfoList(dynamic data) {
List<PrivateKeyInfo> ss = [];
if (data is String) {
data = json.decode(data);
}
for (var t in data) {
ss.add(PrivateKeyInfo.fromJson(t));
}
return ss;
}

View File

@@ -1,5 +1,3 @@
import 'dart:convert';
import 'package:hive_flutter/hive_flutter.dart';
part 'server_private_info.g.dart';
@@ -51,15 +49,3 @@ class ServerPrivateInfo {
return data;
}
}
List<ServerPrivateInfo> getServerInfoList(dynamic data) {
List<ServerPrivateInfo> ss = [];
if (data is String) {
data = json.decode(data);
}
for (var t in data) {
ss.add(ServerPrivateInfo.fromJson(t));
}
return ss;
}

View File

@@ -1,5 +1,3 @@
import 'dart:convert';
import 'package:hive_flutter/hive_flutter.dart';
part 'snippet.g.dart';
@@ -23,15 +21,3 @@ class Snippet {
return data;
}
}
List<Snippet> getSnippetList(dynamic data) {
List<Snippet> ss = [];
if (data is String) {
data = json.decode(data);
}
for (var t in data) {
ss.add(Snippet.fromJson(t));
}
return ss;
}

View File

@@ -9,7 +9,7 @@ class VirtualKey {
final VirtualKeyFunc? func;
VirtualKey(this.text,
{this.key, this.toggleable = false, this.icon, this.func});
{this.key, this.toggleable = false, this.icon, this.func,});
}
enum VirtualKeyFunc { toggleIME, backspace, copy, paste, snippet }

View File

@@ -9,7 +9,7 @@ import 'package:toolbox/core/extension/uint8list.dart';
import 'package:toolbox/core/provider_base.dart';
import 'package:toolbox/data/model/docker/image.dart';
import 'package:toolbox/data/model/docker/ps.dart';
import 'package:toolbox/data/res/error.dart';
import 'package:toolbox/data/model/app/error.dart';
import 'package:toolbox/data/store/docker.dart';
import 'package:toolbox/locator.dart';

View File

@@ -2,8 +2,8 @@
class BuildData {
static const String name = "ServerBox";
static const int build = 314;
static const String engine = "3.10.0";
static const String buildAt = "2023-05-18 22:09:44.404990";
static const int modifications = 2;
static const int build = 318;
static const String engine = "3.10.2";
static const String buildAt = "2023-05-26 13:49:02.698178";
static const int modifications = 6;
}

View File

@@ -47,8 +47,17 @@ ServerStatus get initStatus => ServerStatus(
mem: _initMemory,
sysVer: 'Loading...',
uptime: '',
disk: [DiskInfo('/', '/', 0, '0', '0', '0')],
tcp: ConnStatus(0, 0, 0, 0),
disk: [
DiskInfo(
path: '/',
loc: '/',
usedPercent: 0,
used: '0',
size: '0',
avail: '0',
)
],
tcp: ConnStatus(maxConn: 0, active: 0, passive: 0, fail: 0),
netSpeed: initNetSpeed,
swap: _initSwap,
temps: Temperatures(),