Skip to content

Commit

Permalink
misc changes
Browse files Browse the repository at this point in the history
- Made variable names consistent with not being a global constant.
- formatting
  • Loading branch information
huss committed Dec 3, 2023
1 parent 3413c3a commit c8148aa
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 59 deletions.
2 changes: 1 addition & 1 deletion src/client/app/actions/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function updateDefaultMeterDisableChecks(defaultMeterDisableChecks: boole
}

export function updateDefaultHelpUrl(defaultHelpUrl: string): t.UpdateDefaultHelpUrlAction {
return {type: ActionType.UpdateDefaultHelpUrl, defaultHelpUrl}
return { type: ActionType.UpdateDefaultHelpUrl, defaultHelpUrl }
}

function requestPreferences(): t.RequestPreferencesAction {
Expand Down
6 changes: 3 additions & 3 deletions src/client/app/components/HeaderButtonsComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ export default function HeaderButtonsComponent() {

// OED version is needed for help redirect
const version = useSelector((state: State) => state.version.version);
const BASE_URL = useSelector((state: State) => state.admin.defaultHelpUrl);
const baseHelpUrl = useSelector((state: State) => state.admin.defaultHelpUrl);
// Help URL location
let helpUrl = BASE_URL + version;
let helpUrl = baseHelpUrl + version;
// options help
const optionsHelp = helpUrl + '/optionsMenu.html';

Expand Down Expand Up @@ -85,7 +85,7 @@ export default function HeaderButtonsComponent() {

// Must update in case the version was not set when the page was loaded.
useEffect(() => {
helpUrl = BASE_URL + version;
helpUrl = baseHelpUrl + version;
setState(prevState => ({
...prevState,
pageChoicesHelp: helpUrl
Expand Down
7 changes: 3 additions & 4 deletions src/client/app/components/LanguageSelectorComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/* 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/. */
Expand All @@ -20,9 +19,9 @@ export default function LanguageSelectorComponent() {

const selectedLanguage = useSelector((state: State) => state.options.selectedLanguage);
const version = useSelector((state: State) => state.version.version);
const BASE_URL = useSelector((state: State) => state.admin.defaultHelpUrl);
const baseHelpUrl = useSelector((state: State) => state.admin.defaultHelpUrl);

const HELP_URL = BASE_URL + version;
const helpUrl = baseHelpUrl + version;

return (
<>
Expand All @@ -48,7 +47,7 @@ export default function LanguageSelectorComponent() {
</DropdownItem>
<DropdownItem divider />
<DropdownItem
href={HELP_URL + '/language.html'}>
href={helpUrl + '/language.html'}>
<FormattedMessage id="help" />
</DropdownItem>
</DropdownMenu>
Expand Down
86 changes: 43 additions & 43 deletions src/client/app/components/TooltipHelpComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import { FormattedMessage } from 'react-intl';
import ReactTooltip from 'react-tooltip';
import '../styles/tooltip.css';
import translate from '../utils/translate';

interface TooltipHelpProps {
page: string; // Specifies which page the tip is in.
version: string;
BASE_URL: string;
baseHelpUrl: string;
fetchVersionIfNeeded(): Promise<any>;
}

Expand All @@ -22,61 +23,60 @@ export default class TooltipHelpComponent extends React.Component<TooltipHelpPro
super(props);
this.props.fetchVersionIfNeeded();
}

/**
* @returns JSX to create the help icons with links
*/

public render() {
const divStyle = {
display: 'inline-block'
};

const version = this.props.version
const BASE_URL = this.props.BASE_URL

const HELP_URL = BASE_URL + version;
const baseHelpUrl = this.props.baseHelpUrl
const helpUrl = baseHelpUrl + version;

const helpLinks: Record<string, Record<string, string>> = {
'help.admin.conversioncreate': { link: `${HELP_URL}/adminConversionCreating.html` },
'help.admin.conversionedit': { link: `${HELP_URL}/adminConversionEditing.html` },
'help.admin.conversionview': { link: `${HELP_URL}/adminConversionViewing.html` },
'help.admin.groupcreate': { link: `${HELP_URL}/adminGroupCreating.html` },
'help.admin.groupedit': { link: `${HELP_URL}/adminGroupEditing.html` },
'help.admin.groupview': { link: `${HELP_URL}/adminGroupViewing.html` },
'help.admin.header': { link: `${HELP_URL}/adminPreferences.html` },
'help.admin.mapview': { link: `${HELP_URL}/adminMapViewing.html` },
'help.admin.metercreate': { link: `${HELP_URL}/adminMeterCreating.html` },
'help.admin.meteredit': { link: `${HELP_URL}/adminMeterEditing.html` },
'help.admin.meterview': { link: `${HELP_URL}/adminMeterViewing.html` },
'help.admin.unitcreate': { link: `${HELP_URL}/adminUnitCreating.html` },
'help.admin.unitedit': { link: `${HELP_URL}/adminUnitEditing.html` },
'help.admin.unitview': { link: `${HELP_URL}/adminUnitViewing.html` },
'help.admin.user': { link: `${HELP_URL}/adminUser.html` },
'help.csv.header': { link: `${HELP_URL}/adminDataAcquisition.html` },
'help.home.area.normalize': { link: `${HELP_URL}/areaNormalization.html` },
'help.home.bar.custom.slider.tip': { link: `${HELP_URL}/barGraphic.html#usage` },
'help.home.bar.interval.tip': { link: `${HELP_URL}/barGraphic.html#usage` },
'help.home.bar.stacking.tip': { link: `${HELP_URL}/barGraphic.html#barStacking` },
'help.admin.conversioncreate': { link: `${helpUrl}/adminConversionCreating.html` },
'help.admin.conversionedit': { link: `${helpUrl}/adminConversionEditing.html` },
'help.admin.conversionview': { link: `${helpUrl}/adminConversionViewing.html` },
'help.admin.groupcreate': { link: `${helpUrl}/adminGroupCreating.html` },
'help.admin.groupedit': { link: `${helpUrl}/adminGroupEditing.html` },
'help.admin.groupview': { link: `${helpUrl}/adminGroupViewing.html` },
'help.admin.header': { link: `${helpUrl}/adminPreferences.html` },
'help.admin.mapview': { link: `${helpUrl}/adminMapViewing.html` },
'help.admin.metercreate': { link: `${helpUrl}/adminMeterCreating.html` },
'help.admin.meteredit': { link: `${helpUrl}/adminMeterEditing.html` },
'help.admin.meterview': { link: `${helpUrl}/adminMeterViewing.html` },
'help.admin.unitcreate': { link: `${helpUrl}/adminUnitCreating.html` },
'help.admin.unitedit': { link: `${helpUrl}/adminUnitEditing.html` },
'help.admin.unitview': { link: `${helpUrl}/adminUnitViewing.html` },
'help.admin.user': { link: `${helpUrl}/adminUser.html` },
'help.csv.header': { link: `${helpUrl}/adminDataAcquisition.html` },
'help.home.area.normalize': { link: `${helpUrl}/areaNormalization.html` },
'help.home.bar.custom.slider.tip': { link: `${helpUrl}/barGraphic.html#usage` },
'help.home.bar.interval.tip': { link: `${helpUrl}/barGraphic.html#usage` },
'help.home.bar.stacking.tip': { link: `${helpUrl}/barGraphic.html#barStacking` },
'help.home.chart.plotly.controls': { link: 'https://plotly.com/chart-studio-help/getting-to-know-the-plotly-modebar/' },
'help.home.chart.redraw.restore': { link: `${HELP_URL}/lineGraphic.html#redrawRestore` },
'help.home.chart.select': { link: `${HELP_URL}/graphType.html` },
'help.home.compare.interval.tip': { link: `${HELP_URL}/compareGraphic.html#usage` },
'help.home.compare.sort.tip': { link: `${HELP_URL}/compareGraphic.html#usage` },
'help.home.error.bar': { link: `${HELP_URL}/errorBar.html#usage` },
'help.home.export.graph.data': { link: `${HELP_URL}/export.html` },
'help.home.map.interval.tip': { link: `${HELP_URL}/mapGraphic.html#usage` },
'help.home.chart.redraw.restore': { link: `${helpUrl}/lineGraphic.html#redrawRestore` },
'help.home.chart.select': { link: `${helpUrl}/graphType.html` },
'help.home.compare.interval.tip': { link: `${helpUrl}/compareGraphic.html#usage` },
'help.home.compare.sort.tip': { link: `${helpUrl}/compareGraphic.html#usage` },
'help.home.error.bar': { link: `${helpUrl}/errorBar.html#usage` },
'help.home.export.graph.data': { link: `${helpUrl}/export.html` },
'help.home.map.interval.tip': { link: `${helpUrl}/mapGraphic.html#usage` },
'help.home.navigation': { link: '' },
'help.home.select.dateRange': { link: `${HELP_URL}/dateRange.html` },
'help.home.select.groups': { link: `${HELP_URL}/graphingGroups.html` },
'help.home.select.maps': { link: `${HELP_URL}/mapGraphic.html` },
'help.home.select.meters': { link: `${HELP_URL}/graphingMeters.html` },
'help.home.select.rates': { link: `${HELP_URL}/graphingRates.html` },
'help.home.select.units': { link: `${HELP_URL}/graphingUnits.html` },
'help.home.readings.per.day': { link: `${HELP_URL}/readingsPerDay.html` },
'help.home.toggle.chart.link': { link: `${HELP_URL}/chartLink.html` },
'help.groups.groupdetails': { link: `${HELP_URL}/groupViewing.html#groupDetails` },
'help.groups.groupview': { link: `${HELP_URL}/groupViewing.html` },
'help.meters.meterview': { link: `${HELP_URL}/meterViewing.html` }
'help.home.select.dateRange': { link: `${helpUrl}/dateRange.html` },
'help.home.select.groups': { link: `${helpUrl}/graphingGroups.html` },
'help.home.select.maps': { link: `${helpUrl}/mapGraphic.html` },
'help.home.select.meters': { link: `${helpUrl}/graphingMeters.html` },
'help.home.select.rates': { link: `${helpUrl}/graphingRates.html` },
'help.home.select.units': { link: `${helpUrl}/graphingUnits.html` },
'help.home.readings.per.day': { link: `${helpUrl}/readingsPerDay.html` },
'help.home.toggle.chart.link': { link: `${helpUrl}/chartLink.html` },
'help.groups.groupdetails': { link: `${helpUrl}/groupViewing.html#groupDetails` },
'help.groups.groupview': { link: `${helpUrl}/groupViewing.html` },
'help.meters.meterview': { link: `${helpUrl}/meterViewing.html` }
};

return (
Expand Down
4 changes: 2 additions & 2 deletions src/client/app/components/admin/PreferencesComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { removeUnsavedChanges, updateUnsavedChanges } from '../../actions/unsave
import { defineMessages, FormattedMessage, injectIntl, WrappedComponentProps } from 'react-intl';
import { LanguageTypes } from '../../types/redux/i18n';
import TimeZoneSelect from '../TimeZoneSelect';
import { store } from '../../store';
import { store } from '../../store';
import { fetchPreferencesIfNeeded, submitPreferences } from '../../actions/admin';
import { AreaUnitType } from '../../utils/getAreaUnitConversion';
import translate from '../../utils/translate';
Expand Down Expand Up @@ -67,7 +67,7 @@ interface PreferencesProps {
updateDefaultFileSizeLimit(defaultFileSizeLimit: number): UpdateDefaultFileSizeLimit;
updateDefaultAreaUnit(defaultAreaUnit: AreaUnitType): UpdateDefaultAreaUnitAction;
updateDefaultMeterReadingFrequency(defaultMeterReadingFrequency: string): UpdateDefaultMeterReadingFrequencyAction;
updateDefaultMeterMinimumValue(defaultMeterMinimumValue : number): UpdateDefaultMeterMinimumValueAction;
updateDefaultMeterMinimumValue(defaultMeterMinimumValue: number): UpdateDefaultMeterMinimumValueAction;
updateDefaultMeterMaximumValue(defaultMeterMaximumValue: number): UpdateDefaultMeterMaximumValueAction;
updateDefaultMeterMinimumDate(defaultMeterMinimumDate: string): UpdateDefaultMeterMinimumDateAction;
updateDefaultMeterMaximumDate(defaultMeterMaximumDate: string): UpdateDefaultMeterMaximumDateAction;
Expand Down
2 changes: 1 addition & 1 deletion src/client/app/containers/TooltipHelpContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Dispatch } from '../types/redux/actions';
function mapStateToProps(state: State) {
return {
version: state.version.version,
BASE_URL: state.admin.defaultHelpUrl
baseHelpUrl: state.admin.defaultHelpUrl
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */

Expand Down
4 changes: 2 additions & 2 deletions src/server/models/Preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class Preferences {
* @param {String} defaultHelpUrl - Option to set the default help page url
*/
constructor(displayTitle, defaultChartToRender, defaultBarStacking, defaultLanguage, defaultTimezone,
defaultWarningFileSize, defaultFileSizeLimit, defaultAreaNormalization, defaultAreaUnit, defaultMeterReadingFrequency,
defaultMeterMinimumValue, defaultMeterMaximumValue, defaultMeterMinimumDate,
defaultWarningFileSize, defaultFileSizeLimit, defaultAreaNormalization, defaultAreaUnit, defaultMeterReadingFrequency,
defaultMeterMinimumValue, defaultMeterMaximumValue, defaultMeterMinimumDate,
defaultMeterMaximumDate, defaultMeterReadingGap, defaultMeterMaximumErrors, defaultMeterDisableChecks, defaultHelpUrl) {
this.displayTitle = displayTitle;
this.defaultChartToRender = defaultChartToRender;
Expand Down
1 change: 0 additions & 1 deletion src/server/services/readMamacMeters.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ async function getMeterInfo(url, ip, csvLine) {
preferences.defaultMeterMaximumDate, // maxDate
preferences.defaultMeterMaximumErrors, // maxError
preferences.defaultMeterDisableChecks // disableChecks

);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/sql/preferences/insert_default_row.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ IF NOT EXISTS(SELECT *
VALUES ('', 'line', FALSE, 'en', NULL, 5, 25, FALSE, 'meters', '00:15:00',
-9007199254740991, 9007199254740991, '1970-01-01 00:00:00+00:00', '6970-01-01 00:00:00+00:00',
0, 75, FALSE, 'https://openenergydashboard.github.io/help/');
END IF ;
END IF ;

END;
$$

0 comments on commit c8148aa

Please sign in to comment.