Merge branch 'dev' of https://git.verdnatura.es/salix into dev
* 'dev' of https://git.verdnatura.es/salix: refact list production docker production filtering in temporary table docker compose docker
This commit is contained in:
commit
f6d9f44df4
|
@ -18,7 +18,7 @@ if (branchName == branchProduction)
|
||||||
node
|
node
|
||||||
{
|
{
|
||||||
stage ('Print environment variables'){
|
stage ('Print environment variables'){
|
||||||
echo "Branch ${branchName}, Build ${env.TAG} en docker Host ${dockerHost}"
|
echo "Branch ${branchName}, Build ${env.TAG}, NODE_ENV ${env.NODE_ENV} en docker Host ${dockerHost}"
|
||||||
}
|
}
|
||||||
stage ('Checkout') {
|
stage ('Checkout') {
|
||||||
checkout scm
|
checkout scm
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<paging
|
<paging
|
||||||
page="$ctrl.currentPage"
|
page="$ctrl.currentPage"
|
||||||
page-size="$ctrl.numPerPage"
|
page-size="$ctrl.numPerPage"
|
||||||
|
ng-if="$ctrl.numPages>1"
|
||||||
total="$ctrl.numItems"
|
total="$ctrl.numItems"
|
||||||
show-prev-next="true"
|
show-prev-next="true"
|
||||||
show-first-last="false"
|
show-first-last="false"
|
||||||
|
|
|
@ -83,7 +83,15 @@ export default class ProductionIndex {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
onChildSubmit(filter) {
|
onChildSubmit(filter) {
|
||||||
this.searchTickets(filter);
|
let newFilter = {};
|
||||||
|
Object.keys(filter).forEach(
|
||||||
|
field => {
|
||||||
|
if (filter[field] !== null) {
|
||||||
|
newFilter[field] = filter[field];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
this.searchTickets(newFilter);
|
||||||
this.onChildCancel();
|
this.onChildCancel();
|
||||||
}
|
}
|
||||||
onChildCancel() {
|
onChildCancel() {
|
||||||
|
@ -111,7 +119,7 @@ export default class ProductionIndex {
|
||||||
}
|
}
|
||||||
refreshTickets() {
|
refreshTickets() {
|
||||||
this.filter = {};
|
this.filter = {};
|
||||||
this.filter.warehouseFk = this.userProfile.warehouseId;
|
this.filter.warehouseFk = this.$.displayValue = this.userProfile.warehouseId;
|
||||||
this.search = null;
|
this.search = null;
|
||||||
}
|
}
|
||||||
onChangeWareHouse(warehouse) {
|
onChangeWareHouse(warehouse) {
|
||||||
|
@ -130,7 +138,6 @@ export default class ProductionIndex {
|
||||||
this.hourItems.push({id: i, name: hour});
|
this.hourItems.push({id: i, name: hour});
|
||||||
}
|
}
|
||||||
this.filter.warehouseFk = this.$.displayValue = this.userProfile.warehouseId;
|
this.filter.warehouseFk = this.$.displayValue = this.userProfile.warehouseId;
|
||||||
this.searchTickets(this.filter);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ export class ProductionTable {
|
||||||
constructor($filter) {
|
constructor($filter) {
|
||||||
this.$filter = $filter;
|
this.$filter = $filter;
|
||||||
this._tickets = [];
|
this._tickets = [];
|
||||||
this.itemsDisplayedInList = 14;
|
this.itemsDisplayedInList = 16;
|
||||||
this._checkAll = 0;
|
this._checkAll = 0;
|
||||||
this.pageTable = {
|
this.pageTable = {
|
||||||
filter: {
|
filter: {
|
||||||
|
|
|
@ -52,7 +52,7 @@ html [vn-center], .vn-center{
|
||||||
}
|
}
|
||||||
|
|
||||||
.list-element{
|
.list-element{
|
||||||
padding: 4px 0px;
|
padding: 8px 0 0 0;
|
||||||
border-bottom: 1px solid $color-medium-grey;
|
border-bottom: 1px solid $color-medium-grey;
|
||||||
i {
|
i {
|
||||||
color: $color-orange;
|
color: $color-orange;
|
||||||
|
|
|
@ -64,6 +64,19 @@ services:
|
||||||
ports:
|
ports:
|
||||||
- "3004:3004"
|
- "3004:3004"
|
||||||
|
|
||||||
|
route:
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=${NODE_ENV}
|
||||||
|
container_name: "${BRANCH_NAME}-route"
|
||||||
|
image: "route:${TAG}"
|
||||||
|
build:
|
||||||
|
context: ./services
|
||||||
|
dockerfile: /route/Dockerfile
|
||||||
|
expose:
|
||||||
|
- "3005"
|
||||||
|
ports:
|
||||||
|
- "3005:3005"
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
container_name: "${BRANCH_NAME}-nginx"
|
container_name: "${BRANCH_NAME}-nginx"
|
||||||
image: "nginx:${TAG}"
|
image: "nginx:${TAG}"
|
||||||
|
@ -80,3 +93,4 @@ services:
|
||||||
- "client:${BRANCH_NAME}-client"
|
- "client:${BRANCH_NAME}-client"
|
||||||
- "mailer:${BRANCH_NAME}-mailer"
|
- "mailer:${BRANCH_NAME}-mailer"
|
||||||
- "production:${BRANCH_NAME}-production"
|
- "production:${BRANCH_NAME}-production"
|
||||||
|
- "route:${BRANCH_NAME}-route"
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
FROM node:6.9.1
|
FROM node:6.9.1
|
||||||
|
|
||||||
COPY ./auth /app
|
COPY auth /app
|
||||||
|
|
||||||
COPY ./loopback /loopback
|
COPY loopback /loopback
|
||||||
|
|
||||||
|
RUN npm install loopback
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
FROM node:6.9.1
|
FROM node:6.9.1
|
||||||
|
|
||||||
COPY ./client /app
|
COPY client /app
|
||||||
|
|
||||||
COPY ./loopback /loopback
|
COPY loopback /loopback
|
||||||
|
|
||||||
|
RUN npm install loopback
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ module.exports = function(Self) {
|
||||||
Self.setup = function() {
|
Self.setup = function() {
|
||||||
Self.super_.setup.call(this);
|
Self.super_.setup.call(this);
|
||||||
|
|
||||||
let disableMethods = {
|
/* let disableMethods = {
|
||||||
create: true,
|
create: true,
|
||||||
replaceOrCreate: true,
|
replaceOrCreate: true,
|
||||||
patchOrCreate: true,
|
patchOrCreate: true,
|
||||||
|
@ -22,7 +22,7 @@ module.exports = function(Self) {
|
||||||
};
|
};
|
||||||
for (let method in disableMethods) {
|
for (let method in disableMethods) {
|
||||||
// this.disableRemoteMethod(method, disableMethods[method]);
|
// this.disableRemoteMethod(method, disableMethods[method]);
|
||||||
}
|
} */
|
||||||
};
|
};
|
||||||
|
|
||||||
Self.defineScope = function(serverFilter) {
|
Self.defineScope = function(serverFilter) {
|
||||||
|
@ -108,6 +108,10 @@ module.exports = function(Self) {
|
||||||
this.remoteMethod(methodName, args);
|
this.remoteMethod(methodName, args);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Self.getConnection = function(cb) {
|
||||||
|
this.dataSource.connector.client.getConnection(cb);
|
||||||
|
};
|
||||||
|
|
||||||
Self.connectToService = function(ctx, dataSource) {
|
Self.connectToService = function(ctx, dataSource) {
|
||||||
this.app.dataSources[dataSource].connector.remotes.auth = {
|
this.app.dataSources[dataSource].connector.remotes.auth = {
|
||||||
bearer: new Buffer(ctx.req.accessToken.id).toString('base64'),
|
bearer: new Buffer(ctx.req.accessToken.id).toString('base64'),
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
FROM node:6.9.1
|
FROM node:6.9.1
|
||||||
|
|
||||||
COPY ./production /app
|
COPY production /app
|
||||||
|
|
||||||
COPY ./loopback /loopback
|
COPY loopback /loopback
|
||||||
|
|
||||||
|
RUN npm install loopback
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|
|
@ -1,39 +1,54 @@
|
||||||
module.exports = function(FakeProduction) {
|
module.exports = function(Self) {
|
||||||
FakeProduction.defineScope();
|
Self.defineScope();
|
||||||
|
|
||||||
FakeProduction.list = function(ctx, filter, cb) {
|
Self.list = function(ctx, filter, callback) {
|
||||||
var page = filter.page - 1;
|
var page = filter.page - 1;
|
||||||
var limit = filter.limit * page;
|
var limit = filter.limit * page;
|
||||||
var offset = (page + 1) * filter.limit;
|
var offset = (page + 1) * filter.limit;
|
||||||
let daysTickets = 0;
|
let daysTickets = 0;
|
||||||
|
let warehouseFk = filter.where.warehouseFk;
|
||||||
delete filter.limit;
|
delete filter.limit;
|
||||||
delete filter.page;
|
delete filter.page;
|
||||||
|
delete filter.where.warehouseFk;
|
||||||
|
|
||||||
let query = `call salix.production_control_source( ? , ?)`;
|
let call = `call salix.production_control_source(? , ?)`;
|
||||||
var params = [filter.where.warehouseFk, daysTickets];
|
var params = [warehouseFk, daysTickets];
|
||||||
FakeProduction.rawSql(query, params)
|
let conn;
|
||||||
.then(function(response) {
|
|
||||||
getValue();
|
Self.getConnection((err, connection) => {
|
||||||
})
|
if (err) {
|
||||||
.catch(function(response) {
|
onFinish(err);
|
||||||
cb(response, null);
|
}
|
||||||
|
conn = connection;
|
||||||
|
conn.query(call, params, getValue);
|
||||||
});
|
});
|
||||||
let getValue = () => {
|
|
||||||
|
|
||||||
|
function getValue(err) {
|
||||||
|
if (err) {
|
||||||
|
onFinish(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
reBuildFilter();
|
||||||
|
let where = Self.dataSource.connector.buildWhere(Self.modelName, filter.where);
|
||||||
|
let query = `SELECT * FROM tmp.production ${where.sql} GROUP BY RouteFk ORDER BY routeFk`;
|
||||||
|
conn.query(query, where.params, onFinish);
|
||||||
|
}
|
||||||
|
|
||||||
|
function reBuildFilter() {
|
||||||
if (filter.where && filter.where.q) {
|
if (filter.where && filter.where.q) {
|
||||||
var newFilter = {
|
let regexQ = new RegExp(filter.where.q);
|
||||||
|
delete filter.where.q;
|
||||||
|
let newFilter = {
|
||||||
and: [
|
and: [
|
||||||
{
|
{
|
||||||
or: [
|
or: [
|
||||||
{agency: {regexp: filter.where.q}},
|
{agency: {regexp: regexQ}},
|
||||||
{state: {regexp: filter.where.q}}
|
{state: {regexp: regexQ}}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
delete filter.where.q;
|
|
||||||
|
|
||||||
if (Object.keys(filter.where).length) {
|
if (Object.keys(filter.where).length) {
|
||||||
Object.keys(filter.where).forEach(
|
Object.keys(filter.where).forEach(
|
||||||
key => {
|
key => {
|
||||||
|
@ -45,18 +60,23 @@ module.exports = function(FakeProduction) {
|
||||||
}
|
}
|
||||||
filter.where = newFilter;
|
filter.where = newFilter;
|
||||||
}
|
}
|
||||||
FakeProduction.connectToService(ctx, "client");
|
}
|
||||||
this.find(filter, function(err, tickets) {
|
|
||||||
FakeProduction.disconnectFromService("client");
|
function onFinish(err, results) {
|
||||||
(err) ? cb(err, null) : cb(null, (sum(tickets)));
|
conn.query('DROP TEMPORARY TABLE IF EXISTS tmp.production');
|
||||||
});
|
conn.release();
|
||||||
};
|
if (err)
|
||||||
|
callback(err);
|
||||||
|
callback(null, sum(results));
|
||||||
|
}
|
||||||
|
|
||||||
function sum(tickets) {
|
function sum(tickets) {
|
||||||
var obj = {lines: 0, m3: 0};
|
var obj = {lines: 0, m3: 0};
|
||||||
tickets.forEach(function(t) {
|
tickets.forEach(function(t, i) {
|
||||||
obj.lines += t.lines;
|
obj.lines += t.lines;
|
||||||
obj.m3 += t.m3;
|
obj.m3 += t.m3;
|
||||||
|
if (tickets[i].problem)
|
||||||
|
tickets[i].problem = tickets[i].problem.trim();
|
||||||
}, this);
|
}, this);
|
||||||
obj.m3 = obj.m3.toFixed(2);
|
obj.m3 = obj.m3.toFixed(2);
|
||||||
obj.total = tickets.length;
|
obj.total = tickets.length;
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
FROM node:6.9.1
|
FROM node:6.9.1
|
||||||
|
|
||||||
COPY ./route /app
|
COPY route /app
|
||||||
|
|
||||||
COPY ./loopback /loopback
|
COPY loopback /loopback
|
||||||
|
|
||||||
|
RUN npm install loopback
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
FROM node:6.9.1
|
FROM node:6.9.1
|
||||||
|
|
||||||
COPY ./salix /app
|
COPY salix /app
|
||||||
|
|
||||||
COPY ./loopback /loopback
|
COPY loopback /loopback
|
||||||
|
|
||||||
|
RUN npm install loopback
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue