Merge branch 'dev' of https://git.verdnatura.es/salix into dev

This commit is contained in:
Juan Ferrer Toribio 2018-02-07 16:45:50 +01:00
commit f84bf44550
18 changed files with 202 additions and 40 deletions

View File

@ -61,7 +61,7 @@ export default class Controller {
} }
_observationsEquals(ob1, ob2) { _observationsEquals(ob1, ob2) {
return ob1.observationTypeFk === ob2.observationTypeFk && ob1.description === ob2.description; return ob1.id === ob2.id && ob1.observationTypeFk === ob2.observationTypeFk && ob1.description === ob2.description;
} }
submit() { submit() {
@ -80,12 +80,13 @@ export default class Controller {
let observation = this.observations[i]; let observation = this.observations[i];
let isNewObservation = observation.id === undefined; let isNewObservation = observation.id === undefined;
if (types.indexOf(observation.observationTypeFk) !== -1) { if (observation.observationTypeFk && types.indexOf(observation.observationTypeFk) !== -1) {
repeatedTypes = true; repeatedTypes = true;
break; break;
} }
types.push(observation.observationTypeFk); if (observation.observationTypeFk)
types.push(observation.observationTypeFk);
if (isNewObservation && observation.observationTypeFk && observation.description) { if (isNewObservation && observation.observationTypeFk && observation.description) {
observationsObj.create.push(observation); observationsObj.create.push(observation);

View File

@ -20,7 +20,46 @@ describe('Client', () => {
})); }));
it('should define and set address property', () => { it('should define and set address property', () => {
expect(controller.address.id).toBe(1); expect(controller.address.id).toEqual(1);
});
describe('removeObservation(index)', () => {
it('should remove an observation that occupies in the index given and restore showAddIcon properties', () => {
let index = 2;
controller.observations = [
{id: 1, description: 'Spiderman rocks', showAddIcon: false},
{id: 2, description: 'Batman sucks', showAddIcon: false},
{id: 3, description: 'Ironman rules', showAddIcon: true}
];
spyOn(controller, '_setIconAdd').and.callThrough();
controller.removeObservation(index);
expect(controller._setIconAdd).toHaveBeenCalledWith();
expect(controller.observations.length).toEqual(2);
expect(controller.observations[0].showAddIcon).toBeFalsy();
expect(controller.observations[1].showAddIcon).toBeTruthy();
expect(controller.observations[index]).toBe(undefined);
});
});
describe('_observationsEquals', () => {
it('should return true if two observations are equals independent of control attributes', () => {
let ob1 = {id: 1, observationTypeFk: 1, description: 'Spiderman rocks', showAddIcon: true};
let ob2 = {id: 1, observationTypeFk: 1, description: 'Spiderman rocks', showAddIcon: false};
let equals = controller._observationsEquals(ob2, ob1);
expect(equals).toBeTruthy();
});
it('should return false if two observations are not equals independent of control attributes', () => {
let ob1 = {id: 1, observationTypeFk: 1, description: 'Spiderman rocks', showAddIcon: true};
let ob2 = {id: 1, observationTypeFk: 1, description: 'Spiderman sucks', showAddIcon: true};
let equals = controller._observationsEquals(ob2, ob1);
expect(equals).toBeFalsy();
});
}); });
describe('$onInit()', () => { describe('$onInit()', () => {

View File

@ -1,5 +1,4 @@
<mg-ajax path="/item/api/items/1/getLog"></mg-ajax> <mg-ajax path="/item/api/ItemLogs/getLog" options="vnIndex"></mg-ajax>
<!-- <mg-ajax path="/item/api/history/{{edit.params.id}}/sumAmount" options="mgEdit"></mg-ajax> -->
<vn-card pad-medium> <vn-card pad-medium>
<vn-vertical pad-medium> <vn-vertical pad-medium>
<vn-title vn-one margin-large-bottom>Item history</vn-title> <vn-title vn-one margin-large-bottom>Item history</vn-title>
@ -15,19 +14,17 @@
class="list list-element text-center" class="list list-element text-center"
pad-small-bottom pad-small-bottom
ng-repeat="itemLog in index.model.instances track by itemLog.id"> ng-repeat="itemLog in index.model.instances track by itemLog.id">
<vn-one pad-medium-h>{{::itemLog.originFk}}</vn-one> <vn-one pad-medium-h>{{::itemLog.origin.name}}</vn-one>
<vn-two pad-medium-h>{{::itemLog.userFk}}</vn-two> <vn-two pad-medium-h>{{::itemLog.user.name}}</vn-two>
<vn-one pad-medium-h>{{::itemLog.action}}</vn-one> <vn-one pad-medium-h>{{::itemLog.action}}</vn-one>
<vn-one pad-medium-h>{{::itemLog.creationDate | date:'dd/MM/yyyy HH:mm'}}</vn-one> <vn-one pad-medium-h>{{::itemLog.creationDate | date:'dd/MM/yyyy HH:mm'}}</vn-one>
<vn-one pad-medium-h>{{::itemLog.description}}</vn-one> <vn-one pad-medium-h>{{::itemLog.description}}</vn-one>
</vn-horizontal> </vn-horizontal>
</vn-one> </vn-one>
<vn-one class="text-center pad-small-v" ng-if="index.model.count === 0" translate>No results</vn-one>
<vn-horizontal vn-one class="list list-footer text-center"> <vn-horizontal vn-one class="list list-footer text-center">
<vn-one pad-medium-h></vn-one> <vn-one pad-medium-h></vn-one>
<vn-two pad-medium-h></vn-two> <vn-two pad-medium-h></vn-two>
<vn-one pad-medium-h></vn-one> <vn-one pad-medium-h></vn-one>
</vn-horizontal> </vn-horizontal>
<vn-paging margin-large-top vn-one index="index" total="index.model.count"></vn-paging>
</vn-vertical> </vn-vertical>
</vn-card> </vn-card>

View File

@ -11,6 +11,10 @@ const exec = require('child_process').exec;
// Configuration // Configuration
const isWindows = /^win/.test(process.platform); const isWindows = /^win/.test(process.platform);
if (gutil.env.NODE_ENV)
process.env.NODE_ENV = gutil.env.NODE_ENV;
const env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development'; const env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
const langs = ['es', 'en']; const langs = ['es', 'en'];
@ -118,17 +122,17 @@ gulp.task('docker-compose', async () => {
let services = await getServices(); let services = await getServices();
for (let service of services) { for (let service of services) {
let dockerFile = `${__dirname}/Dockerfile`; let dockerFile = `${__dirname}/${service.name}/Dockerfile`;
if (await fs.exists(`./services/${service.name}/Dockerfile`)) // if (await fs.exists(`./services/${service.name}/Dockerfile`))
dockerFile = 'Dockerfile'; // dockerFile = 'Dockerfile';
composeYml.services[service.name] = { composeYml.services[service.name] = {
environment: ['NODE_ENV=${NODE_ENV}'], environment: ['NODE_ENV=${NODE_ENV}'],
container_name: `\${BRANCH_NAME}-${service.name}`, container_name: `\${BRANCH_NAME}-${service.name}`,
image: `${service.name}:\${TAG}`, image: `${service.name}:\${TAG}`,
build: { build: {
context: `./services/${service.name}`, context: `./services`,
dockerfile: dockerFile dockerfile: dockerFile
}, },
ports: [`${defaultPort}:${service.port}`] ports: [`${defaultPort}:${service.port}`]

11
services/auth/Dockerfile Normal file
View File

@ -0,0 +1,11 @@
FROM node:8.9.4
COPY . /app
COPY ../loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]

View File

@ -0,0 +1,12 @@
FROM node:8.9.4
COPY . /app
COPY ../loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]

12
services/item/Dockerfile Normal file
View File

@ -0,0 +1,12 @@
FROM node:8.9.4
COPY . /app
COPY ../loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]

View File

@ -1,27 +1,19 @@
module.exports = Self => { module.exports = Self => {
Self.remoteMethod('itemLog', { Self.installMethod('getLog', filterParams);
description: 'Returns the item changes log',
accessType: 'READ',
accepts: [{
arg: 'id',
type: 'number',
required: true,
description: 'The item id',
http: {source: 'path'}
}],
returns: {
arg: 'data',
type: ['Object'],
root: true
},
http: {
path: `/:id/itemLog`,
verb: 'get'
}
});
Self.itemLog = itemFk => { function filterParams(params) {
let query = `SELECT * FROM vn.itemLog WHERE itemFk = ?`; return {
return Self.rawSql(query, [itemFk]); where: {
}; itemFk: params.itemFk
},
skip: (params.page - 1) * params.size,
limit: params.size,
include: [{
relation: "origin"
},
{
relation: "user"
}]
};
}
}; };

View File

@ -1,6 +1,5 @@
module.exports = function(Self) { module.exports = function(Self) {
require('../methods/item/filter.js')(Self); require('../methods/item/filter.js')(Self);
require('../methods/item/getLog.js')(Self);
Self.validatesPresenceOf('name', {message: 'Cannot be blank'}); Self.validatesPresenceOf('name', {message: 'Cannot be blank'});
Self.validatesPresenceOf('originFk', {message: 'Cannot be blank'}); Self.validatesPresenceOf('originFk', {message: 'Cannot be blank'});

View File

@ -0,0 +1,3 @@
module.exports = function(Self) {
require('../methods/item/getLog.js')(Self);
};

View File

@ -0,0 +1,35 @@
{
"name": "ItemLog",
"base": "VnModel",
"options": {
"mysql": {
"table": "itemLog",
"database": "vn"
}
},
"properties": {
"id": {
"type": "Number",
"id": true,
"description": "Identifier"
},
"creationDate": {
"type": "Date"
},
"description": {
"type": "String"
}
},
"relations": {
"origin": {
"type": "belongsTo",
"model": "Origin",
"foreignKey": "originFk"
},
"user": {
"type": "belongsTo",
"model": "User",
"foreignKey": "userFk"
}
}
}

View File

@ -34,5 +34,8 @@
}, },
"Tag": { "Tag": {
"dataSource": "vn" "dataSource": "vn"
},
"ItemLog": {
"dataSource": "vn"
} }
} }

View File

@ -0,0 +1,11 @@
FROM node:8.9.4
COPY . /app
COPY ../loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]

11
services/print/Dockerfile Normal file
View File

@ -0,0 +1,11 @@
FROM node:8.9.4
COPY . /app
COPY ../loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]

View File

@ -0,0 +1,11 @@
FROM node:8.9.4
COPY . /app
COPY ../loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]

11
services/route/Dockerfile Normal file
View File

@ -0,0 +1,11 @@
FROM node:8.9.4
COPY . /app
COPY ../loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]

11
services/salix/Dockerfile Normal file
View File

@ -0,0 +1,11 @@
FROM node:8.9.4
COPY . /app
COPY ../loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]

View File

@ -36,4 +36,3 @@ jasmine.addReporter(new SpecReporter({
})); }));
jasmine.execute(); jasmine.execute();