From 6e78fb725f7d719a066bfcf7f1800b810c3e88fe Mon Sep 17 00:00:00 2001 From: Rohit Jnagal Date: Wed, 6 May 2015 14:46:45 -0700 Subject: [PATCH] Revert "Make all links relative." --- pages/containers.go | 16 +++------------- pages/containers_html.go | 20 ++++++++++---------- pages/pages.go | 1 - pages/static/containers_js.go | 14 +++++++------- 4 files changed, 20 insertions(+), 31 deletions(-) diff --git a/pages/containers.go b/pages/containers.go index 4d766e7a..ad083345 100644 --- a/pages/containers.go +++ b/pages/containers.go @@ -195,14 +195,12 @@ func serveContainersPage(m manager.Manager, w http.ResponseWriter, u *url.URL) e return err } - rootDir := getRootDir(cont.Name) - // Make a list of the parent containers and their links pathParts := strings.Split(string(cont.Name), "/") parentContainers := make([]link, 0, len(pathParts)) parentContainers = append(parentContainers, link{ Text: "root", - Link: path.Join(rootDir, ContainersPage), + Link: ContainersPage, }) for i := 1; i < len(pathParts); i++ { // Skip empty parts. @@ -211,7 +209,7 @@ func serveContainersPage(m manager.Manager, w http.ResponseWriter, u *url.URL) e } parentContainers = append(parentContainers, link{ Text: pathParts[i], - Link: path.Join(rootDir, ContainersPage, path.Join(pathParts[1:i+1]...)), + Link: path.Join(ContainersPage, path.Join(pathParts[1:i+1]...)), }) } @@ -223,7 +221,7 @@ func serveContainersPage(m manager.Manager, w http.ResponseWriter, u *url.URL) e } subcontainerLinks = append(subcontainerLinks, link{ Text: getContainerDisplayName(sub), - Link: path.Join(rootDir, ContainersPage, sub.Name), + Link: path.Join(ContainersPage, sub.Name), }) } @@ -241,7 +239,6 @@ func serveContainersPage(m manager.Manager, w http.ResponseWriter, u *url.URL) e MemoryAvailable: cont.Spec.HasMemory, NetworkAvailable: cont.Spec.HasNetwork, FsAvailable: cont.Spec.HasFilesystem, - Root: rootDir, } err = pageTemplate.Execute(w, data) if err != nil { @@ -251,10 +248,3 @@ func serveContainersPage(m manager.Manager, w http.ResponseWriter, u *url.URL) e glog.V(5).Infof("Request took %s", time.Since(start)) return nil } - -// Build a relative path to the root of the container page. -func getRootDir(containerName string) string { - // The root is at: container depth - levels := (strings.Count(containerName, "/")) - return strings.Repeat("../", levels) -} diff --git a/pages/containers_html.go b/pages/containers_html.go index ee652eb2..b3fdd367 100644 --- a/pages/containers_html.go +++ b/pages/containers_html.go @@ -19,23 +19,23 @@ const containersHtmlTemplate = ` cAdvisor - {{.DisplayName}} - + - + - + - - - + + + - +
-
{{if .IsRoot}} {{end}} {{if .Subcontainers}} @@ -179,7 +179,7 @@ const containersHtmlTemplate = ` {{end}}
diff --git a/pages/pages.go b/pages/pages.go index 2086f8a6..89d1c113 100644 --- a/pages/pages.go +++ b/pages/pages.go @@ -51,7 +51,6 @@ type pageData struct { MemoryAvailable bool NetworkAvailable bool FsAvailable bool - Root string } func init() { diff --git a/pages/static/containers_js.go b/pages/static/containers_js.go index 86f72a6c..45c2afdb 100644 --- a/pages/static/containers_js.go +++ b/pages/static/containers_js.go @@ -1518,21 +1518,21 @@ function drawGauges(elementId, gauges) { } // Get the machine info. -function getMachineInfo(rootDir, callback) { - $.getJSON(rootDir + "api/v1.0/machine", function(data) { +function getMachineInfo(callback) { + $.getJSON("/api/v1.0/machine", function(data) { callback(data); }); } // Get the container stats for the specified container. -function getStats(rootDir, containerName, callback) { +function getStats(containerName, callback) { // Request 60s of container history and no samples. var request = JSON.stringify({ // Update main.statsRequestedByUI while updating "num_stats" here. "num_stats": 60, "num_samples": 0 }); - $.post(rootDir + "api/v1.0/containers" + containerName, request, function(data) { + $.post("/api/v1.0/containers" + containerName, request, function(data) { callback(data); }, "json"); } @@ -1891,7 +1891,7 @@ function drawCharts(machineInfo, containerInfo) { } // Executed when the page finishes loading. -function startPage(containerName, hasCpu, hasMemory, rootDir) { +function startPage(containerName, hasCpu, hasMemory) { // Don't fetch data if we don't have any resource. if (!hasCpu && !hasMemory) { return; @@ -1902,9 +1902,9 @@ function startPage(containerName, hasCpu, hasMemory, rootDir) { window.cadvisor.firstRun = true; // Get machine info, then get the stats every 1s. - getMachineInfo(rootDir, function(machineInfo) { + getMachineInfo(function(machineInfo) { setInterval(function() { - getStats(rootDir, containerName, function(containerInfo){ + getStats(containerName, function(containerInfo){ if (window.cadvisor.firstRun && containerInfo.spec.has_filesystem) { window.cadvisor.firstRun = false; startFileSystemUsage("filesystem-usage", machineInfo, containerInfo);