From ca13fa1e85a5f0083d9ee9eec78200c1c7960104 Mon Sep 17 00:00:00 2001 From: Jose Pinto Date: Wed, 12 Dec 2018 16:40:08 -0300 Subject: [PATCH] primera version --- .gitignore | 5 ++ .jshintrc | 64 +++++++++++++++++++++++ gulpfile.js | 89 ++++++++++++++++++++++++++++++++ index.html | 31 +++++++++++ package.json | 60 +++++++++++++++++++++ src/etc/develop.js.ejemplo | 4 ++ src/js/app.js | 1 + src/js/controller.js | 62 ++++++++++++++++++++++ src/js/route.js | 19 +++++++ src/js/service.js | 20 +++++++ src/views/foca-abm-choferes-item.html | 59 +++++++++++++++++++++ src/views/foca-abm-choferes-listado.html | 56 ++++++++++++++++++++ 12 files changed, 470 insertions(+) create mode 100644 .gitignore create mode 100644 .jshintrc create mode 100644 gulpfile.js create mode 100644 index.html create mode 100644 package.json create mode 100644 src/etc/develop.js.ejemplo create mode 100644 src/js/app.js create mode 100644 src/js/controller.js create mode 100644 src/js/route.js create mode 100644 src/js/service.js create mode 100644 src/views/foca-abm-choferes-item.html create mode 100644 src/views/foca-abm-choferes-listado.html 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..3e96c5e --- /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: 'focaAbmChofer', + root: '' + }), + gulp.dest(paths.tmp) + ] + ); +}); + +gulp.task('uglify', ['templates'], function() { + return pump( + [ + gulp.src([ + paths.srcJS, + 'tmp/views.js' + ]), + concat('foca-abm-chofer.js'), + replace("['ngRoute', 'focaModal', 'ui.bootstrap']", '[]'), + replace("src/views/", ''), + gulp.dest(paths.tmp), + rename('foca-abm-chofer.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..eb4dd2d --- /dev/null +++ b/index.html @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + diff --git a/package.json b/package.json new file mode 100644 index 0000000..9837206 --- /dev/null +++ b/package.json @@ -0,0 +1,60 @@ +{ + "name": "foca-abm-vehiculo", + "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 install -D angular bootstrap ui-bootstrap4 font-awesome jquery gulp gulp-connect jasmine-core pre-commit gulp-angular-templatecache gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify-es gulp-uglify gulp-clean jshint pump git+http://git.focasoftware.com/npm/foca-modal.git" + }, + "pre-commit": [ + "gulp-pre-commit" + ], + "repository": { + "type": "git", + "url": "http://git.focasoftware.com/npm/foca-abm-vehiculo.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..252c6eb --- /dev/null +++ b/src/etc/develop.js.ejemplo @@ -0,0 +1,4 @@ +angular.module('focaAbmVehiculo') + .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..e75eddd --- /dev/null +++ b/src/js/app.js @@ -0,0 +1 @@ +angular.module('focaAbmChofer', ['ngRoute', 'focaModal', 'ui.bootstrap']); \ No newline at end of file diff --git a/src/js/controller.js b/src/js/controller.js new file mode 100644 index 0000000..96bc5d4 --- /dev/null +++ b/src/js/controller.js @@ -0,0 +1,62 @@ +angular.module('focaAbmChofer') + .controller('focaAbmChoferesController', [ + '$scope', 'focaAbmChoferService', '$location', 'focaModalService', + function($scope, focaAbmChoferService, $location, focaModalService) { + + $scope.filters = ''; + $scope.choferes = []; + $scope.choferesFiltrados = []; + + focaAbmChoferService.getChoferes().then(function(datos) { + $scope.choferes = datos.data; + $scope.choferesFiltrados = $scope.choferes; + }); + + + + $scope.editar = function(id) { + $location.path('/chofer/' + id); + }; + + $scope.solicitarConfirmacion = function(chofer) { + focaModalService.confirm('¿Está seguro que desea borrar el chofer '+ + chofer.nombre + ' ?').then( function(confirmed) { + if(confirmed){ + focaAbmChoferService.deleteChofer(chofer.id); + $scope.choferes.splice($scope.choferes.indexOf(chofer), 1); + } + }); + }; + + + } + ]) + .controller('focaAbmChoferController', [ + '$scope', 'focaAbmChoferService', '$routeParams', '$location', + function($scope, focaAbmChoferService, $routeParams, $location) { + + $scope.chofer = {}; + $scope.transportistas = []; + + focaAbmChoferService.getChofer($routeParams.id).then(function(res) { + if (res.data) $scope.chofer = res.data; + }); + + focaAbmChoferService.getTransportistas().then(function(res) { + $scope.transportistas = res.data; + }); + + $scope.cancelar = function() { + $location.path('/chofer'); + }; + + $scope.guardar = function() { + $scope.chofer.idTransportista = $scope.chofer.transportista.COD; + delete $scope.chofer.transportista; + focaAbmChoferService.guardarChofer($scope.chofer).then(function() { + $location.path('/chofer'); + }); + }; + + } + ]); \ No newline at end of file diff --git a/src/js/route.js b/src/js/route.js new file mode 100644 index 0000000..ac5bd00 --- /dev/null +++ b/src/js/route.js @@ -0,0 +1,19 @@ +angular.module('focaAbmChofer') + .config([ + '$routeProvider', + function($routeProvider) { + $routeProvider.when('/chofer', { + controller: 'focaAbmChoferesController', + templateUrl: 'src/views/foca-abm-choferes-listado.html' + }); + } + ]) + .config([ + '$routeProvider', + function($routeProvider) { + $routeProvider.when('/chofer/:id', { + controller: 'focaAbmChoferController', + templateUrl: 'src/views/foca-abm-choferes-item.html' + }); + } + ]); \ No newline at end of file diff --git a/src/js/service.js b/src/js/service.js new file mode 100644 index 0000000..655c3d1 --- /dev/null +++ b/src/js/service.js @@ -0,0 +1,20 @@ +angular.module('focaAbmChofer') + .factory('focaAbmChoferService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { + return { + getChoferes: function() { + return $http.get(API_ENDPOINT.URL + '/chofer'); + }, + getChofer: function(id) { + return $http.get(API_ENDPOINT.URL + '/chofer/' + id); + }, + guardarChofer: function(chofer) { + return $http.post(API_ENDPOINT.URL + '/chofer', {chofer: chofer}); + }, + getTransportistas: function() { + return $http.get(API_ENDPOINT.URL + '/transportista'); + }, + deleteChofer: function(id) { + return $http.delete(API_ENDPOINT.URL + '/chofer/' + id); + } + }; + }]); diff --git a/src/views/foca-abm-choferes-item.html b/src/views/foca-abm-choferes-item.html new file mode 100644 index 0000000..0a8dc48 --- /dev/null +++ b/src/views/foca-abm-choferes-item.html @@ -0,0 +1,59 @@ +

Chofer

+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + +
+
+
\ No newline at end of file diff --git a/src/views/foca-abm-choferes-listado.html b/src/views/foca-abm-choferes-listado.html new file mode 100644 index 0000000..d418282 --- /dev/null +++ b/src/views/foca-abm-choferes-listado.html @@ -0,0 +1,56 @@ +
+

Choferes

+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
CódigoNombreDNITeléfonoTransportista + +
+ + +
+ + Salir + +
\ No newline at end of file -- 1.9.1