Skip to content

Commit

Permalink
Add dist directory
Browse files Browse the repository at this point in the history
  • Loading branch information
syifan committed May 30, 2023
1 parent 429c5f4 commit 934cb2e
Show file tree
Hide file tree
Showing 5 changed files with 217 additions and 1 deletion.
1 change: 0 additions & 1 deletion monitoring/web/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

Expand Down
85 changes: 85 additions & 0 deletions monitoring/web/dist/assets/index-702f2fca.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions monitoring/web/dist/assets/index-d610f457.css

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions monitoring/web/dist/dist.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Package dist includes the static web pages for the monitoring tool.
package dist

import (
"embed"
"fmt"
"net/http"
"os"
"path"
"runtime"
"strings"
)

//go:embed index.html assets/*
var staticAssets embed.FS

// GetAssets returns the static assets
func GetAssets() http.FileSystem {
if isDevelopmentMode() {
_, assetPath, _, ok := runtime.Caller(1)
if !ok {
panic("error getting path")
}

assetPath = path.Join(path.Dir(assetPath), "/web")

// path := path.Join(path.Dir(filename), "../config/settings.toml")

fmt.Printf("In monitoring tool development mode, serving assets from %s\n", assetPath)

return http.Dir(assetPath)
}

return http.FS(staticAssets)
}

// isDevelopmentMode returns true if environment variable AKITA_MONITOR_DEV is
// set.
func isDevelopmentMode() bool {
evName := "AKITA_MONITOR_DEV"
evValue, exist := os.LookupEnv(evName)

if !exist {
return false
}

if strings.ToLower(evValue) == "true" || evValue == "1" {
return true
}

return false
}
75 changes: 75 additions & 0 deletions monitoring/web/dist/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<!DOCTYPE html>
<header>
<meta charset="UTF-8">
<title>Akita Monitoring Tool</title>
</header>

<script type="module" crossorigin src="/assets/index-702f2fca.js"></script>
<link rel="stylesheet" href="/assets/index-d610f457.css">

<body>

<nav id="navbar" class="navbar navbar-dark bg-dark">
<a class="navbar-brand" href="/">AkitaRTM</a>

<div class="btn-toolbar my-2 my-lg-0">
<div class="btn-group me-3 ms-3" role="group">
<button class="btn btn-primary" type="button">
<span class="resource-type">CPU</span>
<span id="cpu-usage"></span>
</button>
<button class="btn btn-primary" type="button">
<span class="resource-type">Mem</span>
<span id="mem-usage"></span>
</button>
<button id="profile-button" class="btn btn-primary"
type="button">
<i class="fa-solid fa-clock"></i>
</button>
</div>

<button class="btn btn-success" id="hang-analyzer-btn">
<i class="fa-solid fa-sign-hanging"></i>
</button>

<div class="input-group ms-3 me-2">
<button id="run-button" class="btn btn-success" type="submit">
<i class="fas fa-repeat"></i>
</button>
<button id="continue-button" class="btn btn-success"
type="submit">
<i class="fas fa-play"></i>
</button>
<button id="pause-button" class="btn btn-danger">
<i class="fas fa-pause"></i>
</button>
<label id="now-label" class="input-group-text">
</label>
</div>
</div>
</nav>

<div id="debug-tool-container" class="main-container">
<div id="left-pane" class="horizontal-block horizontal-container">
</div>
<div id="vertical-divider-left"
class="horizontal-block vertical-divider">
</div>
<div id="central-pane" class="horizontal-block horizontal-container ">
</div>
<div id="vertical-divider-right"
class="horizontal-block vertical-divider">
</div>
<div id="right-pane" class="horizontal-block horizontal-container">
</div>
</div>

<div id="monitor-group" class="monitor-group">
<div id="monitor-group-divider" class="horizontal-divider"></div>
<div id="monitor-group-container" class="monitor-group-container">
</div>
</div>

<div id="progress-bar-group" class="progress-bar-group"></div>

</body>

0 comments on commit 934cb2e

Please sign in to comment.