APT/Docker manage

- view apt update
- view docker container
This commit is contained in:
Junyuan Feng
2022-03-08 14:47:57 +08:00
parent b800bd91fd
commit 34e6b99297
20 changed files with 519 additions and 42 deletions

View File

@@ -11,13 +11,13 @@ class MenuItem {
}
class MenuItems {
static const List<MenuItem> firstItems = [ssh, sftp, snippet, apt];
static const List<MenuItem> firstItems = [sftp, snippet, apt, docker];
static const List<MenuItem> secondItems = [edit];
static const ssh = MenuItem(text: 'SSH', icon: Icons.link);
static const sftp = MenuItem(text: 'SFTP', icon: Icons.insert_drive_file);
static const snippet = MenuItem(text: 'Snippet', icon: Icons.label);
static const apt = MenuItem(text: 'Apt', icon: Icons.system_security_update);
static const docker = MenuItem(text: 'Docker', icon: Icons.view_agenda);
static const edit = MenuItem(text: 'Edit', icon: Icons.edit);
static Widget buildItem(MenuItem item) {

View File

@@ -0,0 +1,33 @@
import 'package:toolbox/data/model/distribution.dart';
class AptUpgradePkgInfo {
final String _raw;
final Distribution _dist;
late String package;
late String nowVersion;
late String newVersion;
late String arch;
AptUpgradePkgInfo(this._raw, this._dist) {
switch (_dist) {
case Distribution.debian:
case Distribution.unknown:
_parseApt();
break;
case Distribution.rehl:
_parseYum();
}
}
void _parseApt() {
final split1 = _raw.split("/");
package = split1[0];
final split2 = split1[1].split(" ");
newVersion = split2[1];
arch = split2[2];
nowVersion = split2[5].replaceFirst(']', '');
}
void _parseYum() {}
}

View File

@@ -0,0 +1,21 @@
enum Distribution {
unknown,
debian,
rehl,
}
const debianDistList = [
'debian',
'ubuntu',
'linuxmint',
'elementary',
'raspbian'
];
const rehlDistList = [
'redhat',
'fedora',
'centos',
'scientificlinux',
'rhel',
'oraclelinux'
];

View File

@@ -0,0 +1,29 @@
class DockerPsItem {
late String containerId;
late String image;
late String command;
late String created;
late String status;
late String ports;
late String name;
DockerPsItem(this.containerId, this.image, this.command, this.created,
this.status, this.ports, this.name);
DockerPsItem.fromRawString(String rawString) {
final List<String> parts = rawString.split(' ');
containerId = parts[0];
image = parts[1];
command = parts[2];
created = parts[3];
status = parts[4];
ports = parts[5];
if (running && parts.length == 9) {
name = parts[8];
} else {
name = parts[6];
}
}
bool get running => status.contains('Up ');
}

View File

@@ -13,6 +13,8 @@ class SFTPSideViewStatus {
AbsolutePath? rightPath;
SftpClient? leftClient;
SftpClient? rightClient;
bool isBusyLeft = false;
bool isBusyRight = false;
SFTPSideViewStatus();
@@ -36,4 +38,8 @@ class SFTPSideViewStatus {
SftpClient? client(bool left) => left ? leftClient : rightClient;
void setClient(bool left, SftpClient? nClient) =>
left ? leftClient = nClient : rightClient = nClient;
bool isBusy(bool left) => left ? isBusyLeft : isBusyRight;
void setBusy(bool left, bool nBusy) =>
left ? isBusyLeft = nBusy : isBusyRight = nBusy;
}