Skip to content

Commit

Permalink
Display forced namespace in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
undera committed Nov 6, 2022
1 parent 671fa94 commit f897c0f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pkg/dashboard/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func configureRoutes(abortWeb utils.ControlChan, data *subproc.DataLayer, api *g

api.GET("/status", func(c *gin.Context) {
c.Header("X-Application-Name", "Helm Dashboard by Komodor.io") // to identify ourselves by ourselves
c.IndentedJSON(http.StatusOK, data.VersionInfo)
c.IndentedJSON(http.StatusOK, data.StatusInfo)
})

configureHelms(api.Group("/api/helm"), data)
Expand Down
11 changes: 6 additions & 5 deletions pkg/dashboard/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ func StartServer(version string, port int, ns string, debug bool, noTracking boo
os.Exit(1) // TODO: propagate error instead?
}

data.VersionInfo = &subproc.VersionInfo{
CurVer: version,
Analytics: !noTracking,
data.StatusInfo = &subproc.StatusInfo{
CurVer: version,
Analytics: !noTracking,
LimitedToNamespace: ns,
}
go checkUpgrade(data.VersionInfo)
go checkUpgrade(data.StatusInfo)

discoverScanners(&data)

Expand Down Expand Up @@ -102,7 +103,7 @@ func discoverScanners(data *subproc.DataLayer) {
}
}

func checkUpgrade(d *subproc.VersionInfo) {
func checkUpgrade(d *subproc.StatusInfo) {
url := "https://api.github.com/repos/komodorio/helm-dashboard/releases/latest"
type GHRelease struct {
Name string `json:"name"`
Expand Down
11 changes: 7 additions & 4 deletions pkg/dashboard/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ <h4 class="fs-6">Repositories</h4>
<button class="btn btn-sm btn-light bg-white border border-secondary btn-remove">
<i class="bi-trash3"></i> Remove
</button>
<p class="my-3"><input class="form-control form-control-sm" type="text" placeholder="Filter..." id="inputSearch"></p>
<p class="my-3"><input class="form-control form-control-sm" type="text" placeholder="Filter..."
id="inputSearch"></p>
</div>
<div><span class="text-muted small fw-bold me-3">REPOSITORY</span></div>
<h2 class="mb-3">name-of-repo</h2>
Expand Down Expand Up @@ -120,6 +121,7 @@ <h4>Clusters</h4>
<ul class="list-unstyled" id="cluster">
</ul>

<h4 id="limitNamespace" class="display-none">Forced Namespace: <span></span></h4>
<!-- TODO
<h4 class="mt-4">Namespaces</h4>
<ul class="list-unstyled" id="namespaces">
Expand Down Expand Up @@ -357,8 +359,8 @@ <h4 class="modal-title" id="upgradeModalLabel">
</label>
<label class="form-label me-4 text-dark">
Namespace (optional):
<input type="text" class="form-control rel-ns" list="ns-datalist"/>
<datalist id="ns-datalist"></datalist>
<input type="text" class="form-control rel-ns" list="ns-datalist"/>
<datalist id="ns-datalist"></datalist>
</label>
<label class="form-label me-4 text-dark">
Cluster: <span class="form-label rel-cluster"></span>
Expand Down Expand Up @@ -391,7 +393,8 @@ <h4 class="modal-title" id="upgradeModalLabel">
<div id="upgradeModalBody" class="small"></div>
</form>
<div class="modal-footer d-flex">
<button type="button" class="btn btn-scan bg-white border-secondary display-none">Scan for Problems</button>
<button type="button" class="btn btn-scan bg-white border-secondary display-none">Scan for Problems
</button>
<button type="button" class="btn btn-primary btn-confirm">Confirm</button>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions pkg/dashboard/static/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ $(function () {
reportError("Failed to get tool version", xhr)
}).done(function (data) {
fillToolVersion(data)
$("#limitNamespace").show().find("span").text(data.LimitedToNamespace)
})
})

Expand Down
11 changes: 6 additions & 5 deletions pkg/dashboard/subproc/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ type DataLayer struct {
Helm string
Kubectl string
Scanners []Scanner
VersionInfo *VersionInfo
StatusInfo *StatusInfo
Namespace string
}

type VersionInfo struct {
CurVer string
LatestVer string
Analytics bool
type StatusInfo struct {
CurVer string
LatestVer string
Analytics bool
LimitedToNamespace string
}

func (d *DataLayer) runCommand(cmd ...string) (string, error) {
Expand Down

0 comments on commit f897c0f

Please sign in to comment.