diff --git a/web/app/controllers/Install.java b/web/app/controllers/Install.java index b54f978fcff62b9fb4ffa26bed8b84ef0e63132e..05bf1b9eb7d88769e86a6a246d5324c2e52839c9 100644 --- a/web/app/controllers/Install.java +++ b/web/app/controllers/Install.java @@ -5,8 +5,6 @@ import java.util.ArrayList; import java.awt.*; -import javax.swing.JOptionPane; - import play.*; import play.mvc.*; import play.data.*; @@ -20,7 +18,7 @@ public class Install extends Controller { private static String MAKE_OUTPUT_DIR = "/tmp/"; public static Result index() { - return ok(views.html.install.index.render()); + return ok(views.html.install.index.render(null,null,false,null,null,null,null,true)); } public static Result makePackage() { @@ -36,9 +34,23 @@ public class Install extends Controller { String proxyUser = requestData.get("proxyUser"); String proxyPass = requestData.get("proxyPass"); + String osStr = requestData.get("os"); + boolean osLinux = false; + if (osStr.equals("true")) osLinux = true; + + if (!osLinux) { + return ok(views.html.install.index.render( + "O pacote de instalação para Windows está temporariamente indisponível.", + inep, useProxy, + proxyHost, proxyPort, proxyUser, proxyPass, + osLinux)); + } + if ((inep == null) || (inep.length() < 6) || (inep.length() > 12)) { - JOptionPane.showMessageDialog(null, "Inep Inválido", "INEP", JOptionPane.ERROR_MESSAGE); - return ok(views.html.install.index.render()); + return ok(views.html.install.index.render( + "INEP inválido!", inep, useProxy, + proxyHost, proxyPort, proxyUser, proxyPass, + osLinux)); } School school = null; @@ -52,15 +64,13 @@ public class Install extends Controller { } if (school == null) { - JOptionPane.showMessageDialog(null, "Inep Inválido", "INEP", JOptionPane.ERROR_MESSAGE); - return ok(views.html.install.index.render()); + return ok(views.html.install.index.render( + "INEP não encontrado na base de dados!", inep, useProxy, + proxyHost, proxyPort, proxyUser, proxyPass, + osLinux)); } - // build the package - String osStr = requestData.get("os"); - boolean osLinux = false; - if (osStr.equals("true")) osLinux = true; String command = ""; if (osLinux) command = "sh " + MAKE_PACKAGE_BIN_L + " " + inep; diff --git a/web/app/views/install/index.scala.html b/web/app/views/install/index.scala.html index 04bb303c58de436ad5ef2682c0d4efc0f90d2278..97999a89c98003ed286537d30155c9548f315e4d 100644 --- a/web/app/views/install/index.scala.html +++ b/web/app/views/install/index.scala.html @@ -1,6 +1,40 @@ +@(error: String = "", + inep: String = "", + useProxy: Boolean = false, + proxyHost: String = "", + proxyPort: String = "", + proxyUser: String = "", + proxyPass: String = "", + useLinux: Boolean = true) + @scripts = { <script> (function ($) { + @if(useProxy) { + $('#useProxy').prop('checked', true); + $('#dontUseProxy').prop('checked', false); + $('.proxy').each(function () { + $(this).show(); + }); + } else { + $('#useProxy').prop('checked', false); + $('#dontUseProxy').prop('checked', true); + $('.proxy').each(function () { + $(this).hide(); + }); + } + + @if(useLinux) { + $('#useLinux').prop('checked', true); + $('#dontUseLinux').prop('checked', false); + } + + $('#inep').val("@inep"); + $('#proxyHost').val("@proxyHost"); + $('#proxyPort').val("@proxyPort"); + $('#proxyUser').val("@proxyUser"); + $('#proxyPass').val("@proxyPass"); + $('#useProxy').click(function (){ $('.proxy').each(function () { $(this).show(); @@ -12,10 +46,6 @@ $(this).hide(); }); }); - - $('.proxy').each(function () { - $(this).hide(); - }); })( jQuery ); </script> } @@ -37,6 +67,13 @@ para maiores detalhes. <div class="row-fluid main-row"> <form class="span8 offset2" action="@routes.Install.makePackage()" method="POST"> + @if(error && (!error.isEmpty())) { + <div class="alert alert-error"> + <b>Erro:</b> + @error + </div> + } + <div class="well form-horizontal"> <div class="control-group"> <label class="control-label" for="inep">INEP:</label> diff --git a/web/conf/routes b/web/conf/routes index 9b87e3d3ea62bcdddd082eaf09c7180b5eca4dda..17c5a05e31715b63096c6ac6c93dd53b2d2b9c11 100644 --- a/web/conf/routes +++ b/web/conf/routes @@ -8,7 +8,7 @@ GET / controllers.Application.index() GET /doc/ controllers.Doc.index() GET /install/ controllers.Install.index() -POST /install/make/ controllers.Install.makePackage() +POST /install/ controllers.Install.makePackage() GET /attendance/ controllers.Attendance.index()