Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
securityRemake
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Juan Guevara Mayta
securityRemake
Commits
79fe2d1a
Commit
79fe2d1a
authored
Aug 14, 2023
by
Mauro Paolo Josue Zuñiga Mallqui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[EDIT] CAMBIOS PARA LA EDICION DE MENU Y PERMISOS POR VISTA
parent
72fb43bf
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
753 additions
and
89 deletions
+753
-89
MenuDAO.java
src/main/java/com/mycompany/moduloseguridad/dao/MenuDAO.java
+50
-42
MenuMYSQLDAO.java
.../com/mycompany/moduloseguridad/mysqldao/MenuMYSQLDAO.java
+189
-5
MenuService.java
...a/com/mycompany/moduloseguridad/services/MenuService.java
+30
-0
MantenimientoMenuServlet.java
...ny/moduloseguridad/servlets/MantenimientoMenuServlet.java
+102
-4
general.css
src/main/webapp/css/general.css
+4
-0
MantenimientoMenu.js
src/main/webapp/js/pages/MantenimientoMenu.js
+366
-28
proyecto.js
src/main/webapp/js/pages/proyecto.js
+2
-2
tipoUsuario.js
src/main/webapp/js/pages/tipoUsuario.js
+2
-4
index.jsp
src/main/webapp/vistas/index.jsp
+5
-2
mantenimientoMenu.jsp
src/main/webapp/vistas/mantenimientoMenu.jsp
+3
-2
No files found.
src/main/java/com/mycompany/moduloseguridad/dao/MenuDAO.java
View file @
79fe2d1a
...
...
@@ -8,91 +8,98 @@ package com.mycompany.moduloseguridad.dao;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
java.sql.SQLException
;
/**
*
* @author sistem17user
*/
public
interface
MenuDAO
{
public
JSONArray
listarProyecto
(
int
estado
)
throws
Exception
;
JSONArray
listarProyecto
(
int
estado
)
throws
Exception
;
JSONArray
listarTipoDeUsuario
(
int
proyecto
)
throws
Exception
;
JSONArray
listarTituloCompleto
(
int
proyecto_detalle
,
int
proyecto
,
int
tipo
)
throws
Exception
;
JSONArray
listarModuloCompleto
(
int
titulo
,
int
proyecto_detalle
,
int
proyecto
,
int
tipo
)
throws
Exception
;
public
JSONArray
listarTipoDeUsuario
(
int
proyect
o
)
throws
Exception
;
JSONArray
listarCategoriaCompleto
(
int
modulo
,
int
proyecto_detalle
,
int
proyecto
,
int
tip
o
)
throws
Exception
;
public
JSONArray
listarTituloCompleto
(
int
proyecto_detalle
,
int
proyecto
,
int
tipo
)
throws
Exception
;
JSONArray
listarSubCategoriaCompleto
(
int
categoria
,
int
proyecto_detalle
,
int
proyecto
,
int
tipo
)
throws
Exception
;
public
JSONArray
listarModuloCompleto
(
int
titulo
,
int
proyecto_detalle
,
int
proyecto
,
int
tipo
)
throws
Exception
;
JSONObject
editarTitulo
(
JSONObject
datos
)
throws
Exception
;
public
JSONArray
listarCategoriaCompleto
(
int
modulo
,
int
proyecto_detalle
,
int
proyecto
,
int
tipo
)
throws
Exception
;
JSONObject
editarModulo
(
JSONObject
datos
)
throws
Exception
;
public
JSONArray
listarSubCategoriaCompleto
(
int
categoria
,
int
proyecto_detalle
,
int
proyecto
,
int
tipo
)
throws
Exception
;
JSONObject
editarCategoria
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
editarTitulo
(
JSONObject
datos
)
throws
Exception
;
JSONObject
editarSubCategoria
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
editarMod
ulo
(
JSONObject
datos
)
throws
Exception
;
JSONObject
nuevoTit
ulo
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
editarCategoria
(
JSONObject
datos
)
throws
Exception
;
JSONObject
nuevoModulo
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
editarSub
Categoria
(
JSONObject
datos
)
throws
Exception
;
JSONObject
nuevo
Categoria
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
nuevoTitulo
(
JSONObject
datos
)
throws
Exception
;
JSONObject
nuevoSubCategoria
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
nuevoMod
ulo
(
JSONObject
datos
)
throws
Exception
;
JSONObject
eliminarDetalleTit
ulo
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
nuevoCategoria
(
JSONObject
datos
)
throws
Exception
;
JSONObject
eliminarDetalleModulo
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
nuevoSub
Categoria
(
JSONObject
datos
)
throws
Exception
;
JSONObject
eliminarDetalle
Categoria
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
eliminarDetalleTitulo
(
JSONObject
datos
)
throws
Exception
;
JSONObject
eliminarDetalleSubCategoria
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
eliminarDetalleMod
ulo
(
JSONObject
datos
)
throws
Exception
;
JSONObject
cambiarOrdenTit
ulo
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
eliminarDetalleCategoria
(
JSONObject
datos
)
throws
Exception
;
JSONObject
cambiarOrdenModulo
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
eliminarDetalleSub
Categoria
(
JSONObject
datos
)
throws
Exception
;
JSONObject
cambiarOrden
Categoria
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
cambiarOrdenTitulo
(
JSONObject
datos
)
throws
Exception
;
JSONObject
cambiarOrdenSubCategoria
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
cambiarOrdenModulo
(
JSONObject
datos
)
throws
Exception
;
JSONObject
reconocerNombreSimilar
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
cambiarOrdenCategoria
(
JSONObject
datos
)
throws
Exception
;
JSONObject
nuevoTituloExistente
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
cambiarOrdenSubCategoria
(
JSONObject
datos
)
throws
Exception
;
JSONObject
nuevoModuloExistente
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
reconocerNombreSimilar
(
JSONObject
datos
)
throws
Exception
;
JSONObject
nuevoCategoriaExistente
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
nuevoTitulo
Existente
(
JSONObject
datos
)
throws
Exception
;
JSONObject
nuevoSubCategoria
Existente
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
nuevoModuloExistente
(
JSONObject
datos
)
throws
Exception
;
JSONObject
validarEdicionTitulo
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
nuevoCategoriaExistente
(
JSONObject
datos
)
throws
Exception
;
JSONObject
validarEdicionModulo
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
nuevoSubCategoriaExistente
(
JSONObject
datos
)
throws
Exception
;
JSONObject
validarEdicionCategoria
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
validarEdicionTitulo
(
JSONObject
datos
)
throws
Exception
;
JSONObject
validarEdicionSubCategoria
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
validarEdicionModulo
(
JSONObject
datos
)
throws
Exception
;
JSONObject
listarTitulo
(
JSONObject
datos
,
String
draw
,
String
start
,
String
length
)
throws
Exception
;
public
JSONObject
validarEdicionCategoria
(
JSONObject
datos
)
throws
Exception
;
JSONObject
listarModulo
(
JSONObject
datos
,
String
draw
,
String
start
,
String
length
)
throws
Exception
;
public
JSONObject
validarEdicionSubCategoria
(
JSONObject
datos
)
throws
Exception
;
JSONObject
listarCategoria
(
JSONObject
datos
,
String
draw
,
String
start
,
String
length
)
throws
Exception
;
public
JSONObject
listarTitulo
(
JSONObject
datos
,
String
draw
,
String
start
,
String
length
)
throws
Exception
;
JSONObject
listarSubCategoria
(
JSONObject
datos
,
String
draw
,
String
start
,
String
length
)
throws
Exception
;
public
JSONObject
listarModulo
(
JSONObject
datos
,
String
draw
,
String
start
,
String
length
)
throws
Exception
;
JSONObject
validarElminarTitulo
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
listarCategoria
(
JSONObject
datos
,
String
draw
,
String
start
,
String
length
)
throws
Exception
;
JSONObject
validarElminarModulo
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
listarSubCategoria
(
JSONObject
datos
,
String
draw
,
String
start
,
String
length
)
throws
Exception
;
JSONObject
validarElminarCategoria
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
validarElminarTitulo
(
JSONObject
datos
)
throws
Exception
;
JSONObject
validarElminarSubCategoria
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
validarElminarModul
o
(
JSONObject
datos
)
throws
Exception
;
JSONObject
eliminarMenusAninad
o
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
validarElminarCategoria
(
JSONObject
datos
)
throws
Exception
;
JSONObject
eliminarMenusAninadoGeneral
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
validarElminarSubCategoria
(
JSONObject
datos
)
throws
Exception
;
JSONArray
obtenerAcciones
(
int
codigo
,
int
jerarquia
,
int
tipo_usuario
)
throws
Exception
;
public
JSONObject
eliminarMenusAninado
(
JSONObject
datos
)
throws
Exception
;
JSONObject
listarPermisosPorVista
(
JSONObject
datos
)
throws
Exception
;
public
JSONObject
eliminarMenusAninadoGeneral
(
JSONObject
datos
)
throws
Exception
;
JSONObject
asignarAccionesPorVista
(
JSONObject
json
)
throws
SQL
Exception
;
}
\ No newline at end of file
src/main/java/com/mycompany/moduloseguridad/mysqldao/MenuMYSQLDAO.java
View file @
79fe2d1a
...
...
@@ -225,7 +225,7 @@ public class MenuMYSQLDAO implements MenuDAO {
if
(
tipo
==
1
)
{
extra
=
" -1 "
;
}
query
=
"select c.cod_modulo, c.cod_categoria, c.nom, c.url, c.tip, c.est, 0, 0, count(*) as cant "
query
=
"select c.cod_modulo, c.cod_categoria, c.nom, c.url, c.tip, c.est, 0, 0, count(*) as cant
, c.esvisible
"
+
"from categoria_configuracion tc "
+
"left join proyecto_detalle as pd "
+
"on tc.cod_proyecto_detalle = pd.cod_proyecto_detalle "
...
...
@@ -241,7 +241,7 @@ public class MenuMYSQLDAO implements MenuDAO {
+
"where cod_proyecto = "
+
proyecto
+
" "
+
") "
;
}
else
{
query
=
" select c.cod_modulo, c.cod_categoria, c.nom, c.url, c.tip, c.est, cc.cod_categoria_configuracion, cc.ord from categoria as c "
query
=
" select c.cod_modulo, c.cod_categoria, c.nom, c.url, c.tip, c.est, cc.cod_categoria_configuracion, cc.ord
, c.esvisible
from categoria as c "
+
" inner join categoria_configuracion as cc"
+
" on cc.cod_categoria = c.cod_categoria "
+
" where cod_proyecto_detalle = "
+
proyecto_detalle
+
" "
...
...
@@ -261,6 +261,7 @@ public class MenuMYSQLDAO implements MenuDAO {
obj
.
put
(
"estadoCategoria"
,
rs
.
getString
(
6
));
obj
.
put
(
"configuracionCategoria"
,
rs
.
getString
(
7
));
obj
.
put
(
"ordenCategoria"
,
rs
.
getString
(
8
));
obj
.
put
(
"esVisible"
,
rs
.
getBoolean
(
9
));
lista
.
put
(
obj
);
}
}
catch
(
Exception
e
)
{
...
...
@@ -288,7 +289,7 @@ public class MenuMYSQLDAO implements MenuDAO {
if
(
tipo
==
1
)
{
extra
=
" -1 "
;
}
query
=
"select s.cod_subcategoria, s.cod_categoria, s.nom, s.url, s.est, 0, 0, count(*) as cant "
query
=
"select s.cod_subcategoria, s.cod_categoria, s.nom, s.url, s.est, 0, 0, count(*) as cant
, s.esvisible
"
+
"from subcategoria_configuracion sc "
+
"left join proyecto_detalle as pd "
+
"on sc.cod_proyecto_detalle = pd.cod_proyecto_detalle "
...
...
@@ -304,7 +305,7 @@ public class MenuMYSQLDAO implements MenuDAO {
+
"where cod_proyecto = "
+
proyecto
+
" "
+
") "
;
}
else
{
query
=
" select s.cod_subcategoria, s.cod_categoria, s.nom, s.url, s.est, sc.cod_subcategoria_configuracion, sc.ord from subcategoria as s"
query
=
" select s.cod_subcategoria, s.cod_categoria, s.nom, s.url, s.est, sc.cod_subcategoria_configuracion, sc.ord
, s.esvisible
from subcategoria as s"
+
" inner join subcategoria_configuracion as sc "
+
" on sc.cod_subcategoria = s.cod_subcategoria "
+
" where cod_proyecto_detalle = "
+
proyecto_detalle
+
" "
...
...
@@ -323,6 +324,7 @@ public class MenuMYSQLDAO implements MenuDAO {
obj
.
put
(
"estadoSubCategoria"
,
rs
.
getString
(
5
));
obj
.
put
(
"configuracionSubCategoria"
,
rs
.
getString
(
6
));
obj
.
put
(
"ordenSubCategoria"
,
rs
.
getString
(
7
));
obj
.
put
(
"esVisible"
,
rs
.
getBoolean
(
8
));
lista
.
put
(
obj
);
}
}
catch
(
Exception
e
)
{
...
...
@@ -2081,7 +2083,7 @@ public class MenuMYSQLDAO implements MenuDAO {
try
{
con
=
MySQLDAOFactory
.
getConnectionSQL
(
base
);
sql
=
"select a.cod_subcategoria, a.nom, a.url, "
+
"I
S
NULL( "
+
"I
F
NULL( "
+
"(select count(*) as cant "
+
"from subcategoria_configuracion as sc "
+
"inner join proyecto_detalle as pd "
...
...
@@ -2796,6 +2798,149 @@ public class MenuMYSQLDAO implements MenuDAO {
}
@Override
public
JSONArray
obtenerAcciones
(
int
codigo
,
int
jerarquia
,
int
tipo_usuario
)
{
Connection
con
=
null
;
JSONArray
rs
=
new
JSONArray
();
try
{
PreparedStatement
pst
=
null
;
ResultSet
rSet
=
null
;
String
sql
=
""
;
con
=
MySQLDAOFactory
.
getConnectionSQL
(
"SECURITY"
);
if
(
jerarquia
==
2
)
{
sql
=
"select\n"
+
" modulo.cod_modulo as codigo,\n"
+
" modulo.nom as nom_padre,\n"
+
" accion.cod_accion,\n"
+
" accion.nom_accion\n"
+
"from seguridad.modulo_acciones\n"
+
" left join seguridad.modulo on modulo_acciones.cod_modulo = modulo.cod_modulo\n"
+
" left join seguridad.accion on modulo_acciones.cod_accion = accion.cod_accion\n"
+
"where modulo.cod_modulo = ? and modulo_acciones.cod_tipo_usuario = ?;\n"
;
}
else
if
(
jerarquia
==
3
)
{
sql
=
"select\n"
+
" categoria.cod_categoria as codigo,\n"
+
" categoria.nom as nom_padre,\n"
+
" accion.cod_accion,\n"
+
" accion.nom_accion\n"
+
"from seguridad.categoria_acciones\n"
+
" left join seguridad.categoria on categoria_acciones.cod_categoria = categoria.cod_categoria\n"
+
" left join seguridad.accion on categoria_acciones.cod_accion = accion.cod_accion\n"
+
"where categoria.cod_categoria = ? and categoria_acciones.cod_tipo_usuario = ?;\n"
;
}
else
if
(
jerarquia
==
4
)
{
sql
=
"select\n"
+
" subcategoria.cod_subcategoria as codigo,\n"
+
" subcategoria.nom as nom_padre,\n"
+
" accion.cod_accion,\n"
+
" accion.nom_accion\n"
+
"from seguridad.subcategoria_acciones\n"
+
" left join seguridad.subcategoria on subcategoria_acciones.cod_subcategoria = subcategoria.cod_subcategoria\n"
+
" left join seguridad.accion on subcategoria_acciones.cod_accion = accion.cod_accion\n"
+
"where subcategoria.cod_subcategoria = ? and subcategoria_acciones.cod_tipo_usuario = ?;"
;
}
pst
=
con
.
prepareStatement
(
sql
);
pst
.
setInt
(
1
,
codigo
);
pst
.
setInt
(
2
,
tipo_usuario
);
rSet
=
pst
.
executeQuery
();
while
(
rSet
.
next
())
{
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"codigo"
,
rSet
.
getInt
(
"codigo"
));
json
.
put
(
"nom_padre"
,
rSet
.
getString
(
"nom_padre"
));
json
.
put
(
"cod_accion"
,
rSet
.
getInt
(
"cod_accion"
));
json
.
put
(
"nom_accion"
,
rSet
.
getString
(
"nom_accion"
));
rs
.
put
(
json
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
if
(
con
!=
null
)
{
con
.
close
();
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
return
rs
;
}
@Override
public
JSONObject
listarPermisosPorVista
(
JSONObject
datos
)
throws
Exception
{
Connection
con
=
null
;
PreparedStatement
pst
=
null
;
ResultSet
rSet
=
null
;
JSONObject
jsonReturn
=
new
JSONObject
();
JSONArray
rs
=
new
JSONArray
();
try
{
con
=
MySQLDAOFactory
.
getConnectionSQL
(
"SECURITY"
);
String
sql
=
""
;
if
(
datos
.
getInt
(
"jerarquia"
)
==
2
){
sql
=
"select\n"
+
" modulo_acciones.cod_mod_acc as codigo,\n"
+
" modulo.cod_modulo,\n"
+
" modulo.nom as nom_padre,\n"
+
" accion.cod_accion,\n"
+
" accion.nom_accion\n"
+
"from seguridad.modulo_acciones\n"
+
" left join seguridad.modulo on modulo_acciones.cod_modulo = modulo.cod_modulo\n"
+
" left join seguridad.accion on modulo_acciones.cod_accion = accion.cod_accion\n"
+
"where modulo.cod_modulo = ?;"
;
}
else
if
(
datos
.
getInt
(
"jerarquia"
)
==
3
){
sql
=
"select\n"
+
" categoria_acciones.cod_cat_acc as codigo,\n"
+
" categoria.cod_categoria,\n"
+
" categoria.nom as nom_padre,\n"
+
" accion.cod_accion,\n"
+
" accion.nom_accion\n"
+
"from seguridad.categoria_acciones\n"
+
" left join seguridad.categoria on categoria_acciones.cod_categoria = categoria.cod_categoria\n"
+
" left join seguridad.accion on categoria_acciones.cod_accion = accion.cod_accion\n"
+
"where categoria.cod_categoria = ?;"
;
}
else
if
(
datos
.
getInt
(
"jerarquia"
)
==
4
){
sql
=
"select\n"
+
" subcategoria_acciones.cod_sub_acc as codigo,\n"
+
" subcategoria.cod_subcategoria,\n"
+
" subcategoria.nom as nom_padre,\n"
+
" accion.cod_accion,\n"
+
" accion.nom_accion\n"
+
"from seguridad.subcategoria_acciones\n"
+
" left join seguridad.subcategoria on subcategoria_acciones.cod_subcategoria = subcategoria.cod_subcategoria\n"
+
" left join seguridad.accion on subcategoria_acciones.cod_accion = accion.cod_accion\n"
+
"where subcategoria.cod_subcategoria = ?;"
;
}
pst
=
con
.
prepareStatement
(
sql
);
pst
.
setInt
(
1
,
datos
.
getInt
(
"codigo"
));
rSet
=
pst
.
executeQuery
();
while
(
rSet
.
next
()){
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"codigo"
,
rSet
.
getInt
(
"codigo"
));
// json.put("cod_modulo",rSet.getInt("cod_modulo"));
json
.
put
(
"nom_padre"
,
rSet
.
getString
(
"nom_padre"
));
json
.
put
(
"cod_accion"
,
rSet
.
getInt
(
"cod_accion"
));
json
.
put
(
"nom_accion"
,
rSet
.
getString
(
"nom_accion"
));
rs
.
put
(
json
);
}
jsonReturn
.
put
(
"message"
,
"Consulta exitosa"
);
jsonReturn
.
put
(
"status"
,
true
);
}
catch
(
Exception
e
)
{
jsonReturn
.
put
(
"message"
,
e
.
getMessage
());
jsonReturn
.
put
(
"status"
,
false
);
e
.
printStackTrace
();
}
finally
{
try
{
if
(
con
!=
null
)
{
con
.
close
();
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
return
jsonReturn
.
put
(
"data"
,
rs
);
}
@Override
public
JSONObject
eliminarMenusAninado
(
JSONObject
datos
)
throws
Exception
{
JSONObject
jsonReturn
;
Connection
con
=
null
;
...
...
@@ -2893,4 +3038,42 @@ public class MenuMYSQLDAO implements MenuDAO {
return
jsonReturn
;
}
public
JSONObject
asignarAccionesPorVista
(
JSONObject
json
)
throws
SQLException
{
JSONObject
jsonReturn
=
new
JSONObject
();
Connection
con
=
null
;
PreparedStatement
pst
=
null
;
ResultSet
rSet
=
null
;
try
{
con
=
MySQLDAOFactory
.
getConnectionSQL
(
"SECURITY"
);
con
.
setAutoCommit
(
false
);
String
sql
=
"{CALL SP_TA_ACCIONES_POR_VISTA(?,?,?,?,?,?,?,?)}"
;
pst
=
con
.
prepareStatement
(
sql
);
pst
.
setInt
(
1
,
json
.
getInt
(
"tipo_accion"
));
pst
.
setInt
(
2
,
json
.
getInt
(
"v_cod_accion"
));
pst
.
setString
(
3
,
json
.
getString
(
"v_nom_accion"
));
pst
.
setInt
(
4
,
json
.
getInt
(
"v_jerarquia"
));
pst
.
setInt
(
5
,
json
.
getInt
(
"v_cod_proyecto"
));
pst
.
setInt
(
6
,
json
.
getInt
(
"v_cod_vista"
));
pst
.
setInt
(
7
,
json
.
getInt
(
"v_cod_vista_acc"
));
pst
.
setInt
(
8
,
json
.
getInt
(
"v_tipo_usuario"
));
rSet
=
pst
.
executeQuery
();
if
(
json
.
getInt
(
"tipo_accion"
)
==
3
)
{
while
(
rSet
.
next
())
{
jsonReturn
.
put
(
"status"
,
rSet
.
getInt
(
"result"
));
jsonReturn
.
put
(
"message"
,
"todo bien"
);
}
}
else
{
jsonReturn
.
put
(
"status"
,
true
);
jsonReturn
.
put
(
"message"
,
"todo bien"
);
}
con
.
commit
();
}
catch
(
SQLException
e
)
{
con
.
rollback
();
jsonReturn
.
put
(
"status"
,
false
);
jsonReturn
.
put
(
"message"
,
e
.
getMessage
());
throw
new
RuntimeException
(
e
);
}
return
jsonReturn
;
}
}
\ No newline at end of file
src/main/java/com/mycompany/moduloseguridad/services/MenuService.java
View file @
79fe2d1a
...
...
@@ -429,4 +429,33 @@ public class MenuService {
return
obj
;
}
public
JSONObject
listarPermisosPorVista
(
JSONObject
datos
)
{
JSONObject
obj
=
null
;
try
{
obj
=
dao
.
listarPermisosPorVista
(
datos
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
obj
;
}
public
JSONArray
obtenerAcciones
(
int
codigo
,
int
jerarquia
,
int
tipo_usuario
)
{
JSONArray
obj
=
null
;
try
{
obj
=
dao
.
obtenerAcciones
(
codigo
,
jerarquia
,
tipo_usuario
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
obj
;
}
public
JSONObject
asignarAccionesPorVista
(
JSONObject
json
)
{
JSONObject
obj
=
null
;
try
{
obj
=
dao
.
asignarAccionesPorVista
(
json
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
obj
;
}
}
\ No newline at end of file
src/main/java/com/mycompany/moduloseguridad/servlets/MantenimientoMenuServlet.java
View file @
79fe2d1a
...
...
@@ -7,6 +7,7 @@ package com.mycompany.moduloseguridad.servlets;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.util.Objects
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServlet
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -65,6 +66,12 @@ public class MantenimientoMenuServlet extends HttpServlet {
case
"eliminarMenusAninado"
:
eliminarMenusAninado
(
request
,
response
);
break
;
case
"listarPermisosPorVista"
:
listarPermisosPorVista
(
request
,
response
);
break
;
case
"asignarAccionesPorVista"
:
asignarAccionesPorVista
(
request
,
response
);
break
;
default
:
break
;
...
...
@@ -84,7 +91,7 @@ public class MantenimientoMenuServlet extends HttpServlet {
response
.
setContentType
(
"application/json"
);
PrintWriter
out
=
response
.
getWriter
();
MenuService
srv
=
new
MenuService
();
int
codigo
=
Integer
.
parseInt
(
request
.
getParameter
(
"codigo"
));
int
codigo
=
Integer
.
parseInt
(
Objects
.
equals
(
request
.
getParameter
(
"codigo"
),
""
)
?
"0"
:
request
.
getParameter
(
"codigo"
));
JSONArray
rs
=
srv
.
listarTipoDeUsuario
(
codigo
);
out
.
println
(
rs
);
}
...
...
@@ -129,8 +136,7 @@ public class MantenimientoMenuServlet extends HttpServlet {
int
iCategoria
=
0
;
JSONObject
obj2
=
new
JSONObject
();
JSONObject
objModulo
=
(
JSONObject
)
listaModulo
.
get
(
j
);
System
.
out
.
println
(
"objModulo "
+
i
+
" - "
+
j
+
" : "
+
objModulo
);
boolean
esVisible
=
objModulo
.
getBoolean
(
"esVisible"
);
boolean
esVisible1
=
objModulo
.
getBoolean
(
"esVisible"
);
String
nombreModulo
=
objModulo
.
getString
(
"nombreModulo"
);
int
codigoModulo
=
objModulo
.
getInt
(
"codigoModulo"
);
int
configuracionModulo
=
objModulo
.
getInt
(
"configuracionModulo"
);
...
...
@@ -150,14 +156,32 @@ public class MantenimientoMenuServlet extends HttpServlet {
obj2
.
put
(
"configuracion"
,
configuracionModulo
);
obj2
.
put
(
"padre"
,
padreModulo
);
obj2
.
put
(
"orden"
,
ordenModulo
);
obj2
.
put
(
"esVisible"
,
esVisible
);
obj2
.
put
(
"esVisible"
,
esVisible1
);
lista
.
put
(
obj2
);
JSONArray
listarModuloAcc
=
srv
.
obtenerAcciones
(
codigoModulo
,
2
,
proyecto_detalle
);
for
(
int
modacc
=
0
;
modacc
<
listarModuloAcc
.
length
();
modacc
++)
{
JSONObject
objModuloAcc
=
(
JSONObject
)
listarModuloAcc
.
get
(
modacc
);
JSONObject
objModuloAcc2
=
new
JSONObject
();
objModuloAcc2
.
put
(
"conta"
,
modacc
+
1
);
objModuloAcc2
.
put
(
"jerarquia"
,
5
);
objModuloAcc2
.
put
(
"nombre"
,
objModuloAcc
.
getString
(
"nom_accion"
));
objModuloAcc2
.
put
(
"codigo"
,
objModuloAcc
.
getInt
(
"cod_accion"
));
objModuloAcc2
.
put
(
"icono"
,
""
);
objModuloAcc2
.
put
(
"url"
,
""
);
objModuloAcc2
.
put
(
"tipo"
,
3
);
objModuloAcc2
.
put
(
"configuracion"
,
0
);
objModuloAcc2
.
put
(
"padre"
,
codigoModulo
);
objModuloAcc2
.
put
(
"orden"
,
0
);
// objModuloAcc2.put("esVisible", true);
lista
.
put
(
objModuloAcc2
);
}
JSONArray
listaCategoria
=
srv
.
listarCategoriaCompleto
(
codigoModulo
,
proyecto_detalle
,
proyecto
,
tipo
);
for
(
int
k
=
0
;
k
<
listaCategoria
.
length
();
k
++)
{
int
iSubCategoria
=
0
;
JSONObject
obj3
=
new
JSONObject
();
JSONObject
objCategoria
=
(
JSONObject
)
listaCategoria
.
get
(
k
);
String
nombreCategoria
=
objCategoria
.
getString
(
"nombreCategoria"
);
boolean
esVisible2
=
objModulo
.
getBoolean
(
"esVisible"
);
int
codigoCategoria
=
objCategoria
.
getInt
(
"codigoCategoria"
);
int
configuracionCategoria
=
objCategoria
.
getInt
(
"configuracionCategoria"
);
String
urlCategoria
=
objCategoria
.
getString
(
"urlCategoria"
);
...
...
@@ -175,12 +199,30 @@ public class MantenimientoMenuServlet extends HttpServlet {
obj3
.
put
(
"configuracion"
,
configuracionCategoria
);
obj3
.
put
(
"padre"
,
padreCategoria
);
obj3
.
put
(
"orden"
,
ordenCategoria
);
obj3
.
put
(
"esVisible"
,
esVisible2
);
lista
.
put
(
obj3
);
JSONArray
listarCategoriaAcc
=
srv
.
obtenerAcciones
(
codigoCategoria
,
3
,
proyecto_detalle
);
for
(
int
catacc
=
0
;
catacc
<
listarCategoriaAcc
.
length
();
catacc
++)
{
JSONObject
objCategoriaAcc
=
(
JSONObject
)
listarCategoriaAcc
.
get
(
catacc
);
JSONObject
objCategoriaAcc2
=
new
JSONObject
();
objCategoriaAcc2
.
put
(
"conta"
,
catacc
+
1
);
objCategoriaAcc2
.
put
(
"jerarquia"
,
6
);
objCategoriaAcc2
.
put
(
"nombre"
,
objCategoriaAcc
.
getString
(
"nom_accion"
));
objCategoriaAcc2
.
put
(
"codigo"
,
objCategoriaAcc
.
getInt
(
"cod_accion"
));
objCategoriaAcc2
.
put
(
"icono"
,
""
);
objCategoriaAcc2
.
put
(
"url"
,
""
);
objCategoriaAcc2
.
put
(
"tipo"
,
3
);
objCategoriaAcc2
.
put
(
"configuracion"
,
0
);
objCategoriaAcc2
.
put
(
"padre"
,
codigoCategoria
);
objCategoriaAcc2
.
put
(
"orden"
,
0
);
lista
.
put
(
objCategoriaAcc2
);
}
JSONArray
listaSubCategoria
=
srv
.
listarSubCategoriaCompleto
(
codigoCategoria
,
proyecto_detalle
,
proyecto
,
tipo
);
for
(
int
l
=
0
;
l
<
listaSubCategoria
.
length
();
l
++)
{
JSONObject
obj4
=
new
JSONObject
();
JSONObject
objSubCategoria
=
(
JSONObject
)
listaSubCategoria
.
get
(
l
);
String
nombreSubCategoria
=
objSubCategoria
.
getString
(
"nombreSubCategoria"
);
boolean
esVisible3
=
objSubCategoria
.
getBoolean
(
"esVisible"
);
int
codigoSubCategoria
=
objSubCategoria
.
getInt
(
"codigoSubCategoria"
);
int
configuracionSubCategoria
=
objSubCategoria
.
getInt
(
"configuracionSubCategoria"
);
String
urlSubCategoria
=
objSubCategoria
.
getString
(
"urlSubCategoria"
);
...
...
@@ -197,7 +239,24 @@ public class MantenimientoMenuServlet extends HttpServlet {
obj4
.
put
(
"configuracion"
,
configuracionSubCategoria
);
obj4
.
put
(
"padre"
,
padreSubCategoria
);
obj4
.
put
(
"orden"
,
ordenSubCategoria
);
obj4
.
put
(
"esVisible"
,
esVisible3
);
lista
.
put
(
obj4
);
JSONArray
listarSubAcc
=
srv
.
obtenerAcciones
(
codigoSubCategoria
,
4
,
proyecto_detalle
);
for
(
int
subacc
=
0
;
subacc
<
listarSubAcc
.
length
();
subacc
++)
{
JSONObject
objSubAcc
=
(
JSONObject
)
listarSubAcc
.
get
(
subacc
);
JSONObject
objSubAcc2
=
new
JSONObject
();
objSubAcc2
.
put
(
"conta"
,
subacc
+
1
);
objSubAcc2
.
put
(
"jerarquia"
,
7
);
objSubAcc2
.
put
(
"nombre"
,
objSubAcc
.
getString
(
"nom_accion"
));
objSubAcc2
.
put
(
"codigo"
,
objSubAcc
.
getInt
(
"cod_accion"
));
objSubAcc2
.
put
(
"icono"
,
""
);
objSubAcc2
.
put
(
"url"
,
""
);
objSubAcc2
.
put
(
"tipo"
,
3
);
objSubAcc2
.
put
(
"configuracion"
,
0
);
objSubAcc2
.
put
(
"padre"
,
codigoSubCategoria
);
objSubAcc2
.
put
(
"orden"
,
0
);
lista
.
put
(
objSubAcc2
);
}
}
}
}
...
...
@@ -449,4 +508,42 @@ public class MantenimientoMenuServlet extends HttpServlet {
out
.
print
(
rs
);
}
private
void
listarPermisosPorVista
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
response
.
setContentType
(
"application/json"
);
PrintWriter
out
=
response
.
getWriter
();
MenuService
srv
=
new
MenuService
();
JSONObject
rs
;
int
codigo
=
Integer
.
parseInt
(
request
.
getParameter
(
"codigo"
));
int
jerarquia
=
Integer
.
parseInt
(
request
.
getParameter
(
"jerarquia"
));
JSONObject
json
=
new
JSONObject
().
put
(
"codigo"
,
codigo
).
put
(
"jerarquia"
,
jerarquia
);
rs
=
srv
.
listarPermisosPorVista
(
json
);
out
.
print
(
rs
);
}
public
void
asignarAccionesPorVista
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
response
.
setContentType
(
"application/json"
);
PrintWriter
out
=
response
.
getWriter
();
MenuService
srv
=
new
MenuService
();
JSONObject
rs
;
int
tipo_accion
=
Integer
.
parseInt
(
request
.
getParameter
(
"tipo_accion"
));
int
v_cod_accion
=
Integer
.
parseInt
(
request
.
getParameter
(
"v_cod_accion"
));
String
v_nom_accion
=
request
.
getParameter
(
"v_nom_accion"
);
int
v_jerarquia
=
Integer
.
parseInt
(
request
.
getParameter
(
"v_jerarquia"
));
int
v_cod_proyecto
=
Integer
.
parseInt
(
request
.
getParameter
(
"v_cod_proyecto"
));
int
v_cod_vista
=
Integer
.
parseInt
(
request
.
getParameter
(
"v_cod_vista"
));
int
v_cod_vista_acc
=
Integer
.
parseInt
(
request
.
getParameter
(
"v_cod_vista_acc"
));
int
v_tipo_usuario
=
Integer
.
parseInt
(
request
.
getParameter
(
"v_tipo_usuario"
));
JSONObject
json
=
new
JSONObject
()
.
put
(
"tipo_accion"
,
tipo_accion
)
.
put
(
"v_cod_accion"
,
v_cod_accion
)
.
put
(
"v_nom_accion"
,
v_nom_accion
)
.
put
(
"v_jerarquia"
,
v_jerarquia
)
.
put
(
"v_cod_proyecto"
,
v_cod_proyecto
)
.
put
(
"v_cod_vista"
,
v_cod_vista
)
.
put
(
"v_cod_vista_acc"
,
v_cod_vista_acc
)
.
put
(
"v_tipo_usuario"
,
v_tipo_usuario
);
rs
=
srv
.
asignarAccionesPorVista
(
json
);
out
.
print
(
rs
);
}
}
\ No newline at end of file
src/main/webapp/css/general.css
View file @
79fe2d1a
...
...
@@ -312,6 +312,10 @@ table.display tbody tr:hover td {
padding-left
:
15vw
;
}
.supercategoria
{
padding-left
:
20vw
;
}
.modal-header
[
class
*=
bg-
]
{
padding
:
10px
15px
;
}
...
...
src/main/webapp/js/pages/MantenimientoMenu.js
View file @
79fe2d1a
/* global bootbox */
let
tipo_usuario
=
0
let
tipo_usuario_nombre
=
""
;
function
segundaCarga
()
{
listarProyectos
();
...
...
@@ -73,8 +74,11 @@
var
json
=
{
"codigo"
:
detalle
,
"proyecto"
:
proyecto
,
"tipo"
:
0
"tipo"
:
0
,
"tipo_usuario"
:
tipo_usuario
};
tipo_usuario
=
$
(
'#cboTipoUsuario'
).
val
();
tipo_usuario_nombre
=
$
(
'#cboTipoUsuario option:selected'
).
text
();
if
(
detalle
!==
""
)
{
$
(
'#panelTabla'
).
removeClass
(
'hide'
);
table
=
$
(
"#tblMenu"
).
DataTable
({
...
...
@@ -85,7 +89,7 @@
"infoEmpty"
:
" Mostrando 0 de 0 registros"
,
"search"
:
"Filtrar:"
,
"loadingRecords"
:
"Cargando..."
,
"processing"
:
'<span style="width:100%;"><img src="http
://www.snacklocal.com/images/ajaxload.gif
"></span>'
,
"processing"
:
'<span style="width:100%;"><img src="http
s://upload.wikimedia.org/wikipedia/commons/7/7a/Ajax_loader_metal_512.gif?20180219130538
"></span>'
,
"paginate"
:
{
"first"
:
"First"
,
"last"
:
"Last"
,
...
...
@@ -132,6 +136,13 @@
retorno
=
`<span class='categoria'><i class="fa fa-level-up fa-rotate-90" style="font-size: 16px;"></i> <span class="label bg-orange border-orange-600" style="color: white">
${
row
.
nombre
}
</span></span>`
;
}
else
if
(
data
===
4
)
{
retorno
=
`<span class='subcategoria'><i class="fa fa-level-up fa-rotate-90" style="font-size: 16px;"></i> <span class="label bg-danger border-danger-600" style="color: white">
${
row
.
nombre
}
</span></span>`
;
}
else
if
(
data
===
5
){
retorno
=
`<span class='categoria'><i class="fa fa-level-up fa-rotate-90" style="font-size: 16px;"></i> <span class="label bg-grey-600 border-grey-700" style="color: white">
${
row
.
nombre
}
</span></span>`
;
}
else
if
(
data
===
6
){
retorno
=
`<span class='subcategoria'><i class="fa fa-level-up fa-rotate-90" style="font-size: 16px;"></i> <span class="label bg-grey-600 border-grey-700" style="color: white">
${
row
.
nombre
}
</span></span>`
;
}
else
if
(
data
===
7
){
retorno
=
`<span class='supercategoria'><i class="fa fa-level-up fa-rotate-90" style="font-size: 16px;"></i> <span class="label bg-grey-600 border-grey-700" style="color: white">
${
row
.
nombre
}
</span></span>`
;
}
return
retorno
;
}
...
...
@@ -146,6 +157,8 @@
retorno
=
"<span class='label bg-slate-600 border-slate-700' style='color: white'>ÚNICO</span>"
;
}
else
if
(
data
===
2
)
{
retorno
=
'<span class="label bg-info-600 border-info-700" style="color: white">DESPLEGABLE</span>'
;
}
else
if
(
data
===
3
)
{
retorno
=
'<span class="label bg-blue-400 border-grey-700" style="color: white">PERMISO</span>'
;
}
return
retorno
;
}
...
...
@@ -168,15 +181,21 @@
nombre
=
"Nada"
;
break
;
}
if
(
data
!==
4
&&
row
.
url
===
'#'
||
row
.
url
===
''
)
{
if
([
5
,
6
,
7
].
includes
(
Number
(
data
))){
}
else
if
(
data
!==
4
&&
row
.
url
===
'#'
||
row
.
url
===
''
)
{
retorno
+=
`<span data-toggle="tooltip" title="Crear
${
nombre
}
" style="cursor: pointer"> <i class='crear glyphicon glyphicon-plus text-slate-800' style="font-size: 15px"></i> </span>`
;
}
if
(
!
[
5
,
6
,
7
].
includes
(
Number
(
data
))){
retorno
+=
`<span data-toggle="tooltip" title="Editar" style="cursor: pointer"> <i class='editar glyphicon glyphicon-pencil text-teal-800' style="font-size: 15px"></i> </span>`
;
retorno
+=
`<span data-toggle="tooltip" title="Eliminar" style="cursor: pointer"> <i class='eliminar fa fa-trash text-danger-800' style="font-size: 16px"></i> </span>`
;
}
if
(
row
.
configuracion
!==
0
)
{
retorno
+=
`<span data-toggle="tooltip" title="Bajar" style="cursor: pointer"> <i class='abajo fa fa-chevron-circle-down text-primary-800' style="font-size: 16px"></i> </span>`
;
retorno
+=
`<span data-toggle="tooltip" title="Subir" style="cursor: pointer"> <i class='arriba fa fa-chevron-circle-up text-primary-800' style="font-size: 16px"></i> </span>`
;
}
retorno
+=
`<span data-toggle="tooltip" title="Eliminar" style="cursor: pointer"> <i class='eliminar fa fa-trash text-danger-800' style="font-size: 16px"></i> </span>`
;
//
retorno += `<span data-toggle="tooltip" title="Eliminar" style="cursor: pointer"> <i class='eliminar fa fa-trash text-danger-800' style="font-size: 16px"></i> </span>`;
return
retorno
;
}
...
...
@@ -184,8 +203,9 @@
],
initComplete
:
function
(
nopor
,
data
)
{
$
(
"#tblMenu"
).
addClass
(
"table table-responsive table-striped table-hover table-bordered"
);
},
rowCallback
:
function
(
row
,
data
)
{
if
(
data
.
esVisible
===
false
){
$
(
row
).
css
(
"background-color"
,
"#ffeaea"
);
if
(
data
.
esVisible
===
false
&&
data
.
jerarquia
!==
4
){
$
(
row
).
css
(
"background-color"
,
"#e0f8ff"
);
// $(row).css('opacity',0.5);
}
},
});
...
...
@@ -237,22 +257,23 @@
function
crearFormEdicion
(
data
)
{
console
.
log
(
data
);
var
tipo
=
data
[
"tipo"
];
var
codigo
=
data
[
"codigo"
];
var
jerarquia
=
data
[
"jerarquia"
];
var
nombre
=
data
[
"nombre"
];
var
url
=
data
[
"url"
];
var
visible
=
data
[
"esVisible"
];
var
txturl
;
let
tipo
=
data
[
"tipo"
];
let
codigo
=
data
[
"codigo"
];
let
jerarquia
=
data
[
"jerarquia"
];
let
nombre
=
data
[
"nombre"
];
let
url
=
data
[
"url"
];
let
visible
=
data
[
"esVisible"
];
let
txturl
;
if
(
tipo
===
1
||
jerarquia
===
4
)
{
txturl
=
url
.
slice
(
0
,
-
4
);
}
else
{
txturl
=
url
;
}
var
icono
=
data
[
"icono"
];
var
formEditar
=
bootbox
.
dialog
({
const
icono
=
data
[
"icono"
];
const
formEditar
=
bootbox
.
dialog
({
title
:
"<span><i class='ace-icon fa fa-tags'></i> <span>EDITAR MENU</span>"
,
headerClass
:
"modal-bg-primary"
,
className
:
"tablaFormEdicion"
,
size
:
"medium"
,
message
:
`<form id="formEditarMenu" onsubmit="return false" autocomplete="off">
<div class='divCont row'>
...
...
@@ -292,18 +313,37 @@
<span class="input-group-addon"><div class="" style="color:#848484">.jsp</div></span>
</div>
</div>
<div class='frm col-md-6' id="formEsVisible">
<div class='frm col-md-6
hidden
' id="formEsVisible">
<label style="font-size: small">
Es visible:
</label>
<input id="chkVisible" name="chkEsVisible" class="icp-opts form-control switch" type="checkbox"/>
<input id="chkVisible" name="chkEsVisible" class="icp-opts form-control switch " type="checkbox"/>
</div>
<div class="frm col-md-12
${
tipo
===
1
||
jerarquia
===
4
?
''
:
'hidden'
}
" id ="formPermisos">
<div class="panel-heading" style="padding: 8px 15px; background: #2196f3; color: white">
<h6 class="panel-title" style="font-size: 15px; font-family: inherit"><i class="fa fa-list"></i> Permisos<a class="heading-elements-toggle"><i class="icon-more"></i></a></h6>
<div class="heading-elements">
<button id="bttnAsignarAcciones" type="button" class="btn bg-slate-600 border-slate-800 btn-xs">
<i class="glyphicon glyphicon-plus"></i> Asignar Acciones
</button>
</div>
</div>
<div class="frm col-md-12" id ="formPermisos">
<span>Permisos</span>
<table id="tablaPermisosVista">
<div class="table-responsive" style="overflow-y: auto;height: 17.5rem;">
<table id="tablaPermisosVista" class="table table-striped table-hover table-sm table-bordered display no-footer dataTable table-responsive">
<thead>
<tr>
<th style="text-align:center;">Nº</th>
<th style="text-align:center;">CODIGO</th>
<th style="text-align:center;">NOMBRE</th>
<th style="text-align:center;">ACCION</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-md-12 pull-right form-group">
<div class="text-right" style="font-size: small">
...
...
@@ -316,7 +356,7 @@
label
:
"<i class='fa fa-check bigger-110'></i> Editar"
,
className
:
"btn bg-primary border-primary-600 btn-xs buttonOk"
,
callback
:
function
()
{
var
validar
=
$
(
"#formEditarMenu"
).
validate
({
const
validar
=
$
(
"#formEditarMenu"
).
validate
({
rules
:
{
txtNombre
:
{
required
:
true
},
txtIcono
:
{
required
:
true
},
...
...
@@ -354,6 +394,7 @@
}
});
formEditar
.
init
(
function
()
{
$
(
'#editarTipo'
).
val
(
tipo
);
validarInput
();
if
(
tipo
===
2
)
{
...
...
@@ -362,18 +403,313 @@
if
(
jerarquia
===
2
||
jerarquia
===
3
)
{
validarDependenciaEditar
(
data
);
}
if
(
!
visible
){
if
(
jerarquia
===
2
){
$
(
'#formEsVisible'
).
removeClass
(
'hidden'
);
}
if
(
!
visible
)
{
$
(
"#chkVisible"
).
prop
(
"checked"
,
true
);
}
else
{
}
else
{
$
(
"#chkVisible"
).
removeAttr
(
"checked"
);
}
validarFormulario
(
jerarquia
);
submitKey
(
'formEditarMenu'
,
'.buttonOk'
);
validCaracForm
();
cargarPermisosPorVista
(
data
).
then
(
r
=>
{
$
(
'#bttnAsignarAcciones'
).
off
(
'click'
).
on
(
'click'
,
()
=>
{
asignarAcciones
(
codigo
,
jerarquia
);
});
});
});
}
function
asignarAcciones
(
vista
,
jerarquia
){
$
(
".tablaFormEdicion"
).
addClass
(
"hide"
);
var
listadoAcciones
=
bootbox
.
dialog
({
title
:
"<span><i class='ace-icon fa fa-tags'></i> ASIGNAR ACCION - "
+
tipo_usuario_nombre
+
"</span>"
,
headerClass
:
"modal-bg-primary"
,
size
:
"small"
,
message
:
`<form id="formCrearTipoUsuario" onsubmit="return false" autocomplete="off">
<div class='col-md-12'>
<div class="form-group">
<label style="font-size: small">
Acciones:
</label>
<span id="spanAterik" class="asterisk"> (*)</span>
<select class="form-control" id="cboListadoAcciones" name="cboListAcciones">
</select>
<br>
<div class="text-right" style="font-size: small">
<span class="text-danger">(*) </span> Campo obligatorio
</div>
</div>
</div>
</form>`
,
buttons
:
{
confirm
:
{
label
:
"<i class='fa fa-check bigger-110'></i> Asignar"
,
className
:
"btn-primary buttonOk"
,
callback
:
function
()
{
let
nom_accion
=
$
(
'#cboListadoAcciones'
).
val
();
let
result_accion
=
$
(
'#cboListadoAcciones'
).
siblings
(
"ul"
).
find
(
'li'
).
get
().
filter
(
li
=>
li
.
innerText
.
toUpperCase
()
===
nom_accion
.
toUpperCase
());
let
cod_accion
=
result_accion
.
length
>
0
?
result_accion
[
0
].
value
:
0
;
if
(
nom_accion
!==
""
){
crearAcciones
(
vista
,
jerarquia
,
cod_accion
,
nom_accion
);
}
else
{
alert
(
"Tienes que asignar una accion valida."
);
$
(
".tablaFormEdicion"
).
removeClass
(
"hide"
);
}
}
},
cancel
:
{
label
:
"<i class='fa fa-times bigger-110'></i> Cancelar"
,
className
:
"btn-danger"
,
callback
:
function
()
{
$
(
".tablaFormEdicion"
).
removeClass
(
"hide"
);
}
}
}
});
listadoAcciones
.
init
(
function
()
{
listarCboAcciones
();
});
}
function
listarCboAcciones
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
$
.
ajax
({
type
:
'POST'
,
url
:
"../servlet/TipoUsuarioServlet?accion=listarCboAcciones"
,
dataType
:
'json'
,
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
resolve
(
data
);
},
error
:
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
reject
(
"Error al listar las asignaciones."
);
}
});
}).
then
(
data
=>
{
let
print
=
''
;
if
(
data
.
status
)
{
let
print
=
""
;
var
lista
=
data
.
data
;
lista
.
forEach
(
v
=>
{
print
+=
'<option value="'
+
v
.
codAccion
+
'">'
+
v
.
nombreAccion
+
'</option>'
;
});
$
(
"#cboListadoAcciones"
).
html
(
print
);
$
(
"#cboListadoAcciones"
).
editableSelect
();
}
});
}
let
lastdata
=
null
;
async
function
cargarPermisosPorVista
(
data
=
null
){
let
json
=
null
;
if
(
data
!=
null
){
lastdata
=
data
;
json
=
{
codigo
:
data
.
codigo
,
jerarquia
:
data
.
jerarquia
}
}
else
{
json
=
{
codigo
:
lastdata
.
codigo
,
jerarquia
:
lastdata
.
jerarquia
}
}
$
.
ajax
({
type
:
'POST'
,
url
:
"../servlet/MantenimientoMenuServlet?accion=listarPermisosPorVista"
,
dataType
:
'JSON'
,
data
:
json
,
success
:
function
(
result
)
{
$
(
'#tablaPermisosVista tbody'
).
html
(
`
${
result
.
data
.
map
((
item
,
index
)
=>
`
<tr>
<td style="text-align: center">
${
index
+
1
}
</td>
<td style="text-align: center">
${
item
.
cod_accion
}
</td>
<td style="text-align: left">
${
item
.
nom_accion
}
</td>
<td style="text-align: center">
<span data-toggle="tooltip" title="Eliminar" style="cursor: pointer" data-original-title="Eliminar">
<i class="eliminar_
${
item
.
codigo
}
fa fa-trash text-danger-800" style="font-size: 16px"></i>
</span>
</td>
</tr>`
).
join
(
''
)
}
`
);
result
.
data
.
forEach
(
item
=>
{
$
(
'.eliminar_'
+
item
[
"codigo"
]).
off
(
'click'
).
on
(
'click'
,
()
=>
{
eliminarAcciones
(
item
[
"codigo"
],
data
.
jerarquia
);
});
});
}
});
}
function
eliminarAcciones
(
codigo
,
jerarquia
){
$
(
".tablaFormEdicion"
).
addClass
(
"hide"
);
return
new
Promise
((
resolve
,
reject
)
=>
{
$
.
ajax
({
type
:
'POST'
,
url
:
"../servlet/MantenimientoMenuServlet?accion=asignarAccionesPorVista"
,
dataType
:
'json'
,
data
:{
"tipo_accion"
:
2
,
"v_cod_accion"
:
0
,
"v_nom_accion"
:
""
,
"v_jerarquia"
:
jerarquia
,
"v_cod_proyecto"
:
proyecto
,
"v_cod_vista"
:
codigo
,
"v_cod_vista_acc"
:
codigo
,
"v_tipo_usuario"
:
tipo_usuario
,
},
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
resolve
(
data
);
},
error
:
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
reject
(
"Error al listar las asignaciones."
);
}
});
}).
then
(
data
=>
{
if
(
data
===
null
){
bootbox
.
dialog
({
title
:
"<i class='ace-icon fa fa-exclamation-circle white'></i> <span class='white'>Advertencia</span>"
,
headerClass
:
"modal-bg-warning"
,
message
:
"Ha ocurrido un error"
,
buttons
:
{
si
:
{
label
:
"<i class='fa fa-check bigger-110'></i> OK"
,
className
:
"btn-warning"
,
callback
:
function
()
{
$
(
".tablaListadoAcciones"
).
removeClass
(
"hide"
);
$
(
".tablaFormEdicion"
).
removeClass
(
"hide"
);
}
}
}
});
}
else
if
(
data
.
status
)
{
bootbox
.
dialog
({
className
:
"dialogExtraSmall"
,
title
:
"<i class='ace-icon fa fa-tags white'></i> <span class='white'>Notificación</span>"
,
headerClass
:
"modal-bg-success"
,
message
:
data
.
message
,
buttons
:
{
si
:
{
label
:
"<i class='fa fa-check bigger-110'></i> OK"
,
className
:
"btn-success"
,
callback
:
function
()
{
$
(
".tablaListadoAcciones"
).
removeClass
(
"hide"
);
$
(
".tablaFormEdicion"
).
removeClass
(
"hide"
);
$
(
"#tblMenu"
).
DataTable
().
ajax
.
reload
();
cargarPermisosPorVista
(
lastdata
);
}
}
}
});
}
else
{
bootbox
.
dialog
({
title
:
"<i class='ace-icon fa fa-exclamation-circle white'></i> <span class='white'>Advertencia</span>"
,
headerClass
:
"modal-bg-warning"
,
message
:
"Ha ocurrido un error"
,
buttons
:
{
si
:
{
label
:
"<i class='fa fa-check bigger-110'></i> OK"
,
className
:
"btn-warning"
,
callback
:
function
()
{
$
(
".tablaListadoAcciones"
).
removeClass
(
"hide"
);
$
(
".tablaFormEdicion"
).
removeClass
(
"hide"
);
}
}
}
});
}
}).
catch
(
error
=>
{
console
.
log
(
error
);
$
(
".tablaListadoAcciones"
).
removeClass
(
"hide"
);
$
(
".tablaFormEdicion"
).
removeClass
(
"hide"
);
$
(
"#tblDetalleAcciones"
).
DataTable
().
ajax
.
reload
();
});
}
function
crearAcciones
(
vista
,
jerarquia
,
accion
,
nom_accion
){
return
new
Promise
((
resolve
,
reject
)
=>
{
$
.
ajax
({
type
:
'POST'
,
url
:
"../servlet/MantenimientoMenuServlet?accion=asignarAccionesPorVista"
,
dataType
:
'json'
,
data
:{
"tipo_accion"
:
1
,
"v_cod_accion"
:
accion
,
"v_nom_accion"
:
nom_accion
,
"v_jerarquia"
:
jerarquia
,
"v_cod_proyecto"
:
proyecto
,
"v_cod_vista"
:
vista
,
"v_cod_vista_acc"
:
0
,
"v_tipo_usuario"
:
tipo_usuario
,
},
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
resolve
(
data
);
},
error
:
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
reject
(
"Error al listar las asignaciones."
);
}
});
}).
then
(
data
=>
{
if
(
data
===
null
){
bootbox
.
dialog
({
title
:
"<i class='ace-icon fa fa-exclamation-circle white'></i> <span class='white'>Advertencia</span>"
,
headerClass
:
"modal-bg-warning"
,
message
:
"Ha ocurrido un error"
,
buttons
:
{
si
:
{
label
:
"<i class='fa fa-check bigger-110'></i> OK"
,
className
:
"btn-warning"
,
callback
:
function
()
{
$
(
".tablaListadoAcciones"
).
removeClass
(
"hide"
);
$
(
".tablaFormEdicion"
).
removeClass
(
"hide"
);
}
}
}
});
}
else
if
(
data
.
status
)
{
bootbox
.
dialog
({
className
:
"dialogExtraSmall"
,
title
:
"<i class='ace-icon fa fa-tags white'></i> <span class='white'>Notificación</span>"
,
headerClass
:
"modal-bg-success"
,
message
:
data
.
message
,
buttons
:
{
si
:
{
label
:
"<i class='fa fa-check bigger-110'></i> OK"
,
className
:
"btn-success"
,
callback
:
function
()
{
$
(
".tablaListadoAcciones"
).
removeClass
(
"hide"
);
$
(
".tablaFormEdicion"
).
removeClass
(
"hide"
);
$
(
"#tblMenu"
).
DataTable
().
ajax
.
reload
();
cargarPermisosPorVista
(
lastdata
);
}
}
}
});
}
else
{
bootbox
.
dialog
({
title
:
"<i class='ace-icon fa fa-exclamation-circle white'></i> <span class='white'>Advertencia</span>"
,
headerClass
:
"modal-bg-warning"
,
message
:
"Ha ocurrido un error"
,
buttons
:
{
si
:
{
label
:
"<i class='fa fa-check bigger-110'></i> OK"
,
className
:
"btn-warning"
,
callback
:
function
()
{
$
(
".tablaListadoAcciones"
).
removeClass
(
"hide"
);
$
(
".tablaFormEdicion"
).
removeClass
(
"hide"
);
}
}
}
});
}
}).
catch
(
error
=>
{
console
.
log
(
error
);
$
(
".tablaListadoAcciones"
).
removeClass
(
"hide"
);
$
(
".tablaFormEdicion"
).
removeClass
(
"hide"
);
$
(
"#tblDetalleAcciones"
).
DataTable
().
ajax
.
reload
();
});
}
function
recargar
()
{
table
.
destroy
();
...
...
@@ -428,9 +764,11 @@
if
(
tipo
===
"2"
)
{
$
(
'#editarUrl'
).
attr
(
'disabled'
,
true
);
$
(
'#editarUrl'
).
val
(
"#"
);
$
(
'#formPermisos'
).
addClass
(
'hidden'
);
}
else
{
$
(
'#editarUrl'
).
attr
(
'disabled'
,
false
);
$
(
'#editarUrl'
).
val
(
""
);
$
(
'#formPermisos'
).
removeClass
(
'hidden'
);
}
});
}
...
...
@@ -1402,7 +1740,7 @@
"infoEmpty"
:
" Mostrando 0 de 0 registros"
,
"search"
:
"Filtrar:"
,
"loadingRecords"
:
"Cargando..."
,
"processing"
:
'<span style="width:100%;"><img src="http
://www.snacklocal.com/images/ajaxload.gif
"></span>'
,
"processing"
:
'<span style="width:100%;"><img src="http
s://upload.wikimedia.org/wikipedia/commons/7/7a/Ajax_loader_metal_512.gif?20180219130538
"></span>'
,
"scrollY"
:
false
,
"paginate"
:
{
"first"
:
"First"
,
...
...
src/main/webapp/js/pages/proyecto.js
View file @
79fe2d1a
...
...
@@ -29,7 +29,7 @@
"infoEmpty"
:
" Mostrando 0 de 0 registros"
,
"search"
:
"Filtrar:"
,
"loadingRecords"
:
"Cargando..."
,
"processing"
:
'<span style="width:100%;"><img src="http
://www.snacklocal.com/images/ajaxload.gif
"></span>'
,
"processing"
:
'<span style="width:100%;"><img src="http
s://upload.wikimedia.org/wikipedia/commons/7/7a/Ajax_loader_metal_512.gif?20180219130538
"></span>'
,
"scrollY"
:
false
,
"paginate"
:
{
"first"
:
"First"
,
...
...
@@ -683,7 +683,7 @@
"infoEmpty"
:
" Mostrando 0 de 0 registros"
,
"search"
:
"Filtrar:"
,
"loadingRecords"
:
"Cargando..."
,
"processing"
:
'<span style="width:100%;"><img src="http
://www.snacklocal.com/images/ajaxload.gif
"></span>'
,
"processing"
:
'<span style="width:100%;"><img src="http
s://upload.wikimedia.org/wikipedia/commons/7/7a/Ajax_loader_metal_512.gif?20180219130538
"></span>'
,
"scrollY"
:
false
,
"paginate"
:
{
"first"
:
"First"
,
...
...
src/main/webapp/js/pages/tipoUsuario.js
View file @
79fe2d1a
...
...
@@ -61,7 +61,7 @@
"infoEmpty"
:
" Mostrando 0 de 0 registros"
,
"search"
:
"Filtrar:"
,
"loadingRecords"
:
"Cargando..."
,
"processing"
:
'<span style="width:100%;"><img src="http
://www.snacklocal.com/images/ajaxload.gif
"></span>'
,
"processing"
:
'<span style="width:100%;"><img src="http
s://upload.wikimedia.org/wikipedia/commons/7/7a/Ajax_loader_metal_512.gif?20180219130538
"></span>'
,
"scrollY"
:
false
,
"paginate"
:
{
"first"
:
"First"
,
...
...
@@ -260,7 +260,7 @@
"infoEmpty"
:
" Mostrando 0 de 0 registros"
,
"search"
:
"Filtrar:"
,
"loadingRecords"
:
"Cargando..."
,
"processing"
:
'<span style="width:100%;"><img src="http
://www.snacklocal.com/images/ajaxload.gif
"></span>'
,
"processing"
:
'<span style="width:100%;"><img src="http
s://upload.wikimedia.org/wikipedia/commons/7/7a/Ajax_loader_metal_512.gif?20180219130538
"></span>'
,
"scrollY"
:
false
,
"paginate"
:
{
"first"
:
"First"
,
...
...
@@ -980,9 +980,7 @@
}
}
});
listadoAcciones
.
init
(
function
()
{
//cargar el combo de acciones
listarCboAcciones
();
});
}
...
...
src/main/webapp/vistas/index.jsp
View file @
79fe2d1a
...
...
@@ -45,8 +45,11 @@
<div
class=
"translucentMe card-3"
></div>
<div
class=
"contentMe"
>
<div
class=
"text-center"
>
<div
class=
"icon-object border-white text-white"
><img
src=
"../img/securityIconWhite.png"
alt=
""
style=
"width: 85px; height: 85px;"
></div>
<h5
class=
"content-group text-white"
>
MÓDULO DE SEGURIDAD
<small
class=
"display-block"
style=
"color: white"
>
LOGIN
</small></h5>
<div
class=
"icon-object border-white text-white"
>
<img
src=
"../img/securityIconBlack.png"
alt=
""
style=
"width: 85px; height: 85px;filter: brightness(1000)"
></div>
<h5
class=
"content-group text-white"
>
MÓDULO DE SEGURIDAD
<small
class=
"display-block"
style=
"color: white"
>
LOGIN
</small>
</h5>
</div>
<div
class=
"form-group has-feedback has-feedback-left"
>
...
...
src/main/webapp/vistas/mantenimientoMenu.jsp
View file @
79fe2d1a
...
...
@@ -8,6 +8,7 @@
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<link
href=
"../css/lib/jquery-editable-select.min.css"
rel=
"stylesheet"
type=
"text/css"
/>
<
%@
include
file=
"templates/header.jsp"
%
>
<!--template-core-->
...
...
@@ -122,7 +123,7 @@
<div>
No visibles :
</div>
<div
style=
"background: #
ffeaea; width: 1rem; height: 1
rem; border: 1px solid black; display: block"
></div>
<div
style=
"background: #
e0f8ff; width: 1.5rem; height: 1.5
rem; border: 1px solid black; display: block"
></div>
</div>
</div>
<div
class=
"form-group"
>
...
...
@@ -170,7 +171,7 @@
</div>
<
%@
include
file=
"templates/footer-body.jsp"
%
>
<script
src=
"../js/lib/jquery-editable-select.min.js"
type=
"text/javascript"
></script>
<script
src=
"../js/pages/MantenimientoMenu.js"
type=
"text/javascript"
></script>
<script>
let
switchery
=
new
Switchery
(
document
.
querySelector
(
'#cbkEstado'
),
{
color
:
'red'
,
secondaryColor
:
'green'
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment