diff --git a/build/build-demo.sh b/build/build-demo.sh new file mode 100755 index 00000000..22b2e95f --- /dev/null +++ b/build/build-demo.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash + +function build() { + ROOT=$(dirname $0) + NAME="edge-admin" + DIST=$ROOT/"../dist/${NAME}" + OS=${1} + ARCH=${2} + + if [ -z $OS ]; then + echo "usage: build.sh OS ARCH" + exit + fi + if [ -z $ARCH ]; then + echo "usage: build.sh OS ARCH" + exit + fi + + VERSION=$(lookup-version $ROOT/../internal/const/const.go) + ZIP="${NAME}-${OS}-${ARCH}-v${VERSION}.zip" + + # check edge-api + APINodeVersion=$(lookup-version $ROOT"/../../EdgeAPI/internal/const/const.go") + echo "building edge-api v${APINodeVersion} ..." + EDGE_API_BUILD_SCRIPT=$ROOT"/../../EdgeAPI/build/build.sh" + if [ ! -f $EDGE_API_BUILD_SCRIPT ]; then + echo "unable to find edge-api build script 'EdgeAPI/build/build.sh'" + exit + fi + + cd $ROOT"/../../EdgeAPI/build" + echo "==============================" + ./build.sh $OS $ARCH + echo "==============================" + cd - + + # create dir & copy files + echo "copying ..." + if [ ! -d $DIST ]; then + mkdir $DIST + mkdir $DIST/bin + mkdir $DIST/configs + mkdir $DIST/logs + fi + + cp -R $ROOT/../web $DIST/ + rm -f $DIST/web/tmp/* + cp $ROOT/configs/server.template.yaml $DIST/configs/ + + EDGE_API_ZIP_FILE=$ROOT"/../../EdgeAPI/dist/edge-api-${OS}-${ARCH}-v${APINodeVersion}.zip" + cp $EDGE_API_ZIP_FILE $DIST/ + cd $DIST/ + unzip -q $(basename $EDGE_API_ZIP_FILE) + rm -f $(basename $EDGE_API_ZIP_FILE) + cd - + + # build + echo "building "${NAME}" ..." + env GOOS=$OS GOARCH=$GOARCH go build -ldflags="-s -w" -tags demo -o $DIST/bin/${NAME} $ROOT/../cmd/edge-admin/main.go + + # zip + echo "zip files ..." + cd "${DIST}/../" || exit + if [ -f "${ZIP}" ]; then + rm -f "${ZIP}" + fi + zip -r -X -q "${ZIP}" ${NAME}/ + rm -rf ${NAME} + cd - || exit + + echo "[done]" +} + +function lookup-version() { + FILE=$1 + VERSION_DATA=$(cat $FILE) + re="Version[ ]+=[ ]+\"([0-9.]+)\"" + if [[ $VERSION_DATA =~ $re ]]; then + VERSION=${BASH_REMATCH[1]} + echo $VERSION + else + echo "could not match version" + exit + fi +} + +build $1 $2 diff --git a/internal/const/const_demo.go b/internal/const/const_demo.go new file mode 100644 index 00000000..e26718ab --- /dev/null +++ b/internal/const/const_demo.go @@ -0,0 +1,7 @@ +// +build demo + +package teaconst + +const ( + IsDemo = true +) diff --git a/internal/const/const_normal.go b/internal/const/const_normal.go new file mode 100644 index 00000000..66c42602 --- /dev/null +++ b/internal/const/const_normal.go @@ -0,0 +1,7 @@ +// +build !demo + +package teaconst + +const ( + IsDemo = false +) diff --git a/internal/web/actions/default/messages/index.go b/internal/web/actions/default/messages/index.go index 7810a266..0c02b431 100644 --- a/internal/web/actions/default/messages/index.go +++ b/internal/web/actions/default/messages/index.go @@ -46,6 +46,12 @@ func (this *IndexAction) RunGet(params struct{}) { } nodeMap := maps.Map{} + if message.Node != nil { + nodeMap = maps.Map{ + "id": message.Node.Id, + "name": message.Node.Name, + } + } messages = append(messages, maps.Map{ "id": message.Id, diff --git a/internal/web/actions/default/servers/create.go b/internal/web/actions/default/servers/create.go index b465aab0..505ba886 100644 --- a/internal/web/actions/default/servers/create.go +++ b/internal/web/actions/default/servers/create.go @@ -2,6 +2,7 @@ package servers import ( "encoding/json" + teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" @@ -109,6 +110,11 @@ func (this *CreateAction) RunPost(params struct { } } case serverconfigs.ServerTypeTCPProxy: + // 在DEMO模式下不能创建 + if teaconst.IsDemo { + this.Fail("DEMO模式下不能创建TCP反向代理") + } + listen := []*serverconfigs.NetworkAddressConfig{} err := json.Unmarshal([]byte(params.Addresses), &listen) if err != nil { diff --git a/web/public/js/components/messages/message-row.js b/web/public/js/components/messages/message-row.js index c783c037..1b0b138f 100644 --- a/web/public/js/components/messages/message-row.js +++ b/web/public/js/components/messages/message-row.js @@ -21,6 +21,10 @@ Vue.component("message-row", { | 集群:{{message.cluster.name}} + + | + 节点:{{message.node.name}} +