Commit faa2c5e7a9d8723ec72c45a1dc67bacf1bd2c0d7
1 parent
abad3e74
Exists in
master
and in
1 other branch
V. 0.5.5 - Modificações para debugar. Agora vamos realizar testes com o Heroku, na produção.
Showing
8 changed files
with
60 additions
and
163 deletions
Show diff stats
.gitignore
client/package.json
| ... | ... | @@ -17,6 +17,12 @@ |
| 17 | 17 | }, |
| 18 | 18 | "/auth/google/callback": { |
| 19 | 19 | "target": "http://localhost:5000" |
| 20 | + }, | |
| 21 | + "/api/current_user": { | |
| 22 | + "target": "http://localhost:5000" | |
| 23 | + }, | |
| 24 | + "/api/logout": { | |
| 25 | + "target": "http://localhost:5000" | |
| 20 | 26 | } |
| 21 | 27 | }, |
| 22 | 28 | "dependencies": { | ... | ... |
config/keys.js
| 1 | 1 | // keys.js - figure out what set of credentials to return |
| 2 | 2 | // NODE_ENV - variável do Heroku que informa que estamos em production. o Heroku configura esta variável |
| 3 | +console.log ("Ambiente: " + process.env.NODE_ENV); | |
| 3 | 4 | if (process.env.NODE_ENV === "production") { |
| 4 | 5 | // we are in production - return the production set of keys |
| 5 | 6 | module.exports = require ("./prod"); | ... | ... |
package-lock.json
| ... | ... | @@ -558,11 +558,6 @@ |
| 558 | 558 | "resolved": "https://registry.npmjs.org/jade-bootstrap/-/jade-bootstrap-1.0.14.tgz", |
| 559 | 559 | "integrity": "sha1-x99tRjinKHKZ3HUXXrUAnzJyEeg=" |
| 560 | 560 | }, |
| 561 | - "js-string-escape": { | |
| 562 | - "version": "1.0.1", | |
| 563 | - "resolved": "https://registry.npmjs.org/js-string-escape/-/js-string-escape-1.0.1.tgz", | |
| 564 | - "integrity": "sha1-4mJbrbwNZ8dTPp7cEGjFh65BN+8=" | |
| 565 | - }, | |
| 566 | 561 | "jstransformer": { |
| 567 | 562 | "version": "0.0.2", |
| 568 | 563 | "resolved": "https://registry.npmjs.org/jstransformer/-/jstransformer-0.0.2.tgz", |
| ... | ... | @@ -662,32 +657,32 @@ |
| 662 | 657 | } |
| 663 | 658 | }, |
| 664 | 659 | "mongodb": { |
| 665 | - "version": "3.0.7", | |
| 666 | - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.0.7.tgz", | |
| 667 | - "integrity": "sha512-n/14kMJEoARXz1qhpNPhUocqy+z5130jhqgEIX1Tsl8UVpHrndQ8et+VmgC4yPK/I8Tcgc93JEMQCHTekBUnNA==", | |
| 660 | + "version": "3.0.8", | |
| 661 | + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.0.8.tgz", | |
| 662 | + "integrity": "sha512-mj7yIUyAr9xnO2ev8pcVJ9uX7gSum5LLs1qIFoWLxA5Il50+jcojKtaO1/TbexsScZ9Poz00Pc3b86GiSqJ7WA==", | |
| 668 | 663 | "requires": { |
| 669 | - "mongodb-core": "3.0.7" | |
| 664 | + "mongodb-core": "3.0.8" | |
| 670 | 665 | } |
| 671 | 666 | }, |
| 672 | 667 | "mongodb-core": { |
| 673 | - "version": "3.0.7", | |
| 674 | - "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.0.7.tgz", | |
| 675 | - "integrity": "sha512-z6YufO7s40wLiv2ssFshqoLS4+Kf+huhHq6KZ7gDArsKNzXYjAwTMnhEIJ9GQ8fIfBGs5tBLNPfbIDoCKGPmOw==", | |
| 668 | + "version": "3.0.8", | |
| 669 | + "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.0.8.tgz", | |
| 670 | + "integrity": "sha512-dFxfhH9N7ohuQnINyIl6dqEF8sYOE0WKuymrFf3L3cipJNrx+S8rAbNOTwa00/fuJCjBMJNFsaA+R2N16//UIw==", | |
| 676 | 671 | "requires": { |
| 677 | 672 | "bson": "1.0.6", |
| 678 | 673 | "require_optional": "1.0.1" |
| 679 | 674 | } |
| 680 | 675 | }, |
| 681 | 676 | "mongoose": { |
| 682 | - "version": "5.0.17", | |
| 683 | - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.0.17.tgz", | |
| 684 | - "integrity": "sha512-RV1WBQhzW7oOhStR+s7LQYfgQWTJm4hgmU3TqtgTiBCfnj5/sNliX2/SY+ef7tpIZRUqEBV5xITZdAlwQ6Ymdg==", | |
| 677 | + "version": "5.1.0", | |
| 678 | + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.1.0.tgz", | |
| 679 | + "integrity": "sha512-GFx4Z2YpfxRQ9BExd2ML5MDKYdzOjdXB5a6fhove98EP6iB8tgZDY/fKSociEMJSIA37auPXmKfGfrc2uAMkMQ==", | |
| 685 | 680 | "requires": { |
| 686 | 681 | "async": "2.1.4", |
| 687 | 682 | "bson": "1.0.6", |
| 688 | 683 | "kareem": "2.0.7", |
| 689 | 684 | "lodash.get": "4.4.2", |
| 690 | - "mongodb": "3.0.7", | |
| 685 | + "mongodb": "3.0.8", | |
| 691 | 686 | "mongoose-legacy-pluralize": "1.0.2", |
| 692 | 687 | "mpath": "0.4.1", |
| 693 | 688 | "mquery": "3.0.0", |
| ... | ... | @@ -846,18 +841,24 @@ |
| 846 | 841 | "integrity": "sha1-HUCLP9t2kjuVQ9lvtMnf1TXZy10=" |
| 847 | 842 | }, |
| 848 | 843 | "pg": { |
| 849 | - "version": "7.4.1", | |
| 850 | - "resolved": "https://registry.npmjs.org/pg/-/pg-7.4.1.tgz", | |
| 851 | - "integrity": "sha1-80Ecjd+faSMi/gXnAXoYiOR/ePE=", | |
| 844 | + "version": "7.4.3", | |
| 845 | + "resolved": "https://registry.npmjs.org/pg/-/pg-7.4.3.tgz", | |
| 846 | + "integrity": "sha1-97b5P1NA7MJZavu5ShPj1rYJg0s=", | |
| 852 | 847 | "requires": { |
| 853 | 848 | "buffer-writer": "1.0.1", |
| 854 | - "js-string-escape": "1.0.1", | |
| 855 | 849 | "packet-reader": "0.3.1", |
| 856 | 850 | "pg-connection-string": "0.1.3", |
| 857 | 851 | "pg-pool": "2.0.3", |
| 858 | 852 | "pg-types": "1.12.1", |
| 859 | 853 | "pgpass": "1.0.2", |
| 860 | 854 | "semver": "4.3.2" |
| 855 | + }, | |
| 856 | + "dependencies": { | |
| 857 | + "semver": { | |
| 858 | + "version": "4.3.2", | |
| 859 | + "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.2.tgz", | |
| 860 | + "integrity": "sha1-x6BxWKgL7dBSNVt3DYLWZA+AO+c=" | |
| 861 | + } | |
| 861 | 862 | } |
| 862 | 863 | }, |
| 863 | 864 | "pg-connection-string": { |
| ... | ... | @@ -895,7 +896,7 @@ |
| 895 | 896 | "integrity": "sha1-5nfNNuy7F17hRtE90XCipzpDqUw=", |
| 896 | 897 | "requires": { |
| 897 | 898 | "async": "2.6.0", |
| 898 | - "pg": "7.4.1", | |
| 899 | + "pg": "7.4.3", | |
| 899 | 900 | "topojson": "3.0.2" |
| 900 | 901 | } |
| 901 | 902 | }, |
| ... | ... | @@ -917,7 +918,7 @@ |
| 917 | 918 | "postgres-interval": { |
| 918 | 919 | "version": "1.1.1", |
| 919 | 920 | "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.1.1.tgz", |
| 920 | - "integrity": "sha1-rNsPiXtLHG5JbZ1OCoU+HEKPBvA=", | |
| 921 | + "integrity": "sha512-OkuCi9t/3CZmeQreutGgx/OVNv9MKHGIT5jH8KldQ4NLYXkvmT9nDVxEuCENlNwhlGPE374oA/xMqn05G49pHA==", | |
| 921 | 922 | "requires": { |
| 922 | 923 | "xtend": "4.0.1" |
| 923 | 924 | } |
| ... | ... | @@ -1001,13 +1002,6 @@ |
| 1001 | 1002 | "requires": { |
| 1002 | 1003 | "resolve-from": "2.0.0", |
| 1003 | 1004 | "semver": "5.5.0" |
| 1004 | - }, | |
| 1005 | - "dependencies": { | |
| 1006 | - "semver": { | |
| 1007 | - "version": "5.5.0", | |
| 1008 | - "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", | |
| 1009 | - "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==" | |
| 1010 | - } | |
| 1011 | 1005 | } |
| 1012 | 1006 | }, |
| 1013 | 1007 | "resolve-from": { |
| ... | ... | @@ -1034,9 +1028,9 @@ |
| 1034 | 1028 | "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=" |
| 1035 | 1029 | }, |
| 1036 | 1030 | "semver": { |
| 1037 | - "version": "4.3.2", | |
| 1038 | - "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.2.tgz", | |
| 1039 | - "integrity": "sha1-x6BxWKgL7dBSNVt3DYLWZA+AO+c=" | |
| 1031 | + "version": "5.5.0", | |
| 1032 | + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", | |
| 1033 | + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==" | |
| 1040 | 1034 | }, |
| 1041 | 1035 | "send": { |
| 1042 | 1036 | "version": "0.15.6", |
| ... | ... | @@ -1114,7 +1108,7 @@ |
| 1114 | 1108 | "split": { |
| 1115 | 1109 | "version": "1.0.1", |
| 1116 | 1110 | "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", |
| 1117 | - "integrity": "sha1-YFvZvjA6pZ+zX5Ip++oN3snqB9k=", | |
| 1111 | + "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", | |
| 1118 | 1112 | "requires": { |
| 1119 | 1113 | "through": "2.3.8" |
| 1120 | 1114 | } | ... | ... |
package.json
| ... | ... | @@ -25,12 +25,12 @@ |
| 25 | 25 | "jade": "~1.11.0", |
| 26 | 26 | "jade-bootstrap": "^1.0.14", |
| 27 | 27 | "leaflet-draw": "^1.0.2", |
| 28 | - "mongoose": "^5.0.17", | |
| 28 | + "mongoose": "^5.1.0", | |
| 29 | 29 | "morgan": "~1.9.0", |
| 30 | 30 | "mssql": "^4.1.0", |
| 31 | 31 | "passport": "^0.4.0", |
| 32 | 32 | "passport-google-oauth20": "^1.0.0", |
| 33 | - "pg": "*", | |
| 33 | + "pg": "^7.4.3", | |
| 34 | 34 | "postgeo": "*", |
| 35 | 35 | "serve-favicon": "~2.4.5" |
| 36 | 36 | } | ... | ... |
routes/authRoutes.js
| 1 | +// Autentication routes | |
| 2 | +// | |
| 1 | 3 | const passport = require("passport"); // from npm |
| 2 | 4 | |
| 3 | 5 | module.exports = router => { |
| ... | ... | @@ -18,10 +20,12 @@ module.exports = router => { |
| 18 | 20 | if (err.name === "TokenError") { |
| 19 | 21 | res.redirect("http://nexusbr.com"); // redirect them back to the login page |
| 20 | 22 | } else { |
| 23 | + console.log("Falhou ao logar!"); | |
| 21 | 24 | // Handle other errors here |
| 22 | 25 | } |
| 23 | 26 | }, |
| 24 | 27 | (req, res) => { |
| 28 | + console.log("Logou com sucesso!"); | |
| 25 | 29 | // On success, redirect back to '/' |
| 26 | 30 | res.redirect("/"); |
| 27 | 31 | } | ... | ... |
routes/mapRoutes.js
| 1 | 1 | // Here are all mapping routes |
| 2 | 2 | // |
| 3 | 3 | const keys = require("../config/keys"); |
| 4 | - | |
| 4 | +console.log ("Layers de água: " + keys.waterLayers); | |
| 5 | 5 | module.exports = router => { |
| 6 | 6 | // bounding coordinates to view the map |
| 7 | 7 | var boundSW = [-23.6506647239914, -46.5848434588656]; // lat, long |
| ... | ... | @@ -17,17 +17,16 @@ module.exports = router => { |
| 17 | 17 | var retorno = coordenadas(numero, function(x, y) { |
| 18 | 18 | console.log("Terminou procura coordenadas x: " + x + " y: " + y); |
| 19 | 19 | res.render("map", { |
| 20 | - codigo: numero, | |
| 21 | - consumidor: codigoComNome, | |
| 22 | - fator_zoom: 23, | |
| 23 | - title: "NEXUS", | |
| 24 | - lat: y, | |
| 25 | - lng: x, | |
| 26 | - bndSW: boundSW, | |
| 27 | - bndNE: boundNE, | |
| 28 | - geoserverWMS: keys.geoserverWMS, | |
| 29 | - waterLayers: keys.waterLayers, | |
| 30 | - server: keys.server | |
| 20 | + codigo: numero, | |
| 21 | + consumidor: codigoComNome, | |
| 22 | + fator_zoom: 23, | |
| 23 | + title: "NEXUS", | |
| 24 | + lat: y, | |
| 25 | + lng: x, | |
| 26 | + bndSW: boundSW, | |
| 27 | + bndNE: boundNE, | |
| 28 | + geoserverWMS: keys.geoserverWMS, | |
| 29 | + waterLayers: keys.waterLayers, | |
| 31 | 30 | }); |
| 32 | 31 | }); |
| 33 | 32 | } | ... | ... |
views/map.jade
| ... | ... | @@ -32,127 +32,18 @@ block content |
| 32 | 32 | format: 'image/png', |
| 33 | 33 | transparent: true, |
| 34 | 34 | maxZoom: 23 |
| 35 | - }), | |
| 35 | + }), | |
| 36 | 36 | drawnItems = L.featureGroup().addTo(map); |
| 37 | + | |
| 37 | 38 | L.control.layers({ |
| 38 | 39 | "OSM": osm.addTo(map), |
| 39 | 40 | "Google": L.tileLayer('http://www.google.cn/maps/vt?lyrs=s@189&gl=cn&x={x}&y={y}&z={z}', { |
| 40 | 41 | attribution: 'google' |
| 41 | 42 | }) |
| 42 | - }, {'Ocorrências': drawnItems, 'Redes': wmsLayer}, { position: 'topright', collapsed: true }).addTo(map); | |
| 43 | + }, | |
| 44 | + {'Redes': wmsLayer, 'Ocorrências': drawnItems}, | |
| 45 | + { position: 'topright', collapsed: false } | |
| 46 | + ).addTo(map); | |
| 43 | 47 | |
| 44 | 48 | var marker = L.marker([#{lat},#{lng}]).addTo(map); |
| 45 | - marker.bindPopup("<b>#{codigo}</b><br>#{consumidor}").openPopup(); | |
| 46 | - | |
| 47 | - //- var modifiedDraw = L.Control.Draw.extend({ | |
| 48 | - //- draw: { | |
| 49 | - //- polygon: false, | |
| 50 | - //- polyline: false, | |
| 51 | - //- line: false, | |
| 52 | - //- circle: false, | |
| 53 | - //- rectangle: false, | |
| 54 | - //- circlemarker: false, | |
| 55 | - //- marker: true, | |
| 56 | - //- toolbar: { | |
| 57 | - //- buttons: { | |
| 58 | - //- marker: 'Cadastra árvore' | |
| 59 | - //- } | |
| 60 | - //- } | |
| 61 | - //- }, | |
| 62 | - //- edit: { | |
| 63 | - //- featureGroup: drawnItems | |
| 64 | - //- } | |
| 65 | - //- }); | |
| 66 | - | |
| 67 | - //- modifiedDraw = L.Control.Draw({ | |
| 68 | - //- draw: { | |
| 69 | - //- polygon: false, | |
| 70 | - //- polyline: false, | |
| 71 | - //- line: false, | |
| 72 | - //- circle: false, | |
| 73 | - //- rectangle: false, | |
| 74 | - //- circlemarker: false, | |
| 75 | - //- marker: true | |
| 76 | - //- }, | |
| 77 | - //- edit: { | |
| 78 | - //- featureGroup: drawnItems | |
| 79 | - //- }, | |
| 80 | - //- }); | |
| 81 | - | |
| 82 | - var drawControl = new L.Control.Draw({ | |
| 83 | - draw: { | |
| 84 | - toolbar: { | |
| 85 | - buttons: { | |
| 86 | - marker: 'Draw an awesome polygon' | |
| 87 | - } | |
| 88 | - }, | |
| 89 | - handlers: { | |
| 90 | - marker: { | |
| 91 | - tooltip: { | |
| 92 | - start: "Selecione no mapa para colocar uma árvore." | |
| 93 | - } | |
| 94 | - } | |
| 95 | - }, | |
| 96 | - polygon: false, | |
| 97 | - polyline: false, | |
| 98 | - line: false, | |
| 99 | - circle: false, | |
| 100 | - rectangle: false, | |
| 101 | - circlemarker: false, | |
| 102 | - marker: true | |
| 103 | - }, | |
| 104 | - edit: { | |
| 105 | - featureGroup: drawnItems | |
| 106 | - }, | |
| 107 | - }); | |
| 108 | - L.drawLocal = { | |
| 109 | - | |
| 110 | - }; | |
| 111 | - | |
| 112 | - map.addControl(drawControl); | |
| 113 | - | |
| 114 | - // Truncate value based on number of decimals | |
| 115 | - var _round = function(num, len) { | |
| 116 | - return Math.round(num*(Math.pow(10, len)))/(Math.pow(10, len)); | |
| 117 | - }; | |
| 118 | - // Helper method to format LatLng object (x.xxxxxx, y.yyyyyy) | |
| 119 | - var strLatLng = function(latlng) { | |
| 120 | - var coordenadas = "("+_round(latlng.lat, 2)+", "+_round(latlng.lng, 2)+")"; | |
| 121 | - return coordenadas; | |
| 122 | - }; | |
| 123 | - | |
| 124 | - // Generate popup content based on layer type | |
| 125 | - // - Returns HTML string, or null if unknown object | |
| 126 | - var getPopupContent = function(layer) { | |
| 127 | - return strLatLng(layer.getLatLng()); | |
| 128 | - }; | |
| 129 | - | |
| 130 | - // Object created - bind popup to layer, add to feature group | |
| 131 | - map.on(L.Draw.Event.CREATED, function(event) { | |
| 132 | - console.log ("Entrou no evento Created"); | |
| 133 | - var layer = event.layer; | |
| 134 | - var content = getPopupContent(layer); | |
| 135 | - if (content !== null) { | |
| 136 | - console.log ("Coordendas: " + layer.getLatLng().lat + " - " + layer.getLatLng().lng); | |
| 137 | - $.post({ | |
| 138 | - data: "teste", | |
| 139 | - // data: layer.getLatLng().lng + "/lat/" + layer.getLatLng().lat, | |
| 140 | - url: "http://127.0.0.1/ponto" | |
| 141 | - }); | |
| 142 | - layer.bindPopup(content); | |
| 143 | - } | |
| 144 | - drawnItems.addLayer(layer); | |
| 145 | - }); | |
| 146 | - | |
| 147 | - // Object(s) edited - update popups | |
| 148 | - map.on(L.Draw.Event.EDITED, function(event) { | |
| 149 | - console.log ("Entrou no evento Edited"); | |
| 150 | - var layers = event.layers, | |
| 151 | - content = null; | |
| 152 | - layers.eachLayer(function(layer) { | |
| 153 | - content = getPopupContent(layer); | |
| 154 | - if (content !== null) { | |
| 155 | - layer.setPopupContent(content); | |
| 156 | - } | |
| 157 | - }); | |
| 158 | - }); | |
| 49 | + marker.bindPopup("<b>#{codigo}</b><br>#{consumidor}").openPopup(); | |
| 159 | 50 | \ No newline at end of file | ... | ... |