Commit 865d1229 by Billy Larru

agregando instancias de axios

parent 301644a2
...@@ -3,24 +3,30 @@ const PATH_GENERAL = 'http://localhost:7070/Asistencia/'; ...@@ -3,24 +3,30 @@ const PATH_GENERAL = 'http://localhost:7070/Asistencia/';
const PATH_IP = 'http://172.16.2.102:7070/Asistencia/'; const PATH_IP = 'http://172.16.2.102:7070/Asistencia/';
//PRODUCCION //PRODUCCION
const PATH_DOMAIN = ''; const PATH_DOMAIN = '';
const CODIGO_PROYECTO_ASISTENCIA = '7'; const CODIGO_PROYECTO = '7';
//const PATH_SERVICIO_REST = 'http://172.16.2.53:8080/security-rest/api/'//'http://app8.sacooliveros.edu.pe:8080/security-rest/api/'; //const PATH_SERVICIO_REST = 'http://172.16.2.53:8080/security-rest/api/'//'http://app8.sacooliveros.edu.pe:8080/security-rest/api/';
const PATH_SERVICIO_REST = 'http://app9.sacooliveros.edu.pe:8080/security-rest/api/'; const PATH_SERVICIO_REST = 'http://app9.sacooliveros.edu.pe:8080/security-rest/api/';
//<editor-fold> SERVICIOS REST
const ajaxWebService = axios.create({
baseURL: 'http://sistem16:666/'
});
const ajaxModal = axios.create({
baseURL: `http://localhost:7070/Asistencia/vistas/modals/`
});
//<editor-fold> SERVICIOS REST
//<editor-fold> MODULO DE POLICIAS //<editor-fold> MODULO DE POLICIAS
const URI_TIPOROL_POLICIA = "http://172.16.2.91:666/tipoRolPolicias"; const URI_TIPOROL_POLICIA = "tipoRolPolicias";
const URI_FRECUENCIA_ROL_POLICIA = "http://172.16.2.91:666/frecuenciaRolPolicias"; const URI_FRECUENCIA_ROL_POLICIA = "frecuenciaRolPolicias";
const URI_SEDES = "http://172.16.2.91:666/sedes"; const URI_SEDES = "sedes";
const URI_ESTADO_ASISTENCIA = "http://172.16.2.91:666/estadoAsistencia"; const URI_ESTADO_ASISTENCIA = "estadoAsistencia";
const URI_POLICIAS = "http://172.16.2.91:666/policias"; const URI_POLICIAS = "policias";
const URI_ROL_POLICIA = "http://172.16.2.91:666/rolesPolicias"; const URI_ROL_POLICIA = "rolesPolicias";
const URI_POLICIAS_ASISTENCIA = "http://sistem16:666/asistenciaPolicias"; const URI_POLICIAS_ASISTENCIA = "asistenciaPolicias";
const URI_POLICIA_MONTOS_AMANECIDAS = "http://sistem16:666/montoAmanecidas"; const URI_POLICIA_MONTOS_AMANECIDAS = "montoAmanecidas";
const URI_POLICIA_CONCEPTOSEDES = "http://sistem16:666/conceptoSedes"; const URI_POLICIA_CONCEPTOSEDES = "conceptoSedes";
const URI_POLICIA_REPORTE_MONTOS = "http://sistem16:666/reporteMontosPolicias"; const URI_POLICIA_REPORTE_MONTOS = "reporteMontosPolicias";
//</editor-fold> //</editor-fold>
...@@ -60,7 +66,7 @@ $.extend($.fn.dataTable.defaults, { ...@@ -60,7 +66,7 @@ $.extend($.fn.dataTable.defaults, {
} }
}); });
axios.interceptors.response.use(function (response) { ajaxWebService.interceptors.response.use(function (response) {
// Do something with response data // Do something with response data
let respuesta = { let respuesta = {
status: response.data.status || true, status: response.data.status || true,
...@@ -125,7 +131,7 @@ const ajaxRequestGeneral = obj => { ...@@ -125,7 +131,7 @@ const ajaxRequestGeneral = obj => {
let createSelectOptions = (obj, valueName, textName) => { let createSelectOptions = (obj, valueName, textName) => {
let options = '' let options = ''
obj.forEach((data) => { obj.forEach((data) => {
options += `<option value="${data[valueName]}">${data[textName]}</option>` options += ` < option value = "${data[valueName]}" > ${data[textName]} < /option>`
}) })
return options return options
} }
...@@ -160,7 +166,7 @@ let customSwal = { ...@@ -160,7 +166,7 @@ let customSwal = {
*/ */
let getClosest = (elem, selector) => { let getClosest = (elem, selector) => {
// Element.matches() polyfill // Element.matches() polyfill
if (!Element.prototype.matches) { if (!Element.prototype.matches) {
Element.prototype.matches = Element.prototype.matches =
Element.prototype.matchesSelector || Element.prototype.matchesSelector ||
...@@ -176,7 +182,7 @@ let getClosest = (elem, selector) => { ...@@ -176,7 +182,7 @@ let getClosest = (elem, selector) => {
return i > -1 return i > -1
} }
} }
// Get closest match // Get closest match
for (; elem && elem !== document; elem = elem.parentNode) { for (; elem && elem !== document; elem = elem.parentNode) {
if (elem.matches(selector)) if (elem.matches(selector))
return elem return elem
...@@ -219,13 +225,6 @@ let logOut = () => { ...@@ -219,13 +225,6 @@ let logOut = () => {
window.location.href = '../vistas/logout'; window.location.href = '../vistas/logout';
}); });
}; };
function defaultConfigDatePicker() { function defaultConfigDatePicker() {
$('.datepicker').datepicker({ $('.datepicker').datepicker({
dateFormat: 'dd/mm/yy', dateFormat: 'dd/mm/yy',
...@@ -236,7 +235,6 @@ function defaultConfigDatePicker() { ...@@ -236,7 +235,6 @@ function defaultConfigDatePicker() {
maxDate: '+1Y', maxDate: '+1Y',
inline: true inline: true
}); });
$.datepicker.regional['es'] = { $.datepicker.regional['es'] = {
closeText: 'Cerrar', closeText: 'Cerrar',
prevText: '<Ant', prevText: '<Ant',
...@@ -287,8 +285,6 @@ function defaultConfigDatePicker() { ...@@ -287,8 +285,6 @@ function defaultConfigDatePicker() {
}}) }})
} }
})(jQuery); })(jQuery);
function primeraLetraMayuscula(str) { function primeraLetraMayuscula(str) {
let strLower = str.toLowerCase(); let strLower = str.toLowerCase();
let caracter = strLower.substr(0, 1).toUpperCase(); let caracter = strLower.substr(0, 1).toUpperCase();
...@@ -306,11 +302,10 @@ data: [], ...@@ -306,11 +302,10 @@ data: [],
classNameForDatatable: ``, classNameForDatatable: ``,
footerFilter: false, footerFilter: false,
highlighting: true highlighting: true
}) => { }) => {
let data = jsonForDatatable.data; let data = jsonForDatatable.data;
let columns = jsonForDatatable.columns; let columns = jsonForDatatable.columns;
let columnDefs = jsonForDatatable.columns; let columnDefs = jsonForDatatable.columns;
let wrapsNameDatatable = jsonForDatatable.wrapsNameDatatable let wrapsNameDatatable = jsonForDatatable.wrapsNameDatatable
let nameDatatable = `${wrapsNameDatatable}-datatable` let nameDatatable = `${wrapsNameDatatable}-datatable`
let classNameForDatatable = jsonForDatatable.classNameForDatatable let classNameForDatatable = jsonForDatatable.classNameForDatatable
...@@ -320,7 +315,6 @@ data: [], ...@@ -320,7 +315,6 @@ data: [],
let table_head = ` let table_head = `
<table id="${nameDatatable}" class="${classNameForDatatable} table-hover" cellspacing="0" width="100%">`; <table id="${nameDatatable}" class="${classNameForDatatable} table-hover" cellspacing="0" width="100%">`;
let table_head_th = ` let table_head_th = `
<thead> <thead>
<tr>`; <tr>`;
...@@ -362,9 +356,8 @@ data: [], ...@@ -362,9 +356,8 @@ data: [],
let table_foot = `</table>` let table_foot = `</table>`
$(`#${wrapsNameDatatable}`).empty().append(`${table_head}${table_head_th}${table_foot_th}${table_foot}`); $(`#${wrapsNameDatatable}`).empty().append(`${table_head}${table_head_th}${table_foot_th}${table_foot}`);
if (footerFilter) { if (footerFilter) {
// Setup - add a text input to each footer cell // Setup - add a text input to each footer cell
$(`#${nameDatatable} tfoot th`).each(function () { $(`#${nameDatatable} tfoot th`).each(function () {
var title = $(this).text(); var title = $(this).text();
$(this).html(`<input type="text" class="form-control" placeholder="${title}" />`); $(this).html(`<input type="text" class="form-control" placeholder="${title}" />`);
...@@ -381,11 +374,9 @@ data: [], ...@@ -381,11 +374,9 @@ data: [],
rightColumns: 1 rightColumns: 1
} }
}); });
if (footerFilter) { if (footerFilter) {
// DataTable // DataTable
let table = $(`#${nameDatatable}`).DataTable(); let table = $(`#${nameDatatable}`).DataTable();
// Apply the search // Apply the search
table.columns().every(function () { table.columns().every(function () {
var that = this; var that = this;
...@@ -397,7 +388,6 @@ data: [], ...@@ -397,7 +388,6 @@ data: [],
} }
}); });
}); });
$(`#${wrapsNameDatatable} .dataTables_scrollBody`).appendTo(`#${wrapsNameDatatable} .dataTables_scroll`); $(`#${wrapsNameDatatable} .dataTables_scrollBody`).appendTo(`#${wrapsNameDatatable} .dataTables_scroll`);
} }
...@@ -406,7 +396,6 @@ data: [], ...@@ -406,7 +396,6 @@ data: [],
$(`#${nameDatatable} tbody`) $(`#${nameDatatable} tbody`)
.on('mouseenter', 'td', function () { .on('mouseenter', 'td', function () {
let colIdx = table.cell(this).index().column; let colIdx = table.cell(this).index().column;
$(table.cells().nodes()).removeClass('highlight'); $(table.cells().nodes()).removeClass('highlight');
$(table.column(colIdx).nodes()).addClass('highlight'); $(table.column(colIdx).nodes()).addClass('highlight');
}); });
......
...@@ -16,7 +16,7 @@ function initDatePicker(selectorName) { ...@@ -16,7 +16,7 @@ function initDatePicker(selectorName) {
function listarRolesPolicias(objParams = {}) { function listarRolesPolicias(objParams = {}) {
axios.get(URI_ROL_POLICIA, objParams).then((response) => { ajaxWebService.get(URI_ROL_POLICIA, objParams).then((response) => {
debugger debugger
let columns = [ let columns = [
{ {
...@@ -104,7 +104,7 @@ function listarRolesPolicias(objParams = {}) { ...@@ -104,7 +104,7 @@ function listarRolesPolicias(objParams = {}) {
let data = nodes.datatable.DataTable().row($(this).parents("tr")).data(); let data = nodes.datatable.DataTable().row($(this).parents("tr")).data();
console.log(data); console.log(data);
axios.get("modals/policias/mantenimientoRol/detalleRol.jspf").then((response) => { ajaxWebService.get("modals/policias/mantenimientoRol/detalleRol.jspf").then((response) => {
debugger debugger
swal({ swal({
title: '<strong>Detalle de rol</strong>', title: '<strong>Detalle de rol</strong>',
...@@ -136,7 +136,7 @@ function listarRolesPolicias(objParams = {}) { ...@@ -136,7 +136,7 @@ function listarRolesPolicias(objParams = {}) {
} }
function listarTipoRoles() { function listarTipoRoles() {
axios.get(URI_TIPOROL_POLICIA).then((result) => { ajaxWebService.get(URI_TIPOROL_POLICIA).then((result) => {
let roles = result.data; let roles = result.data;
let html = "<option>[SELECCIONE]</option>"; let html = "<option>[SELECCIONE]</option>";
roles.forEach(rol => html += `<option value="${rol.codigo}">${rol.descripcion}</option>`); roles.forEach(rol => html += `<option value="${rol.codigo}">${rol.descripcion}</option>`);
...@@ -146,7 +146,7 @@ function listarTipoRoles() { ...@@ -146,7 +146,7 @@ function listarTipoRoles() {
function listarFrecuenciaRol() { function listarFrecuenciaRol() {
axios.get(URI_FRECUENCIA_ROL_POLICIA).then((result) => { ajaxWebService.get(URI_FRECUENCIA_ROL_POLICIA).then((result) => {
let frecuenciasRol = result.data; let frecuenciasRol = result.data;
let html = "<option>[SELECCIONE]</option>"; let html = "<option>[SELECCIONE]</option>";
frecuenciasRol.forEach(f => html += `<option value="${f.codigo}">${f.descripcion}</option>`); frecuenciasRol.forEach(f => html += `<option value="${f.codigo}">${f.descripcion}</option>`);
...@@ -155,7 +155,7 @@ function listarFrecuenciaRol() { ...@@ -155,7 +155,7 @@ function listarFrecuenciaRol() {
} }
function listarSedes(selectorName) { function listarSedes(selectorName) {
axios.get(URI_SEDES).then((result) => { ajaxWebService.get(URI_SEDES).then((result) => {
let sedes = result.data; let sedes = result.data;
sedes = _.orderBy(sedes, s => s.descripcion); sedes = _.orderBy(sedes, s => s.descripcion);
let html = `<option value="">[SELECCIONE]</option>`; let html = `<option value="">[SELECCIONE]</option>`;
...@@ -165,7 +165,7 @@ function listarSedes(selectorName) { ...@@ -165,7 +165,7 @@ function listarSedes(selectorName) {
} }
function listarPolicias(selectorName) { function listarPolicias(selectorName) {
axios.get(URI_POLICIAS).then((result) => { ajaxWebService.get(URI_POLICIAS).then((result) => {
let policias = result.data; let policias = result.data;
policias = _.orderBy(policias, p => p.nombres); policias = _.orderBy(policias, p => p.nombres);
let html = `<option value="">[SELECCIONE]</option>`; let html = `<option value="">[SELECCIONE]</option>`;
...@@ -237,7 +237,7 @@ function registrarRolPolicia() { ...@@ -237,7 +237,7 @@ function registrarRolPolicia() {
estado estado
}; };
axios.post(URI_ROL_POLICIA, params) ajaxWebService.post(URI_ROL_POLICIA, params)
.then((result) => { .then((result) => {
result.data = formatResponse(result); result.data = formatResponse(result);
debugger; debugger;
...@@ -295,7 +295,7 @@ function guardarCambios() { ...@@ -295,7 +295,7 @@ function guardarCambios() {
function mostrarModalNuevoRol() { function mostrarModalNuevoRol() {
axios.get("modals/policias/mantenimientoRol/crearRol.jspf").then((response) => { ajaxModal.get("modals/policias/mantenimientoRol/crearRol.jspf").then((response) => {
swal({ swal({
title: '<strong>Nuevo Rol</strong>', title: '<strong>Nuevo Rol</strong>',
// type: 'info', // type: 'info',
......
...@@ -40,15 +40,15 @@ const DOMEvents = { ...@@ -40,15 +40,15 @@ const DOMEvents = {
let params = { let params = {
usuario: document.querySelector('#usuario').value.trim(), usuario: document.querySelector('#usuario').value.trim(),
pass: document.querySelector('#pass').value, pass: document.querySelector('#pass').value,
codigoProyecto: CODIGO_PROYECTO_ASISTENCIA codigoProyecto: CODIGO_PROYECTO
} }
httpRequest.login(params) httpRequest.login(params)
.then(data => { .then(data => {
$.unblockUI(); $.unblockUI();
console.log(data) console.log(data)
if(data.status){ if (data.status) {
window.location.href="../vistas/main.jsp"; window.location.href = "../vistas/main.jsp";
}else{ } else {
customSwal.alert('¡Error!', "Usuario o contraseña incorrecto.", 'error') customSwal.alert('¡Error!', "Usuario o contraseña incorrecto.", 'error')
} }
}) })
......
...@@ -33,7 +33,7 @@ let DOMNav = { ...@@ -33,7 +33,7 @@ let DOMNav = {
let url = proyectos[i].url;//produccion let url = proyectos[i].url;//produccion
let cp = proyectos[i].codigoProyecto;//produccion let cp = proyectos[i].codigoProyecto;//produccion
if (cp === CODIGO_PROYECTO_ASISTENCIA) { if (cp === CODIGO_PROYECTO) {
continue; continue;
} }
......
...@@ -115,7 +115,6 @@ ...@@ -115,7 +115,6 @@
<script type="text/javascript" src="../plantilla/assets/js/plugins/forms/styling/uniform.min.js"></script> <script type="text/javascript" src="../plantilla/assets/js/plugins/forms/styling/uniform.min.js"></script>
<script type="text/javascript" src="../plantilla/assets/js/core/app.js"></script> <script type="text/javascript" src="../plantilla/assets/js/core/app.js"></script>
<script type="text/javascript" src="../plantilla/assets/js/pages/login.js"></script>
<!-- /theme JS files --> <!-- /theme JS files -->
<!--javascript template--> <!--javascript template-->
<script src="../js/lib/cookies.js" type="text/javascript"></script> <script src="../js/lib/cookies.js" type="text/javascript"></script>
......
...@@ -15,9 +15,11 @@ ...@@ -15,9 +15,11 @@
<script src="../js/lib/cookies.js" type="text/javascript"></script> <script src="../js/lib/cookies.js" type="text/javascript"></script>
<!--<script src="../js/pages/validate.js" type="text/javascript"></script>--> <!--<script src="../js/pages/validate.js" type="text/javascript"></script>-->
<script> <script>
var sidebar = <%=(String)request.getSession().getAttribute("menu")%>; var sidebar = <%=(String) request.getSession().getAttribute("menu")%>;
var nombreUsuario = "<%=(String)request.getSession().getAttribute("nombre")%>"; var nombreUsuario = "<%=(String) request.getSession().getAttribute("nombre")%>";
var rolesUsuario = "<%=(String)request.getSession().getAttribute("roles")%>"; var rolesUsuario = "<%=(String) request.getSession().getAttribute("roles")%>";
var contextPath = "${pageContext.request.contextPath}/";
</script> </script>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment