4075-ticket_boxing #1070
|
@ -0,0 +1,16 @@
|
|||
CREATE TABLE `vn`.`packingSiteConfig` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`shinobiUrl` varchar(255) NOT NULL,
|
||||
`shinobiGroupKey` varchar(255) NOT NULL,
|
||||
`avgBoxingTime` INT(3) NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
INSERT INTO `vn`.`packingSiteConfig` SET
|
||||
shinobiUrl = 'https://shinobi.verdnatura.es/',
|
||||
shinobiGroupKey = 'xVqft9LFXg',
|
||||
avgBoxingTime = 30;
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Boxing', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
export default function lilium(route) {
|
||||
const env = process.env.NODE_ENV;
|
||||
let newRoute = 'https://localhost:8080/#/' + route;
|
||||
|
||||
if (env == 'test')
|
||||
newRoute = 'https://test-lilium.verdnatura.es/#/' + route;
|
||||
if (env == 'producction')
|
||||
newRoute = 'https://lilium.verdnatura.es/#/' + route;
|
||||
|
||||
return newRoute;
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
const axios = require('axios');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('getVideo', {
|
||||
description: 'Get packing video of ticketId',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'Ticket id'
|
||||
},
|
||||
{
|
||||
arg: 'time',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'Time to add'
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true,
|
||||
},
|
||||
http: {
|
||||
path: `/getVideo`,
|
||||
verb: 'GET',
|
||||
},
|
||||
});
|
||||
|
||||
Self.getVideo = async(id, time, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const expedition = await models.Expedition.findById(id, null, myOptions);
|
||||
const packingSiteConfig = await models.PackingSiteConfig.findOne({}, myOptions);
|
||||
const token = await Self.getToken(packingSiteConfig);
|
||||
const monitorId = 'xVqft9LFXg';
|
||||
|
||||
const start = new Date(expedition.created);
|
||||
const end = start.setTime(start.getTime() + (time ? time : packingSiteConfig.avgBoxingTime));
|
||||
|
||||
const videoUrl = `${token}/videos/${packingSiteConfig}/${monitorId}?start=${start}&end=${end}`;
|
||||
const videos = await axios.post(`${packingSiteConfig.shinobiUrl}${videoUrl}`, {
|
||||
mail: packingSiteConfig.mail,
|
||||
pass: packingSiteConfig.pass
|
||||
});
|
||||
|
||||
console.log(videos);
|
||||
return videos.data;
|
||||
};
|
||||
|
||||
Self.getToken = async function getToken(packingSiteConfig) {
|
||||
const response = await axios.post(`${packingSiteConfig.shinobiUrl}?json=true`, {
|
||||
machineID: 1,
|
||||
ke: 'hola',
|
||||
});
|
||||
|
||||
console.log(response);
|
||||
return response.data;
|
||||
};
|
||||
};
|
|
@ -0,0 +1,69 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
xdescribe('sale canEdit()', () => {
|
||||
it('should return true if the role is production regardless of the saleTrackings', async() => {
|
||||
const tx = await models.Sale.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const productionUserID = 49;
|
||||
const ctx = {req: {accessToken: {userId: productionUserID}}};
|
||||
|
||||
const sales = [{id: 3}];
|
||||
|
||||
const result = await models.Sale.canEdit(ctx, sales, options);
|
||||
|
||||
expect(result).toEqual(true);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return true if the role is not production and none of the sales has saleTracking', async() => {
|
||||
const tx = await models.Sale.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const salesPersonUserID = 18;
|
||||
const ctx = {req: {accessToken: {userId: salesPersonUserID}}};
|
||||
|
||||
const sales = [{id: 10}];
|
||||
|
||||
const result = await models.Sale.canEdit(ctx, sales, options);
|
||||
|
||||
expect(result).toEqual(true);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return false if any of the sales has a saleTracking record', async() => {
|
||||
const tx = await models.Sale.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const salesPersonUserID = 18;
|
||||
const ctx = {req: {accessToken: {userId: salesPersonUserID}}};
|
||||
|
||||
const sales = [{id: 3}];
|
||||
|
||||
const result = await models.Sale.canEdit(ctx, sales, options);
|
||||
|
||||
expect(result).toEqual(false);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
|
@ -5,6 +5,9 @@
|
|||
"AnnualAverageInvoiced": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Boxing": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Component": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
@ -20,6 +23,9 @@
|
|||
"Packaging": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"PackingSiteConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"PrintServerQueue": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/boxing/getVideo')(Self);
|
||||
};
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "Boxing",
|
||||
"base": "PersistedModel",
|
||||
"acls": [
|
||||
{
|
||||
"accessType": "READ",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"name": "PackingSiteConfig",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "packingSiteConfig"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"description": "Identifier"
|
||||
},
|
||||
"shinobiUrl": {
|
||||
"type": "string"
|
||||
},
|
||||
"shinobiGroupKey":{
|
||||
"type":"string"
|
||||
},
|
||||
"avgBoxingTime":{
|
||||
"type":"number"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
<vn-card>
|
||||
</vn-card>
|
|
@ -0,0 +1,32 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
}
|
||||
|
||||
$onInit() {
|
||||
window.location.href = this.lilium('dashboard');
|
||||
}
|
||||
|
||||
lilium(route) {
|
||||
const env = process.env.NODE_ENV;
|
||||
let newRoute = 'http://localhost:8080/#/' + route;
|
||||
|
||||
if (env == 'test')
|
||||
newRoute = 'https://test-lilium.verdnatura.es/#/' + route;
|
||||
if (env == 'producction')
|
||||
newRoute = 'https://lilium.verdnatura.es/#/' + route;
|
||||
|
||||
return newRoute;
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnTicketBoxing', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
ticket: '<'
|
||||
}
|
||||
});
|
|
@ -33,3 +33,4 @@ import './dms/index';
|
|||
import './dms/create';
|
||||
import './dms/edit';
|
||||
import './sms';
|
||||
import './boxing';
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
{"state": "ticket.card.saleChecked", "icon": "assignment"},
|
||||
{"state": "ticket.card.components", "icon": "icon-components"},
|
||||
{"state": "ticket.card.saleTracking", "icon": "assignment"},
|
||||
{"state": "ticket.card.dms.index", "icon": "cloud_download"}
|
||||
{"state": "ticket.card.dms.index", "icon": "cloud_download"},
|
||||
{"state": "ticket.card.boxing", "icon": "science"}
|
||||
]
|
||||
},
|
||||
"keybindings": [
|
||||
|
@ -66,7 +67,7 @@
|
|||
"abstract": true,
|
||||
"params": {
|
||||
"ticket": "$ctrl.ticket"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"url" : "/step-one",
|
||||
|
@ -273,6 +274,15 @@
|
|||
"params": {
|
||||
"ticket": "$ctrl.ticket"
|
||||
}
|
||||
},
|
||||
{
|
||||
"url": "/boxing",
|
||||
"state": "ticket.card.boxing",
|
||||
"component": "vn-ticket-boxing",
|
||||
"description": "Boxing",
|
||||
"params": {
|
||||
"ticket": "$ctrl.ticket"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue