From 34730f48edc6473b20f0d7cfcd36f9d1a142cff5 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 16 Feb 2022 12:51:45 +0100 Subject: [PATCH 1/8] fix: add role salesBoss to filter --- modules/claim/front/search-panel/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/claim/front/search-panel/index.html b/modules/claim/front/search-panel/index.html index dbbc3a46b..22faf9ec4 100644 --- a/modules/claim/front/search-panel/index.html +++ b/modules/claim/front/search-panel/index.html @@ -28,7 +28,7 @@ url="Workers/activeWithRole" search-function="{firstName: $search}" value-field="id" - where="{role: {inq: ['salesPerson', 'officeBoss']}}" + where="{role: {inq: ['salesBoss', 'salesPerson', 'officeBoss']}}" label="Salesperson"> {{firstName}} {{name}} @@ -38,7 +38,7 @@ url="Workers/activeWithRole" search-function="{firstName: $search}" value-field="id" - where="{role: 'salesPerson'}" + where="{role: {inq: ['salesBoss', 'salesPerson']}}" label="Attended by"> {{firstName}} {{name}} From 743972e9c31466ebca89bf051bf73303fdff692b Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 17 Feb 2022 11:23:27 +0100 Subject: [PATCH 2/8] fix(invoice): prevent report empty pages --- print/templates/reports/invoice/assets/css/style.css | 9 ++++++--- print/templates/reports/invoice/invoice.html | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/print/templates/reports/invoice/assets/css/style.css b/print/templates/reports/invoice/assets/css/style.css index cd605db9b..9fda2a613 100644 --- a/print/templates/reports/invoice/assets/css/style.css +++ b/print/templates/reports/invoice/assets/css/style.css @@ -5,7 +5,7 @@ h2 { .table-title { margin-bottom: 15px; - font-size: 0.8rem + font-size: .8rem } .table-title h2 { @@ -16,9 +16,12 @@ h2 { font-size: 22px } + #nickname h2 { - max-width: 400px; - word-wrap: break-word + max-width: 400px; + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; } #phytosanitary { diff --git a/print/templates/reports/invoice/invoice.html b/print/templates/reports/invoice/invoice.html index 8b13f2a15..1d646a0db 100644 --- a/print/templates/reports/invoice/invoice.html +++ b/print/templates/reports/invoice/invoice.html @@ -85,7 +85,7 @@ -
+

{{$t('deliveryNote')}} From 2bdb1075fbc57d2b4ae8064b11e77c6014e6ca1e Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 17 Feb 2022 11:23:27 +0100 Subject: [PATCH 3/8] fix(invoice): prevent report empty pages --- print/templates/reports/invoice/assets/css/style.css | 9 ++++++--- print/templates/reports/invoice/invoice.html | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/print/templates/reports/invoice/assets/css/style.css b/print/templates/reports/invoice/assets/css/style.css index cd605db9b..9fda2a613 100644 --- a/print/templates/reports/invoice/assets/css/style.css +++ b/print/templates/reports/invoice/assets/css/style.css @@ -5,7 +5,7 @@ h2 { .table-title { margin-bottom: 15px; - font-size: 0.8rem + font-size: .8rem } .table-title h2 { @@ -16,9 +16,12 @@ h2 { font-size: 22px } + #nickname h2 { - max-width: 400px; - word-wrap: break-word + max-width: 400px; + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; } #phytosanitary { diff --git a/print/templates/reports/invoice/invoice.html b/print/templates/reports/invoice/invoice.html index 8b13f2a15..1d646a0db 100644 --- a/print/templates/reports/invoice/invoice.html +++ b/print/templates/reports/invoice/invoice.html @@ -85,7 +85,7 @@ -
+

{{$t('deliveryNote')}} From 05aa5791564d4bc9883f9c8e1f566d4a080760bb Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 16 Feb 2022 12:51:45 +0100 Subject: [PATCH 4/8] fix: add role salesBoss to filter --- modules/claim/front/search-panel/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/claim/front/search-panel/index.html b/modules/claim/front/search-panel/index.html index 6efd6603b..b48d94d21 100644 --- a/modules/claim/front/search-panel/index.html +++ b/modules/claim/front/search-panel/index.html @@ -28,7 +28,7 @@ url="Workers/activeWithRole" search-function="{firstName: $search}" value-field="id" - where="{role: {inq: ['salesPerson', 'officeBoss']}}" + where="{role: {inq: ['salesBoss', 'salesPerson', 'officeBoss']}}" label="Salesperson"> {{firstName}} {{name}} @@ -38,7 +38,7 @@ url="Workers/activeWithRole" search-function="{firstName: $search}" value-field="id" - where="{role: 'salesPerson'}" + where="{role: {inq: ['salesBoss', 'salesPerson']}}" label="Attended by"> {{firstName}} {{name}} From 46488aa60002df15f3fde5435e8372c6738e4e6a Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 3 Feb 2022 11:52:55 +0100 Subject: [PATCH 5/8] fix(icon): icon-plant --- front/core/styles/icons/salixfont.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/core/styles/icons/salixfont.css b/front/core/styles/icons/salixfont.css index ff2eaa1f5..e37ccbc1f 100644 --- a/front/core/styles/icons/salixfont.css +++ b/front/core/styles/icons/salixfont.css @@ -290,7 +290,7 @@ .icon-photo:before { content: "\e924"; } -.icon-planta:before { +.icon-plant:before { content: "\e908"; } .icon-polizon:before { From c260917e20a8a87b65a13823625e4245918609e2 Mon Sep 17 00:00:00 2001 From: joan Date: Fri, 18 Feb 2022 08:49:31 +0100 Subject: [PATCH 6/8] fix(closure): removed transaction --- print/methods/closure/closure.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/print/methods/closure/closure.js b/print/methods/closure/closure.js index 8cce8237c..2b58205e3 100644 --- a/print/methods/closure/closure.js +++ b/print/methods/closure/closure.js @@ -12,8 +12,6 @@ module.exports = { const failedtickets = []; for (const ticket of tickets) { try { - await db.rawSql('START TRANSACTION'); - await db.rawSql(`CALL vn.ticket_closeByTicket(?)`, [ticket.id]); const invoiceOut = await db.findOne(` @@ -91,9 +89,7 @@ module.exports = { const email = new Email('delivery-note-link', args); await email.send(); } - await db.rawSql('COMMIT'); } catch (error) { - await db.rawSql('ROLLBACK'); // Domain not found if (error.responseCode == 450) return invalidEmail(ticket); From 6f1bfbd955da3e4e92065a29c32a00eef9576aad Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Sat, 19 Feb 2022 14:05:35 +0100 Subject: [PATCH 7/8] roleConfig: fixes & refactor --- modules/account/back/models/role-config.js | 41 ++++++++------------ modules/account/back/models/role-config.json | 12 ++++++ 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/modules/account/back/models/role-config.js b/modules/account/back/models/role-config.js index b5cfb7b83..c6b32a4c5 100644 --- a/modules/account/back/models/role-config.js +++ b/modules/account/back/models/role-config.js @@ -1,7 +1,9 @@ module.exports = Self => { Self.getSynchronizer = async function() { - return await Self.findOne({fields: ['id']}); + return await Self.findOne({ + fields: ['id', 'rolePrefix', 'userPrefix', 'userHost'] + }); }; Object.assign(Self.prototype, { @@ -14,17 +16,16 @@ module.exports = Self => { }, async syncUser(userName, info, password) { - const mysqlHost = '%'; - let mysqlUser = userName; - if (this.dbType == 'MySQL') mysqlUser = `!${mysqlUser}`; + if (this.dbType == 'MySQL') + mysqlUser = this.userPrefix + mysqlUser; const [row] = await Self.rawSql( `SELECT COUNT(*) AS nRows FROM mysql.user WHERE User = ? AND Host = ?`, - [mysqlUser, mysqlHost] + [mysqlUser, this.userHost] ); let userExists = row.nRows > 0; @@ -35,11 +36,10 @@ module.exports = Self => { FROM mysql.global_priv WHERE User = ? AND Host = ?`, - [mysqlUser, mysqlHost] + [mysqlUser, this.userHost] ); const priv = row && JSON.parse(row.priv); - const role = priv && priv.default_role; - isUpdatable = !row || (role && role.startsWith('z-')); + isUpdatable = !row || (priv && priv.autogenerated); } if (!isUpdatable) { @@ -51,31 +51,27 @@ module.exports = Self => { if (password) { if (!userExists) { await Self.rawSql('CREATE USER ?@? IDENTIFIED BY ?', - [mysqlUser, mysqlHost, password] - ); + [mysqlUser, this.userHost, password]); userExists = true; } else { switch (this.dbType) { case 'MariaDB': await Self.rawSql('ALTER USER ?@? IDENTIFIED BY ?', - [mysqlUser, mysqlHost, password] - ); + [mysqlUser, this.userHost, password]); break; default: await Self.rawSql('SET PASSWORD FOR ?@? = PASSWORD(?)', - [mysqlUser, mysqlHost, password] - ); + [mysqlUser, this.userHost, password]); } } } if (userExists && this.dbType == 'MariaDB') { - let role = `z-${info.user.role().name}`; + let role = `${this.rolePrefix}${info.user.role().name}`; try { await Self.rawSql('REVOKE ALL, GRANT OPTION FROM ?@?', - [mysqlUser, mysqlHost] - ); + [mysqlUser, this.userHost]); } catch (err) { if (err.code == 'ER_REVOKE_GRANTS') console.warn(`${err.code}: ${err.sqlMessage}: ${err.sql}`); @@ -83,21 +79,18 @@ module.exports = Self => { throw err; } await Self.rawSql('GRANT ? TO ?@?', - [role, mysqlUser, mysqlHost] - ); + [role, mysqlUser, this.userHost]); if (role) { await Self.rawSql('SET DEFAULT ROLE ? FOR ?@?', - [role, mysqlUser, mysqlHost] - ); + [role, mysqlUser, this.userHost]); } else { await Self.rawSql('SET DEFAULT ROLE NONE FOR ?@?', - [mysqlUser, mysqlHost] - ); + [mysqlUser, this.userHost]); } } } else if (userExists) - await Self.rawSql('DROP USER ?@?', [mysqlUser, mysqlHost]); + await Self.rawSql('DROP USER ?@?', [mysqlUser, this.userHost]); } }); }; diff --git a/modules/account/back/models/role-config.json b/modules/account/back/models/role-config.json index c2abfcc38..f4138bea8 100644 --- a/modules/account/back/models/role-config.json +++ b/modules/account/back/models/role-config.json @@ -16,6 +16,18 @@ }, "mysqlPassword": { "type": "string" + }, + "rolePrefix": { + "type": "string" + }, + "userPrefix": { + "type": "string" + }, + "userHost": { + "type": "string" + }, + "tplUser": { + "type": "string" } } } From c3e480b2e7832d49aab4ed9de8acfbd823db2260 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 24 Feb 2022 15:02:16 +0100 Subject: [PATCH 8/8] MariaDB user sync disabled in dev environment --- modules/account/back/models/role-config.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/account/back/models/role-config.js b/modules/account/back/models/role-config.js index c6b32a4c5..6051f2060 100644 --- a/modules/account/back/models/role-config.js +++ b/modules/account/back/models/role-config.js @@ -1,6 +1,10 @@ module.exports = Self => { Self.getSynchronizer = async function() { + let NODE_ENV = process.env.NODE_ENV; + if (!NODE_ENV || NODE_ENV == 'development') + return null; + return await Self.findOne({ fields: ['id', 'rolePrefix', 'userPrefix', 'userHost'] });