Web Editor home made

This commit is contained in:
Surya Paolo
2022-11-17 08:09:48 +01:00
parent 60cf27c002
commit 745d4829bb
7 changed files with 52 additions and 9 deletions

BIN
.DS_Store vendored

Binary file not shown.

13
.vscode/launch.json vendored
View File

@@ -1,6 +1,19 @@
{ {
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{
"name": "Server Debug",
"request": "launch",
"runtimeArgs": [
"run-script",
"start"
],
"runtimeExecutable": "npm",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
},
{ {
"name": "ServerSide", "name": "ServerSide",
"program": "${workspaceFolder}/src/server/server.js", "program": "${workspaceFolder}/src/server/server.js",

View File

@@ -2,7 +2,7 @@ const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema; const Schema = mongoose.Schema;
const tools = require('../tools/general'); const tools = require('../tools/general');
const {ObjectID, ObjectId} = require('mongodb'); const { ObjectID, ObjectId } = require('mongodb');
mongoose.Promise = global.Promise; mongoose.Promise = global.Promise;
mongoose.level = "F"; mongoose.level = "F";
@@ -16,7 +16,7 @@ mongoose.plugin(schema => {
const MyElemSchema = new Schema({ const MyElemSchema = new Schema({
_id: { _id: {
type: ObjectId, type: ObjectId,
default: function() { default: function () {
return new ObjectId(); return new ObjectId();
}, },
}, },
@@ -108,6 +108,9 @@ const MyElemSchema = new Schema({
class2: { class2: {
type: String, type: String,
}, },
class3: {
type: String,
},
styleadd: { styleadd: {
type: String, type: String,
}, },
@@ -125,6 +128,9 @@ const MyElemSchema = new Schema({
description: { description: {
type: String, type: String,
}, },
style: {
type: String,
},
size: { size: {
type: String, type: String,
}, },
@@ -137,7 +143,7 @@ const MyElemSchema = new Schema({
colorsub: { colorsub: {
type: String type: String
}, },
}, }
], ],
list: [ list: [
{ {
@@ -157,7 +163,7 @@ const MyElemSchema = new Schema({
], ],
}); });
MyElemSchema.pre('save', async function(next) { MyElemSchema.pre('save', async function (next) {
if (this.isNew) { if (this.isNew) {
this._id = new ObjectID(); this._id = new ObjectID();
} }
@@ -167,7 +173,7 @@ MyElemSchema.pre('save', async function(next) {
MyElemSchema.statics.getFieldsForSearch = function () { MyElemSchema.statics.getFieldsForSearch = function () {
return [{ field: 'title', type: tools.FieldType.string }, 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) { MyElemSchema.statics.executeQueryTable = function (idapp, params, user) {

View File

@@ -89,6 +89,12 @@ const SiteSchema = new Schema({
next_payment: { next_payment: {
type: Date type: Date
}, },
description: {
type: String,
},
keywords: {
type: String,
},
confsite: { confsite: {
options: { // ConfSite options: { // ConfSite
type: Number, type: Number,
@@ -114,12 +120,22 @@ module.exports.executeQueryTable = async function (idapp, params, userreq) {
const extrapar = params.extrapar; const extrapar = params.extrapar;
if (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)) { if (User.isAdmin(userreq.perm)) {
const myarr = await Site.find({}); const myarr = await Site.find({});
// return await Site.find({}).lean();
return ({ count: myarr.length, rows: myarr }) return ({ count: myarr.length, rows: myarr })
} }

View File

@@ -1593,9 +1593,10 @@ function uploadFile(req, res, version) {
// console.log('tofile', tofile); // console.log('tofile', tofile);
if (!tools.sulServer()) { if (!tools.sulServer()) {
res.end(); res.end();
return; return;
} }
// Move in the folder application ! // Move in the folder application !
tools.move(fromfile, tofile, (err) => { tools.move(fromfile, tofile, (err) => {

View File

@@ -1456,6 +1456,13 @@ module.exports = {
return myapp.abilitanave; return myapp.abilitanave;
}, },
removeLastSlashFromPath: function(myString) {
let regex = /\/$/;
let result = myString.replace(regex, "");
return result;
},
getdirByIdApp: function(idapp, dirmain = false) { getdirByIdApp: function(idapp, dirmain = false) {
let mypath = ''; let mypath = '';
@@ -1474,7 +1481,7 @@ module.exports = {
} }
} }
return mypath; return this.removeLastSlashFromPath(mypath);
}, },
getAdminEmailByIdApp: function(idapp) { getAdminEmailByIdApp: function(idapp) {