Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2df57e6249 | ||
|
|
106d58575b | ||
|
|
bdf36276da | ||
|
|
f32f127dfc | ||
|
|
f78ba281fb | ||
|
|
7f9f9a9129 | ||
|
|
b701efd9b5 | ||
|
|
511f43784e | ||
|
|
3f6112a919 | ||
|
|
23751440c6 | ||
|
|
989c9f9740 | ||
|
|
71508f8724 |
+116
-71
@@ -4,20 +4,125 @@ on:
|
|||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- "v*"
|
- "v*"
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
build:
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix:
|
||||||
|
goos: [linux, windows]
|
||||||
|
goarch: [amd64]
|
||||||
|
include:
|
||||||
|
- goos: linux
|
||||||
|
goarch: s390x
|
||||||
|
- goos: linux
|
||||||
|
goarch: arm64
|
||||||
|
|
||||||
|
name: Build artifacts
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: goreleaser/goreleaser-cross:v1.21
|
||||||
|
env:
|
||||||
|
GOOS: ${{ matrix.goos }}
|
||||||
|
GOARCH: ${{ matrix.goarch }}
|
||||||
|
GOARM: ${{ matrix.goarm }}
|
||||||
|
outputs:
|
||||||
|
tag_name: ${{ steps.extract_branch.outputs.tag }}
|
||||||
steps:
|
steps:
|
||||||
|
- run: git config --global --add safe.directory /__w/nezha/nezha
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Fetch IPInfo GeoIP Database
|
- name: Fetch IPInfo GeoIP Database
|
||||||
|
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
|
||||||
env:
|
env:
|
||||||
IPINFO_TOKEN: ${{ secrets.IPINFO_TOKEN }}
|
IPINFO_TOKEN: ${{ secrets.IPINFO_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
rm pkg/geoip/geoip.db
|
rm pkg/geoip/geoip.db
|
||||||
wget -O pkg/geoip/geoip.db https://ipinfo.io/data/free/country.mmdb?token=${IPINFO_TOKEN}
|
wget -qO pkg/geoip/geoip.db https://ipinfo.io/data/free/country.mmdb?token=${IPINFO_TOKEN}
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: "1.21.x"
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
uses: goreleaser/goreleaser-action@v6
|
||||||
|
with:
|
||||||
|
distribution: goreleaser
|
||||||
|
version: '~> v2'
|
||||||
|
args: build --single-target --clean --skip=validate
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: dashboard-${{ env.GOOS }}-${{ env.GOARCH }}
|
||||||
|
path: |
|
||||||
|
./dist/*/*
|
||||||
|
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
|
||||||
|
needs: build
|
||||||
|
name: Release
|
||||||
|
steps:
|
||||||
|
- name: Download artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: ./assets
|
||||||
|
|
||||||
|
- name: Archive and compress binaries
|
||||||
|
run: |
|
||||||
|
for file in assets/*/*/*; do
|
||||||
|
if [ -f "$file" ]; then
|
||||||
|
chmod +x "$file"
|
||||||
|
zip -jr "$file.zip" "$file"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
uses: ncipollo/release-action@v1
|
||||||
|
with:
|
||||||
|
artifacts: "assets/*/*/*.zip"
|
||||||
|
generateReleaseNotes: true
|
||||||
|
|
||||||
|
- name: Purge jsdelivr cache
|
||||||
|
run: |
|
||||||
|
curl -s https://purge.jsdelivr.net/gh/${{ github.repository_owner }}/nezha@master/script/install.sh
|
||||||
|
curl -s https://purge.jsdelivr.net/gh/${{ github.repository_owner }}/nezha@master/script/nezha-agent.service
|
||||||
|
curl -s https://purge.jsdelivr.net/gh/${{ github.repository_owner }}/nezha@master/script/docker-compose.yaml
|
||||||
|
curl -s https://purge.jsdelivr.net/gh/${{ github.repository_owner }}/nezha@master/script/config.yaml
|
||||||
|
LOWER_USERNAME=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
|
||||||
|
curl -s https://purge.jsdelivr.net/gh/$LOWER_USERNAME/nezha@master/script/install.sh
|
||||||
|
curl -s https://purge.jsdelivr.net/gh/$LOWER_USERNAME/nezha@master/script/nezha-agent.service
|
||||||
|
curl -s https://purge.jsdelivr.net/gh/$LOWER_USERNAME/nezha@master/script/docker-compose.yaml
|
||||||
|
curl -s https://purge.jsdelivr.net/gh/$LOWER_USERNAME/nezha@master/script/config.yaml
|
||||||
|
|
||||||
|
- name: Trigger sync
|
||||||
|
env:
|
||||||
|
GH_REPO: ${{ github.repository }}
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
GH_DEBUG: api
|
||||||
|
run: |
|
||||||
|
gh workflow run sync-release.yml
|
||||||
|
|
||||||
|
release-docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
|
||||||
|
needs: build
|
||||||
|
name: Release Docker images
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Download artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: ./assets
|
||||||
|
|
||||||
|
- name: Fix permissions
|
||||||
|
run: |
|
||||||
|
chmod -R +x ./assets/*
|
||||||
|
mkdir dist
|
||||||
|
mv ./assets/*/*/* ./dist
|
||||||
|
|
||||||
- name: Extract branch name
|
- name: Extract branch name
|
||||||
run: |
|
run: |
|
||||||
@@ -25,33 +130,12 @@ jobs:
|
|||||||
echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT
|
echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT
|
||||||
id: extract_branch
|
id: extract_branch
|
||||||
|
|
||||||
- name: xgo build
|
- name: Log into GHCR
|
||||||
uses: crazy-max/ghaction-xgo@v2
|
|
||||||
with:
|
|
||||||
xgo_version: latest
|
|
||||||
go_version: 1.21.x
|
|
||||||
dest: dist
|
|
||||||
pkg: cmd/dashboard
|
|
||||||
prefix: dashboard
|
|
||||||
targets: linux/amd64,linux/arm64,linux/arm-7,linux/s390x,linux/riscv64,windows/amd64,windows/386,windows/arm64 # linux/386,
|
|
||||||
v: true
|
|
||||||
x: false
|
|
||||||
race: false
|
|
||||||
tags: timetzdata
|
|
||||||
ldflags: -s -w --extldflags '-static -fpic' -X github.com/naiba/nezha/service/singleton.Version=${{ steps.extract_branch.outputs.tag }}
|
|
||||||
buildmode: default
|
|
||||||
|
|
||||||
- name: fix dist
|
|
||||||
run: |
|
|
||||||
ls -al dist/
|
|
||||||
mv dist/dashboard-linux-arm-7 dist/dashboard-linux-arm
|
|
||||||
|
|
||||||
- name: Log in to the GHCR
|
|
||||||
uses: docker/login-action@master
|
uses: docker/login-action@master
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ github.token }}
|
||||||
|
|
||||||
- name: Log in to the AliyunCS
|
- name: Log in to the AliyunCS
|
||||||
uses: docker/login-action@master
|
uses: docker/login-action@master
|
||||||
@@ -68,13 +152,13 @@ jobs:
|
|||||||
|
|
||||||
- name: Set up image name
|
- name: Set up image name
|
||||||
run: |
|
run: |
|
||||||
GHRC_IMAGE_NAME=$(echo "ghcr.io/${{ github.repository_owner }}/nezha-dashboard" | tr '[:upper:]' '[:lower:]')
|
GHCR_IMAGE_NAME=$(echo "ghcr.io/${{ github.repository_owner }}/nezha-dashboard" | tr '[:upper:]' '[:lower:]')
|
||||||
if [ ${{ github.repository_owner }} = "naiba" ]
|
if [ ${{ github.repository_owner }} = "naiba" ]
|
||||||
then ALI_IMAGE_NAME=$(echo "registry.cn-shanghai.aliyuncs.com/naibahq/nezha-dashboard")
|
then ALI_IMAGE_NAME=$(echo "registry.cn-shanghai.aliyuncs.com/naibahq/nezha-dashboard")
|
||||||
else ALI_IMAGE_NAME=$(echo "registry.cn-shanghai.aliyuncs.com/${{ github.repository_owner }}/nezha-dashboard" | tr '[:upper:]' '[:lower:]')
|
else ALI_IMAGE_NAME=$(echo "registry.cn-shanghai.aliyuncs.com/${{ github.repository_owner }}/nezha-dashboard" | tr '[:upper:]' '[:lower:]')
|
||||||
fi
|
fi
|
||||||
echo "::set-output name=GHRC_IMAGE_NAME::$GHRC_IMAGE_NAME"
|
echo "GHCR_IMAGE_NAME=$GHCR_IMAGE_NAME" >> $GITHUB_OUTPUT
|
||||||
echo "::set-output name=ALI_IMAGE_NAME::$ALI_IMAGE_NAME"
|
echo "ALI_IMAGE_NAME=$ALI_IMAGE_NAME" >> $GITHUB_OUTPUT
|
||||||
id: image-name
|
id: image-name
|
||||||
|
|
||||||
- name: Build dasbboard image And Push
|
- name: Build dasbboard image And Push
|
||||||
@@ -82,49 +166,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./Dockerfile
|
file: ./Dockerfile
|
||||||
platforms: linux/amd64,linux/arm64,linux/arm,linux/s390x,linux/riscv64 # linux/386,
|
platforms: linux/amd64,linux/arm64,linux/s390x
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
${{ steps.image-name.outputs.GHRC_IMAGE_NAME }}:latest
|
${{ steps.image-name.outputs.GHCR_IMAGE_NAME }}:latest
|
||||||
${{ steps.image-name.outputs.GHRC_IMAGE_NAME }}:${{ steps.extract_branch.outputs.tag }}
|
${{ steps.image-name.outputs.GHCR_IMAGE_NAME }}:${{ steps.extract_branch.outputs.tag }}
|
||||||
${{ steps.image-name.outputs.ALI_IMAGE_NAME }}:latest
|
${{ steps.image-name.outputs.ALI_IMAGE_NAME }}:latest
|
||||||
${{ steps.image-name.outputs.ALI_IMAGE_NAME }}:${{ steps.extract_branch.outputs.tag }}
|
${{ steps.image-name.outputs.ALI_IMAGE_NAME }}:${{ steps.extract_branch.outputs.tag }}
|
||||||
|
|
||||||
- name: Compress dist files
|
|
||||||
run: |
|
|
||||||
for file in dist/*; do
|
|
||||||
if [ -f "$file" ]; then
|
|
||||||
zip -r "$file.zip" "$file"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
- name: Release
|
|
||||||
uses: ncipollo/release-action@v1
|
|
||||||
with:
|
|
||||||
artifacts: "dist/*.zip"
|
|
||||||
generateReleaseNotes: true
|
|
||||||
|
|
||||||
- name: Purge jsdelivr cache
|
|
||||||
run: |
|
|
||||||
curl -s https://purge.jsdelivr.net/gh/${{ github.repository_owner }}/nezha@master/script/install.sh
|
|
||||||
curl -s https://purge.jsdelivr.net/gh/${{ github.repository_owner }}/nezha@master/script/nezha-agent.service
|
|
||||||
curl -s https://purge.jsdelivr.net/gh/${{ github.repository_owner }}/nezha@master/script/docker-compose.yaml
|
|
||||||
curl -s https://purge.jsdelivr.net/gh/${{ github.repository_owner }}/nezha@master/script/config.yaml
|
|
||||||
LOWER_USERNAME=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
|
|
||||||
curl -s https://purge.jsdelivr.net/gh/$LOWER_USERNAME/nezha@master/script/install.sh
|
|
||||||
curl -s https://purge.jsdelivr.net/gh/$LOWER_USERNAME/nezha@master/script/nezha-agent.service
|
|
||||||
curl -s https://purge.jsdelivr.net/gh/$LOWER_USERNAME/nezha@master/script/docker-compose.yaml
|
|
||||||
curl -s https://purge.jsdelivr.net/gh/$LOWER_USERNAME/nezha@master/script/config.yaml
|
|
||||||
|
|
||||||
- name: Trigger sync
|
|
||||||
if: ${{ env.SYNCED == 0 }}
|
|
||||||
uses: actions/github-script@v6
|
|
||||||
with:
|
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
script: |
|
|
||||||
await github.rest.actions.createWorkflowDispatch({
|
|
||||||
owner: 'naiba',
|
|
||||||
repo: 'nezha',
|
|
||||||
workflow_id: 'sync-release.yml',
|
|
||||||
ref: 'master'
|
|
||||||
})
|
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
name: Run Tests on PR
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
jobs:
|
|
||||||
tests:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
env:
|
|
||||||
GO111MODULE: on
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-go@v4
|
|
||||||
with:
|
|
||||||
go-version: "^1.21.3"
|
|
||||||
- name: Unit test
|
|
||||||
run: |
|
|
||||||
go test -v ./...
|
|
||||||
- name: Run Gosec Security Scanner
|
|
||||||
uses: securego/gosec@master
|
|
||||||
with:
|
|
||||||
args: --exclude=G104,G402 ./...
|
|
||||||
- name: xgo build
|
|
||||||
uses: crazy-max/ghaction-xgo@v2
|
|
||||||
with:
|
|
||||||
xgo_version: latest
|
|
||||||
go_version: 1.21.x
|
|
||||||
dest: dist
|
|
||||||
pkg: cmd/dashboard
|
|
||||||
prefix: dashboard
|
|
||||||
targets: linux/amd64,linux/arm64,linux/arm-7,linux/s390x,linux/riscv64,windows/amd64,windows/386,windows/arm64 # linux/386,
|
|
||||||
v: true
|
|
||||||
x: false
|
|
||||||
race: false
|
|
||||||
tags: timetzdata
|
|
||||||
ldflags: -s -w --extldflags '-static -fpic' -X github.com/naiba/nezha/service/singleton.Version=test
|
|
||||||
buildmode: default
|
|
||||||
- name: fix dist
|
|
||||||
run: |
|
|
||||||
ls -al dist/
|
|
||||||
mv dist/dashboard-linux-arm-7 dist/dashboard-linux-arm
|
|
||||||
|
|
||||||
+18
-22
@@ -10,40 +10,36 @@ on:
|
|||||||
- "go.sum"
|
- "go.sum"
|
||||||
- "resource/**"
|
- "resource/**"
|
||||||
- ".github/workflows/test.yml"
|
- ".github/workflows/test.yml"
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
tests:
|
||||||
runs-on: ubuntu-latest
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu, windows, macos]
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.os }}-latest
|
||||||
env:
|
env:
|
||||||
GO111MODULE: on
|
GO111MODULE: on
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-go@v4
|
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: "^1.21.3"
|
go-version: "1.21.x"
|
||||||
|
|
||||||
- name: Unit test
|
- name: Unit test
|
||||||
run: |
|
run: |
|
||||||
go test -v ./...
|
go test -v ./...
|
||||||
|
|
||||||
|
- name: Build test
|
||||||
|
run: go build -v ./cmd/dashboard
|
||||||
|
|
||||||
- name: Run Gosec Security Scanner
|
- name: Run Gosec Security Scanner
|
||||||
|
if: runner.os == 'Linux'
|
||||||
uses: securego/gosec@master
|
uses: securego/gosec@master
|
||||||
with:
|
with:
|
||||||
args: --exclude=G104,G402 ./...
|
args: --exclude=G104,G402 ./...
|
||||||
- name: xgo build
|
|
||||||
uses: crazy-max/ghaction-xgo@v2
|
|
||||||
with:
|
|
||||||
xgo_version: latest
|
|
||||||
go_version: 1.21.x
|
|
||||||
dest: dist
|
|
||||||
pkg: cmd/dashboard
|
|
||||||
prefix: dashboard
|
|
||||||
targets: linux/amd64,linux/arm64,linux/arm-7,linux/s390x,linux/riscv64,windows/amd64,windows/386,windows/arm64 # linux/386,
|
|
||||||
v: true
|
|
||||||
x: false
|
|
||||||
race: false
|
|
||||||
tags: timetzdata
|
|
||||||
ldflags: -s -w --extldflags '-static -fpic' -X github.com/naiba/nezha/service/singleton.Version=test
|
|
||||||
buildmode: default
|
|
||||||
- name: fix dist
|
|
||||||
run: |
|
|
||||||
ls -al dist/
|
|
||||||
mv dist/dashboard-linux-arm-7 dist/dashboard-linux-arm
|
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
version: 2
|
||||||
|
before:
|
||||||
|
hooks:
|
||||||
|
- go mod tidy -v
|
||||||
|
builds:
|
||||||
|
- id: linux_arm64
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=1
|
||||||
|
- CC=aarch64-linux-gnu-gcc
|
||||||
|
ldflags:
|
||||||
|
- -s -w
|
||||||
|
- -X github.com/naiba/nezha/service/singleton.Version={{.Version}}
|
||||||
|
- -extldflags "-static -fpic"
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
goarch:
|
||||||
|
- arm64
|
||||||
|
main: ./cmd/dashboard
|
||||||
|
binary: dashboard-{{ .Os }}-{{ .Arch }}
|
||||||
|
- id: linux_amd64
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=1
|
||||||
|
- CC=x86_64-linux-gnu-gcc
|
||||||
|
ldflags:
|
||||||
|
- -s -w
|
||||||
|
- -X github.com/naiba/nezha/service/singleton.Version={{.Version}}
|
||||||
|
- -extldflags "-static -fpic"
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
main: ./cmd/dashboard
|
||||||
|
binary: dashboard-{{ .Os }}-{{ .Arch }}
|
||||||
|
- id: linux_s390x
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=1
|
||||||
|
- CC=s390x-linux-gnu-gcc
|
||||||
|
ldflags:
|
||||||
|
- -s -w
|
||||||
|
- -X github.com/naiba/nezha/service/singleton.Version={{.Version}}
|
||||||
|
- -extldflags "-static -fpic"
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
goarch:
|
||||||
|
- s390x
|
||||||
|
main: ./cmd/dashboard
|
||||||
|
binary: dashboard-{{ .Os }}-{{ .Arch }}
|
||||||
|
- id: windows_amd64
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=1
|
||||||
|
- CC=x86_64-w64-mingw32-gcc
|
||||||
|
ldflags:
|
||||||
|
- -s -w
|
||||||
|
- -X github.com/naiba/nezha/service/singleton.Version={{.Version}}
|
||||||
|
- -extldflags "-static -fpic"
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
goos:
|
||||||
|
- windows
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
main: ./cmd/dashboard
|
||||||
|
binary: dashboard-{{ .Os }}-{{ .Arch }}
|
||||||
|
snapshot:
|
||||||
|
version_template: "dashboard"
|
||||||
+7
-9
@@ -1,16 +1,12 @@
|
|||||||
# latest 镜像还没有 riscv64 https://hub.docker.com/_/alpine/tags
|
FROM alpine AS certs
|
||||||
FROM alpine:edge
|
RUN apk update && apk add ca-certificates
|
||||||
|
|
||||||
|
FROM busybox:stable-musl
|
||||||
|
|
||||||
ARG TARGETOS
|
ARG TARGETOS
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
|
|
||||||
RUN apk update && \
|
COPY --from=certs /etc/ssl/certs /etc/ssl/certs
|
||||||
apk upgrade --no-cache && \
|
|
||||||
apk add --no-cache tzdata && \
|
|
||||||
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
|
||||||
echo 'Asia/Shanghai' >/etc/timezone && \
|
|
||||||
rm -rf /var/cache/apk/*
|
|
||||||
|
|
||||||
COPY ./script/entrypoint.sh /entrypoint.sh
|
COPY ./script/entrypoint.sh /entrypoint.sh
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
@@ -19,4 +15,6 @@ COPY dist/dashboard-${TARGETOS}-${TARGETARCH} ./app
|
|||||||
|
|
||||||
VOLUME ["/dashboard/data"]
|
VOLUME ["/dashboard/data"]
|
||||||
EXPOSE 80 5555
|
EXPOSE 80 5555
|
||||||
|
ARG TZ=Asia/Shanghai
|
||||||
|
ENV TZ=$TZ
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
<br>
|
<br>
|
||||||
<small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
|
<small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
|
||||||
<br><br>
|
<br><br>
|
||||||
<img alt="GitHub release (with filter)" src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&style=for-the-badge&logo=github&label=Dashboard"> <img src="https://img.shields.io/github/v/release/nezhahq/agent?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/actions/workflow/status/nezhahq/agent/agent.yml?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.18.3-brightgreen?style=for-the-badge&logo=linux">
|
<img alt="GitHub release (with filter)" src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&style=for-the-badge&logo=github&label=Dashboard"> <img src="https://img.shields.io/github/v/release/nezhahq/agent?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/actions/workflow/status/nezhahq/agent/agent.yml?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.19.0-brightgreen?style=for-the-badge&logo=linux">
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<p>:trollface: <b>Nezha Monitoring: Self-hostable, lightweight, servers and websites monitoring and O&M tool.</b></p>
|
<p>:trollface: <b>Nezha Monitoring: Self-hostable, lightweight, servers and websites monitoring and O&M tool.</b></p>
|
||||||
@@ -44,8 +44,8 @@ You can change the dashboard language in the settings page (`/setting`) after th
|
|||||||
<a href="https://github.com/AkkiaS7" title="Akkia"><img src="https://avatars.githubusercontent.com/u/68485070?v=4" width="50;" alt="Akkia"/></a>
|
<a href="https://github.com/AkkiaS7" title="Akkia"><img src="https://avatars.githubusercontent.com/u/68485070?v=4" width="50;" alt="Akkia"/></a>
|
||||||
<a href="https://github.com/Erope" title="卖女孩的小火柴"><img src="https://avatars.githubusercontent.com/u/44471469?v=4" width="50;" alt="卖女孩的小火柴"/></a>
|
<a href="https://github.com/Erope" title="卖女孩的小火柴"><img src="https://avatars.githubusercontent.com/u/44471469?v=4" width="50;" alt="卖女孩的小火柴"/></a>
|
||||||
<a href="https://github.com/uubulb" title="UUBulb"><img src="https://avatars.githubusercontent.com/u/35923940?v=4" width="50;" alt="UUBulb"/></a>
|
<a href="https://github.com/uubulb" title="UUBulb"><img src="https://avatars.githubusercontent.com/u/35923940?v=4" width="50;" alt="UUBulb"/></a>
|
||||||
<a href="https://github.com/dysf888" title="黑歌"><img src="https://avatars.githubusercontent.com/u/47450409?v=4" width="50;" alt="黑歌"/></a>
|
|
||||||
<a href="https://github.com/nap0o" title="nap0o"><img src="https://avatars.githubusercontent.com/u/144927971?v=4" width="50;" alt="nap0o"/></a>
|
<a href="https://github.com/nap0o" title="nap0o"><img src="https://avatars.githubusercontent.com/u/144927971?v=4" width="50;" alt="nap0o"/></a>
|
||||||
|
<a href="https://github.com/dysf888" title="黑歌"><img src="https://avatars.githubusercontent.com/u/47450409?v=4" width="50;" alt="黑歌"/></a>
|
||||||
<a href="https://github.com/xykt" title="xykt"><img src="https://avatars.githubusercontent.com/u/152045469?v=4" width="50;" alt="xykt"/></a>
|
<a href="https://github.com/xykt" title="xykt"><img src="https://avatars.githubusercontent.com/u/152045469?v=4" width="50;" alt="xykt"/></a>
|
||||||
<a href="https://github.com/MikoyChinese" title="MikoyChinese"><img src="https://avatars.githubusercontent.com/u/22676744?v=4" width="50;" alt="MikoyChinese"/></a>
|
<a href="https://github.com/MikoyChinese" title="MikoyChinese"><img src="https://avatars.githubusercontent.com/u/22676744?v=4" width="50;" alt="MikoyChinese"/></a>
|
||||||
<a href="https://github.com/JackieSung4ev" title="JackieSung4ev"><img src="https://avatars.githubusercontent.com/u/24974735?v=4" width="50;" alt="JackieSung4ev"/></a>
|
<a href="https://github.com/JackieSung4ev" title="JackieSung4ev"><img src="https://avatars.githubusercontent.com/u/24974735?v=4" width="50;" alt="JackieSung4ev"/></a>
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ func (cp *commonPage) network(c *gin.Context) {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cp *commonPage) getServerStat(c *gin.Context) ([]byte, error) {
|
func (cp *commonPage) getServerStat(c *gin.Context, withPublicNote bool) ([]byte, error) {
|
||||||
_, isMember := c.Get(model.CtxKeyAuthorizedUser)
|
_, isMember := c.Get(model.CtxKeyAuthorizedUser)
|
||||||
_, isViewPasswordVerfied := c.Get(model.CtxKeyViewPasswordVerified)
|
_, isViewPasswordVerfied := c.Get(model.CtxKeyViewPasswordVerified)
|
||||||
authorized := isMember || isViewPasswordVerfied
|
authorized := isMember || isViewPasswordVerfied
|
||||||
@@ -217,18 +217,20 @@ func (cp *commonPage) getServerStat(c *gin.Context) ([]byte, error) {
|
|||||||
singleton.SortedServerLock.RLock()
|
singleton.SortedServerLock.RLock()
|
||||||
defer singleton.SortedServerLock.RUnlock()
|
defer singleton.SortedServerLock.RUnlock()
|
||||||
|
|
||||||
var servers []*model.Server
|
var serverList []*model.Server
|
||||||
|
|
||||||
if authorized {
|
if authorized {
|
||||||
servers = singleton.SortedServerList
|
serverList = singleton.SortedServerList
|
||||||
} else {
|
} else {
|
||||||
filteredServers := make([]*model.Server, len(singleton.SortedServerListForGuest))
|
serverList = singleton.SortedServerListForGuest
|
||||||
for i, server := range singleton.SortedServerListForGuest {
|
}
|
||||||
filteredServer := *server
|
|
||||||
filteredServer.DDNSDomain = "redacted"
|
var servers []*model.Server
|
||||||
filteredServers[i] = &filteredServer
|
for _, server := range serverList {
|
||||||
|
item := *server
|
||||||
|
if !withPublicNote {
|
||||||
|
item.PublicNote = ""
|
||||||
}
|
}
|
||||||
servers = filteredServers
|
servers = append(servers, &item)
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.Json.Marshal(Data{
|
return utils.Json.Marshal(Data{
|
||||||
@@ -240,7 +242,7 @@ func (cp *commonPage) getServerStat(c *gin.Context) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cp *commonPage) home(c *gin.Context) {
|
func (cp *commonPage) home(c *gin.Context) {
|
||||||
stat, err := cp.getServerStat(c)
|
stat, err := cp.getServerStat(c, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
mygin.ShowErrorPage(c, mygin.ErrInfo{
|
mygin.ShowErrorPage(c, mygin.ErrInfo{
|
||||||
Code: http.StatusInternalServerError,
|
Code: http.StatusInternalServerError,
|
||||||
@@ -285,7 +287,7 @@ func (cp *commonPage) ws(c *gin.Context) {
|
|||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
count := 0
|
count := 0
|
||||||
for {
|
for {
|
||||||
stat, err := cp.getServerStat(c)
|
stat, err := cp.getServerStat(c, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -306,6 +306,7 @@ type serverForm struct {
|
|||||||
Secret string
|
Secret string
|
||||||
Tag string
|
Tag string
|
||||||
Note string
|
Note string
|
||||||
|
PublicNote string
|
||||||
HideForGuest string
|
HideForGuest string
|
||||||
EnableDDNS string
|
EnableDDNS string
|
||||||
EnableIPv4 string
|
EnableIPv4 string
|
||||||
@@ -326,6 +327,7 @@ func (ma *memberAPI) addOrEditServer(c *gin.Context) {
|
|||||||
s.ID = sf.ID
|
s.ID = sf.ID
|
||||||
s.Tag = sf.Tag
|
s.Tag = sf.Tag
|
||||||
s.Note = sf.Note
|
s.Note = sf.Note
|
||||||
|
s.PublicNote = sf.PublicNote
|
||||||
s.HideForGuest = sf.HideForGuest == "on"
|
s.HideForGuest = sf.HideForGuest == "on"
|
||||||
s.EnableDDNS = sf.EnableDDNS == "on"
|
s.EnableDDNS = sf.EnableDDNS == "on"
|
||||||
s.EnableIPv4 = sf.EnableIPv4 == "on"
|
s.EnableIPv4 = sf.EnableIPv4 == "on"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
_ "time/tzdata"
|
||||||
|
|
||||||
"github.com/naiba/nezha/cmd/dashboard/controller"
|
"github.com/naiba/nezha/cmd/dashboard/controller"
|
||||||
"github.com/naiba/nezha/cmd/dashboard/rpc"
|
"github.com/naiba/nezha/cmd/dashboard/rpc"
|
||||||
|
|||||||
+5
-3
@@ -15,7 +15,8 @@ type Server struct {
|
|||||||
Name string
|
Name string
|
||||||
Tag string // 分组名
|
Tag string // 分组名
|
||||||
Secret string `gorm:"uniqueIndex" json:"-"`
|
Secret string `gorm:"uniqueIndex" json:"-"`
|
||||||
Note string `json:"-"` // 管理员可见备注
|
Note string `json:"-"` // 管理员可见备注
|
||||||
|
PublicNote string `json:"PublicNote,omitempty"` // 公开备注
|
||||||
DisplayIndex int // 展示排序,越大越靠前
|
DisplayIndex int // 展示排序,越大越靠前
|
||||||
HideForGuest bool // 对游客隐藏
|
HideForGuest bool // 对游客隐藏
|
||||||
EnableDDNS bool `json:"-"` // 是否启用DDNS 未在配置文件中启用DDNS 或 DDNS检查时间为0时此项无效
|
EnableDDNS bool `json:"-"` // 是否启用DDNS 未在配置文件中启用DDNS 或 DDNS检查时间为0时此项无效
|
||||||
@@ -54,12 +55,13 @@ func boolToString(b bool) string {
|
|||||||
return "false"
|
return "false"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Server) Marshal() template.JS {
|
func (s Server) MarshalForDashboard() template.JS {
|
||||||
name, _ := utils.Json.Marshal(s.Name)
|
name, _ := utils.Json.Marshal(s.Name)
|
||||||
tag, _ := utils.Json.Marshal(s.Tag)
|
tag, _ := utils.Json.Marshal(s.Tag)
|
||||||
note, _ := utils.Json.Marshal(s.Note)
|
note, _ := utils.Json.Marshal(s.Note)
|
||||||
secret, _ := utils.Json.Marshal(s.Secret)
|
secret, _ := utils.Json.Marshal(s.Secret)
|
||||||
ddnsDomain, _ := utils.Json.Marshal(s.DDNSDomain)
|
ddnsDomain, _ := utils.Json.Marshal(s.DDNSDomain)
|
||||||
ddnsProfile, _ := utils.Json.Marshal(s.DDNSProfile)
|
ddnsProfile, _ := utils.Json.Marshal(s.DDNSProfile)
|
||||||
return template.JS(fmt.Sprintf(`{"ID":%d,"Name":%s,"Secret":%s,"DisplayIndex":%d,"Tag":%s,"Note":%s,"HideForGuest": %s,"EnableDDNS": %s,"EnableIPv4": %s,"EnableIpv6": %s,"DDNSDomain": %s,"DDNSProfile": %s}`, s.ID, name, secret, s.DisplayIndex, tag, note, boolToString(s.HideForGuest), boolToString(s.EnableDDNS), boolToString(s.EnableIPv4), boolToString(s.EnableIpv6), ddnsDomain, ddnsProfile)) // #nosec
|
publicNote, _ := utils.Json.Marshal(s.PublicNote)
|
||||||
|
return template.JS(fmt.Sprintf(`{"ID":%d,"Name":%s,"Secret":%s,"DisplayIndex":%d,"Tag":%s,"Note":%s,"HideForGuest": %s,"EnableDDNS": %s,"EnableIPv4": %s,"EnableIpv6": %s,"DDNSDomain": %s,"DDNSProfile": %s,"PublicNote": %s}`, s.ID, name, secret, s.DisplayIndex, tag, note, boolToString(s.HideForGuest), boolToString(s.EnableDDNS), boolToString(s.EnableIPv4), boolToString(s.EnableIpv6), ddnsDomain, ddnsProfile, publicNote))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ func TestServerMarshal(t *testing.T) {
|
|||||||
Name: patterns[i],
|
Name: patterns[i],
|
||||||
Tag: patterns[i],
|
Tag: patterns[i],
|
||||||
}
|
}
|
||||||
serverStr := string(server.Marshal())
|
serverStr := string(server.MarshalForDashboard())
|
||||||
var serverRestore Server
|
var serverRestore Server
|
||||||
if utils.Json.Unmarshal([]byte(serverStr), &serverRestore) != nil {
|
if utils.Json.Unmarshal([]byte(serverStr), &serverRestore) != nil {
|
||||||
t.Fatalf("Error: %s", serverStr)
|
t.Fatalf("Error: %s", serverStr)
|
||||||
|
|||||||
Vendored
+12
@@ -226,6 +226,9 @@ other = "Secret"
|
|||||||
[Note]
|
[Note]
|
||||||
other = "Note"
|
other = "Note"
|
||||||
|
|
||||||
|
[PublicNote]
|
||||||
|
other = "Public Note"
|
||||||
|
|
||||||
[LinuxOneKeyInstall]
|
[LinuxOneKeyInstall]
|
||||||
other = "Linux One-Command Install"
|
other = "Linux One-Command Install"
|
||||||
|
|
||||||
@@ -655,6 +658,15 @@ other = "Servers On World Map"
|
|||||||
[NAT]
|
[NAT]
|
||||||
other = "NAT Traversal"
|
other = "NAT Traversal"
|
||||||
|
|
||||||
|
[LocalService]
|
||||||
|
other = "Local service"
|
||||||
|
|
||||||
|
[LocalServicePlaceholder]
|
||||||
|
other = "192.168.1.1:80 (with port)"
|
||||||
|
|
||||||
|
[BindHostname]
|
||||||
|
other = "Bind hostname"
|
||||||
|
|
||||||
[NetworkSpiterList]
|
[NetworkSpiterList]
|
||||||
other = "Network Monitor"
|
other = "Network Monitor"
|
||||||
|
|
||||||
|
|||||||
Vendored
+12
@@ -226,6 +226,9 @@ other = "Secreto"
|
|||||||
[Note]
|
[Note]
|
||||||
other = "Nota"
|
other = "Nota"
|
||||||
|
|
||||||
|
[PublicNote]
|
||||||
|
other = "Nota Pública"
|
||||||
|
|
||||||
[LinuxOneKeyInstall]
|
[LinuxOneKeyInstall]
|
||||||
other = "Instalación Linux con Un Solo Clic"
|
other = "Instalación Linux con Un Solo Clic"
|
||||||
|
|
||||||
@@ -655,6 +658,15 @@ other = "Servidores en el mapa mundial"
|
|||||||
[NAT]
|
[NAT]
|
||||||
other = "NAT traversal"
|
other = "NAT traversal"
|
||||||
|
|
||||||
|
[LocalService]
|
||||||
|
other = "Servicio de red local"
|
||||||
|
|
||||||
|
[LocalServicePlaceholder]
|
||||||
|
other = "192.168.1.1:80 (con puerto)"
|
||||||
|
|
||||||
|
[BindHostname]
|
||||||
|
other = "Vincular nombre de host"
|
||||||
|
|
||||||
[NetworkSpiterList]
|
[NetworkSpiterList]
|
||||||
other = "Monitor de red"
|
other = "Monitor de red"
|
||||||
|
|
||||||
|
|||||||
Vendored
+12
@@ -226,6 +226,9 @@ other = "密钥"
|
|||||||
[Note]
|
[Note]
|
||||||
other = "备注"
|
other = "备注"
|
||||||
|
|
||||||
|
[PublicNote]
|
||||||
|
other = "公开备注"
|
||||||
|
|
||||||
[LinuxOneKeyInstall]
|
[LinuxOneKeyInstall]
|
||||||
other = "Linux 一键安装"
|
other = "Linux 一键安装"
|
||||||
|
|
||||||
@@ -655,6 +658,15 @@ other = "服务器世界分布图"
|
|||||||
[NAT]
|
[NAT]
|
||||||
other = "内网穿透"
|
other = "内网穿透"
|
||||||
|
|
||||||
|
[LocalService]
|
||||||
|
other = "内网服务"
|
||||||
|
|
||||||
|
[LocalServicePlaceholder]
|
||||||
|
other = "192.168.1.1:80(带端口)"
|
||||||
|
|
||||||
|
[BindHostname]
|
||||||
|
other = "绑定域名"
|
||||||
|
|
||||||
[NetworkSpiterList]
|
[NetworkSpiterList]
|
||||||
other = "网络监控"
|
other = "网络监控"
|
||||||
|
|
||||||
|
|||||||
Vendored
+13
-1
@@ -226,6 +226,9 @@ other = "金鑰"
|
|||||||
[Note]
|
[Note]
|
||||||
other = "備註"
|
other = "備註"
|
||||||
|
|
||||||
|
[PublicNote]
|
||||||
|
other = "公開備註"
|
||||||
|
|
||||||
[LinuxOneKeyInstall]
|
[LinuxOneKeyInstall]
|
||||||
other = "Linux 一鍵安裝"
|
other = "Linux 一鍵安裝"
|
||||||
|
|
||||||
@@ -653,7 +656,16 @@ other = "禁止前台切換主題"
|
|||||||
other = "伺服器世界分布圖"
|
other = "伺服器世界分布圖"
|
||||||
|
|
||||||
[NAT]
|
[NAT]
|
||||||
other = "NAT"
|
other = "NAT穿透"
|
||||||
|
|
||||||
|
[LocalService]
|
||||||
|
other = "內網服務"
|
||||||
|
|
||||||
|
[LocalServicePlaceholder]
|
||||||
|
other = "192.168.1.1:80(帶埠號)"
|
||||||
|
|
||||||
|
[BindHostname]
|
||||||
|
other = "綁定網域"
|
||||||
|
|
||||||
[NetworkSpiterList]
|
[NetworkSpiterList]
|
||||||
other = "網路監控"
|
other = "網路監控"
|
||||||
|
|||||||
@@ -331,6 +331,7 @@ function addOrEditServer(server, conf) {
|
|||||||
.find("input[name=DisplayIndex]")
|
.find("input[name=DisplayIndex]")
|
||||||
.val(server ? server.DisplayIndex : null);
|
.val(server ? server.DisplayIndex : null);
|
||||||
modal.find("textarea[name=Note]").val(server ? server.Note : null);
|
modal.find("textarea[name=Note]").val(server ? server.Note : null);
|
||||||
|
modal.find("textarea[name=PublicNote]").val(server ? server.PublicNote : null);
|
||||||
if (server) {
|
if (server) {
|
||||||
modal.find(".secret.field").attr("style", "");
|
modal.find(".secret.field").attr("style", "");
|
||||||
modal.find(".command.field").attr("style", "");
|
modal.find(".command.field").attr("style", "");
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"name": "Nezha",
|
||||||
|
"short_name": "Nezha",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "/static/manifest-192x192.png",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "any"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/static/manifest-192x192.png",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "maskable"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/static/manifest-512x512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "any"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/static/manifest-512x512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "maskable"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"start_url": "/",
|
||||||
|
"display": "standalone",
|
||||||
|
"theme_color": "#000000",
|
||||||
|
"background_color": "#000000",
|
||||||
|
"lang": "eu-US",
|
||||||
|
"dir": "auto"
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"name": "哪吒监控",
|
||||||
|
"short_name": "哪吒监控",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "/static/manifest-192x192.png",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "any"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/static/manifest-192x192.png",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "maskable"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/static/manifest-512x512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "any"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/static/manifest-512x512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "maskable"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"start_url": "/",
|
||||||
|
"display": "standalone",
|
||||||
|
"theme_color": "#000000",
|
||||||
|
"background_color": "#000000",
|
||||||
|
"lang": "zh-CN",
|
||||||
|
"dir": "auto"
|
||||||
|
}
|
||||||
+11
@@ -13,7 +13,18 @@ const mixinsVue = {
|
|||||||
this.isMobile = this.checkIsMobile();
|
this.isMobile = this.checkIsMobile();
|
||||||
this.preferredTemplate = this.getCookie('preferred_theme') ? this.getCookie('preferred_theme') : this.$root.defaultTemplate;
|
this.preferredTemplate = this.getCookie('preferred_theme') ? this.getCookie('preferred_theme') : this.$root.defaultTemplate;
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
this.initDropdown();
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
initDropdown() {
|
||||||
|
if(this.isMobile) $('.ui.dropdown').dropdown({
|
||||||
|
action: 'hide',
|
||||||
|
on: 'click',
|
||||||
|
duration: 100,
|
||||||
|
direction: 'direction'
|
||||||
|
});
|
||||||
|
},
|
||||||
toggleTemplate(template) {
|
toggleTemplate(template) {
|
||||||
if( template != this.preferredTemplate){
|
if( template != this.preferredTemplate){
|
||||||
this.preferredTemplate = template;
|
this.preferredTemplate = template;
|
||||||
|
|||||||
+7
-1
@@ -381,6 +381,7 @@ td.ping-network-quality {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.network-box .chartTitle {
|
.network-box .chartTitle {
|
||||||
|
cursor: pointer;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
margin: 18px 0px 15px 0px;
|
margin: 18px 0px 15px 0px;
|
||||||
@@ -480,7 +481,12 @@ footer p{
|
|||||||
padding-top:60px !important;
|
padding-top:60px !important;
|
||||||
}
|
}
|
||||||
.nezha {
|
.nezha {
|
||||||
min-height: calc(74.5vh);
|
min-height: calc(100vh - 90px);
|
||||||
|
min-height: calc(var(--vh, 1vh) * 100 - 90px);
|
||||||
|
}
|
||||||
|
#chartbox {
|
||||||
|
min-height: calc(100vh - 170px);
|
||||||
|
min-height: calc(var(--vh, 1vh) * 100 - 170px);
|
||||||
}
|
}
|
||||||
.content {
|
.content {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|||||||
@@ -26,7 +26,9 @@ const mixinsVue = {
|
|||||||
this.semiTransparent = this.initSemiTransparent();
|
this.semiTransparent = this.initSemiTransparent();
|
||||||
this.preferredTemplate = this.getCookie('preferred_theme') ? this.getCookie('preferred_theme') : this.$root.defaultTemplate;
|
this.preferredTemplate = this.getCookie('preferred_theme') ? this.getCookie('preferred_theme') : this.$root.defaultTemplate;
|
||||||
this.colors = this.theme == "dark" ? this.colorsDark : this.colorsLight;
|
this.colors = this.theme == "dark" ? this.colorsDark : this.colorsLight;
|
||||||
|
this.setBenchmarkHeight();
|
||||||
window.addEventListener('scroll', this.handleScroll);
|
window.addEventListener('scroll', this.handleScroll);
|
||||||
|
window.addEventListener('resize', this.setBenchmarkHeight());
|
||||||
},
|
},
|
||||||
destroyed() {
|
destroyed() {
|
||||||
window.removeEventListener('scroll', this.handleScroll);
|
window.removeEventListener('scroll', this.handleScroll);
|
||||||
@@ -152,6 +154,10 @@ const mixinsVue = {
|
|||||||
},
|
},
|
||||||
checkIsMobile() { // 检测设备类型,页面宽度小于768px认为是移动设备
|
checkIsMobile() { // 检测设备类型,页面宽度小于768px认为是移动设备
|
||||||
return window.innerWidth <= 768;
|
return window.innerWidth <= 768;
|
||||||
|
},
|
||||||
|
setBenchmarkHeight() {
|
||||||
|
let vh = window.innerHeight * 0.01;
|
||||||
|
document.documentElement.style.setProperty('--vh', `${vh}px`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Vendored
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
<script src="https://unpkg.com/[email protected]/dist/semantic.min.js"></script>
|
<script src="https://unpkg.com/[email protected]/dist/semantic.min.js"></script>
|
||||||
<script src="/static/semantic-ui-alerts.min.js"></script>
|
<script src="/static/semantic-ui-alerts.min.js"></script>
|
||||||
<script src="https://unpkg.com/[email protected]/dist/vue.min.js"></script>
|
<script src="https://unpkg.com/[email protected]/dist/vue.min.js"></script>
|
||||||
<script src="/static/main.js?v20240714"></script>
|
<script src="/static/main.js?v2024927"></script>
|
||||||
<script>
|
<script>
|
||||||
(function () {
|
(function () {
|
||||||
updateLang({{.LANG }});
|
updateLang({{.LANG }});
|
||||||
|
|||||||
Vendored
+3
-3
@@ -13,11 +13,11 @@
|
|||||||
<input type="number" name="ServerID" placeholder="1">
|
<input type="number" name="ServerID" placeholder="1">
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>内网服务</label>
|
<label>{{tr "LocalService"}}</label>
|
||||||
<input type="text" name="Host" placeholder="192.168.1.1:80(带端口)">
|
<input type="text" name="Host" placeholder="{{tr "LocalServicePlaceholder"}}">
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>绑定域名</label>
|
<label>{{tr "BindHostname"}}</label>
|
||||||
<input type="text" name="Domain" placeholder="router.app.yourdomain.com">
|
<input type="text" name="Domain" placeholder="router.app.yourdomain.com">
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
+4
@@ -56,6 +56,10 @@
|
|||||||
<label>{{tr "Note"}}</label>
|
<label>{{tr "Note"}}</label>
|
||||||
<textarea name="Note"></textarea>
|
<textarea name="Note"></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label>{{tr "PublicNote"}}</label>
|
||||||
|
<textarea name="PublicNote"></textarea>
|
||||||
|
</div>
|
||||||
<div class="command field">
|
<div class="command field">
|
||||||
<label>{{tr "LinuxOneKeyInstall"}}</label>
|
<label>{{tr "LinuxOneKeyInstall"}}</label>
|
||||||
<div class="ui message">
|
<div class="ui message">
|
||||||
|
|||||||
+2
-1
@@ -221,7 +221,7 @@
|
|||||||
|
|
||||||
const checkCompletion = setInterval(() => {
|
const checkCompletion = setInterval(() => {
|
||||||
if (isUpCompleted) {
|
if (isUpCompleted) {
|
||||||
clearInterval(checkCompletion); // 任务完成后停止检查
|
clearInterval(checkCompletion);
|
||||||
hideUpdModal();
|
hideUpdModal();
|
||||||
resetUpdState();
|
resetUpdState();
|
||||||
listFile();
|
listFile();
|
||||||
@@ -480,6 +480,7 @@
|
|||||||
const file = event.target.files[0];
|
const file = event.target.files[0];
|
||||||
if (file) {
|
if (file) {
|
||||||
await uploadFile(file);
|
await uploadFile(file);
|
||||||
|
isUpCompleted = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -16,8 +16,8 @@
|
|||||||
<th>ID</th>
|
<th>ID</th>
|
||||||
<th>{{tr "Name"}}</th>
|
<th>{{tr "Name"}}</th>
|
||||||
<th>Agent ID</th>
|
<th>Agent ID</th>
|
||||||
<th>内网服务</th>
|
<th>{{tr "LocalService"}}</th>
|
||||||
<th>绑定域名</th>
|
<th>{{tr "BindHostname"}}</th>
|
||||||
<th>{{tr "Administration"}}</th>
|
<th>{{tr "Administration"}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|||||||
+3
-1
@@ -36,6 +36,7 @@
|
|||||||
<th>{{tr "Secret"}}</th>
|
<th>{{tr "Secret"}}</th>
|
||||||
<th>{{tr "OneKeyInstall"}}</th>
|
<th>{{tr "OneKeyInstall"}}</th>
|
||||||
<th>{{tr "Note"}}</th>
|
<th>{{tr "Note"}}</th>
|
||||||
|
<th>{{tr "PublicNote"}}</th>
|
||||||
<th>{{tr "Administration"}}</th>
|
<th>{{tr "Administration"}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -76,12 +77,13 @@
|
|||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
<td style="word-break: break-word;white-space: pre-wrap;">{{$server.Note}}</td>
|
<td style="word-break: break-word;white-space: pre-wrap;">{{$server.Note}}</td>
|
||||||
|
<td style="word-break: break-word;white-space: pre-wrap;">{{$server.PublicNote}}</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="ui mini icon buttons">
|
<div class="ui mini icon buttons">
|
||||||
<button class="ui button" onclick="connectToServer({{$server.ID}})">
|
<button class="ui button" onclick="connectToServer({{$server.ID}})">
|
||||||
<i class="terminal icon"></i>
|
<i class="terminal icon"></i>
|
||||||
</button>
|
</button>
|
||||||
<button class="ui button" onclick="addOrEditServer({{$server.Marshal}})">
|
<button class="ui button" onclick="addOrEditServer({{$server.MarshalForDashboard}})">
|
||||||
<i class="edit icon"></i>
|
<i class="edit icon"></i>
|
||||||
</button>
|
</button>
|
||||||
<button class="ui button"
|
<button class="ui button"
|
||||||
|
|||||||
+16
-15
@@ -261,22 +261,23 @@
|
|||||||
const x = readableBytes(bs)
|
const x = readableBytes(bs)
|
||||||
return x != "NaN undefined" ? x : '0B'
|
return x != "NaN undefined" ? x : '0B'
|
||||||
},
|
},
|
||||||
getCoreAndGHz(str){
|
getCoreAndGHz(arr) {
|
||||||
if((str || []).hasOwnProperty(0) === false){
|
if ((arr || []).length === 0) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
str = str[0];
|
let totalCores = 0;
|
||||||
let GHz = str.match(/(\d|\.)+GHz/g);
|
arr.forEach(str => {
|
||||||
let Core = str.match(/(\d|\.)+ Physical/g);
|
let coreMatch = str.match(/(\d+(\.\d+)?) Physical/g);
|
||||||
GHz = GHz!==null?GHz.hasOwnProperty(0)===false?'':GHz[0]:''
|
let coreCount = 0;
|
||||||
Core = Core!==null?Core.hasOwnProperty(0)===false?'?':Core[0]:'?'
|
if (coreMatch) {
|
||||||
if(Core === '?'){
|
coreCount = parseFloat(coreMatch[0]);
|
||||||
let Core = str.match(/(\d|\.)+ Virtual/g);
|
} else {
|
||||||
Core = Core!==null?Core.hasOwnProperty(0)===false?'?':Core[0]:'?'
|
let coreMatch = str.match(/(\d+(\.\d+)?) Virtual/g);
|
||||||
return Core.replace('Virtual','Core')
|
coreCount = coreMatch ? parseFloat(coreMatch[0]) : 0;
|
||||||
}
|
}
|
||||||
return Core.replace('Physical','Core');
|
totalCores += coreCount;
|
||||||
|
});
|
||||||
|
return `${totalCores} Cores`;
|
||||||
},
|
},
|
||||||
getByteToGB(bs){
|
getByteToGB(bs){
|
||||||
return (bs/1024/1024/1024).toFixed(2) + 'GB'
|
return (bs/1024/1024/1024).toFixed(2) + 'GB'
|
||||||
|
|||||||
+14
-5
@@ -3,12 +3,21 @@
|
|||||||
<html lang="{{.Conf.Language}}">
|
<html lang="{{.Conf.Language}}">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<title>{{ .Title }}</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
<meta content="telephone=no" name="format-detection">
|
<meta content="telephone=no" name="format-detection">
|
||||||
<title>{{.Title}}</title>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="shortcut icon" type="image/png" href="/static/logo.svg" />
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||||
|
<meta name="mobile-web-app-capable" content="yes" />
|
||||||
|
<meta name="theme-color" content="#000000" />
|
||||||
|
{{ if eq .Conf.Language "zh-CN" }}
|
||||||
|
<link rel="manifest" href="/static/manifest-zh-CN.json?v20240905" />
|
||||||
|
{{ else }}
|
||||||
|
<link rel="manifest" href="/static/manifest-en-US.json?v20240905" />
|
||||||
|
{{ end }}
|
||||||
|
<link rel="apple-touch-startup-image" href="/static/logo.svg" />
|
||||||
|
<link rel="shortcut icon" type="image/png" href="/static/logo.svg">
|
||||||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/semantic.min.css">
|
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/semantic.min.css">
|
||||||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/assets/font-logos.css">
|
<link rel="stylesheet" href="https://unpkg.com/[email protected]/assets/font-logos.css">
|
||||||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/font/bootstrap-icons.min.css">
|
<link rel="stylesheet" href="https://unpkg.com/[email protected]/font/bootstrap-icons.min.css">
|
||||||
@@ -21,7 +30,7 @@
|
|||||||
<script src="https://unpkg.com/[email protected]/dist/vue.min.js"></script>
|
<script src="https://unpkg.com/[email protected]/dist/vue.min.js"></script>
|
||||||
<script src="https://unpkg.com/[email protected]/dist/echarts.min.js"></script>
|
<script src="https://unpkg.com/[email protected]/dist/echarts.min.js"></script>
|
||||||
<script src="/static/semantic-ui-alerts.min.js"></script>
|
<script src="/static/semantic-ui-alerts.min.js"></script>
|
||||||
<script src="/static/theme-default/js/mixin.js?v20240302"></script>
|
<script src="/static/theme-default/js/mixin.js?v20240911"></script>
|
||||||
<script>
|
<script>
|
||||||
document.documentElement.setAttribute('nz-theme', window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
|
document.documentElement.setAttribute('nz-theme', window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
+16
-14
@@ -194,7 +194,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
mixins: [mixinsVue],
|
mixins: [mixinsVue],
|
||||||
created() {
|
created() {
|
||||||
this.servers = JSON.parse('{{.Servers}}').servers;
|
this.servers = JSON.parse('{{.Servers}}').servers;
|
||||||
this.group()
|
this.group()
|
||||||
},
|
},
|
||||||
@@ -474,21 +474,23 @@
|
|||||||
const sizes = ["B", "K", "M", "G", "T", "P", "E", "Z", "Y"];
|
const sizes = ["B", "K", "M", "G", "T", "P", "E", "Z", "Y"];
|
||||||
return parseFloat((bytes / Math.pow(1024, i)).toFixed(2)) + sizes[i];
|
return parseFloat((bytes / Math.pow(1024, i)).toFixed(2)) + sizes[i];
|
||||||
},
|
},
|
||||||
getCoreAndGHz(str){
|
getCoreAndGHz(arr) {
|
||||||
if ((str || []).hasOwnProperty(0) === false) {
|
if ((arr || []).length === 0) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
str = str[0];
|
let totalCores = 0;
|
||||||
let GHz = str.match(/(\d|\.)+GHz/g);
|
arr.forEach(str => {
|
||||||
let Core = str.match(/(\d|\.)+ Physical/g);
|
let coreMatch = str.match(/(\d+(\.\d+)?) Physical/g);
|
||||||
GHz = GHz !== null ? GHz.hasOwnProperty(0) === false ? '' : GHz[0] : ''
|
let coreCount = 0;
|
||||||
Core = Core !== null ? Core.hasOwnProperty(0) === false ? '?' : Core[0] : '?'
|
if (coreMatch) {
|
||||||
if (Core === '?') {
|
coreCount = parseFloat(coreMatch[0]);
|
||||||
let Core = str.match(/(\d|\.)+ Virtual/g);
|
} else {
|
||||||
Core = Core !== null ? Core.hasOwnProperty(0) === false ? '?' : Core[0] : '?'
|
let coreMatch = str.match(/(\d+(\.\d+)?) Virtual/g);
|
||||||
return Core.replace('Virtual', 'Core')
|
coreCount = coreMatch ? parseFloat(coreMatch[0]) : 0;
|
||||||
}
|
}
|
||||||
return Core.replace('Physical', 'Core');
|
totalCores += coreCount;
|
||||||
|
});
|
||||||
|
return `${totalCores} Cores`;
|
||||||
},
|
},
|
||||||
getK2Gb(bs){
|
getK2Gb(bs){
|
||||||
bs = bs / 1024 / 1024 / 1024;
|
bs = bs / 1024 / 1024 / 1024;
|
||||||
|
|||||||
+2
-2
@@ -7,7 +7,7 @@
|
|||||||
</a>
|
</a>
|
||||||
<a class='item' href="/"><i class="home icon"></i>{{tr "Home"}}</a>
|
<a class='item' href="/"><i class="home icon"></i>{{tr "Home"}}</a>
|
||||||
<template v-if="isMobile">
|
<template v-if="isMobile">
|
||||||
<div class="item ui simple dropdown">
|
<div class="item ui dropdown" :class="{ simple: !isMobile }">
|
||||||
<div class="text"><i class="bi bi-gear-wide-connected icon" style="margin-right:3px;"></i>{{tr "Feature" }}<i class="dropdown icon" style="margin-right:0px;"></i></div>
|
<div class="text"><i class="bi bi-gear-wide-connected icon" style="margin-right:3px;"></i>{{tr "Feature" }}<i class="dropdown icon" style="margin-right:0px;"></i></div>
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
<a href="/service" class="item"><i class="rss icon"></i>{{tr "Services" }}</a>
|
<a href="/service" class="item"><i class="rss icon"></i>{{tr "Services" }}</a>
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<a href="/network" class="item"><i class="bi bi-hdd-network icon"></i>{{tr "NetworkSpiter"}}</a>
|
<a href="/network" class="item"><i class="bi bi-hdd-network icon"></i>{{tr "NetworkSpiter"}}</a>
|
||||||
</template>
|
</template>
|
||||||
{{ if not .Conf.DisableSwitchTemplateInFrontend }}
|
{{ if not .Conf.DisableSwitchTemplateInFrontend }}
|
||||||
<div class="item ui simple dropdown">
|
<div class="item ui dropdown" :class="{ simple: !isMobile }">
|
||||||
<div class="text"><i class="bi bi-incognito icon" style="margin-right:3px;"></i>{{tr "Template" }}<i class="dropdown icon" style="margin-right:0px;"></i></div>
|
<div class="text"><i class="bi bi-incognito icon" style="margin-right:3px;"></i>{{tr "Template" }}<i class="dropdown icon" style="margin-right:0px;"></i></div>
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
<a v-for="(item, index) in adaptedTemplates" :key="index" @click="toggleTemplate(item.key)" class="item">
|
<a v-for="(item, index) in adaptedTemplates" :key="index" @click="toggleTemplate(item.key)" class="item">
|
||||||
|
|||||||
+22
-14
@@ -18,7 +18,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui container">
|
<div class="ui container">
|
||||||
<div ref="chartDom" style="margin-top: 15px;height: 520px;overflow: hidden"></div>
|
<div ref="chartDom" style="margin-top: 15px;height: auto;overflow: hidden"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -36,7 +36,11 @@
|
|||||||
defaultTemplate: {{.Conf.Site.Theme}},
|
defaultTemplate: {{.Conf.Site.Theme}},
|
||||||
templates: {{.Themes}},
|
templates: {{.Themes}},
|
||||||
servers: initData,
|
servers: initData,
|
||||||
option: {
|
option: {}
|
||||||
|
},
|
||||||
|
mixins: [mixinsVue],
|
||||||
|
created() {
|
||||||
|
this.option = {
|
||||||
tooltip: {
|
tooltip: {
|
||||||
trigger: 'axis',
|
trigger: 'axis',
|
||||||
position: function (pt) {
|
position: function (pt) {
|
||||||
@@ -69,17 +73,9 @@
|
|||||||
right: this.isMobile ? '8%' : '3.8%',
|
right: this.isMobile ? '8%' : '3.8%',
|
||||||
},
|
},
|
||||||
backgroundColor: '',
|
backgroundColor: '',
|
||||||
toolbox: {
|
|
||||||
feature: {
|
|
||||||
dataZoom: {
|
|
||||||
yAxisIndex: 'none'
|
|
||||||
},
|
|
||||||
restore: {},
|
|
||||||
saveAsImage: {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
dataZoom: [
|
dataZoom: [
|
||||||
{
|
{
|
||||||
|
type: 'slider',
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 100
|
end: 100
|
||||||
}
|
}
|
||||||
@@ -93,10 +89,8 @@
|
|||||||
boundaryGap: false
|
boundaryGap: false
|
||||||
},
|
},
|
||||||
series: [],
|
series: [],
|
||||||
},
|
}
|
||||||
chartOnOff: true,
|
|
||||||
},
|
},
|
||||||
mixins: [mixinsVue],
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.renderChart();
|
this.renderChart();
|
||||||
this.parseMonitorInfo(monitorInfo);
|
this.parseMonitorInfo(monitorInfo);
|
||||||
@@ -236,6 +230,20 @@
|
|||||||
this.option.title.text = monitorInfo.result[0].server_name;
|
this.option.title.text = monitorInfo.result[0].server_name;
|
||||||
this.option.series = tSeries;
|
this.option.series = tSeries;
|
||||||
this.option.legend.data = tLegendData;
|
this.option.legend.data = tLegendData;
|
||||||
|
const maxLegendsPerRowMobile = localStorage.getItem("maxLegendsPerRowMobile") ? localStorage.getItem("maxLegendsPerRowMobile") : 2;
|
||||||
|
const maxLegendsPerRowPc = localStorage.getItem("maxLegendsPerRowPc") ? localStorage.getItem("maxLegendsPerRowPc") : 6;
|
||||||
|
const autoIncrement = Math.floor((tLegendData.length - 1) / (this.isMobile ? maxLegendsPerRowMobile : maxLegendsPerRowPc)) * (this.isMobile ? 28 : 34);
|
||||||
|
const height = 520 + autoIncrement;
|
||||||
|
const gridTop = 60 + autoIncrement;
|
||||||
|
this.option.grid = {
|
||||||
|
left: this.isMobile ? '8%' : '3.8%',
|
||||||
|
right: this.isMobile ? '8%' : '3.8%',
|
||||||
|
top: gridTop
|
||||||
|
};
|
||||||
|
this.myChart.resize({
|
||||||
|
width: 'auto',
|
||||||
|
height: height
|
||||||
|
});
|
||||||
this.myChart.clear();
|
this.myChart.clear();
|
||||||
this.myChart.setOption(this.option);
|
this.myChart.setOption(this.option);
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
{{define "theme-server-status/footer"}}
|
{{define "theme-server-status/footer"}}
|
||||||
</div>
|
</section>
|
||||||
<footer class="container-fluid">
|
<footer class="container-fluid">
|
||||||
<p>{{ .Conf.Site.Brand }} | Theme ServerStatus | Powered by <a target="_blank" href="https://github.com/naiba/nezha">{{tr "NezhaMonitoring"}}</a> {{.Version}}</p>
|
<p>{{ .Conf.Site.Brand }} | Theme ServerStatus | Powered by <a target="_blank" href="https://github.com/naiba/nezha">{{tr "NezhaMonitoring"}}</a> {{.Version}}</p>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
+15
-5
@@ -2,11 +2,21 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="{{.Conf.Language}}">
|
<html lang="{{.Conf.Language}}">
|
||||||
<head>
|
<head>
|
||||||
<title>{{ .Title }}</title>
|
<title>{{.Title}}</title>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
|
<meta content="telephone=no" name="format-detection">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="shortcut icon" type="image/png" href="/static/logo.svg" />
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||||
|
<meta name="mobile-web-app-capable" content="yes" />
|
||||||
|
<meta name="theme-color" content="#000000" />
|
||||||
|
{{if eq .Conf.Language "zh-CN"}}
|
||||||
|
<link rel="manifest" href="/static/manifest-zh-CN.json?v20240905" />
|
||||||
|
{{else}}
|
||||||
|
<link rel="manifest" href="/static/manifest-en-US.json?v20240905" />
|
||||||
|
{{end}}
|
||||||
|
<link rel="apple-touch-startup-image" href="/static/logo.svg" />
|
||||||
|
<link rel="shortcut icon" type="image/png" href="/static/logo.svg">
|
||||||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/css/bootstrap.min.css">
|
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/css/bootstrap.min.css">
|
||||||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/font/bootstrap-icons.min.css">
|
<link rel="stylesheet" href="https://unpkg.com/[email protected]/font/bootstrap-icons.min.css">
|
||||||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/assets/font-logos.css">
|
<link rel="stylesheet" href="https://unpkg.com/[email protected]/assets/font-logos.css">
|
||||||
@@ -16,10 +26,10 @@
|
|||||||
<script src="https://unpkg.com/[email protected]/dist/js/bootstrap.min.js"></script>
|
<script src="https://unpkg.com/[email protected]/dist/js/bootstrap.min.js"></script>
|
||||||
<script src="https://unpkg.com/[email protected]/dist/vue.min.js"></script>
|
<script src="https://unpkg.com/[email protected]/dist/vue.min.js"></script>
|
||||||
<script src="https://unpkg.com/[email protected]/dist/echarts.min.js"></script>
|
<script src="https://unpkg.com/[email protected]/dist/echarts.min.js"></script>
|
||||||
<link rel="stylesheet" href="/static/theme-server-status/css/main.css?v202408016">
|
<link rel="stylesheet" href="/static/theme-server-status/css/main.css?v20240909">
|
||||||
<link rel="stylesheet" href="/static/theme-server-status/css/dark.css?v202408011">
|
<link rel="stylesheet" href="/static/theme-server-status/css/dark.css?v202408011">
|
||||||
<link rel="stylesheet" href="/static/theme-server-status/css/light.css?v20240811">
|
<link rel="stylesheet" href="/static/theme-server-status/css/light.css?v20240811">
|
||||||
<script src="/static/theme-server-status/js/mixin.js?v20240811"></script>
|
<script src="/static/theme-server-status/js/mixin.js?v20240907"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<tbody id="servers">
|
<tbody id="servers">
|
||||||
<template v-for="(node,index) in nodesNoTag">
|
<template v-for="(node,index) in nodesNoTag">
|
||||||
<tr :id="'r'+node.ID" data-toggle="collapse" :data-target="'#rt'+node.ID" class="accordion-toggle" :class="index % 2 === 0 ? 'odd': 'even'"
|
<tr :id="'r'+node.ID" data-toggle="collapse" :data-target="'#rt'+node.ID" class="accordion-toggle" :class="index % 2 === 0 ? 'odd': 'even'"
|
||||||
aria-expanded="false" @click="showCharts($event, node.ID)">
|
aria-expanded="false" @click="showCharts(node.ID)">
|
||||||
<td class="node-cell status center">
|
<td class="node-cell status center">
|
||||||
<div class="status-container">
|
<div class="status-container">
|
||||||
<div v-if="node.online" class="status-icon online"></div>
|
<div v-if="node.online" class="status-icon online"></div>
|
||||||
@@ -143,7 +143,7 @@
|
|||||||
@#node.host.Version#@
|
@#node.host.Version#@
|
||||||
</span>
|
</span>
|
||||||
<span class="node-echarts-expand">
|
<span class="node-echarts-expand">
|
||||||
<div class="chartbox" chartbox-show="0" :key="node.ID" :ref="`chart${node.ID}`" style="width: 100%; height: auto;"></div>
|
<div class="chartbox" :id="`chart-${node.ID}`" chartbox-show="0" :key="node.ID" style="width: 100%; height: auto;"></div>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<tbody id="servers">
|
<tbody id="servers">
|
||||||
<template v-for="(node,index) in group.data">
|
<template v-for="(node,index) in group.data">
|
||||||
<tr :id="'r'+node.ID" data-toggle="collapse" :data-target="'#rt'+node.ID" class="accordion-toggle"
|
<tr :id="'r'+node.ID" data-toggle="collapse" :data-target="'#rt'+node.ID" class="accordion-toggle"
|
||||||
:class="index % 2 === 0 ? 'odd': 'even'" aria-expanded="false" @click="showCharts($event, node.ID)">
|
:class="index % 2 === 0 ? 'odd': 'even'" aria-expanded="false" @click="showCharts(node.ID)">
|
||||||
<td class="node-cell status center">
|
<td class="node-cell status center">
|
||||||
<div class="status-container">
|
<div class="status-container">
|
||||||
<div v-if="node.online" class="status-icon online"></div>
|
<div v-if="node.online" class="status-icon online"></div>
|
||||||
@@ -146,7 +146,7 @@
|
|||||||
@#node.host.Version#@
|
@#node.host.Version#@
|
||||||
</span>
|
</span>
|
||||||
<span class="node-echarts-expand">
|
<span class="node-echarts-expand">
|
||||||
<div class="chartbox" chartbox-show="0" :key="node.ID" :ref="`chart${node.ID}`" style="width: 100%; height: auto;"></div>
|
<div class="chartbox" :id="`chart-${node.ID}`" chartbox-show="0" :key="node.ID" style="width: 100%; height: auto;"></div>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+160
-92
@@ -3,15 +3,15 @@
|
|||||||
{{template "theme-server-status/menu" .}}
|
{{template "theme-server-status/menu" .}}
|
||||||
<!-- showGroup true -->
|
<!-- showGroup true -->
|
||||||
<template v-if="showGroup">
|
<template v-if="showGroup">
|
||||||
<section class="container-fluid table-responsive content" v-for="group in nodesTag">
|
<div class="container-fluid table-responsive content" v-for="group in nodesTag">
|
||||||
{{template "theme-server-status/home-group-true" .}}
|
{{template "theme-server-status/home-group-true" .}}
|
||||||
</section>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<!-- showGroup false -->
|
<!-- showGroup false -->
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<section class="container-fluid table-responsive content">
|
<div class="container-fluid table-responsive content">
|
||||||
{{template "theme-server-status/home-group-false" .}}
|
{{template "theme-server-status/home-group-false" .}}
|
||||||
</section>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<div class="modal fade" id="mapChartBox" tabindex="-1" role="dialog" aria-labelledby="mapChartTitle" aria-hidden="true" style="padding-left:0">
|
<div class="modal fade" id="mapChartBox" tabindex="-1" role="dialog" aria-labelledby="mapChartTitle" aria-hidden="true" style="padding-left:0">
|
||||||
<div class="modal-dialog modal-lg modal-dialog-centered">
|
<div class="modal-dialog modal-lg modal-dialog-centered">
|
||||||
@@ -163,6 +163,9 @@
|
|||||||
const tooltipBorderColor = this.theme == "dark" ? "#ffffff" : "#ffffff";
|
const tooltipBorderColor = this.theme == "dark" ? "#ffffff" : "#ffffff";
|
||||||
const fontSize = this.isMobile ? 10 : 12;
|
const fontSize = this.isMobile ? 10 : 12;
|
||||||
const fontColor = this.theme == "dark" ? "#000000" : "#000000";
|
const fontColor = this.theme == "dark" ? "#000000" : "#000000";
|
||||||
|
const showLoadingMaskColor = this.theme == "dark" ? 'rgba(28, 29, 38, 1)' : 'rgba(249, 249, 249, 1)';
|
||||||
|
const showLoadingTextColor = this.theme == "dark" ? 'rgba(241, 241, 241, 1)' : 'rgba(0, 0, 0, 1)';
|
||||||
|
const showLoadingColor = inRangeColor;
|
||||||
const chartContainer = document.getElementById('mapChart');
|
const chartContainer = document.getElementById('mapChart');
|
||||||
const mapChart = echarts.init(chartContainer, '', { // init图表
|
const mapChart = echarts.init(chartContainer, '', { // init图表
|
||||||
renderer: 'canvas',
|
renderer: 'canvas',
|
||||||
@@ -170,6 +173,13 @@
|
|||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
});
|
});
|
||||||
|
mapChart.showLoading({
|
||||||
|
text: 'loading',
|
||||||
|
textColor: showLoadingTextColor,
|
||||||
|
color: showLoadingColor,
|
||||||
|
maskColor: showLoadingMaskColor,
|
||||||
|
zlevel: 2
|
||||||
|
});
|
||||||
fetch(this.staticUrl + '/maps/' + this.countryMapGeoFile)
|
fetch(this.staticUrl + '/maps/' + this.countryMapGeoFile)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(worldMap => {
|
.then(worldMap => {
|
||||||
@@ -224,7 +234,10 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
mapChart.setOption(option);
|
setTimeout(() => {
|
||||||
|
mapChart.hideLoading();
|
||||||
|
mapChart.setOption(option);
|
||||||
|
}, 1000);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
isWindowsPlatform(str) {
|
isWindowsPlatform(str) {
|
||||||
@@ -470,24 +483,27 @@
|
|||||||
// 如果所有元素的 Temperature 都为 0,则返回一个默认值 0
|
// 如果所有元素的 Temperature 都为 0,则返回一个默认值 0
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
showCharts(event, id) {
|
showCharts(id,changeChartboxShow=true) {
|
||||||
const chartContainer = this.$refs[`chart${id}`][0];
|
const chartContainer = document.getElementById(`chart-${id}`);
|
||||||
const chartboxShow = chartContainer.getAttribute('chartbox-show');
|
if(changeChartboxShow){
|
||||||
chartContainer.setAttribute('chartbox-show', chartboxShow === '0' ? '1' : '0');
|
const chartboxShow = chartContainer.getAttribute('chartbox-show');
|
||||||
const isAriaExpandedFalse = event.currentTarget.getAttribute('aria-expanded') === 'false';
|
chartContainer.setAttribute('chartbox-show', chartboxShow === '0' ? '1' : '0');
|
||||||
if (!isAriaExpandedFalse) return;
|
const collapseContainer = document.getElementById(`r${id}`);
|
||||||
|
const isAriaExpandedFalse = collapseContainer.getAttribute('aria-expanded') === 'false';
|
||||||
|
if (!isAriaExpandedFalse) return;
|
||||||
|
}
|
||||||
// 发起数据请求
|
// 发起数据请求
|
||||||
const url = `/api/v1/monitor/${id}`;
|
const url = `/api/v1/monitor/${id}`;
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
if (data.result) { // 数据请求成功,更新数据并渲染图表
|
if (data.result) { // 数据请求成功,更新数据并渲染图表
|
||||||
this.chartDataList[id - 1] = data.result;
|
this.chartDataList[id] = data.result;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.renderCharts(id);
|
this.renderCharts(id);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log('this agent (id:'+ id + ') has no monitor.');
|
console.log('this server (id:'+ id + ') has no monitor.');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
@@ -495,73 +511,113 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
renderCharts(id, reload = false) {
|
renderCharts(id, reload = false) {
|
||||||
if (!this.chartDataList[id - 1]) return;
|
if (!this.chartDataList[id]) return;
|
||||||
const chartData = this.chartDataList[id - 1];
|
const chartData = this.chartDataList[id];
|
||||||
const chartContainer = this.$refs[`chart${id}`][0];
|
const chartContainer = document.getElementById(`chart-${id}`);
|
||||||
if (reload) { //点击切换亮色/暗色风格模式时,重新载入echarts图表的逻辑,
|
if (reload) {
|
||||||
// 第一步,查找已经渲染出的图表容器,并销毁它
|
|
||||||
const existingChart = echarts.getInstanceByDom(chartContainer);
|
const existingChart = echarts.getInstanceByDom(chartContainer);
|
||||||
if (existingChart) existingChart.dispose();
|
if (existingChart) existingChart.dispose();
|
||||||
// 第二步,如果图表容器处于不可见状态chartboxShow=0,不重新渲染出新的图表,
|
|
||||||
// 如果图表容器处于可见状态chartboxShow=1,重新渲染出新的图表
|
|
||||||
const chartboxShow = chartContainer.getAttribute('chartbox-show');
|
const chartboxShow = chartContainer.getAttribute('chartbox-show');
|
||||||
if ( chartboxShow === '0' ) return;
|
if ( chartboxShow === '0' ) return;
|
||||||
}
|
}
|
||||||
// 定义图表参数值
|
|
||||||
const MaxTCPPingValue = {{.Conf.MaxTCPPingValue}} ? {{.Conf.MaxTCPPingValue}} : 300;
|
const MaxTCPPingValue = {{.Conf.MaxTCPPingValue}} ? {{.Conf.MaxTCPPingValue}} : 300;
|
||||||
const fontSize = this.isMobile ? 10 : 14;
|
const fontSize = this.isMobile ? 10 : 14;
|
||||||
const gridLeft = this.isMobile ? 25 : 36;
|
const gridLeft = (MaxTCPPingValue > 500) ? (this.isMobile ? 36 : 42) : (this.isMobile ? 25 : 36);
|
||||||
const gridRight = this.isMobile ? 5 : 20;
|
const gridRight = this.isMobile ? 5 : 20;
|
||||||
const legendLeft = this.isMobile ? 'center' : 'center';
|
const legendLeft = this.isMobile ? 'center' : 'center';
|
||||||
const legendTop = this.isMobile ? 5 : 5;
|
const legendTop = this.isMobile ? 5 : 5;
|
||||||
const legendPadding= this.isMobile ? [5,0,5,0] : [5,0,5,0];
|
const legendPadding= this.isMobile ? [5,0,5,0] : [5,0,5,0];
|
||||||
const systemDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
const systemDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
||||||
const theme = localStorage.getItem("theme") ? localStorage.getItem("theme") : systemDarkMode;
|
const theme = localStorage.getItem("theme") ? localStorage.getItem("theme") : systemDarkMode;
|
||||||
const chartTheme = theme == "dark" ? "dark" : "default";
|
const chartTheme = this.theme == "dark" ? "dark" : "default";
|
||||||
const fontColor = theme == "dark" ? "#f1f1f1" : "#000000";
|
const fontColor = this.theme == "dark" ? "#f1f1f1" : "#000000";
|
||||||
const backgroundColor = theme == "dark" ? '' : '';
|
const backgroundColor = theme == "dark" ? '' : '';
|
||||||
const tooltipBackgroundColor = this.theme == "dark" ? (this.semiTransparent ? "rgba(28,29,38,0.85)" : "rgba(28,29,38,1)") : (this.semiTransparent ? "rgba(255,255,255,0.85)" : "rgba(255,255,255,1)");
|
const tooltipBackgroundColor = this.theme == "dark" ? (this.semiTransparent ? "rgba(28,29,38,0.85)" : "rgba(28,29,38,1)") : (this.semiTransparent ? "rgba(255,255,255,0.85)" : "rgba(255,255,255,1)");
|
||||||
const tooltipBorderColor = this.theme == "dark" ? (this.semiTransparent ? "rgba(28,29,38,0.9)" : "rgba(28,29,38,1)") : (this.semiTransparent ? "rgba(255,255,255,0.9)" : "rgba(255,255,255,1)");
|
const tooltipBorderColor = this.theme == "dark" ? (this.semiTransparent ? "rgba(28,29,38,0.9)" : "rgba(28,29,38,1)") : (this.semiTransparent ? "rgba(255,255,255,0.9)" : "rgba(255,255,255,1)");
|
||||||
const lineStyleWidth = this.isMobile ? 1 : 2;
|
const lineStyleWidth = this.isMobile ? 1 : 2;
|
||||||
const splitLineWidth = this.isMobile ? 0.5 : 1;
|
const splitLineWidth = this.isMobile ? 0.5 : 1;
|
||||||
// 渲染图表
|
const markLineItemStyleOpacity = this.semiTransparent ? 1 : 0.75;
|
||||||
const chart = echarts.init(chartContainer, chartTheme, {
|
const markLineLineStyleWidth = this.isMobile ? 0.15 : 0.3;
|
||||||
|
const chart = echarts.init(chartContainer, chartTheme, { // init图表
|
||||||
renderer: 'canvas',
|
renderer: 'canvas',
|
||||||
useDirtyRect: false,
|
useDirtyRect: false,
|
||||||
width: 'auto',
|
width: 'auto',
|
||||||
height: 300,
|
height: 300
|
||||||
});
|
});
|
||||||
const xAxisData = chartData[0].created_at.map(time => new Date(time).toLocaleString());
|
let legendData = [];
|
||||||
const seriesData = chartData.map(item => {
|
let seriesData = [];
|
||||||
|
chartData.forEach((item,key)=> {
|
||||||
let loss = 0;
|
let loss = 0;
|
||||||
const data = item.avg_delay.map((avgDelay, index) => {
|
let totalLossRate = 0;
|
||||||
if(avgDelay > 0 && avgDelay < MaxTCPPingValue){
|
let legendName = '';
|
||||||
loss += avgDelay > 0.9 * MaxTCPPingValue ? 1 : 0;
|
let data = { main: [], markLine: []};
|
||||||
return [item.created_at[index], avgDelay.toFixed(2)];
|
item.avg_delay.forEach((avgDelay, index) => {
|
||||||
}else{
|
const threshold = 0.9 * MaxTCPPingValue; // 定义阀值,用于判断是否丢包
|
||||||
|
// 定义丢包 1. avgDelay==0 2. avgDelay>=MaxTCPPingValue 3. avgDelay>=threshold
|
||||||
|
if(avgDelay == 0 || avgDelay >= MaxTCPPingValue){ //绝对丢包
|
||||||
loss += 1;
|
loss += 1;
|
||||||
|
const lossrate = 100 * loss / (index + 1);
|
||||||
|
if(lossrate != 100) {
|
||||||
|
data['markLine'].push({
|
||||||
|
xAxis: item.created_at[index],
|
||||||
|
label: { show: false },
|
||||||
|
emphasis: { disabled: true },
|
||||||
|
lineStyle: { type: "solid" }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (avgDelay >= threshold && avgDelay < MaxTCPPingValue){ // 相对丢包
|
||||||
|
loss += 1;
|
||||||
|
const lossrate = 100 * loss / (index + 1);
|
||||||
|
if(lossrate != 100) {
|
||||||
|
data['main'].push(
|
||||||
|
[item.created_at[index], avgDelay, lossrate]
|
||||||
|
);
|
||||||
|
data['markLine'].push({
|
||||||
|
xAxis: item.created_at[index],
|
||||||
|
label: { show: false },
|
||||||
|
emphasis: { disabled: true },
|
||||||
|
lineStyle: { type: "solid" }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else { // 未丢包
|
||||||
|
const lossrate = 100 * loss / (index + 1);
|
||||||
|
data['main'].push(
|
||||||
|
[item.created_at[index], avgDelay, lossrate]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const lossRate = ((loss / item.created_at.length) * 100).toFixed(1);
|
totalLossRate = ((loss / item.created_at.length) * 100).toFixed(1);
|
||||||
item.monitor_name = item.monitor_name.includes("%") ? item.monitor_name : `${item.monitor_name} ${lossRate}%`;
|
legendName = `${item.monitor_name} ${totalLossRate}%`;
|
||||||
return {
|
legendData.push(legendName);
|
||||||
name: item.monitor_name,
|
seriesData.push(
|
||||||
type: 'line',
|
{
|
||||||
smooth: true,
|
name: legendName,
|
||||||
symbol: 'none',
|
type: 'line',
|
||||||
data: data,
|
smooth: true,
|
||||||
connectNulls: true,
|
symbol: 'none',
|
||||||
legendHoverLink: false,
|
connectNulls: true,
|
||||||
emphasis: {
|
legendHoverLink: false,
|
||||||
disabled: true
|
emphasis: {
|
||||||
},
|
disabled: true
|
||||||
lineStyle: {
|
},
|
||||||
width: lineStyleWidth
|
lineStyle: {
|
||||||
|
width: lineStyleWidth
|
||||||
|
},
|
||||||
|
data: data['main'],
|
||||||
|
markLine: {
|
||||||
|
symbol: "none",
|
||||||
|
symbolSize :0,
|
||||||
|
data: data['markLine'],
|
||||||
|
itemStyle: {
|
||||||
|
opacity: markLineItemStyleOpacity
|
||||||
|
},
|
||||||
|
lineStyle:{
|
||||||
|
width: markLineLineStyleWidth
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const legendData = chartData.map(item => item.monitor_name);
|
|
||||||
const maxLegendsPerRowMobile = localStorage.getItem("maxLegendsPerRowMobile") ? localStorage.getItem("maxLegendsPerRowMobile") : 3;
|
const maxLegendsPerRowMobile = localStorage.getItem("maxLegendsPerRowMobile") ? localStorage.getItem("maxLegendsPerRowMobile") : 3;
|
||||||
const maxLegendsPerRowPc = localStorage.getItem("maxLegendsPerRowPc") ? localStorage.getItem("maxLegendsPerRowPc") : 6;
|
const maxLegendsPerRowPc = localStorage.getItem("maxLegendsPerRowPc") ? localStorage.getItem("maxLegendsPerRowPc") : 6;
|
||||||
const autoIncrement = Math.floor((legendData.length - 1) / (this.isMobile ? maxLegendsPerRowMobile : maxLegendsPerRowPc)) * (this.isMobile ? 20 : 28);
|
const autoIncrement = Math.floor((legendData.length - 1) / (this.isMobile ? maxLegendsPerRowMobile : maxLegendsPerRowPc)) * (this.isMobile ? 20 : 28);
|
||||||
@@ -574,39 +630,24 @@
|
|||||||
width: 'auto',
|
width: 'auto',
|
||||||
height: height
|
height: height
|
||||||
});
|
});
|
||||||
|
|
||||||
const option = {
|
const option = {
|
||||||
|
color: this.colors,
|
||||||
backgroundColor: backgroundColor,
|
backgroundColor: backgroundColor,
|
||||||
|
textStyle: {
|
||||||
|
fontSize: fontSize,
|
||||||
|
color: fontColor
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
top: gridTop,
|
||||||
|
left: gridLeft,
|
||||||
|
right: gridRight,
|
||||||
|
},
|
||||||
title: {
|
title: {
|
||||||
show: false
|
show: false,
|
||||||
},
|
|
||||||
tooltip: {
|
|
||||||
trigger: 'axis',
|
|
||||||
backgroundColor: tooltipBackgroundColor,
|
|
||||||
borderColor: tooltipBorderColor,
|
|
||||||
textStyle: {
|
|
||||||
fontSize: fontSize,
|
|
||||||
color: fontColor
|
|
||||||
}
|
|
||||||
},
|
|
||||||
legend: {
|
|
||||||
data: legendData,
|
|
||||||
show: true,
|
|
||||||
icon: legendIcon,
|
|
||||||
textStyle: {
|
|
||||||
fontSize: fontSize,
|
|
||||||
color: fontColor
|
|
||||||
},
|
|
||||||
top: legendTop,
|
|
||||||
bottom: 0,
|
|
||||||
left: legendLeft,
|
|
||||||
padding: legendPadding,
|
|
||||||
itemWidth: itemWidth,
|
|
||||||
itemHeight: itemHeight,
|
|
||||||
},
|
},
|
||||||
|
series: seriesData.flat(),
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: 'time',
|
type: 'time',
|
||||||
data: xAxisData,
|
|
||||||
axisLabel: {
|
axisLabel: {
|
||||||
textStyle: {
|
textStyle: {
|
||||||
fontSize: fontSize
|
fontSize: fontSize
|
||||||
@@ -626,30 +667,57 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
legend: {
|
||||||
|
data: legendData,
|
||||||
|
show: true,
|
||||||
|
icon: legendIcon,
|
||||||
|
textStyle: {
|
||||||
|
fontSize: fontSize,
|
||||||
|
color: fontColor
|
||||||
|
},
|
||||||
|
top: legendTop,
|
||||||
|
bottom: 0,
|
||||||
|
left: legendLeft,
|
||||||
|
padding: legendPadding,
|
||||||
|
itemWidth: itemWidth,
|
||||||
|
itemHeight: itemHeight,
|
||||||
|
},
|
||||||
|
tooltip: {
|
||||||
|
trigger: 'axis',
|
||||||
|
backgroundColor: tooltipBackgroundColor,
|
||||||
|
borderColor: tooltipBorderColor,
|
||||||
|
textStyle: {
|
||||||
|
fontSize: fontSize,
|
||||||
|
color: fontColor
|
||||||
|
},
|
||||||
|
formatter: function (params) {
|
||||||
|
let tooltipContent = '';
|
||||||
|
const formattedTime = new Date(params[0].value[0]).toLocaleString();
|
||||||
|
tooltipContent += `<span style="line-height:2em">${formattedTime}</span><br>`;
|
||||||
|
params.forEach(param => {
|
||||||
|
const formattedTime = new Date(param.value[0]).toLocaleString();
|
||||||
|
if (!param.seriesName.includes('stack')) {
|
||||||
|
const name = param.seriesName.replace(/\s\d+(\.\d+)?%$/, '');
|
||||||
|
tooltipContent += `<span style="line-height:2em">${param.marker} ${name} ${param.value[2].toFixed(1)}% ${param.value[1].toFixed(2)}</span><br>`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return tooltipContent;
|
||||||
|
}
|
||||||
|
},
|
||||||
dataZoom: [
|
dataZoom: [
|
||||||
{
|
{
|
||||||
type: 'slider',
|
type: 'slider',
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 100
|
end: 100
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
series: seriesData,
|
|
||||||
textStyle: {
|
|
||||||
fontSize: fontSize,
|
|
||||||
color: fontColor
|
|
||||||
},
|
|
||||||
grid: {
|
|
||||||
top: gridTop,
|
|
||||||
left: gridLeft,
|
|
||||||
right: gridRight
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
chart.setOption(option);
|
chart.setOption(option);
|
||||||
},
|
},
|
||||||
reloadCharts() { // 重新加载所有图表
|
reloadCharts() {
|
||||||
this.servers.forEach(node => {
|
this.servers.forEach(node => {
|
||||||
const id = node.ID;
|
const id = node.ID;
|
||||||
const chartData = this.chartDataList[id - 1];
|
const chartData = this.chartDataList[id];
|
||||||
if (chartData) {
|
if (chartData) {
|
||||||
this.renderCharts(id,true);
|
this.renderCharts(id,true);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -64,6 +64,6 @@
|
|||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<div class="nezha">
|
<section class="nezha">
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
|
|||||||
+49
-46
@@ -15,7 +15,7 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="chartTitle"><i class="chartCountryCode" :class="'fi fi-' + chartCountryCode"></i> @#chartTitle#@</div>
|
<div class="chartTitle" @click="showCharts(nextServerId)"><i class="chartCountryCode" :class="'fi fi-' + chartCountryCode"></i> @#chartTitle#@</div>
|
||||||
<div id="chartbox" style="width:100%;height:auto;"></div>
|
<div id="chartbox" style="width:100%;height:auto;"></div>
|
||||||
</div>
|
</div>
|
||||||
{{template "theme-server-status/footer" .}}
|
{{template "theme-server-status/footer" .}}
|
||||||
@@ -32,7 +32,8 @@
|
|||||||
chartTitle: '',
|
chartTitle: '',
|
||||||
chartCountryCode: '',
|
chartCountryCode: '',
|
||||||
chart: null,
|
chart: null,
|
||||||
currentServerId: ''
|
currentServerId: '',
|
||||||
|
nextServerId: '',
|
||||||
},
|
},
|
||||||
mixins: [mixinsVue],
|
mixins: [mixinsVue],
|
||||||
created() {
|
created() {
|
||||||
@@ -66,37 +67,47 @@
|
|||||||
if(!this.chartDataList[id]) return;
|
if(!this.chartDataList[id]) return;
|
||||||
if(this.chart) this.disposeCharts(this.chart);
|
if(this.chart) this.disposeCharts(this.chart);
|
||||||
this.currentServerId = id;
|
this.currentServerId = id;
|
||||||
|
this.nextServerId = this.getNextServerId(id);
|
||||||
this.chartCountryCode = this.getServerCountryCode(id);
|
this.chartCountryCode = this.getServerCountryCode(id);
|
||||||
this.chartTitle = this.chartDataList[id][0].server_name;
|
this.chartTitle = this.chartDataList[id][0].server_name;
|
||||||
const chartData = this.chartDataList[id];
|
const chartData = this.chartDataList[id];
|
||||||
const chartContainer = document.getElementById('chartbox');
|
const chartContainer = document.getElementById('chartbox');
|
||||||
// 定义图表参数值
|
|
||||||
const MaxTCPPingValue = {{.Conf.MaxTCPPingValue}} ? {{.Conf.MaxTCPPingValue}} : 300;
|
const MaxTCPPingValue = {{.Conf.MaxTCPPingValue}} ? {{.Conf.MaxTCPPingValue}} : 300;
|
||||||
const autoheight = this.isMobile ? (window.innerHeight - 200) : (window.innerHeight - 250);
|
const autoheight = this.isMobile ? (window.innerHeight - 180) : (window.innerHeight - 250);
|
||||||
const fontSize = this.isMobile ? 10 : 14;
|
const fontSize = this.isMobile ? 10 : 14;
|
||||||
const gridLeft = this.isMobile ? 30 : 36;
|
const gridLeft = (MaxTCPPingValue > 500) ? (this.isMobile ? 36 : 42) : (this.isMobile ? 30 : 36);
|
||||||
const gridRight = this.isMobile ? 12 : 20;
|
const gridRight = this.isMobile ? 12 : 20;
|
||||||
const legendLeft = this.isMobile ? 'center' : 'center';
|
const legendLeft = this.isMobile ? 'center' : 'center';
|
||||||
const legendTop = this.isMobile ? 5 : 5;
|
const legendTop = this.isMobile ? 5 : 5;
|
||||||
const legendPadding= this.isMobile ? [5,0,5,0] : [5,0,5,0];
|
const legendPadding= this.isMobile ? [5,0,5,0] : [5,0,5,0];
|
||||||
const fontColor = this.theme == "dark" ? "#f1f1f1" : "#000000";
|
const fontColor = this.theme == "dark" ? "#f1f1f1" : "#000000";
|
||||||
|
const chartTheme = this.theme == "dark" ? "dark" : "default";
|
||||||
const backgroundColor = this.theme == "dark" ? '' : '';
|
const backgroundColor = this.theme == "dark" ? '' : '';
|
||||||
const tooltipBackgroundColor = this.theme == "dark" ? (this.semiTransparent ? "rgba(28,29,38,0.85)" : "rgba(28,29,38,1)") : (this.semiTransparent ? "rgba(255,255,255,0.85)" : "rgba(255,255,255,1)");
|
const tooltipBackgroundColor = this.theme == "dark" ? (this.semiTransparent ? "rgba(28,29,38,0.85)" : "rgba(28,29,38,1)") : (this.semiTransparent ? "rgba(255,255,255,0.85)" : "rgba(255,255,255,1)");
|
||||||
const tooltipBorderColor = this.theme == "dark" ? (this.semiTransparent ? "rgba(28,29,38,0.9)" : "rgba(28,29,38,1)") : (this.semiTransparent ? "rgba(255,255,255,0.9)" : "rgba(255,255,255,1)");
|
const tooltipBorderColor = this.theme == "dark" ? (this.semiTransparent ? "rgba(28,29,38,0.9)" : "rgba(28,29,38,1)") : (this.semiTransparent ? "rgba(255,255,255,0.9)" : "rgba(255,255,255,1)");
|
||||||
const lineStyleWidth = this.isMobile ? 1 : 2;
|
const lineStyleWidth = this.isMobile ? 1 : 2;
|
||||||
const splitLineWidth = this.isMobile ? 0.5 : 1;
|
const splitLineWidth = this.isMobile ? 0.5 : 1;
|
||||||
const splitLineColor = this.theme == "dark" ? "rgba(110, 112, 121, 0.95)" : "rgba(224, 230, 241, 0.95)";
|
const markPointSymbolSize = this.isMobile ? 36 : 42;
|
||||||
const markPointLabelColor = this.theme == "dark" ? "#111111" : "#000000";
|
const markPointItemStyleOpacity = this.semiTransparent ? 1 : 1;
|
||||||
const markPointItemStyleOpacity = this.semiTransparent ? 1 : 0.75;
|
const markPointFontSize = this.isMobile ? 8 : 10;
|
||||||
const markLineItemStyleOpacity = this.semiTransparent ? 1 : 0.75;
|
const markLineItemStyleOpacity = this.semiTransparent ? 1 : 0.75;
|
||||||
const markLineLineStyleWidth = this.isMobile ? 0.15 : 0.3;
|
const markLineLineStyleWidth = this.isMobile ? 0.15 : 0.3;
|
||||||
this.chart = echarts.init(chartContainer, '', { // init图表
|
const showLoadingMaskColor = this.theme == "dark" ? 'rgba(0, 0, 0, 0)' : 'rgba(255, 255, 255, 0)';
|
||||||
|
const showLoadingTextColor = this.theme == "dark" ? 'rgba(241, 241, 241, 1)' : 'rgba(0, 0, 0, 1)';
|
||||||
|
const showLoadingColor = this.theme == "dark" ? '#D2B206' : '#FFDF32';
|
||||||
|
this.chart = echarts.init(chartContainer, chartTheme, { // init图表
|
||||||
renderer: 'canvas',
|
renderer: 'canvas',
|
||||||
useDirtyRect: false,
|
useDirtyRect: false,
|
||||||
width: 'auto',
|
width: 'auto',
|
||||||
height: autoheight,
|
height: autoheight,
|
||||||
});
|
});
|
||||||
// 获取图表数据
|
this.chart.showLoading({
|
||||||
|
text: 'loading',
|
||||||
|
textColor: showLoadingTextColor,
|
||||||
|
color: showLoadingColor,
|
||||||
|
maskColor: showLoadingMaskColor,
|
||||||
|
zlevel: 2
|
||||||
|
});
|
||||||
let legendData = [];
|
let legendData = [];
|
||||||
let seriesData = [];
|
let seriesData = [];
|
||||||
chartData.forEach((item,key)=> {
|
chartData.forEach((item,key)=> {
|
||||||
@@ -111,9 +122,6 @@
|
|||||||
loss += 1;
|
loss += 1;
|
||||||
const lossrate = 100 * loss / (index + 1);
|
const lossrate = 100 * loss / (index + 1);
|
||||||
if(lossrate != 100) {
|
if(lossrate != 100) {
|
||||||
data['main'].push(
|
|
||||||
[item.created_at[index], MaxTCPPingValue, lossrate]
|
|
||||||
);
|
|
||||||
data['markLine'].push({
|
data['markLine'].push({
|
||||||
xAxis: item.created_at[index],
|
xAxis: item.created_at[index],
|
||||||
label: { show: false },
|
label: { show: false },
|
||||||
@@ -142,11 +150,9 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// 处理legendData
|
|
||||||
totalLossRate = ((loss / item.created_at.length) * 100).toFixed(1);
|
totalLossRate = ((loss / item.created_at.length) * 100).toFixed(1);
|
||||||
legendName = `${item.monitor_name} ${totalLossRate}%`;
|
legendName = `${item.monitor_name} ${totalLossRate}%`;
|
||||||
legendData.push(legendName);
|
legendData.push(legendName);
|
||||||
// 处理seriesData
|
|
||||||
seriesData.push(
|
seriesData.push(
|
||||||
{
|
{
|
||||||
name: legendName,
|
name: legendName,
|
||||||
@@ -182,10 +188,9 @@
|
|||||||
itemStyle: {
|
itemStyle: {
|
||||||
opacity: markPointItemStyleOpacity
|
opacity: markPointItemStyleOpacity
|
||||||
},
|
},
|
||||||
symbolSize: 30,
|
symbolSize: markPointSymbolSize,
|
||||||
label: {
|
label: {
|
||||||
fontSize: 8,
|
fontSize: markPointFontSize,
|
||||||
color: markPointLabelColor,
|
|
||||||
formatter: function (params) {
|
formatter: function (params) {
|
||||||
return Math.round(params.value);
|
return Math.round(params.value);
|
||||||
}
|
}
|
||||||
@@ -198,10 +203,9 @@
|
|||||||
itemStyle: {
|
itemStyle: {
|
||||||
opacity: markPointItemStyleOpacity
|
opacity: markPointItemStyleOpacity
|
||||||
},
|
},
|
||||||
symbolSize: 30,
|
symbolSize: markPointSymbolSize,
|
||||||
label: {
|
label: {
|
||||||
fontSize: 8,
|
fontSize: markPointFontSize,
|
||||||
color: markPointLabelColor,
|
|
||||||
offset: [0, 8],
|
offset: [0, 8],
|
||||||
formatter: function (params) {
|
formatter: function (params) {
|
||||||
return Math.round(params.value);
|
return Math.round(params.value);
|
||||||
@@ -218,7 +222,8 @@
|
|||||||
const maxLegendsPerRowPc = localStorage.getItem("maxLegendsPerRowPc") ? localStorage.getItem("maxLegendsPerRowPc") : 6;
|
const maxLegendsPerRowPc = localStorage.getItem("maxLegendsPerRowPc") ? localStorage.getItem("maxLegendsPerRowPc") : 6;
|
||||||
const autoIncrement = Math.floor((legendData.length - 1) / (this.isMobile ? maxLegendsPerRowMobile : maxLegendsPerRowPc)) * (this.isMobile ? 20 : 28);
|
const autoIncrement = Math.floor((legendData.length - 1) / (this.isMobile ? maxLegendsPerRowMobile : maxLegendsPerRowPc)) * (this.isMobile ? 20 : 28);
|
||||||
const height = autoheight + autoIncrement;
|
const height = autoheight + autoIncrement;
|
||||||
const gridTop = 40 + autoIncrement;
|
const gridTop = this.isMobile ? ( 60 + autoIncrement) : (80 + autoIncrement);
|
||||||
|
const gridBottom = this.isMobile ? 70 : 90;
|
||||||
const legendIcon = this.isMobile ? 'rect' : "";
|
const legendIcon = this.isMobile ? 'rect' : "";
|
||||||
const itemWidth = this.isMobile ? 10 : 25;
|
const itemWidth = this.isMobile ? 10 : 25;
|
||||||
const itemHeight = this.isMobile ? 10 : 14;
|
const itemHeight = this.isMobile ? 10 : 14;
|
||||||
@@ -228,28 +233,22 @@
|
|||||||
});
|
});
|
||||||
// 设置图表配置项
|
// 设置图表配置项
|
||||||
const option = {
|
const option = {
|
||||||
// 全局调色盘
|
|
||||||
color: this.colors,
|
color: this.colors,
|
||||||
// 背景颜色
|
|
||||||
backgroundColor: backgroundColor,
|
backgroundColor: backgroundColor,
|
||||||
// 文字样式
|
|
||||||
textStyle: {
|
textStyle: {
|
||||||
fontSize: fontSize,
|
fontSize: fontSize,
|
||||||
color: fontColor
|
color: fontColor
|
||||||
},
|
},
|
||||||
// 图表网格设置
|
|
||||||
grid: {
|
grid: {
|
||||||
top: gridTop,
|
top: gridTop,
|
||||||
left: gridLeft,
|
left: gridLeft,
|
||||||
right: gridRight
|
right: gridRight,
|
||||||
|
bottom: gridBottom
|
||||||
},
|
},
|
||||||
// 图表标题设置
|
|
||||||
title: {
|
title: {
|
||||||
show: false,
|
show: false,
|
||||||
},
|
},
|
||||||
// 图表系列数据设置
|
|
||||||
series: seriesData.flat(),
|
series: seriesData.flat(),
|
||||||
// X轴设置
|
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: 'time',
|
type: 'time',
|
||||||
axisLabel: {
|
axisLabel: {
|
||||||
@@ -258,7 +257,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Y轴设置
|
|
||||||
yAxis: {
|
yAxis: {
|
||||||
type: 'value',
|
type: 'value',
|
||||||
axisLabel: {
|
axisLabel: {
|
||||||
@@ -268,12 +266,10 @@
|
|||||||
},
|
},
|
||||||
splitLine: {
|
splitLine: {
|
||||||
lineStyle: {
|
lineStyle: {
|
||||||
width: splitLineWidth,
|
width: splitLineWidth
|
||||||
color: splitLineColor
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 图例设置
|
|
||||||
legend: {
|
legend: {
|
||||||
data: legendData,
|
data: legendData,
|
||||||
show: true,
|
show: true,
|
||||||
@@ -289,7 +285,6 @@
|
|||||||
itemWidth: itemWidth,
|
itemWidth: itemWidth,
|
||||||
itemHeight: itemHeight,
|
itemHeight: itemHeight,
|
||||||
},
|
},
|
||||||
// 提示框设置
|
|
||||||
tooltip: {
|
tooltip: {
|
||||||
trigger: 'axis',
|
trigger: 'axis',
|
||||||
backgroundColor: tooltipBackgroundColor,
|
backgroundColor: tooltipBackgroundColor,
|
||||||
@@ -312,7 +307,6 @@
|
|||||||
return tooltipContent;
|
return tooltipContent;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 数据缩放设置
|
|
||||||
dataZoom: [
|
dataZoom: [
|
||||||
{
|
{
|
||||||
type: 'slider',
|
type: 'slider',
|
||||||
@@ -321,17 +315,16 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
// 设置图表的配置选项
|
setTimeout(() => {
|
||||||
this.chart.setOption(option);
|
this.chart.hideLoading();
|
||||||
|
this.chart.setOption(option);
|
||||||
|
}, 1000);
|
||||||
},
|
},
|
||||||
reloadCharts() { // 重新加载所有图表
|
reloadCharts() {
|
||||||
this.servers.forEach(node => {
|
const chartData = this.chartDataList[this.currentServerId];
|
||||||
const id = node.ID;
|
if (chartData) {
|
||||||
const chartData = this.chartDataList[id];
|
this.renderCharts(this.currentServerId,true);
|
||||||
if (chartData) {
|
}
|
||||||
this.renderCharts(id,true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
disposeCharts(chart){
|
disposeCharts(chart){
|
||||||
chart.dispose();
|
chart.dispose();
|
||||||
@@ -341,6 +334,16 @@
|
|||||||
const result = this.servers.find(item => item.ID == id);
|
const result = this.servers.find(item => item.ID == id);
|
||||||
return result.Host.CountryCode ? result.Host.CountryCode : 'rb';
|
return result.Host.CountryCode ? result.Host.CountryCode : 'rb';
|
||||||
},
|
},
|
||||||
|
getNextServerId(id) {
|
||||||
|
const currentIndex = this.servers.findIndex(item => item.ID === id);
|
||||||
|
if (currentIndex === -1) {
|
||||||
|
return this.servers[0].ID;
|
||||||
|
}
|
||||||
|
// 判断是否有下一个元素
|
||||||
|
const nextIndex = currentIndex + 1;
|
||||||
|
// 如果有下一个元素,返回下一个元素的 ID;否则返回第一个元素的 ID
|
||||||
|
return nextIndex < this.servers.length ? this.servers[nextIndex].ID : this.servers[0].ID;
|
||||||
|
},
|
||||||
initSearch() {
|
initSearch() {
|
||||||
$('#dropdown-search').on('keyup', function() {
|
$('#dropdown-search').on('keyup', function() {
|
||||||
var searchTerm = $(this).val().toLowerCase();
|
var searchTerm = $(this).val().toLowerCase();
|
||||||
|
|||||||
+10
-10
@@ -3,24 +3,24 @@
|
|||||||
{{template "theme-server-status/menu" .}}
|
{{template "theme-server-status/menu" .}}
|
||||||
<!-- showGroup true -->
|
<!-- showGroup true -->
|
||||||
<template v-if="showGroup">
|
<template v-if="showGroup">
|
||||||
<section v-if="servicesTag.length === 0" class="container-fluid content" style="min-height: .01%;overflow-x: auto;">
|
<div v-if="servicesTag.length === 0" class="container-fluid content" style="min-height: .01%;overflow-x: auto;">
|
||||||
<p>No Valid Service Monitor Configuration Entries Found. Please Verify in the <a href="/monitor">Admin Panel</a>.</p>
|
<p>No Valid Service Monitor Configuration Entries Found. Please Verify in the <a href="/monitor">Admin Panel</a>.</p>
|
||||||
</section>
|
</div>
|
||||||
<section v-else class="container-fluid content" style="min-height: .01%;overflow-x: auto;" v-for="group in servicesTag">
|
<div v-else class="container-fluid content" style="min-height: .01%;overflow-x: auto;" v-for="group in servicesTag">
|
||||||
{{template "theme-server-status/service-group-true" .}}
|
{{template "theme-server-status/service-group-true" .}}
|
||||||
</section>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<!-- showGroup false -->
|
<!-- showGroup false -->
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<section v-if="servicesNoTag.length === 0" class="container-fluid content" style="min-height: .01%;overflow-x: auto;">
|
<div v-if="servicesNoTag.length === 0" class="container-fluid content" style="min-height: .01%;overflow-x: auto;">
|
||||||
<p>No Valid Service Monitor Configuration Entries Found. Please Verify in the <a href="/monitor">Admin Panel</a>.</p>
|
<p>No Valid Service Monitor Configuration Entries Found. Please Verify in the <a href="/monitor">Admin Panel</a>.</p>
|
||||||
</section>
|
</div>
|
||||||
<section v-else class="container-fluid content" style="min-height: .01%;overflow-x: auto;">
|
<div v-else class="container-fluid content" style="min-height: .01%;overflow-x: auto;">
|
||||||
{{template "theme-server-status/service-group-false" .}}
|
{{template "theme-server-status/service-group-false" .}}
|
||||||
</section>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
{{if .CycleTransferStats}}
|
{{if .CycleTransferStats}}
|
||||||
<section class="container-fluid content table-responsive">
|
<div class="container-fluid content table-responsive">
|
||||||
<table class="table table-striped table-condensed table-hover">
|
<table class="table table-striped table-condensed table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="node-group-tag">
|
<tr class="node-group-tag">
|
||||||
@@ -67,7 +67,7 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</section>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{template "theme-server-status/footer" .}}
|
{{template "theme-server-status/footer" .}}
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
+2
-2
@@ -12,7 +12,7 @@ NZ_DASHBOARD_PATH="${NZ_BASE_PATH}/dashboard"
|
|||||||
NZ_AGENT_PATH="${NZ_BASE_PATH}/agent"
|
NZ_AGENT_PATH="${NZ_BASE_PATH}/agent"
|
||||||
NZ_DASHBOARD_SERVICE="/etc/systemd/system/nezha-dashboard.service"
|
NZ_DASHBOARD_SERVICE="/etc/systemd/system/nezha-dashboard.service"
|
||||||
NZ_DASHBOARD_SERVICERC="/etc/init.d/nezha-dashboard"
|
NZ_DASHBOARD_SERVICERC="/etc/init.d/nezha-dashboard"
|
||||||
NZ_VERSION="v0.18.3"
|
NZ_VERSION="v0.19.0"
|
||||||
|
|
||||||
red='\033[0;31m'
|
red='\033[0;31m'
|
||||||
green='\033[0;32m'
|
green='\033[0;32m'
|
||||||
@@ -604,7 +604,7 @@ restart_and_update_standalone() {
|
|||||||
NZ_DASHBOARD_URL="https://${GITHUB_URL}/naibahq/nezha/releases/download/$version/dashboard-linux-$os_arch.zip"
|
NZ_DASHBOARD_URL="https://${GITHUB_URL}/naibahq/nezha/releases/download/$version/dashboard-linux-$os_arch.zip"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo wget -qO $NZ_DASHBOARD_PATH/app.zip $NZ_DASHBOARD_URL >/dev/null 2>&1 && sudo unzip -qq $NZ_DASHBOARD_PATH/app.zip -d $NZ_DASHBOARD_PATH && sudo mv $NZ_DASHBOARD_PATH/dist/dashboard-linux-$os_arch $NZ_DASHBOARD_PATH/app && sudo rm -r $NZ_DASHBOARD_PATH/app.zip $NZ_DASHBOARD_PATH/dist
|
sudo wget -qO $NZ_DASHBOARD_PATH/app.zip $NZ_DASHBOARD_URL >/dev/null 2>&1 && sudo unzip -qq -o $NZ_DASHBOARD_PATH/app.zip -d $NZ_DASHBOARD_PATH && sudo mv $NZ_DASHBOARD_PATH/dashboard-linux-$os_arch $NZ_DASHBOARD_PATH/app && sudo rm $NZ_DASHBOARD_PATH/app.zip
|
||||||
|
|
||||||
if [ "$os_alpine" != 1 ]; then
|
if [ "$os_alpine" != 1 ]; then
|
||||||
sudo systemctl enable nezha-dashboard
|
sudo systemctl enable nezha-dashboard
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ NZ_DASHBOARD_PATH="${NZ_BASE_PATH}/dashboard"
|
|||||||
NZ_AGENT_PATH="${NZ_BASE_PATH}/agent"
|
NZ_AGENT_PATH="${NZ_BASE_PATH}/agent"
|
||||||
NZ_DASHBOARD_SERVICE="/etc/systemd/system/nezha-dashboard.service"
|
NZ_DASHBOARD_SERVICE="/etc/systemd/system/nezha-dashboard.service"
|
||||||
NZ_DASHBOARD_SERVICERC="/etc/init.d/nezha-dashboard"
|
NZ_DASHBOARD_SERVICERC="/etc/init.d/nezha-dashboard"
|
||||||
NZ_VERSION="v0.18.3"
|
NZ_VERSION="v0.19.0"
|
||||||
|
|
||||||
red='\033[0;31m'
|
red='\033[0;31m'
|
||||||
green='\033[0;32m'
|
green='\033[0;32m'
|
||||||
@@ -598,7 +598,7 @@ restart_and_update_standalone() {
|
|||||||
NZ_DASHBOARD_URL="https://${GITHUB_URL}/naibahq/nezha/releases/download/$version/dashboard-linux-$os_arch.zip"
|
NZ_DASHBOARD_URL="https://${GITHUB_URL}/naibahq/nezha/releases/download/$version/dashboard-linux-$os_arch.zip"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo wget -qO $NZ_DASHBOARD_PATH/app.zip $NZ_DASHBOARD_URL >/dev/null 2>&1 && sudo unzip -qq $NZ_DASHBOARD_PATH/app.zip -d $NZ_DASHBOARD_PATH && sudo mv $NZ_DASHBOARD_PATH/dist/dashboard-linux-$os_arch $NZ_DASHBOARD_PATH/app && sudo rm -r $NZ_DASHBOARD_PATH/app.zip $NZ_DASHBOARD_PATH/dist
|
sudo wget -qO $NZ_DASHBOARD_PATH/app.zip $NZ_DASHBOARD_URL >/dev/null 2>&1 && sudo unzip -qq -o $NZ_DASHBOARD_PATH/app.zip -d $NZ_DASHBOARD_PATH && sudo mv $NZ_DASHBOARD_PATH/dashboard-linux-$os_arch $NZ_DASHBOARD_PATH/app && sudo rm $NZ_DASHBOARD_PATH/app.zip
|
||||||
|
|
||||||
if [ "$os_alpine" != 1 ]; then
|
if [ "$os_alpine" != 1 ]; then
|
||||||
sudo systemctl enable nezha-dashboard
|
sudo systemctl enable nezha-dashboard
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package rpc
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -14,6 +15,18 @@ type ioStreamContext struct {
|
|||||||
agentIoConnectCh chan struct{}
|
agentIoConnectCh chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type bp struct {
|
||||||
|
buf []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
var bufPool = sync.Pool{
|
||||||
|
New: func() any {
|
||||||
|
return &bp{
|
||||||
|
buf: make([]byte, 1024*1024),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
func (s *NezhaHandler) CreateStream(streamId string) {
|
func (s *NezhaHandler) CreateStream(streamId string) {
|
||||||
s.ioStreamMutex.Lock()
|
s.ioStreamMutex.Lock()
|
||||||
defer s.ioStreamMutex.Unlock()
|
defer s.ioStreamMutex.Unlock()
|
||||||
@@ -117,7 +130,9 @@ LOOP:
|
|||||||
endCh := make(chan struct{})
|
endCh := make(chan struct{})
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
_, innerErr := io.CopyBuffer(stream.userIo, stream.agentIo, make([]byte, 1048576))
|
bp := bufPool.Get().(*bp)
|
||||||
|
defer bufPool.Put(bp)
|
||||||
|
_, innerErr := io.CopyBuffer(stream.userIo, stream.agentIo, bp.buf)
|
||||||
if innerErr != nil {
|
if innerErr != nil {
|
||||||
err = innerErr
|
err = innerErr
|
||||||
}
|
}
|
||||||
@@ -126,7 +141,9 @@ LOOP:
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
go func() {
|
go func() {
|
||||||
_, innerErr := io.CopyBuffer(stream.agentIo, stream.userIo, make([]byte, 1048576))
|
bp := bufPool.Get().(*bp)
|
||||||
|
defer bufPool.Put(bp)
|
||||||
|
_, innerErr := io.CopyBuffer(stream.agentIo, stream.userIo, bp.buf)
|
||||||
if innerErr != nil {
|
if innerErr != nil {
|
||||||
err = innerErr
|
err = innerErr
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user