From b3a7a170f0522ff693be1684d3201b8914a8ca7e Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 18 Jul 2023 11:54:43 +0200 Subject: [PATCH 1/3] =?UTF-8?q?refs=20#5934=20feat:=20a=C3=B1adido=20clien?= =?UTF-8?q?tSms=20log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/changes/233001/00-clientSms.sql | 15 +++++++ modules/client/back/methods/client/sendSms.js | 8 +++- modules/client/back/model-config.json | 3 ++ modules/client/back/models/client-sms.json | 29 +++++++++++++ modules/client/back/models/sms.json | 2 +- modules/client/front/index.js | 1 + modules/client/front/routes.json | 7 ++++ modules/client/front/sms/index.html | 42 +++++++++++++++++++ modules/client/front/sms/index.js | 39 +++++++++++++++++ modules/client/front/sms/locale/es.yml | 2 + 10 files changed, 146 insertions(+), 2 deletions(-) create mode 100644 db/changes/233001/00-clientSms.sql create mode 100644 modules/client/back/models/client-sms.json create mode 100644 modules/client/front/sms/index.html create mode 100644 modules/client/front/sms/index.js create mode 100644 modules/client/front/sms/locale/es.yml diff --git a/db/changes/233001/00-clientSms.sql b/db/changes/233001/00-clientSms.sql new file mode 100644 index 000000000..353041ad9 --- /dev/null +++ b/db/changes/233001/00-clientSms.sql @@ -0,0 +1,15 @@ +CREATE TABLE `vn`.`clientSms` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `clientFk` int(11) NOT NULL, + `smsFk` mediumint(8) unsigned NOT NULL, + PRIMARY KEY (`id`), + KEY `clientSms_FK` (`clientFk`), + KEY `clientSms_FK_1` (`smsFk`), + CONSTRAINT `clientSms_FK` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE, + CONSTRAINT `clientSms_FK_1` FOREIGN KEY (`smsFk`) REFERENCES `sms` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('ClientSms', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('ClientSms', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee'); diff --git a/modules/client/back/methods/client/sendSms.js b/modules/client/back/methods/client/sendSms.js index 83b7c8d6e..270d7e5b5 100644 --- a/modules/client/back/methods/client/sendSms.js +++ b/modules/client/back/methods/client/sendSms.js @@ -7,7 +7,7 @@ module.exports = Self => { arg: 'id', type: 'number', required: true, - description: 'The ticket id', + description: 'The client id', http: {source: 'path'} }, { @@ -33,6 +33,12 @@ module.exports = Self => { Self.sendSms = async(ctx, id, destination, message) => { const models = Self.app.models; const sms = await models.Sms.send(ctx, destination, message); + + await models.ClientSms.create({ + clientFk: id, + smsFk: sms.id + }); + return sms; }; }; diff --git a/modules/client/back/model-config.json b/modules/client/back/model-config.json index 1e06ea1c0..bc48ec360 100644 --- a/modules/client/back/model-config.json +++ b/modules/client/back/model-config.json @@ -95,6 +95,9 @@ "ClientSample": { "dataSource": "vn" }, + "ClientSms": { + "dataSource": "vn" + }, "Sms": { "dataSource": "vn" }, diff --git a/modules/client/back/models/client-sms.json b/modules/client/back/models/client-sms.json new file mode 100644 index 000000000..18d7ad051 --- /dev/null +++ b/modules/client/back/models/client-sms.json @@ -0,0 +1,29 @@ +{ + "name": "ClientSms", + "base": "VnModel", + "options": { + "mysql": { + "table": "clientSms" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "clientFk": { + "type": "number" + }, + "smsFk": { + "type": "number" + } + }, + "relations": { + "sms": { + "type": "belongsTo", + "model": "Sms", + "foreignKey": "smsFk" + } + } +} diff --git a/modules/client/back/models/sms.json b/modules/client/back/models/sms.json index 4639131ef..8f349b073 100644 --- a/modules/client/back/models/sms.json +++ b/modules/client/back/models/sms.json @@ -36,7 +36,7 @@ } }, "relations": { - "sender": { + "user": { "type": "belongsTo", "model": "VnUser", "foreignKey": "senderFk" diff --git a/modules/client/front/index.js b/modules/client/front/index.js index c7e39ea5d..62076459b 100644 --- a/modules/client/front/index.js +++ b/modules/client/front/index.js @@ -48,4 +48,5 @@ import './notification'; import './unpaid'; import './extended-list'; import './credit-management'; +import './sms'; diff --git a/modules/client/front/routes.json b/modules/client/front/routes.json index 01d1b53bf..773b7b22a 100644 --- a/modules/client/front/routes.json +++ b/modules/client/front/routes.json @@ -23,6 +23,7 @@ {"state": "client.card.recovery.index", "icon": "icon-recovery"}, {"state": "client.card.webAccess", "icon": "cloud"}, {"state": "client.card.log", "icon": "history"}, + {"state": "client.card.sms", "icon": "contact_support"}, { "description": "Credit management", "icon": "monetization_on", @@ -373,6 +374,12 @@ "component": "vn-client-log", "description": "Log" }, + { + "url" : "/sms", + "state": "client.card.sms", + "component": "vn-client-sms", + "description": "Sms" + }, { "url": "/dms", "state": "client.card.dms", diff --git a/modules/client/front/sms/index.html b/modules/client/front/sms/index.html new file mode 100644 index 000000000..db944e3b0 --- /dev/null +++ b/modules/client/front/sms/index.html @@ -0,0 +1,42 @@ + + + + + + + + Sender + Number sender + Destination + Message + Status + Created + + + + + + + {{::clientSms.sms.user.name}} + + + {{::clientSms.sms.sender}} + {{::clientSms.sms.destination}} + {{::clientSms.sms.message}} + {{::clientSms.sms.status}} + {{::clientSms.sms.created | date:'dd/MM/yyyy HH:mm'}} + + + + + + + diff --git a/modules/client/front/sms/index.js b/modules/client/front/sms/index.js new file mode 100644 index 000000000..1478b78e9 --- /dev/null +++ b/modules/client/front/sms/index.js @@ -0,0 +1,39 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +export default class Controller extends Section { + constructor($element, $) { + super($element, $); + + this.filter = { + fields: ['id', 'smsFk'], + include: { + relation: 'sms', + scope: { + fields: [ + 'senderFk', + 'sender', + 'destination', + 'message', + 'statusCode', + 'status', + 'created'], + include: { + relation: 'user', + scope: { + fields: ['name'] + } + } + } + } + }; + } +} + +ngModule.vnComponent('vnClientSms', { + template: require('./index.html'), + controller: Controller, + bindings: { + client: '<' + } +}); diff --git a/modules/client/front/sms/locale/es.yml b/modules/client/front/sms/locale/es.yml new file mode 100644 index 000000000..6d1e9e147 --- /dev/null +++ b/modules/client/front/sms/locale/es.yml @@ -0,0 +1,2 @@ +Sender: Remitente +Number sender: NĂºmero remitente -- 2.40.1 From 3e8775149a4dc286ebedeeb4cd9b95a4157d2596 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 18 Jul 2023 13:02:42 +0200 Subject: [PATCH 2/3] refs #5934 feat: change icon --- modules/client/back/models/sms.json | 2 +- modules/client/front/routes.json | 2 +- modules/client/front/sms/index.html | 4 +--- modules/client/front/sms/index.js | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/client/back/models/sms.json b/modules/client/back/models/sms.json index 8f349b073..4639131ef 100644 --- a/modules/client/back/models/sms.json +++ b/modules/client/back/models/sms.json @@ -36,7 +36,7 @@ } }, "relations": { - "user": { + "sender": { "type": "belongsTo", "model": "VnUser", "foreignKey": "senderFk" diff --git a/modules/client/front/routes.json b/modules/client/front/routes.json index 773b7b22a..63d6709e5 100644 --- a/modules/client/front/routes.json +++ b/modules/client/front/routes.json @@ -23,7 +23,7 @@ {"state": "client.card.recovery.index", "icon": "icon-recovery"}, {"state": "client.card.webAccess", "icon": "cloud"}, {"state": "client.card.log", "icon": "history"}, - {"state": "client.card.sms", "icon": "contact_support"}, + {"state": "client.card.sms", "icon": "sms"}, { "description": "Credit management", "icon": "monetization_on", diff --git a/modules/client/front/sms/index.html b/modules/client/front/sms/index.html index db944e3b0..3331f217b 100644 --- a/modules/client/front/sms/index.html +++ b/modules/client/front/sms/index.html @@ -13,7 +13,6 @@ Sender - Number sender Destination Message Status @@ -24,10 +23,9 @@ - {{::clientSms.sms.user.name}} + {{::clientSms.sms.sender.name}} - {{::clientSms.sms.sender}} {{::clientSms.sms.destination}} {{::clientSms.sms.message}} {{::clientSms.sms.status}} diff --git a/modules/client/front/sms/index.js b/modules/client/front/sms/index.js index 1478b78e9..6ad64282e 100644 --- a/modules/client/front/sms/index.js +++ b/modules/client/front/sms/index.js @@ -19,7 +19,7 @@ export default class Controller extends Section { 'status', 'created'], include: { - relation: 'user', + relation: 'sender', scope: { fields: ['name'] } -- 2.40.1 From ab95ef74a945c4c232f2cb6a9a73c9c51f767147 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Jul 2023 07:17:35 +0200 Subject: [PATCH 3/3] refs #5934 refactor: nombres variables --- db/changes/233001/00-clientSms.sql | 6 +++--- modules/client/back/models/client-sms.json | 3 --- modules/client/front/sms/index.html | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/db/changes/233001/00-clientSms.sql b/db/changes/233001/00-clientSms.sql index 353041ad9..e1e34f6b2 100644 --- a/db/changes/233001/00-clientSms.sql +++ b/db/changes/233001/00-clientSms.sql @@ -7,9 +7,9 @@ CREATE TABLE `vn`.`clientSms` ( KEY `clientSms_FK_1` (`smsFk`), CONSTRAINT `clientSms_FK` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE, CONSTRAINT `clientSms_FK_1` FOREIGN KEY (`smsFk`) REFERENCES `sms` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES - ('ClientSms', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), - ('ClientSms', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee'); + ('ClientSms', 'find', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('ClientSms', 'create', 'WRITE', 'ALLOW', 'ROLE', 'employee'); diff --git a/modules/client/back/models/client-sms.json b/modules/client/back/models/client-sms.json index 18d7ad051..b2244ebbb 100644 --- a/modules/client/back/models/client-sms.json +++ b/modules/client/back/models/client-sms.json @@ -14,9 +14,6 @@ }, "clientFk": { "type": "number" - }, - "smsFk": { - "type": "number" } }, "relations": { diff --git a/modules/client/front/sms/index.html b/modules/client/front/sms/index.html index 3331f217b..9abadd312 100644 --- a/modules/client/front/sms/index.html +++ b/modules/client/front/sms/index.html @@ -3,7 +3,7 @@ url="ClientSms" link="{clientFk: $ctrl.$params.id}" filter="::$ctrl.filter" - data="clientSmss" + data="clientSmsList" limit="20" auto-load="true"> @@ -20,7 +20,7 @@ - + {{::clientSms.sms.sender.name}} -- 2.40.1