Lista Navi

This commit is contained in:
Paolo Arena
2020-04-07 14:34:29 +02:00
parent 8c9a5f7518
commit 7c575c0687
14 changed files with 317 additions and 154 deletions

View File

@@ -62,9 +62,14 @@ router.post('/msgnave', authenticate, async (req, res) => {
try {
let ris = null;
if (mydata.tipomsg === tools.TipoMsg.SEND_MSG_SINGOLO)
ris = await telegrambot.sendMsgTelegram(idapp, mydata.username, mydata.msgpar1, true); // Anche a STAFF
else
if (mydata.tipomsg === tools.TipoMsg.SEND_MSG_SINGOLO) {
let mymsg = '';
if (!!mydata.username_mitt) {
mymsg = '[' + tools.getres__('MSG_SEND_FROM', res) + ' ' + mydata.username_mitt + ']:' + tools.ACAPO;
}
mymsg += mydata.msgpar1;
ris = await telegrambot.sendMsgTelegram(idapp, mydata.username, mymsg, true, mydata.username_mitt); // Anche a STAFF
} else
ris = await telegrambot.sendMsgTelegramToNave(idapp, mydata);
if (ris)
@@ -73,38 +78,60 @@ router.post('/msgnave', authenticate, async (req, res) => {
res.send({ code: server_constants.RIS_CODE_ERR, ris: null });
}catch (e) {
} catch (e) {
res.status(400).send(e);
}
});
router.post('/getnave', authenticate, async (req, res) => {
const idapp = req.body.idapp;
const riga = req.body.riga;
const col = req.body.col;
const riga1don = req.body.riga1don;
const col1don = req.body.col1don;
const ind_order = req.body.ind_order;
const nave = await NavePersistente.findByRigaCol(idapp, riga, col);
if (!!nave) {
nave._doc.rec = await Nave.getNaveByRigaCol(idapp, riga1don, col1don);
if (ind_order >= 0)
nave._doc.ind_order = ind_order;
nave._doc.listadonatoridelsognatore = await Nave.getDonatoridelSognatore(idapp, riga1don, col1don);
}
const navi_partenza = await NavePersistente.findAllIdApp(idapp);
ris = { nave, navi_partenza };
if (ris)
res.send({ code: server_constants.RIS_CODE_OK, ris });
else
res.status(400).send(e);
});
router.post('/getnavi', authenticate, async (req, res) => {
const idapp = req.body.idapp;
let arrnavi = [];
let test = false;
if (test) {
let indriga = 7;
let indcol = 49;
arrnavi.push({ riga: indriga, col: indcol });
} else {
for (let indriga = 4; indriga <= 9; indriga++) {
let numcol = Math.pow(2, indriga - 1);
let quanti = Math.ceil(numcol / 8);
for (let indquanti = 1; indquanti <= quanti; indquanti++) {
arrnavi.push({ riga: indriga, col: (indquanti * 8) - 7 });
}
}
}
let arrnavi = await NavePersistente.findAllIdApp(idapp);
for (nave of arrnavi) {
nave.rec = await Nave.getNaveByRigaCol(idapp, nave.riga, nave.col);
//nave.rec = await Nave.getNaveByRigaCol(idapp, nave.riga, nave.col);
nave._doc.rec = {
donatore: {},
mediatore: null
};
let riganave = nave.riga;
let colnave = nave.col;
// if (riganave < 4) {
// riganave = 4;
// colnave = 1;
// }
// nave._doc.rec.donatore.navepersistente = await NavePersistente.findByRigaColByDonatore(idapp, riganave, colnave, 0);
nave._doc.rec.donatore.navepersistente = await NavePersistente.findOne({ idapp, riga: riganave, col: colnave });
}
const navi_partenza = await NavePersistente.findAllIdApp(idapp);