Merge branch 'dev' into 4146-claim_pickup_order
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2022-11-02 12:01:11 +00:00
commit 2a8a8ed84a
12 changed files with 141 additions and 22 deletions

View File

@ -1,12 +1,13 @@
const jsdom = require('jsdom'); const jsdom = require('jsdom');
const mysql = require('mysql'); const mysql = require('mysql');
const FormData = require('form-data');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('closeTicket', { Self.remoteMethodCtx('closeTicket', {
description: 'Close tickets without response from the user', description: 'Close tickets without response from the user',
accessType: 'READ', accessType: 'READ',
returns: { returns: {
type: 'Object', type: 'object',
root: true root: true
}, },
http: { http: {
@ -54,9 +55,9 @@ module.exports = Self => {
}); });
}); });
await requestToken(); await getRequestToken();
async function requestToken() { async function getRequestToken() {
const response = await fetch(ostUri); const response = await fetch(ostUri);
const result = response.headers.get('set-cookie'); const result = response.headers.get('set-cookie');
@ -93,24 +94,45 @@ module.exports = Self => {
await close(token, secondCookie); await close(token, secondCookie);
} }
async function getLockCode(token, secondCookie, ticketId) {
const ostUri = `${config.host}/ajax.php/lock/ticket/${ticketId}`;
const params = {
method: 'POST',
headers: {
'X-CSRFToken': token,
'Cookie': secondCookie
}
};
const response = await fetch(ostUri, params);
const body = await response.text();
const json = JSON.parse(body);
return json.code;
}
async function close(token, secondCookie) { async function close(token, secondCookie) {
for (const ticketId of ticketsId) { for (const ticketId of ticketsId) {
const ostUri = `${config.host}/ajax.php/tickets/${ticketId}/status`; const lockCode = await getLockCode(token, secondCookie, ticketId);
const data = { let form = new FormData();
status_id: config.newStatusId, form.append('__CSRFToken__', token);
comments: config.comment, form.append('id', ticketId);
undefined: config.action form.append('a', config.responseType);
}; form.append('lockCode', lockCode);
form.append('from_email_id', config.fromEmailId);
form.append('reply-to', config.replyTo);
form.append('cannedResp', 0);
form.append('response', config.comment);
form.append('signature', 'none');
form.append('reply_status_id', config.newStatusId);
const ostUri = `${config.host}/tickets.php?id=${ticketId}`;
const params = { const params = {
method: 'POST', method: 'POST',
body: new URLSearchParams(data), body: form,
headers: { headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'X-CSRFToken': token,
'Cookie': secondCookie 'Cookie': secondCookie
} }
}; };
return fetch(ostUri, params); return fetch(ostUri, params);
} }
} }

View File

@ -27,9 +27,6 @@
"newStatusId": { "newStatusId": {
"type": "number" "type": "number"
}, },
"action": {
"type": "string"
},
"day": { "day": {
"type": "number" "type": "number"
}, },
@ -47,6 +44,15 @@
}, },
"portDb": { "portDb": {
"type": "number" "type": "number"
},
"responseType": {
"type": "string"
},
"fromEmailId": {
"type": "number"
},
"replyTo": {
"type": "string"
} }
} }
} }

View File

@ -14,7 +14,3 @@ CREATE TABLE `vn`.`osTicketConfig` (
`portDb` int(11) DEFAULT NULL, `portDb` int(11) DEFAULT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
INSERT INTO `vn`.`osTicketConfig`(`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `action`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`)
VALUES
(0, 'https://cau.verdnatura.es/scp', NULL, NULL, 'open', 3, 'Cerrar', 60, 'Este CAU se ha cerrado automáticamente', NULL, NULL, NULL, NULL);

View File

@ -0,0 +1,2 @@
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalId)
VALUES ('WorkerDisableExcluded','*','*','ALLOW','hr');

View File

@ -0,0 +1,8 @@
ALTER TABLE `vn`.`osTicketConfig` DROP COLUMN `action`;
ALTER TABLE `vn`.`osTicketConfig` ADD responseType varchar(100) NULL;
ALTER TABLE `vn`.`osTicketConfig` ADD fromEmailId INT NULL;
ALTER TABLE `vn`.`osTicketConfig` ADD replyTo varchar(100) NULL;
UPDATE `vn`.`osTicketConfig`
SET responseType='reply', fromEmailId=5, replyTo='all'
WHERE id=0;

