feat(vnApp): getUrl and create salix.url. test(boxing): getVideoList
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
f698a22fcf
commit
2c691eb796
|
@ -101,6 +101,9 @@
|
|||
"Town": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Url": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"UserConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"name": "Url",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "salix.url"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"appName": {
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"id": 1
|
||||
},
|
||||
"environment": {
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"id": 2
|
||||
},
|
||||
"url": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ INSERT INTO `vn`.`packingSiteConfig` SET
|
|||
shinobiUrl = 'https://shinobi.verdnatura.es',
|
||||
shinobiToken = 'BW4o7FZyJ85she1hlRDe6QnwW3jwEP',
|
||||
shinobiGroupKey = 'xVqft9LFXg',
|
||||
avgBoxingTime = 30;
|
||||
avgBoxingTime = 6000;
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
CREATE TABLE `salix`.`url` (
|
||||
`appName` varchar(100) NOT NULL,
|
||||
`environment` varchar(100) NOT NULL,
|
||||
`url` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`appName`,`environment`)
|
||||
);
|
||||
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('salix', 'production', 'https://salix.verdnatura.es/#!/');
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('salix', 'test', 'https://test-salix.verdnatura.es/#!/');
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('salix', 'dev', 'http://localhost:5000/#!/');
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('lilium', 'production', 'https://lilium.verdnatura.es/#/');
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('lilium', 'test', 'https://test-lilium.verdnatura.es/#/');
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('lilium', 'dev', 'http://localhost:8080/#/');
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Url', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Url', '*', 'WRITE', 'ALLOW', 'ROLE', 'it');
|
|
@ -54,6 +54,23 @@ export default class App {
|
|||
localStorage.setItem('salix-version', newVersion);
|
||||
}
|
||||
}
|
||||
|
||||
getUrl(route, appName) {
|
||||
if (!appName) appName = 'lilium';
|
||||
|
||||
const env = process.env.NODE_ENV;
|
||||
const filter = {
|
||||
where: {and: [
|
||||
{appName: appName},
|
||||
{environment: env}
|
||||
]}
|
||||
};
|
||||
|
||||
return this.logger.$http.get('Urls/findOne', {filter})
|
||||
.then(res => {
|
||||
return res.data.url + route;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.service('vnApp', App);
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const https = require('https');
|
||||
|
||||
xdescribe('boxing getVideo()', () => {
|
||||
it('should return data', async() => {
|
||||
const tx = await models.PackingSiteConfig.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const id = 1;
|
||||
const video = 'video.mp4';
|
||||
|
||||
const response = {
|
||||
pipe: () => {},
|
||||
on: () => {},
|
||||
end: () => {},
|
||||
};
|
||||
|
||||
const req = {
|
||||
headers: 'apiHeader',
|
||||
data: {
|
||||
pipe: () => {},
|
||||
on: () => {},
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(https, 'request').and.returnValue(response);
|
||||
|
||||
const result = await models.Boxing.getVideo(id, video, req, null, options);
|
||||
|
||||
expect(result[0]).toEqual(response.data.videos[0].filename);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
|
@ -2,29 +2,30 @@ const models = require('vn-loopback/server/server').models;
|
|||
const axios = require('axios');
|
||||
|
||||
describe('boxing getVideoList()', () => {
|
||||
it('should return data', async() => {
|
||||
it('should return video list', async() => {
|
||||
const tx = await models.PackingSiteConfig.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const params = {
|
||||
id: 1,
|
||||
from: 1,
|
||||
to: 2
|
||||
};
|
||||
const id = 1;
|
||||
const from = 1;
|
||||
const to = 2;
|
||||
|
||||
const response = {
|
||||
data: {
|
||||
pipe: () => {},
|
||||
on: () => {},
|
||||
videos: [{
|
||||
id: 1,
|
||||
filename: 'video1.mp4'
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(axios, 'get').and.returnValue(new Promise(resolve => resolve(response)));
|
||||
|
||||
const result = await models.Sale.canEdit(params, options);
|
||||
const result = await models.Boxing.getVideoList(id, from, to, options);
|
||||
|
||||
expect(result).toEqual([]);
|
||||
expect(result[0]).toEqual(response.data.videos[0].filename);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
|
@ -6,20 +6,9 @@ class Controller extends Section {
|
|||
super($element, $);
|
||||
}
|
||||
|
||||
$onInit() {
|
||||
window.location.href = this.lilium(`ticket/${this.ticket.id}/boxing`);
|
||||
}
|
||||
|
||||
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;
|
||||
async $onInit() {
|
||||
const url = await this.vnApp.getUrl(`ticket/${this.$params.id}/boxing`);
|
||||
window.open(url).focus();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue