diff --git a/web/app/controllers/Install.java b/web/app/controllers/Install.java index f221c78207f8c584367ea419ce40981956bc94bb..b54f978fcff62b9fb4ffa26bed8b84ef0e63132e 100644 --- a/web/app/controllers/Install.java +++ b/web/app/controllers/Install.java @@ -3,6 +3,10 @@ package controllers; import java.io.*; import java.util.ArrayList; +import java.awt.*; + +import javax.swing.JOptionPane; + import play.*; import play.mvc.*; import play.data.*; @@ -11,7 +15,8 @@ import models.*; public class Install extends Controller { - private static String MAKE_PACKAGE_BIN = "/home/proinfodata/conf/make-package.sh"; + private static String MAKE_PACKAGE_BIN_L = "/home/proinfodata/conf/make-package.sh"; + private static String MAKE_PACKAGE_BIN_W = "/home/proinfodata/conf/build-windows-installer.sh"; private static String MAKE_OUTPUT_DIR = "/tmp/"; public static Result index() { @@ -31,8 +36,10 @@ public class Install extends Controller { String proxyUser = requestData.get("proxyUser"); String proxyPass = requestData.get("proxyPass"); - if ((inep == null) || (inep.length() < 6) || (inep.length() > 12)) - return badRequest("Inep inválido"); + 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()); + } School school = null; @@ -44,12 +51,22 @@ public class Install extends Controller { return internalServerError(); } - if (school == null) - return badRequest("Inep inválido"); + if (school == null) { + JOptionPane.showMessageDialog(null, "Inep Inválido", "INEP", JOptionPane.ERROR_MESSAGE); + return ok(views.html.install.index.render()); + } // build the package - String command = "sh " + MAKE_PACKAGE_BIN + " " + inep; + 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; + else + command = "sh " + MAKE_PACKAGE_BIN_W + " " + inep; + if (useProxy) { command += " " + proxyHost + " " + proxyPort + " " + proxyUser + " " + proxyPass; @@ -74,7 +91,12 @@ public class Install extends Controller { return internalServerError(); } - String filename = "agent_"+inep+".run"; + String filename = ""; + if (osLinux) + filename = "agent_"+inep+".run"; + else + filename = "ProInfoData-"+inep+".exe"; + response().setHeader("Content-Disposition", "attachment; filename="+filename); return ok(new File(MAKE_OUTPUT_DIR+filename)); } diff --git a/web/app/views/install/index.scala.html b/web/app/views/install/index.scala.html index 2b4d1c5c210f22919189230e488b8509a08b8c64..04bb303c58de436ad5ef2682c0d4efc0f90d2278 100644 --- a/web/app/views/install/index.scala.html +++ b/web/app/views/install/index.scala.html @@ -23,11 +23,6 @@ @install(scripts=scripts) { <h1 class="title">Instalação</h1> -<p class="small indent4"> -Se você está usando o Windows, para instalar o programa de -acompanhamento PROINFODATA, baixe o agente -<a href="/download/proinfodata_windows_1.0.0.exe">aqui</a>. -</p> <p class="small indent4"> Caso você esteja usando o Linux, digite o código INEP referente @@ -93,6 +88,21 @@ para maiores detalhes. </div> </div> + <div class="well form-horizontal"> + <div class="control-group"> + <label class="control-label">Qual sistema utilizado?</label> + <div class="controls"> + <label class="radio inline"> + <input type="radio" name="os" id="useLinux" value="true" checked> Linux + </label> + <label class="radio inline"> + <input type="radio" name="os" id="dontUseLinux" value="false"> Windows + </label> + </div> + </div> + </div> + + <div class="pull-right"> <input type="submit" class="btn btn-primary" value="Gerar Pacote"> </div> diff --git a/web/project/Build.scala b/web/project/Build.scala index b8b9ae4634df997671c0014cf49788e21aca46cb..6886123aef9855feea56eceaae13be6652950e2b 100644 --- a/web/project/Build.scala +++ b/web/project/Build.scala @@ -5,7 +5,7 @@ import play.Project._ object ApplicationBuild extends Build { val appName = "proinfodata-web" - val appVersion = "2.0.1" + val appVersion = "2.0.2" val appDependencies = Seq( javaCore,