Export Movements to CSV File
fix Visibility for a Circuit
This commit is contained in:
@@ -45,8 +45,13 @@ const CircuitSchema = new Schema({
|
|||||||
type: Number,
|
type: Number,
|
||||||
}],
|
}],
|
||||||
pub_to_share: {
|
pub_to_share: {
|
||||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_GROUPS_FOLLOW
|
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||||
},
|
},
|
||||||
|
visibility: [
|
||||||
|
{
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
],
|
||||||
longdescr: {
|
longdescr: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
@@ -202,9 +207,9 @@ CircuitSchema.statics.getFieldsForSearch = function() {
|
|||||||
{field: 'descr', type: tools.FieldType.string}];
|
{field: 'descr', type: tools.FieldType.string}];
|
||||||
};
|
};
|
||||||
|
|
||||||
CircuitSchema.statics.executeQueryTable = function(idapp, params) {
|
CircuitSchema.statics.executeQueryTable = function(idapp, params, user) {
|
||||||
params.fieldsearch = this.getFieldsForSearch();
|
params.fieldsearch = this.getFieldsForSearch();
|
||||||
return tools.executeQueryTable(this, idapp, params);
|
return tools.executeQueryTable(this, idapp, params, user);
|
||||||
};
|
};
|
||||||
|
|
||||||
CircuitSchema.statics.getWhatToShow = function(idapp, username) {
|
CircuitSchema.statics.getWhatToShow = function(idapp, username) {
|
||||||
@@ -229,6 +234,7 @@ CircuitSchema.statics.getWhatToShow = function(idapp, username) {
|
|||||||
symbol: 1,
|
symbol: 1,
|
||||||
idCity: 1,
|
idCity: 1,
|
||||||
pub_to_share: 1,
|
pub_to_share: 1,
|
||||||
|
visibility: 1,
|
||||||
color: 1,
|
color: 1,
|
||||||
abbrev: 1,
|
abbrev: 1,
|
||||||
data_costituz: 1,
|
data_costituz: 1,
|
||||||
@@ -267,6 +273,7 @@ CircuitSchema.statics.getWhatToShow_Unknown = function(idapp, username) {
|
|||||||
color: 1,
|
color: 1,
|
||||||
idCity: 1,
|
idCity: 1,
|
||||||
pub_to_share: 1,
|
pub_to_share: 1,
|
||||||
|
visibility: 1,
|
||||||
abbrev: 1,
|
abbrev: 1,
|
||||||
data_costituz: 1,
|
data_costituz: 1,
|
||||||
photos: 1,
|
photos: 1,
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ const MyGoodSchema = new Schema({
|
|||||||
type: Number,
|
type: Number,
|
||||||
}],
|
}],
|
||||||
pub_to_share: {
|
pub_to_share: {
|
||||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_GROUPS_FOLLOW
|
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||||
},
|
},
|
||||||
numLevel: {
|
numLevel: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ const MyHospSchema = new Schema({
|
|||||||
type: Number,
|
type: Number,
|
||||||
}],
|
}],
|
||||||
pub_to_share: {
|
pub_to_share: {
|
||||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_GROUPS_FOLLOW
|
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||||
},
|
},
|
||||||
descr: {
|
descr: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ const MySkillSchema = new Schema({
|
|||||||
type: Number,
|
type: Number,
|
||||||
}],
|
}],
|
||||||
pub_to_share: {
|
pub_to_share: {
|
||||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_GROUPS_FOLLOW
|
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||||
},
|
},
|
||||||
numLevel: {
|
numLevel: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
|||||||
@@ -417,7 +417,7 @@ router.post('/settable', authenticate, async (req, res) => {
|
|||||||
typedir = shared_consts.TypeNotifs.TYPEDIR_CIRCUITS;
|
typedir = shared_consts.TypeNotifs.TYPEDIR_CIRCUITS;
|
||||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_NEW_REC;
|
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_NEW_REC;
|
||||||
circuitnameDest = myrec ? myrec.name : '';
|
circuitnameDest = myrec ? myrec.name : '';
|
||||||
setnotif = true;
|
setnotif = (myrec.visibility === 0); // Not send a notification to others if the Circuit is HIDDEN or PRIVATE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -731,17 +731,17 @@ module.exports = {
|
|||||||
// Pass object into sendNotification
|
// Pass object into sendNotification
|
||||||
return webpush.sendNotification(subscription._doc, JSON.stringify(payload),
|
return webpush.sendNotification(subscription._doc, JSON.stringify(payload),
|
||||||
pushOptions).
|
pushOptions).
|
||||||
catch(err => {
|
catch((err) => {
|
||||||
if (err.statusCode === 410) {
|
if (err.statusCode === 410) {
|
||||||
// Gone: is not valid anymore (Expired probably!), so I have to delete from my db
|
// Gone: is not valid anymore (Expired probably!), so I have to delete from my db
|
||||||
return Subscription.findOneAndRemove({_id: subscription._id});
|
return Subscription.findOneAndRemove({_id: subscription._id});
|
||||||
} else {
|
} else {
|
||||||
console.log('Subscription is no longer valid: ', err);
|
console.log('Subscription is no longer valid: ', err);
|
||||||
}
|
}
|
||||||
|
}).then((ris) => {
|
||||||
|
|
||||||
}).
|
}).
|
||||||
then(ris => {
|
// console.log('sendNotification', ris);
|
||||||
console.log('sendNotification', ris);
|
|
||||||
}).
|
|
||||||
catch(err => {
|
catch(err => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
@@ -1157,17 +1157,19 @@ module.exports = {
|
|||||||
|
|
||||||
let recnotif = null;
|
let recnotif = null;
|
||||||
if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ) {
|
if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ) {
|
||||||
recnotif = await this.sendNotifCircuitByUsername(shared_consts.CIRCUITCMD.SENDCOINS_REQ_SENT, idapp, extrarec.dest, usernameOrig, username_action, circuitname, circuit.path, null,
|
recnotif = await this.sendNotifCircuitByUsername(shared_consts.CIRCUITCMD.SENDCOINS_REQ_SENT, idapp, extrarec.dest, usernameOrig,
|
||||||
|
username_action, circuitname, circuit.path, null,
|
||||||
false, '', extrarec);
|
false, '', extrarec);
|
||||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) {
|
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) {
|
||||||
await this.sendNotifCircuitByUsername(shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT_SENT, idapp, extrarec.dest, usernameOrig, username_action, circuitname, circuit.path, null,
|
await this.sendNotifCircuitByUsername(shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT_SENT, idapp, extrarec.dest, usernameOrig,
|
||||||
|
username_action, circuitname, circuit.path, null,
|
||||||
false, '', extrarec);
|
false, '', extrarec);
|
||||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE) {
|
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE) {
|
||||||
await this.sendNotifCircuitByUsername(shared_consts.CIRCUITCMD.SENDCOINS_REFUSE_SENT, idapp, extrarec.dest, usernameOrig, username_action, circuitname, circuit.path, null,
|
await this.sendNotifCircuitByUsername(shared_consts.CIRCUITCMD.SENDCOINS_REFUSE_SENT, idapp, extrarec.dest, usernameOrig,
|
||||||
|
username_action, circuitname, circuit.path, null,
|
||||||
false, '', extrarec);
|
false, '', extrarec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (recnotif)
|
if (recnotif)
|
||||||
extrarec.notifIdToUpdate = recnotif._id;
|
extrarec.notifIdToUpdate = recnotif._id;
|
||||||
ris = await this.sendNotifCircuitByUsername(cmd, idapp, usernameOrig, extrarec.dest, username_action, circuitname, circuit.path,
|
ris = await this.sendNotifCircuitByUsername(cmd, idapp, usernameOrig, extrarec.dest, username_action, circuitname, circuit.path,
|
||||||
@@ -1176,7 +1178,6 @@ module.exports = {
|
|||||||
|
|
||||||
extrarec.notifIdToUpdate = '';
|
extrarec.notifIdToUpdate = '';
|
||||||
|
|
||||||
|
|
||||||
if (ris)
|
if (ris)
|
||||||
inviato = true;
|
inviato = true;
|
||||||
// ++Todo: Inviare anche agli Admin ?!
|
// ++Todo: Inviare anche agli Admin ?!
|
||||||
@@ -2018,7 +2019,7 @@ module.exports = {
|
|||||||
filteradmin = true;
|
filteradmin = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myfilter['pub_to_share'] === shared_consts.PUBTOSHARE.ONLY_GROUPS_FOLLOW) {
|
if (myfilter['pub_to_share'] === shared_consts.PUBTOSHARE.ONLY_TABLE_FOLLOW && params.table === 'mygroups') {
|
||||||
|
|
||||||
let arraygroups = [];
|
let arraygroups = [];
|
||||||
|
|
||||||
@@ -2038,6 +2039,27 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
query.push({$match: {$and: [condition]}});
|
||||||
|
} else if (myfilter['pub_to_share'] === shared_consts.PUBTOSHARE.ONLY_TABLE_FOLLOW && params.table === 'circuits') {
|
||||||
|
|
||||||
|
let arraycircuits = [];
|
||||||
|
|
||||||
|
if (user && user.profile.mycircuits) {
|
||||||
|
arraycircuits = user.profile.mycircuits.map(rec => rec.circuitname);
|
||||||
|
}
|
||||||
|
// prendere i gruppi dell'utente
|
||||||
|
|
||||||
|
// Cerca tra i gruppi di ogni record, se combaciano almeno 1
|
||||||
|
condition = {
|
||||||
|
'profile.mycircuits':
|
||||||
|
{
|
||||||
|
$elemMatch: {
|
||||||
|
circuitname: {$in: arraycircuits},
|
||||||
|
},
|
||||||
|
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
query.push({$match: {$and: [condition]}});
|
query.push({$match: {$and: [condition]}});
|
||||||
} else if (shared_consts.TABLES_ENABLE_GETREC_BYID.includes(params.table)) {
|
} else if (shared_consts.TABLES_ENABLE_GETREC_BYID.includes(params.table)) {
|
||||||
// Rimuovi dalla query quelli non visibili
|
// Rimuovi dalla query quelli non visibili
|
||||||
@@ -2099,17 +2121,26 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.table === 'mygroups') {
|
if (params.table === 'mygroups' || params.table === 'circuits') {
|
||||||
// BINARY CHECK (?): const filter = [{ visibility: { $bitsAnyClear: [1] } }];
|
// BINARY CHECK (?): const filter = [{ visibility: { $bitsAnyClear: [1] } }];
|
||||||
// if (!User.isAdmin(req.user.perm)) {
|
// if (!User.isAdmin(req.user.perm)) {
|
||||||
// not Visibility_Group.HIDDEN
|
// not Visibility_Group.HIDDEN
|
||||||
if (!filteradmin) {
|
if (!filteradmin) {
|
||||||
const filter = [
|
const filter = [
|
||||||
|
{
|
||||||
|
$or: [
|
||||||
{
|
{
|
||||||
visibility: {
|
visibility: {
|
||||||
$nin: [shared_consts.Visibility_Group.HIDDEN],
|
$nin: [shared_consts.Visibility_Group.HIDDEN],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
createdBy: {
|
||||||
|
$eq: user.username,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
];
|
];
|
||||||
query.push({$match: {$and: filter}});
|
query.push({$match: {$and: filter}});
|
||||||
}
|
}
|
||||||
@@ -3331,6 +3362,6 @@ module.exports = {
|
|||||||
|
|
||||||
getAhref(username, link) {
|
getAhref(username, link) {
|
||||||
return `<a href='${link}'>${username}</a>`;
|
return `<a href='${link}'>${username}</a>`;
|
||||||
}
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ module.exports = {
|
|||||||
|
|
||||||
PUBTOSHARE: {
|
PUBTOSHARE: {
|
||||||
ALL: 0,
|
ALL: 0,
|
||||||
ONLY_GROUPS_FOLLOW: 1,
|
ONLY_TABLE_FOLLOW: 1,
|
||||||
},
|
},
|
||||||
|
|
||||||
TAB_COUNTRY: 'countries',
|
TAB_COUNTRY: 'countries',
|
||||||
|
|||||||
Reference in New Issue
Block a user