refs #5858 feat: email notification
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Javier Segarra 2023-11-24 12:30:44 +01:00
parent 5d156e81ca
commit 4383ebd7f1
7 changed files with 36 additions and 20 deletions

View File

@ -17,7 +17,8 @@ BEGIN
`zoneFk` = NEW.zoneFk,
`geoFk` = NEW.geoFk,
`userFk` = account.myUser_getId();
CALL `vn`.`zoneIncluded_checkCollisions`();
-- CALL `vn`.`zoneIncluded_checkCollisions`(NEW.zoneFk, NEW.geoFk);
END$$
DELIMITER ;
@ -41,7 +42,7 @@ BEGIN
`geoFk` = NEW.geoFk,
`userFk` = account.myUser_getId();
CALL `vn`.`zoneIncluded_checkCollisions`();
-- CALL `vn`.`zoneIncluded_checkCollisions`();
END$$
@ -67,6 +68,6 @@ BEGIN
`geoFk` = OLD.geoFk,
`userFk` = account.myUser_getId();
CALL `vn`.`zoneIncluded_checkCollisions`();
-- CALL `vn`.`zoneIncluded_checkCollisions`();
END$$
DELIMITER ;

View File

@ -1,5 +1,7 @@
-- DROP PROCEDURE IF EXISTS `vn`.`zoneIncluded_checkCollisions`;
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneIncluded_checkCollisions`(IN id INT)
DROP PROCEDURE IF EXISTS `vn`.`zoneIncluded_checkCollisions`;
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneIncluded_checkCollisions`(IN zi_zone INT, IN zi_geo INT)
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE zic_id, zic_zone, zic_geo, zic_action, zic_userFk INT;
@ -27,4 +29,5 @@ OPEN my_cur;
CLOSE my_cur;
END
END$$
DELIMITER ;

View File

@ -0,0 +1,11 @@
-- Auto-generated SQL script #202311241021
INSERT INTO util.notification (name,description)
VALUES ('zone-included','An email to notify zoneCollisions');
-- Auto-generated SQL script #202311241051
INSERT INTO util.notificationSubscription (notificationFk,userFk)
SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included"
INSERT INTO util.notificationAcl (notificationFk,roleFk)
SELECT id, account.role FROM util.notification WHERE name= "zone-included"

View File

@ -1,8 +1,9 @@
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
let conn = null;
describe('zone toggleIsIncluded()', () => {
beforeAll(async() => {
conn = await models.Item.dataSource.connector;
const activeCtx = {
accessToken: {userId: 9},
http: {
@ -16,15 +17,23 @@ describe('zone toggleIsIncluded()', () => {
});
});
it('should return the created location with isIncluded true', async() => {
fit('should return the created location with isIncluded true', async() => {
const tx = await models.Zone.beginTransaction({});
try {
let toCheck = await conn.executeStmt({sql: ' SELECT * FROM zoneIncludedCheck'});
expect(toCheck.length).toEqual(0);
const options = {transaction: tx};
let result = await models.Zone.toggleIsIncluded(1, 20, true, options);
expect(result.isIncluded).toBeTrue();
toCheck = await conn.executeStmt({sql: ' SELECT * FROM zoneIncludedCheck'});
expect(toCheck.length).not.toEqual(1);
await conn.executeStmt({sql: 'CALL vn.zoneIncluded_checkCollisions(?, ? )', params: [0, 0]});
await tx.rollback();
} catch (e) {

View File

@ -1,2 +1,2 @@
subject: Colisión de zona {0} detectada
title: "La localización {0} ha sido registrada en más de un sitio"
subject: Colisión de zona detectada
title: "La zona {0} y localización {1} ha sido registrada en más de un sitio"

View File

@ -1,8 +1,8 @@
<email-body v-bind="$props">
<div class="grid-row">
<div class="grid-block vn-pa-ml">
<h1>{{ $t('subject', [zoneSelected]) }}</h1>
<p>{{ $t('title', [geoSelected]) }}</p>
<h1>{{ $t('subject') }}</h1>
<p>{{ $t('title', [zoneSelected,geoSelected]) }}</p>
</div>
</div>
</email-body>

View File

@ -3,14 +3,6 @@ const emailBody = new Component('email-body');
module.exports = {
name: 'zone-included',
async serverPrefetch() {
this.zoneIncluded = await this.fetchZoneIncluded(this.id);
},
methods: {
fetchZoneIncluded(id) {
return this.findOneFromDef('zoneIncluded', [id]);
},
},
components: {
'email-body': emailBody.build(),
},