Commit 139ac49c authored by Andrew Cohen's avatar Andrew Cohen

kill/pause processing, view settings for all lever files

parent 2b4f33e0
......@@ -66,10 +66,10 @@ function pauseAll(bKill)
}
else {
if (bKill) {
cmd=gServerURL+'pauseProcessAll';
cmd=gServerURL+'killProcessAll';
}
else {
cmd=gServerURL+'killProcessAll';
cmd=gServerURL+'pauseProcessAll';
}
editSendServerCommand(cmd,function(){},pauseAll,[]);
......@@ -135,7 +135,7 @@ function buildProcessTables(Q)
var bAllIdle=true;
for (var i=0;i<Q.inProcessQ.length;i++) {
if ('empty'===Q.inProcessQ[i].leverFile)
if (""===Q.inProcessQ[i].leverFile || 'empty'===Q.inProcessQ[i].leverFile)
continue;
var iRow=findProcessRow(tbl,Q.inProcessQ[i].nSlot);
var row=tbl.insertRow(iRow);
......
......@@ -428,16 +428,6 @@ class LeverDB {
});
}
updateConstants(CONSTANTS,fnCallback) {
var sqlCmd="UPDATE tblConstants set jsConstants='"+JSON.stringify(CONSTANTS)+"'";
this._lDB.exec(sqlCmd,function(err){
if (err !== null) {
console.error('lever.js ERROR updateConstants:' + err.message);
}
if (undefined!==fnCallback)
fnCallback;
});
}
updateStatus(status,fnCallback) {
var sqlCmd='UPDATE tblConstants SET uiStatus="'+status+'"';
this._lDB.exec(sqlCmd,function(err){
......@@ -496,6 +486,17 @@ class LeverDB {
} // addCommand
setConstants(CONSTANTS,fnCallback) {
var sqlCmd="UPDATE tblConstants set jsConstants='"+JSON.stringify(CONSTANTS)+"'";
this._lDB.exec(sqlCmd,function(err){
if (err !== null) {
console.error('lever.js ERROR setConstants:' + err.message);
}
if (undefined!==fnCallback)
fnCallback;
});
}
getConstants(fnCallback, callbackArgs) {
if (null === this._lDB) {
console.error('leverdb: no database open');
......@@ -625,6 +626,24 @@ class LeverDB {
editReq.send();
}
}
allRenderParams(ROOT,renderParams) {
const path=require('path');
this.leverGetFileList(ROOT,function(leverFileNames){
for (let f=0;f<leverFileNames.length;f++){
var leverFile=leverFileNames[f];
leverFile=leverFile.replace(/\*/g,path.sep);
leverFile=path.join(ROOT,leverFile);
let leverDB=new LeverDB(leverFile);
leverDB.getConstants(function(CONSTANTS){
CONSTANTS.renderParams=renderParams;
leverDB.setConstants(CONSTANTS,function(){
leverDB.close();
});
});
}
})
}
}
// read all the leverfiles in a folder, send one massive response
......
......@@ -439,8 +439,11 @@ function populateViewTab()
// finally, add store settings button
var viewSetDefault=document.getElementById('viewSetDefault');
viewSetDefault.innerHTML='<br><button class="sbButton" id="viewStoreSettings" '+
'onclick="writeViewConstantsToDB()"> save view settings for all users</button>';
'onclick="writeViewConstantsToDB(false)"> save view settings for all users</button>';
viewSetDefault.innerHTML+='<br><button class="sbButton" id="viewStoreSettingsAll" '+
'onclick="writeViewConstantsToDB(true)"> save view settings for all users for all LEVER files in project</button>';
// finally, finally, add MR controls
if (undefined !== CONSTANTS.mrLevels && CONSTANTS.mrLevels.length > 2) {
var viewMR=document.getElementById('viewMR');
......@@ -459,14 +462,33 @@ function populateViewTab()
drawViewCanvas();
} // populateViewTab
function writeViewConstantsToDB()
function writeAllViewConstants()
{
if (('undefined'===typeof IS_NODE) || (IS_NODE)) {
const LeverDB=require('./lever.js');
var leverDB=new LeverDB;
const path=require('path')
var root=path.dirname(g_db_path);
leverDB.allRenderParams(root,gRenderParams);
}
else {
var cmd=gServerURL + "allRenderParams/";
var body=(JSON.stringify(gRenderParams));
editSendServerCommand(cmd,function(){},writeAllViewConstants,[],false,body);
}
} //
function writeViewConstantsToDB(bAll)
{
CONSTANTS.renderParams=gRenderParams;
if (bAll) {
writeAllViewConstants();
return;
}
if (('undefined'===typeof IS_NODE) || (IS_NODE)) {
const LeverDB=require('./lever.js');
var leverDB=new LeverDB;
leverDB.lDB=gDB;
leverDB.updateConstants(CONSTANTS);
leverDB.setConstants(CONSTANTS);
}
else {
var cmd=gServerURL + g_db_path + "/CONSTANTS/";
......
......@@ -148,6 +148,14 @@ app.post('/:LEVER/createCells/',checkLWT, jsonParser,function(req,res) {
});
app.post('/allRenderParams/',checkLWT, jsonParser, function(req,res) {
var renderParams=req.body;
const LeverDB=require('./leverjs/lever.js');
var leverDB=new LeverDB;
leverDB.allRenderParams(ROOT,renderParams);
res.send('ok');
});
app.post('/pauseProcessAll/',checkLWT, function(req,res) {
const process=require('./leverjs/process.js');
process.pauseOrKillAll(false);
......@@ -265,7 +273,7 @@ app.post('/:LEVER/CONSTANTS/', checkJwt, jsonParser, function(req,res) {
const LeverDB=require('./leverjs/lever.js');
var leverDB=new LeverDB(leverFile);
var CONSTANTS=req.body;
leverDB.updateConstants(CONSTANTS,function() {
leverDB.setConstants(CONSTANTS,function() {
leverDB.close();
});
res.send('ok');
......
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