Skip to content

Commit a9b9108

Browse files
authored
Updated frontend from thebilly (#1)
1 parent 95044a8 commit a9b9108

File tree

3 files changed

+62
-68
lines changed

3 files changed

+62
-68
lines changed

cloud-sql/servlet/src/main/java/com/example/cloudsql/ConnectionPoolContextListener.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private DataSource createConnectionPool(){
4545

4646
// Configure the Cloud SQL JDBC Socket Factory to provide authentication
4747
config.addDataSourceProperty("socketFactory", "com.google.cloud.sql.mysql.SocketFactory");
48-
config.addDataSourceProperty("cloudSqlInstance", "kvg-testing:us-central1:test1");
48+
config.addDataSourceProperty("cloudSqlInstance", "first-bigtable-dashboard:us-central1:myinstance");
4949
config.addDataSourceProperty("useSSL", "false");
5050

5151
config.setMaximumPoolSize(5); // Limit the maximum number of connections

cloud-sql/servlet/src/main/webapp/css/index.css

-35
This file was deleted.

cloud-sql/servlet/src/main/webapp/index.jsp

+61-32
Original file line numberDiff line numberDiff line change
@@ -19,55 +19,84 @@ limitations under the License.
1919
<html lang="en">
2020
<head>
2121
<title>Tabs VS Spaces</title>
22-
<link rel="stylesheet" type="text/css" href="css/index.css">
22+
<link rel="stylesheet"
23+
href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
24+
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
2325
</head>
2426
<body>
25-
<div id="main" >
26-
<aside> </aside>
27-
<article>
28-
<div id="title">
29-
<h1 class="tabs">TABS</h1>
30-
<p>vs</p>
31-
<h1 class="spaces">SPACES</h1>
32-
</div>
33-
<div id="tally">
34-
<p id="tabs-tally">Tabs: <%= request.getAttribute("tabVoteCt") %></p>
35-
<p id="spaces-tally">Spaces: <%= request.getAttribute("spaceVoteCt") %></p>
36-
<p id="winner">Currently <b><%= request.getAttribute("winningTeam") %></b> is winning by <%= request.getAttribute("voteDiff") %> votes</p>
27+
<nav>
28+
<div class="nav-wrapper">
29+
<a href="#" class="brand-logo center">Tabs vs. Spaces</a>
30+
</div>
31+
</nav>
32+
33+
<%
34+
String tabsWinning = "";
35+
if (request.getAttribute("winningTeam") == "TABS") {
36+
tabsWinning = "green lighten-4";
37+
}
38+
String spacesWinning = "";
39+
if (request.getAttribute("winningTeam") == "SPACES") {
40+
spacesWinning = "green lighten-4";
41+
}
42+
%>
43+
<div class="section">
44+
<div class="row center">
45+
<div class="col s6 m5 offset-m1">
46+
<div class="card-panel <%= tabsWinning %>">
47+
<h3>Tabs</h3>
48+
<h3><%= request.getAttribute("tabVoteCt") %></h3>
3749
</div>
38-
<div id="history">
39-
<%
40-
List<String> votesTeam = (List<String>) request.getAttribute("votesTeam");
41-
List<Timestamp> votesTs = (List<Timestamp>) request.getAttribute("votesTs");
42-
for(int i = 0; i < votesTeam.size(); i+=1) { %>
43-
<div><%= votesTeam.get(i) %> received vote at <%= votesTs.get(i) %>. </div>
44-
<% } %>
50+
</div>
51+
<div class="col s6 m5">
52+
<div class="card-panel <%= spacesWinning %>">
53+
<h3>Spaces</h3>
54+
<h3><%= request.getAttribute("spaceVoteCt") %></h3>
4555
</div>
46-
<button id="voteTabs" type="button">Vote for tabs!</button>
47-
<button id="voteSpaces" type="button">Vote for spaces!</button>
48-
</article>
49-
<aside> </aside>
56+
</div>
5057
</div>
58+
</div>
59+
<div class="section center">
60+
<h4>Currently, <%= request.getAttribute("winningTeam") %> is winning by
61+
<%= request.getAttribute("voteDiff") %> votes</h4>
62+
<h4>Vote for your favorite:</h4>
63+
<button id="voteTabs" class="btn">tabs</button>
64+
<button id="voteSpaces" class="btn">spaces</button>
65+
</div>
66+
67+
<ul class="collection with-header">
68+
<li class="collection-header"><h4>Votes</h4></li>
69+
<%
70+
List<String> votesTeam = (List<String>) request.getAttribute("votesTeam");
71+
List<Timestamp> votesTs = (List<Timestamp>) request.getAttribute("votesTs");
72+
for (int i = 0; i < votesTeam.size(); i += 1) { %>
73+
<li class="collection-item"><div><%= votesTeam.get(i) %> received vote at <%= votesTs.get(i) %></div></li>
74+
<% } %>
75+
</ul>
5176
</body>
5277
<footer>
5378
<script>
54-
function vote(team){
79+
function vote(team) {
5580
var xhr = new XMLHttpRequest();
56-
xhr.onreadystatechange = function() {
81+
xhr.onreadystatechange = function () {
5782
var msg = "";
58-
if (this.readyState == 4){
59-
if(!window.alert(this.responseText)){
83+
if (this.readyState == 4) {
84+
if (!window.alert(this.responseText)) {
6085
window.location.reload();
6186
}
6287
}
6388
};
64-
xhr.open("POST","/", true);
89+
xhr.open("POST", "/", true);
6590
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
66-
xhr.send("team="+team);
91+
xhr.send("team=" + team);
6792
}
6893
69-
document.getElementById("voteTabs").addEventListener("click", function() { vote("tabs"); });
70-
document.getElementById("voteSpaces").addEventListener("click", function() { vote("spaces"); });
94+
document.getElementById("voteTabs").addEventListener("click", function () {
95+
vote("tabs");
96+
});
97+
document.getElementById("voteSpaces").addEventListener("click", function () {
98+
vote("spaces");
99+
});
71100
</script>
72101
</footer>
73102
</html>

0 commit comments

Comments
 (0)