From 2229b41458588a72551eaf46987b72c66518e725 Mon Sep 17 00:00:00 2001 From: Marcos Viera <mviera@fing.edu.uy> Date: Fri, 13 Aug 2021 17:49:58 -0300 Subject: [PATCH] fixes --- .../app/layout/matefun/matefun.component.ts | 2 +- .../plotter/graph2D/graph2D.component.ts | 62 ++++++++++++++----- Frontend Angular 4/src/app/shared/config.ts | 1 - Servidor JEE/WebContent/index.html | 2 +- .../java/edu/proygrado/ejb/ArchivosEJB.java | 21 ++++--- .../java/edu/proygrado/ejb/CommandsBean.java | 2 +- .../servicios/ghci/WebSocketEndpoint.java | 10 ++- addUsers.sh | 2 +- 8 files changed, 73 insertions(+), 29 deletions(-) diff --git a/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts b/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts index c92c55d6..bd70c7ff 100755 --- a/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts +++ b/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts @@ -113,7 +113,7 @@ export class MateFunComponent { }; configCodeMirrorDefinicion: any = {}; themes = ['3024-day', '3024-night', 'abcdef', 'ambiance-mobile', 'ambiance', 'base16-dark', 'base16-light', 'bespin', 'blackboard', 'cobalt', 'colorforth', 'dracula', 'duotone-dark', 'duotone-light', 'eclipse', 'elegant', 'erlang-dark', 'hopscotch', 'icecoder', 'isotope', 'lesser-dark', 'liquibyte', 'material', 'mbo', 'mdn-like', 'midnight', 'monokai', 'neat', 'neo', 'night', 'panda-syntax', 'paraiso-dark', 'paraiso-light', 'pastel-on-dark', 'railscasts', 'rubyblue', 'seti', 'solarized', 'the-matrix', 'tomorrow-night-bright', 'tomorrow-night-eighties', 'ttcn', 'twilight', 'vibrant-ink', 'xq-dark', 'xq-light', 'yeti', 'zenburn'] - version: string = "3.1.1";//npm.version; + version: string = "3.1.3";//npm.version; constructor( private haskellService: HaskellService, diff --git a/Frontend Angular 4/src/app/layout/plotter/graph2D/graph2D.component.ts b/Frontend Angular 4/src/app/layout/plotter/graph2D/graph2D.component.ts index d8ca4273..3743a4ba 100755 --- a/Frontend Angular 4/src/app/layout/plotter/graph2D/graph2D.component.ts +++ b/Frontend Angular 4/src/app/layout/plotter/graph2D/graph2D.component.ts @@ -81,7 +81,7 @@ export class Graph2DComponent { console.log(canvas.resultado) // var jsonCanvas = JSON.parse(JSONRepair(canvas.resultado)); - var jsonCanvas = JSON.parse(canvas.resultado); + var jsonCanvas = JSON.parse(canvas.resultado); var conjs = this.obtenerConjunto(jsonCanvas.funs[0]); var d = conjs + "}"; //Leo @@ -958,6 +958,7 @@ export class Graph2DComponent { } generarExpresion = function (exp) { + var expresion = ''; if (exp.kind == 'cnd') { expresion = ' (' + this.generarExpresion(exp.cond) + '?' + this.generarExpresion(exp.exp1) + ':' + this.generarExpresion(exp.exp2) + ') '; @@ -974,17 +975,24 @@ export class Graph2DComponent { } else if (exp.kind == 'uop') { expresion = ' ' + exp.op + ' ' + this.generarExpresion(exp.exp) + ' '; } else if (exp.kind == 'app') { - - if (exp.fun == 'cos') { + var mul = ''; + + if (exp.fun == 'Math.tan' || exp.fun == 'tan') { + exp.fun = 'Math.tan' + mul = '*Math.PI/180' + } else if (exp.fun == 'Math.cos' || exp.fun == 'cos') { exp.fun = 'Math.cos' - } else if (exp.fun == 'sin') { + mul = '*Math.PI/180' + } else if (exp.fun == 'Math.sin' || exp.fun == 'sin') { exp.fun = 'Math.sin' - } else if (exp.fun == 'round') { + mul = '*Math.PI/180' + } else if (exp.fun == 'red') { exp.fun = 'Math.round' }else if (exp.fun == 'sqrt'){ - exp.fun = 'Math.sqrt' - } - expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarExpresion(e)).join() + ') '; + exp.fun = 'Math.sqrt' + } + + expresion = ' ' + exp.fun + '((' + exp.args.map(e => this.generarExpresion(e)).join() + ')'+ mul +') '; } else if (exp.kind == 'tup') { @@ -1161,19 +1169,33 @@ generateFunctionAndExp = function (exp,graph,namefun6) { } else if (exp.kind == 'app') { if ((exp.fun == 'Math.cos') || (exp.fun == 'cos')) { var aux4 = []; - var aux14 = 'Math.cos('+ exp.args.map(e => this.generarExpresion(e)).join() +')'; + var aux14 = 'Math.cos(('+ exp.args.map(e => this.generarExpresion(e)).join() +')*Math.PI/180)'; var aux24 = 'N' aux4[0]= aux24; aux4[1] = aux14; myList.push(aux4); } else if ((exp.fun == 'Math.sin') || (exp.fun == 'sin')) { var aux5 = []; - var aux15 = 'Math.sin('+ exp.args.map(e => this.generarExpresion(e)).join() +')'; + var aux15 = 'Math.sin(('+ exp.args.map(e => this.generarExpresion(e)).join() +')*Math.PI/180)'; + var aux25 = 'N' + aux5[0]= aux25; + aux5[1] = aux15; + myList.push(aux5); + } else if ((exp.fun == 'Math.tan') || (exp.fun == 'tan')) { + var aux5 = []; + var aux15 = 'Math.tan(('+ exp.args.map(e => this.generarExpresion(e)).join() +')*Math.PI/180)'; var aux25 = 'N' aux5[0]= aux25; aux5[1] = aux15; myList.push(aux5); - } else if ((exp.fun == 'Math.round') || (exp.fun == 'round')){ + } else if ((exp.fun == 'Math.PI') || (exp.fun == 'pi')) { + var aux5 = []; + var aux15 = 'Math.PI'; + var aux25 = 'N' + aux5[0]= aux25; + aux5[1] = aux15; + myList.push(aux5); + } else if ((exp.fun == 'Math.round') || (exp.fun == 'red')){ var aux6 = []; var aux16 = 'Math.round('+ exp.args.map(e => this.generarExpresion(e)).join() +')'; var aux26 = 'N' @@ -1204,7 +1226,6 @@ generateFunctionAndExp = function (exp,graph,namefun6) { // aux102[1] = aux1102; // myList.push(aux102); } else if(JSON.stringify(exp.args[0]).indexOf("app") != -1){ - console.log("Entro"); exp.args[0] = this.recorrerArgumentos(exp.args[0]); var aux102 = []; var aux1102 = exp.fun+'('+ exp.args.map(e => this.generarExpresion(e)).join() +')'; @@ -1278,7 +1299,9 @@ recorrerArgumentos = function(argumento){ argumento.fun = 'Math.cos'; }else if((argumento.fun == 'Math.sin') || (argumento.fun == 'sin')){ argumento.fun = 'Math.sin'; - }else if((argumento.fun == 'Math.round') || (argumento.fun == 'round')){ + }else if((argumento.fun == 'Math.tan') || (argumento.fun == 'tan')){ + argumento.fun = 'Math.tan'; + }else if((argumento.fun == 'Math.round') || (argumento.fun == 'red')){ argumento.fun = 'Math.round'; }else if((argumento.fun == 'Math.sqrt') || (argumento.fun == 'sqrt')){ argumento.fun = 'Math.sqrt'; @@ -1350,13 +1373,20 @@ createListExp = function (exp) { if (exp.fun == 'Math.cos') { exp.fun = 'Math.cos' - expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarExpresion(e)).join() + ') '; + expresion = ' ' + exp.fun + '((' + exp.args.map(e => this.generarExpresion(e)).join() + ')*Math.PI/180) '; funcione.push(expresion) } else if (exp.fun == 'Math.sin') { exp.fun = 'Math.sin' - expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarExpresion(e)).join() + ') '; + expresion = ' ' + exp.fun + '((' + exp.args.map(e => this.generarExpresion(e)).join() + ')*Math.PI/180) '; funcione.push(expresion) + } else if (exp.fun == 'Math.tan') { + exp.fun = 'Math.tan' + expresion = ' ' + exp.fun + '((' + exp.args.map(e => this.generarExpresion(e)).join() + ')*Math.PI/180) '; + funcione.push(expresion) + } else if ((exp.fun == 'Math.PI') || (exp.fun == 'pi')) { + exp.fun = 'Math.PI' + funcione.push(exp.fun) } else if (exp.fun == 'Math.round') { exp.fun = 'Math.round' @@ -1640,7 +1670,7 @@ createListExp = function (exp) { recursionfuncion = function (func, nombre) { var fun = func[0][nombre].set; - var resul = ""; + var resul = "var z = 2;"; // PRUEBA if (fun == 'R' || fun == 'Z' || fun == 'N') { resul += this.generarF(func[0][nombre].cond); diff --git a/Frontend Angular 4/src/app/shared/config.ts b/Frontend Angular 4/src/app/shared/config.ts index 04b68e29..6185ca08 100755 --- a/Frontend Angular 4/src/app/shared/config.ts +++ b/Frontend Angular 4/src/app/shared/config.ts @@ -13,4 +13,3 @@ export const GHCI_URL = 'wss://www.fing.edu.uy/proyectos/matefun/endpoint'; // export const GHCI_URL = 'ws://localhost:8080/endpoint'; - diff --git a/Servidor JEE/WebContent/index.html b/Servidor JEE/WebContent/index.html index d5ffc291..d226dd05 100644 --- a/Servidor JEE/WebContent/index.html +++ b/Servidor JEE/WebContent/index.html @@ -1,4 +1,4 @@ <!doctype html><html><head><meta charset="utf-8"><title>Proyecto MateFun</title><base href="/proyectos/matefun/"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" type="image/x-icon" href="favicon.ico"><!-- despues lo saco de aca --><!-- <link rel="stylesheet" type="text/css" href="node_modules/codemirror/addon/hint/show-hint.css"> --><script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script><script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js" crossorigin="anonymous"></script><!-- <script src="https://wzrd.in/standalone/function-plot@1.18.1" crossorigin="anonymous"></script> - --><link href="styles.1111de0348a2a1de8dc6.bundle.css" rel="stylesheet"/></head><body><app-root><div class="loading"><div class="loading-bar"></div><div class="loading-bar"></div><div class="loading-bar"></div><div class="loading-bar"></div><div class="loading-bar"></div></div></app-root><script type="text/javascript" src="inline.b80a7a287d4af8908226.bundle.js"></script><script type="text/javascript" src="polyfills.d50ac7c762e2eb4097d9.bundle.js"></script><script type="text/javascript" src="scripts.d01654a9119059a68b2b.bundle.js"></script><script type="text/javascript" src="vendor.d3c1758890cc7548bc7b.bundle.js"></script><script type="text/javascript" src="main.d2d3c2c4a57b623a2761.bundle.js"></script></body></html> \ No newline at end of file + --><link href="styles.1111de0348a2a1de8dc6.bundle.css" rel="stylesheet"/></head><body><app-root><div class="loading"><div class="loading-bar"></div><div class="loading-bar"></div><div class="loading-bar"></div><div class="loading-bar"></div><div class="loading-bar"></div></div></app-root><script type="text/javascript" src="inline.fad0dd87d0e3ef8da6ca.bundle.js"></script><script type="text/javascript" src="polyfills.d50ac7c762e2eb4097d9.bundle.js"></script><script type="text/javascript" src="scripts.d01654a9119059a68b2b.bundle.js"></script><script type="text/javascript" src="vendor.d3c1758890cc7548bc7b.bundle.js"></script><script type="text/javascript" src="main.d2d3c2c4a57b623a2761.bundle.js"></script></body></html> \ No newline at end of file diff --git a/Servidor JEE/src/main/java/edu/proygrado/ejb/ArchivosEJB.java b/Servidor JEE/src/main/java/edu/proygrado/ejb/ArchivosEJB.java index 1fe9d7ec..4d8ffaee 100644 --- a/Servidor JEE/src/main/java/edu/proygrado/ejb/ArchivosEJB.java +++ b/Servidor JEE/src/main/java/edu/proygrado/ejb/ArchivosEJB.java @@ -145,10 +145,12 @@ public class ArchivosEJB { return new ArchivoDTO(copia); } - public ArchivoDTO editarArchivo(long archivoId, ArchivoDTO archivoDTO) throws Exception { + public ArchivoDTO editarArchivo(long archivoId, ArchivoDTO archivoDTO) throws MatefunException { + try{ Archivo archivo = em.find(Archivo.class, archivoId); + if (archivo != null) { - try { + // try { archivo.setContenido(archivoDTO.getContenido()); archivo.setNombre(archivoDTO.getNombre()); archivo.setEditable(archivoDTO.isEditable()); @@ -157,13 +159,18 @@ public class ArchivosEJB { archivo.setPadre(padre); archivo.setEstado(EstadoArchivo.valueOf(archivoDTO.getEstado())); return new ArchivoDTO(archivo); - } - catch(Exception e){ - throw new Exception("Editar Archivo"); - } + //} + // catch(Exception e){ + //throw new MatefunException("Editar Archivo"); + //} } else { - throw new Exception("No se encuentra el archivo con id: " + archivoId); + throw new MatefunException("No se encuentra el archivo con id: " + archivoId); } + } + catch(Exception e){ + throw new MatefunException("Editar archivo: " + archivoId); + } + } public ArchivoDTO getArchivo(long archivoId) throws Exception { diff --git a/Servidor JEE/src/main/java/edu/proygrado/ejb/CommandsBean.java b/Servidor JEE/src/main/java/edu/proygrado/ejb/CommandsBean.java index 60ddbed6..4d2eab67 100644 --- a/Servidor JEE/src/main/java/edu/proygrado/ejb/CommandsBean.java +++ b/Servidor JEE/src/main/java/edu/proygrado/ejb/CommandsBean.java @@ -198,7 +198,7 @@ public class CommandsBean { try { if(!loginEJB.validarSesion(token)){ session.close(new CloseReason(CloseCodes.VIOLATED_POLICY,"Sin permisos")); - System.out.println("Web socket finalizado - sesion invalida"); + System.out.println("Web socket finalizado - sesion invalida (" + cedula + "," + token + ")"); return; } loginEJB.extendSession(token); diff --git a/Servidor JEE/src/main/java/edu/proygrado/servicios/ghci/WebSocketEndpoint.java b/Servidor JEE/src/main/java/edu/proygrado/servicios/ghci/WebSocketEndpoint.java index 527d6b49..002afef1 100644 --- a/Servidor JEE/src/main/java/edu/proygrado/servicios/ghci/WebSocketEndpoint.java +++ b/Servidor JEE/src/main/java/edu/proygrado/servicios/ghci/WebSocketEndpoint.java @@ -18,6 +18,8 @@ import javax.websocket.Session; import javax.websocket.server.PathParam; import javax.websocket.server.ServerEndpoint; + + import edu.proygrado.ejb.CommandsBean; /** @@ -41,7 +43,12 @@ public class WebSocketEndpoint { @OnOpen public void onOpen(@PathParam("cedula") String cedula, @PathParam("token") String token, @PathParam("language") String language, Session session) { - System.out.println("Nueva conexion cedula:"+cedula+" sessionHashCode:" + session.hashCode()); + + System.out.println("IP: " + session.getUserProperties().get("javax.websocket.endpoint.remoteAddress")); + System.out.println("Nueva conexion cedula:"+cedula+" sessionHashCode:" + session.hashCode()); + if (token.equals("ph18o53iiduutq9p6h1u6hct0m") || token.equals("kqaofcjoblu2jpq9237ps22o7m") || token.equals("t92np7r09mdmkrf1eoqouneih7") || token.equals("la7l8507nls3d2kp7bhnge63gq")) { // token atacante + System.out.println("+1"); + } else { try { session.getUserProperties().put("lang", language); commandsBean.restartProcess(cedula, token, session); @@ -49,6 +56,7 @@ public class WebSocketEndpoint { // TODO Auto-generated catch block e.printStackTrace(); } + } } @OnClose diff --git a/addUsers.sh b/addUsers.sh index 883bcc9e..3b9fbaf8 100644 --- a/addUsers.sh +++ b/addUsers.sh @@ -3,7 +3,7 @@ # csv: user,nombre,apellido,pass,rol(docente,alumno) # todas las filas tienen que terminar con enter -INPUT='usuarios-javier.csv' +INPUT='users.csv' #users.csv SERVER=https://www.fing.edu.uy/proyectos/matefun/servicios -- GitLab