Initial
|
After Width: | Height: | Size: 386 B |
|
After Width: | Height: | Size: 400 B |
|
After Width: | Height: | Size: 375 B |
|
After Width: | Height: | Size: 396 B |
|
After Width: | Height: | Size: 388 B |
|
After Width: | Height: | Size: 8.4 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 17 KiB |
@@ -0,0 +1,264 @@
|
||||
const sdk = require('matrix-js-sdk');
|
||||
const fs = require('fs');
|
||||
// const { ipcRenderer } = require('electron');
|
||||
|
||||
function saveScreenshot(dataUrl) {
|
||||
// Obtener el contenido base64 de la imagen
|
||||
const base64Data = dataUrl.replace(/^data:image\/png;base64,/, '');
|
||||
|
||||
// Especificar la ruta donde se guardará la captura de pantalla
|
||||
const filePath = 'screenshot.png';
|
||||
|
||||
// Escribir la imagen en el disco
|
||||
fs.writeFile(filePath, base64Data, 'base64', (error) => {
|
||||
if (error) {
|
||||
console.error('Error saving screenshot:', error);
|
||||
} else {
|
||||
console.log('Screenshot saved successfully:', filePath);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$('#helpdesk').on('submit', function (event) {
|
||||
event.preventDefault();
|
||||
$('#loader').css('display', 'flex');
|
||||
var description = $('#description').val();
|
||||
|
||||
try {
|
||||
|
||||
const client = sdk.createClient({
|
||||
baseUrl: "https://matrixadm.mind.brm.co",
|
||||
accessToken: "syt_YnJhamFuLmFsZGFuYQ_GsGDJXWtpWkuTayxUIff_4OAXsg",
|
||||
userId: "@brajan.aldana:matrixadm.mind.brm.co"
|
||||
});
|
||||
|
||||
client.on("sync", (state, prevState, res) => {
|
||||
if (state === "SYNCING" && prevState === "SYNCING") {
|
||||
// La sincronización está en progreso
|
||||
} else if (state === "SYNCING" && prevState !== "SYNCING") {
|
||||
// La sincronización acaba de comenzar
|
||||
} else if (state === "PREPARED" && prevState === "SYNCING") {
|
||||
// La sincronización ha terminado, ahora puedes detener el cliente
|
||||
client.stopClient();
|
||||
}
|
||||
});
|
||||
|
||||
var roomid = "!EKItKhtVBxGSvkbPtx:matrixadm.mind.brm.co";
|
||||
|
||||
client.startClient();
|
||||
|
||||
const info_msg = {
|
||||
"body": "Status: **success**<br/> Build: by xoxys",
|
||||
"msgtype": "m.notice",
|
||||
"format": "org.matrix.custom.html",
|
||||
"formatted_body": "<h4>Solicitud HelpDesk</h4><p>Usuario: <strong>EC9596Q</strong><br/>Cedula: <strong>1022969596</strong><br/>" + description + "</p>\n",
|
||||
};
|
||||
|
||||
client.sendMessage(roomid, info_msg);
|
||||
|
||||
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
|
||||
const filename = "C:/RpaClaro/video.webm";
|
||||
|
||||
const contentBuffer = fs.readFileSync(filename);
|
||||
const blob = new Blob([contentBuffer], { type: "video/webm" });
|
||||
|
||||
client.uploadContent(blob, {
|
||||
name: "video.webm",
|
||||
type: "video/webm"
|
||||
}).then(function (url) {
|
||||
var content = {
|
||||
msgtype: "m.video",
|
||||
body: filename,
|
||||
info: {
|
||||
mimetype: "video/webm"
|
||||
},
|
||||
url: url.content_uri
|
||||
};
|
||||
client.sendMessage(roomid, content);
|
||||
});
|
||||
console.log('envio video');
|
||||
|
||||
}, 2000);
|
||||
|
||||
setTimeout(() => {
|
||||
|
||||
const filename = "C:/RpaClaro/logs.txt";
|
||||
|
||||
const contentBuffer = fs.readFileSync(filename);
|
||||
const blob = new Blob([contentBuffer], { type: "text/plain" });
|
||||
|
||||
client.uploadContent(blob, {
|
||||
name: "logs.txt",
|
||||
type: "text/plain"
|
||||
}).then(function (url) {
|
||||
var content = {
|
||||
msgtype: "m.file",
|
||||
body: filename,
|
||||
info: {
|
||||
mimetype: "text/plain"
|
||||
},
|
||||
url: url.content_uri
|
||||
};
|
||||
client.sendMessage(roomid, content);
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
client.stopClient();
|
||||
console.log('termino');
|
||||
|
||||
}, 5000);
|
||||
console.log('envio txt');
|
||||
|
||||
}, 2000);
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
client.stopClient();
|
||||
console.log('termino');
|
||||
$('#loader').css('display', 'none');
|
||||
$('#description').val('');
|
||||
$('#close_drawer').trigger('click');
|
||||
$('#description').attr('disabled', 'disabled');
|
||||
$('#send').attr('disabled', 'disabled');
|
||||
$('#record').css('display', 'block');
|
||||
}, 5000);
|
||||
} catch (e) {
|
||||
console.error('Problema al enviar info Element', e);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$('#screenshot').on('click', function (event) {
|
||||
console.log('screenshot');
|
||||
ipcRenderer.send('screenshot');
|
||||
ipcRenderer.once('screenshot-response', (event, response) => {
|
||||
console.log('Respuesta del proceso principal:', response);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
function handleStream(stream) {
|
||||
const video = document.querySelector('video')
|
||||
video.srcObject = stream
|
||||
video.onloadedmetadata = (e) => video.play()
|
||||
}
|
||||
|
||||
function handleError(e) {
|
||||
console.log(e)
|
||||
}
|
||||
|
||||
$('#record').on('click', function (event) {
|
||||
console.log('record');
|
||||
$('#record').css('display', 'none');
|
||||
$('#close_drawer').trigger('click');
|
||||
ipcRenderer.send('newNotification', { 'title': 'Recopilando evidencias', 'body': 'Grabando pantalla...' });
|
||||
ipcRenderer.send('newLog', {window:'main', log: '-----------------------', msg: '-----------------------', splash: false});
|
||||
ipcRenderer.send('newLog', {window:'main', log: 'SOLICITUD HELPDESK', msg: 'SOLICITUD HELPDESK', splash: false});
|
||||
ipcRenderer.send('newLog', {window:'main', log: '-----------------------', msg: '-----------------------', splash: false});
|
||||
ipcRenderer.send('newLog', {window:'main', log: 'Recopilando evidencias', msg: 'Recopilando evidencias', splash: false});
|
||||
ipcRenderer.send('record');
|
||||
ipcRenderer.once('record-response', async (event, response) => {
|
||||
console.log('devolvio ventana');
|
||||
ipcRenderer.send('newLog', {window:'main', log: 'Respuesta del proceso principal: '+ response, 'msg': 'Respuesta del proceso principal', splash: false});
|
||||
setTimeout(async () => {
|
||||
try {
|
||||
const stream = await navigator.mediaDevices.getUserMedia({
|
||||
audio: false,
|
||||
video: {
|
||||
mandatory: {
|
||||
chromeMediaSource: 'desktop',
|
||||
chromeMediaSourceId: response,
|
||||
minWidth: 1280,
|
||||
maxWidth: 1280,
|
||||
minHeight: 720,
|
||||
maxHeight: 720,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const mediaRecorder = new MediaRecorder(stream);
|
||||
const chunks = [];
|
||||
|
||||
mediaRecorder.ondataavailable = (event) => {
|
||||
if (event.data.size > 0) {
|
||||
chunks.push(event.data);
|
||||
}
|
||||
};
|
||||
|
||||
mediaRecorder.onstop = () => {
|
||||
const blob = new Blob(chunks, { type: 'video/webm' });
|
||||
blob.arrayBuffer().then((buffer) => {
|
||||
ipcRenderer.send('save-video', buffer);
|
||||
ipcRenderer.send('newLog', {window:'main', log:'Termino recopilacion', msg: 'Termino recopilacion', splash: false});
|
||||
|
||||
$('#open_drawer').text('Solicitar HelpDesk');
|
||||
$('#open_drawer').trigger('click');
|
||||
$('#description').removeAttr('disabled');
|
||||
$('#send').removeAttr('disabled');
|
||||
});
|
||||
};
|
||||
|
||||
mediaRecorder.start();
|
||||
|
||||
// Después de un tiempo (por ejemplo, 5000 ms), detener la grabación
|
||||
setTimeout(async () => {
|
||||
mediaRecorder.stop();
|
||||
stream.getTracks().forEach((track) => track.stop());
|
||||
}, 22000);
|
||||
} catch (e) {
|
||||
console.error('Error:', e);
|
||||
}
|
||||
}, 2000);
|
||||
});
|
||||
|
||||
ipcRenderer.once('send-video', async (event, response) => {
|
||||
ipcRenderer.send('newLog', {window:'splash', log:'Enviando video', msg: 'Enviando video', splash: true});
|
||||
|
||||
const client = sdk.createClient({
|
||||
baseUrl: "https://matrixadm.mind.brm.co",
|
||||
accessToken: "syt_YnJhamFuLmFsZGFuYQ_GsGDJXWtpWkuTayxUIff_4OAXsg",
|
||||
userId: "@brajan.aldana:matrixadm.mind.brm.co"
|
||||
});
|
||||
|
||||
client.startClient();
|
||||
|
||||
client.once('sync', function (state, prevState, res) {
|
||||
console.log(state);
|
||||
});
|
||||
|
||||
var roomid = "!EKItKhtVBxGSvkbPtx:matrixadm.mind.brm.co";
|
||||
|
||||
const filename = "C:/Users/LENOVO/Desktop/REPOS/rpa-claro/video.webm";
|
||||
|
||||
const contentBuffer = fs.readFileSync(filename);
|
||||
const blob = new Blob([contentBuffer], { type: "video/webm" });
|
||||
|
||||
client.uploadContent(blob, {
|
||||
name: "video.webm",
|
||||
type: "video/webm"
|
||||
}).then(function (url) {
|
||||
var content = {
|
||||
msgtype: "m.video",
|
||||
body: filename,
|
||||
info: {
|
||||
mimetype: "video/webm"
|
||||
},
|
||||
url: url.content_uri
|
||||
};
|
||||
client.sendMessage(roomid, content);
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
client.stopClient();
|
||||
console.log('termino');
|
||||
}, 2000);
|
||||
ipcRenderer.send('newLog', { 'log': 'Envio video', 'msg': '' });
|
||||
});
|
||||
|
||||
});
|
||||
@@ -0,0 +1,67 @@
|
||||
const $ = require('jquery');
|
||||
const axios = require('axios');
|
||||
const os = require('os');
|
||||
|
||||
$('#loader').css('display', 'flex');
|
||||
|
||||
$(document).on("click", ".app_click", function () {
|
||||
ipcRenderer.send('newNotification', { 'title': 'Abriendo aplicativo', 'body': $(this).attr('name_app') });
|
||||
if ($(this).attr('integrado') == 'true') {
|
||||
data_code = $(this).attr('code')
|
||||
console.log(data_code);
|
||||
ipcRenderer.send('openNewWindow', data_code);
|
||||
} else {
|
||||
error_window = {
|
||||
title: 'Error de aplicativo',
|
||||
content: 'No tienes habilitado este aplicativo, informa al coordinador'
|
||||
}
|
||||
ipcRenderer.send('error_window', error_window);
|
||||
}
|
||||
});
|
||||
|
||||
$('#search-input').on('input', function () {
|
||||
var textoBusqueda = $(this).val().toUpperCase();
|
||||
$('.shortcut').each(function () {
|
||||
var textoElemento = $(this).find('h5').text().toUpperCase();
|
||||
var elemento = $(this);
|
||||
elemento.toggle(textoElemento.includes(textoBusqueda));
|
||||
});
|
||||
});
|
||||
|
||||
function updateButtonCounts() {
|
||||
const totalCount = $('.shortcut').length;
|
||||
const activeCount = $('.shortcut[integrado="true"]').length;
|
||||
const inactiveCount = $('.shortcut[integrado="false"]').length;
|
||||
|
||||
$('#all_apps span').text(`Todos (${totalCount})`);
|
||||
$('#active_apps span').text(`Activos (${activeCount})`);
|
||||
$('#inactive_apps span').text(`Inactivos (${inactiveCount})`);
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
$('#active_apps').on('click', function () {
|
||||
var elementosFiltrados = $('.shortcut[integrado="true"]');
|
||||
$('.shortcut').hide();
|
||||
elementosFiltrados.show();
|
||||
});
|
||||
|
||||
$('#inactive_apps').on('click', function () {
|
||||
var elementosFiltrados = $('.shortcut[integrado="false"]');
|
||||
$('.shortcut').hide();
|
||||
elementosFiltrados.show();
|
||||
});
|
||||
|
||||
$('#all_apps').on('click', function () {
|
||||
$('.shortcut').show();
|
||||
});
|
||||
|
||||
$('#search-input').on('input', function () {
|
||||
var textoBusqueda = $(this).val().toUpperCase();
|
||||
$('.shortcut').each(function () {
|
||||
var textoElemento = $(this).find('h5').text().toUpperCase();
|
||||
var elemento = $(this);
|
||||
elemento.toggle(textoElemento.includes(textoBusqueda));
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,236 @@
|
||||
const $ = require('jquery');
|
||||
const axios = require('axios');
|
||||
const os = require('os');
|
||||
// const remote = require('electron').remote;
|
||||
|
||||
|
||||
// const FindInPage = require('electron-find').FindInPage;
|
||||
|
||||
// let findInPage = new FindInPage(remote.getCurrentWebContents());
|
||||
|
||||
// ipcRenderer.on('on-find', (e, args) => {
|
||||
// findInPage.openFindWindow();
|
||||
// });
|
||||
|
||||
$('#loader').css('display', 'flex');
|
||||
async function index() {
|
||||
try {
|
||||
const urlOkan = "https://io.okan.tools/api/auth/electron";
|
||||
const token = 'HrZTvmBNyQaM6jPI7sHo5ywN35ht/cplIBFeE+4Ufx8=';
|
||||
const urlGetProfile = 'https://io.okan.tools/api/auth/users/electron';
|
||||
let documento;
|
||||
let profile;
|
||||
try {
|
||||
const responseOkan = await axios.post(urlOkan, { user: process.env.USUARIO }, { headers: { 'Authorization': token } });
|
||||
if (responseOkan.data.cod == '0') {
|
||||
ipcRenderer.send('newLog', { window: 'splash', log: 'Token obtenido: ' + responseOkan.data.data, msg: 'Información del documento encontrado...', splash: true });
|
||||
console.log('Token: ' + responseOkan.data.data);
|
||||
const token_okan = 'Bearer ' + responseOkan.data.data;
|
||||
console.log(token_okan);
|
||||
try {
|
||||
const responseGetProfile = await axios.get(urlGetProfile, { headers: { 'Authorization': token_okan } });
|
||||
if (responseGetProfile.data.cod == '0') {
|
||||
ipcRenderer.send('newLog', { window: 'splash', log: 'Perfil obtenido: ' + responseGetProfile.data.data.profile, msg: 'Información del documento encontrado...', splash: true });
|
||||
console.log('Profile: ' + JSON.stringify(responseGetProfile.data.data));
|
||||
documento = responseGetProfile.data.data.document_number;
|
||||
profile = responseGetProfile.data.data.profile.id;
|
||||
} else {
|
||||
ipcRenderer.send('newLog', { window: 'splash', log: 'Ha ocurrido un error: ' + responseGetProfile.data.message, msg: 'Ha ocurrido un error', splash: true });
|
||||
}
|
||||
} catch (e) {
|
||||
ipcRenderer.send('newLog', { window: 'splash', log: 'Error al obtener el perfil: ' + e, msg: 'Error al obtener el perfil: '+e, splash: true });
|
||||
}
|
||||
} else {
|
||||
ipcRenderer.send('newLog', { window: 'splash', log: 'Ha ocurrido un error: ' + responseGetProfile.data.message, msg: 'Ha ocurrido un error', splash: true });
|
||||
}
|
||||
} catch (error) {
|
||||
ipcRenderer.send('newLog', { window: 'splash', log: 'Error al obtener el token: ' + error, msg: 'Error al obtener el token: '+error, splash: true });
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// const foundElement = datos.find(item => item.nickname === nicknameToFind);
|
||||
|
||||
// if (foundElement) {
|
||||
// ipcRenderer.send('newLog', { window: 'splash', log: 'Usuario encontrado: ' + nicknameToFind, msg: 'Información del usuario encontrada...', splash: true });
|
||||
// if (foundElement.document_number) {
|
||||
// documento = foundElement.document_number;
|
||||
// ipcRenderer.send('newLog', { window: 'splash', log: 'Documento encontrado: ' + documento, msg: 'Información del documento encontrado...', splash: true });
|
||||
// } else {
|
||||
// ipcRenderer.send('newLog', { window: 'splash', log: 'Documento no encontrado', msg: 'No se pudo encontrar el documento del usuario...', splash: true });
|
||||
// }
|
||||
// } else {
|
||||
// ipcRenderer.send('newLog', { window: 'splash', log: 'Usuario no encontrado', msg: 'No se pudo obtener el usuario...', splash: true });
|
||||
// }
|
||||
|
||||
// const urlProfile = `https://io.okan.tools/api/auth/user/${documento}`;
|
||||
// const responseProfile = await axios.get(urlProfile, { headers: { "Accept": "*/*", "Content-Type": "application/json" } });
|
||||
// if (responseProfile.data['cod'] == '0') {
|
||||
// profile = responseProfile.data['data'];
|
||||
// ipcRenderer.send('newLog', { window: 'splash', log: 'Perfil encontrado: ' + profile.profile.id, msg: 'Información del perfil encontrado...', splash: true });
|
||||
// }
|
||||
|
||||
const urlAplicativos = `https://adm.okan.tools/wp-json/okanapiwp/v1/aplicativos/${documento}/${profile}`;
|
||||
const responseAplicativos = await axios.get(urlAplicativos, { headers: { "Accept": "*/*", "Content-Type": "application/json" } });
|
||||
|
||||
var apps_okan = [];
|
||||
var type_app;
|
||||
var url_service;
|
||||
var code_app;
|
||||
if (responseAplicativos.data['cod'] == '0') {
|
||||
const promises = responseAplicativos.data['data'].map(async element => {
|
||||
if (element['rpa'] == "true") {
|
||||
if (element['url'].includes('RpaClaro://?code=')) {
|
||||
|
||||
var code_temp = element['url'];
|
||||
code_app = code_temp.slice(code_temp.indexOf("=") + 1);
|
||||
if(code_app != 'IRR123' && code_app != 'ACC098' && code_app != 'XLT001' && code_app != 'CTB002' && code_app != 'AVY003'){
|
||||
url_service = "https://rpa.mind.brm.co/app";
|
||||
type_app = 'apps';
|
||||
} else {
|
||||
url_service = "https://rpa.mind.brm.co/desk";
|
||||
type_app = 'desk';
|
||||
}
|
||||
|
||||
apps_okan.push(
|
||||
{
|
||||
'code_app': code_app,
|
||||
'name': element['nombre_app'],
|
||||
'type_app': type_app,
|
||||
'url_service': url_service,
|
||||
'url_logo': element['logo']
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var status_integrado;
|
||||
var status;
|
||||
|
||||
ipcRenderer.send('newLog', { window: 'splash', log: 'Aplicativos obtenidos: ' + apps_okan.length, msg: 'Obteniendo aplicaciones...', splash: true });
|
||||
|
||||
|
||||
const promises = [];
|
||||
|
||||
async function makeRequest(element) {
|
||||
try {
|
||||
|
||||
const bodyContent = {
|
||||
code: element.code_app,
|
||||
user: process.env.USUARIO,
|
||||
};
|
||||
|
||||
console.log('_____________________________');
|
||||
|
||||
await axios.post(element.url_service, bodyContent, { headers: { "Accept": "*/*", "Content-Type": "application/json" } })
|
||||
.then(response => {
|
||||
console.log(response.data); // Access the response data here
|
||||
status = response.data == 'Invalid parameter' ? false : true;
|
||||
console.log(status);
|
||||
status_integrado = status ? 'integrado' : 'no_integrado';
|
||||
console.log(status_integrado);
|
||||
|
||||
console.log('App: ' + element.code_app + ' - ' + status + ' - ' + element.name);
|
||||
$('#aplicativos').append(`<div class="col-3 col-md-3 col-xl-3 shortcut app_click ${status_integrado}" name_app="${element.name}" type_app="${element.type_app}" integrado="${status}" code="${element.code_app}"><div class="card border-none text-center"><div class="card-body hp-knowledge-basic-card"><img src="${element.url_logo}" class="logo"><h5>${element.name}</h5></div></div></div>`);
|
||||
})
|
||||
.catch(error => {
|
||||
ipcRenderer.send('newLog', { window: 'splash', log: 'Error al consultar aplicación', msg: 'Error al consultar aplicación...', splash: true });
|
||||
status = false;
|
||||
status_integrado = 'no_integrado';
|
||||
console.log('App: ' + element.code_app + ' - ' + status + ' - ' + element.name);
|
||||
$('#aplicativos').append(`<div class="col-3 col-md-3 col-xl-3 shortcut app_click ${status_integrado}" name_app="${element.name}" type_app="${element.type_app}" integrado="${status}" code="${element.code_app}"><div class="card border-none text-center"><div class="card-body hp-knowledge-basic-card"><img src="${element.url_logo}" class="logo"><h5>${element.name}</h5></div></div></div>`);
|
||||
});
|
||||
console.log('_____________________________');
|
||||
|
||||
} catch (e) {
|
||||
// ipcRenderer.send('newLog', { window: 'splash', log: 'Error al consultar aplicación', msg: 'Error al consultar aplicación...', splash: true });
|
||||
// status = false;
|
||||
// status_integrado = 'no_integrado';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async function processApps() {
|
||||
for (const element of apps_okan) {
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
// await makeRequest(element);
|
||||
}
|
||||
|
||||
// Lógica de ordenación
|
||||
var divs = $('.shortcut').sort(function (a, b) {
|
||||
var textoA = $(a).find('h5').text().toUpperCase();
|
||||
var textoB = $(b).find('h5').text().toUpperCase();
|
||||
return (textoA < textoB) ? -1 : (textoA > textoB) ? 1 : 0;
|
||||
});
|
||||
|
||||
// Limpia el contenedor original
|
||||
$('.shortcut').remove();
|
||||
|
||||
// Agrega los divs ordenados de nuevo al contenedor
|
||||
divs.appendTo('#aplicativos');
|
||||
|
||||
ipcRenderer.send('newLog', { window: 'splash', log: 'Termino de ordenar', msg: 'Estamos terminando...', splash: true });
|
||||
|
||||
// Esperar un poco antes de emitir el evento 'ordeno'
|
||||
setTimeout(function () {
|
||||
console.log('ordeno apps');
|
||||
ipcRenderer.send('ordeno');
|
||||
$('#loader').css('display', 'none');
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
processApps();
|
||||
} catch (error) {
|
||||
console.log("Error en la ejecución: " + error);
|
||||
ipcRenderer.send('newLog', { window: 'splash', log: 'Error en la ejecución', msg: 'Ha ocurrido un error: ' + error, splash: true });
|
||||
}
|
||||
}
|
||||
index();
|
||||
|
||||
$(document).on("click", ".app_click", function () {
|
||||
ipcRenderer.send('newNotification', { 'title': 'Abriendo aplicativo', 'body': $(this).attr('name_app') });
|
||||
console.log('click');
|
||||
console.log($(this).attr('integrado'));
|
||||
if ($(this).attr('integrado') == 'true') {
|
||||
data_code = $(this).attr('code')
|
||||
console.log(data_code);
|
||||
ipcRenderer.send('openNewWindow', data_code);
|
||||
} else {
|
||||
error_window = {
|
||||
title: 'Error de aplicativo',
|
||||
content: 'No tienes habilitado este aplicativo, informa al coordinador'
|
||||
}
|
||||
ipcRenderer.send('error_window', error_window);
|
||||
}
|
||||
});
|
||||
|
||||
$('#search-input').on('input', function () {
|
||||
var textoBusqueda = $(this).val().toUpperCase();
|
||||
$('.shortcut').each(function () {
|
||||
var textoElemento = $(this).find('h5').text().toUpperCase();
|
||||
var elemento = $(this);
|
||||
elemento.toggle(textoElemento.includes(textoBusqueda));
|
||||
});
|
||||
});
|
||||
|
||||
$('#active_apps').on('click', function () {
|
||||
var elementosFiltrados = $('.shortcut[integrado="true"]');
|
||||
$('.shortcut').hide();
|
||||
elementosFiltrados.show();
|
||||
});
|
||||
|
||||
$('#inactive_apps').on('click', function () {
|
||||
var elementosFiltrados = $('.shortcut[integrado="false"]');
|
||||
$('.shortcut').hide();
|
||||
elementosFiltrados.show();
|
||||
});
|
||||
|
||||
$('#all_apps').on('click', function () {
|
||||
$('.shortcut').show();
|
||||
});
|
||||
@@ -0,0 +1,190 @@
|
||||
const $ = require('jquery');
|
||||
const axios = require('axios');
|
||||
const os = require('os');
|
||||
|
||||
let data_apps_user = []; // Initialize as an empty array
|
||||
|
||||
ipcRenderer.on('data-apps', (event, data_apps) => {
|
||||
data_apps_user = data_apps;
|
||||
});
|
||||
|
||||
$('#loader').css('display', 'flex');
|
||||
async function index() {
|
||||
try {
|
||||
const urlOkan = "https://io.okan.tools/api/auth/electron";
|
||||
const token = 'HrZTvmBNyQaM6jPI7sHo5ywN35ht/cplIBFeE+4Ufx8=';
|
||||
const urlGetProfile = 'https://io.okan.tools/api/auth/users/electron';
|
||||
let documento;
|
||||
let profile;
|
||||
try {
|
||||
const responseOkan = await axios.post(urlOkan, { user: process.env.USUARIO }, { headers: { 'Authorization': token } });
|
||||
if (responseOkan.data.cod == '0') {
|
||||
const token_okan = 'Bearer ' + responseOkan.data.data;
|
||||
try {
|
||||
const responseGetProfile = await axios.get(urlGetProfile, { headers: { 'Authorization': token_okan } });
|
||||
if (responseGetProfile.data.cod == '0') {
|
||||
documento = responseGetProfile.data.data.document_number;
|
||||
profile = responseGetProfile.data.data.profile.id;
|
||||
} else {
|
||||
ipcRenderer.send('newLog', { window: 'splash', log: 'Ha ocurrido un error: ' + responseGetProfile.data.message, msg: 'Ha ocurrido un error', splash: true });
|
||||
}
|
||||
} catch (e) {
|
||||
ipcRenderer.send('newLog', { window: 'splash', log: 'Error al obtener el perfil: ' + e, msg: 'Error al obtener el perfil: ' + e, splash: true });
|
||||
}
|
||||
} else {
|
||||
ipcRenderer.send('newLog', { window: 'splash', log: 'Ha ocurrido un error: ' + responseGetProfile.data.message, msg: 'Ha ocurrido un error', splash: true });
|
||||
}
|
||||
} catch (error) {
|
||||
ipcRenderer.send('newLog', { window: 'splash', log: 'Error al obtener el token: ' + error, msg: 'Error al obtener el token: ' + error, splash: true });
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const urlAplicativos = `https://adm.okan.tools/wp-json/okanapiwp/v1/aplicativos/${documento}/${profile}`;
|
||||
const responseAplicativos = await axios.get(urlAplicativos, { headers: { "Accept": "*/*", "Content-Type": "application/json" } });
|
||||
|
||||
var apps_okan = [];
|
||||
var type_app;
|
||||
var url_service;
|
||||
var code_app;
|
||||
let new_apps = [];
|
||||
if (responseAplicativos.data['cod'] == '0') {
|
||||
console.log('_________________');
|
||||
console.log('Aplicativos:');
|
||||
console.log(responseAplicativos.data['data']);
|
||||
console.log('_________________');
|
||||
|
||||
console.log('data_apps:', data_apps_user);
|
||||
|
||||
// Filter RPA apps and extract codes in one pass
|
||||
const new_apps = responseAplicativos.data['data'].filter(element =>
|
||||
element['url'].includes('RpaClaro://?code=')
|
||||
);
|
||||
|
||||
console.log(new_apps);
|
||||
|
||||
// Process each app from new_apps
|
||||
for (const app of new_apps) {
|
||||
// Check if app code exists in data_apps_user
|
||||
const appExists = data_apps_user.web?.some(webApp => webApp.code === app.url.split('=')[1]) ||
|
||||
data_apps_user.desk?.some(deskApp => deskApp.code === app.url.split('=')[1]);
|
||||
|
||||
// Extract app information
|
||||
const appInfo = {
|
||||
nombre_app: app.nombre_app,
|
||||
// type_app: app.tipo,
|
||||
code_app: app.url.split('=')[1],
|
||||
logo: app.logo,
|
||||
status: appExists,
|
||||
status_integrado: appExists ? 'integrado' : 'no_integrado',
|
||||
};
|
||||
|
||||
// Add to apps_okan array
|
||||
apps_okan.push(appInfo);
|
||||
|
||||
// Add HTML element for the app
|
||||
$('#aplicativos').append(`
|
||||
<div class="col-3 col-md-3 col-xl-3 shortcut app_click ${appInfo.status_integrado}"
|
||||
name_app="${appInfo.nombre_app}"
|
||||
integrado="${appInfo.status}"
|
||||
code="${appInfo.code_app}">
|
||||
<div class="card border-none text-center">
|
||||
<div class="card-body hp-knowledge-basic-card">
|
||||
<img src="${appInfo.logo}" class="logo">
|
||||
<h5>${appInfo.nombre_app}</h5>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
|
||||
console.log(apps_okan);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function processApps() {
|
||||
for (const element of apps_okan) {
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
// await makeRequest(element);
|
||||
}
|
||||
|
||||
// Lógica de ordenación
|
||||
var divs = $('.shortcut').sort(function (a, b) {
|
||||
var textoA = $(a).find('h5').text().toUpperCase();
|
||||
var textoB = $(b).find('h5').text().toUpperCase();
|
||||
return (textoA < textoB) ? -1 : (textoA > textoB) ? 1 : 0;
|
||||
});
|
||||
|
||||
// Limpia el contenedor original
|
||||
$('.shortcut').remove();
|
||||
|
||||
// Agrega los divs ordenados de nuevo al contenedor
|
||||
divs.appendTo('#aplicativos');
|
||||
|
||||
ipcRenderer.send('newLog', { window: 'splash', log: 'Termino de ordenar', msg: 'Estamos terminando...', splash: true });
|
||||
|
||||
// Esperar un poco antes de emitir el evento 'ordeno'
|
||||
setTimeout(function () {
|
||||
console.log('ordeno apps');
|
||||
ipcRenderer.send('ordeno');
|
||||
$('#loader').css('display', 'none');
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
processApps();
|
||||
} catch (error) {
|
||||
console.log("Error en la ejecución: " + error);
|
||||
ipcRenderer.send('newLog', { window: 'splash', log: 'Error en la ejecución', msg: 'Ha ocurrido un error: ' + error, splash: true });
|
||||
}
|
||||
}
|
||||
index();
|
||||
|
||||
$(document).on("click", ".app_click", function () {
|
||||
ipcRenderer.send('newNotification', { 'title': 'Abriendo aplicativo', 'body': $(this).attr('name_app') });
|
||||
console.log('click');
|
||||
console.log($(this).attr('integrado'));
|
||||
if ($(this).attr('integrado') == 'true') {
|
||||
data_code = $(this).attr('code')
|
||||
console.log(data_code);
|
||||
ipcRenderer.send('openNewWindow', data_code);
|
||||
} else {
|
||||
error_window = {
|
||||
title: 'Error de aplicativo',
|
||||
content: 'No tienes habilitado este aplicativo, informa al coordinador'
|
||||
}
|
||||
ipcRenderer.send('error_window', error_window);
|
||||
}
|
||||
});
|
||||
|
||||
$('#search-input').on('input', function () {
|
||||
var textoBusqueda = $(this).val().toUpperCase();
|
||||
$('.shortcut').each(function () {
|
||||
var textoElemento = $(this).find('h5').text().toUpperCase();
|
||||
var elemento = $(this);
|
||||
elemento.toggle(textoElemento.includes(textoBusqueda));
|
||||
});
|
||||
});
|
||||
|
||||
$('#active_apps').on('click', function () {
|
||||
var elementosFiltrados = $('.shortcut[integrado="true"]');
|
||||
$('.shortcut').hide();
|
||||
elementosFiltrados.show();
|
||||
});
|
||||
|
||||
$('#inactive_apps').on('click', function () {
|
||||
var elementosFiltrados = $('.shortcut[integrado="false"]');
|
||||
$('.shortcut').hide();
|
||||
elementosFiltrados.show();
|
||||
});
|
||||
|
||||
$('#all_apps').on('click', function () {
|
||||
$('.shortcut').show();
|
||||
});
|
||||