This section aims to list the different changes to apply in your application so that it can work with the upgrade of a Nodea core. For each version you will find the list of the elements to be carried out in order to solve the upgrade problem.
To upgrade the Nodea Core of your application simply replace de _core/ folder with the _core/ folder of 3.1 → 3.1 Core
npm i --save passport@0.6.0
Error:
Error: Cannot find module '/home/newmipsmsi/Documents/Nodea/3.1/Upgrade/upgrade-nodea/config/tracking.json'
Solution:
Create a new tracking.json file in your config folder with this content:
{}
npm i dayjs puppeteer
Now default models validators are in @core. Please replace the content of @app/models/validators.js with:
module.exports = function(attribute) { // eslint-disable-line
/** Define attributes validation here
* Any validator defined here will have priority over existing validator defined in `@core/models/validators`
* Expected return value :
* [{
* types: ['nodeaType', ...],
* validator: value => {} // Can be either a custom function or a sequelize validator (see https://sequelize.org/master/manual/validations-and-constraints.html#validators)
* }]
*/
return [];
}
If you have written custom validators don't forget to put them in the new @app/models/validators.js file, everything is explain in file comment.
Please add two new key in @config/global.js:
smsProvider: process.env.SMS || 'ovh',
logConnexionFolder: __dirname + "/../logs/"
Please add in @config/application.json
"dropzoneInfo": {
"sizeFileLimit": 50000000
}
In @app/models/e_media_sms.js, replace:
const sms = require('@core/services/sms');
With:
const sms = require('@app/services/sms');
In @app/models/e_task.js, replace:
this.hooks.beforeCreate.push({
name: 'attachToRobot',
func: async (model) => {
With:
this.hooks.attachToRobot = {
type: 'beforeCreate',
func: async (model) => {
Don't forget to remove the useless ) at the end of the file.
In @app/routes/app.js, add in get middlewares() object:
translate: [
middlewares.isLoggedIn
]
Add new folder SMS in @app/services: App SMS folder
And remove old @app/services/sms.js
If you have already written new custom SMS strategy don't forget to put it again in the folder. Now SMS strategy is configured in @config/global.js and you can add them in folder @app/services/sms
Add in views/main_layout.dust:
const locales = {@getFromContext key="locales" /};
In all [entity]/show.dust make sure to not include NodeaTable.js
Before:
{! Nodea encapsulations !}
<script src="/core/js/nodeaTable.js?v={config.version}" type="text/javascript"></script>
<script src="/core/js/nodeaTabs.js?v={config.version}" type="text/javascript"></script>
After:
{! Nodea encapsulations !}
<script src="/core/js/nodeaTabs.js?v={config.version}" type="text/javascript"></script>
Or if you want to use bundle version of code look at the 3.1 default show.dust:
https://github.com/nodea-software/Nodea/blob/3.1h1/structure/pieces/views/entity/show.dust
In all entity/list_fields.dust please add attributes data-entity="e_myentity"
Before
<table id="table_e_myentity" data-url="{tableUrl}" class="dataTable table table-bordered table-striped animated fadeIn" style="display: none;">
<thead class="main">
After:
<table id="table_e_myentity" data-entity="e_myentity" data-url="{tableUrl}" class="dataTable table table-bordered table-striped animated fadeIn" style="display: none;">
<thead class="main">
Add in app/locales/fr-FR.json on the first level:
,
"datatable": {
"processing": "Traitement en cours...",
"search": "Rechercher :",
"lengthMenu": "Afficher _MENU_ éléments",
"info": "Affichage de l'élément _START_ à _END_ sur _TOTAL_ éléments",
"infoEmpty": "Affichage de l'élément 0 à 0 sur 0 élément",
"infoFiltered": "(filtré de _MAX_ éléments au total)",
"infoPostFix": "",
"loadingRecords": "Chargement en cours...",
"zeroRecords": "Aucun élément à afficher",
"emptyTable": "Aucune donnée disponible dans le tableau",
"reset_filter": "Réinitialiser les filtres",
"scroll_right": "Défilement à droite",
"download_file": "Télécharger le fichier",
"close": "Fermer",
"paginate": {
"first": "Premier",
"previous": "Précédent",
"next": "Suivant",
"last": "Dernier"
},
"aria": {
"sortAscending": ": activer pour trier la colonne par ordre croissant",
"sortDescending": ": activer pour trier la colonne par ordre décroissant"
},
"choose_columns": "Choix Colonnes",
"check": "Cocher Tout",
"uncheck": "Décocher Tout",
"apply": "Appliquer",
"display": "Afficher",
"boolean_filter": {
"null": "Non renseigné",
"checked": "Coché",
"unchecked": "Décoché",
"all": "Tout"
},
"min_one_column_display": "Vous devez laisser au moins une colonne affichée."
}
And also in app/locales/en-EN.js
,
"datatable": {
"processing": "Processing...",
"search": "Search :",
"lengthMenu": "Display _MENU_ records",
"info": "Displaying records _START_ to _END_ on _TOTAL_ records",
"infoEmpty": "No record to display",
"infoFiltered": "(filter on _MAX_ records total)",
"infoPostFix": "",
"loadingRecords": "Loading...",
"zeroRecords": "No record to display",
"emptyTable": "No data available in this array",
"reset_filter": "Reset all filters",
"scroll_right": "Scroll right",
"download_file": "Download the file",
"close": "Close",
"paginate": {
"first": "First",
"previous": "Previous",
"next": "Next",
"last": "Last"
},
"aria": {
"sortAscending": ": click to sort column by ascending order",
"sortDescending": ": click to sort column by descending order"
},
"choose_columns": "Choose Columns",
"apply": "Apply",
"check": "Check all",
"uncheck": "Uncheck all",
"display": "Display",
"boolean_filter": {
"null": "Not specified",
"checked": "Checked",
"unchecked": "Unchecked",
"all": "Both"
},
"min_one_column_display": "You must leave at least one column displayed."
}
Add the file _core/public/js/component/agenda.js
Finally in app/routes/access_settings.js
Replace middlewares:
get middlewares() {
return {
show_api: [
middlewares.entityAccess('access_settings_api'),
middlewares.actionAccess('access_settings_api', 'read')
],
show_group: [
middlewares.entityAccess('access_settings'),
middlewares.entityAccess('access_settings_group'),
middlewares.actionAccess('access_settings_group', 'read')
],
show_role: [
middlewares.entityAccess('access_settings'),
middlewares.entityAccess('access_settings_role'),
middlewares.actionAccess('access_settings_role', 'read')
],
enable_disable_api: [
middlewares.entityAccess('access_settings_api'),
middlewares.actionAccess('access_settings_api', 'update')
],
set_group_access: [
middlewares.entityAccess('access_settings'),
middlewares.entityAccess('access_settings_group'),
middlewares.actionAccess('access_settings_group', 'update')
],
set_role_access: [
middlewares.entityAccess('access_settings'),
middlewares.entityAccess('access_settings_role'),
middlewares.actionAccess('access_settings_role', 'update')
],
};
}
With:
get middlewares() {
return {
show_api: [
middlewares.entityAccess("access_settings_api"),
middlewares.actionAccess("access_settings_api", "read")
],
show_group: [
middlewares.entityAccess("access_settings"),
middlewares.entityAccess("access_settings_group"),
middlewares.actionAccess("access_settings_group", "read")
],
show_role: [
middlewares.entityAccess("access_settings"),
middlewares.entityAccess("access_settings_role"),
middlewares.actionAccess("access_settings_group", "read")
],
enable_disable_api: [
middlewares.entityAccess("access_settings_api"),
middlewares.actionAccess("access_settings", "update")
],
set_group_access: [
middlewares.entityAccess("access_settings"),
middlewares.entityAccess("access_settings_group"),
middlewares.actionAccess("access_settings_group", "update")
],
set_role_access: [
middlewares.entityAccess("access_settings"),
middlewares.entityAccess("access_settings_role"),
middlewares.actionAccess("access_settings_group", "update")
]
}
}
You need to have the data-entity attributes specified in the <i></i>
Before:
<i data-entity="entity" data-field="f_field"
After:
<i data-field="f_field"
To upgrade the Nodea Core of your application simply replace de _core/ folder with the _core/ folder of 3.0.2 → 3.0.2 Core
If
Cannot find module bcrypt
then
npm install --save bcrypt
And then replace all bcrypt-nodejs
with bcrypt
in your app code.
if
access.entityAccessMiddleware is not a function // OR
access.actionAccessMiddleware is not a function // OR
Route.get() requires a callback function but got a [object Boolean]
Here is the list of replace that you have to execute:
Find | Replace With | Exclude files (Do not change in it) |
---|---|---|
entityAccessMiddleware |
entityAccess |
|
actionAccessMiddleware |
actionAccess |
|
const access = helpers.access; |
const access = helpers.middlewares; |
_core/routes/access_settings.js |
const block_access = helpers.access; |
const block_access = helpers.middlewares; |
|
helpers.access.isLoggedIn |
block_access.isLoggedIn |
|
const block_access = require('@core/helpers/access'); |
const block_access = require('@core/helpers/middlewares'); |
server.js |
const access = require('@core/helpers/access'); |
const access = require('@core/helpers/middlewares'); |
_core/server/routing.js |
Replace in app/models/e_media_sms.js TABLE_NAME
with e_media_sms
First of all it is required to add in your app/views/main_layout.dust after
{! Nodea App !}
<script src="/core/js/nodea.js?v={config.version}" type="text/javascript"></script>
these lines:
<script type="text/javascript">
Nodea();
</script>
{! Nodea Tables !}
<script src="/core/js/nodeaTable.js" type="text/javascript"></script>
And then the hard work begins, indeed in each list.dust file you have to replace
<script src="/core/js/nodeaTable.js" type="text/javascript"></script>
with
<!-- Nodea Table initialization -->
<script>
/* Datatable throw error instead of alert */
$.fn.dataTable.ext.errMode = 'throw';
$(function() {
$("table:not(.no-init)").each(function() {
NodeaTable("#"+$(this).attr('id'));
});
});
</script>
data-customwhere in front select2 and also customWhere key in search() routes has been removed.
Please use and customize data.query.where in beforeQuery hook instead.
See Select2 in Nodea JS Libraries
In order to work on env develop, studio, cloud please update your config/database.js to add process.env priority before direct string value:
host: process.env.APP_DB_IP || process.env.DATABASE_IP || '127.0.0.1',
port: process.env.APP_DB_PORT || '3306',
user: process.env.APP_DB_USER || 'your_user',
password: process.env.APP_DB_PWD || 'your_pwd',
database: process.env.APP_DB_NAME || 'your_db',
dialect: process.env.APP_DB_DIALECT || 'mysql'