From 15ed2516caa080ad87b8246551bda0383b7a7636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s?= Date: Sat, 12 Jan 2019 13:43:28 -0300 Subject: [PATCH] version 0.1 --- .gitignore | 5 +++ .jshintrc | 64 ++++++++++++++++++++++++++++++++++ gulpfile.js | 85 ++++++++++++++++++++++++++++++++++++++++++++++ src/etc/develop.js.ejemplo | 4 +++ src/js/app.js | 5 +++ src/js/controller.js | 50 +++++++++++++++++++++++++++ src/js/service.js | 8 +++++ src/views/modal-login.html | 40 ++++++++++++++++++++++ 8 files changed, 261 insertions(+) create mode 100644 .gitignore create mode 100644 .jshintrc create mode 100644 gulpfile.js 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/service.js create mode 100644 src/views/modal-login.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..31a0ef5 --- /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..dd429f7 --- /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": true, + + // 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..5a11613 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,85 @@ +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('clean', function(){ + return gulp.src(['tmp', 'dist'], {read: false}) + .pipe(clean()); +}); + +gulp.task('templates', ['clean'], function() { + return pump( + [ + gulp.src(paths.srcViews), + htmlmin(), + templateCache('views.js', { + module: 'focaModalLogin', + root: '' + }), + gulp.dest(paths.tmp) + ] + ); +}); + +gulp.task('uglify', ['templates'], function() { + return pump( + [ + gulp.src([ + paths.srcJS, + 'tmp/views.js' + ]), + concat('foca-modal-login.js'), + replace("['ui.bootstrap', 'focaDirectivas', 'angular-ladda']", '[]'), + replace('src/views/', ''), + gulp.dest(paths.tmp), + rename('foca-modal-login.min.js'), + uglify(), + gulp.dest(paths.dist) + ] + ); +}); + +gulp.task('pre-commit', function() { + return pump( + [ + gulp.src(paths.srcJS), + jshint('.jshintrc'), + jshint.reporter('default'), + jshint.reporter('fail') + ] + ); +}); + + +gulp.task('webserver', function() { + pump [ + connect.server({port: 3000}) + ] +}); + +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('default', ['webserver']); + +gulp.task('watch', function(){ + gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); +}); diff --git a/src/etc/develop.js.ejemplo b/src/etc/develop.js.ejemplo new file mode 100644 index 0000000..6d9e967 --- /dev/null +++ b/src/etc/develop.js.ejemplo @@ -0,0 +1,4 @@ +angular.module('focaBusquedaCliente') + .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..d7cdc1e --- /dev/null +++ b/src/js/app.js @@ -0,0 +1,5 @@ +angular.module('focaModalLogin', [ + 'ui.bootstrap', + 'focaDirectivas', + 'angular-ladda' +]); diff --git a/src/js/controller.js b/src/js/controller.js new file mode 100644 index 0000000..2afd920 --- /dev/null +++ b/src/js/controller.js @@ -0,0 +1,50 @@ +angular.module('focaModalLogin') + .controller('focaModalLoginController', [ + '$uibModalInstance', '$scope', 'parametros', 'focaModalLoginService', + function($uibModalInstance, $scope, parametros, focaModalLoginService) { + init(); + + function init() { + console.info(parametros); + $scope.cuenta = parametros.cuenta; + $scope.usuario = { + login: '', + pass: '' + } + + if (parametros.tipo == 'Transportistas') { + $scope.usuario.login = parametros.cuenta.dni; + } + + if (parametros.tipo == 'Cobradores' || parametros.tipo == 'Vendedores') { + $scope.usuario.login = parametros.cuenta.CodVen; + } + } + + $scope.guardar = function() { + var result = { + login: { + username: $scope.usuario.login, + password: $scope.usuario.pass, + activo: true + }, + cuenta: { + tipo: parametros.tipo, + id: parametros.cuenta.id + } + } + + if (parametros.cuenta.idLogin) { + result.login.id = parametros.cuenta.idLogin; + } + + focaModalLoginService.postLogin(result).then(function(data) { + $uibModalInstance.close(data); + }); + } + + $scope.cancel = function() { + $uibModalInstance.dismiss(); + } + } + ]); \ No newline at end of file diff --git a/src/js/service.js b/src/js/service.js new file mode 100644 index 0000000..4f336d9 --- /dev/null +++ b/src/js/service.js @@ -0,0 +1,8 @@ +angular.module('focaModalLogin') + .factory('focaModalLoginService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { + return { + postLogin: function(login) { + return $http.post(API_ENDPOINT.URL + '/login/crear', login); + } + }; + }]); diff --git a/src/views/modal-login.html b/src/views/modal-login.html new file mode 100644 index 0000000..5479a8b --- /dev/null +++ b/src/views/modal-login.html @@ -0,0 +1,40 @@ + + + -- 1.9.1