diff options
Diffstat (limited to 'app/views/matches/index.html.erb')
-rw-r--r-- | app/views/matches/index.html.erb | 59 |
1 files changed, 44 insertions, 15 deletions
diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index 8d699f9..031b2a9 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -1,30 +1,24 @@ -<h1>Listing matches</h1> +<h1><%= @tournament.name %> - Matches</h1> -<table> + +<table class="table"> <thead> <tr> <th>Status</th> - <th>Tournament</th> <th>Name</th> <th>Winner</th> - <th>Remote</th> - <th></th> - <th></th> <th></th> </tr> </thead> - <tbody> - <% @matches.each do |match| %> + <tbody class="table-hover"> + <% @tournament.matches.each do |match| %> <tr> <td><%= match.status %></td> - <td><%= match.tournament %></td> + <td><%= match.id%></td> <td><%= match.name %></td> - <td><%= match.winner %></td> - <td><%= match.remote_id %></td> - <td><%= link_to 'Show', match %></td> - <td><%= link_to 'Edit', edit_match_path(match) %></td> - <td><%= link_to 'Destroy', match, method: :delete, data: { confirm: 'Are you sure?' } %></td> + <td><%= link_to "Show", tournament_match_path(@tournament, match) %> + <td><%= submit_tag("Start Match") %> </tr> <% end %> </tbody> @@ -32,4 +26,39 @@ <br> -<%= link_to 'New Match', new_match_path %> +<div id="match-tree"> +<SVG version="1.1" + baseProfile="full" + width="<%= @width %>" height="<%= @height = [@height, 500].max %>" + xmlns="http://www.w3.org/2000/svg"> + <line x1="300" y1="0" x2="300" y2="<%= @height %>" stroke="black" /> + <% (1..@matches.count).each do |i| %> + <g class="svg-match"> + <rect height="120px" width="213px" + x="<%= @width - (i-1)*50 - 250*(Math.log2(i).floor+1) %>" + y="<%= (@height/(Math.log2(i).floor+2)) - 60 + 250*(i - 2**(Math.log2(i).floor)) %>" + fill="#ffd281" + rx="20px" + stroke-width="2" + <% case @matches[i-1].status %> + <% when 0 %> + <% if @matches[i-1].teams.count < @tournament.min_teams_per_match %> + stroke="red" + fill-opacity="0.6" + <% else %> + stroke="green" + <% end %> + <% when 1 %> + stroke="orange" + <% when 2 %> + stroke="yellow" + <% when 3 %> + stroke="grey" + <% end %> + /> + </g> + <% end %> + + +</SVG> +</div>
\ No newline at end of file |