Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added maps to preferences #666

Merged
merged 8 commits into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/client/app/components/admin/PreferencesComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,19 @@ class PreferencesComponent extends React.Component<PreferencesPropsWithIntl, {}>
<FormattedMessage id='compare'/>
</label>
</div>
<div className='radio'>
<label>
<input
type='radio'
name='chartTypes'
style={{marginRight: '10px'}}
value={ChartTypes.map}
onChange={this.handleDefaultChartToRenderChange}
checked={this.props.defaultChartToRender === ChartTypes.map}
/>
<FormattedMessage id='map'/>
</label>
</div>
</div>
<div className='checkbox'>
<p style={labelStyle}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

ALTER TABLE meters
ADD COLUMN IF NOT EXISTS gps POINT DEFAULT NULL;
ADD COLUMN IF NOT EXISTS gps POINT DEFAULT NULL;
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
ALTER TABLE meters
ADD COLUMN IF NOT EXISTS identifier TEXT;

UPDATE meters SET identifier=name WHERE identifier IS NULL or identifier='';
UPDATE meters SET identifier=name WHERE identifier IS NULL or identifier='';
14 changes: 14 additions & 0 deletions src/server/migrations/0.7.0-0.7.1/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

const database = require('../../models/database');
const sqlFile = database.sqlFile;

module.exports = {
fromVersion: '0.7.0',
toVersion: '0.7.1',
up: async db => {
await db.none(sqlFile('../migrations/0.7.0-0.7.1/sql/preferences/alter_preferences_type.sql'));
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

-- See 0.6.0-0.7.0/add_meter_type.sql for more information on this migration.

-- Move the currently named type to a temporary name.
ALTER TYPE graph_type RENAME TO graph_type_temp;
-- Create the type desired with new value, 'other' in this case but need to include old ones.
CREATE TYPE graph_type as enum ('line', 'bar', 'compare', 'map');
-- Change the column in meters to use the new type with the current rows.
ALTER TABLE preferences ALTER COLUMN default_chart_to_render TYPE graph_type USING default_chart_to_render::text::graph_type;
-- Get rid of the old, temporary type that no longer needed.
DROP TYPE graph_type_temp;
3 changes: 2 additions & 1 deletion src/server/migrations/registerMigration.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const migrations = [
//require('./0.2.0-0.3.0-Template/indexTemplate'),
require('./0.3.0-0.5.0'),
require('./0.5.0-0.6.0'),
require('./0.6.0-0.7.0')
require('./0.6.0-0.7.0'),
require('./0.7.0-0.7.1')
/* eslint-disable global-require */
];

Expand Down
2 changes: 1 addition & 1 deletion src/server/sql/preferences/create_graph_types_enum.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
-- This should avoid an error when the type already exists. This is an issue since
-- the OED install stops the creation of database items after this.
DO $$ BEGIN
CREATE TYPE graph_type AS ENUM('line', 'bar', 'compare');
CREATE TYPE graph_type AS ENUM('line', 'bar', 'compare', 'map');
EXCEPTION
WHEN duplicate_object THEN null;
END $$;