Sorting fixed

- added tables Skills, Sectors,
This commit is contained in:
Paolo Arena
2021-10-05 00:20:12 +02:00
parent 177489521d
commit 3d7471f2d2
8 changed files with 286 additions and 14 deletions

View File

@@ -187,4 +187,45 @@ Mer 22/09 ORE 00:47: 🔥 Si è appena Registrato "Paolo3 Arena3 (paoloar77A) (n
Mer 22/09 ORE 00:53: 🔥 Si è appena Registrato "Paolo3 Arena3 (paoloar77A) (n. 2) Mer 22/09 ORE 00:53: 🔥 Si è appena Registrato "Paolo3 Arena3 (paoloar77A) (n. 2)
Mer 22/09 ORE 00:55: 🔥 Si è appena Registrato "Paolo3 Arena3 (paoloar77A) (n. 2) Mer 22/09 ORE 00:55: 🔥 Si è appena Registrato "Paolo3 Arena3 (paoloar77A) (n. 2)
Mer 22/09 ORE 00:56: 🔥 Si è appena Registrato "Paolo3 Arena3 (paoloar77A) (n. 2) Mer 22/09 ORE 00:56: 🔥 Si è appena Registrato "Paolo3 Arena3 (paoloar77A) (n. 2)
Mer 22/09 ORE 01:12: 🔥 Si è appena Registrato "Paolo3 Arena3 (paoloar77A) (n. 2) Mer 22/09 ORE 01:12: 🔥 Si è appena Registrato "Paolo3 Arena3 (paoloar77A) (n. 2)
Dom 03/10 ORE 16:07: L'utente Paolo Arena (paoloar77) è stato cancellato (nascosto) da Paolo Arena
Lun 04/10 ORE 10:48: Prenotazione Evento [Paolo Arena] 'Ciaooooooo 2' (13/10/2021 Dalle 21:00) (Nuovo)
1 partecipanti all'Evento
Lun 04/10 ORE 12:03: Cancellazione Evento [Paolo Arena] 'Ciaooooooo 2' (13/10/2021 Dalle 21:00) (Nuovo)
1 partecipanti all'Evento
Lun 04/10 ORE 12:03: Cancellazione Evento [Paolo Arena] 'Ciaooooooo 2' (13/10/2021 Dalle 21:00)
Lun 04/10 ORE 12:14: Prenotazione Evento [Paolo Arena] 'Evento Secondo' (13/10/2021 Dalle 21:00) (Nuovo)
1 partecipanti all'Evento
1 partecipanti a Cena Condivisa
Lun 04/10 ORE 14:23: Prenotazione Evento [Paolo Arena] 'Evento Secondo' (13/10/2021 Dalle 21:00) (Nuovo)
1 partecipanti all'Evento
1 partecipanti a Cena Condivisa
Lun 04/10 ORE 14:23: Cancellazione Evento [Paolo Arena] 'Evento Secondo' (13/10/2021 Dalle 21:00) (Nuovo)
1 partecipanti all'Evento
1 partecipanti a Cena Condivisa
Lun 04/10 ORE 14:23: Cancellazione Evento [Paolo Arena] 'Evento Secondo' (13/10/2021 Dalle 21:00)
Lun 04/10 ORE 14:23: Prenotazione Evento [Paolo Arena] 'Evento Secondo' (13/10/2021 Dalle 21:00) (modificato)
1 partecipanti all'Evento
1 partecipanti a Cena Condivisa
Lun 04/10 ORE 14:23: Prenotazione Evento [Paolo Arena] 'Evento Secondo' (13/10/2021 Dalle 21:00) (Nuovo)
1 partecipanti all'Evento
Lun 04/10 ORE 15:32: Prenotazione Evento [Paolo Arena] 'Ciaooooooo 1' (06/10/2021 Dalle 21:00) (Nuovo)
2 partecipanti all'Evento
1 partecipanti a Cena
1 partecipanti a Cena Condivisa
Lun 04/10 ORE 15:32: Cancellazione Evento [Paolo Arena] 'Ciaooooooo 1' (06/10/2021 Dalle 21:00) (Nuovo)
2 partecipanti all'Evento
1 partecipanti a Cena
1 partecipanti a Cena Condivisa
Lun 04/10 ORE 15:32: Cancellazione Evento [Paolo Arena] 'Ciaooooooo 1' (06/10/2021 Dalle 21:00)
Lun 04/10 ORE 15:36: Prenotazione Evento [Paolo Arena] 'Evento Secondo' (13/10/2021 Dalle 21:00) (Nuovo)
1 partecipanti all'Evento

72
src/server/models/level.js Executable file
View File