View File

@ -2710,3 +2710,7 @@ INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `created`, `lev
UPDATE `account`.`user` UPDATE `account`.`user`
SET `hasGrant` = 1 SET `hasGrant` = 1
WHERE `id` = 66; WHERE `id` = 66;
INSERT INTO `vn`.`osTicketConfig` (`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`, `responseType`, `fromEmailId`, `replyTo`)
VALUES
(0, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', 'open', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all');

View File

@ -64,6 +64,9 @@
}, },
"WorkerTimeControlMail": { "WorkerTimeControlMail": {
"dataSource": "vn" "dataSource": "vn"
},
"WorkerDisableExcluded": {
"dataSource": "vn"
} }
} }

View File

@ -0,0 +1,26 @@
{
"name": "WorkerDisableExcluded",
"base": "VnModel",
"options": {
"mysql": {
"table": "workerDisableExcluded"
}
},
"properties": {
"workerFk": {
"id": true,
"type": "number"
},
"dated": {
"type": "date"
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}
]
}

View File

@ -14,6 +14,20 @@
</vn-float-button> </vn-float-button>
</div> </div>
</slot-before> </slot-before>
<slot-menu>
<vn-item
ng-click="$ctrl.handleExcluded()"
translate
ng-if="!$ctrl.excluded">
Click to exclude the user from getting disabled
</vn-item>
<vn-item
ng-click="$ctrl.handleExcluded()"
translate
ng-if="$ctrl.excluded">
Click to allow the user to be disabled
</vn-item>
</slot-menu>
<slot-body> <slot-body>
<div class="attributes"> <div class="attributes">
<vn-label-value <vn-label-value
@ -37,6 +51,13 @@
value="{{$ctrl.worker.sip.extension}}"> value="{{$ctrl.worker.sip.extension}}">
</vn-label-value> </vn-label-value>
</div> </div>
<div class="icons">
<vn-icon
vn-tooltip="This user can't be disabled"
icon="person"
ng-if="$ctrl.worker.excluded">
</vn-icon>
</div>
<div class="quicklinks"> <div class="quicklinks">
<div ng-transclude="btnOne"> <div ng-transclude="btnOne">
<vn-quick-link <vn-quick-link

View File

@ -13,6 +13,33 @@ class Controller extends Descriptor {
set worker(value) { set worker(value) {
this.entity = value; this.entity = value;
if (value)
this.getIsExcluded();
}
get excluded() {
return this.entity.excluded;
}
set excluded(value) {
this.entity.excluded = value;
}
getIsExcluded() {
this.$http.get(`workerDisableExcludeds/${this.entity.id}/exists`).then(data => {
this.excluded = data.data.exists;
});
}
handleExcluded() {
if (this.excluded) {
this.$http.delete(`workerDisableExcludeds/${this.entity.id}`);
this.excluded = false;
} else {
this.$http.post(`workerDisableExcludeds`, {workerFk: this.entity.id, dated: new Date});
this.excluded = true;
}
} }
loadData() { loadData() {

View File

@ -21,3 +21,6 @@ Worker id: Id trabajador
Workers: Trabajadores Workers: Trabajadores
worker: trabajador worker: trabajador
Go to the worker: Ir al trabajador Go to the worker: Ir al trabajador
Click to exclude the user from getting disabled: Marcar para no deshabilitar
Click to allow the user to be disabled: Marcar para deshabilitar
This user can't be disabled: Fijado para no deshabilitar

View File

@ -16,6 +16,7 @@
"bcrypt": "^5.0.1", "bcrypt": "^5.0.1",
"bmp-js": "^0.1.0", "bmp-js": "^0.1.0",
"compression": "^1.7.3", "compression": "^1.7.3",
"form-data": "^4.0.0",
"fs-extra": "^5.0.0", "fs-extra": "^5.0.0",
"ftps": "^1.2.0", "ftps": "^1.2.0",
"got": "^10.7.0", "got": "^10.7.0",