<%#
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008-2009 Jo-Philipp Wich <xm@subsignal.org>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0
-%>

<h2><%:Upgrade firmware%></h2>

<p>
  <%:The firmware image has been transmitted. Please ensure the SHA-256 checksum and image size are correct and click "continue".%>
</p>

<% if flashsize > 0 and filesize > flashsize then %>
<p class="error"><%:The firmware is too big for your device's storage.%></p>
<% end %>

<p>
  <ul>
    <li>sha256sum: <code><%=checksum%></code></li>
    <li><%:Size%>: <%
      function byte_format(byte)
        local suff = {"B", "KB", "MB", "GB", "TB"}
        for i=1, 5 do
          if byte > 1024 and i < 5 then
            byte = byte / 1024
          else
            return string.format("%.2f %s", byte, suff[i])
          end
        end
      end

      write(byte_format(filesize))

      if flashsize > 0 then
        write(translatef(
          " (%s available)",
          byte_format(flashsize)
        ))
      end
    %></li>
  </ul>
</p>
<div class="gluon-page-actions">
  <form method="post" enctype="multipart/form-data" action="<%|url(request)%>" style="display:inline">
    <input type="hidden" name="step" value="3" />
    <input type="hidden" name="keepcfg" value="<%=keepconfig and "1" or "0"%>" />
    <input type="hidden" name="token" value="<%=token%>" />
    <input class="gluon-button gluon-button-submit" type="submit" value="<%:Continue%>" />
  </form>
  <form method="post" enctype="multipart/form-data" action="<%|url(request)%>" style="display:inline">
    <input type="hidden" name="step" value="1" />
    <input type="hidden" name="keepcfg" value="<%=keepconfig and "1" or "0"%>" />
    <input type="hidden" name="token" value="<%=token%>" />
    <input class="gluon-button gluon-button-reset" type="submit" value="<%:Cancel%>" />
  </form>
</div>
