Skip to content

Commit

Permalink
Merge branch 'hotfix2.8.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Syno committed Oct 11, 2019
2 parents 890c508 + eaf440a commit b132ee1
Show file tree
Hide file tree
Showing 33 changed files with 1,332 additions and 982 deletions.
4 changes: 2 additions & 2 deletions config/mail.js
Expand Up @@ -55,7 +55,7 @@ let mailConf = {
},
expediteur: 'NoReply <no-reply@newmips.com>',
administrateur: 'Responsable Newmips <contact@newmips.com>',
host: 'https://'+process.env.HOSTNAME+'.newmips.studio'
host: 'https://'+process.env.SUB_DOMAIN+'.newmips.studio'
},
cloud: {
transport: {
Expand All @@ -69,7 +69,7 @@ let mailConf = {
},
expediteur: 'NoReply <no-reply@newmips.com>',
administrateur: 'Responsable Newmips <contact@newmips.com>',
host: 'https://'+process.env.HOSTNAME+'.newmips.studio'
host: 'https://'+process.env.SUB_DOMAIN+'.newmips.studio'
}
}

Expand Down
6 changes: 4 additions & 2 deletions locales/en-EN.json
Expand Up @@ -13,7 +13,8 @@
"success": "Update completed. You could now log in with your username and password",
"hasAlreadyPassword": "Can not update. This user already has a password.",
"userNotExist": "Error, this user doesn't exist.",
"passwordNotMatch": "Sorry, passwords do not match. Password must contain at least 8 characters."
"passwordNotMatch": "Sorry, passwords do not match. Password must contain at least 8 characters.",
"userNotActivate": "Your account is not activated, please do the first login procedure."
},
"authentication": "Connection",
"login": "Login",
Expand Down Expand Up @@ -110,7 +111,8 @@
"modal_title": "How to clone this application ?",
"text1": "In order to clone your application just execute this command:",
"text2": "Your Gitlab login is:",
"text3": "and your password is the one you use on your generator account"
"text3": "and your password is the one of your generator account or your Gitlab account if you have changed it on gitlab",
"text4": "(If you have forgotten your password you can do a password change procedure on the generator, it will also change the password of your gitlab account)"
},
"no_project_1": "No application found.",
"no_project_2": "You can generate one directly from <a href='/'>home</a> or with a <a href='/instruction_script/index'>script</a>."
Expand Down
8 changes: 5 additions & 3 deletions locales/fr-FR.json
Expand Up @@ -13,7 +13,8 @@
"success": "Mise à jour effectuée. Vous pouvez désormais vous connecter avec votre identifiant et votre nouveau mot de passe.",
"hasAlreadyPassword": "Mise à jour impossible. Cet utilisateur possède déjà un mot de passe.",
"userNotExist": "Erreur, cet utilisateur n'existe pas.",
"passwordNotMatch": "Désolé, les mots de passe ne correspondent pas. Le mot de passe doit faire minimum 8 caractères."
"passwordNotMatch": "Désolé, les mots de passe ne correspondent pas. Le mot de passe doit faire minimum 8 caractères.",
"userNotActivate": "Votre compte n'est pas activé, merci de faire la procédure de première connexion."
},
"authentication": "Connexion",
"login": "Login",
Expand Down Expand Up @@ -109,7 +110,8 @@
"modal_title": "Comment cloner cette application ?",
"text1": "Afin de pouvoir cloner votre application il suffit d'executer cette commande :",
"text2": "Votre identifiant Gitlab est :",
"text3": "et votre mot de passe est celui de votre compte générateur"
"text3": "et votre mot de passe est celui de votre compte générateur ou de votre compte Gitlab si vous l'avez changé sur gitlab",
"text4": "(Si vous avez oublié votre mot de passe vous pouvez faire une procédure de changement de mot de passe sur le générateur, cela changera aussi celui de votre compte gitlab)"
},
"no_project_1": "Aucune application générée.",
"no_project_2": "Vous pouvez créer une application directement depuis <a href='/'>l'accueil</a> ou à l'aide d'un <a href='/instruction_script/index'>script</a>."
Expand Down Expand Up @@ -237,7 +239,7 @@
"textthree": "simplement revenir en arrière.",
"404": "Le lien que vous avez suivi peut être incorrect ou la page peut avoir été supprimée.",
"valueTooLong": "Désolé, la valeur renseignée dépasse la longueur maximum autorisée (<30) après génération (%s).",
"cannotFindInstruction": "Désolé, je ne comprend pas ce que vous me demandez.",
"cannotFindInstruction": "Désolé, je ne comprends pas ce que vous me demandez.",
"missingParametersInstruction": "Ils manque des paramètres à votre instruction. Consultez la documentation"
},
"back":{
Expand Down
21 changes: 10 additions & 11 deletions models/index.js
@@ -1,13 +1,13 @@
'use strict';

var fs = require('fs');
var path = require('path');
var Sequelize = require('sequelize');
var basename = path.basename(module.filename);
var env = require('../config/global');
var dbConfig = require('../config/database');
var moment_timezone = require('moment-timezone');
var db = {};
const fs = require('fs');
const path = require('path');
const Sequelize = require('sequelize');
const env = require('../config/global');
const dbConfig = require('../config/database');

let basename = path.basename(module.filename);
let db = {};

const Op = Sequelize.Op;
const operatorsAliases = {
Expand Down Expand Up @@ -47,7 +47,7 @@ const operatorsAliases = {
$col: Op.col
};

var sequelize = new Sequelize(dbConfig.database, dbConfig.user, dbConfig.password, {
const sequelize = new Sequelize(dbConfig.database, dbConfig.user, dbConfig.password, {
host: dbConfig.host,
logging: false,
port: dbConfig.port,
Expand All @@ -60,14 +60,13 @@ var sequelize = new Sequelize(dbConfig.database, dbConfig.user, dbConfig.passwor
},
charset: 'utf8',
collate: 'utf8_general_ci',
timezone: moment_timezone.tz.guess(),
operatorsAliases
})

fs.readdirSync(__dirname).filter(function(file) {
return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js');
}).forEach(function(file) {
var model = sequelize['import'](path.join(__dirname, file));
let model = sequelize['import'](path.join(__dirname, file));
db[model.name] = model;
})

Expand Down
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -42,11 +42,10 @@
"math": "0.0.3",
"mocha": "^5.2.0",
"moment": "^2.22.1",
"moment-timezone": "^0.5.17",
"morgan": "^1.9.0",
"multer": "^1.3.0",
"mysql": "^2.15.0",
"mysql2": "^1.5.3",
"mysql2": "^1.7.0",
"nodemailer": "^4.6.5",
"npm": "^6.4.0",
"passport": "^0.4.0",
Expand Down
13 changes: 11 additions & 2 deletions public/js/Newmips/instructionsScriptStatus.js
Expand Up @@ -10,6 +10,12 @@ function fetchStatus() {
success: function(data) {
try {

// Skip current update status due to internal serveur error
if(data.skip){
setTimeout(fetchStatus, 50);
return;
}

$("#instructionCount").text('Instructions : ' + data.doneInstruction + ' / ' + data.totalInstruction);

var percent = (Number(data.doneInstruction) * 100 / Number(data.totalInstruction)).toFixed(0);
Expand All @@ -22,18 +28,21 @@ function fetchStatus() {
else
$("#answers").html("<b>" + data.text[0].message + "</b><br><br>" + $("#answers").html());
}

if (!data.over)
setTimeout(fetchStatus, 50);
else {
if (percent >= 100) {
window.location.href = "/application/preview?id_application="+data.id_application+"&timeout=50000";
/*$("#goTo").attr('href', $("#goTo").attr('href')+data.id_application);*/
$("#goTo").show();
$("#scriptSubmit").prop('disabled', false);
$("#goTo").prop('disabled', false);
$("#progressbarcontent").hide();
} else {
$("#scriptSubmit").prop('disabled', false);
// Wait 2 sec before let user click again on button
setTimeout(function(){
$("#scriptSubmit").prop('disabled', false);
}, 2000);
$("#progressbarcontent").hide();
}
}
Expand Down
65 changes: 39 additions & 26 deletions routes/application.js
Expand Up @@ -16,6 +16,10 @@ var fs = require('fs-extra');
var parser = require('../services/bot.js');
var globalConf = require('../config/global.js');
var gitlabConf = require('../config/gitlab.js');

// Gitlab API
const gitlab = require('../services/gitlab_api');

var helpers = require('../utils/helpers');
var attrHelper = require('../utils/attr_helper');
var gitHelper = require('../utils/git_helper');
Expand Down Expand Up @@ -669,32 +673,35 @@ router.post('/set_logo', block_access.hasAccessApplication, function (req, res)

// List all applications
router.get('/list', block_access.isLoggedIn, function(req, res) {
var data = {};

models.Project.findAll({
include: [{
model: models.Application,
required: true,
(async () => {
let projects = await models.Project.findAll({
include: [{
model: models.User,
as: "users",
where: {
id: req.session.passport.user.id
},
required: true
}]
}],
order: [
[models.Application, 'id', 'DESC']
]
}).then(function(projects) {

let data = {};
model: models.Application,
required: true,
include: [{
model: models.User,
as: "users",
where: {
id: req.session.passport.user.id
},
required: true
}]
}],
order: [
[models.Application, 'id', 'DESC']
]
});

let iframe_status_url;
let host = globalConf.host;
let port;
let appName;
let data = {};

// Get user project for clone url generation
let gitlabProjects = [];
if(gitlabConf.doGit)
gitlabProjects = await gitlab.getAllProjects(req.session.gitlab.user.id);

for (var i = 0; i < projects.length; i++) {
for (var j = 0; j < projects[i].Applications.length; j++) {
Expand All @@ -710,20 +717,26 @@ router.get('/list', block_access.isLoggedIn, function(req, res) {
}

if(gitlabConf.doGit){
projects[i].dataValues.Applications[j].dataValues.repo_url = gitlabConf.protocol + "://" + gitlabConf.url + "/" + req.session.gitlab.user.username + "/" + globalConf.host.replace(/\./g, "-") + "-" + appName + ".git"
data.gitlabUser = req.session.gitlab.user;
let project = gitlabProjects.filter(x => x.name == globalConf.host + "-" + appName)[0];
if(project) {
// projects[i].dataValues.Applications[j].dataValues.repo_url = gitlabConf.protocol + "://" + gitlabConf.url + "/" + req.session.gitlab.user.username + "/" + globalConf.host.replace(/\./g, "-") + "-" + appName + ".git"
projects[i].dataValues.Applications[j].dataValues.repo_url = project.http_url_to_repo;
data.gitlabUser = req.session.gitlab.user;
}
}

projects[i].dataValues.Applications[j].dataValues.url = iframe_status_url;
}
}
data.projects = projects;

data.projects = projects
return data;
})().then(data => {
res.render('front/application', data);
}).catch(function(err) {
}).catch(err => {
console.error(err);
data.code = 500;
res.render('common/error', data);
});
})
});

router.post('/execute', block_access.isLoggedIn, function(req, res) {
Expand Down

0 comments on commit b132ee1

Please sign in to comment.