Skip to content

Commit aece681

Browse files
committed
change color gradients for web agents, dropdown select
1 parent 789da1d commit aece681

File tree

1 file changed

+67
-3
lines changed

1 file changed

+67
-3
lines changed

ui/gauge.html

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77
<body style="display: flex; justify-content: center; align-items: center; width: 100vw; height: 100vh; margin: 0;">
88
<div id="app" style="display: flex; width: 67%; height: 67%; flex-direction: column;">
99
</div>
10+
11+
<div>
12+
<label for="agents">Choose a web agent:</label>
13+
14+
<select name="agents" id="web_agent_select" onchange="update(this.value)">
15+
<option value="/unit/master" style = "color:#50e3c2">/unit/master</option>
16+
<option value="/unit/secondAgent" style = "color:#3c52f0">/unit/secondAgent</option>
17+
<option value="/unit/thirdAgent" style = "color:#212326">/unit/thirdAgent</option>
18+
</select>
19+
</div>
20+
1021
<script src="https://cdn.swimos.org/js/3.10.2/swim-system.js"></script>
1122
<script>
1223

@@ -39,20 +50,30 @@
3950
.label("BAZ");
4051
gauge.setChildView("baz", bazDial);
4152

53+
var colorLow = "#50e3c2";
54+
var colorMed = "#359680";
55+
var colorHigh = "#1f5c4e"
56+
4257
function updateDial(dial, max, key, value) {
4358
const v = value.get(key).numberValue();
4459
const percent = v / max;
4560
const legend = key + ": " + (v) + " out of " + max;
4661
dial.value(v, tween)
4762
.total(max)
48-
.meterColor(percent < 0.5 ? "#989898" : percent < 0.9 ? "#4a4a4a" : "#000000", tween);
63+
.meterColor(percent < 0.5 ? colorLow : percent < 0.9 ? colorMed : colorHigh, tween);
4964
dial.label().text(legend);
5065
}
5166

67+
68+
// switching between web agents
69+
var agent_URI = "/unit/master";
70+
5271
/* Data Subscriptions */
53-
const valueLink = swim.downlinkValue()
72+
73+
// runs once
74+
var valueLink = swim.downlinkValue()
5475
.hostUri("warp://localhost:9001")
55-
.nodeUri("/unit/master")
76+
.nodeUri(agent_URI)
5677
.laneUri("latest")
5778
.didSet(function (value) {
5879
updateDial(fooDial, 70, "foo", value);
@@ -61,6 +82,49 @@
6182
})
6283
.open();
6384

85+
86+
// update logic runs whenever a new dropdown option is selected
87+
function update(val) {
88+
if (valueLink) {
89+
// close downlink on update
90+
valueLink.close();
91+
92+
// update the node URI used in histogramLink to match the selected agent
93+
agent_URI = document.getElementById('web_agent_select').value;
94+
console.log(agent_URI);
95+
96+
valueLink = swim.downlinkValue()
97+
.hostUri("warp://localhost:9001")
98+
.nodeUri(agent_URI)
99+
.laneUri("latest")
100+
.didSet(function (value) {
101+
updateDial(fooDial, 70, "foo", value);
102+
updateDial(barDial, 140, "bar", value);
103+
updateDial(bazDial, 210, "baz", value);
104+
})
105+
.open();
106+
107+
// switch statement that changes the plot color according to web agent
108+
switch(agent_URI) {
109+
case "/unit/secondAgent":
110+
colorLow = "#3c52f0";
111+
colorMed = "#182373";
112+
colorHigh = "#0b1347"
113+
break;
114+
case "/unit/thirdAgent":
115+
colorLow = "#d5d9e0";
116+
colorMed = "#6d7178";
117+
colorHigh = "#000000"
118+
break;
119+
default:
120+
// for master web agent
121+
colorLow = "#50e3c2";
122+
colorMed = "#359680";
123+
colorHigh = "#1f5c4e"
124+
}
125+
}
126+
}
127+
64128
</script>
65129
</body>
66130
</html>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy