diff --git a/agent/app/dto/docker.go b/agent/app/dto/docker.go
index bfabacc41..6de1926db 100644
--- a/agent/app/dto/docker.go
+++ b/agent/app/dto/docker.go
@@ -6,7 +6,8 @@ type DaemonJsonUpdateByFile struct {
type DaemonJsonConf struct {
IsSwarm bool `json:"isSwarm"`
- Status string `json:"status"`
+ IsExist bool `json:"isExist"`
+ IsActive bool `json:"isActive"`
Version string `json:"version"`
Mirrors []string `json:"registryMirrors"`
Registries []string `json:"insecureRegistries"`
diff --git a/agent/app/dto/firewall.go b/agent/app/dto/firewall.go
index c3d3646e1..ab1d446ee 100644
--- a/agent/app/dto/firewall.go
+++ b/agent/app/dto/firewall.go
@@ -2,7 +2,8 @@ package dto
type FirewallBaseInfo struct {
Name string `json:"name"`
- Status string `json:"status"`
+ IsExist bool `json:"isExist"`
+ IsActive bool `json:"isActive"`
Version string `json:"version"`
PingStatus string `json:"pingStatus"`
}
diff --git a/agent/app/dto/ssh.go b/agent/app/dto/ssh.go
index c07a3f4e9..c020ad567 100644
--- a/agent/app/dto/ssh.go
+++ b/agent/app/dto/ssh.go
@@ -10,7 +10,8 @@ type SSHUpdate struct {
type SSHInfo struct {
AutoStart bool `json:"autoStart"`
- Status string `json:"status"`
+ IsExist bool `json:"isExist"`
+ IsActive bool `json:"isActive"`
Message string `json:"message"`
Port string `json:"port"`
ListenAddress string `json:"listenAddress"`
diff --git a/agent/app/service/docker.go b/agent/app/service/docker.go
index beb6e0b84..d995f947b 100644
--- a/agent/app/service/docker.go
+++ b/agent/app/service/docker.go
@@ -69,15 +69,19 @@ func (u *DockerService) LoadDockerConf() *dto.DaemonJsonConf {
ctx := context.Background()
var data dto.DaemonJsonConf
data.IPTables = true
- data.Status = constant.StatusRunning
data.Version = "-"
+ if cmd.Which("docker") {
+ data.IsExist = false
+ return &data
+ }
+ data.IsExist = true
client, err := docker.NewDockerClient()
if err != nil {
- data.Status = constant.Stopped
+ data.IsActive = false
} else {
defer client.Close()
if _, err := client.Ping(ctx); err != nil {
- data.Status = constant.Stopped
+ data.IsActive = false
}
itemVersion, err := client.ServerVersion(ctx)
if err == nil {
diff --git a/agent/app/service/fail2ban.go b/agent/app/service/fail2ban.go
index b0f2af483..4876f543c 100644
--- a/agent/app/service/fail2ban.go
+++ b/agent/app/service/fail2ban.go
@@ -116,8 +116,8 @@ func (u *Fail2BanService) UpdateConf(req dto.Fail2BanUpdate) error {
if client.Name() != itemName {
return buserr.WithName("ErrBanAction", itemName)
}
- status, _ := client.Status()
- if status != "running" {
+ isActive, _ := client.Status()
+ if !isActive {
return buserr.WithName("ErrBanAction", itemName)
}
}
diff --git a/agent/app/service/firewall.go b/agent/app/service/firewall.go
index 744adc4d3..820507d75 100644
--- a/agent/app/service/firewall.go
+++ b/agent/app/service/firewall.go
@@ -43,13 +43,14 @@ func NewIFirewallService() IFirewallService {
func (u *FirewallService) LoadBaseInfo() (dto.FirewallBaseInfo, error) {
var baseInfo dto.FirewallBaseInfo
- baseInfo.Status = "not running"
baseInfo.Version = "-"
baseInfo.Name = "-"
client, err := firewall.NewFirewallClient()
if err != nil {
+ baseInfo.IsExist = false
return baseInfo, err
}
+ baseInfo.IsExist = true
baseInfo.Name = client.Name()
var wg sync.WaitGroup
@@ -60,7 +61,7 @@ func (u *FirewallService) LoadBaseInfo() (dto.FirewallBaseInfo, error) {
}()
go func() {
defer wg.Done()
- baseInfo.Status, _ = client.Status()
+ baseInfo.IsActive, _ = client.Status()
}()
go func() {
defer wg.Done()
diff --git a/agent/app/service/ssh.go b/agent/app/service/ssh.go
index 02e3bf297..8e62b3a46 100644
--- a/agent/app/service/ssh.go
+++ b/agent/app/service/ssh.go
@@ -45,7 +45,8 @@ func NewISSHService() ISSHService {
func (u *SSHService) GetSSHInfo() (*dto.SSHInfo, error) {
data := dto.SSHInfo{
AutoStart: true,
- Status: constant.StatusEnable,
+ IsExist: true,
+ IsActive: true,
Message: "",
Port: "22",
ListenAddress: "",
@@ -56,17 +57,13 @@ func (u *SSHService) GetSSHInfo() (*dto.SSHInfo, error) {
}
serviceName, err := loadServiceName()
if err != nil {
- data.Status = constant.StatusDisable
+ data.IsExist = false
data.Message = err.Error()
} else {
active, err := systemctl.IsActive(serviceName)
- if !active {
- data.Status = constant.StatusDisable
- if err != nil {
- data.Message = err.Error()
- }
- } else {
- data.Status = constant.StatusEnable
+ data.IsActive = active
+ if !active && err != nil {
+ data.Message = err.Error()
}
}
@@ -84,7 +81,7 @@ func (u *SSHService) GetSSHInfo() (*dto.SSHInfo, error) {
sshConf, err := os.ReadFile(sshPath)
if err != nil {
data.Message = err.Error()
- data.Status = constant.StatusDisable
+ data.IsActive = false
}
lines := strings.Split(string(sshConf), "\n")
for _, line := range lines {
diff --git a/agent/utils/firewall/client.go b/agent/utils/firewall/client.go
index 80f421962..c106e5654 100644
--- a/agent/utils/firewall/client.go
+++ b/agent/utils/firewall/client.go
@@ -13,7 +13,7 @@ type FirewallClient interface {
Stop() error
Restart() error
Reload() error
- Status() (string, error) // running not running
+ Status() (bool, error) // running not running
Version() (string, error)
ListPort() ([]client.FireInfo, error)
diff --git a/agent/utils/firewall/client/firewalld.go b/agent/utils/firewall/client/firewalld.go
index 84db69373..88c813b5c 100644
--- a/agent/utils/firewall/client/firewalld.go
+++ b/agent/utils/firewall/client/firewalld.go
@@ -24,12 +24,9 @@ func (f *Firewall) Name() string {
return "firewalld"
}
-func (f *Firewall) Status() (string, error) {
+func (f *Firewall) Status() (bool, error) {
stdout, _ := cmd.Exec("firewall-cmd --state")
- if stdout == "running\n" {
- return "running", nil
- }
- return "not running", nil
+ return stdout == "running\n", nil
}
func (f *Firewall) Version() (string, error) {
diff --git a/agent/utils/firewall/client/iptables.go b/agent/utils/firewall/client/iptables.go
index 5ea38a938..4aa1e1e31 100644
--- a/agent/utils/firewall/client/iptables.go
+++ b/agent/utils/firewall/client/iptables.go
@@ -27,8 +27,8 @@ func NewIptables() (*Iptables, error) {
return iptables, nil
}
-func (iptables *Iptables) runf(rule string, a ...any) error {
- stdout, err := cmd.Execf("%s iptables -t nat %s", iptables.CmdStr, fmt.Sprintf(rule, a...))
+func (iptables *Iptables) run(rule string) error {
+ stdout, err := cmd.Execf("%s iptables -t nat %s", iptables.CmdStr, rule)
if err != nil {
return fmt.Errorf("%s, %s", err, stdout)
}
@@ -39,6 +39,10 @@ func (iptables *Iptables) runf(rule string, a ...any) error {
return nil
}
+func (iptables *Iptables) runf(rule string, a ...any) error {
+ return iptables.run(fmt.Sprintf(rule, a...))
+}
+
func (iptables *Iptables) Check() error {
stdout, err := cmd.Exec("cat /proc/sys/net/ipv4/ip_forward")
if err != nil {
@@ -100,7 +104,7 @@ func (iptables *Iptables) NatAdd(protocol, src, destIp, destPort string, save bo
if destIp != "" && destIp != "127.0.0.1" && destIp != "localhost" {
rule = fmt.Sprintf("-A %s -p %s --dport %s -j DNAT --to-destination %s:%s", NatChain, protocol, src, destIp, destPort)
}
- if err := iptables.runf(rule); err != nil {
+ if err := iptables.run(rule); err != nil {
return err
}
diff --git a/agent/utils/firewall/client/ufw.go b/agent/utils/firewall/client/ufw.go
index e90c4b81a..ca09516be 100644
--- a/agent/utils/firewall/client/ufw.go
+++ b/agent/utils/firewall/client/ufw.go
@@ -28,16 +28,16 @@ func (f *Ufw) Name() string {
return "ufw"
}
-func (f *Ufw) Status() (string, error) {
+func (f *Ufw) Status() (bool, error) {
stdout, _ := cmd.Execf("%s status | grep Status", f.CmdStr)
if stdout == "Status: active\n" {
- return "running", nil
+ return true, nil
}
stdout1, _ := cmd.Execf("%s status | grep 状态", f.CmdStr)
if stdout1 == "状态: 激活\n" {
- return "running", nil
+ return true, nil
}
- return "not running", nil
+ return false, nil
}
func (f *Ufw) Version() (string, error) {
diff --git a/frontend/src/views/container/compose/index.vue b/frontend/src/views/container/compose/index.vue
index 18f5dc823..55adbbf2f 100644
--- a/frontend/src/views/container/compose/index.vue
+++ b/frontend/src/views/container/compose/index.vue
@@ -3,13 +3,10 @@
-
- {{ $t('container.serviceUnavailable') }}
- 【 {{ $t('container.setting') }} 】
- {{ $t('container.startIn') }}
-
-
+
+
+
{{ $t('container.createCompose') }}
@@ -90,12 +87,13 @@
diff --git a/frontend/src/views/container/container/index.vue b/frontend/src/views/container/container/index.vue
index 47084e242..6c3a7d1f7 100644
--- a/frontend/src/views/container/container/index.vue
+++ b/frontend/src/views/container/container/index.vue
@@ -1,12 +1,8 @@
-
- {{ $t('container.serviceUnavailable') }}
- 【 {{ $t('container.setting') }} 】
- {{ $t('container.startIn') }}
-
+
-
+
{{ $t('commons.table.all') }} * {{ countItem.all }}
@@ -69,7 +65,7 @@
-
+
{{ $t('container.create') }}
@@ -414,6 +410,7 @@ import ContainerLogDialog from '@/views/container/container/log/index.vue';
import TerminalDialog from '@/views/container/container/terminal/index.vue';
import CodemirrorDialog from '@/components/codemirror-dialog/index.vue';
import PortJumpDialog from '@/components/port-jump/index.vue';
+import DockerStatus from '@/views/container/docker-status/index.vue';
import Status from '@/components/status/index.vue';
import { reactive, onMounted, ref, computed } from 'vue';
import {
@@ -421,7 +418,6 @@ import {
containerOperator,
inspect,
loadContainerStatus,
- loadDockerStatus,
searchContainer,
} from '@/api/modules/container';
import { Container } from '@/api/interface/container';
@@ -434,6 +430,7 @@ const globalStore = GlobalStore();
const mobile = computed(() => {
return globalStore.isMobile();
});
+const isActive = ref(false);
const loading = ref(false);
const data = ref();
@@ -466,23 +463,6 @@ const countItem = reactive({
dead: 0,
});
-const dockerStatus = ref('Running');
-const loadStatus = async () => {
- loading.value = true;
- await loadDockerStatus()
- .then((res) => {
- loading.value = false;
- dockerStatus.value = res.data;
- if (dockerStatus.value === 'Running') {
- search();
- }
- })
- .catch(() => {
- dockerStatus.value = 'Failed';
- loading.value = false;
- });
-};
-
const goDashboard = async (port: any) => {
if (port.indexOf('127.0.0.1') !== -1) {
MsgWarning(i18n.global.t('container.unExposedPort'));
@@ -499,10 +479,6 @@ const goDashboard = async (port: any) => {
dialogPortJumpRef.value.acceptParams({ port: portEx, ip: ip });
};
-const goSetting = async () => {
- router.push({ name: 'ContainerSetting' });
-};
-
interface Filters {
filters?: string;
}
@@ -517,6 +493,9 @@ const dialogRenameRef = ref();
const dialogPruneRef = ref();
const search = async (column?: any) => {
+ if (!isActive.value) {
+ return;
+ }
localStorage.setItem('includeAppStore', includeAppStore.value ? 'true' : 'false');
let filterItem = props.filters ? props.filters : '';
paginationConfig.orderBy = column?.order ? column.prop : paginationConfig.orderBy;
@@ -802,7 +781,6 @@ const buttons = [
onMounted(() => {
let includeItem = localStorage.getItem('includeAppStore');
includeAppStore.value = !includeItem || includeItem === 'true';
- loadStatus();
});
diff --git a/frontend/src/views/container/docker-status/index.vue b/frontend/src/views/container/docker-status/index.vue
new file mode 100644
index 000000000..46fac2fe1
--- /dev/null
+++ b/frontend/src/views/container/docker-status/index.vue
@@ -0,0 +1,40 @@
+
+
+
+ {{ $t('container.serviceUnavailable') }}
+ 【 {{ $t('container.setting') }} 】
+ {{ $t('container.startIn') }}
+
+
+
+
+
diff --git a/frontend/src/views/container/image/index.vue b/frontend/src/views/container/image/index.vue
index b2d34f2bd..ed5f3a426 100644
--- a/frontend/src/views/container/image/index.vue
+++ b/frontend/src/views/container/image/index.vue
@@ -1,12 +1,8 @@
-
- {{ $t('container.serviceUnavailable') }}
- 【 {{ $t('container.setting') }} 】
- {{ $t('container.startIn') }}
-
+
-
+
{{ $t('container.imagePull') }}
@@ -99,7 +95,7 @@
diff --git a/frontend/src/views/container/network/index.vue b/frontend/src/views/container/network/index.vue
index f67cf0854..106d63f36 100644
--- a/frontend/src/views/container/network/index.vue
+++ b/frontend/src/views/container/network/index.vue
@@ -1,12 +1,8 @@
-
- {{ $t('container.serviceUnavailable') }}
- 【 {{ $t('container.setting') }} 】
- {{ $t('container.startIn') }}
-
+
-
+
{{ $t('container.createNetwork') }}
@@ -93,14 +89,14 @@
diff --git a/frontend/src/views/container/repo/index.vue b/frontend/src/views/container/repo/index.vue
index fdf210828..98819db13 100644
--- a/frontend/src/views/container/repo/index.vue
+++ b/frontend/src/views/container/repo/index.vue
@@ -1,12 +1,8 @@
-
- {{ $t('container.serviceUnavailable') }}
- 【 {{ $t('container.setting') }} 】
- {{ $t('container.startIn') }}
-
+
-
+
{{ $t('container.createRepo') }}
@@ -66,12 +62,12 @@
diff --git a/frontend/src/views/container/template/index.vue b/frontend/src/views/container/template/index.vue
index 218f29114..e6f0c7046 100644
--- a/frontend/src/views/container/template/index.vue
+++ b/frontend/src/views/container/template/index.vue
@@ -1,12 +1,8 @@
-
- {{ $t('container.serviceUnavailable') }}
- 【 {{ $t('container.setting') }} 】
- {{ $t('container.startIn') }}
-
+
-
+
{{ $t('container.createComposeTemplate') }}
@@ -61,14 +57,14 @@
diff --git a/frontend/src/views/container/volume/index.vue b/frontend/src/views/container/volume/index.vue
index 1bae03fd3..b33b279b6 100644
--- a/frontend/src/views/container/volume/index.vue
+++ b/frontend/src/views/container/volume/index.vue
@@ -1,12 +1,8 @@
-
- {{ $t('container.serviceUnavailable') }}
- 【 {{ $t('container.setting') }} 】
- {{ $t('container.startIn') }}
-
+
-
+
{{ $t('container.createVolume') }}
@@ -88,9 +84,10 @@
diff --git a/frontend/src/views/host/firewall/forward/index.vue b/frontend/src/views/host/firewall/forward/index.vue
index d95189069..c3a6bace3 100644
--- a/frontend/src/views/host/firewall/forward/index.vue
+++ b/frontend/src/views/host/firewall/forward/index.vue
@@ -9,15 +9,15 @@
@search="search"
v-model:loading="loading"
v-model:mask-show="maskShow"
- v-model:status="fireStatus"
+ v-model:is-active="isActive"
v-model:name="fireName"
/>
-
+
{{ $t('firewall.firewallNotStart') }}
-
+
{{ $t('commons.button.create') }}{{ $t('firewall.forwardRule') }}
@@ -97,7 +97,7 @@ const searchStatus = ref('');
const searchStrategy = ref('');
const maskShow = ref(true);
-const fireStatus = ref('running');
+const isActive = ref(false);
const fireName = ref();
const fireStatusRef = ref();
@@ -112,7 +112,7 @@ const paginationConfig = reactive({
});
const search = async () => {
- if (fireStatus.value !== 'running') {
+ if (!isActive.value) {
loading.value = false;
data.value = [];
paginationConfig.total = 0;
diff --git a/frontend/src/views/host/firewall/ip/index.vue b/frontend/src/views/host/firewall/ip/index.vue
index 2ca8d7d00..528057a20 100644
--- a/frontend/src/views/host/firewall/ip/index.vue
+++ b/frontend/src/views/host/firewall/ip/index.vue
@@ -10,15 +10,15 @@
v-model:loading="loading"
v-model:name="fireName"
v-model:mask-show="maskShow"
- v-model:status="fireStatus"
+ v-model:is-active="isActive"
/>
-
+
{{ $t('firewall.firewallNotStart') }}
-
+
{{ $t('commons.button.create') }} {{ $t('firewall.ipRule') }}
@@ -133,7 +133,7 @@ const searchStrategy = ref('');
const fireName = ref();
const maskShow = ref(true);
-const fireStatus = ref('running');
+const isActive = ref(false);
const fireStatusRef = ref();
const opRef = ref();
@@ -147,7 +147,7 @@ const paginationConfig = reactive({
});
const search = async () => {
- if (fireStatus.value !== 'running') {
+ if (!isActive.value) {
loading.value = false;
data.value = [];
paginationConfig.total = 0;
diff --git a/frontend/src/views/host/firewall/port/index.vue b/frontend/src/views/host/firewall/port/index.vue
index 30d8e0839..301b159ea 100644
--- a/frontend/src/views/host/firewall/port/index.vue
+++ b/frontend/src/views/host/firewall/port/index.vue
@@ -9,15 +9,15 @@
@search="search"
v-model:loading="loading"
v-model:mask-show="maskShow"
- v-model:status="fireStatus"
+ v-model:is-active="isActive"
v-model:name="fireName"
/>
-
+
{{ $t('firewall.firewallNotStart') }}
-
+
@@ -184,7 +184,7 @@ const searchStatus = ref('');
const searchStrategy = ref('');
const maskShow = ref(true);
-const fireStatus = ref('running');
+const isActive = ref(false);
const fireName = ref();
const fireStatusRef = ref();
@@ -199,7 +199,7 @@ const paginationConfig = reactive({
});
const search = async () => {
- if (fireStatus.value !== 'running') {
+ if (!isActive.value) {
loading.value = false;
data.value = [];
paginationConfig.total = 0;
diff --git a/frontend/src/views/host/firewall/status/index.vue b/frontend/src/views/host/firewall/status/index.vue
index 3c8cb7505..26853fa43 100644
--- a/frontend/src/views/host/firewall/status/index.vue
+++ b/frontend/src/views/host/firewall/status/index.vue
@@ -5,19 +5,19 @@
{{ baseInfo.name }}
-
+
{{ $t('commons.status.running') }}
-
+
{{ $t('commons.status.stopped') }}
{{ $t('app.version') }}: {{ baseInfo.version }}
-
+
{{ $t('commons.button.stop') }}
-
+
{{ $t('commons.button.start') }}
@@ -51,14 +51,14 @@ import { MsgSuccess } from '@/utils/message';
import { ElMessageBox } from 'element-plus';
import { ref } from 'vue';
-const baseInfo = ref({ status: '', name: '', version: '', pingStatus: '' });
+const baseInfo = ref({ isActive: false, isExist: false, name: '', version: '', pingStatus: '' });
const onPing = ref('Disable');
const oldStatus = ref();
const acceptParams = (): void => {
loadBaseInfo(true);
};
-const emit = defineEmits(['search', 'update:status', 'update:loading', 'update:maskShow', 'update:name']);
+const emit = defineEmits(['search', 'update:is-active', 'update:loading', 'update:maskShow', 'update:name']);
const loadBaseInfo = async (search: boolean) => {
await loadFireBaseInfo()
@@ -67,7 +67,7 @@ const loadBaseInfo = async (search: boolean) => {
onPing.value = baseInfo.value.pingStatus;
oldStatus.value = onPing.value;
emit('update:name', baseInfo.value.name);
- emit('update:status', baseInfo.value.status);
+ emit('update:is-active', baseInfo.value.status);
if (search) {
emit('search');
} else {
@@ -91,7 +91,6 @@ const onOperate = async (operation: string) => {
})
.then(async () => {
emit('update:loading', true);
- emit('update:status', 'running');
emit('update:maskShow', true);
await operateFire(operation)
.then(() => {
@@ -117,7 +116,6 @@ const onPingOperate = async (operation: string) => {
})
.then(async () => {
emit('update:loading', true);
- emit('update:status', 'running');
operation = operation === 'Disable' ? 'disablePing' : 'enablePing';
emit('update:maskShow', true);
await operateFire(operation)
diff --git a/frontend/src/views/host/ssh/ssh/index.vue b/frontend/src/views/host/ssh/ssh/index.vue
index 3bd37188d..5226cd37b 100644
--- a/frontend/src/views/host/ssh/ssh/index.vue
+++ b/frontend/src/views/host/ssh/ssh/index.vue
@@ -7,28 +7,28 @@
SSH
-
+
{{ $t('commons.status.running') }}
-
+
{{ $t('commons.status.stopped') }}
-
+
{{ $t('commons.button.stop') }}
-
+
{{ $t('commons.button.start') }}
@@ -174,7 +174,7 @@ const autoStart = ref('enable');
const sshConf = ref();
const form = reactive({
- status: 'enable',
+ isActive: false,
message: '',
port: 22,
listenAddress: '',
@@ -316,7 +316,7 @@ const changeMode = async () => {
const search = async () => {
const res = await getSSHInfo();
- form.status = res.data.status;
+ form.isActive = res.data.isActive;
form.port = Number(res.data.port);
autoStart.value = res.data.autoStart ? 'enable' : 'disable';
form.listenAddress = res.data.listenAddress;