diff --git a/backend/app/dto/dashboard.go b/backend/app/dto/dashboard.go
index 3d4e96bad..c976a56ff 100644
--- a/backend/app/dto/dashboard.go
+++ b/backend/app/dto/dashboard.go
@@ -23,6 +23,8 @@ type DashboardBase struct {
KernelArch string `json:"kernelArch"`
KernelVersion string `json:"kernelVersion"`
VirtualizationSystem string `json:"virtualizationSystem"`
+ Uptime string `json:"uptime"`
+ TimeSinceUptime string `json:"timeSinceUptime"`
CPUCores int `json:"cpuCores"`
CPULogicalCores int `json:"cpuLogicalCores"`
diff --git a/backend/app/service/dashboard.go b/backend/app/service/dashboard.go
index e15fae20f..562554550 100644
--- a/backend/app/service/dashboard.go
+++ b/backend/app/service/dashboard.go
@@ -2,6 +2,8 @@ package service
import (
"encoding/json"
+ "fmt"
+ "os/exec"
"time"
"github.com/1Panel-dev/1Panel/backend/app/dto"
@@ -39,6 +41,18 @@ func (u *DashboardService) LoadBaseInfo(ioOption string, netOption string) (*dto
ss, _ := json.Marshal(hostInfo)
baseInfo.VirtualizationSystem = string(ss)
+ cmd := exec.Command("uptime", "-s")
+ stdout, err := cmd.CombinedOutput()
+ if err != nil {
+ baseInfo.Uptime = string(stdout)
+ uptime, err := time.Parse("2006-01-02 15:04:05", string(stdout))
+ if err != nil {
+ hours := int(time.Since(uptime).Hours())
+ minutes := int(time.Since(uptime).Minutes())
+ baseInfo.TimeSinceUptime = fmt.Sprintf("%ddays %dhours %dmimutes", hours/24, hours%24, minutes-hours*60)
+ }
+ }
+
apps, err := appRepo.GetBy()
if err != nil {
return nil, err
diff --git a/backend/utils/ssl/acme_test.go b/backend/utils/ssl/acme_test.go
index 3415e0f2e..fb9449f7b 100644
--- a/backend/utils/ssl/acme_test.go
+++ b/backend/utils/ssl/acme_test.go
@@ -8,6 +8,13 @@ import (
"encoding/pem"
"errors"
"fmt"
+ "io/ioutil"
+ "os"
+ "strconv"
+ "strings"
+ "testing"
+ "time"
+
"github.com/1Panel-dev/1Panel/backend/utils/cmd"
"github.com/cenkalti/backoff/v4"
"github.com/go-acme/lego/v4/acme"
@@ -18,12 +25,6 @@ import (
"github.com/go-acme/lego/v4/challenge/dns01"
"github.com/go-acme/lego/v4/lego"
"github.com/go-acme/lego/v4/registration"
- "io/ioutil"
- "os"
- "strconv"
- "strings"
- "testing"
- "time"
)
type plainDnsProvider struct {
@@ -37,11 +38,6 @@ func (p *plainDnsProvider) Present(domain, token, keyAuth string) error {
return nil
}
-func (p *plainDnsProvider) CleanUp(domain, token, keyAuth string) error {
- fmt.Sprintf("%s,%s,%s", domain, token, keyAuth)
- return nil
-}
-
func TestCreatePrivate(t *testing.T) {
priKey, err := rsa.GenerateKey(rand.Reader, 2048)
if err != nil {
@@ -263,10 +259,10 @@ func TestSSL(t *testing.T) {
// panic(err)
//}
- err = client.Challenge.SetDNS01Provider(&plainDnsProvider{}, dns01.AddDNSTimeout(6*time.Minute))
- if err != nil {
- panic(err)
- }
+ // err = client.Challenge.SetDNS01Provider(&plainDnsProvider{}, dns01.AddDNSTimeout(6*time.Minute))
+ // if err != nil {
+ // panic(err)
+ // }
core, err := api.New(config.HTTPClient, config.UserAgent, config.CADirURL, reg.URI, priKey)
if err != nil {
diff --git a/frontend/src/api/interface/dashboard.ts b/frontend/src/api/interface/dashboard.ts
index 1635d2038..4ffc684cd 100644
--- a/frontend/src/api/interface/dashboard.ts
+++ b/frontend/src/api/interface/dashboard.ts
@@ -20,6 +20,8 @@ export namespace Dashboard {
kernelArch: string;
kernelVersion: string;
virtualizationSystem: string;
+ uptime: string;
+ timeSinceUptime: string;
cpuCores: number;
cpuLogicalCores: number;
diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts
index 9d52e1a7b..cd52d61dc 100644
--- a/frontend/src/lang/modules/en.ts
+++ b/frontend/src/lang/modules/en.ts
@@ -163,6 +163,8 @@ export default {
rwPerSecond: 'RW per second',
ioDelay: 'IO delay',
time: 'Times',
+ uptime: 'Up Time',
+ runningTime: 'Running Time',
runSmoothly: 'Run smoothly',
runNormal: 'Run normal',
diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts
index 7cbe0a55b..050c955a0 100644
--- a/frontend/src/lang/modules/zh.ts
+++ b/frontend/src/lang/modules/zh.ts
@@ -169,6 +169,8 @@ export default {
rwPerSecond: '每秒读写',
ioDelay: 'IO 延迟',
time: '次',
+ uptime: '启动时间',
+ runningTime: '运行时间',
runSmoothly: '运行流畅',
runNormal: '运行正常',
diff --git a/frontend/src/views/database/mysql/index.vue b/frontend/src/views/database/mysql/index.vue
index a99521f47..fa45a7c8f 100644
--- a/frontend/src/views/database/mysql/index.vue
+++ b/frontend/src/views/database/mysql/index.vue
@@ -106,6 +106,25 @@
+
+
+
+ {{ $t('database.goInstall') }}
+
+
+
+
+
+
+
@@ -133,13 +152,16 @@ import { Database } from '@/api/interface/database';
import { Rules } from '@/global/form-rules';
import { App } from '@/api/interface/app';
import { GetAppPort } from '@/api/modules/app';
+import router from '@/routers';
const selects = ref([]);
const mysqlName = ref();
const isOnSetting = ref();
const checkRef = ref();
+
const phpadminPort = ref();
+const phpVisiable = ref(false);
const data = ref();
const paginationConfig = reactive({
@@ -214,7 +236,15 @@ const search = async () => {
paginationConfig.total = res.data.total;
};
+const goRouter = async (path: string) => {
+ router.push({ path: path });
+};
+
const goDashboard = async () => {
+ if (phpadminPort.value === 0) {
+ phpVisiable.value = true;
+ return;
+ }
window.open('http://localhost:' + phpadminPort.value, '_blank');
};
diff --git a/frontend/src/views/database/redis/index.vue b/frontend/src/views/database/redis/index.vue
index a3ff96a9c..3f5605907 100644
--- a/frontend/src/views/database/redis/index.vue
+++ b/frontend/src/views/database/redis/index.vue
@@ -9,6 +9,25 @@
Redis-Command
+
+
+
+
+ {{ $t('database.goInstall') }}
+
+
+
+
+
+
@@ -20,6 +39,7 @@ import AppStatus from '@/components/app-status/index.vue';
import { ref } from 'vue';
import { App } from '@/api/interface/app';
import { GetAppPort } from '@/api/modules/app';
+import router from '@/routers';
const terminalRef = ref();
const settingRef = ref();
@@ -27,6 +47,7 @@ const isOnSetting = ref(false);
const redisIsExist = ref(false);
const redisCommandPort = ref();
+const commandVisiable = ref(false);
const onSetting = async () => {
isOnSetting.value = true;
@@ -34,12 +55,20 @@ const onSetting = async () => {
settingRef.value!.acceptParams();
};
+const goRouter = async (path: string) => {
+ router.push({ path: path });
+};
+
const goDashboard = async () => {
+ if (redisCommandPort.value === 0) {
+ commandVisiable.value = true;
+ return;
+ }
window.open('http://localhost:' + redisCommandPort.value, '_blank');
};
const loadDashboardPort = async () => {
- const res = await GetAppPort('phpmyadmin');
+ const res = await GetAppPort('redis-commander');
redisCommandPort.value = res.data;
};
diff --git a/frontend/src/views/home/index.vue b/frontend/src/views/home/index.vue
index 239841109..55ff04111 100644
--- a/frontend/src/views/home/index.vue
+++ b/frontend/src/views/home/index.vue
@@ -93,6 +93,8 @@
{{ baseInfo.kernelVersion }}
{{ baseInfo.kernelArch }}
+ {{ baseInfo.uptime }}
+ {{ baseInfo.timeSinceUptime }}
@@ -218,6 +220,8 @@ const baseInfo = ref({
kernelArch: '',
kernelVersion: '',
virtualizationSystem: '',
+ uptime: '',
+ timeSinceUptime: '',
cpuCores: 0,
cpuLogicalCores: 0,
diff --git a/go.mod b/go.mod
index 40cb63512..35dea251f 100644
--- a/go.mod
+++ b/go.mod
@@ -5,6 +5,7 @@ go 1.18
require (
github.com/aliyun/aliyun-oss-go-sdk v2.2.5+incompatible
github.com/aws/aws-sdk-go v1.44.99
+ github.com/cenkalti/backoff/v4 v4.1.3
github.com/compose-spec/compose-go v1.6.0
github.com/dgraph-io/badger/v3 v3.2103.2
github.com/docker/docker v20.10.18+incompatible
@@ -63,7 +64,6 @@ require (
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1755 // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
- github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cloudflare/cloudflare-go v0.49.0 // indirect