Merge branch 'dev' into 2483-email_replyTo
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
01f0fed0c3
|
@ -15,15 +15,24 @@ module.exports = Self => {
|
||||||
Self.notifyIssues = async ctx => {
|
Self.notifyIssues = async ctx => {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const $t = ctx.req.__; // $translate
|
const $t = ctx.req.__; // $translate
|
||||||
const [urgentIssue] = await Self.rawSql(`
|
const tickets = await models.OsTicket.rawSql(`
|
||||||
SELECT * FROM managedesktop.vn_workOrderInmediata LIMIT 1
|
SELECT t.ticket_id AS id, t.number, ua.username, td.subject
|
||||||
`);
|
FROM ost_ticket t
|
||||||
|
JOIN ost_user_account ua ON t.user_id = ua.user_id
|
||||||
|
JOIN ost_ticket__cdata td ON t.ticket_id = td.ticket_id
|
||||||
|
JOIN ost_ticket_priority tp ON td.priority = tp.priority_id
|
||||||
|
LEFT JOIN ost_department dept ON dept.id = t.dept_id
|
||||||
|
WHERE tp.priority = 'emergency'
|
||||||
|
AND (t.staff_id = 0 AND t.team_id = 0)
|
||||||
|
AND dept.code = 'IT'
|
||||||
|
`);
|
||||||
|
|
||||||
if (!urgentIssue) return;
|
if (!tickets.length) return;
|
||||||
|
|
||||||
const message = $t(`There's a new urgent ticket`, {
|
let message = $t(`There's a new urgent ticket:`);
|
||||||
title: urgentIssue.title,
|
const ostUri = 'https://cau.verdnatura.es/scp/tickets.php?id=';
|
||||||
issueId: urgentIssue.workOrderId
|
tickets.forEach(ticket => {
|
||||||
|
message += `\r\n[ID: *${ticket.number}* - ${ticket.subject} (@${ticket.username})](${ostUri + ticket.id})`;
|
||||||
});
|
});
|
||||||
|
|
||||||
const department = await models.Department.findOne({
|
const department = await models.Department.findOne({
|
||||||
|
|
|
@ -6,11 +6,12 @@ describe('Chat notifyIssue()', () => {
|
||||||
return value;
|
return value;
|
||||||
};
|
};
|
||||||
const chatModel = app.models.Chat;
|
const chatModel = app.models.Chat;
|
||||||
|
const osTicketModel = app.models.OsTicket;
|
||||||
const departmentId = 31;
|
const departmentId = 31;
|
||||||
|
|
||||||
it(`should not call to the send() method and neither return a response`, async() => {
|
it(`should not call to the send() method and neither return a response`, async() => {
|
||||||
spyOn(chatModel, 'send').and.callThrough();
|
spyOn(chatModel, 'send').and.callThrough();
|
||||||
spyOn(chatModel, 'rawSql').and.returnValue([]);
|
spyOn(osTicketModel, 'rawSql').and.returnValue([]);
|
||||||
|
|
||||||
const response = await chatModel.notifyIssues(ctx);
|
const response = await chatModel.notifyIssues(ctx);
|
||||||
|
|
||||||
|
@ -20,7 +21,13 @@ describe('Chat notifyIssue()', () => {
|
||||||
|
|
||||||
it(`should return a response calling the send() method`, async() => {
|
it(`should return a response calling the send() method`, async() => {
|
||||||
spyOn(chatModel, 'send').and.callThrough();
|
spyOn(chatModel, 'send').and.callThrough();
|
||||||
spyOn(chatModel, 'rawSql').and.returnValue([{title: 'Issue title'}]);
|
spyOn(osTicketModel, 'rawSql').and.returnValue([{
|
||||||
|
id: 1,
|
||||||
|
number: '00001',
|
||||||
|
username: 'batman',
|
||||||
|
subject: 'Issue title'}
|
||||||
|
]);
|
||||||
|
const expectedMessage = `@all ➔ There's a new urgent ticket:\r\n[ID: *00001* - Issue title (@batman)](https://cau.verdnatura.es/scp/tickets.php?id=1)`;
|
||||||
|
|
||||||
const department = await app.models.Department.findById(departmentId);
|
const department = await app.models.Department.findById(departmentId);
|
||||||
let orgChatName = department.chatName;
|
let orgChatName = department.chatName;
|
||||||
|
@ -30,7 +37,7 @@ describe('Chat notifyIssue()', () => {
|
||||||
|
|
||||||
expect(response.statusCode).toEqual(200);
|
expect(response.statusCode).toEqual(200);
|
||||||
expect(response.message).toEqual('Fake notification sent');
|
expect(response.message).toEqual('Fake notification sent');
|
||||||
expect(chatModel.send).toHaveBeenCalledWith(ctx, '#IT', `@all ➔ There's a new urgent ticket`);
|
expect(chatModel.send).toHaveBeenCalledWith(ctx, '#IT', expectedMessage);
|
||||||
|
|
||||||
// restores
|
// restores
|
||||||
await department.updateAttribute('chatName', orgChatName);
|
await department.updateAttribute('chatName', orgChatName);
|
||||||
|
|
|
@ -94,6 +94,9 @@
|
||||||
},
|
},
|
||||||
"Warehouse": {
|
"Warehouse": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"OsTicket": {
|
||||||
|
"dataSource": "osticket"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"name": "OsTicket",
|
||||||
|
"base": "VnModel",
|
||||||
|
"acls": [{
|
||||||
|
"property": "validations",
|
||||||
|
"accessType": "EXECUTE",
|
||||||
|
"principalType": "ROLE",
|
||||||
|
"principalId": "$everyone",
|
||||||
|
"permission": "ALLOW"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
|
@ -83,9 +83,6 @@ export default class Field extends FormInput {
|
||||||
this._required = value;
|
this._required = value;
|
||||||
let required = this.element.querySelector('.required');
|
let required = this.element.querySelector('.required');
|
||||||
display(required, this._required);
|
display(required, this._required);
|
||||||
|
|
||||||
this.$.$applyAsync(() =>
|
|
||||||
this.input.setAttribute('required', value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get required() {
|
get required() {
|
||||||
|
|
|
@ -173,7 +173,7 @@
|
||||||
"Swift / BIC cannot be empty": "Swift / BIC no puede estar vacío",
|
"Swift / BIC cannot be empty": "Swift / BIC no puede estar vacío",
|
||||||
"This BIC already exist.": "Este BIC ya existe.",
|
"This BIC already exist.": "Este BIC ya existe.",
|
||||||
"That item doesn't exists": "Ese artículo no existe",
|
"That item doesn't exists": "Ese artículo no existe",
|
||||||
"There's a new urgent ticket": "Hay un nuevo ticket urgente: [{{title}}](https://cau.verdnatura.es/WorkOrder.do?woMode=viewWO&woID={{issueId}})",
|
"There's a new urgent ticket:": "Hay un nuevo ticket urgente:",
|
||||||
"Invalid account": "Cuenta inválida",
|
"Invalid account": "Cuenta inválida",
|
||||||
"Compensation account is empty": "La cuenta para compensar está vacia",
|
"Compensation account is empty": "La cuenta para compensar está vacia",
|
||||||
"This genus already exist": "Este genus ya existe",
|
"This genus already exist": "Este genus ya existe",
|
||||||
|
|
|
@ -17,6 +17,15 @@
|
||||||
"connectTimeout": 40000,
|
"connectTimeout": 40000,
|
||||||
"acquireTimeout": 20000
|
"acquireTimeout": 20000
|
||||||
},
|
},
|
||||||
|
"osticket": {
|
||||||
|
"connector": "vn-mysql",
|
||||||
|
"database": "vn",
|
||||||
|
"debug": false,
|
||||||
|
"host": "localhost",
|
||||||
|
"port": "3306",
|
||||||
|
"username": "root",
|
||||||
|
"password": "root"
|
||||||
|
},
|
||||||
"tempStorage": {
|
"tempStorage": {
|
||||||
"name": "tempStorage",
|
"name": "tempStorage",
|
||||||
"connector": "loopback-component-storage",
|
"connector": "loopback-component-storage",
|
||||||
|
|
|
@ -165,13 +165,13 @@ class Controller extends Section {
|
||||||
created: this.ticket.updated
|
created: this.ticket.updated
|
||||||
};
|
};
|
||||||
this.showSMSDialog({
|
this.showSMSDialog({
|
||||||
message: this.$params.message || this.$t('Minimum is needed', params)
|
message: this.$t('Minimum is needed', params)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
sendPaymentSms() {
|
sendPaymentSms() {
|
||||||
this.showSMSDialog({
|
this.showSMSDialog({
|
||||||
message: this.$params.message || this.$t('Make a payment')
|
message: this.$t('Make a payment')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,12 @@ class Controller extends Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
get ticketState() {
|
get ticketState() {
|
||||||
if (!this.ticket) return null;
|
const ticket = this.ticket;
|
||||||
|
if (!ticket) return null;
|
||||||
|
|
||||||
return this.ticket.ticketState.state.code;
|
const ticketState = ticket.ticketState;
|
||||||
|
|
||||||
|
return ticketState && ticketState.state.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSaleTotal(sale) {
|
getSaleTotal(sale) {
|
||||||
|
|
Loading…
Reference in New Issue