From a9557028ee74e8c92bfceca306d5bda0b07c5b0c Mon Sep 17 00:00:00 2001 From: Jose Pinto Date: Thu, 31 Jan 2019 15:58:01 -0300 Subject: [PATCH] Primera version --- .gitignore | 5 ++ .jshintrc | 64 ++++++++++++++++++++++++ gulpfile.js | 89 +++++++++++++++++++++++++++++++++ package.json | 39 +++++++++++++++ src/etc/develop.js.ejemplo | 4 ++ src/js/app.js | 4 ++ src/js/controller.js | 39 +++++++++++++++ src/js/route.js | 10 ++++ src/js/service.js | 8 +++ src/views/foca-configurar-terminal.html | 41 +++++++++++++++ 10 files changed, 303 insertions(+) create mode 100644 .gitignore create mode 100644 .jshintrc create mode 100644 gulpfile.js 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-configurar-terminal.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..7f39c11 --- /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: 'focaConfigurarTerminal', + root: '' + }), + gulp.dest(paths.tmp) + ] + ); +}); + +gulp.task('uglify', ['templates'], function() { + return pump( + [ + gulp.src([ + paths.srcJS, + 'tmp/views.js' + ]), + concat('foca-configurar-terminal.js'), + replace("['ngRoute', 'focaBotoneraLateral']", '[]'), + replace("src/views/", ''), + gulp.dest(paths.tmp), + rename('foca-configurar-terminal.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/package.json b/package.json new file mode 100644 index 0000000..9c5fd11 --- /dev/null +++ b/package.json @@ -0,0 +1,39 @@ +{ + "name": "foca-configurar-terminal", + "version": "0.0.1", + "description": "foca-configurar-terminal", + "main": "index.js", + "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 angular bootstrap font-awesome jquery gulp gulp-connect jasmine-core pre-commit gulp-angular-templatecache gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify-es jshint pump" + }, + "repository": { + "type": "git", + "url": "git@git.focasoftware.com:npm/foca-configurar-terminal.git" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "angular": "^1.7.5", + "angular-route": "^1.7.5", + "bootstrap": "^4.2.1", + "gulp": "^3.9.1", + "gulp-angular-templatecache": "^2.2.6", + "gulp-clean": "^0.4.0", + "gulp-connect": "^5.7.0", + "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.7", + "pre-commit": "^1.2.2", + "pump": "^3.0.0" + } +} diff --git a/src/etc/develop.js.ejemplo b/src/etc/develop.js.ejemplo new file mode 100644 index 0000000..b423d3d --- /dev/null +++ b/src/etc/develop.js.ejemplo @@ -0,0 +1,4 @@ +angular.module('focaConfigurarTerminal') + .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..a6305c7 --- /dev/null +++ b/src/js/app.js @@ -0,0 +1,4 @@ +angular.module('focaConfigurarTerminal', [ + 'ngRoute', + 'focaBotoneraLateral' +]); diff --git a/src/js/controller.js b/src/js/controller.js new file mode 100644 index 0000000..0601b9b --- /dev/null +++ b/src/js/controller.js @@ -0,0 +1,39 @@ +angular.module('focaConfigurarTerminal') + .controller('focaConfigurarTerminalController', [ + '$scope', + '$timeout', + '$location', + 'focaConfigurarTerminalService', + 'focaBotoneraLateralService', + function( + $scope, + $timeout, + $location, + focaConfigurarTerminalService, + focaBotoneraLateralService) { + $scope.now = new Date(); + $scope.focused = 1; + $scope.terminal = { + variable: 'terminalId' + }; + + $timeout(function() { + focaBotoneraLateralService.showSalir(true); + focaBotoneraLateralService.showPausar(false); + focaBotoneraLateralService.showCancelar(false); + focaBotoneraLateralService.showGuardar(true, $scope.guardar); + }); + + $scope.guardar = function() { + focaConfigurarTerminalService + .configTerminal($scope.terminal) + .then(function() { + $location.path('/'); + }); + }; + + $scope.next = function(key) { + if(key === 13) $scope.focused ++; + }; + } + ]); diff --git a/src/js/route.js b/src/js/route.js new file mode 100644 index 0000000..77944e4 --- /dev/null +++ b/src/js/route.js @@ -0,0 +1,10 @@ +angular.module('focaConfigurarTerminal') + .config([ + '$routeProvider', + function($routeProvider) { + $routeProvider.when('/terminal/config', { + controller: 'focaConfigurarTerminalController', + templateUrl: 'src/views/foca-configurar-terminal.html' + }); + } + ]); diff --git a/src/js/service.js b/src/js/service.js new file mode 100644 index 0000000..c89747c --- /dev/null +++ b/src/js/service.js @@ -0,0 +1,8 @@ +angular.module('focaConfigurarTerminal') + .factory('focaConfigurarTerminalService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { + return { + configTerminal: function(terminal) { + return $http.post(API_ENDPOINT.URL + '/config/terminal', terminal); + } + }; + }]); diff --git a/src/views/foca-configurar-terminal.html b/src/views/foca-configurar-terminal.html new file mode 100644 index 0000000..e596469 --- /dev/null +++ b/src/views/foca-configurar-terminal.html @@ -0,0 +1,41 @@ +
+ +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
-- 1.9.1