diff --git a/Dockerfile b/Dockerfile index f2cbeeff9..5a65b9b18 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,5 +34,5 @@ COPY \ CMD ["pm2-runtime", "./back/process.yml"] -HEALTHCHECK --interval=1m --timeout=10s \ +HEALTHCHECK --interval=15s --timeout=10s \ CMD curl -f http://localhost:3000/api/Applications/status || exit 1 diff --git a/Jenkinsfile b/Jenkinsfile index 0d56f7476..1fa6a49ea 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,20 +6,13 @@ pipeline { disableConcurrentBuilds() } environment { - PROJECT_NAME = 'salix' - REGISTRY = 'registry.verdnatura.es' - PORT_MASTER_FRONT = '5002' - PORT_MASTER_BACK = '3001' - PORT_TEST_FRONT = '5001' - PORT_TEST_BACK = '4001' - TAG = "${env.BRANCH_NAME}" + PROJECT_NAME = 'salix' + STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}" } stages { stage('Checkout') { steps { script { - env.STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}" - if (!env.GIT_COMMITTER_EMAIL) { env.COMMITTER_EMAIL = sh( script: 'git --no-pager show -s --format="%ae"', @@ -29,16 +22,6 @@ pipeline { env.COMMITTER_EMAIL = env.GIT_COMMITTER_EMAIL; } - switch (env.BRANCH_NAME) { - case 'master': - env.PORT_FRONT = PORT_MASTER_FRONT - env.PORT_BACK = PORT_MASTER_BACK - break - case 'test': - env.PORT_FRONT = PORT_TEST_FRONT - env.PORT_BACK = PORT_TEST_BACK - break - } switch (env.BRANCH_NAME) { case 'master': env.NODE_ENV = 'production' @@ -48,6 +31,14 @@ pipeline { break } } + + configFileProvider([ + configFile(fileId: "salix.groovy", + variable: 'GROOVY_FILE') + ]) { + load env.GROOVY_FILE + } + sh 'printenv' } } @@ -57,8 +48,8 @@ pipeline { } steps { nodejs('node-lts') { - sh 'npm install --no-audit' - sh 'gulp install' + sh 'npm install --no-audit --prefer-offline' + sh 'gulp install --ci' } } } diff --git a/back/process.yml b/back/process.yml index 3062091b4..41a2fafff 100644 --- a/back/process.yml +++ b/back/process.yml @@ -2,4 +2,5 @@ apps: - script: ./loopback/server/server.js name: salix-back instances: 1 - max_restarts: 5 + max_restarts: 3 + restart_delay: 15000 diff --git a/docker-compose.yml b/docker-compose.yml index c9011bdf4..ff53b238d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,28 +1,45 @@ -version: '3.5' +version: '3.7' services: - front: - image: registry.verdnatura.es/salix-front:${TAG} - restart: unless-stopped - build: - context: . - dockerfile: front/Dockerfile - ports: - - ${PORT_FRONT}:80 - links: - - back - deploy: - replicas: 3 - back: - image: registry.verdnatura.es/salix-back:${TAG} - restart: unless-stopped - build: . - ports: - - ${PORT_BACK}:3000 - environment: - - NODE_ENV - volumes: - - /mnt/storage/containers/salix:/etc/salix - - /mnt/storage/pdfs:/var/lib/salix/pdfs - - /mnt/storage/dms:/var/lib/salix/dms - deploy: - replicas: 6 + front: + image: registry.verdnatura.es/salix-front:${BRANCH_NAME:?} + build: + context: . + dockerfile: front/Dockerfile + ports: + - ${FRONT_PORT:?}:80 + deploy: + replicas: 3 + back: + image: registry.verdnatura.es/salix-back:${BRANCH_NAME:?} + build: . + ports: + - ${BACK_PORT:?}:3000 + environment: + - NODE_ENV + configs: + - source: datasources + target: /etc/salix/datasources.json + - source: datasources_local + target: /etc/salix/datasources.local.json + - source: print + target: /etc/salix/print.json + - source: print_local + target: /etc/salix/print.local.json + volumes: + - /mnt/storage/pdfs:/var/lib/salix/pdfs + - /mnt/storage/dms:/var/lib/salix/dms + deploy: + replicas: 6 +configs: + datasources: + external: true + name: salix_datasources + datasources_local: + external: true + name: salix-${BRANCH_NAME:?}_datasources + print: + external: true + name: salix_print + print_local: + external: true + name: salix-${BRANCH_NAME:?}_print diff --git a/front/core/components/data-viewer/locale/es.yml b/front/core/components/data-viewer/locale/es.yml new file mode 100644 index 000000000..0368321f2 --- /dev/null +++ b/front/core/components/data-viewer/locale/es.yml @@ -0,0 +1 @@ +No service for the specified zone: No hay servicio para la zona especificada \ No newline at end of file diff --git a/front/core/directives/droppable.scss b/front/core/directives/droppable.scss index 97e6f8a19..f2e18a3ad 100644 --- a/front/core/directives/droppable.scss +++ b/front/core/directives/droppable.scss @@ -11,11 +11,9 @@ .vn-droppable, [vn-droppable] { - display: block; - &.dropping { background-color: $color-hover-cd; - border-color: $color-bg-dark; + border-color: $color-font-secondary; } } diff --git a/front/salix/components/app/style.scss b/front/salix/components/app/style.scss index aab37c8a3..96d6a6193 100644 --- a/front/salix/components/app/style.scss +++ b/front/salix/components/app/style.scss @@ -7,7 +7,7 @@ vn-app { ui-view { display: block; box-sizing: border-box; - height: inherit; + height: 100%; &.ng-enter { animation-name: nothing, slideIn; diff --git a/front/salix/components/layout/style.scss b/front/salix/components/layout/style.scss index 9a9d903a6..b66c620ad 100644 --- a/front/salix/components/layout/style.scss +++ b/front/salix/components/layout/style.scss @@ -87,6 +87,8 @@ vn-layout { & > * { display: block; padding: $spacing-md; + box-sizing: border-box; + height: 100% } &.ng-enter { vn-side-menu { diff --git a/front/salix/styles/photo-list.scss b/front/salix/styles/photo-list.scss index 3737c508a..b0c926def 100644 --- a/front/salix/styles/photo-list.scss +++ b/front/salix/styles/photo-list.scss @@ -11,7 +11,6 @@ transition: all 0.5s; padding: $spacing-sm; position: relative; - opacity: 0.7; width: 28em; .image { @@ -20,6 +19,7 @@ 0 1px 5px 0 rgba(0,0,0,.12); background: no-repeat center center fixed; background-size: cover !important; + border: 2px solid transparent; overflow: hidden; cursor: zoom-in; height: 100%; @@ -34,7 +34,7 @@ top: 1em } } - .photo:hover { - opacity: 1 + .photo:hover .image { + border: 2px solid $color-primary } } \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index dcb0aa6f1..4036bb993 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -101,6 +101,7 @@ async function backTestOnce() { gulp.src(backSpecFiles) .pipe(jasmine(options)) .on('end', resolve) + .on('error', reject) .resume(); }); @@ -110,27 +111,33 @@ backTestOnce.description = `Runs the backend tests once, can receive --junit arg async function backTestDockerOnce() { let containerId = await docker(); + let err; + try { await backTestOnce(); } catch (e) { - throw e; - } finally { - if (argv['random']) - await execP(`docker rm -fv ${containerId}`); + err = e; } + + if (argv['random']) + await execP(`docker rm -fv ${containerId}`); + if (err) throw err; } backTestDockerOnce.description = `Runs backend tests using in site container once`; async function backTestDocker() { let containerId = await docker(); + let err; + try { await backTest(); } catch (e) { - throw e; - } finally { - if (argv['random']) - await execP(`docker rm -fv ${containerId}`); + err = e; } + + if (argv['random']) + await execP(`docker rm -fv ${containerId}`); + if (err) throw err; } backTestDocker.description = `Runs backend tests restoring fixtures first`; @@ -240,14 +247,15 @@ function install() { const install = require('gulp-install'); const print = require('gulp-print'); + let npmArgs = []; + if (argv.ci) npmArgs = ['--no-audit', '--prefer-offline']; + let packageFiles = ['front/package.json', 'print/package.json']; return gulp.src(packageFiles) .pipe(print(filepath => { return `Installing packages in ${filepath}`; })) - .pipe(install({ - npm: ['--no-package-lock'] - })); + .pipe(install({npm: npmArgs})); } install.description = `Installs node dependencies in all directories`; @@ -429,15 +437,22 @@ async function docker() { let result = await execP(`docker run --env RUN_CHOWN=${runChown} -d ${dockerArgs} salix-db`); containerId = result.stdout; - if (argv['random']) { - let inspect = await execP(`docker inspect -f "{{json .NetworkSettings}}" ${containerId}`); - let netSettings = JSON.parse(inspect.stdout); + try { + if (argv['random']) { + let inspect = await execP(`docker inspect -f "{{json .NetworkSettings}}" ${containerId}`); + let netSettings = JSON.parse(inspect.stdout); - dbConf.host = netSettings.Gateway; - dbConf.port = netSettings.Ports['3306/tcp'][0]['HostPort']; + dbConf.host = netSettings.Gateway; + dbConf.port = netSettings.Ports['3306/tcp'][0]['HostPort']; + } + + if (runChown) await dockerWait(); + } catch (err) { + if (argv['random']) + await execP(`docker rm -fv ${containerId}`); + throw err; } - if (runChown) await dockerWait(); return containerId; } docker.description = `Builds the database image and runs a container`; diff --git a/loopback/server/datasources.json b/loopback/server/datasources.json index bbd8ce0d5..0ea634484 100644 --- a/loopback/server/datasources.json +++ b/loopback/server/datasources.json @@ -14,7 +14,7 @@ "multipleStatements": true, "legacyUtcDateProcessing": false, "timezone": "local", - "connectTimeout": 20000, + "connectTimeout": 40000, "acquireTimeout": 20000 }, "storage": { diff --git a/modules/agency/back/methods/zone/getEvents.js b/modules/agency/back/methods/zone/getEvents.js index 1c70dfffd..abf3d7e19 100644 --- a/modules/agency/back/methods/zone/getEvents.js +++ b/modules/agency/back/methods/zone/getEvents.js @@ -9,7 +9,7 @@ module.exports = Self => { description: 'The province id', required: true }, { - arg: 'search', + arg: 'postCode', type: 'String', description: 'The postcode' }, { diff --git a/modules/agency/front/delivery-days/index.js b/modules/agency/front/delivery-days/index.js index e9c885a13..0d7baeb60 100644 --- a/modules/agency/front/delivery-days/index.js +++ b/modules/agency/front/delivery-days/index.js @@ -8,8 +8,14 @@ class Controller extends Section { } onSubmit() { + this.$.data = null; this.$http.get(`Zones/getEvents`, {params: this.$.params}) - .then(res => this.$.data = res.data); + .then(res => { + let data = res.data; + this.$.data = data; + if (!data.events.length) + this.vnApp.showMessage(this.$t('No service for the specified zone')); + }); } } diff --git a/modules/agency/front/events/index.html b/modules/agency/front/events/index.html index 274d79997..693b24a85 100644 --- a/modules/agency/front/events/index.html +++ b/modules/agency/front/events/index.html @@ -160,12 +160,12 @@ response="cancel" translate-attr="{value: 'Cancel'}"> - - Delete - + translate-attr="{value: 'Delete'}"> + Add Save diff --git a/modules/claim/front/dms/index/index.html b/modules/claim/front/dms/index/index.html index bd6b9a21d..447538bd1 100644 --- a/modules/claim/front/dms/index/index.html +++ b/modules/claim/front/dms/index/index.html @@ -5,31 +5,28 @@ data="$ctrl.photos"> - - - Drag & Drop files here... - - - - - - - - - - + + + + Drag & Drop photos here... + + + - - + + + + + + + @@ -38,4 +35,10 @@ message="This file will be deleted" question="Are you sure you want to continue?" on-response="$ctrl.deleteDms($response)"> - \ No newline at end of file + + + diff --git a/modules/claim/front/dms/index/index.js b/modules/claim/front/dms/index/index.js index 20eba62a3..e83204000 100644 --- a/modules/claim/front/dms/index/index.js +++ b/modules/claim/front/dms/index/index.js @@ -68,6 +68,19 @@ class Controller { }); } + openUploadDialog() { + const element = document.createElement('input'); + element.setAttribute('type', 'file'); + element.setAttribute('multiple', true); + element.click(); + + element.addEventListener('change', () => + this.setDefaultParams().then(() => { + this.dms.files = element.files; + this.create(); + }) + ); + } create() { const query = `claims/${this.claim.id}/uploadFile`; diff --git a/modules/claim/front/dms/index/style.scss b/modules/claim/front/dms/index/style.scss index e7e957cd8..28f9db6fc 100644 --- a/modules/claim/front/dms/index/style.scss +++ b/modules/claim/front/dms/index/style.scss @@ -2,13 +2,16 @@ vn-claim-dms-index { .drop-zone { - border: 2px dashed $color-font-secondary; color: $color-font-secondary; box-sizing: border-box; - padding: 2em $spacing-md; border-radius: 0.5em; text-align: center; - font-size: 1.4em; + min-height: 100%; + + .empty-rows { + padding: 5em $spacing-md; + font-size: 1.4em + } vn-icon { font-size: 3em diff --git a/modules/claim/front/dms/locale/en.yml b/modules/claim/front/dms/locale/en.yml deleted file mode 100644 index a202e8bf2..000000000 --- a/modules/claim/front/dms/locale/en.yml +++ /dev/null @@ -1,2 +0,0 @@ -FileDescription: Ticket id {{ticketId}} from client {{clientName}} id {{clientId}} -ContentTypesInfo: Allowed file types {{allowedContentTypes}} \ No newline at end of file diff --git a/modules/claim/front/dms/locale/es.yml b/modules/claim/front/dms/locale/es.yml index 3e765ae78..8ccc1dba4 100644 --- a/modules/claim/front/dms/locale/es.yml +++ b/modules/claim/front/dms/locale/es.yml @@ -1,4 +1,5 @@ Are you sure you want to continue?: ¿Seguro que quieres continuar? -Drag & Drop files here...: Arrastra y suelta archivos aquí... +Drag & Drop photos here...: Arrastra y suelta fotos aquí... Photo deleted: Foto eliminada -Photo uploaded!: Foto subida! \ No newline at end of file +Photo uploaded!: Foto subida! +Select photo: Seleccionar foto \ No newline at end of file diff --git a/modules/claim/front/summary/style.scss b/modules/claim/front/summary/style.scss index 38136f24a..afd3838be 100644 --- a/modules/claim/front/summary/style.scss +++ b/modules/claim/front/summary/style.scss @@ -1,12 +1,10 @@ @import "./variables"; vn-claim-summary { - .photo { - height: 15.5em; + section.photo { + height: 15.5em } - .photo .image { - border: 2px solid $color-bg-dark; - border-radius: 0.2em; + .photo .image { + border-radius: 0.2em } - } \ No newline at end of file diff --git a/modules/invoiceOut/front/descriptor/index.js b/modules/invoiceOut/front/descriptor/index.js index 100f27c1f..a69f6ed8b 100644 --- a/modules/invoiceOut/front/descriptor/index.js +++ b/modules/invoiceOut/front/descriptor/index.js @@ -53,7 +53,7 @@ class Controller { } showInvoiceOutPdf() { - let url = `InvoiceOuts/${this.invoiceOut.id}/download?access_token=${this.accessToken}`; + let url = `api/InvoiceOuts/${this.invoiceOut.id}/download?access_token=${this.accessToken}`; window.open(url, '_blank'); } diff --git a/modules/invoiceOut/front/index/index.js b/modules/invoiceOut/front/index/index.js index c75b2bebe..dd8219fae 100644 --- a/modules/invoiceOut/front/index/index.js +++ b/modules/invoiceOut/front/index/index.js @@ -27,7 +27,7 @@ export default class Controller { } openPdf(id, event) { - let url = `InvoiceOuts/${id}/download?access_token=${this.accessToken}`; + let url = `api/InvoiceOuts/${id}/download?access_token=${this.accessToken}`; window.open(url, '_blank'); event.preventDefault(); event.stopImmediatePropagation(); diff --git a/modules/travel/front/summary/index.html b/modules/travel/front/summary/index.html index 0ce4517f2..51b73ac06 100644 --- a/modules/travel/front/summary/index.html +++ b/modules/travel/front/summary/index.html @@ -43,7 +43,7 @@ Entries - + Confirmed @@ -51,8 +51,8 @@ Supplier Reference HB - Freight cost - Package cost + Freight + Package CC Pallet m3 @@ -61,16 +61,18 @@ - - + + + + {{entry.id}} {{entry.supplierName}} {{entry.ref}} {{entry.hb}} - {{entry.freightValue}} - {{entry.packageValue}} + {{entry.freightValue | currency: 'EUR': 2}} + {{entry.packageValue | currency: 'EUR': 2}} {{entry.cc}} {{entry.pallet}} {{entry.m3}} @@ -81,13 +83,28 @@ icon="insert_drive_file"> + + + + + + + {{$ctrl.total('hb')}} + {{$ctrl.total('freightValue') | currency: 'EUR': 2}} + {{$ctrl.total('packageValue') | currency: 'EUR': 2}} + {{$ctrl.total('cc')}} + {{$ctrl.total('pallet')}} + {{$ctrl.total('m3')}} + + + diff --git a/modules/travel/front/summary/index.js b/modules/travel/front/summary/index.js index 20946ed3b..670adbd9d 100644 --- a/modules/travel/front/summary/index.js +++ b/modules/travel/front/summary/index.js @@ -5,6 +5,7 @@ class Controller { constructor($scope, $http) { this.$ = $scope; this.$http = $http; + this.entries = []; } get travel() { @@ -31,6 +32,15 @@ class Controller { this.entries = response.data; }); } + + total(field) { + let total = 0; + + for (let entry of this.entries) + total += entry[field]; + + return total; + } } Controller.$inject = ['$scope', '$http']; diff --git a/modules/travel/front/summary/index.spec.js b/modules/travel/front/summary/index.spec.js index dc6e4b23a..ec5beb053 100644 --- a/modules/travel/front/summary/index.spec.js +++ b/modules/travel/front/summary/index.spec.js @@ -58,4 +58,18 @@ describe('component vnTravelSummary', () => { expect(controller.entries).toEqual('I am the entries'); }); }); + + describe('total()', () => { + it('should calculate the total amount of a given property for every row', () => { + controller.entries = [ + {id: 1, freightValue: 1, packageValue: 2, cc: 0.01}, + {id: 2, freightValue: 1, packageValue: 2, cc: 0.01}, + {id: 3, freightValue: 1, packageValue: 2, cc: 0.01} + ]; + + expect(controller.total('freightValue')).toEqual(3); + expect(controller.total('packageValue')).toEqual(6); + expect(controller.total('cc')).toEqual(0.03); + }); + }); }); diff --git a/modules/travel/front/summary/locale/es.yml b/modules/travel/front/summary/locale/es.yml index 16f21fdde..c82508dfc 100644 --- a/modules/travel/front/summary/locale/es.yml +++ b/modules/travel/front/summary/locale/es.yml @@ -12,6 +12,6 @@ Confirmed: Confirmada Entry Id: Entrada Id Supplier: Proveedor Pallet: Pallet -Freight cost: Coste porte -Package cost: Coste embalaje +Freight: Porte +Package: Embalaje Half box: Media caja diff --git a/print/core/config.js b/print/core/config.js index 8db388401..864e1658a 100644 --- a/print/core/config.js +++ b/print/core/config.js @@ -4,8 +4,10 @@ let env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development'; let configPath = `/etc/salix`; let config = require('../config/print.json'); let configFiles = [ + `${appPath}/config/print.local.json`, `${appPath}/config/print.${env}.json`, `${configPath}/print.json`, + `${configPath}/print.local.json`, `${configPath}/print.${env}.json` ]; diff --git a/print/templates/email/buyer-week-waste/assets/css/import.js b/print/templates/email/buyer-week-waste/assets/css/import.js new file mode 100644 index 000000000..b44d6bd37 --- /dev/null +++ b/print/templates/email/buyer-week-waste/assets/css/import.js @@ -0,0 +1,8 @@ +const Stylesheet = require(`${appPath}/core/stylesheet`); + +module.exports = new Stylesheet([ + `${appPath}/common/css/spacing.css`, + `${appPath}/common/css/misc.css`, + `${appPath}/common/css/layout.css`, + `${appPath}/common/css/email.css`]) + .mergeStyles(); diff --git a/print/templates/email/buyer-week-waste/buyer-week-waste.html b/print/templates/email/buyer-week-waste/buyer-week-waste.html new file mode 100644 index 000000000..47d162a6f --- /dev/null +++ b/print/templates/email/buyer-week-waste/buyer-week-waste.html @@ -0,0 +1,69 @@ + + + + + + {{ $t('subject') }} + + + + + + + + + + + + + + + + + + + + {{ $t('title') }} + {{$t('dear')}}, + + + + + + + + + + {{$t('buyer')}} + {{$t('percentage')}} + {{$t('dwindle')}} + {{$t('total')}} + + + + + {{waste.buyer}} + {{(waste.percentage / 100) | percentage(4, 4, locale)}} + {{waste.dwindle | currency('EUR', locale)}} + {{waste.total | currency('EUR', locale)}} + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/print/templates/email/buyer-week-waste/buyer-week-waste.js b/print/templates/email/buyer-week-waste/buyer-week-waste.js new file mode 100755 index 000000000..4639e7d5b --- /dev/null +++ b/print/templates/email/buyer-week-waste/buyer-week-waste.js @@ -0,0 +1,31 @@ +const Component = require(`${appPath}/core/component`); +const db = require(`${appPath}/core/database`); +const emailHeader = new Component('email-header'); +const emailFooter = new Component('email-footer'); + +module.exports = { + name: 'buyer-week-waste', + async serverPrefetch() { + this.wastes = await this.fetchWastes(); + + if (!this.wastes) + throw new Error('Something went wrong'); + }, + computed: { + dated: function() { + const filters = this.$options.filters; + + return filters.date(new Date(), '%d-%m-%Y'); + } + }, + methods: { + fetchWastes() { + return db.findOne(`CALL bs.weekWaste()`); + } + }, + components: { + 'email-header': emailHeader.build(), + 'email-footer': emailFooter.build() + }, + props: {} +}; diff --git a/print/templates/email/buyer-week-waste/locale/es.yml b/print/templates/email/buyer-week-waste/locale/es.yml new file mode 100644 index 000000000..96e49d9eb --- /dev/null +++ b/print/templates/email/buyer-week-waste/locale/es.yml @@ -0,0 +1,8 @@ +subject: Merma semanal +title: Merma semanal +dear: Hola +description: A continuación se muestra la merma semanal a fecha de {0}. +buyer: Comprador +percentage: Porcentaje +weakening: Mermas +total: Total \ No newline at end of file diff --git a/print/templates/reports/claim-pickup-order/locale/es.yml b/print/templates/reports/claim-pickup-order/locale/es.yml index 534fd2da8..b37793b70 100644 --- a/print/templates/reports/claim-pickup-order/locale/es.yml +++ b/print/templates/reports/claim-pickup-order/locale/es.yml @@ -12,4 +12,4 @@ claim: Reclamación {0} sections: agency: description: 'Para agilizar tu recogida, por favor, pónte en contacto con la oficina - de integrados. Tlf: 96 166 77 88 - Ana Gómez (Ext. 2133) (agomezf@integra2.es)' + de integrados. Tlf: 96 166 77 88 - Ana Gómez (Ext. 2113) (agomezf@integra2.es)'
{{$t('dear')}},