Display forced namespace in UI

This commit is contained in:
Andrei Pohilko
2022-11-06 16:16:36 +00:00
parent 671fa949df
commit f897c0f197
5 changed files with 21 additions and 15 deletions

View File

@@ -73,7 +73,7 @@ func configureRoutes(abortWeb utils.ControlChan, data *subproc.DataLayer, api *g
api.GET("/status", func(c *gin.Context) { api.GET("/status", func(c *gin.Context) {
c.Header("X-Application-Name", "Helm Dashboard by Komodor.io") // to identify ourselves by ourselves 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) configureHelms(api.Group("/api/helm"), data)

View File

@@ -26,11 +26,12 @@ func StartServer(version string, port int, ns string, debug bool, noTracking boo
os.Exit(1) // TODO: propagate error instead? os.Exit(1) // TODO: propagate error instead?
} }
data.VersionInfo = &subproc.VersionInfo{ data.StatusInfo = &subproc.StatusInfo{
CurVer: version, CurVer: version,
Analytics: !noTracking, Analytics: !noTracking,
LimitedToNamespace: ns,
} }
go checkUpgrade(data.VersionInfo) go checkUpgrade(data.StatusInfo)
discoverScanners(&data) discoverScanners(&data)
@@ -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" url := "https://api.github.com/repos/komodorio/helm-dashboard/releases/latest"
type GHRelease struct { type GHRelease struct {
Name string `json:"name"` Name string `json:"name"`

View File

@@ -90,7 +90,8 @@
<button class="btn btn-sm btn-light bg-white border border-secondary btn-remove"> <button class="btn btn-sm btn-light bg-white border border-secondary btn-remove">
<i class="bi-trash3"></i> Remove <i class="bi-trash3"></i> Remove
</button> </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>
<div><span class="text-muted small fw-bold me-3">REPOSITORY</span></div> <div><span class="text-muted small fw-bold me-3">REPOSITORY</span></div>
<h2 class="mb-3">name-of-repo</h2> <h2 class="mb-3">name-of-repo</h2>
@@ -120,6 +121,7 @@
<ul class="list-unstyled" id="cluster"> <ul class="list-unstyled" id="cluster">
</ul> </ul>
<h4 id="limitNamespace" class="display-none">Forced Namespace: <span></span></h4>
<!-- TODO <!-- TODO
<h4 class="mt-4">Namespaces</h4> <h4 class="mt-4">Namespaces</h4>
<ul class="list-unstyled" id="namespaces"> <ul class="list-unstyled" id="namespaces">
@@ -357,8 +359,8 @@
</label> </label>
<label class="form-label me-4 text-dark"> <label class="form-label me-4 text-dark">
Namespace (optional): Namespace (optional):
<input type="text" class="form-control rel-ns" list="ns-datalist"/> <input type="text" class="form-control rel-ns" list="ns-datalist"/>
<datalist id="ns-datalist"></datalist> <datalist id="ns-datalist"></datalist>
</label> </label>
<label class="form-label me-4 text-dark"> <label class="form-label me-4 text-dark">
Cluster: <span class="form-label rel-cluster"></span> Cluster: <span class="form-label rel-cluster"></span>
@@ -391,7 +393,8 @@
<div id="upgradeModalBody" class="small"></div> <div id="upgradeModalBody" class="small"></div>
</form> </form>
<div class="modal-footer d-flex"> <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> <button type="button" class="btn btn-primary btn-confirm">Confirm</button>
</div> </div>
</div> </div>

View File

@@ -29,6 +29,7 @@ $(function () {
reportError("Failed to get tool version", xhr) reportError("Failed to get tool version", xhr)
}).done(function (data) { }).done(function (data) {
fillToolVersion(data) fillToolVersion(data)
$("#limitNamespace").show().find("span").text(data.LimitedToNamespace)
}) })
}) })

View File

@@ -26,14 +26,15 @@ type DataLayer struct {
Helm string Helm string
Kubectl string Kubectl string
Scanners []Scanner Scanners []Scanner
VersionInfo *VersionInfo StatusInfo *StatusInfo
Namespace string Namespace string
} }
type VersionInfo struct { type StatusInfo struct {
CurVer string CurVer string
LatestVer string LatestVer string
Analytics bool Analytics bool
LimitedToNamespace string
} }
func (d *DataLayer) runCommand(cmd ...string) (string, error) { func (d *DataLayer) runCommand(cmd ...string) (string, error) {