Skip to content

Commit

Permalink
Moved services to separate directory
Browse files Browse the repository at this point in the history
- Moved `commHelper`, `UnifiedDataLoader` into a new `/services/`
 directory
- Updated imports on other files
  • Loading branch information
the-bay-kay committed Oct 27, 2023
1 parent f0da5ea commit 3ddf403
Show file tree
Hide file tree
Showing 18 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion www/__tests__/commHelper.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mockLogger } from '../__mocks__/globalMocks';
import { fetchUrlCached } from '../js/commHelper';
import { fetchUrlCached } from '../js/services/commHelper';

mockLogger();

Expand Down
2 changes: 1 addition & 1 deletion www/__tests__/unifiedDataLoader.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mockLogger } from '../__mocks__/globalMocks';
import { combineWithDedup, combinedPromises } from '../js/unifiedDataLoader';
import { combineWithDedup, combinedPromises } from '../js/services/unifiedDataLoader';
import { ServerData } from '../js/types/serverData';

mockLogger();
Expand Down
2 changes: 1 addition & 1 deletion www/js/config/dynamicConfig.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import i18next from "i18next";
import { displayError, logDebug, logWarn } from "../plugin/logger";
import { getAngularService } from "../angular-react-helper";
import { fetchUrlCached } from "../commHelper";
import { fetchUrlCached } from "../services/commHelper";
import { storageClear, storageGet, storageSet } from "../plugin/storage";

export const CONFIG_PHONE_UI="config/app_ui_config";
Expand Down
2 changes: 1 addition & 1 deletion www/js/control/ControlSyncHelper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import SettingRow from "./SettingRow";
import AlertBar from "./AlertBar";
import moment from "moment";
import { addStatEvent, statKeys } from "../plugin/clientStats";
import { updateUser } from "../commHelper";
import { updateUser } from "../services/commHelper";

