Skip to content

Commit

Permalink
Release 0.0.2:
Browse files Browse the repository at this point in the history
- Include the log panel
  • Loading branch information
jmrodriguezc committed Sep 20, 2019
1 parent 2ebe7d0 commit 63a47ac
Show file tree
Hide file tree
Showing 14 changed files with 390 additions and 176 deletions.
53 changes: 53 additions & 0 deletions app/assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,56 @@ section.tab-content > .form-inline {
#processor button#stop {
margin-left: 0.1em;
}

/* loader */
.loading-page {
z-index: 10000;
background: transparent;
width: 99%;
height: 99%;
position: absolute;
display: none;
}
.loading-icon {
position: absolute;
left: 50%;
top: 50%;
z-index: 1;
width: 150px;
height: 150px;
margin: -75px 0 0 -75px;
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid goldenrod;
width: 120px;
height: 120px;
-webkit-animation: spin 2s linear infinite;
animation: spin 2s linear infinite;
}
@-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}

/* Add animation to "page content" */
.animate-bottom {
position: relative;
-webkit-animation-name: animatebottom;
-webkit-animation-duration: 1s;
animation-name: animatebottom;
animation-duration: 1s
}

@-webkit-keyframes animatebottom {
from { bottom:-100px; opacity:0 }
to { bottom:0px; opacity:1 }
}

@keyframes animatebottom {
from{ bottom:-100px; opacity:0 }
to{ bottom:0; opacity:1 }
}
2 changes: 1 addition & 1 deletion app/processes.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<body>
<header></header>

<section class="processes" id="processes"></section>
<section class="logger" id="logger"></section>

<section class="processor" id="processor"></section>

Expand Down
23 changes: 20 additions & 3 deletions app/renderer-process/exceptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@ function showMessageBox(head, message, end=false) {
}
};

// We assign properties to the `module.exports` property, or reassign `module.exports` it to something totally different.
// In the end of the day, calls to `require` returns exactly what `module.exports` is set to.
module.exports.showMessageBox = showMessageBox;
function loadingWorkflow() {
$(`.loading-page`).show();
$(document.body).css({'cursor' : 'wait'});
$(`#main`).css({'opacity' : 0.5});
$(`#executor`).css({'opacity' : 0.5});
}

function stopLoadingWorkflow() {
$(`.loading-page`).hide();
$(document.body).css({'cursor' : 'default'});
$(`#main`).css({'opacity' : 1});
$(`#executor`).css({'opacity' : 1});
}

// Exporting modules
module.exports = {
showMessageBox: showMessageBox,
loadingWorkflow: loadingWorkflow,
stopLoadingWorkflow: stopLoadingWorkflow
};
78 changes: 78 additions & 0 deletions app/renderer-process/executor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
Global variables
*/
let importer = require('./imports');
let exceptor = require('./exceptor');
let sessioner = require('./sessioner');
let path = require('path');
let cProcess = require('child_process');
let proc = null;


// Exec process
function execSyncProcess(cmd) {
try {
console.log(cmd);
proc = cProcess.execSync(cmd);
} catch (ex) {
console.log(`stderr: ${ex.error}`);
exceptor.stopLoadingWorkflow();
exceptor.showMessageBox('Error Message', `${ex.error}`);
}
};

function execProcess(cmd, log, wfname) {
// eexecute command line
console.log(cmd);
proc = cProcess.exec(cmd);

// save the process id in the session storage
sessioner.addProcessesToSession(proc.pid, log, wfname, `${__dirname}/../processes.html`);

// Handle on stderr
proc.stderr.on('data', (data) => {
console.log(`stderr: ${data}`);
exceptor.stopLoadingWorkflow();
exceptor.showMessageBox('Error Message', `${data}`);
});

// Handle on exit event
proc.on('close', (code) => {
console.log(`Child exited with code ${code}`);
exceptor.stopLoadingWorkflow();
});
};


/*
* Events
*/
// Execute process
if ( document.querySelector('#executor #start') !== null ) {
document.querySelector('#executor #start').addEventListener('click', function() {
// get the type of Workflow
let smkfile = importer.tasktable.smkfile;
let cfgfile = importer.tasktable.cfgfile;
// get the name of workflow
let wfname = path.basename(cfgfile, '.json');
// Check and retrieves parameters depending on the type of workflow
let params = importer.parameters.createParameters(cfgfile);
if ( params ) {
// loading...
exceptor.loadingWorkflow();
// Execute the workflow
setTimeout(function() {
let cmd_smk = `"${process.env.ISANXOT_PYTHON3x_HOME}/tools/Scripts/snakemake.exe" --configfile "${params.cfgfile}" --snakefile "${smkfile}" --cores ${params.nthreads} --directory "${params.outdir}" --rerun-incomplete`;
let cmd_unlock = `${cmd_smk} --unlock `;
let cmd_clean = `${cmd_smk} --cleanup-metadata "${smkfile}"`;
// Sync process that Unlock the output directory
// First we unlock the ouput directory
let cmd1 = `${cmd_unlock} && ${cmd_clean}`
execSyncProcess(cmd1);
// Then, we execute the workflow
let cmd2 = `${cmd_smk} > "${params.logfile}" 2>&1`;
execProcess(cmd2, params.logfile, wfname);
}, 1000); // due the execSync block everything, we have to wait until loading event is finished
}
});
}
9 changes: 6 additions & 3 deletions app/renderer-process/imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ function importHTMLtemplate(wfhref) {
// Import main templates
importHTMLtemplate(`${__dirname}/../sections/footer.html`);
importHTMLtemplate(`${__dirname}/../sections/executor.html`);
importHTMLtemplate(`${__dirname}/../sections/executor.html`);
importHTMLtemplate(`${__dirname}/../sections/processor.html`);
importHTMLtemplate(`${__dirname}/../sections/processes.html`);
importHTMLtemplate(`${__dirname}/../sections/logger.html`);
importHTMLtemplate(`${__dirname}/../sections/loader.html`);
importHTMLtemplate(`${__dirname}/../sections/advance/help_adv.html`);
importHTMLtemplate(`${__dirname}/../sections/lblfree/help_lblfree.html`);

Expand All @@ -52,8 +54,9 @@ if ( wfid !== undefined ) {
var parameters = require('./lblfree/parameters');
require('./lblfree/samples');
}
// add the module to process the jobs
require('./processor');
// add the module to execute the jobs
// require('./processor');
require('./executor');

// Export the In the end of the day, calls to `require` returns exactly what `module.exports` is set to.
module.exports.tasktable = tasktable;
Expand Down
9 changes: 8 additions & 1 deletion app/renderer-process/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ class log {
this.pid = pid;
this.file = file;
this.name = name;
}
}
readLogFile() {
fs.readFile(this.file, 'utf8', function(err, contents) {
console.log(this.file);
console.log(contents);
});
console.log('after calling readFile');
}
}

// class logger extends log {
Expand Down
Loading

0 comments on commit 63a47ac

Please sign in to comment.