@@ -0,0 +1,72 @@
const mongoose = require('mongoose').set('debug', false);
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;
mongoose.level = 'F';
const tools = require('../tools/general');
const {ObjectID} = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true;
});
const LevelSchema = new Schema({
_id: {
type: Number,
},
descr: {
type: String,
},
years_of_exp: {
type: Number,
},
}, {_id: false});
LevelSchema.pre('save', async function (next) {
if (this.isNew) {
const myrec = await Level.findOne().limit(1).sort({_id:-1});
if (!!myrec) {
if (myrec._doc._id === 0)
this._id = 1;
else
this._id = myrec._doc._id + 1;
} else {
this._id = 1;
}
}
next();
});
LevelSchema.statics.findAllIdApp = function(idapp) {
const Level = this;
const query = [
{$sort: {descr: 1}},
];
return Level.aggregate(query).then((arrrec) => {
return arrrec;
});
};
LevelSchema.statics.getFieldsForSearch = function() {
return [
{field: 'label', type: tools.FieldType.string},
{field: 'descr', type: tools.FieldType.string}];
};
LevelSchema.statics.executeQueryTable = function(idapp, params) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, 0, params);
};
const Level = mongoose.model('Level', LevelSchema);
module.exports = {Level};

55
src/server/models/sector.js Executable file
View File

@@ -0,0 +1,55 @@
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;
mongoose.level = "F";
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true
});
const SectorSchema = new Schema({
descr: {
type: String,
},
icon: {
type: String,
},
img: {
type: String,
},
});
SectorSchema.statics.findAllIdApp = function (idapp) {
const Sector = this;
const query = [
{ $sort: { descr: 1 } }
];
return Sector
.aggregate(query)
.then((arrrec) => {
return arrrec
})
};
SectorSchema.statics.getFieldsForSearch = function () {
return [{ field: 'descr', type: tools.FieldType.string }]
};
SectorSchema.statics.executeQueryTable = function (idapp, params) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, 0, params);
};
const Sector = mongoose.model('Sector', SectorSchema);
module.exports = { Sector };

59
src/server/models/skill.js Executable file
View File

@@ -0,0 +1,59 @@
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;
mongoose.level = "F";
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true
});
const SkillSchema = new Schema({
descr: {
type: String,
},
idSector: {
type: String
},
icon: {
type: String,
},
img: {
type: String,
},
});
SkillSchema.statics.findAllIdApp = function (idapp) {
const Skill = this;
const query = [
{ $sort: { descr: 1 } }
];
return Skill
.aggregate(query)
.then((arrrec) => {
return arrrec
})
};
SkillSchema.statics.getFieldsForSearch = function () {
return [{ field: 'label', type: tools.FieldType.string },
{ field: 'descr', type: tools.FieldType.string }]
};
SkillSchema.statics.executeQueryTable = function (idapp, params) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, 0, params);
};
const Skill = mongoose.model('Skill', SkillSchema);
module.exports = { Skill };

View File

