From 7d4dd7bb52751dc442f489e2d057b25f047288c4 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 1 Aug 2022 15:03:17 +0200 Subject: [PATCH] feat(boxing): return stream video --- .../10480-june/00-packingSiteConfig.sql | 2 +- .../ticket/back/methods/boxing/getVideo.js | 48 ++++++++++--------- modules/ticket/front/boxing/index.html | 3 ++ modules/ticket/front/boxing/index.js | 2 +- 4 files changed, 30 insertions(+), 25 deletions(-) diff --git a/db/changes/10480-june/00-packingSiteConfig.sql b/db/changes/10480-june/00-packingSiteConfig.sql index b32bc115e..879896f41 100644 --- a/db/changes/10480-june/00-packingSiteConfig.sql +++ b/db/changes/10480-june/00-packingSiteConfig.sql @@ -7,7 +7,7 @@ CREATE TABLE `vn`.`packingSiteConfig` ( ); INSERT INTO `vn`.`packingSiteConfig` SET - shinobiUrl = 'https://shinobi.verdnatura.es/', + shinobiUrl = 'http://shinobi.verdnatura.es', shinobiGroupKey = 'xVqft9LFXg', avgBoxingTime = 30; diff --git a/modules/ticket/back/methods/boxing/getVideo.js b/modules/ticket/back/methods/boxing/getVideo.js index 851e4cfac..4e2a4b12c 100644 --- a/modules/ticket/back/methods/boxing/getVideo.js +++ b/modules/ticket/back/methods/boxing/getVideo.js @@ -8,13 +8,13 @@ module.exports = Self => { { arg: 'id', type: 'number', - required: true, + required: false, description: 'Ticket id' }, { arg: 'time', type: 'number', - required: true, + required: false, description: 'Time to add' } ], @@ -31,35 +31,37 @@ module.exports = Self => { Self.getVideo = async(id, time, options) => { const models = Self.app.models; const myOptions = {}; - + console.log('ENTRY'); 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 token = 'BW4o7FZyJ85she1hlRDe6QnwW3jwEP'; + const groupKey = 'xVqft9LFXg'; + const monitorId = 'VbiUcajdaT';// 'xVqft9LFXg'; - const start = new Date(expedition.created); - const end = start.setTime(start.getTime() + (time ? time : packingSiteConfig.avgBoxingTime)); + const start = '2022-07-27T09:00:00';// new Date('2022-07-27'); // new Date(expedition.created); + const end = '2022-07-27T09:15:00';// 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 - }); + const videoUrl = `/${token}/videos/${groupKey}/${monitorId}?start=${start}&end=${end}`; + const url = `${packingSiteConfig.shinobiUrl}${videoUrl}`; + const data = await axios.post(url); - console.log(videos); - return videos.data; - }; + console.log(data.data.videos); + console.log('-----------------------'); + console.log('-----------------------'); + console.log('-----------------------'); + console.log('-----------------------'); - 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; + axios({ + method: 'get', + url: `${packingSiteConfig.shinobiUrl}${data.data.videos[0].href}`, + responseType: 'stream' + }) + .then(response => { + console.log(response); + return response; + }); }; }; diff --git a/modules/ticket/front/boxing/index.html b/modules/ticket/front/boxing/index.html index 7fb3b870e..e47976cd7 100644 --- a/modules/ticket/front/boxing/index.html +++ b/modules/ticket/front/boxing/index.html @@ -1,2 +1,5 @@ + diff --git a/modules/ticket/front/boxing/index.js b/modules/ticket/front/boxing/index.js index 6a1d4b4d3..722301963 100644 --- a/modules/ticket/front/boxing/index.js +++ b/modules/ticket/front/boxing/index.js @@ -7,7 +7,7 @@ class Controller extends Section { } $onInit() { - window.location.href = this.lilium('dashboard'); + // window.location.href = this.lilium('dashboard'); } lilium(route) {