/*
* BEGIN: Simple read/write wrappers
Expand Down
2 changes: 1 addition & 1 deletion www/js/diary/LabelTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { SurveyOptions } from "../survey/survey";
import { getLabelOptions } from "../survey/multilabel/confirmHelper";
import { displayError } from "../plugin/logger";
import { useTheme } from "react-native-paper";
import { getPipelineRangeTs } from "../commHelper";
import { getPipelineRangeTs } from "../services/commHelper";

let labelPopulateFactory, labelsResultMap, notesResultMap, showPlaces;
const ONE_DAY = 24 * 60 * 60; // seconds
Expand Down
4 changes: 2 additions & 2 deletions www/js/diary/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import angular from 'angular';
import { SurveyOptions } from '../survey/survey';
import { getConfig } from '../config/dynamicConfig';
import { getRawEntries } from '../commHelper';
import { getUnifiedDataForInterval } from '../unifiedDataLoader'
import { getRawEntries } from '../services/commHelper';
import { getUnifiedDataForInterval } from '../services/unifiedDataLoader'

angular.module('emission.main.diary.services', ['emission.plugin.logger',
'emission.services'])
Expand Down
2 changes: 1 addition & 1 deletion www/js/diary/timelineHelper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import moment from "moment";
import { displayError, logDebug } from "../plugin/logger";
import { getBaseModeByKey, getBaseModeOfLabeledTrip } from "./diaryHelper";
import { getUnifiedDataForInterval} from "../unifiedDataLoader";
import { getUnifiedDataForInterval } from "../services/unifiedDataLoader";
import i18next from "i18next";

const cachedGeojsons = new Map();
Expand Down
2 changes: 1 addition & 1 deletion www/js/metrics/MetricsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Carousel from "../components/Carousel";
import DailyActiveMinutesCard from "./DailyActiveMinutesCard";
import CarbonTextCard from "./CarbonTextCard";
import ActiveMinutesTableCard from "./ActiveMinutesTableCard";
import { getAggregateData, getMetrics } from "../commHelper";
import { getAggregateData, getMetrics } from "../services/commHelper";

export const METRIC_LIST = ['duration', 'mean_speed', 'count', 'distance'] as const;

Expand Down
2 changes: 1 addition & 1 deletion www/js/onboarding/SaveQrPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import QrCode, { shareQR } from "../components/QrCode";
import { onboardingStyles } from "./OnboardingStack";
import { preloadDemoSurveyResponse } from "./SurveyPage";
import { storageSet } from "../plugin/storage";
import { registerUser } from "../commHelper";
import { registerUser } from "../services/commHelper";

const SaveQrPage = ({ }) => {

Expand Down
2 changes: 1 addition & 1 deletion www/js/services.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import angular from 'angular';
import { getRawEntries } from './commHelper';
import { getRawEntries } from './services/commHelper';

angular.module('emission.services', ['emission.plugin.logger'])
.service('ControlHelper', function($window,
Expand Down
2 changes: 1 addition & 1 deletion www/js/commHelper.ts → www/js/services/commHelper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DateTime } from "luxon";
import { logDebug } from "./plugin/logger";
import { logDebug } from "../plugin/logger";

/**
* @param url URL endpoint for the request
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { logDebug } from './plugin/logger'
import { logDebug } from '../plugin/logger'
import { getRawEntries } from './commHelper';
import { ServerResponse, ServerData, TimeQuery } from './types/serverData';
import { ServerResponse, ServerData, TimeQuery } from '../types/serverData';

/**
* combineWithDedup is a helper function for combinedPromises
Expand Down
2 changes: 1 addition & 1 deletion www/js/splash/notifScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import angular from 'angular';
import { getConfig } from '../config/dynamicConfig';
import { addStatReading, statKeys } from '../plugin/clientStats';
import { getUser, updateUser } from '../commHelper';
import { getUser, updateUser } from '../services/commHelper';

angular.module('emission.splash.notifscheduler',
['emission.services',
Expand Down
2 changes: 1 addition & 1 deletion www/js/splash/pushnotify.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

import angular from 'angular';
import { updateUser } from '../commHelper';
import { updateUser } from '../services/commHelper';

angular.module('emission.splash.pushnotify', ['emission.plugin.logger',
'emission.services',
Expand Down
2 changes: 1 addition & 1 deletion www/js/splash/storedevicesettings.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import angular from 'angular';
import { updateUser } from '../commHelper';
import { updateUser } from '../services/commHelper';

angular.module('emission.splash.storedevicesettings', ['emission.plugin.logger',
'emission.services',
Expand Down
2 changes: 1 addition & 1 deletion www/js/survey/enketo/EnketoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ModalProps } from 'react-native-paper';
import useAppConfig from '../../useAppConfig';
import { useTranslation } from 'react-i18next';
import { SurveyOptions, getInstanceStr, saveResponse } from './enketoHelper';
import { fetchUrlCached } from '../../commHelper';
import { fetchUrlCached } from '../../services/commHelper';
import { displayError, displayErrorMsg } from '../../plugin/logger';
// import { transform } from 'enketo-transformer/web';

Expand Down
2 changes: 1 addition & 1 deletion www/js/survey/enketo/enketoHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Form } from 'enketo-core';
import { XMLParser } from 'fast-xml-parser';
import i18next from 'i18next';
import { logDebug } from "../../plugin/logger";
import { getUnifiedDataForInterval} from "../../unifiedDataLoader";
import { getUnifiedDataForInterval} from "../../services/unifiedDataLoader";

export type PrefillFields = {[key: string]: string};

Expand Down
2 changes: 1 addition & 1 deletion www/js/survey/multilabel/confirmHelper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// may refactor this into a React hook once it's no longer used by any Angular screens

import { getAngularService } from "../../angular-react-helper";
import { fetchUrlCached } from "../../commHelper";
import { fetchUrlCached } from "../../services/commHelper";
import i18next from "i18next";
import { logDebug } from "../../plugin/logger";

Expand Down

0 comments on commit 3ddf403

Please sign in to comment.