@@ -40,6 +40,9 @@ const { MyEvent } = require('../models/myevent');
const { Contribtype } = require('../models/contribtype'); const { Contribtype } = require('../models/contribtype');
const { PaymentType } = require('../models/paymenttype'); const { PaymentType } = require('../models/paymenttype');
const { Discipline } = require('../models/discipline'); const { Discipline } = require('../models/discipline');
const { Skill } = require('../models/skill');
const { Sector } = require('../models/sector');
const { Level } = require('../models/level');
const { Newstosent } = require('../models/newstosent'); const { Newstosent } = require('../models/newstosent');
const { MyPage } = require('../models/mypage'); const { MyPage } = require('../models/mypage');
const { CalZoom } = require('../models/calzoom'); const { CalZoom } = require('../models/calzoom');
@@ -281,6 +284,12 @@ function getTableByTableName(tablename) {
mytable = ListaIngresso; mytable = ListaIngresso;
else if (tablename === 'graduatorias') else if (tablename === 'graduatorias')
mytable = Graduatoria; mytable = Graduatoria;
else if (tablename === 'skills')
mytable = Skill;
else if (tablename === 'sectors')
mytable = Sector;
else if (tablename === 'levels')
mytable = Level;
return mytable return mytable
} }
@@ -292,7 +301,8 @@ router.post('/settable', authenticate, (req, res) => {
mydata.idapp = req.user.idapp; mydata.idapp = req.user.idapp;
if (params.table === 'permissions') {
if (shared_consts.TABLES_ID_NUMBER.includes(params.table)) {
if (mydata["_id"] === undefined) { if (mydata["_id"] === undefined) {
mydata._id = 1; mydata._id = 1;
} }
@@ -306,7 +316,7 @@ router.post('/settable', authenticate, (req, res) => {
let mytablerec = new mytable(mydata); let mytablerec = new mytable(mydata);
console.log('mytablerec', mytablerec); // console.log('mytablerec', mytablerec);
const mytablestrutt = getTableByTableName(params.table); const mytablestrutt = getTableByTableName(params.table);
@@ -1137,11 +1147,11 @@ router.get('/loadsite/:userId/:idapp', authenticate_noerror, (req, res) => {
}); });
router.get('/loadsite/:userId/:idapp/:vers', authenticate_noerror, (req, res) => { router.get('/loadsite/:userId/:idapp/:vers', authenticate_noerror, (req, res) => {
let version = req.params.vers; let versionstr = req.params.vers;
version = version.replace('.', '');
version = version.replace('.', '');
load(req, res, parseInt(version)); let version = tools.getVersionint(versionstr);
load(req, res, version);
}); });
function load(req, res, version) { function load(req, res, version) {
@@ -1201,6 +1211,9 @@ function load(req, res, version) {
let workers = User.getusersWorkersList(idapp); let workers = User.getusersWorkersList(idapp);
let storehouses = Storehouse.findAllIdApp(idapp); let storehouses = Storehouse.findAllIdApp(idapp);
let departments = Department.findAllIdApp(idapp); let departments = Department.findAllIdApp(idapp);
let levels = Level.findAllIdApp(idapp);
let skills = Skill.findAllIdApp(idapp);
let sectors = Sector.findAllIdApp(idapp);
let cart = null; let cart = null;
let orderscart = null; let orderscart = null;
if (sall) { if (sall) {
@@ -1220,7 +1233,8 @@ function load(req, res, version) {
} }
return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, settings, permissions, disciplines, newstosent, mailinglist, mypage, gallery, paymenttype, calcstat, calzoom, producers, cart, storehouses, departments, orderscart, groups, resps, workers, internalpages]) return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, settings, permissions, disciplines, newstosent, mailinglist, mypage, gallery, paymenttype, calcstat, calzoom, producers, cart, storehouses, departments, orderscart, groups, resps, workers, internalpages,
levels, skills, sectors ])
.then((arrdata) => { .then((arrdata) => {
// console.table(arrdata); // console.table(arrdata);
const myuser = req.user; const myuser = req.user;
@@ -1254,6 +1268,9 @@ function load(req, res, version) {
workers: arrdata[22], workers: arrdata[22],
myuser, myuser,
internalpages: arrdata[23], internalpages: arrdata[23],
levels: arrdata[24],
skills: arrdata[25],
sectors: arrdata[26],
}); });
}) })
.catch((e) => { .catch((e) => {
@@ -1377,17 +1394,20 @@ router.post('/upload_from_other_server/:dir', authenticate, (req, res) => {
}); });
function uploadFile(req, res, version) {
router.post('/upload/:dir', authenticate, (req, res) => { // console.log('/upload dir:' + dir);
const dir = req.params.dir; const dir = req.params.dir;
const idapp = req.user.idapp; const idapp = req.user.idapp;
// console.log('/upload dir:' + dir);
const form = new formidable.IncomingForm(); const form = new formidable.IncomingForm();
form.parse(req); form.parse(req);
let dirmain = '/statics';
if (version > 0) {
dirmain = '';
}
form.uploadDir = folder + '/' + dir; form.uploadDir = folder + '/' + dir;
try { try {
@@ -1398,7 +1418,7 @@ router.post('/upload/:dir', authenticate, (req, res) => {
form.on('file', async function (name, file) { form.on('file', async function (name, file) {
try { try {
console.log('Uploaded ' + file.name); console.log('Uploaded ' + file.name);
const mydir = tools.getdirByIdApp(idapp) + '/statics/upload/' + dir; const mydir = tools.getdirByIdApp(idapp) + dirmain + '/upload/' + dir;
// Create Dir if doesn't exist: // Create Dir if doesn't exist:
tools.mkdirpath(mydir); tools.mkdirpath(mydir);
@@ -1435,6 +1455,20 @@ router.post('/upload/:dir', authenticate, (req, res) => {
} catch (e) { } catch (e) {
console.log('Error', e) console.log('Error', e)
} }
}
router.post('/upload/:dir', authenticate, (req, res) => {
uploadFile(req, res, 0);
});
router.post('/upload/:dir/:vers', authenticate, (req, res) => {
let versionstr = req.params.vers;
let version = tools.getVersionint(versionstr);
uploadFile(req, res, version);
}); });

View File

@@ -69,7 +69,9 @@ router.post('/', authenticate, (req, res) => {
// res.status(201).json({ data: 'Subscription saved.' }); // res.status(201).json({ data: 'Subscription saved.' });
res.send({ data: 'Subscription saved.' }); res.send({ data: 'Subscription saved.' });
console.log('req.body', req.body) console.log('New Subscription id=', subscriptionModel.userId);
// console.log('req.body', req.body)
if (req.body.options !== null) { if (req.body.options !== null) {
tools.sendBackNotif(subscription, req.body.options) tools.sendBackNotif(subscription, req.body.options)

View File

@@ -1971,4 +1971,11 @@ module.exports = {
return shared_consts.PaymentTypes[idmetodo] return shared_consts.PaymentTypes[idmetodo]
}, },
getVersionint(versionstr) {
let version = versionstr.replace('.', '');
version = version.replace('.', '');
return parseInt(version);
}
}; };

View File

@@ -39,6 +39,8 @@ module.exports = {
'In Contanti alla CNM' 'In Contanti alla CNM'
], ],
TABLES_ID_NUMBER: ['permissions', 'levels'],
CashType: { CashType: {
None: 0, None: 0,
Incoming: 1, Incoming: 1,