diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e9fd069 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/node_modules +/dist +/tmp +package-lock\.json +src/etc/develop.js diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..d8cbb07 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,64 @@ +{ + /* + * ENVIRONMENTS + * ================= + */ + + // Define globals exposed by modern browsers. + "browser": true, + + // Define globals exposed by jQuery. + "jquery": true, + + // Define globals exposed by Node.js. + "node": true, + + // Allow ES6. + "esversion": 6, + + /* + * ENFORCING OPTIONS + * ================= + */ + + // Force all variable names to use either camelCase style or UPPER_CASE + // with underscores. + "camelcase": true, + + // Prohibit use of == and != in favor of === and !==. + "eqeqeq": true, + + // Enforce tab width of 2 spaces. + "indent": 4, + + // Prohibit use of a variable before it is defined. + "latedef": false, + + // Enforce line length to 100 characters + "maxlen": 100, + + // Require capitalized names for constructor functions. + "newcap": true, + + // Enforce use of single quotation marks for strings. + "quotmark": "single", + + // Enforce placing 'use strict' at the top function scope + "strict": false, + + // Prohibit use of explicitly undeclared variables. + "undef": true, + + // Warn when variables are defined but never used. + "unused": true, + + // Para que funcione en angular + "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"], + /* + * RELAXING OPTIONS + * ================= + */ + + // Suppress warnings about == null comparisons. + "eqnull": true +} diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..3e9d149 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,89 @@ +const templateCache = require('gulp-angular-templatecache'); +const concat = require('gulp-concat'); +const htmlmin = require('gulp-htmlmin'); +const rename = require('gulp-rename'); +const uglify = require('gulp-uglify-es').default; +const gulp = require('gulp'); +const pump = require('pump'); +const jshint = require('gulp-jshint'); +const replace = require('gulp-replace'); +const connect = require('gulp-connect'); +const clean = require('gulp-clean'); + +var paths = { + srcJS: 'src/js/*.js', + srcViews: 'src/views/*.html', + tmp: 'tmp', + dist: 'dist/' +}; + +gulp.task('templates', function() { + return pump( + [ + gulp.src(paths.srcViews), + replace('views/', ''), + htmlmin(), + templateCache('views.js', { + module: 'focaEstadoCisterna', + root: '' + }), + gulp.dest(paths.tmp) + ] + ); +}); + +gulp.task('uglify', ['templates'], function() { + return pump( + [ + gulp.src([ + paths.srcJS, + 'tmp/views.js' + ]), + concat('foca-estado-cisterna.js'), + replace("['ngRoute', 'focaModal', 'ui.bootstrap', 'focaBotoneraLateral']", '[]'), + replace("src/views/", ''), + gulp.dest(paths.tmp), + rename('foca-estado-cisterna.min.js'), + uglify(), + gulp.dest(paths.dist) + ] + ); +}); + +gulp.task('clean', function() { + return gulp.src(['tmp', 'dist'], {read: false}) + .pipe(clean()); +}); + +gulp.task('pre-commit', function() { + pump( + [ + gulp.src(paths.srcJS), + jshint('.jshintrc'), + jshint.reporter('default'), + jshint.reporter('fail') + ] + ); + + gulp.start('uglify'); +}); + +gulp.task('clean-post-install', function() { + return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', + 'index.html'], {read: false}) + .pipe(clean()); +}); + +gulp.task('compile', ['templates', 'uglify']); + +gulp.task('watch', function() { + gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); +}); + +gulp.task('webserver', function() { + pump [ + connect.server({port: 3000}) + ] +}); + +gulp.task('default', ['webserver']); diff --git a/index.html b/index.html new file mode 100644 index 0000000..3b24860 --- /dev/null +++ b/index.html @@ -0,0 +1,31 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..0a81266 --- /dev/null +++ b/package.json @@ -0,0 +1,60 @@ +{ + "name": "foca-estado-cisternas", + "version": "0.0.1", + "description": "Abm de vehiculo", + "main": "index.html", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "compile": "gulp uglify", + "gulp-pre-commit": "gulp pre-commit", + "postinstall": "npm run compile && gulp clean-post-install", + "install-dev": "npm i --ignore-scripts" + }, + "pre-commit": [ + "gulp-pre-commit" + ], + "repository": { + "type": "git", + "url": "http://git.focasoftware.com/npm/foca-estado-cisternas.git" + }, + "author": "Foca Software", + "license": "ISC", + "peerDependencies": { + "angular": "^1.7.x", + "angular-route": "^1.7.x", + "bootstrap": "^4.1.x", + "jquery": "^3.3.x", + "font-awesome": "^4.7.x", + "gulp": "^3.9.x", + "gulp-concat": "2.6.x", + "gulp-jshint": "^2.1.x", + "gulp-rename": "^1.4.x", + "gulp-replace": "^1.0.x", + "gulp-uglify-es": "^1.0.x", + "jshint": "^2.9.x", + "pump": "^3.0.x" + }, + "devDependencies": { + "angular": "^1.7.5", + "angular-route": "^1.7.5", + "bootstrap": "^4.1.3", + "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", + "font-awesome": "^4.7.0", + "gulp": "^3.9.1", + "gulp-angular-templatecache": "^2.2.5", + "gulp-clean": "^0.4.0", + "gulp-connect": "^5.6.1", + "gulp-htmlmin": "^5.0.1", + "gulp-jshint": "^2.1.0", + "gulp-rename": "^1.4.0", + "gulp-replace": "^1.0.0", + "gulp-uglify": "^3.0.1", + "gulp-uglify-es": "^1.0.4", + "jasmine-core": "^3.3.0", + "jquery": "^3.3.1", + "jshint": "^2.9.6", + "pre-commit": "^1.2.2", + "pump": "^3.0.0", + "ui-bootstrap4": "^3.0.5" + } +} diff --git a/src/etc/develop.js.ejemplo b/src/etc/develop.js.ejemplo new file mode 100644 index 0000000..1df08ba --- /dev/null +++ b/src/etc/develop.js.ejemplo @@ -0,0 +1,4 @@ +angular.module('focaEstadoCisterna') + .constant("API_ENDPOINT", { + 'URL': '//127.0.0.1:9000' + }); diff --git a/src/js/app.js b/src/js/app.js new file mode 100644 index 0000000..f160cf2 --- /dev/null +++ b/src/js/app.js @@ -0,0 +1 @@ +angular.module('focaEstadoCisterna', ['ngRoute', 'focaModal', 'ui.bootstrap', 'focaBotoneraLateral']); diff --git a/src/js/controller.js b/src/js/controller.js new file mode 100644 index 0000000..f029b0a --- /dev/null +++ b/src/js/controller.js @@ -0,0 +1,117 @@ +angular.module('focaEstadoCisterna') + .controller('focaEstadoCisternaController', [ + '$scope', 'focaEstadoCisternaService', '$location', 'focaModalService', + '$uibModal', 'focaBotoneraLateralService', '$timeout', + function($scope, focaEstadoCisternaService, $location, focaModalService, + $uibModal, focaBotoneraLateralService, $timeout) { + + $scope.now = new Date(); + $scope.fecha = new Date(); + $scope.cisternas = []; + $scope.botonera = [{ + label: 'Transportista', + image: 'transportista.png' + }, + { + label: 'Vehiculo', + image: 'vehiculos.png' + }, + { + label: 'Fecha', + image: 'fechaDeReparto.png' + }]; + + //SETEO BOTONERA LATERAL + focaBotoneraLateralService.showSalir(true); + focaBotoneraLateralService.showPausar(false); + focaBotoneraLateralService.showCancelar(false); + focaBotoneraLateralService.showGuardar(false); + + $timeout(function() { + $scope.$broadcast('addCabecera',{ + label: 'Fecha:', + valor: $scope.fecha.toLocaleDateString() + }); + }); + + $scope.seleccionarTransportista = function() { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Transportista', + templateUrl: 'modal-proveedor.html', + controller: 'focaModalProveedorCtrl', + size: 'lg', + resolve: { + transportista: function() { + return true; + } + } + } + ); + modalInstance.result.then( + function(transportista) { + elegirTransportista(transportista); + }, function() { + + } + ); + }; + + $scope.seleccionarVehiculo = function() { + if(!$scope.idTransportista){ + focaModalService.alert('Primero seleccione un transportista'); + return; + } + var query = '/vehiculo/transportista/' + $scope.idTransportista; + var columnas = { + nombre: ['Código', 'tractor', 'Semi', 'Capacidad'], + propiedad: ['codigo', 'tractor', 'semi', 'capacidadTotalCisternas'] + }; + var titulo = 'Búsqueda de vehículos'; + + focaModalService.modal(columnas, query, titulo).then( + function(vehiculo) { + $scope.$broadcast('addCabecera', { + label: 'Vehículo:', + valor: vehiculo.codigo + }); + $scope.cisternas = vehiculo.cisternas; + getEstadosCisternas($scope.cisternas); + }, function() { + // funcion ejecutada cuando se cancela el modal + }); + }; + + $scope.seleccionarFecha = function() { + focaModalService.modalFecha('Fecha').then(function(fecha) { + $scope.$broadcast('addCabecera',{ + label: 'Fecha:', + valor: fecha.toLocaleDateString() + }); + $scope.fecha = fecha; + if($scope.cisternas) + getEstadosCisternas($scope.cisternas); + }); + }; + + function elegirTransportista(transportista) { + var codigo = ('00000' + transportista.COD).slice(-5); + $scope.idTransportista = transportista.COD; + $scope.filtros = transportista.NOM.trim(); + $scope.$broadcast('addCabecera', { + label: 'Transportista:', + valor: codigo + ' - ' + transportista.NOM + }); + } + + function getEstadosCisternas(cisternas) { + cisternas.forEach(function(cisterna) { + focaEstadoCisternaService + .getEstadoCisterna(cisterna.id, $scope.fecha) + .then(function(res) { + cisterna.estado = res.data; + }); + }); + } + } + ]); diff --git a/src/js/route.js b/src/js/route.js new file mode 100644 index 0000000..5bb0a5a --- /dev/null +++ b/src/js/route.js @@ -0,0 +1,10 @@ +angular.module('focaEstadoCisterna') + .config([ + '$routeProvider', + function($routeProvider) { + $routeProvider.when('/estado-cisterna', { + controller: 'focaEstadoCisternaController', + templateUrl: 'src/views/foca-estado-cisterna.html' + }); + } + ]); diff --git a/src/js/service.js b/src/js/service.js new file mode 100644 index 0000000..1d59bdb --- /dev/null +++ b/src/js/service.js @@ -0,0 +1,30 @@ +angular.module('focaEstadoCisterna') + .factory('focaEstadoCisternaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { + return { + getVehiculos: function() { + return $http.get(API_ENDPOINT.URL + '/vehiculo'); + }, + getTransportistas: function() { + return $http.get(API_ENDPOINT.URL + '/transportista'); + }, + getCisternadoPorVehiculo: function(idVehiculo) { + return $http.get(API_ENDPOINT.URL + '/cisterna/listar/' + idVehiculo); + }, + getCisterna: function(id) { + return $http.get(API_ENDPOINT.URL + '/cisterna/obtener/' + id); + }, + guardarCisterna: function(cisterna) { + return $http.post(API_ENDPOINT.URL + '/cisterna/guardar', {cisterna: cisterna}); + }, + deleteCisterna: function(id) { + return $http.delete(API_ENDPOINT.URL + '/cisterna/borrar/' + id); + }, + getVehiculosPorTransportista: function(id) { + return $http.get(API_ENDPOINT.URL + '/vehiculo/transportista/' + id); + }, + getEstadoCisterna: function(id, fecha) { + return $http.post(API_ENDPOINT.URL + '/cisterna/stock', + {idCisterna: id, fecha: fecha}); + } + }; + }]); diff --git a/src/views/foca-estado-cisterna.html b/src/views/foca-estado-cisterna.html new file mode 100644 index 0000000..08eed7b --- /dev/null +++ b/src/views/foca-estado-cisterna.html @@ -0,0 +1,35 @@ +Código | +Capacidad total | +Carga | +Producto | +
---|---|---|---|
+ | + | + | + |