Fix _id new in Wheres table /settable
This commit is contained in:
@@ -231,6 +231,7 @@ CircuitSchema.statics.getWhatToShow = function(idapp, username) {
|
||||
nome_valuta: 1,
|
||||
fido_scoperto_default: 1,
|
||||
qta_max_default: 1,
|
||||
valuta_per_euro: 1,
|
||||
symbol: 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
@@ -269,6 +270,7 @@ CircuitSchema.statics.getWhatToShow_Unknown = function(idapp, username) {
|
||||
totTransato: 1,
|
||||
fido_scoperto_default: 1,
|
||||
qta_max_default: 1,
|
||||
valuta_per_euro: 1,
|
||||
symbol: 1,
|
||||
color: 1,
|
||||
idCity: 1,
|
||||
|
||||
@@ -331,8 +331,8 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
} else if (params.table === 'hours') {
|
||||
|
||||
} else {
|
||||
if (mydata['_id'] === undefined || (mytablerec.isNew && mydata['_id'] === 0)) {
|
||||
mydata._id = new ObjectID();
|
||||
if ((mydata['_id'] === undefined || (mytablerec.isNew && mydata['_id'] === 0)) && (mytablerec._id === undefined)) {
|
||||
mytablerec._id = new ObjectID();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1522,6 +1522,7 @@ router.post('/upload_from_other_server/:dir', authenticate, (req, res) => {
|
||||
function uploadFile(req, res, version) {
|
||||
// console.log('/upload dir:' + dir);
|
||||
const dir = tools.invertescapeslash(req.params.dir);
|
||||
console.log('inverted = ', dir);
|
||||
const idapp = req.user.idapp;
|
||||
|
||||
const form = new formidable.IncomingForm();
|
||||
@@ -1537,11 +1538,15 @@ function uploadFile(req, res, version) {
|
||||
}
|
||||
}
|
||||
|
||||
form.uploadDir = folder + '/' + dir;
|
||||
const mydir2 = folder + '/' + dir;
|
||||
tools.mkdirpath(mydir2);
|
||||
form.uploadDir = mydir2;
|
||||
try {
|
||||
|
||||
form.on('fileBegin', async function(name, file) {
|
||||
file.path = folder + '/' + file.newFilename;
|
||||
const mydir = folder + '/' + file.newFilename;
|
||||
// tools.mkdirpath(mydir);
|
||||
file.path = mydir
|
||||
});
|
||||
|
||||
form.on('file', async function(name, file) {
|
||||
@@ -1550,6 +1555,8 @@ function uploadFile(req, res, version) {
|
||||
const mydir = tools.getdirByIdApp(idapp) + dirmain +
|
||||
server_constants.DIR_UPLOAD + '/' + dir;
|
||||
|
||||
// console.log('mydir', mydir);
|
||||
|
||||
// Create Dir if doesn't exist:
|
||||
const rismk = tools.mkdirpath(mydir);
|
||||
|
||||
@@ -1562,11 +1569,19 @@ function uploadFile(req, res, version) {
|
||||
//}
|
||||
|
||||
file.name = filename;
|
||||
let newname = mydir + '/' + file.originalFilename;
|
||||
let resized_img = mydir + '/' + server_constants.PREFIX_IMG + filename;
|
||||
|
||||
oldpath = file.newFilename;
|
||||
|
||||
let fromfile = '.'+server_constants.DIR_UPLOAD + '/' + dir + '/' + oldpath;
|
||||
let tofile = '.'+server_constants.DIR_UPLOAD + '/' + dir + '/' +file.originalFilename;
|
||||
let mydircurrent = process.cwd() + '/src/server/router/upload/' + dir;
|
||||
fromfile = mydircurrent + '/' + oldpath;
|
||||
tofile = mydir + '/' + file.originalFilename;
|
||||
let newname = tofile;
|
||||
file.path = newname;
|
||||
// console.log('fromfile', fromfile)
|
||||
// console.log('tofile', tofile);
|
||||
|
||||
if (!tools.sulServer()) {
|
||||
res.end();
|
||||
@@ -1574,7 +1589,7 @@ function uploadFile(req, res, version) {
|
||||
}
|
||||
|
||||
// Move in the folder application !
|
||||
tools.move(oldpath, newname, (err) => {
|
||||
tools.move(fromfile, tofile, (err) => {
|
||||
if (err) {
|
||||
console.log('err uploadDir:', err);
|
||||
res.status(400).send();
|
||||
@@ -1642,7 +1657,7 @@ function uploadFile(req, res, version) {
|
||||
});
|
||||
|
||||
form.on('end', function() {
|
||||
// console.log('-> upload done');
|
||||
console.log('-> upload done');
|
||||
});
|
||||
|
||||
form.on('aborted', () => {
|
||||
|
||||
@@ -133,7 +133,7 @@ router.get('/delall/:username/:qualinotif/:idapp', authenticate, async (req, res
|
||||
});
|
||||
|
||||
router.get('/:username/:lastdataread/:idapp', authenticate, (req, res) => {
|
||||
tools.mylog('GET NotifS : ', req.params);
|
||||
// tools.mylog('GET NotifS : ', req.params);
|
||||
const username = req.params.username;
|
||||
const lastdataread = req.params.lastdataread;
|
||||
const idapp = req.params.idapp;
|
||||
|
||||
@@ -1460,7 +1460,7 @@ module.exports = {
|
||||
|
||||
if (dirmain) {
|
||||
if (!this.sulServer()) {
|
||||
mypath += '/public';
|
||||
mypath += 'public';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3145,7 +3145,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
invertescapeslash(mystr) {
|
||||
return mystr.replace(/-/g, '/');
|
||||
return mystr.replace(/Ç/g, '/');
|
||||
},
|
||||
|
||||
isNumber(n) {
|
||||
|
||||
Reference in New Issue
Block a user