Commit 48e24f5177bfcabef9197ddbb88aa6df3b0ac17e
1 parent
392ba91860
Exists in
master
Primera version
Showing
11 changed files
with
446 additions
and
0 deletions
Show diff stats
.gitignore
File was created | 1 | /node_modules | |
2 | /dist | ||
3 | /tmp | ||
4 | package-lock\.json | ||
5 | src/etc/develop.js | ||
6 |
.jshintrc
File was created | 1 | { | |
2 | /* | ||
3 | * ENVIRONMENTS | ||
4 | * ================= | ||
5 | */ | ||
6 | |||
7 | // Define globals exposed by modern browsers. | ||
8 | "browser": true, | ||
9 | |||
10 | // Define globals exposed by jQuery. | ||
11 | "jquery": true, | ||
12 | |||
13 | // Define globals exposed by Node.js. | ||
14 | "node": true, | ||
15 | |||
16 | // Allow ES6. | ||
17 | "esversion": 6, | ||
18 | |||
19 | /* | ||
20 | * ENFORCING OPTIONS | ||
21 | * ================= | ||
22 | */ | ||
23 | |||
24 | // Force all variable names to use either camelCase style or UPPER_CASE | ||
25 | // with underscores. | ||
26 | "camelcase": true, | ||
27 | |||
28 | // Prohibit use of == and != in favor of === and !==. | ||
29 | "eqeqeq": true, | ||
30 | |||
31 | // Enforce tab width of 2 spaces. | ||
32 | "indent": 4, | ||
33 | |||
34 | // Prohibit use of a variable before it is defined. | ||
35 | "latedef": false, | ||
36 | |||
37 | // Enforce line length to 100 characters | ||
38 | "maxlen": 100, | ||
39 | |||
40 | // Require capitalized names for constructor functions. | ||
41 | "newcap": true, | ||
42 | |||
43 | // Enforce use of single quotation marks for strings. | ||
44 | "quotmark": "single", | ||
45 | |||
46 | // Enforce placing 'use strict' at the top function scope | ||
47 | "strict": false, | ||
48 | |||
49 | // Prohibit use of explicitly undeclared variables. | ||
50 | "undef": true, | ||
51 | |||
52 | // Warn when variables are defined but never used. | ||
53 | "unused": true, | ||
54 | |||
55 | // Para que funcione en angular | ||
56 | "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"], | ||
57 | /* | ||
58 | * RELAXING OPTIONS | ||
59 | * ================= | ||
60 | */ | ||
61 | |||
62 | // Suppress warnings about == null comparisons. | ||
63 | "eqnull": true | ||
64 | } | ||
65 |
gulpfile.js
File was created | 1 | const templateCache = require('gulp-angular-templatecache'); | |
2 | const concat = require('gulp-concat'); | ||
3 | const htmlmin = require('gulp-htmlmin'); | ||
4 | const rename = require('gulp-rename'); | ||
5 | const uglify = require('gulp-uglify-es').default; | ||
6 | const gulp = require('gulp'); | ||
7 | const pump = require('pump'); | ||
8 | const jshint = require('gulp-jshint'); | ||
9 | const replace = require('gulp-replace'); | ||
10 | const connect = require('gulp-connect'); | ||
11 | const clean = require('gulp-clean'); | ||
12 | |||
13 | var paths = { | ||
14 | srcJS: 'src/js/*.js', | ||
15 | srcViews: 'src/views/*.html', | ||
16 | tmp: 'tmp', | ||
17 | dist: 'dist/' | ||
18 | }; | ||
19 | |||
20 | gulp.task('templates', function() { | ||
21 | return pump( | ||
22 | [ | ||
23 | gulp.src(paths.srcViews), | ||
24 | replace('views/', ''), | ||
25 | htmlmin(), | ||
26 | templateCache('views.js', { | ||
27 | module: 'focaEstadoCisterna', | ||
28 | root: '' | ||
29 | }), | ||
30 | gulp.dest(paths.tmp) | ||
31 | ] | ||
32 | ); | ||
33 | }); | ||
34 | |||
35 | gulp.task('uglify', ['templates'], function() { | ||
36 | return pump( | ||
37 | [ | ||
38 | gulp.src([ | ||
39 | paths.srcJS, | ||
40 | 'tmp/views.js' | ||
41 | ]), | ||
42 | concat('foca-estado-cisterna.js'), | ||
43 | replace("['ngRoute', 'focaModal', 'ui.bootstrap', 'focaBotoneraLateral']", '[]'), | ||
44 | replace("src/views/", ''), | ||
45 | gulp.dest(paths.tmp), | ||
46 | rename('foca-estado-cisterna.min.js'), | ||
47 | uglify(), | ||
48 | gulp.dest(paths.dist) | ||
49 | ] | ||
50 | ); | ||
51 | }); | ||
52 | |||
53 | gulp.task('clean', function() { | ||
54 | return gulp.src(['tmp', 'dist'], {read: false}) | ||
55 | .pipe(clean()); | ||
56 | }); | ||
57 | |||
58 | gulp.task('pre-commit', function() { | ||
59 | pump( | ||
60 | [ | ||
61 | gulp.src(paths.srcJS), | ||
62 | jshint('.jshintrc'), | ||
63 | jshint.reporter('default'), | ||
64 | jshint.reporter('fail') | ||
65 | ] | ||
66 | ); | ||
67 | |||
68 | gulp.start('uglify'); | ||
69 | }); | ||
70 | |||
71 | gulp.task('clean-post-install', function() { | ||
72 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | ||
73 | 'index.html'], {read: false}) | ||
74 | .pipe(clean()); | ||
75 | }); | ||
76 | |||
77 | gulp.task('compile', ['templates', 'uglify']); | ||
78 | |||
79 | gulp.task('watch', function() { | ||
80 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | ||
81 | }); | ||
82 | |||
83 | gulp.task('webserver', function() { | ||
84 | pump [ | ||
85 | connect.server({port: 3000}) | ||
86 | ] | ||
87 | }); | ||
88 | |||
89 | gulp.task('default', ['webserver']); | ||
90 |
index.html
File was created | 1 | <html ng-app="focaEstadoCisterna"> | |
2 | <head> | ||
3 | <meta charset="UTF-8"/> | ||
4 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
5 | |||
6 | <!--CSS--> | ||
7 | <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/> | ||
8 | <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet"/> | ||
9 | |||
10 | <!--VENDOR JS--> | ||
11 | <script src="node_modules/jquery/dist/jquery.min.js"></script> | ||
12 | <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> | ||
13 | <script src="node_modules/angular/angular.min.js"></script> | ||
14 | <script src="node_modules/angular-route/angular-route.min.js"></script> | ||
15 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> | ||
16 | <script src="node_modules/foca-modal/dist/foca-modal.min.js"></script> | ||
17 | |||
18 | <!-- BUILD --> | ||
19 | <script src="src/js/app.js"></script> | ||
20 | <script src="src/js/route.js"></script> | ||
21 | <script src="src/js/controller.js"></script> | ||
22 | <script src="src/js/service.js"></script> | ||
23 | <!-- /BUILD --> | ||
24 | |||
25 | <!-- CONFIG PARA DEVELOP --> | ||
26 | <script src="src/etc/develop.js"></script> | ||
27 | </head> | ||
28 | <body style="background: #afafaf;padding: 25px"> | ||
29 | <div class="container-fluid pt-3 pb-3" ng-view style="background: #fff"></div> | ||
30 | </body> | ||
31 | </html> | ||
32 |
package.json
File was created | 1 | { | |
2 | "name": "foca-estado-cisternas", | ||
3 | "version": "0.0.1", | ||
4 | "description": "Abm de vehiculo", | ||
5 | "main": "index.html", | ||
6 | "scripts": { | ||
7 | "test": "echo \"Error: no test specified\" && exit 1", | ||
8 | "compile": "gulp uglify", | ||
9 | "gulp-pre-commit": "gulp pre-commit", | ||
10 | "postinstall": "npm run compile && gulp clean-post-install", | ||
11 | "install-dev": "npm i --ignore-scripts" | ||
12 | }, | ||
13 | "pre-commit": [ | ||
14 | "gulp-pre-commit" | ||
15 | ], | ||
16 | "repository": { | ||
17 | "type": "git", | ||
18 | "url": "http://git.focasoftware.com/npm/foca-estado-cisternas.git" | ||
19 | }, | ||
20 | "author": "Foca Software", | ||
21 | "license": "ISC", | ||
22 | "peerDependencies": { | ||
23 | "angular": "^1.7.x", | ||
24 | "angular-route": "^1.7.x", | ||
25 | "bootstrap": "^4.1.x", | ||
26 | "jquery": "^3.3.x", | ||
27 | "font-awesome": "^4.7.x", | ||
28 | "gulp": "^3.9.x", | ||
29 | "gulp-concat": "2.6.x", | ||
30 | "gulp-jshint": "^2.1.x", | ||
31 | "gulp-rename": "^1.4.x", | ||
32 | "gulp-replace": "^1.0.x", | ||
33 | "gulp-uglify-es": "^1.0.x", | ||
34 | "jshint": "^2.9.x", | ||
35 | "pump": "^3.0.x" | ||
36 | }, | ||
37 | "devDependencies": { | ||
38 | "angular": "^1.7.5", | ||
39 | "angular-route": "^1.7.5", | ||
40 | "bootstrap": "^4.1.3", | ||
41 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", | ||
42 | "font-awesome": "^4.7.0", | ||
43 | "gulp": "^3.9.1", | ||
44 | "gulp-angular-templatecache": "^2.2.5", | ||
45 | "gulp-clean": "^0.4.0", | ||
46 | "gulp-connect": "^5.6.1", | ||
47 | "gulp-htmlmin": "^5.0.1", | ||
48 | "gulp-jshint": "^2.1.0", | ||
49 | "gulp-rename": "^1.4.0", | ||
50 | "gulp-replace": "^1.0.0", | ||
51 | "gulp-uglify": "^3.0.1", | ||
52 | "gulp-uglify-es": "^1.0.4", | ||
53 | "jasmine-core": "^3.3.0", | ||
54 | "jquery": "^3.3.1", | ||
55 | "jshint": "^2.9.6", | ||
56 | "pre-commit": "^1.2.2", | ||
57 | "pump": "^3.0.0", | ||
58 | "ui-bootstrap4": "^3.0.5" | ||
59 | } | ||
60 | } | ||
61 |
src/etc/develop.js.ejemplo
File was created | 1 | angular.module('focaEstadoCisterna') | |
2 | .constant("API_ENDPOINT", { | ||
3 | 'URL': '//127.0.0.1:9000' | ||
4 | }); | ||
5 |
src/js/app.js
File was created | 1 | angular.module('focaEstadoCisterna', ['ngRoute', 'focaModal', 'ui.bootstrap', 'focaBotoneraLateral']); | |
2 |
src/js/controller.js
File was created | 1 | angular.module('focaEstadoCisterna') | |
2 | .controller('focaEstadoCisternaController', [ | ||
3 | '$scope', 'focaEstadoCisternaService', '$location', 'focaModalService', | ||
4 | '$uibModal', 'focaBotoneraLateralService', '$timeout', | ||
5 | function($scope, focaEstadoCisternaService, $location, focaModalService, | ||
6 | $uibModal, focaBotoneraLateralService, $timeout) { | ||
7 | |||
8 | $scope.now = new Date(); | ||
9 | $scope.fecha = new Date(); | ||
10 | $scope.cisternas = []; | ||
11 | $scope.botonera = [{ | ||
12 | label: 'Transportista', | ||
13 | image: 'transportista.png' | ||
14 | }, | ||
15 | { | ||
16 | label: 'Vehiculo', | ||
17 | image: 'vehiculos.png' | ||
18 | }, | ||
19 | { | ||
20 | label: 'Fecha', | ||
21 | image: 'fechaDeReparto.png' | ||
22 | }]; | ||
23 | |||
24 | //SETEO BOTONERA LATERAL | ||
25 | focaBotoneraLateralService.showSalir(true); | ||
26 | focaBotoneraLateralService.showPausar(false); | ||
27 | focaBotoneraLateralService.showCancelar(false); | ||
28 | focaBotoneraLateralService.showGuardar(false); | ||
29 | |||
30 | $timeout(function() { | ||
31 | $scope.$broadcast('addCabecera',{ | ||
32 | label: 'Fecha:', | ||
33 | valor: $scope.fecha.toLocaleDateString() | ||
34 | }); | ||
35 | }); | ||
36 | |||
37 | $scope.seleccionarTransportista = function() { | ||
38 | var modalInstance = $uibModal.open( | ||
39 | { | ||
40 | ariaLabelledBy: 'Busqueda de Transportista', | ||
41 | templateUrl: 'modal-proveedor.html', | ||
42 | controller: 'focaModalProveedorCtrl', | ||
43 | size: 'lg', | ||
44 | resolve: { | ||
45 | transportista: function() { | ||
46 | return true; | ||
47 | } | ||
48 | } | ||
49 | } | ||
50 | ); | ||
51 | modalInstance.result.then( | ||
52 | function(transportista) { | ||
53 | elegirTransportista(transportista); | ||
54 | }, function() { | ||
55 | |||
56 | } | ||
57 | ); | ||
58 | }; | ||
59 | |||
60 | $scope.seleccionarVehiculo = function() { | ||
61 | if(!$scope.idTransportista){ | ||
62 | focaModalService.alert('Primero seleccione un transportista'); | ||
63 | return; | ||
64 | } | ||
65 | var query = '/vehiculo/transportista/' + $scope.idTransportista; | ||
66 | var columnas = { | ||
67 | nombre: ['Código', 'tractor', 'Semi', 'Capacidad'], | ||
68 | propiedad: ['codigo', 'tractor', 'semi', 'capacidadTotalCisternas'] | ||
69 | }; | ||
70 | var titulo = 'Búsqueda de vehículos'; | ||
71 | |||
72 | focaModalService.modal(columnas, query, titulo).then( | ||
73 | function(vehiculo) { | ||
74 | $scope.$broadcast('addCabecera', { | ||
75 | label: 'Vehículo:', | ||
76 | valor: vehiculo.codigo | ||
77 | }); | ||
78 | $scope.cisternas = vehiculo.cisternas; | ||
79 | getEstadosCisternas($scope.cisternas); | ||
80 | }, function() { | ||
81 | // funcion ejecutada cuando se cancela el modal | ||
82 | }); | ||
83 | }; | ||
84 | |||
85 | $scope.seleccionarFecha = function() { | ||
86 | focaModalService.modalFecha('Fecha').then(function(fecha) { | ||
87 | $scope.$broadcast('addCabecera',{ | ||
88 | label: 'Fecha:', | ||
89 | valor: fecha.toLocaleDateString() | ||
90 | }); | ||
91 | $scope.fecha = fecha; | ||
92 | if($scope.cisternas) | ||
93 | getEstadosCisternas($scope.cisternas); | ||
94 | }); | ||
95 | }; | ||
96 | |||
97 | function elegirTransportista(transportista) { | ||
98 | var codigo = ('00000' + transportista.COD).slice(-5); | ||
99 | $scope.idTransportista = transportista.COD; | ||
100 | $scope.filtros = transportista.NOM.trim(); | ||
101 | $scope.$broadcast('addCabecera', { | ||
102 | label: 'Transportista:', | ||
103 | valor: codigo + ' - ' + transportista.NOM | ||
104 | }); | ||
105 | } | ||
106 | |||
107 | function getEstadosCisternas(cisternas) { | ||
108 | cisternas.forEach(function(cisterna) { | ||
109 | focaEstadoCisternaService | ||
110 | .getEstadoCisterna(cisterna.id, $scope.fecha) | ||
111 | .then(function(res) { | ||
112 | cisterna.estado = res.data; | ||
113 | }); | ||
114 | }); | ||
115 | } | ||
116 | } | ||
117 | ]); | ||
118 |
src/js/route.js
File was created | 1 | angular.module('focaEstadoCisterna') | |
2 | .config([ | ||
3 | '$routeProvider', | ||
4 | function($routeProvider) { | ||
5 | $routeProvider.when('/estado-cisterna', { | ||
6 | controller: 'focaEstadoCisternaController', | ||
7 | templateUrl: 'src/views/foca-estado-cisterna.html' | ||
8 | }); | ||
9 | } | ||
10 | ]); | ||
11 |
src/js/service.js
File was created | 1 | angular.module('focaEstadoCisterna') | |
2 | .factory('focaEstadoCisternaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | ||
3 | return { | ||
4 | getVehiculos: function() { | ||
5 | return $http.get(API_ENDPOINT.URL + '/vehiculo'); | ||
6 | }, | ||
7 | getTransportistas: function() { | ||
8 | return $http.get(API_ENDPOINT.URL + '/transportista'); | ||
9 | }, | ||
10 | getCisternadoPorVehiculo: function(idVehiculo) { | ||
11 | return $http.get(API_ENDPOINT.URL + '/cisterna/listar/' + idVehiculo); | ||
12 | }, | ||
13 | getCisterna: function(id) { | ||
14 | return $http.get(API_ENDPOINT.URL + '/cisterna/obtener/' + id); | ||
15 | }, | ||
16 | guardarCisterna: function(cisterna) { | ||
17 | return $http.post(API_ENDPOINT.URL + '/cisterna/guardar', {cisterna: cisterna}); | ||
18 | }, | ||
19 | deleteCisterna: function(id) { | ||
20 | return $http.delete(API_ENDPOINT.URL + '/cisterna/borrar/' + id); | ||
21 | }, | ||
22 | getVehiculosPorTransportista: function(id) { | ||
23 | return $http.get(API_ENDPOINT.URL + '/vehiculo/transportista/' + id); | ||
24 | }, | ||
25 | getEstadoCisterna: function(id, fecha) { | ||
26 | return $http.post(API_ENDPOINT.URL + '/cisterna/stock', | ||
27 | {idCisterna: id, fecha: fecha}); | ||
28 | } | ||
29 | }; | ||
30 | }]); | ||
31 |
src/views/foca-estado-cisterna.html
File was created | 1 | <div class="row"> | |
2 | <foca-cabecera-facturador | ||
3 | titulo="'Estado de cisternas'" | ||
4 | fecha="now" | ||
5 | class="mb-0 col-lg-12" | ||
6 | ></foca-cabecera-facturador> | ||
7 | </div> | ||
8 | <div class="row"> | ||
9 | <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded"> | ||
10 | <div class="row px-5 py-2 botonera-secundaria"> | ||
11 | <div class="col-12"> | ||
12 | <foca-botonera-facturador botones="botonera" extra="3" class="row"> | ||
13 | </foca-botonera-facturador> | ||
14 | </div> | ||
15 | </div> | ||
16 | <table class="table table-default table-hover table-sm table-abm table-striped mb-0"> | ||
17 | <thead> | ||
18 | <tr> | ||
19 | <th>Código</th> | ||
20 | <th>Capacidad total</th> | ||
21 | <th>Carga</th> | ||
22 | <th>Producto</th> | ||
23 | </tr> | ||
24 | </thead> | ||
25 | <tbody> | ||
26 | <tr ng-repeat="cisterna in cisternas"> | ||
27 | <td ng-bind="cisterna.codigo"></td> | ||
28 | <td ng-bind="cisterna.capacidad + ' ' + cisterna.unidadMedida.NOM"></td> | ||
29 | <td ng-bind="cisterna.estado.cantidad"></td> | ||
30 | <td ng-bind="(cisterna.estado.producto) ? cisterna.estado.producto.DetArt : '-'"></td> | ||
31 | </tr> | ||
32 | </body> | ||
33 | </table> | ||
34 | </div> | ||
35 | </div> | ||
36 |