Web Editor home made
This commit is contained in:
13
.vscode/launch.json
vendored
13
.vscode/launch.json
vendored
@@ -1,6 +1,19 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Server Debug",
|
||||
"request": "launch",
|
||||
"runtimeArgs": [
|
||||
"run-script",
|
||||
"start"
|
||||
],
|
||||
"runtimeExecutable": "npm",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"type": "node"
|
||||
},
|
||||
{
|
||||
"name": "ServerSide",
|
||||
"program": "${workspaceFolder}/src/server/server.js",
|
||||
|
||||
@@ -2,7 +2,7 @@ const mongoose = require('mongoose').set('debug', false)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
const {ObjectID, ObjectId} = require('mongodb');
|
||||
const { ObjectID, ObjectId } = require('mongodb');
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
@@ -16,7 +16,7 @@ mongoose.plugin(schema => {
|
||||
const MyElemSchema = new Schema({
|
||||
_id: {
|
||||
type: ObjectId,
|
||||
default: function() {
|
||||
default: function () {
|
||||
return new ObjectId();
|
||||
},
|
||||
},
|
||||
@@ -108,6 +108,9 @@ const MyElemSchema = new Schema({
|
||||
class2: {
|
||||
type: String,
|
||||
},
|
||||
class3: {
|
||||
type: String,
|
||||
},
|
||||
styleadd: {
|
||||
type: String,
|
||||
},
|
||||
@@ -125,6 +128,9 @@ const MyElemSchema = new Schema({
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
style: {
|
||||
type: String,
|
||||
},
|
||||
size: {
|
||||
type: String,
|
||||
},
|
||||
@@ -137,7 +143,7 @@ const MyElemSchema = new Schema({
|
||||
colorsub: {
|
||||
type: String
|
||||
},
|
||||
},
|
||||
}
|
||||
],
|
||||
list: [
|
||||
{
|
||||
@@ -157,7 +163,7 @@ const MyElemSchema = new Schema({
|
||||
],
|
||||
});
|
||||
|
||||
MyElemSchema.pre('save', async function(next) {
|
||||
MyElemSchema.pre('save', async function (next) {
|
||||
if (this.isNew) {
|
||||
this._id = new ObjectID();
|
||||
}
|
||||
@@ -167,7 +173,7 @@ MyElemSchema.pre('save', async function(next) {
|
||||
|
||||
MyElemSchema.statics.getFieldsForSearch = function () {
|
||||
return [{ field: 'title', type: tools.FieldType.string },
|
||||
{ field: 'content', type: tools.FieldType.string }]
|
||||
{ field: 'content', type: tools.FieldType.string }]
|
||||
};
|
||||
|
||||
MyElemSchema.statics.executeQueryTable = function (idapp, params, user) {
|
||||
|
||||
@@ -89,6 +89,12 @@ const SiteSchema = new Schema({
|
||||
next_payment: {
|
||||
type: Date
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
keywords: {
|
||||
type: String,
|
||||
},
|
||||
confsite: {
|
||||
options: { // ConfSite
|
||||
type: Number,
|
||||
@@ -114,12 +120,22 @@ module.exports.executeQueryTable = async function (idapp, params, userreq) {
|
||||
const extrapar = params.extrapar;
|
||||
|
||||
if (extrapar) {
|
||||
return await Site.findOne({idapp: extrapar}, {name: 1, manageremail: 1, confsite: 1}).lean();
|
||||
if (User.isManager(userreq.perm)) {
|
||||
return await Site.findOne({ idapp: extrapar }).lean();
|
||||
} else {
|
||||
return await Site.findOne({ idapp: extrapar }, {
|
||||
name: 1, manageremail: 1,
|
||||
confsite: 1,
|
||||
description: 1,
|
||||
keywords: 1,
|
||||
}).lean();
|
||||
}
|
||||
}
|
||||
|
||||
if (User.isAdmin(userreq.perm)) {
|
||||
const myarr = await Site.find({});
|
||||
|
||||
// return await Site.find({}).lean();
|
||||
return ({ count: myarr.length, rows: myarr })
|
||||
|
||||
}
|
||||
|
||||
@@ -1593,10 +1593,11 @@ function uploadFile(req, res, version) {
|
||||
// console.log('tofile', tofile);
|
||||
|
||||
if (!tools.sulServer()) {
|
||||
res.end();
|
||||
return;
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Move in the folder application !
|
||||
tools.move(fromfile, tofile, (err) => {
|
||||
if (err) {
|
||||
|
||||
@@ -1456,6 +1456,13 @@ module.exports = {
|
||||
return myapp.abilitanave;
|
||||
},
|
||||
|
||||
removeLastSlashFromPath: function(myString) {
|
||||
let regex = /\/$/;
|
||||
let result = myString.replace(regex, "");
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
getdirByIdApp: function(idapp, dirmain = false) {
|
||||
|
||||
let mypath = '';
|
||||
@@ -1474,7 +1481,7 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
|
||||
return mypath;
|
||||
return this.removeLastSlashFromPath(mypath);
|
||||
},
|
||||
|
||||
getAdminEmailByIdApp: function(idapp) {
|
||||
|
||||
Reference in New Issue
Block a user