diff --git a/.bowerrc b/.bowerrc index daf4462c..284deaf4 100644 --- a/.bowerrc +++ b/.bowerrc @@ -1,5 +1,6 @@ { "directory": "bower_components", "analytics": false, + "strict-ssl": false, "registry": "https://registry.bower.io" } diff --git a/.env.colombia b/.env.colombia index 1e22c824..c5007918 100644 --- a/.env.colombia +++ b/.env.colombia @@ -1,6 +1,7 @@ GA=Winter_is_coming OTHER_LOCALE=en-col DEFAULT_LOCALE=es-col -API_URL=http://atlas-colombia-harvard.cid-labs.com/api +API_URL=https://prudatlascolombia.bancoldex.com:9006 DOWNLOAD_URL=https://s3.amazonaws.com/datlas-colombia-downloads MAP_URL=http://download.geofabrik.de/south-america/colombia.html +AGRO_URL=https://prudatlascolombia.bancoldex.com:9007 diff --git a/.env.deploy b/.env.deploy index 1e22c824..353924f6 100644 --- a/.env.deploy +++ b/.env.deploy @@ -1,6 +1,7 @@ GA=Winter_is_coming OTHER_LOCALE=en-col DEFAULT_LOCALE=es-col -API_URL=http://atlas-colombia-harvard.cid-labs.com/api +API_URL=https://atlas-colombia-harvard.cid-labs.com/api DOWNLOAD_URL=https://s3.amazonaws.com/datlas-colombia-downloads MAP_URL=http://download.geofabrik.de/south-america/colombia.html +AGRO_URL=http://52.44.92.68:8080 diff --git a/.env.example b/.env.example index 6ce4b0b3..55712b54 100644 --- a/.env.example +++ b/.env.example @@ -5,4 +5,5 @@ API_URL=something-something DOWNLOAD_URL=another-url-for-download ROOT_URL= / DOWNLOAD_URL=something-something +AGRO_URL=http://52.44.92.68:8080 diff --git a/.env.mexico b/.env.mexico index 80b12a87..e9fd3e35 100644 --- a/.env.mexico +++ b/.env.mexico @@ -5,3 +5,4 @@ API_URL=http://cide.cid-labs.com/api/ ROOT_URL= / DOWNLOAD_URL=https://s3-us-west-2.amazonaws.com/datlas-mexico-downloads-prod MAP_URL=http://mapserver.inegi.org.mx/MGN/mge2010v5_0.zip +AGRO_URL=http://52.44.92.68:8080 diff --git a/.env.peru b/.env.peru index 054025eb..31986ba0 100644 --- a/.env.peru +++ b/.env.peru @@ -4,3 +4,4 @@ DEFAULT_LOCALE=es-peru API_URL=http://atlas-peru-preview.cid-labs.com/api DOWNLOAD_URL=https://s3.amazonaws.com/datlas-peru-downloads MAP_URL=http://www.geoidep.gob.pe/index.php/catalogo-nacional-de-servicios-web/servicios-de-publicacion-de-objetos-wfs +AGRO_URL=http://52.44.92.68:8080 diff --git a/.github/workflows/aws.yml b/.github/workflows/aws.yml new file mode 100644 index 00000000..be8f1ec8 --- /dev/null +++ b/.github/workflows/aws.yml @@ -0,0 +1,86 @@ +# This workflow will build and push a new container image to Amazon ECR, +# and then will deploy a new task definition to Amazon ECS, when a release is created +# +# To use this workflow, you will need to complete the following set-up steps: +# +# 1. Create an ECR repository to store your images. +# For example: `aws ecr create-repository --repository-name my-ecr-repo --region us-east-2`. +# Replace the value of `ECR_REPOSITORY` in the workflow below with your repository's name. +# Replace the value of `aws-region` in the workflow below with your repository's region. +# +# 2. Create an ECS task definition, an ECS cluster, and an ECS service. +# For example, follow the Getting Started guide on the ECS console: +# https://us-east-2.console.aws.amazon.com/ecs/home?region=us-east-2#/firstRun +# Replace the values for `service` and `cluster` in the workflow below with your service and cluster names. +# +# 3. Store your ECS task definition as a JSON file in your repository. +# The format should follow the output of `aws ecs register-task-definition --generate-cli-skeleton`. +# Replace the value of `task-definition` in the workflow below with your JSON file's name. +# Replace the value of `container-name` in the workflow below with the name of the container +# in the `containerDefinitions` section of the task definition. +# +# 4. Store an IAM user access key in GitHub Actions secrets named `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`. +# See the documentation for each action used below for the recommended IAM policies for this IAM user, +# and best practices on handling the access key credentials. +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +name: Deploy to Amazon ECS + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + environment: deploy_prod + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION_NAME }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }} + IMAGE_TAG: ${{ github.sha }} + run: | + # Build a docker container and + # push it to ECR so that it can + # be deployed to ECS. + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f ./docker/Dockerfile . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" + + - name: Download task definition + run: | + aws ecs describe-task-definition --task-definition ${{ secrets.ECS_TASK_DEFINITION }} --query taskDefinition > task-definition.json + + - name: Fill in the new image ID in the Amazon ECS task definition + id: task-def + uses: aws-actions/amazon-ecs-render-task-definition@v1 + with: + task-definition: task-definition.json + container-name: ${{ secrets.CONTAINER_NAME }} + image: ${{ steps.build-image.outputs.image }} + + - name: Deploy Amazon ECS task definition + uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + with: + task-definition: ${{ steps.task-def.outputs.task-definition }} + service: ${{ secrets.ECS_SERVICE_NAME }} + cluster: ${{ secrets.ECS_CLUSTER }} + wait-for-service-stability: true diff --git a/.github/workflows/aws_develop.yml b/.github/workflows/aws_develop.yml new file mode 100644 index 00000000..a2a60a50 --- /dev/null +++ b/.github/workflows/aws_develop.yml @@ -0,0 +1,84 @@ +# This workflow will build and push a new container image to Amazon ECR, +# and then will deploy a new task definition to Amazon ECS, when a release is created +# +# To use this workflow, you will need to complete the following set-up steps: +# +# 1. Create an ECR repository to store your images. +# For example: `aws ecr create-repository --repository-name my-ecr-repo --region us-east-2`. +# Replace the value of `ECR_REPOSITORY` in the workflow below with your repository's name. +# Replace the value of `aws-region` in the workflow below with your repository's region. +# +# 2. Create an ECS task definition, an ECS cluster, and an ECS service. +# For example, follow the Getting Started guide on the ECS console: +# https://us-east-2.console.aws.amazon.com/ecs/home?region=us-east-2#/firstRun +# Replace the values for `service` and `cluster` in the workflow below with your service and cluster names. +# +# 3. Store your ECS task definition as a JSON file in your repository. +# The format should follow the output of `aws ecs register-task-definition --generate-cli-skeleton`. +# Replace the value of `task-definition` in the workflow below with your JSON file's name. +# Replace the value of `container-name` in the workflow below with the name of the container +# in the `containerDefinitions` section of the task definition. +# +# 4. Store an IAM user access key in GitHub Actions secrets named `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`. +# See the documentation for each action used below for the recommended IAM policies for this IAM user, +# and best practices on handling the access key credentials. +on: + push: + branches: [ fix/ports-deploy-jag ] + pull_request: + branches: [ fix/ports-deploy-jag ] + +name: Deploy to Amazon ECS + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + environment: deploy + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION_NAME }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }} + IMAGE_TAG: ${{ github.sha }} + run: | + # Build a docker container and + # push it to ECR so that it can + # be deployed to ECS. + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f ./docker/Dockerfile . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" + - name: Download task definition + run: | + aws ecs describe-task-definition --task-definition ${{ secrets.ECS_TASK_DEFINITION }} --query taskDefinition > task-definition.json + - name: Fill in the new image ID in the Amazon ECS task definition + id: task-def + uses: aws-actions/amazon-ecs-render-task-definition@v1 + with: + task-definition: task-definition.json + container-name: ${{ secrets.CONTAINER_NAME }} + image: ${{ steps.build-image.outputs.image }} + + - name: Deploy Amazon ECS task definition + uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + with: + task-definition: ${{ steps.task-def.outputs.task-definition }} + service: ${{ secrets.ECS_SERVICE_NAME }} + cluster: ${{ secrets.ECS_CLUSTER }} + wait-for-service-stability: true diff --git a/.gitignore b/.gitignore index 2d333cdd..53eafe8c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ # compiled output /dist /tmp +.idea/ +package-lock.json # dependencies /node_modules diff --git a/Brocfile.js b/Brocfile.js index c92c963b..689d4b6f 100644 --- a/Brocfile.js +++ b/Brocfile.js @@ -42,7 +42,7 @@ var app = new EmberApp({ }); // FileSaver -app.import('bower_components/FileSaver.js/FileSaver.min.js'); +app.import('bower_components/FileSaver.js/dist/FileSaver.min.js'); // PapaParse app.import('bower_components/papaparse/papaparse.min.js'); @@ -72,6 +72,9 @@ app.import('vendor/networks/col-industry_space.json', { destDir: 'assets/network app.import('vendor/networks/mex-industry_space.json', { destDir: 'assets/networks' }); app.import('vendor/color_mappings/product_section_colors.json', { destDir: 'assets/color_mappings' }); +app.import('vendor/color_mappings/partners_section_colors.json', { destDir: 'assets/color_mappings' }); +app.import('vendor/color_mappings/farmtypes_section_colors.json', { destDir: 'assets/color_mappings' }); +app.import('vendor/color_mappings/agproducts_section_colors.json', { destDir: 'assets/color_mappings' }); app.import('vendor/color_mappings/col-industry_section_colors.json', { destDir: 'assets/color_mappings' }); app.import('vendor/color_mappings/mex-industry_section_colors.json', { destDir: 'assets/color_mappings' }); @@ -79,6 +82,7 @@ app.import('vendor/color_mappings/mex-industry_section_colors.json', { destDir: //Import leaflet-omnivore app.import('vendor/leaflet-omnivore.min.js'); + // Font Awesome // The npm package readme mentions refactoring this as a Broccoli tree, so consider that a TODO app.import('bower_components/font-awesome/fonts/fontawesome-webfont.eot', { destDir: 'fonts' }); diff --git a/app/components/autocomplete-chained-input-datlas.js b/app/components/autocomplete-chained-input-datlas.js new file mode 100644 index 00000000..ae6ab5ac --- /dev/null +++ b/app/components/autocomplete-chained-input-datlas.js @@ -0,0 +1,232 @@ +import Ember from 'ember'; +const {computed, get, observer} = Ember; + +export default Ember.Component.extend({ + i18n: Ember.inject.service(), + buildermodSearchService: Ember.inject.service(), + treemapService: Ember.inject.service(), + search: null, + searchSelect1: 1, + searchSelect2: null, + placeHolder: null, + transitionProduct: 'transitionProduct', + transitionLocation: 'transitionLocation', + transitionLocationRoute: 'transitionLocationRoute', + transitionIndustry: 'transitionIndustry', + transitionLocationProducts: 'transitionLocationProducts', + transitionAgproduct: 'transitionAgproduct', + transitionLivestock: 'transitionLivestock', + transitionNonag: 'transitionNonag', + transitionLanduse: 'transitionLanduse', + runSelectChained: computed('idSelect', 'data_search', 'placeHolder', 'search', 'i18n', function(){ + + this.set('searchSelect1', null); + + let id_select = this.get('idSelect'); + + var $eventSelect = $(`#${id_select}`); + + let type = this.get('type'); + let source = this.get('source'); + let self = this; + var data = this.get('data_search') + var placeholder = this.get("placeHolder") + + if(placeholder === null){ + placeholder = this.get('i18n').t(`pageheader.search_placeholder.first.${type}.${source}`).string + } + + if(data === undefined){ + data = []; + } + + data.unshift({ id: "", text: ""}) + + $eventSelect.select2({ + placeholder: placeholder, + allowClear: true, + theme: 'bootstrap4', + language: this.get('i18n').display, + width: 'auto', + dropdownAutoWidth : true, + data: data, + containerCssClass: "flex-fill", + templateSelection: function (data, container) { + $(data.element).attr('data-key', data.key); + return data.text; + } + }); + + $eventSelect.on("select2:select", function (e) { + + let id = $eventSelect.val(); + self.set('searchSelect1', id); + + let text= $(`#${id_select} option:selected`).text(); + self.set('search', text); + self.set("buildermodSearchService.search", text); + + }); + }), + runSelectChained2: observer('searchSelect1', function(){ + + let id_select2 = this.get('idSelect2'); + let searchSelect1 = this.get('searchSelect1'); + + var $eventSelect2 = $(`#${id_select2}`); + + $eventSelect2.empty(); + + let type = this.get('type'); + let source = this.get('source'); + let self = this; + var data = [] + var placeholder = this.get("placeHolder") + + var data_search = this.get('data_search'); + + + if(data_search === undefined){ + data_search = [] + } + + data_search.filter(item => { + return item.id == searchSelect1 + }).map(item => { + item.chained.map(item => data.push(item)) + }); + + if(placeholder === null){ + placeholder = this.get('i18n').t(`pageheader.search_placeholder.second.${type}.${source}`).string + } + + if(data === undefined){ + data = []; + } + + data.unshift({ id: "", text: ""}) + + $eventSelect2.select2({ + placeholder: placeholder, + allowClear: true, + theme: 'bootstrap4', + language: this.get('i18n').display, + width: 'auto', + dropdownAutoWidth : true, + data: data, + containerCssClass: "flex-fill", + templateSelection: function (data, container) { + $(data.element).attr('data-key', data.key); + return data.text; + } + }); + + $eventSelect2.on("select2:select", function (e) { + let text= $(`#${id_select2} option:selected`).text(); + self.set('search', text); + self.set("buildermodSearchService.search", text); + }); + }), + didInsertElement: function() { + Ember.run.scheduleOnce('afterRender', this , function() { + + this.get("runSelectChained"); + this.get("buildermodSearchService.search"); + + }); + }, + update: observer('i18n.display', 'data_search', 'buildermodSearchService.search', function() { + + let type = this.get('type'); + + if(type === "chained"){ + } + else{ + let id_select = this.get('idSelect'); + var buildermodSearchService = this.get("buildermodSearchService.search"); + var $eventSelect = $(`#${id_select}`); + var placeholder = this.get("placeHolder"); + let type = this.get('type'); + var data = this.get('data_search'); + var self = this; + + if(placeholder === null){ + placeholder = this.get('i18n').t(`pageheader.search_placeholder.${type}`).string + } + + $eventSelect.select2({ + placeholder: placeholder, + allowClear: true, + theme: 'bootstrap4', + language: this.get('i18n').display, + width: 'auto', + dropdownAutoWidth : true, + data: data, + containerCssClass: "flex-fill", + templateSelection: function (data, container) { + $(data.element).attr('data-key', data.key); + return data.text; + } + }); + + let val = $eventSelect.find("option:contains('"+buildermodSearchService+"')").val(); + + if(val !== undefined){ + $eventSelect.val(val).trigger('change.select2'); + let text= $(`#${id_select} option:selected`).text(); + if (type === 'search') { + this.set('search', text); + } + } + + $eventSelect.on("select2:select", function (e) { + + let id = $eventSelect.val(); + let text= $(`#${id_select} option:selected`).text(); + + if(id !== ""){ + if(type === 'location') { + self.sendAction('transitionLocation', id); + } else if (type === 'product') { + self.sendAction('transitionProduct', id); + } else if (type === 'locations_route') { + self.sendAction('transitionLocationRoute', id); + } else if (type === 'industry') { + self.sendAction('transitionIndustry', id); + } else if (type === 'location-product') { + self.sendAction('transitionLocationProducts', id); + } else if (type === 'rural') { + + var key = $(`#${id_select}`).find(':selected').data("key").replace('-', '') + var action = `transition${key.charAt(0).toUpperCase() + key.slice(1)}` + + self.sendAction(action, id); + + } else if (type === 'search') { + self.set('search', text); + self.set("buildermodSearchService.search", text); + } + } + + }); + } + + }), + actions: { + reset: function() { + this.set('search', null); + this.set("buildermodSearchService.search", null); + + let id_select = this.get('idSelect'); + var $eventSelect = $(`#${id_select}`); + let id_select2 = this.get('idSelect2'); + var $eventSelect2 = $(`#${id_select2}`); + + $eventSelect.val(''); + $eventSelect.trigger('change'); + this.set("searchSelect1", null); + $eventSelect2.val(''); + $eventSelect2.trigger('change'); + } + } +}); diff --git a/app/components/autocomplete-input-datlas.js b/app/components/autocomplete-input-datlas.js new file mode 100644 index 00000000..a4005849 --- /dev/null +++ b/app/components/autocomplete-input-datlas.js @@ -0,0 +1,199 @@ +import Ember from 'ember'; +const {computed, get, observer} = Ember; + +export default Ember.Component.extend({ + i18n: Ember.inject.service(), + buildermodSearchService: Ember.inject.service(), + treemapService: Ember.inject.service(), + search: null, + placeHolder: null, + transitionProduct: 'transitionProduct', + transitionLocation: 'transitionLocation', + transitionLocationRoute: 'transitionLocationRoute', + transitionIndustry: 'transitionIndustry', + transitionLocationProducts: 'transitionLocationProducts', + transitionProductsRoute: 'transitionProductsRoute', + transitionAgproduct: 'transitionAgproduct', + transitionLivestock: 'transitionLivestock', + transitionNonag: 'transitionNonag', + transitionLanduse: 'transitionLanduse', + runSelect: computed('idSelect', 'data_search', 'placeHolder', 'search', 'i18n', function(){ + + let id_select = this.get('idSelect'); + var $eventSelect = $(`#${id_select}`); + let type = this.get('type'); + let self = this; + var data = this.get('data_search') + var placeholder = this.get("placeHolder") + + + $eventSelect.find('option').remove().end(); + $eventSelect.append($('