Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mnakao committed Apr 28, 2024
1 parent d6a4fd0 commit c0ef6ab
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
1 change: 1 addition & 0 deletions Resource_Info/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def output()
limit = (defined_limit[user] == "unlimited")? get_resource_limit(g).to_i : defined_limit[user].to_i / 3600
usage = row[1].to_i / 3600 # NH
avail = (defined_limit[user] == "unlimited")? dashboard_resource(g).avail : limit - usage
avail = 0 if avail.to_i < 0
tmp.push([user, limit, usage, avail])
end

Expand Down
31 changes: 15 additions & 16 deletions Resource_Info/views/index.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,14 @@ input {
<table class="table table-bordered" style="border: solid 2px #888888;">
<tr>
<th style="vertical-align: middle;" rowspan="2">User</th>
<th colspan="4">Resource (NH)</th>
<% if @is_admin[i] %>
<th width="250px" style="vertical-align: middle;" rowspan="2">Change Limit</th>
<% end %>
<th colspan="5">Resource (NH)</th>
</tr>
<tr>
<th>Limit</th>
<th>Usage</th>
<th>Available</th>
<th>Ratio</th>
<th style="vertical-align: middle;">Limit</th>
<th style="vertical-align: middle;">Usage</th>
<th style="vertical-align: middle;">Available</th>
<th style="vertical-align: middle;">Ratio</th>
<th width="280px">Change Limit<br>(For only a theme manager)</th>
</tr>
<% @resource_info[i].each do |d| %>
<tr>
Expand All @@ -66,25 +64,26 @@ input {
<strong class="bar_<%= dashboard_color(ratio(usage, limit)) %>" style="width: <%= ratio(usage, limit, 100) %>%;"><%= ratio(usage, limit) %>%</strong>
</div>
</td>
<% if @is_admin[i] %>
<td>
<form action="" method="post">
<input type="hidden" name="group" value="<%= g %>" required>
<input type="hidden" name="user" value="<%= user %>" required>
<input type="number" name="volume_NH" max="<%= get_resource_limit(g).to_i %>" min="0" value="<%= limit %>" required>
<input type="submit" value="submit">
<% if @is_admin[i] %>
<input type="hidden" name="group" value="<%= g %>" required>
<input type="hidden" name="user" value="<%= user %>" required>
<input type="number" name="volume_NH" max="<%= get_resource_limit(g).to_i %>" min="0" value="<%= limit %>" required>
<input type="submit" value="submit">
<% else %>
<input type="number" name="volume_NH" max="<%= get_resource_limit(g).to_i %>" min="0" value="<%= limit %>" disabled>
<input type="submit" value="submit" disabled>
<% end %>
</form>
</td>
<% end %>
<% else %>
<td> - </td>
<td> - </td>
<td> - </td>
<td> - </td>
<% if @is_admin[i] %>
<td> - </td>
<% end %>
<% end %>
</tr>
<% end %>
</table>
Expand Down
4 changes: 2 additions & 2 deletions misc/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1083,8 +1083,8 @@ def dashboard_date()
end

def ratio(a, b, limit = NOT_USED)
if b.to_i == 0
return 0
if a.to_i > b.to_i
return 100
else
if limit != NOT_USED
v = (a.to_f * 100/ b.to_f)
Expand Down

0 comments on commit c0ef6ab

Please sign in to comment.