diff --git a/README.md b/README.md
index 5ace2ee..b39392a 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,80 @@
- [Production](https://helix-calculator.sunpower.com/)
-### Setup
+## Local Development and Testing with Docker
+
+##### Dependencies
+
+- Docker: [docs.docker.com/engine/installation](https://docs.docker.com/engine/installation/)
+- CircleCi CLI: [Installing and using CircleCi locally](https://circleci.com/docs/2.0/local-jobs/#installing-the-cli-locally)
+
+- Current CircleCi and development image:
+[ivannnn/heroku-cedar14-extras:2.0](https://hub.docker.com/r/ivannnn/heroku-cedar14-extras/)
+
+| ivannnn/heroku-cedar14-extras:2.0 |
+| ------------- |
+| ruby 2.3.5p376 |
+| Python 3.5.4 |
+| postgresql-9.5 |
+| postgresql-client-9.5|
+| postgresql-client-9.6 |
+| postgresql-client-common |
+| postgresql-common |
+| postgresql-contrib-9.5 |
+| postgresql-server-dev-9.6 |
+| redis-server/trusty,now 2:2.8.4-2 amd64 |
+| redis-tools/trusty,now 2:2.8.4-2 amd64 |
+| google-chrome-stable/stable,now 62.0.3202.94-1 amd64 |
+| nodejs/unknown,now 6.12.0-1nodesource1 amd64 |
+
+##### Test locally with CircleCi
+
+- Go to the project dir
+- ```circleci build```
+
+##### Develop
+
+- Run the docker container for the 1st time
+
+```docker run -d --name helix -p 5000:5000 --expose 5000 -t ivannnn/heroku-cedar14-extras:2.0```
+
+- Or re start the docker conatiner
+
+```docker container start helix```
+
+- Copy the code to the container
+
+```docker cp . helix:project```
+
+- Log in the docker container
+
+```docker exec -t -i helix /bin/bash```
+
+- Run this commands inside the docker conatiner
+
+```
+cd project && \
+rm -rf env && \
+gem install bundler && \
+service postgresql start &&\
+service redis-server start &&\
+export PGPASSWORD=password &&\
+export CIRCLE_TEST_REPORTS=$(pwd) &&\
+python3.5 -m venv env &&\
+source env/bin/activate &&\
+pip install invoke &&\
+invoke install &&\
+npm install &&\
+invoke db_migrate
+```
+
+##### Important
+- Open another terminal tab, this script watches for changes and pass them
+to the docker conatiner, which will restart the web server
+```./watch.sh```
+
+
+## OS steps wihout Docker
#### macOS systems
diff --git a/circle.yml b/circle.yml
index 75441f5..46d87b6 100644
--- a/circle.yml
+++ b/circle.yml
@@ -1,58 +1,51 @@
-machine:
- python:
- version: 3.5.1
- node:
- version: 6.1.0
-
-dependencies:
- pre:
- - pip install invoke
- override:
- - invoke install
- - invoke update_version
-
-database:
- override:
- - createdb test
- - createdb pivotal
- - echo "CREATE ROLE pivotal WITH UNENCRYPTED PASSWORD 'password';" | psql -U postgres
- - echo "ALTER ROLE pivotal WITH LOGIN;" | psql -U postgres
- - echo "GRANT SELECT, UPDATE, INSERT ON ALL TABLES IN SCHEMA test.public TO pivotal;" | psql -U postgres
- - echo "GRANT CREATE, CONNECT ON DATABASE test TO pivotal;" | psql -U postgres
- - echo "GRANT SELECT, UPDATE, INSERT ON ALL TABLES IN SCHEMA pivotal.public TO pivotal;" | psql -U postgres
- - echo "GRANT CREATE, CONNECT ON DATABASE pivotal TO pivotal;" | psql -U postgres
- - PYTHONPATH=.:$PYTHONPATH alembic upgrade head
-
-test:
- override:
- - invoke test_ci
-
-deployment:
- staging:
- branch: master
- commands:
- - invoke update_heroku_version staging
- - "[[ ! -s \"$(git rev-parse --git-dir)/shallow\" ]] || git fetch --unshallow"
- - git push -f git@heroku.com:sp-helix-staging.git $CIRCLE_SHA1:refs/heads/master
- - heroku run --app sp-helix-staging invoke db_migrate
- - rake ci:deliver
- preprod:
- branch: preprod
- commands:
- - invoke update_heroku_version preprod
- - "[[ ! -s \"$(git rev-parse --git-dir)/shallow\" ]] || git fetch --unshallow"
- - git push -f git@heroku.com:sp-helix-preprod.git $CIRCLE_SHA1:refs/heads/master
- - heroku run --app sp-helix-preprod invoke db_migrate
- - rake ci:deliver
- production:
- tag: /release-.*/
- commands:
- - invoke update_heroku_version production
- - "[[ ! -s \"$(git rev-parse --git-dir)/shallow\" ]] || git fetch --unshallow"
- - git push -f git@heroku.com:sp-helix-production.git $CIRCLE_SHA1:refs/heads/master
- - heroku run --app sp-helix-production invoke db_migrate
- - rake ci:deliver
-
-notify:
- webhooks:
- - url: http://pulse.pivotallabs.com/projects/03ba990f-b8f5-4508-b4c1-19038b2cb791/status
+version: 2
+jobs:
+ build:
+ docker:
+ - image: ivannnn/heroku_cedar14:2.0
+ environment:
+ PGUSER: pivotal
+ PGPASSWORD: password
+ PASSWORD: password
+ environment:
+ PATH: /usr/local/rvm/gems/ruby-2.3.4/bin:/usr/local/rvm/gems/ruby-2.3.4@global/bin:/usr/local/rvm/rubies/ruby-2.3.4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/rvm/bin
+ steps:
+ - checkout
+ - run:
+ name: Set up and Run tests
+ command: |
+ source /etc/profile.d/rvm.sh
+ rvm use 2.3.4
+ /etc/init.d/postgresql start
+ python3.4 -m venv env
+ source env/bin/activate
+ pip install invoke
+ invoke install
+ npm install
+ invoke db_migrate
+ invoke test_ci
+ - deploy:
+ name: staging
+ command: |
+ invoke update_heroku_version staging
+ "[[ ! -s \"$(git rev-parse --git-dir)/shallow\" ]] || git fetch --unshallow"
+ git push -f git@heroku.com:sp-helix-staging.git $CIRCLE_SHA1:refs/heads/master
+ heroku run --app sp-helix-staging invoke db_migrate
+ rake ci:deliver
+ name: preprod
+ command: |
+ invoke update_heroku_version preprod
+ "[[ ! -s \"$(git rev-parse --git-dir)/shallow\" ]] || git fetch --unshallow"
+ git push -f git@heroku.com:sp-helix-preprod.git $CIRCLE_SHA1:refs/heads/master
+ heroku run --app sp-helix-preprod invoke db_migrate
+ rake ci:deliver
+ name: production
+ commands: |
+ invoke update_heroku_version production
+ "[[ ! -s \"$(git rev-parse --git-dir)/shallow\" ]] || git fetch --unshallow"
+ git push -f git@heroku.com:sp-helix-production.git $CIRCLE_SHA1:refs/heads/master
+ heroku run --app sp-helix-production invoke db_migrate
+ rake ci:deliver
+ notify:
+ webhooks:
+ - url: http://pulse.pivotallabs.com/projects/03ba990f-b8f5-4508-b4c1-19038b2cb791/status
diff --git a/helix/calculators/ebom_calculator.py b/helix/calculators/ebom_calculator.py
index 316a55d..e9113af 100644
--- a/helix/calculators/ebom_calculator.py
+++ b/helix/calculators/ebom_calculator.py
@@ -5,6 +5,8 @@ from helix.constants import ebom_parts
from helix.constants.ebom_parts import *
from helix.constants.parts import wire_clip_large, cable_support, cable_support_lid, channel_nut, sunshade
from helix.constants.system_type import SystemType
+from helix.constants.inverter_brand import InverterBrand
+from helix.forms.ebom_form import InverterBrandForm
class EbomCalculator(object):
@@ -36,11 +38,25 @@ class EbomCalculator(object):
monitors = self.values.power_monitors()
module_type = self.values.module_type()
system_type = self.values.system_type()
+
+ is_delta=None
+ try:
+ is_delta=(self.values.inverter_brands()[0]['inverter_brand_id']==InverterBrand.DELTA.value)
+ except IndexError :
+ #Some tests are calculating bom without providing inverter brand so inverter_brands is empty
+ #for those tests, inverter brand is irrelevant
+ is_delta=False
+
inverter_count = 0
total_ac_run_length = 0
panel_board_counts = [0, 0]
proper_monitor_controller = self.resolve_power_monitor_type()
+ try:
+ is_delta = (self.values.inverter_brands()[0]['inverter_brand_id']==InverterBrand.DELTA.value)
+ except IndexError:
+ is_delta = False
+
for power_station in power_stations:
power_station_count = power_station['power_station_quantity']
total_ac_run_length += power_station['ac_run_length']
@@ -75,6 +91,8 @@ class EbomCalculator(object):
for monitor in monitors:
if monitor['power_source'][0] == 'Switch Gear/External':
add_parts_to_list(part_list, {proper_monitor_controller: 1}, 1)
+ if (is_delta):
+ add_parts_to_list(part_list, {ethernet_plug: 2},1)
add_parts_to_list(part_list, {wire_clip_large: inverter_count}, self.row_count)
@@ -84,8 +102,9 @@ class EbomCalculator(object):
add_parts_to_list(part_list, {rear_skirt: -1}, ceil(cable_supports*.38))
dependent_part_list = {}
+
for part, quantity in part_list.items():
- dependent_parts = ebom_parts.dependent_parts(module_type, system_type).get(part)
+ dependent_parts = ebom_parts.dependent_parts(module_type, system_type,is_delta).get(part)
if dependent_parts:
add_parts_to_list(dependent_part_list, dependent_parts, quantity)
diff --git a/helix/constants/dual_tilt_parts.py b/helix/constants/dual_tilt_parts.py
index 0585786..7474ae2 100644
--- a/helix/constants/dual_tilt_parts.py
+++ b/helix/constants/dual_tilt_parts.py
@@ -18,32 +18,18 @@ class DualTiltParts(object):
}
def __init__(self, module_type):
- if module_type == ModuleType.PSeries:
- self.corner_panel_parts = {
- left_deflector_1_1: 1,
- right_deflector_1_1: 1,
- dual_tilt_chassis: 1.5,
- module: 2
- }
- self.north_south_panel_parts = {
- left_deflector_1_1: 1,
- right_deflector_1_1: 1,
- dual_tilt_chassis: 1.5,
- module: 2
- }
- else:
- self.corner_panel_parts = {
- left_deflector: 1,
- right_deflector: 1,
- dual_tilt_chassis: 1.5,
- module: 2
- }
- self.north_south_panel_parts = {
- left_deflector: 1,
- right_deflector: 1,
- dual_tilt_chassis: 1.5,
- module: 2
- }
+ self.corner_panel_parts = {
+ left_deflector_1_1: 1,
+ right_deflector_1_1: 1,
+ dual_tilt_chassis: 1.5,
+ module: 2
+ }
+ self.north_south_panel_parts = {
+ left_deflector_1_1: 1,
+ right_deflector_1_1: 1,
+ dual_tilt_chassis: 1.5,
+ module: 2
+ }
def row_parts(self, module_type):
if module_type == ModuleType.Cell96:
diff --git a/helix/constants/ebom_parts.py b/helix/constants/ebom_parts.py
index 2c7e55f..b1f0f7f 100644
--- a/helix/constants/ebom_parts.py
+++ b/helix/constants/ebom_parts.py
@@ -144,6 +144,7 @@ def standalone_inverter_parts(inverter, system_type, module_type):
phillips_screw: 4 * multiplier,
ac_inverter_bracket: 1 * multiplier,
hex_bolt_1_2: 4,
+ ethernet_plug: 1.8,
flat_washer_6: 4,
inverter_link_short: v1_1_inverter_links,
inverter_link_long: v1_1_inverter_links,
@@ -195,10 +196,30 @@ def inverter_parts(inverter, module_type):
stump: 6,
}
-def dependent_parts(module_type, system_type):
+def dependent_parts(module_type, system_type, is_delta):
v1_1_inverter_links = 0
if system_type == SystemType.singleTilt and (module_type == ModuleType.Cell128 or module_type == ModuleType.PSeries):
v1_1_inverter_links = 1
+
+ if is_delta:
+ monitor_controller_480_v_={
+ monitor_power_plug: 1,
+ }
+ else:
+ monitor_controller_480_v_={
+ monitor_power_plug: 1,
+ flat_washer: 4,
+ channel_nut: 4,
+ hex_nut_three_eighths_16: 2,
+ front_legs: 1,
+ back_legs: 1,
+ inverter_link: 2,
+ inverter_rail: 1,
+ rubber_foot: 3,
+ hex_bolt_1_2: 9,
+ mounting_back_plate: 1,
+ }
+
return {
panel_board_2: {
harness_ac_inner: 2,
@@ -246,19 +267,7 @@ def dependent_parts(module_type, system_type):
inverter_link_long: v1_1_inverter_links,
inverter_link: -2 * v1_1_inverter_links,
},
- monitor_controller_480_v: {
- monitor_power_plug: 1,
- flat_washer: 4,
- channel_nut: 4,
- hex_nut_three_eighths_16: 2,
- front_legs: 1,
- back_legs: 1,
- inverter_link: 2,
- inverter_rail: 1,
- rubber_foot: 3,
- hex_bolt_1_2: 9,
- mounting_back_plate: 1,
- },
+ monitor_controller_480_v: monitor_controller_480_v_,
monitor_controller_240_v: {},
ac_splice_box: {
hex_bolt_1_2: 4,
diff --git a/helix/constants/file_validation_error.py b/helix/constants/file_validation_error.py
index 3c042fb..339ff95 100644
--- a/helix/constants/file_validation_error.py
+++ b/helix/constants/file_validation_error.py
@@ -15,6 +15,7 @@ class FileValidationMessage(Enum):
ExpectedTxtFile = 'Invalid file uploaded. Please upload a valid .txt file.'
ExpectedDxfFile = 'Invalid file uploaded. Please upload a valid .dxf file.'
OldDxfFormat = 'Invalid Aurora format uploaded. Please upload a new format.'
+ PanelsTooClose = 'It appears that the panel coordinates are too close together. Please ensure that panel spacing is correct and that you have selected the correct configuration.'
@classmethod
def invalid_wind_zones(cls, system_type):
diff --git a/helix/constants/module_type_constants/dual_tilt_128_cell_constants.py b/helix/constants/module_type_constants/dual_tilt_128_cell_constants.py
index 1fd0931..616f75a 100644
--- a/helix/constants/module_type_constants/dual_tilt_128_cell_constants.py
+++ b/helix/constants/module_type_constants/dual_tilt_128_cell_constants.py
@@ -5,6 +5,7 @@ from helix.constants.panel_type import PanelType
class DualTilt128CellConstants(object):
+ tolerance = 0.1 #require 10% additional space for panel spacing
panel_spacing = (88.24, 82.0) # inches
spacing_size_inches = 5.12 # This is inches
presenter_spacing = (1.5, 1.5)
diff --git a/helix/constants/module_type_constants/dual_tilt_96_cell_constants.py b/helix/constants/module_type_constants/dual_tilt_96_cell_constants.py
index 3a3d15a..a1273db 100644
--- a/helix/constants/module_type_constants/dual_tilt_96_cell_constants.py
+++ b/helix/constants/module_type_constants/dual_tilt_96_cell_constants.py
@@ -5,6 +5,7 @@ from helix.constants.panel_type import PanelType
class DualTilt96CellConstants(object):
+ tolerance = 0.1 #require 10% additional space for panel spacing
panel_spacing = (88.24, 62.0) # inches
spacing_size_inches = 5.12 # This is inches
presenter_spacing = (1.5, 1)
diff --git a/helix/constants/module_type_constants/dual_tilt_pseries_constants.py b/helix/constants/module_type_constants/dual_tilt_pseries_constants.py
index 542aac0..647001f 100644
--- a/helix/constants/module_type_constants/dual_tilt_pseries_constants.py
+++ b/helix/constants/module_type_constants/dual_tilt_pseries_constants.py
@@ -5,6 +5,7 @@ from helix.constants.panel_type import PanelType
class DualTiltPSeriesConstants(object):
+ tolerance = 0.1 #require 10% additional space for panel spacing
panel_spacing = (88.24, 82.0) # inches
spacing_size_inches = 8.8503937 # This is inches
presenter_spacing = (1.5, 1.5)
diff --git a/helix/constants/module_type_constants/single_tilt_128_cell_constants.py b/helix/constants/module_type_constants/single_tilt_128_cell_constants.py
index 613eb31..2815154 100644
--- a/helix/constants/module_type_constants/single_tilt_128_cell_constants.py
+++ b/helix/constants/module_type_constants/single_tilt_128_cell_constants.py
@@ -8,6 +8,7 @@ from helix.constants.system_type_constants.single_tilt_constants import SingleTi
class SingleTilt128CellConstants(object):
+ tolerance = 0.1 #require 10% additional space for panel spacing
panel_spacing = (82.0, 60.0) # inches
presenter_spacing = (1.5, 1)
panel_area = 23.29
diff --git a/helix/constants/module_type_constants/single_tilt_96_cell_constants.py b/helix/constants/module_type_constants/single_tilt_96_cell_constants.py
index 5e69666..de639fd 100644
--- a/helix/constants/module_type_constants/single_tilt_96_cell_constants.py
+++ b/helix/constants/module_type_constants/single_tilt_96_cell_constants.py
@@ -7,6 +7,7 @@ from helix.constants.system_type_constants.single_tilt_constants import SingleTi
class SingleTilt96CellConstants(object):
+ tolerance = 0.1 #require 10% additional space for panel spacing
panel_spacing = (62.0, 60.0) # inches
presenter_spacing = (1, 1)
panel_area = 17.58
diff --git a/helix/constants/module_type_constants/single_tilt_pseries_constants.py b/helix/constants/module_type_constants/single_tilt_pseries_constants.py
index 43d316f..0e50141 100644
--- a/helix/constants/module_type_constants/single_tilt_pseries_constants.py
+++ b/helix/constants/module_type_constants/single_tilt_pseries_constants.py
@@ -7,6 +7,7 @@ from helix.constants.system_type_constants.single_tilt_constants import SingleTi
class SingleTiltPSeriesConstants(object):
+ tolerance = 0.1 #require 10% additional space for panel spacing
panel_spacing = (82.0, 61.8755) # inches
presenter_spacing = (1.5, 1)
panel_area = 22.22
diff --git a/helix/constants/parts.py b/helix/constants/parts.py
index d7f01a4..4afbac7 100644
--- a/helix/constants/parts.py
+++ b/helix/constants/parts.py
@@ -5,8 +5,6 @@ dual_tilt_chassis = ('514056', 'BASE, CHASSIS, DUAL TILT, HELIX ROOF')
dual_tilt_platform = ('514057', 'PLATFORM, CHASSIS, DUAL TILT, HELIX ROOF')
platform_bolt = ('515063', 'SCREW, CAP, SH, M6 X 1 X 12, 18-8 SS (DIN 912)')
-left_deflector = ('513841', 'DEFLECTOR, LH, HELIX ROOF')
-right_deflector = ('513842', 'DEFLECTOR, RH, HELIX ROOF')
front_skirt = ('515928', 'FRONT SKIRT, HELIX ROOF')
rear_skirt = ('515929', 'REAR SKIRT, HELIX ROOF')
spoiler = ('513836', 'SPOILER, SINGLE TILT, HELIX ROOF')
@@ -59,10 +57,10 @@ inverter_link_long = ('521797', 'LINK TO ARRAY, SHORT, INVERTER RACK, HELIX ROOF
mounting_back_plate = ('518331', 'MOUNTING BACK PLATE, INVERTER/PANEL BOARD, HELIX ROOF/TRACKER')
-sma_12kw_inverter = ('514686', 'INVERTER, SMA, STP, 12000TL-US-10 (SPR-12000m-3 XXX), AFCI, CONNECTORIZED')
-sma_15kw_inverter = ('514687', 'INVERTER, SMA, STP, 15000TL-US-10 (SPR-15000m-3 XXX), AFCI, CONNECTORIZED')
-sma_20kw_inverter = ('512676', 'INVERTER, SMA, STP, 20000TL-US-10 (SPR-20000m-3 XXX), AFCI, CONNECTORIZED')
-sma_24kw_inverter = ('514685', 'INVERTER, SMA, STP, 24000TL-US-10 (SPR-24000m-3 XXX), AFCI, CONNECTORIZED')
+sma_12kw_inverter = ('523921', 'INVERTER, SMA, STP, 20000TL-US-10 (SPR-20000m-3-H), AFCI, CONNECTORIZED, UTX XL REV D DC CONNECTORS')
+sma_15kw_inverter = ('523922', 'INVERTER, SMA, STP, 24000TL-US-10 (SPR-24000m-3-H), AFCI, CONNECTORIZED, UTX XL REV D DC CONNECTORS')
+sma_20kw_inverter = ('523923', 'INVERTER, SMA, STP, 12000TL-US-10 (SPR-12000m-3-H), AFCI, CONNECTORIZED, UTX XL REV D DC CONNECTORS')
+sma_24kw_inverter = ('523924', 'INVERTER, SMA, STP, 15000TL-US-10 (SPR-15000m-3-H), AFCI, CONNECTORIZED, UTX XL REV D DC CONNECTORS')
delta_36kw_inverter = ('524952', 'INVERTER, DELTA, M36U_122(MC4), 10INPUT, 36KW, 3PH 480V AC,1000V DC')
delta_42kw_inverter = ('524969', 'INVERTER, DELTA, M42U_122(MC4), 12INPUT, 42KW, 3PH 480V AC,1000V DC')
@@ -159,8 +157,6 @@ all_parts = [
dual_tilt_chassis,
dual_tilt_platform,
platform_bolt,
- left_deflector,
- right_deflector,
front_skirt,
rear_skirt,
spoiler,
diff --git a/helix/constants/single_tilt_parts.py b/helix/constants/single_tilt_parts.py
index ade1fcb..fe98e1c 100644
--- a/helix/constants/single_tilt_parts.py
+++ b/helix/constants/single_tilt_parts.py
@@ -18,32 +18,19 @@ class SingleTiltParts(object):
}
def __init__(self, module_type):
- if module_type == ModuleType.PSeries:
- self.corner_panel_parts = {
- module: 1,
- single_tilt_chassis: 1,
- left_deflector_1_1: 0.5,
- right_deflector_1_1: 0.5,
- }
- self.east_west_panel_parts = {
- module: 1,
- single_tilt_chassis: 1.5,
- left_deflector_1_1: 0.5,
- right_deflector_1_1: 0.5
- }
- else:
- self.corner_panel_parts = {
- module: 1,
- single_tilt_chassis: 1,
- left_deflector: 0.5,
- right_deflector: 0.5
- }
- self.east_west_panel_parts = {
- module: 1,
- single_tilt_chassis: 1.5,
- left_deflector: 0.5,
- right_deflector: 0.5
- }
+ self.corner_panel_parts = {
+ module: 1,
+ single_tilt_chassis: 1,
+ left_deflector_1_1: 0.5,
+ right_deflector_1_1: 0.5,
+ }
+ self.east_west_panel_parts = {
+ module: 1,
+ single_tilt_chassis: 1.5,
+ left_deflector_1_1: 0.5,
+ right_deflector_1_1: 0.5
+ }
+
def row_parts(self, _):
return {}
diff --git a/helix/javascript/array_summary/array_visualization.js b/helix/javascript/array_summary/array_visualization.js
index 0ecdf0c..5ce3920 100644
--- a/helix/javascript/array_summary/array_visualization.js
+++ b/helix/javascript/array_summary/array_visualization.js
@@ -9,7 +9,10 @@ class ArrayVisualization {
this.isDualTilt = isDualTilt;
this.subarrayDisplay = subarrayDisplay;
this.buildings = buildings;
+
+ // Default options
this.scale = 10;
+ this.panels = [];
}
init() {
@@ -22,12 +25,12 @@ class ArrayVisualization {
this.stage.mouseMoveOutside = true;
this.adjustScale(this.buildings);
- this.drawArray(this.container, this.panelData, this.scale);
+ this.drawArray(this.container, this.panelData);
this.container.x = 0;
this.container.y = 0;
this.stage.addChild(this.container);
- this.drawBuildings(this.buildings,this.scale);
+ this.drawBuildings(this.buildings, this.scale);
this.stage.update();
@@ -76,13 +79,13 @@ class ArrayVisualization {
}
- drawBuildings(buildings, scale) {
- if (!buildings) {
+ drawBuildings(buildings) {
+ if (!buildings || buildings.length === 0) {
console.log("No Buildings!");
return;
}
- if (!scale) {
+ if (!this.scale) {
console.log("No Scale - don't know how big the buildings should be!");
return;
}
@@ -99,14 +102,14 @@ class ArrayVisualization {
line.graphics.beginStroke(color);
- line.graphics.moveTo(firstPoint.x * scale, firstPoint.y * scale);
+ line.graphics.moveTo(firstPoint.x * this.scale, firstPoint.y * this.scale);
for (let j = 1; j < building.length; j++ ) {
nextPoint = building[j];
- line.graphics.lineTo(nextPoint.x * scale ,nextPoint.y * scale);
- line.graphics.moveTo(nextPoint.x * scale,nextPoint.y * scale);
+ line.graphics.lineTo(nextPoint.x * this.scale, nextPoint.y * this.scale);
+ line.graphics.moveTo(nextPoint.x * this.scale, nextPoint.y * this.scale);
}
- line.graphics.lineTo(firstPoint.x * scale, firstPoint.y * scale );
+ line.graphics.lineTo(firstPoint.x * this.scale, firstPoint.y * this.scale );
line.graphics.endStroke();
}
@@ -121,7 +124,7 @@ class ArrayVisualization {
this.container.removeChild(this.panels[i]);
}
- this.drawArray(this.container, this.panelData, this.scale);
+ this.drawArray(this.container, this.panelData);
let selectedPanel = this.selectedPanel;
this.selectedPanel = undefined;
@@ -134,18 +137,14 @@ class ArrayVisualization {
}
drawArray(container, panels) {
- this.panels = [];
let treatCoordinatesAsCenterpoints = this.buildings && this.buildings.length > 0;
for (let i = 0; i < panels.length; i++) {
- let panel = panels[i];
-
- let box = new Panel(panel, this.isDualTilt, this.scale, treatCoordinatesAsCenterpoints);
+ let box = new Panel(panels[i], this.isDualTilt, this.scale, treatCoordinatesAsCenterpoints);
container.addChild(box);
this.panels.push(box);
- let self = this;
- box.on("click", function () {
- self.selectPanel(i);
+ box.on("click", () => {
+ this.selectPanel(i);
});
}
}
diff --git a/helix/presenters/panel_presenter.py b/helix/presenters/panel_presenter.py
index cef976c..c601500 100644
--- a/helix/presenters/panel_presenter.py
+++ b/helix/presenters/panel_presenter.py
@@ -48,14 +48,11 @@ class ProjectPresenter(object):
# Move coordinates to reflect origin being at top-left
# (as per canvas) instead of bottom-left
- # if max_y is not passed - use the panels instead of buildings
- if max_y is None:
- height = max(map(lambda row: row['y'], table_data))
- else:
- height = max_y
+ height = max(map(lambda row: row['y'], table_data))
+ first_cell = min(map(lambda row: row['y'], table_data))
self.offset = height
for panel in table_data:
- panel['y'] = height - panel['y']
+ panel['y'] = height - panel['y'] + first_cell
return table_data
def get_buildings(self, buildings):
@@ -76,10 +73,6 @@ class ProjectPresenter(object):
point.y = point.y * spacing_y
presentable_building.append(point.__dict__)
- for presentable_building in result:
- for point in presentable_building:
- point['y'] = self.offset - point['y']
-
return result
def get_max_y(self,buildings, panels):
diff --git a/helix/static/javascripts/array_summary_bundle.js b/helix/static/javascripts/array_summary_bundle.js
index 070323f..639096c 100644
--- a/helix/static/javascripts/array_summary_bundle.js
+++ b/helix/static/javascripts/array_summary_bundle.js
@@ -122,7 +122,10 @@
this.isDualTilt = isDualTilt;
this.subarrayDisplay = subarrayDisplay;
this.buildings = buildings;
+
+ // Default options
this.scale = 10;
+ this.panels = [];
}
_createClass(ArrayVisualization, [{
@@ -137,7 +140,7 @@
this.stage.mouseMoveOutside = true;
this.adjustScale(this.buildings);
- this.drawArray(this.container, this.panelData, this.scale);
+ this.drawArray(this.container, this.panelData);
this.container.x = 0;
this.container.y = 0;
this.stage.addChild(this.container);
@@ -200,13 +203,13 @@
}
}, {
key: 'drawBuildings',
- value: function drawBuildings(buildings, scale) {
- if (!buildings) {
+ value: function drawBuildings(buildings) {
+ if (!buildings || buildings.length === 0) {
console.log("No Buildings!");
return;
}
- if (!scale) {
+ if (!this.scale) {
console.log("No Scale - don't know how big the buildings should be!");
return;
}
@@ -223,14 +226,14 @@
line.graphics.beginStroke(color);
- line.graphics.moveTo(firstPoint.x * scale, firstPoint.y * scale);
+ line.graphics.moveTo(firstPoint.x * this.scale, firstPoint.y * this.scale);
for (var j = 1; j < building.length; j++) {
nextPoint = building[j];
- line.graphics.lineTo(nextPoint.x * scale, nextPoint.y * scale);
- line.graphics.moveTo(nextPoint.x * scale, nextPoint.y * scale);
+ line.graphics.lineTo(nextPoint.x * this.scale, nextPoint.y * this.scale);
+ line.graphics.moveTo(nextPoint.x * this.scale, nextPoint.y * this.scale);
}
- line.graphics.lineTo(firstPoint.x * scale, firstPoint.y * scale);
+ line.graphics.lineTo(firstPoint.x * this.scale, firstPoint.y * this.scale);
line.graphics.endStroke();
}
@@ -245,7 +248,7 @@
this.container.removeChild(this.panels[i]);
}
- this.drawArray(this.container, this.panelData, this.scale);
+ this.drawArray(this.container, this.panelData);
var selectedPanel = this.selectedPanel;
this.selectedPanel = undefined;
@@ -261,19 +264,15 @@
value: function drawArray(container, panels) {
var _this2 = this;
- this.panels = [];
var treatCoordinatesAsCenterpoints = this.buildings && this.buildings.length > 0;
var _loop = function _loop(i) {
- var panel = panels[i];
-
- var box = new _panel.Panel(panel, _this2.isDualTilt, _this2.scale, treatCoordinatesAsCenterpoints);
+ var box = new _panel.Panel(panels[i], _this2.isDualTilt, _this2.scale, treatCoordinatesAsCenterpoints);
container.addChild(box);
_this2.panels.push(box);
- var self = _this2;
box.on("click", function () {
- self.selectPanel(i);
+ _this2.selectPanel(i);
});
};
diff --git a/helix/templates/layout.html.jinja b/helix/templates/layout.html.jinja
index c261023..c2f9540 100644
--- a/helix/templates/layout.html.jinja
+++ b/helix/templates/layout.html.jinja
@@ -8,6 +8,9 @@
+
{% if context['google_analytics_token'] %}