You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by oc...@apache.org on 2020/08/12 17:08:59 UTC

[trafficcontrol] branch master updated: Add indicator when using a UI backup (#4925)

This is an automated email from the ASF dual-hosted git repository.

ocket8888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new 62b8121  Add indicator when using a UI backup (#4925)
62b8121 is described below

commit 62b81210ebcf598b9daf35e17c847ad166d092bb
Author: Steve Hamrick <sh...@users.noreply.github.com>
AuthorDate: Wed Aug 12 11:08:49 2020 -0600

    Add indicator when using a UI backup (#4925)
    
    * Add indicator when using a UI backup
    
    * Clean up, fix typo, fix spacing
    
    * more whitespace
    
    * Remove cursor
    
    * Clean up code
---
 CHANGELOG.md                         |  1 +
 traffic_monitor/handler/handler.go   |  1 +
 traffic_monitor/manager/opsconfig.go |  3 ++
 traffic_monitor/static/index.html    |  4 +++
 traffic_monitor/static/script.js     | 10 ++++++-
 traffic_monitor/static/style.css     | 58 ++++++++++++++++++++++++++++++++++++
 6 files changed, 76 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index ab40f6e..473522d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -32,6 +32,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
 - Updated /deliveryservices/{{ID}}/servers to use multiple interfaces in API v3
 - Updated /deliveryservices/{{ID}}/servers/eligible to use multiple interfaces in API v3
 - Added the ability to view Hash ID field (aka xmppID) on Traffic Portals' server summary page
+- Added an indiciator to the Traffic Monitor UI when using a disk backup of Traffic ops.
 - Added debugging functionality to CDN-in-a-Box for Traffic Stats.
 
 ### Fixed
diff --git a/traffic_monitor/handler/handler.go b/traffic_monitor/handler/handler.go
index 319210c..34e903b 100644
--- a/traffic_monitor/handler/handler.go
+++ b/traffic_monitor/handler/handler.go
@@ -40,6 +40,7 @@ type OpsConfig struct {
 	HttpsListener string `json:"httpsListener"`
 	CertFile      string `json:"certFile"`
 	KeyFile       string `json:"keyFile"`
+	UsingDummyTO  bool   `json:"usingDummyTO"`
 }
 
 type Handler interface {
diff --git a/traffic_monitor/manager/opsconfig.go b/traffic_monitor/manager/opsconfig.go
index 9a90bbf..eecca61 100644
--- a/traffic_monitor/manager/opsconfig.go
+++ b/traffic_monitor/manager/opsconfig.go
@@ -193,6 +193,7 @@ func StartOpsConfigManager(
 					toSession.Set(realToSession)
 					// At this point we have a valid 'dummy' session. This will allow us to pull from disk but will also retry when TO comes up
 					log.Errorf("error instantiating Session with traffic_ops, backup disk files exist, creating empty traffic_ops session to read")
+					newOpsConfig.UsingDummyTO = true
 					break
 				}
 
@@ -200,9 +201,11 @@ func StartOpsConfigManager(
 				continue
 			} else {
 				toSession.Set(realToSession)
+				newOpsConfig.UsingDummyTO = false
 				break
 			}
 		}
+		opsConfig.Set(newOpsConfig)
 
 		if cdn, err := getMonitorCDN(realToSession, staticAppData.Hostname); err != nil {
 			handleErr(fmt.Errorf("getting CDN name from Traffic Ops, using config CDN '%s': %s\n", newOpsConfig.CdnName, err))
diff --git a/traffic_monitor/static/index.html b/traffic_monitor/static/index.html
index ef1b851..66b38f9 100644
--- a/traffic_monitor/static/index.html
+++ b/traffic_monitor/static/index.html
@@ -65,6 +65,10 @@ under the License.
 	<!-- TODO: There's no reference to these in the script nor styling; safe to remove? -->
 	<div>Number of updates: <span>0</span></div>
 	<div>Last Val: <span>0</span></div>
+	<div id="icon-disc-holder" hidden>
+		<span class="icon-disc-tooltip">Traffic Monitor is using a disk backup of Traffic Ops</span>
+		<i id="icon-disc"></i>
+	</div>
 
 	<ul class="tabs" role="tablist">
 		<li class="tab" id="cache-states-content-tab">
diff --git a/traffic_monitor/static/script.js b/traffic_monitor/static/script.js
index e3d0391..7aabb31 100644
--- a/traffic_monitor/static/script.js
+++ b/traffic_monitor/static/script.js
@@ -108,8 +108,16 @@ function getTrafficOpsUri() {
 }
 
 function getTrafficOpsCdn() {
+	const cdnName = document.getElementById("cdn-name");
+	const discIconContainer = document.getElementById("icon-disc-holder");
 	ajax("/publish/ConfigDoc", function(r) {
-		document.getElementById("cdn-name").textContent = JSON.parse(r).cdnName || "unknown";
+		let opsConfig = JSON.parse(r);
+		cdnName.textContent = opsConfig.cdnName || "unknown";
+		if (opsConfig.usingDummyTO === false) {
+		    discIconContainer.hidden = true;
+		} else {
+			discIconContainer.hidden = false;
+		}
 	});
 }
 
diff --git a/traffic_monitor/static/style.css b/traffic_monitor/static/style.css
index 87de588..59bc487 100644
--- a/traffic_monitor/static/style.css
+++ b/traffic_monitor/static/style.css
@@ -80,6 +80,64 @@ th {
 	margin: 15px 0;
 }
 
+#icon-disc-holder {
+	width: 125px;
+	position: relative;
+	margin-top: 5px;
+}
+
+#icon-disc,
+#icon-disc::after,
+#icon-disc::before {
+	display: block;
+	box-sizing: border-box;
+	border: 2px solid;
+	border-radius: 50%
+}
+#icon-disc {
+	margin: auto;
+	border-top-color: transparent;
+	border-bottom-color: transparent;
+	transform: rotate(45deg);
+	position: relative;
+	width: 14px;
+	height: 14px;
+}
+#icon-disc-holder .icon-disc-tooltip {
+	visibility: hidden;
+	background-color: black;
+	color: #fff;
+	text-align: center;
+	border-radius: 6px;
+	padding: 5px 0;
+
+	position: absolute;
+	z-index: 1;
+	width: 125px;
+	top: 20px
+}
+
+#icon-disc-holder:hover .icon-disc-tooltip {
+	visibility: visible;
+}
+
+#icon-disc::after,
+#icon-disc::before {
+	content: "";
+	position: absolute;
+	width: 6px;
+	height: 6px;
+	top: 2px;
+	left: 2px
+}
+#icon-disc::after {
+	width: 22px;
+	height: 22px;
+	border-radius: 100%;
+	top: -6px;
+	left: -6px
+}
+
 /*****************/
 /*     Links     */
 /*****************/