mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 23:34:24 +01:00
Support Docker start/stop/remove
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toolbox/data/res/color.dart';
|
||||
|
||||
class MenuItem {
|
||||
final String text;
|
||||
@@ -8,9 +9,21 @@ class MenuItem {
|
||||
required this.text,
|
||||
required this.icon,
|
||||
});
|
||||
|
||||
Widget get build => Row(
|
||||
children: [
|
||||
Icon(icon, color: primaryColor),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text(
|
||||
text,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
class MenuItems {
|
||||
class ServerTabMenuItems {
|
||||
static const List<MenuItem> firstItems = [sftp, snippet, apt, docker];
|
||||
static const List<MenuItem> secondItems = [edit];
|
||||
|
||||
@@ -19,18 +32,10 @@ class MenuItems {
|
||||
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) {
|
||||
return Row(
|
||||
children: [
|
||||
Icon(item.icon),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text(
|
||||
item.text,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DockerMenuItems {
|
||||
static const rm = MenuItem(text: 'Remove', icon: Icons.delete);
|
||||
static const start = MenuItem(text: 'Start', icon: Icons.play_arrow);
|
||||
static const stop = MenuItem(text: 'Stop', icon: Icons.stop);
|
||||
}
|
||||
|
||||
@@ -11,17 +11,21 @@ class DockerPsItem {
|
||||
this.status, this.ports, this.name);
|
||||
|
||||
DockerPsItem.fromRawString(String rawString) {
|
||||
final List<String> parts = rawString.split(' ');
|
||||
List<String> parts = rawString.split(' ');
|
||||
parts.removeWhere((element) => element.isEmpty);
|
||||
parts = parts.map((e) => e.trim()).toList();
|
||||
|
||||
containerId = parts[0];
|
||||
image = parts[1];
|
||||
command = parts[2];
|
||||
command = parts[2].trim();
|
||||
created = parts[3];
|
||||
status = parts[4];
|
||||
ports = parts[5];
|
||||
if (running && parts.length == 9) {
|
||||
name = parts[8];
|
||||
} else {
|
||||
if (running) {
|
||||
ports = parts[5];
|
||||
name = parts[6];
|
||||
} else {
|
||||
ports = '';
|
||||
name = parts[5];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user