From 35f6eebeb631a5ef944d331e2194bbd02fc7f5bf Mon Sep 17 00:00:00 2001 From: Dominic H Date: Thu, 15 Aug 2019 14:28:27 +0100 Subject: [PATCH 01/93] Sustainability sub categories for launch #360 - Tested on local db --- migrations/011.sustainability.down.sql | 26 ++++++++++++ migrations/012.sustainability.up.sql | 58 ++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 migrations/011.sustainability.down.sql create mode 100644 migrations/012.sustainability.up.sql diff --git a/migrations/011.sustainability.down.sql b/migrations/011.sustainability.down.sql new file mode 100644 index 00000000..252ed0b3 --- /dev/null +++ b/migrations/011.sustainability.down.sql @@ -0,0 +1,26 @@ +-- Remove sustainability fields, update in paralell with adding new fields +-- BREEAM rating +ALTER TABLE buildings DROP COLUMN IF EXISTS sust_breeam_rating; +-- BREEAM date +ALTER TABLE buildings DROP COLUMN IF EXISTS sust_breeam_date; + +-- DEC (display energy certifcate, only applies to non domestic buildings) +ALTER TABLE buildings DROP COLUMN IF EXISTS sust_dec; +-- DEC date +ALTER TABLE buildings DROP COLUMN IF EXISTS sust_dec_date; + +--TODO: DEC certifcate number, is there an online store for these? + +-- Aggregate EPC rating (Estimated) for a building, derived from inidividual certificates +ALTER TABLE buildings DROP COLUMN IF EXISTS sust_aggregate_estimate_epc; + +-- Last significant retrofit date YYYY +ALTER TABLE buildings DROP COLUMN IF EXISTS sust_retrofit_date; + +--TODO : Embodied carbon + +--TODO : Life expectancy minimum + +--TODO : Average lifespan for typology + +--TODO : Adaptability rating diff --git a/migrations/012.sustainability.up.sql b/migrations/012.sustainability.up.sql new file mode 100644 index 00000000..1be3da7f --- /dev/null +++ b/migrations/012.sustainability.up.sql @@ -0,0 +1,58 @@ +-- BREEAM ratings, one of: +-- - Outstanding +-- - Excellent +-- - Very good +-- - Good +-- - Pass +-- - Unclassified +CREATE TYPE sust_breeam_rating +AS ENUM ('Outstanding', + 'Excellent', + 'Very good', + 'Good', + 'Pass', + 'Unclassified'); + +ALTER TABLE buildings + ADD COLUMN IF NOT EXISTS sust_breeam_rating sust_breeam_rating DEFAULT 'Unclassified'; + +-- Date of BREEAM +ALTER TABLE buildings + ADD COLUMN IF NOT EXISTS sust_breeam_date smallint; + +-- DEC (display energy certifcate, only applies to non domestic buildings) +-- A - G +CREATE TYPE sust_dec +AS ENUM ('A', + 'B', + 'C', + 'D', + 'E', + 'F', + 'G'); + +-- Date of DEC YYYY +ALTER TABLE buildings + ADD COLUMN IF NOT EXISTS sust_dec_date smallint; + + +ALTER TABLE buildings + ADD COLUMN IF NOT EXISTS sust_dec sust_dec; + +-- Aggregate EPC rating (Estimated) for a building, derived from inidividual certificates +-- A+ - G +CREATE TYPE sust_aggregate_estimate_epc +AS ENUM ('A', + 'B', + 'C', + 'D', + 'E', + 'F', + 'G'); + +ALTER TABLE buildings + ADD COLUMN IF NOT EXISTS sust_aggregate_estimate_epc sust_aggregate_estimate_epc; + +-- Last significant retrofit date YYYY +ALTER TABLE buildings + ADD COLUMN IF NOT EXISTS sust_retrofit_date smallint; From 7cc358dcb7c1153bedc89730a890537014b50899 Mon Sep 17 00:00:00 2001 From: Maciej Ziarkowski Date: Thu, 22 Aug 2019 15:56:04 +0100 Subject: [PATCH 02/93] Introduce env variable for webapp origin --- app/src/api/controllers/userController.ts | 11 +++++++++-- ecosystem.config.dev-template.js | 1 + ecosystem.config.template.js | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/api/controllers/userController.ts b/app/src/api/controllers/userController.ts index 9a2b1004..ecde5ee9 100644 --- a/app/src/api/controllers/userController.ts +++ b/app/src/api/controllers/userController.ts @@ -72,8 +72,7 @@ async function resetPassword(req: express.Request, res: express.Response) { if(req.body.email != undefined) { // first stage: send reset token to email address - // this relies on the API being on the same hostname as the frontend - const { origin } = new URL(req.protocol + '://' + req.headers.host); + const origin = getWebAppOrigin(); await passwordResetService.sendPasswordResetToken(req.body.email, origin); return res.status(202).send({ success: true }); @@ -96,6 +95,14 @@ async function resetPassword(req: express.Request, res: express.Response) { } } +function getWebAppOrigin() : string { + const origin = process.env.WEBAPP_ORIGIN; + if (origin == undefined) { + throw new Error('WEBAPP_ORIGIN not defined'); + } + return origin; +} + export default { createUser, getCurrentUser, diff --git a/ecosystem.config.dev-template.js b/ecosystem.config.dev-template.js index 02e13a4f..5c26ec70 100644 --- a/ecosystem.config.dev-template.js +++ b/ecosystem.config.dev-template.js @@ -25,6 +25,7 @@ module.exports = { MAIL_SERVER_PORT: 587, MAIL_SERVER_USER: "mail_username", MAIL_SERVER_PASSWORD: "longrandompassword", + WEBAPP_ORIGIN: "http://localhost:3000", } } ] diff --git a/ecosystem.config.template.js b/ecosystem.config.template.js index 695440d5..34b454d7 100644 --- a/ecosystem.config.template.js +++ b/ecosystem.config.template.js @@ -22,6 +22,7 @@ module.exports = { MAIL_SERVER_PORT: 587, MAIL_SERVER_USER: "mail_username", MAIL_SERVER_PASSWORD: "longrandompassword", + WEBAPP_ORIGIN: "https://beta.colouring.london", } } ] From a5447e6ee3960a63681d7255cc664d14fe67bf79 Mon Sep 17 00:00:00 2001 From: Tom Russell Date: Wed, 14 Aug 2019 08:28:15 +0100 Subject: [PATCH 03/93] Use React.FunctionComponent when typing --- app/src/frontend/building-edit.tsx | 6 +++--- app/src/frontend/building-view.tsx | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/frontend/building-edit.tsx b/app/src/frontend/building-edit.tsx index e7cc9eb8..f062ff63 100644 --- a/app/src/frontend/building-edit.tsx +++ b/app/src/frontend/building-edit.tsx @@ -70,7 +70,7 @@ class EditForm extends Component { // TODO: add proper types for (const field of props.fields) { fieldsObj[field.slug] = props[field.slug]; } - + this.state = { error: this.props.error || undefined, like: this.props.like || undefined, @@ -591,7 +591,7 @@ class YearEstimator extends Component { // TODO: add proper types toggleCopyAttribute: PropTypes.func, copying: PropTypes.bool }; - + constructor(props) { super(props); this.state = { @@ -680,7 +680,7 @@ LikeButton.propTypes = { handleLike: PropTypes.func } -const Label: React.SFC = (props) => { // TODO: remove any +const Label: React.FunctionComponent = (props) => { // TODO: remove any return (