diff --git a/app/actions/async.js b/app/actions/async.js
deleted file mode 100644
index 69cc66058..000000000
--- a/app/actions/async.js
+++ /dev/null
@@ -1,809 +0,0 @@
-/*
- * == BSD2 LICENSE ==
- * Copyright (c) 2015, Tidepool Project
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the associated License, which is identical to the BSD 2-Clause
- * License as published by the Open Source Initiative at opensource.org.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the License for more details.
- *
- * You should have received a copy of the License along with this program; if
- * not, you can obtain one from Tidepool Project at tidepool.org.
- * == BSD2 LICENSE ==
- */
-
-import _ from 'lodash';
-import semver from 'semver';
-import os from 'os';
-import { push } from 'connected-react-router';
-
-import sundial from 'sundial';
-
-import * as actionTypes from '../constants/actionTypes';
-import * as actionSources from '../constants/actionSources';
-import { pages, pagesMap, paths, steps, urls } from '../constants/otherConstants';
-import errorText from '../constants/errors';
-import * as metrics from '../constants/metrics';
-
-import * as syncActions from './sync';
-import * as actionUtils from './utils';
-import personUtils from '../../lib/core/personUtils';
-import driverManifests from '../../lib/core/driverManifests';
-import env from '../utils/env';
-
-let services = {};
-let versionInfo = {};
-let daysForCareLink = null;
-let hostMap = {
- 'darwin': 'mac',
- 'win32' : 'win',
- 'linux': 'linux',
-};
-/*
- * ASYNCHRONOUS ACTION CREATORS
- */
-
-export function doAppInit(opts, servicesToInit) {
- return (dispatch, getState) => {
- // when we are developing with hot reload, we get into trouble if we try to initialize the app
- // when it's already been initialized, so we check the working.initializingApp flag first
- if (getState().working.initializingApp === false) {
- console.log('App already initialized! Skipping initialization.');
- return;
- }
- services = servicesToInit;
- versionInfo.semver = opts.version;
- versionInfo.name = opts.namedVersion;
- daysForCareLink = opts.DEFAULT_CARELINK_DAYS;
- const { api, carelink, device, localStore, log } = services;
-
- dispatch(syncActions.initRequest());
- dispatch(syncActions.hideUnavailableDevices(opts.os || hostMap[os.platform()]));
-
- log('Initializing local store.');
- localStore.init(localStore.getInitialState(), function(localStoreResult){
- log('Initializing device');
- device.init({
- api,
- version: opts.namedVersion
- }, function(deviceError, deviceResult){
- if (deviceError) {
- return dispatch(syncActions.initFailure(deviceError));
- }
- log('Initializing CareLink');
- carelink.init({ api }, function(carelinkError, carelinkResult){
- if (carelinkError) {
- return dispatch(syncActions.initFailure(carelinkError));
- }
- log('Initializing api');
- api.init(function(apiError, apiResult){
- if (apiError) {
- return dispatch(syncActions.initFailure(apiError));
- }
- log('Setting all api hosts', opts.environment);
- api.setHosts(_.pick(opts, ['API_URL', 'UPLOAD_URL', 'BLIP_URL', 'environment']));
- dispatch(syncActions.setForgotPasswordUrl(api.makeBlipUrl(paths.FORGOT_PASSWORD)));
- dispatch(syncActions.setSignUpUrl(api.makeBlipUrl(paths.SIGNUP)));
- dispatch(syncActions.setNewPatientUrl(api.makeBlipUrl(paths.NEW_PATIENT)));
- let session = apiResult;
- if (session === undefined) {
- dispatch(setPage(pages.LOGIN));
- dispatch(syncActions.initSuccess());
- return dispatch(doVersionCheck());
- }
-
- api.user.initializationInfo((err, results) => {
- if (err) {
- return dispatch(syncActions.initFailure(err));
- }
- dispatch(syncActions.initSuccess());
- dispatch(doVersionCheck());
- dispatch(syncActions.setUserInfoFromToken({
- user: results[0],
- profile: results[1],
- memberships: results[2]
- }));
- const { uploadTargetUser } = getState();
- if (uploadTargetUser !== null) {
- dispatch(syncActions.setBlipViewDataUrl(
- api.makeBlipUrl(actionUtils.viewDataPathForUser(uploadTargetUser))
- ));
- }
- dispatch(retrieveTargetsFromStorage());
- });
- });
- });
- });
- });
- };
-}
-
-export function doLogin(creds, opts) {
- return (dispatch, getState) => {
- const { api } = services;
- dispatch(syncActions.loginRequest());
-
- api.user.loginExtended(creds, opts, (err, results) => {
- if (err) {
- return dispatch(syncActions.loginFailure(err.status));
- }
- dispatch(syncActions.loginSuccess({
- user: results[0].user,
- profile: results[1],
- memberships: results[2]
- }));
-
- // detect if a VCA here and redirect to clinic user select screen
- if(personUtils.userHasRole(results[0].user, 'clinic')){
- return dispatch(setPage(pages.CLINIC_USER_SELECT, actionSources.USER, {metric: {eventName: metrics.CLINIC_SEARCH_DISPLAYED}}));
- }
-
- // detect if a DSA here and redirect to data storage screen
- const { targetUsersForUpload } = getState();
- if (_.isEmpty(targetUsersForUpload)) {
- return dispatch(setPage(pages.NO_UPLOAD_TARGETS));
- }
-
- const { uploadTargetUser } = getState();
- if (uploadTargetUser !== null) {
- dispatch(syncActions.setBlipViewDataUrl(
- api.makeBlipUrl(actionUtils.viewDataPathForUser(uploadTargetUser))
- ));
- }
- dispatch(retrieveTargetsFromStorage());
- });
- };
-}
-
-export function doLogout() {
- return (dispatch) => {
- const { api } = services;
- dispatch(syncActions.logoutRequest());
- api.user.logout((err) => {
- if (err) {
- dispatch(syncActions.logoutFailure());
- dispatch(setPage(pages.LOGIN, actionSources.USER));
- }
- else {
- dispatch(syncActions.logoutSuccess());
- dispatch(setPage(pages.LOGIN, actionSources.USER));
- }
- });
- };
-}
-
-export function doCareLinkUpload(deviceKey, creds, utc) {
- return (dispatch, getState) => {
- const { api, carelink } = services;
- const version = versionInfo.semver;
- const { devices, targetTimezones, uploadTargetUser } = getState();
-
- const targetDevice = devices[deviceKey];
-
- dispatch(syncActions.fetchCareLinkRequest(uploadTargetUser, deviceKey));
-
- api.upload.fetchCarelinkData({
- carelinkUsername: creds.username,
- carelinkPassword: creds.password,
- daysAgo: daysForCareLink,
- targetUserId: uploadTargetUser
- }, (err, data) => {
- if (err) {
- let fetchErr = new Error(errorText.E_FETCH_CARELINK);
- let fetchErrProps = {
- details: err.message,
- utc: actionUtils.getUtc(utc),
- code: 'E_FETCH_CARELINK',
- version: version
- };
- dispatch(syncActions.fetchCareLinkFailure(errorText.E_FETCH_CARELINK));
- return dispatch(syncActions.uploadFailure(fetchErr, fetchErrProps, targetDevice));
- }
- if (data.search(/302 Moved Temporarily/) !== -1) {
- let credsErr = new Error(errorText.E_CARELINK_CREDS);
- let credsErrProps = {
- utc: actionUtils.getUtc(utc),
- code: 'E_CARELINK_CREDS',
- version: version
- };
- dispatch(syncActions.fetchCareLinkFailure(errorText.E_CARELINK_CREDS));
- return dispatch(syncActions.uploadFailure(credsErr, credsErrProps, targetDevice));
- }
- dispatch(syncActions.fetchCareLinkSuccess(uploadTargetUser, deviceKey));
-
- const opts = {
- targetId: uploadTargetUser,
- timezone: targetTimezones[uploadTargetUser],
- progress: actionUtils.makeProgressFn(dispatch),
- version: version
- };
- carelink.upload(data, opts, actionUtils.makeUploadCb(dispatch, getState, 'E_CARELINK_UPLOAD', utc));
- });
- };
-}
-
-export function doDeviceUpload(driverId, opts = {}, utc) {
- return (dispatch, getState) => {
- const { device } = services;
- const version = versionInfo.semver;
- const { devices, os, targetTimezones, uploadTargetUser } = getState();
- const targetDevice = _.find(devices, {source: {driverId: driverId}});
- dispatch(syncActions.deviceDetectRequest());
- _.assign(opts, {
- targetId: uploadTargetUser,
- timezone: targetTimezones[uploadTargetUser],
- progress: actionUtils.makeProgressFn(dispatch),
- displayTimeModal: actionUtils.makeDisplayTimeModal(dispatch),
- displayAdHocModal: actionUtils.makeDisplayAdhocModal(dispatch),
- version: version
- });
- const { uploadsByUser } = getState();
- const currentUpload = _.get(
- uploadsByUser,
- [uploadTargetUser, targetDevice.key],
- {}
- );
- if (currentUpload.file) {
- opts.filedata = currentUpload.file.data;
- opts.filename = currentUpload.file.name;
- }
-
- device.detect(driverId, opts, (err, dev) => {
- if (err) {
- let displayErr = new Error(errorText.E_SERIAL_CONNECTION);
- let deviceDetectErrProps = {
- details: err.message,
- utc: actionUtils.getUtc(utc),
- code: 'E_SERIAL_CONNECTION',
- version: version
- };
-
- if (_.get(targetDevice, 'source.driverId', null) === 'Dexcom') {
- displayErr = new Error(errorText.E_DEXCOM_CONNECTION);
- deviceDetectErrProps.code = 'E_DEXCOM_CONNECTION';
- }
-
- displayErr.originalError = err;
- return dispatch(syncActions.uploadFailure(displayErr, deviceDetectErrProps, targetDevice));
- }
-
- if (!dev && opts.filename == null) {
- let displayErr = new Error(errorText.E_HID_CONNECTION);
- let disconnectedErrProps = {
- utc: actionUtils.getUtc(utc),
- code: 'E_HID_CONNECTION',
- version: version
- };
-
- if (targetDevice.powerOnlyWarning) {
- displayErr = new Error(errorText.E_USB_CABLE);
- disconnectedErrProps.code = 'E_USB_CABLE';
- }
-
- if (_.get(targetDevice, 'source.driverId', null) === 'Dexcom') {
- displayErr = new Error(errorText.E_DEXCOM_CONNECTION);
- disconnectedErrProps.code = 'E_DEXCOM_CONNECTION';
- }
-
- return dispatch(syncActions.uploadFailure(displayErr, disconnectedErrProps, targetDevice));
- }
-
- var errorMessage = 'E_DEVICE_UPLOAD';
- if (_.get(targetDevice, 'source.driverId', null) === 'Medtronic') {
- errorMessage = 'E_MEDTRONIC_UPLOAD';
- } else if (_.get(targetDevice, 'source.driverId', null) === 'BluetoothLE') {
- errorMessage = 'E_BLUETOOTH_PAIR';
- }
- device.upload(driverId, opts, actionUtils.makeUploadCb(dispatch, getState, errorMessage , utc));
- });
- };
-}
-
-export function doUpload (deviceKey, opts, utc) {
- return async (dispatch, getState) => {
-
- const { devices, uploadTargetUser, working } = getState();
-
- const targetDevice = _.get(devices, deviceKey);
- const driverId = _.get(targetDevice, 'source.driverId');
- const driverManifest = _.get(driverManifests, driverId);
-
- if (driverManifest && driverManifest.mode === 'serial') {
- dispatch(syncActions.uploadRequest(uploadTargetUser, devices[deviceKey], utc));
-
- const filters = driverManifest.usb.map(({vendorId, productId}) => ({
- usbVendorId: vendorId,
- usbProductId: productId
- }));
-
- try {
- const existingPermissions = await navigator.serial.getPorts();
-
- for (let i = 0; i < existingPermissions.length; i++) {
- const { usbProductId, usbVendorId } = existingPermissions[i].getInfo();
-
- for (let j = 0; j < driverManifest.usb.length; j++) {
- if (driverManifest.usb[j].vendorId === usbVendorId
- && driverManifest.usb[j].productId === usbProductId) {
- console.log('Device has already been granted permission');
- opts.port = existingPermissions[i];
- }
- }
- }
-
- if (opts.port == null) {
- opts.port = await navigator.serial.requestPort({ filters: filters });
- }
- } catch (err) {
- // not returning error, as we'll attempt user-space driver instead
- console.log('Error:', err);
- }
- }
-
- if (env.browser && driverManifest && driverManifest.mode === 'HID') {
- dispatch(syncActions.uploadRequest(uploadTargetUser, devices[deviceKey], utc));
-
- const filters = driverManifest.usb.map(({vendorId, productId}) => ({
- vendorId,
- productId
- }));
-
- try {
- const existingPermissions = await navigator.hid.getDevices();
-
- for (let i = 0; i < existingPermissions.length; i++) {
- for (let j = 0; j < driverManifest.usb.length; j++) {
- if (driverManifest.usb[j].vendorId === existingPermissions[i].vendorId
- && driverManifest.usb[j].productId === existingPermissions[i].productId) {
- console.log('Device has already been granted permission');
- opts.hidDevice = existingPermissions[i];
- }
- }
- }
-
- if (opts.hidDevice == null) {
- [opts.hidDevice] = await navigator.hid.requestDevice({ filters: filters });
- }
-
- if (opts.hidDevice == null) {
- throw new Error('No device was selected.');
- }
- } catch (err) {
- console.log('Error:', err);
-
- let hidErr = new Error(errorText.E_HID_CONNECTION);
- let errProps = {
- details: err.message,
- utc: actionUtils.getUtc(utc),
- code: 'E_HID_CONNECTION',
- };
-
- return dispatch(syncActions.uploadFailure(hidErr, errProps, devices[deviceKey]));
- }
- }
-
- if (opts && opts.ble) {
- // we need to to scan for Bluetooth devices before the version check,
- // otherwise it doesn't count as a response to a user request anymore
- dispatch(syncActions.uploadRequest(uploadTargetUser, devices[deviceKey], utc));
- console.log('Scanning..');
- try {
- await opts.ble.scan();
- } catch (err) {
- console.log('Error:', err);
-
- let btErr = new Error(errorText.E_BLUETOOTH_OFF);
- let errProps = {
- details: err.message,
- utc: actionUtils.getUtc(utc),
- code: 'E_BLUETOOTH_OFF',
- };
-
- return dispatch(syncActions.uploadFailure(btErr, errProps, devices[deviceKey]));
- }
- console.log('Done.');
- }
-
- dispatch(syncActions.versionCheckRequest());
- const { api } = services;
- const version = versionInfo.semver;
- api.upload.getVersions((err, versions) => {
- if (err) {
- dispatch(syncActions.versionCheckFailure(err));
- return dispatch(syncActions.uploadAborted());
- }
- const { uploaderMinimum } = versions;
- // if either the version from the jellyfish response
- // or the local uploader version is somehow an invalid semver
- // we will catch the error and dispatch versionCheckFailure
- try {
- const upToDate = semver.gte(version, uploaderMinimum);
- if (!upToDate) {
- dispatch(syncActions.versionCheckFailure(null, version, uploaderMinimum));
- return dispatch(syncActions.uploadAborted());
- }
- else {
- dispatch(syncActions.versionCheckSuccess());
- }
- }
- catch(err) {
- dispatch(syncActions.versionCheckFailure(err));
- return dispatch(syncActions.uploadAborted());
- }
-
- if (working.uploading === true) {
- return dispatch(syncActions.uploadAborted());
- }
-
- dispatch(syncActions.uploadRequest(uploadTargetUser, devices[deviceKey], utc));
-
- const targetDevice = devices[deviceKey];
- const deviceType = targetDevice.source.type;
-
- if (_.includes(['device', 'block'], deviceType)) {
- dispatch(doDeviceUpload(targetDevice.source.driverId, opts, utc));
- }
- else if (deviceType === 'carelink') {
- dispatch(doCareLinkUpload(deviceKey, opts, utc));
- }
- });
- };
-}
-
-export function readFile(userId, deviceKey, file, extension) {
- return (dispatch, getState) => {
- if (!file) {
- return;
- }
- dispatch(syncActions.choosingFile(userId, deviceKey));
- const version = versionInfo.semver;
-
- if (file.name.slice(-extension.length) !== extension) {
- let err = new Error(errorText.E_FILE_EXT + extension);
- let errProps = {
- code: 'E_FILE_EXT',
- version: version
- };
- return dispatch(syncActions.readFileAborted(err, errProps));
- }
- else {
- let reader = new FileReader();
- reader.onloadstart = () => {
- dispatch(syncActions.readFileRequest(userId, deviceKey, file.name));
- };
-
- reader.onerror = () => {
- let err = new Error(errorText.E_READ_FILE + file.name);
- let errProps = {
- code: 'E_READ_FILE',
- version: version
- };
- return dispatch(syncActions.readFileFailure(err, errProps));
- };
-
- reader.onloadend = ((theFile) => {
- return (e) => {
- dispatch(syncActions.readFileSuccess(userId, deviceKey, e.srcElement.result));
- dispatch(doUpload(deviceKey));
- };
- })(file);
-
- reader.readAsArrayBuffer(file);
- }
- };
-}
-
-export function doVersionCheck() {
- return (dispatch, getState) => {
- dispatch(syncActions.versionCheckRequest());
- const { api } = services;
- const version = versionInfo.semver;
- if(env.browser){
- return dispatch(syncActions.versionCheckSuccess());
- }
- api.upload.getVersions((err, versions) => {
- if (err) {
- return dispatch(syncActions.versionCheckFailure(err));
- }
- const { uploaderMinimum } = versions;
- // if either the version from the jellyfish response
- // or the local uploader version is somehow an invalid semver
- // we will catch the error and dispatch versionCheckFailure
- try {
- const upToDate = semver.gte(version, uploaderMinimum);
- if (!upToDate) {
- return dispatch(syncActions.versionCheckFailure(null, version, uploaderMinimum));
- }
- else {
- return dispatch(syncActions.versionCheckSuccess());
- }
- }
- catch(err) {
- return dispatch(syncActions.versionCheckFailure(err));
- }
- });
- };
-}
-
-export function setTargetTimezone(userId, timezoneName) {
- return (dispatch, getState) => {
- const { allUsers, loggedInUser } = getState();
- const isClinicAccount = personUtils.userHasRole(allUsers[loggedInUser], 'clinic');
- const { api } = services;
- dispatch(syncActions.updateProfileRequest());
- let updates = {
- patient: {
- targetTimezone: timezoneName
- }
- };
- api.user.updateProfile(userId, updates, (err, profile) => {
- // suppress unauthorized error until custodial vs normal permissions are ironed out
- // TODO: remove conditional when perms are finalized or accounts are converted
- if (err){
- if (_.get(err,'status') !== 401) {
- dispatch(syncActions.updateProfileFailure(err));
- } else {
- let newProfile = actionUtils.mergeProfileUpdates(allUsers[userId], updates);
- dispatch(syncActions.updateProfileSuccess(newProfile, userId));
- }
- } else {
- dispatch(syncActions.updateProfileSuccess(profile, userId));
- }
- if (isClinicAccount) {
- return dispatch(syncActions.setTargetTimezone(userId, timezoneName, {metric: {eventName: metrics.CLINIC_TIMEZONE_SELECT}}));
- }
- return dispatch(syncActions.setTargetTimezone(userId, timezoneName));
- });
- };
-}
-
-export function clickDeviceSelectionDone() {
- return (dispatch, getState) => {
- const { targetDevices, uploadTargetUser, allUsers, loggedInUser } = getState();
- const isClinicAccount = personUtils.userHasRole(allUsers[loggedInUser], 'clinic');
- const { api } = services;
- dispatch(syncActions.updateProfileRequest());
- if (!_.isEmpty(targetDevices[uploadTargetUser])) {
- let updates = {
- patient: {
- targetDevices: targetDevices[uploadTargetUser]
- }
- };
- api.user.updateProfile(uploadTargetUser, updates, (err, profile) => {
- // suppress unauthorized error until custodial vs normal permissions are ironed out
- // TODO: remove conditional when perms are finalized or accounts are converted
- if (err) {
- if (_.get(err,'status') !== 401) {
- dispatch(syncActions.updateProfileFailure(err));
- } else {
- let newProfile = actionUtils.mergeProfileUpdates(allUsers[uploadTargetUser], updates);
- dispatch(syncActions.updateProfileSuccess(newProfile, uploadTargetUser));
- if (isClinicAccount) {
- _.forEach(targetDevices[uploadTargetUser], function(device){
- dispatch(syncActions.clinicAddDevice(device));
- });
- }
- }
- } else {
- dispatch(syncActions.updateProfileSuccess(profile, uploadTargetUser));
- if (isClinicAccount) {
- _.forEach(targetDevices[uploadTargetUser], function(device){
- dispatch(syncActions.clinicAddDevice(device));
- });
- }
- }
- if (isClinicAccount) {
- return dispatch(setPage(pages.MAIN, undefined, {metric: {eventName: metrics.CLINIC_DEVICES_DONE}}));
- }
- return dispatch(setPage(pages.MAIN));
- });
- }
- };
-}
-
-export function clickEditUserNext(profile) {
- return (dispatch, getState) => {
- const { uploadTargetUser, allUsers } = getState();
- const { api } = services;
- const updates = profile;
- if (!_.isEmpty(profile)){
- dispatch(syncActions.updateProfileRequest());
- api.user.updateProfile(uploadTargetUser, profile, (err, profile) => {
- // suppress unauthorized error until custodial vs normal permissions are ironed out
- // TODO: remove conditional when perms are finalized or accounts are converted
- if (err) {
- if(_.get(err,'status') !== 401) {
- return dispatch(syncActions.updateProfileFailure(err));
- } else {
- const { allUsers } = getState();
- let newProfile = actionUtils.mergeProfileUpdates(allUsers[uploadTargetUser], updates);
- dispatch(syncActions.updateProfileSuccess(newProfile, uploadTargetUser));
- }
- } else {
- dispatch(syncActions.updateProfileSuccess(profile, uploadTargetUser));
- }
- const { targetDevices, devices, allUsers, loggedInUser } = getState();
- const targetedDevices = _.get(targetDevices, uploadTargetUser, []);
- const supportedDeviceKeys = _.keys(devices);
- const atLeastOneDeviceSupportedOnSystem = _.some(targetedDevices, (key) => {
- return _.includes(supportedDeviceKeys, key);
- });
- if (_.isEmpty(targetedDevices) || !atLeastOneDeviceSupportedOnSystem) {
- return dispatch(setPage(pages.SETTINGS));
- } else {
- return dispatch(setPage(pages.MAIN));
- }
- });
- }
- };
-}
-
-export function retrieveTargetsFromStorage() {
- return (dispatch, getState) => {
- const { devices, uploadTargetUser } = getState();
- const { api, localStore } = services;
- let fromLocalStore = false;
-
- dispatch(syncActions.retrieveUsersTargetsFromStorage());
- let targets = localStore.getItem('devices');
- if (targets !== null) {
- fromLocalStore = true;
- // wipe out the deprecated 'devices' localStore key
- localStore.removeItem('devices');
- const uploadsByUser = actionUtils.getDeviceTargetsByUser(targets);
- dispatch(syncActions.setUploads(uploadsByUser));
- dispatch(syncActions.setUsersTargets(targets));
- }
-
- const { targetDevices, targetTimezones, allUsers, loggedInUser } = getState();
- const isClinicAccount = personUtils.userHasRole(allUsers[loggedInUser], 'clinic');
-
- if (isClinicAccount) {
- return dispatch(setPage(pages.CLINIC_USER_SELECT, null, /*{metric: {eventName: metrics.CLINIC_SEARCH_DISPLAYED}}*/));
- }
- // redirect based on having a supported device if not clinic account
- if (!_.isEmpty(_.get(targetDevices, uploadTargetUser))) {
- let usersWithTargets = {};
- _.forOwn(targetDevices, (devicesArray, userId) => {
- usersWithTargets[userId] = _.map(devicesArray, (deviceKey) => {
- return {key: deviceKey};
- });
- });
- _.forOwn(targetTimezones, (timezoneName, userId) => {
- usersWithTargets[userId] = _.map(usersWithTargets[userId], (target) => {
- if (timezoneName != null) {
- target.timezone = timezoneName;
- }
- return target;
- });
- });
- const targetDeviceKeys = targetDevices[uploadTargetUser];
- const supportedDeviceKeys = _.keys(devices);
- const atLeastOneDeviceSupportedOnSystem = _.some(targetDeviceKeys, (key) => {
- return _.includes(supportedDeviceKeys, key);
- });
-
- if(!fromLocalStore){
- const uploadsByUser = actionUtils.getDeviceTargetsByUser(usersWithTargets);
- dispatch(syncActions.setUploads(uploadsByUser));
- } else {
- if (!_.isEmpty(targetDevices[uploadTargetUser]) && !_.isEmpty(targetTimezones[uploadTargetUser])) {
- dispatch(syncActions.updateProfileRequest());
- const updates = {
- patient: {
- targetDevices: targetDevices[uploadTargetUser],
- targetTimezone: targetTimezones[uploadTargetUser]
- }
- };
- api.user.updateProfile(uploadTargetUser, updates, (err, profile) => {
- // suppress unauthorized error until custodial vs normal permissions are ironed out
- // TODO: remove conditional when perms are finalized or accounts are converted
- if(err){
- if (_.get(err,'status') !== 401) {
- dispatch(syncActions.updateProfileFailure(err));
- } else {
- let newProfile = actionUtils.mergeProfileUpdates(allUsers[uploadTargetUser], updates);
- dispatch(syncActions.updateProfileSuccess(newProfile, uploadTargetUser));
- }
- } else {
- dispatch(syncActions.updateProfileSuccess(profile, uploadTargetUser));
- }
- });
- }
- }
-
- if (atLeastOneDeviceSupportedOnSystem) {
- return dispatch(setPage(pages.MAIN));
- } else {
- return dispatch(setPage(pages.SETTINGS));
- }
- } else {
- return dispatch(setPage(pages.SETTINGS));
- }
- };
-}
-
-export function createCustodialAccount(profile) {
- return (dispatch, getState) => {
- const { api } = services;
- dispatch(syncActions.createCustodialAccountRequest());
- api.user.createCustodialAccount(profile, (err, account) => {
- if (err) {
- dispatch(syncActions.createCustodialAccountFailure(err));
- }
- else {
- dispatch(syncActions.createCustodialAccountSuccess(account));
- if (_.get(account, 'profile.patient.mrn', false)) {
- dispatch(syncActions.clinicAddMrn());
- }
- if (_.get(account, 'profile.patient.email', false)) {
- dispatch(syncActions.clinicAddEmail());
- }
- dispatch(syncActions.setUploadTargetUser(account.userid));
- dispatch(setPage(pages.SETTINGS));
- }
- });
- };
-}
-
-/*
- * COMPLEX ACTION CREATORS
- */
-
-export function setUploadTargetUserAndMaybeRedirect(targetId) {
- return (dispatch, getState) => {
- const { devices, targetDevices, allUsers, loggedInUser} = getState();
- dispatch(syncActions.setUploadTargetUser(targetId));
- const { api } = services;
- dispatch(syncActions.setBlipViewDataUrl(
- api.makeBlipUrl(actionUtils.viewDataPathForUser(targetId))
- ));
- const targetedDevices = _.get(targetDevices, targetId, []);
- const supportedDeviceKeys = _.keys(devices);
- const atLeastOneDeviceSupportedOnSystem = _.some(targetedDevices, (key) => {
- return _.includes(supportedDeviceKeys, key);
- });
- if (_.isEmpty(targetedDevices) || !atLeastOneDeviceSupportedOnSystem) {
- return dispatch(setPage(pages.SETTINGS));
- }
- };
-}
-
-export function checkUploadTargetUserAndMaybeRedirect() {
- return (dispatch, getState) => {
- const { devices, targetDevices, allUsers, loggedInUser, uploadTargetUser } = getState();
- if (!uploadTargetUser) {
- return;
- }
- const targetedDevices = _.get(targetDevices, uploadTargetUser, []);
- const supportedDeviceKeys = _.keys(devices);
- const atLeastOneDeviceSupportedOnSystem = _.some(targetedDevices, (key) => {
- return _.includes(supportedDeviceKeys, key);
- });
- if (_.isEmpty(targetedDevices) || !atLeastOneDeviceSupportedOnSystem) {
- return dispatch(setPage(pages.SETTINGS, undefined, {metric: {eventName: metrics.CLINIC_NEXT}}));
- } else {
- return dispatch(setPage(pages.MAIN, undefined, {metric: {eventName: metrics.CLINIC_NEXT}}));
- }
- };
-}
-
-export function clickAddNewUser(){
- return (dispatch, getState) =>{
- dispatch(syncActions.setUploadTargetUser(null));
- dispatch(setPage(pages.CLINIC_USER_EDIT, undefined, {metric: {eventName: metrics.CLINIC_ADD}}));
- };
-}
-
-export function setPage(page, actionSource = actionSources[actionTypes.SET_PAGE], metric) {
- return (dispatch, getState) => {
- if(pagesMap[page]){
- const meta = { source: actionSource };
- _.assign(meta, metric);
- dispatch(push({pathname: pagesMap[page], state: { meta }}));
- }
- };
-}
diff --git a/app/actions/index.js b/app/actions/index.js
deleted file mode 100644
index 859a62bf8..000000000
--- a/app/actions/index.js
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * == BSD2 LICENSE ==
- * Copyright (c) 2015, Tidepool Project
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the associated License, which is identical to the BSD 2-Clause
- * License as published by the Open Source Initiative at opensource.org.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the License for more details.
- *
- * You should have received a copy of the License along with this program; if
- * not, you can obtain one from Tidepool Project at tidepool.org.
- * == BSD2 LICENSE ==
- */
-
-import * as async from './async';
-import * as sync from './sync';
-
-export default {
- async: async,
- sync: sync
-};
diff --git a/app/actions/sync.js b/app/actions/sync.js
deleted file mode 100644
index 75aabb2d4..000000000
--- a/app/actions/sync.js
+++ /dev/null
@@ -1,842 +0,0 @@
-/*
- * == BSD2 LICENSE ==
- * Copyright (c) 2015, Tidepool Project
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the associated License, which is identical to the BSD 2-Clause
- * License as published by the Open Source Initiative at opensource.org.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the License for more details.
- *
- * You should have received a copy of the License along with this program; if
- * not, you can obtain one from Tidepool Project at tidepool.org.
- * == BSD2 LICENSE ==
- */
-
-import _ from 'lodash';
-
-import * as actionTypes from '../constants/actionTypes';
-import * as actionSources from '../constants/actionSources';
-import * as metrics from '../constants/metrics';
-
-import {
- addInfoToError,
- getAppInitErrorMessage,
- getLoginErrorMessage,
- getLogoutErrorMessage,
- getUpdateProfileErrorMessage,
- getCreateCustodialAccountErrorMessage,
- UnsupportedError
-} from '../utils/errors';
-import errorText from '../constants/errors';
-
-import * as actionUtils from './utils';
-import personUtils from '../../lib/core/personUtils';
-import uploadDataPeriod from '../utils/uploadDataPeriod';
-
-const uploadDataPeriodLabels = {
- [uploadDataPeriod.PERIODS.ALL]: 'all data',
- [uploadDataPeriod.PERIODS.DELTA]: 'new data',
- [uploadDataPeriod.PERIODS.FOUR_WEEKS]: '4 weeks'
-};
-
-export function addTargetDevice(userId, deviceKey) {
- return {
- type: actionTypes.ADD_TARGET_DEVICE,
- payload: { userId, deviceKey },
- meta: {source: actionSources[actionTypes.ADD_TARGET_DEVICE]}
- };
-}
-
-// NB: this action exists purely to trigger the metrics middleware
-// no reducer responds to it to adjust any state!
-export function clickGoToBlip() {
- return {
- type: actionTypes.CLICK_GO_TO_BLIP,
- meta: {
- source: actionSources[actionTypes.CLICK_GO_TO_BLIP],
- metric: {eventName: metrics.CLICK_GO_TO_BLIP}
- }
- };
-}
-
-export function rememberMedtronicSerialNumber(serialNumber) {
- return {
- type: actionTypes.MEDTRONIC_REMEMBER_SERIAL_NUMBER,
- meta: {
- source: actionSources[actionTypes.MEDTRONIC_REMEMBER_SERIAL_NUMBER],
- metric: { eventName: metrics.MEDTRONIC_REMEMBER_SERIAL_NUMBER }
- }
- };
-}
-
-export function clinicAddMrn(){
- return {
- type: actionTypes.CLINIC_ADD_MRN,
- meta: {
- source: actionSources[actionTypes.CLINIC_ADD_MRN],
- metric: {eventName: metrics.CLINIC_ADD_MRN}
- }
- };
-}
-
-export function clinicAddEmail(){
- return {
- type: actionTypes.CLINIC_ADD_EMAIL,
- meta: {
- source: actionSources[actionTypes.CLINIC_ADD_EMAIL],
- metric: {eventName: metrics.CLINIC_ADD_EMAIL}
- }
- };
-}
-
-export function clinicAddDevice(deviceKey){
- return {
- type: actionTypes.CLINIC_DEVICE_STORED,
- meta: {
- source: actionSources[actionTypes.CLINIC_DEVICE_STORED],
- metric: {eventName: metrics.CLINIC_DEVICE_STORED + ' - ' + deviceKey}
- }
- };
-}
-
-export function clinicInvalidDate(errors){
- if (_.get(errors, 'year', false)) {
- return {
- type: actionTypes.CLINIC_ADD_INVALID_DATE,
- meta: {
- source: actionSources[actionTypes.CLINIC_ADD_INVALID_DATE],
- metric: {eventName: metrics.CLINIC_ADD_INVALID_DATE}
- }
- };
- }
-}
-
-export function hideUnavailableDevices(os) {
- return {
- type: actionTypes.HIDE_UNAVAILABLE_DEVICES,
- payload: { os },
- meta: {source: actionSources[actionTypes.HIDE_UNAVAILABLE_DEVICES]}
- };
-}
-
-export function removeTargetDevice(userId, deviceKey) {
- return {
- type: actionTypes.REMOVE_TARGET_DEVICE,
- payload: { userId, deviceKey },
- meta: {source: actionSources[actionTypes.REMOVE_TARGET_DEVICE]}
- };
-}
-
-export function resetUpload(userId, deviceKey) {
- return {
- type: actionTypes.RESET_UPLOAD,
- payload: { userId, deviceKey },
- meta: {source: actionSources[actionTypes.RESET_UPLOAD]}
- };
-}
-
-export function setBlipViewDataUrl(url) {
- return {
- type: actionTypes.SET_BLIP_VIEW_DATA_URL,
- payload: { url },
- meta: {source: actionSources[actionTypes.SET_BLIP_VIEW_DATA_URL]}
- };
-}
-
-export function setForgotPasswordUrl(url) {
- return {
- type: actionTypes.SET_FORGOT_PASSWORD_URL,
- payload: { url },
- meta: {source: actionSources[actionTypes.SET_FORGOT_PASSWORD_URL]}
- };
-}
-
-export function setNewPatientUrl(url) {
- return {
- type: actionTypes.SET_NEW_PATIENT_URL,
- payload: { url },
- meta: {source: actionSources[actionTypes.SET_NEW_PATIENT_URL]}
- };
-}
-
-export function setSignUpUrl(url) {
- return {
- type: actionTypes.SET_SIGNUP_URL,
- payload: { url },
- meta: {source: actionSources[actionTypes.SET_SIGNUP_URL]}
- };
-}
-
-export function setTargetTimezone(userId, timezoneName, metric) {
- let meta = {source: actionSources[actionTypes.SET_TARGET_TIMEZONE]};
- if (metric) {
- _.assign(meta, metric);
- }
- return {
- type: actionTypes.SET_TARGET_TIMEZONE,
- payload: { userId, timezoneName },
- meta: meta
- };
-}
-
-export function setUploads(devicesByUser) {
- return {
- type: actionTypes.SET_UPLOADS,
- payload: { devicesByUser },
- meta: {source: actionSources[actionTypes.SET_UPLOADS]}
- };
-}
-
-export function setUploadTargetUser(userId, metric) {
- let meta = {source: actionSources[actionTypes.SET_UPLOAD_TARGET_USER]};
- if (metric) {
- _.assign(meta, {metric});
- }
- return {
- type: actionTypes.SET_UPLOAD_TARGET_USER,
- payload: { userId },
- meta
- };
-}
-
-export function toggleDropdown(previous, actionSource = actionSources[actionTypes.TOGGLE_DROPDOWN]) {
- return {
- type: actionTypes.TOGGLE_DROPDOWN,
- payload: { isVisible: !previous },
- meta: {source: actionSource}
- };
-}
-
-export function toggleErrorDetails(userId, deviceKey, previous) {
- if (_.includes([null, undefined], previous)) {
- previous = false;
- }
- return {
- type: actionTypes.TOGGLE_ERROR_DETAILS,
- payload: { isVisible: !previous, userId, deviceKey },
- meta: {source: actionSources[actionTypes.TOGGLE_ERROR_DETAILS]}
- };
-}
-
-export function dismissUpdateProfileError(){
- return {
- type: actionTypes.DISMISS_UPDATE_PROFILE_ERROR,
- meta: {source: actionSources[actionTypes.DISMISS_UPDATE_PROFILE_ERROR]}
- };
-}
-
-export function dismissCreateCustodialAccountError(){
- return {
- type: actionTypes.DISMISS_CREATE_CUSTODIAL_ACCOUNT_ERROR,
- meta: {source: actionSources[actionTypes.DISMISS_CREATE_CUSTODIAL_ACCOUNT_ERROR]}
- };
-}
-
-export function setAllUsers(user, profile, memberships){
- return {
- type: actionTypes.SET_ALL_USERS,
- payload: { memberships: memberships, user: user, profile: profile },
- meta: {source: actionSources[actionTypes.SET_ALL_USERS]}
- };
-}
-
-/*
- * relating to async action creator doAppInit
- */
-
-export function initRequest() {
- return {
- type: actionTypes.INIT_APP_REQUEST,
- meta: {source: actionSources[actionTypes.INIT_APP_REQUEST]}
- };
-}
-
-export function initSuccess() {
- return {
- type: actionTypes.INIT_APP_SUCCESS,
- meta: {source: actionSources[actionTypes.INIT_APP_SUCCESS]}
- };
-}
-
-export function initFailure(err) {
- const error = new Error(getAppInitErrorMessage(err.status || null));
- error.originalError = err;
- return {
- type: actionTypes.INIT_APP_FAILURE,
- error: true,
- payload: error,
- meta: {source: actionSources[actionTypes.INIT_APP_FAILURE]}
- };
-}
-
-export function setUserInfoFromToken(results) {
- const { user, profile, memberships } = results;
- return {
- type: actionTypes.SET_USER_INFO_FROM_TOKEN,
- payload: { user, profile, memberships },
- meta: {source: actionSources[actionTypes.SET_USER_INFO_FROM_TOKEN]}
- };
-}
-
-/*
- * relating to async action creator doLogin
- */
-
-export function loginRequest() {
- return {
- type: actionTypes.LOGIN_REQUEST,
- meta: {source: actionSources[actionTypes.LOGIN_REQUEST]}
- };
-}
-
-export function loginSuccess(results) {
- const { user, profile, memberships } = results;
- const isClinicAccount = personUtils.userHasRole(user, 'clinic');
- if (isClinicAccount) {
- uploadDataPeriod.setPeriodMedtronic600(uploadDataPeriod.PERIODS.FOUR_WEEKS);
- }
- return {
- type: actionTypes.LOGIN_SUCCESS,
- payload: { user, profile, memberships },
- meta: {
- source: actionSources[actionTypes.LOGIN_SUCCESS],
- metric: {eventName: isClinicAccount ? metrics.CLINIC_LOGIN_SUCCESS : metrics.LOGIN_SUCCESS}
- }
- };
-}
-
-export function loginFailure(errorCode) {
- return {
- type: actionTypes.LOGIN_FAILURE,
- error: true,
- payload: new Error(getLoginErrorMessage(errorCode)),
- meta: {source: actionSources[actionTypes.LOGIN_FAILURE]}
- };
-}
-
-/*
- * relating to async action creator doLogout
- */
-
-export function logoutRequest() {
- return {
- type: actionTypes.LOGOUT_REQUEST,
- meta: {
- source: actionSources[actionTypes.LOGOUT_REQUEST],
- metric: {eventName: metrics.LOGOUT_REQUEST}
- }
- };
-}
-
-export function logoutSuccess() {
- return {
- type: actionTypes.LOGOUT_SUCCESS,
- meta: {source: actionSources[actionTypes.LOGOUT_SUCCESS]}
- };
-}
-
-export function logoutFailure() {
- return {
- type: actionTypes.LOGOUT_FAILURE,
- error: true,
- payload: new Error(getLogoutErrorMessage()),
- meta: {source: actionSources[actionTypes.LOGOUT_FAILURE]}
- };
-}
-
-/*
- * relating to async action creator doCareLinkUpload
- */
-
-export function fetchCareLinkRequest(userId, deviceKey) {
- return {
- type: actionTypes.CARELINK_FETCH_REQUEST,
- payload: { userId, deviceKey },
- meta: {source: actionSources[actionTypes.CARELINK_FETCH_REQUEST]}
- };
-}
-
-export function fetchCareLinkSuccess(userId, deviceKey) {
- return {
- type: actionTypes.CARELINK_FETCH_SUCCESS,
- payload: { userId, deviceKey },
- meta: {
- source: actionSources[actionTypes.CARELINK_FETCH_SUCCESS],
- metric: {eventName: metrics.CARELINK_FETCH_SUCCESS}
- }
- };
-}
-
-export function fetchCareLinkFailure(message) {
- return {
- type: actionTypes.CARELINK_FETCH_FAILURE,
- error: true,
- payload: new Error(message),
- meta: {
- source: actionSources[actionTypes.CARELINK_FETCH_FAILURE],
- metric: {eventName: metrics.CARELINK_FETCH_FAILURE}
- }
- };
-}
-
-/*
- * relating to async action creator doUpload
- */
-
-export function uploadAborted() {
- return {
- type: actionTypes.UPLOAD_ABORTED,
- error: true,
- payload: new Error(errorText.E_UPLOAD_IN_PROGRESS),
- meta: {source: actionSources[actionTypes.UPLOAD_ABORTED]}
- };
-}
-
-export function uploadRequest(userId, device, utc) {
- utc = actionUtils.getUtc(utc);
- const properties = {
- type: _.get(device, 'source.type', undefined),
- source: `${actionUtils.getUploadTrackingId(device)}`
- };
- if (_.get(device, 'source.driverId', null) === 'Medtronic600') {
- _.extend(properties, { 'limit': uploadDataPeriodLabels[uploadDataPeriod.periodMedtronic600] });
- }
- return {
- type: actionTypes.UPLOAD_REQUEST,
- payload: { userId, deviceKey: device.key, utc },
- meta: {
- source: actionSources[actionTypes.UPLOAD_REQUEST],
- metric: {
- eventName: `${metrics.UPLOAD_REQUEST}`,
- properties
- }
- }
- };
-}
-
-export function uploadProgress(step, percentage, isFirstUpload) {
- return {
- type: actionTypes.UPLOAD_PROGRESS,
- payload: { step, percentage, isFirstUpload },
- meta: {source: actionSources[actionTypes.UPLOAD_PROGRESS]}
- };
-}
-
-export function uploadSuccess(userId, device, upload, data, utc) {
- utc = actionUtils.getUtc(utc);
- const numRecs = _.get(data, 'post_records.length', undefined);
- const properties = {
- type: _.get(device, 'source.type', undefined),
- deviceModel: _.get(data, 'deviceModel', undefined),
- source: `${actionUtils.getUploadTrackingId(device)}`,
- started: upload.history[0].start || '',
- finished: utc || '',
- processed: numRecs || 0
- };
- if (_.get(device, 'source.driverId', null) === 'Medtronic600') {
- _.extend(properties, { 'limit': uploadDataPeriodLabels[uploadDataPeriod.periodMedtronic600] });
- }
- return {
- type: actionTypes.UPLOAD_SUCCESS,
- payload: { userId, deviceKey: device.key, data, utc },
- meta: {
- source: actionSources[actionTypes.UPLOAD_SUCCESS],
- metric: {
- eventName: `${metrics.UPLOAD_SUCCESS}`,
- properties
- }
- }
- };
-}
-
-export function uploadFailure(err, errProps, device) {
- err = addInfoToError(err, errProps);
- const properties = {
- type: _.get(device, 'source.type', undefined),
- source: `${actionUtils.getUploadTrackingId(device)}`,
- error: err
- };
- if (_.get(device, 'source.driverId', null) === 'Medtronic600') {
- _.extend(properties, { 'limit': uploadDataPeriodLabels[uploadDataPeriod.periodMedtronic600] });
- }
- return {
- type: actionTypes.UPLOAD_FAILURE,
- error: true,
- payload: err,
- meta: {
- source: actionSources[actionTypes.UPLOAD_FAILURE],
- metric: {
- eventName: `${metrics.UPLOAD_FAILURE}`,
- properties
- }
- }
- };
-}
-
-export function uploadCancelled(utc) {
- return {
- type: actionTypes.UPLOAD_CANCELLED,
- payload: { utc },
- meta: {
- source: actionSources[actionTypes.UPLOAD_CANCELLED]
- }
- };
-}
-
-export function deviceDetectRequest() {
- return {
- type: actionTypes.DEVICE_DETECT_REQUEST,
- meta: {source: actionSources[actionTypes.DEVICE_DETECT_REQUEST]}
- };
-}
-
-/*
- * relating to async action creator readFile
- */
-
-export function choosingFile(userId, deviceKey) {
- return {
- type: actionTypes.CHOOSING_FILE,
- payload: { userId, deviceKey },
- meta: {source: actionSources[actionTypes.CHOOSING_FILE]}
- };
-}
-
-export function readFileAborted(err, errProps) {
- return {
- type: actionTypes.READ_FILE_ABORTED,
- error: true,
- payload: addInfoToError(err, errProps),
- meta: {source: actionSources[actionTypes.READ_FILE_ABORTED]}
- };
-}
-
-export function readFileRequest(userId, deviceKey, filename) {
- return {
- type: actionTypes.READ_FILE_REQUEST,
- payload: { userId, deviceKey, filename },
- meta: {source: actionSources[actionTypes.READ_FILE_REQUEST]}
- };
-}
-
-export function readFileSuccess(userId, deviceKey, filedata) {
- return {
- type: actionTypes.READ_FILE_SUCCESS,
- payload: { userId, deviceKey, filedata },
- meta: {source: actionSources[actionTypes.READ_FILE_SUCCESS]}
- };
-}
-
-export function readFileFailure(err, errProps) {
- return {
- type: actionTypes.READ_FILE_FAILURE,
- error: true,
- payload: addInfoToError(err, errProps),
- meta: {source: actionSources[actionTypes.READ_FILE_FAILURE]}
- };
-}
-
-/*
- * relating to async action creator doVersionCheck
- */
-
-export function versionCheckRequest() {
- return {
- type: actionTypes.VERSION_CHECK_REQUEST,
- meta: {source: actionSources[actionTypes.VERSION_CHECK_REQUEST]}
- };
-}
-
-export function versionCheckSuccess() {
- return {
- type: actionTypes.VERSION_CHECK_SUCCESS,
- meta: {source: actionSources[actionTypes.VERSION_CHECK_SUCCESS]}
- };
-}
-
-export function versionCheckFailure(err, currentVersion, requiredVersion) {
- if (err != null) {
- return {
- type: actionTypes.VERSION_CHECK_FAILURE,
- error: true,
- payload: err,
- meta: {
- source: actionSources[actionTypes.VERSION_CHECK_FAILURE],
- metric: {
- eventName: metrics.UNSUPPORTED_SCREEN_DISPLAYED
- }
- }
- };
- }
- else {
- return {
- type: actionTypes.VERSION_CHECK_FAILURE,
- error: true,
- payload: new UnsupportedError(currentVersion, requiredVersion),
- meta: {
- source: actionSources[actionTypes.VERSION_CHECK_FAILURE],
- metric: {
- eventName: metrics.VERSION_CHECK_FAILURE_OUTDATED,
- properties: { requiredVersion }
- }
- }
- };
- }
-}
-
-/*
- * relating to updateProfile
- */
-
-export function updateProfileRequest() {
- return {
- type: actionTypes.UPDATE_PROFILE_REQUEST,
- meta: {source: actionSources[actionTypes.UPDATE_PROFILE_REQUEST]}
- };
-}
-
-export function updateProfileSuccess(profile, userId) {
- return {
- type: actionTypes.UPDATE_PROFILE_SUCCESS,
- payload: { profile, userId },
- meta: {source: actionSources[actionTypes.UPDATE_PROFILE_SUCCESS]}
- };
-}
-
-export function updateProfileFailure(err) {
- const error = new Error(getUpdateProfileErrorMessage(err.status || null));
- error.originalError = err;
- return {
- type: actionTypes.UPDATE_PROFILE_FAILURE,
- error: true,
- payload: error,
- meta: {source: actionSources[actionTypes.UPDATE_PROFILE_FAILURE]}
- };
-}
-
-/*
- * relating to createCustodialAccount
- */
-
-export function createCustodialAccountRequest() {
- return {
- type: actionTypes.CREATE_CUSTODIAL_ACCOUNT_REQUEST,
- meta: {source: actionSources[actionTypes.CREATE_CUSTODIAL_ACCOUNT_REQUEST]}
- };
-}
-
-export function createCustodialAccountSuccess(account) {
- return {
- type: actionTypes.CREATE_CUSTODIAL_ACCOUNT_SUCCESS,
- payload: { account },
- meta: {
- source: actionSources[actionTypes.CREATE_CUSTODIAL_ACCOUNT_SUCCESS],
- metric: {eventName: metrics.CLINIC_ADD_NEW_PATIENT}
- }
- };
-}
-
-export function createCustodialAccountFailure(err) {
- const error = new Error(getCreateCustodialAccountErrorMessage(err.status || null));
- error.originalError = err;
- return {
- type: actionTypes.CREATE_CUSTODIAL_ACCOUNT_FAILURE,
- error: true,
- payload: error,
- meta: {source: actionSources[actionTypes.CREATE_CUSTODIAL_ACCOUNT_FAILURE]}
- };
-}
-
-/*
- * relating to side-effect-performing action creators
- * retrieveTargetsFromStorage
- */
-
-export function retrieveUsersTargetsFromStorage() {
- return {
- type: actionTypes.RETRIEVING_USERS_TARGETS,
- meta: {source: actionSources[actionTypes.RETRIEVING_USERS_TARGETS]}
- };
-}
-
-export function setUsersTargets(targets) {
- return {
- type: actionTypes.SET_USERS_TARGETS,
- payload: { targets },
- meta: {source: actionSources[actionTypes.SET_USERS_TARGETS]}
- };
-}
-
-/*
- * relating to electron auto-updater
- */
-
-export function autoCheckingForUpdates() {
- return {
- type: actionTypes.AUTO_UPDATE_CHECKING_FOR_UPDATES,
- meta: { source: actionSources[actionTypes.AUTO_UPDATE_CHECKING_FOR_UPDATES] }
- };
-}
-
-export function manualCheckingForUpdates() {
- return {
- type: actionTypes.MANUAL_UPDATE_CHECKING_FOR_UPDATES,
- meta: { source: actionSources[actionTypes.MANUAL_UPDATE_CHECKING_FOR_UPDATES] }
- };
-}
-
-export function updateAvailable(info) {
- return {
- type: actionTypes.UPDATE_AVAILABLE,
- payload: { info },
- meta: { source: actionSources[actionTypes.UPDATE_AVAILABLE] }
- };
-}
-
-export function updateNotAvailable(info) {
- return {
- type: actionTypes.UPDATE_NOT_AVAILABLE,
- payload: { info },
- meta: { source: actionSources[actionTypes.UPDATE_NOT_AVAILABLE] }
- };
-}
-
-export function autoUpdateError(error) {
- return {
- type: actionTypes.AUTOUPDATE_ERROR,
- payload: { error },
- meta: { source: actionSources[actionTypes.AUTOUPDATE_ERROR] }
- };
-}
-
-export function updateDownloaded(info) {
- return {
- type: actionTypes.UPDATE_DOWNLOADED,
- payload: { info },
- meta: { source: actionSources[actionTypes.UPDATE_DOWNLOADED] }
- };
-}
-
-export function dismissUpdateAvailable() {
- return {
- type: actionTypes.DISMISS_UPDATE_AVAILABLE,
- meta: { source: actionSources[actionTypes.DISMISS_UPDATE_AVAILABLE] }
- };
-}
-
-export function dismissUpdateNotAvailable() {
- return {
- type: actionTypes.DISMISS_UPDATE_NOT_AVAILABLE,
- meta: { source: actionSources[actionTypes.DISMISS_UPDATE_NOT_AVAILABLE] }
- };
-}
-
-export function quitAndInstall() {
- return {
- type: actionTypes.QUIT_AND_INSTALL,
- meta: {
- source: actionSources[actionTypes.QUIT_AND_INSTALL],
- metric: { eventName: metrics.QUIT_AND_INSTALL }
- }
- };
-}
-
-/*
- * relating to driver updates
- */
-
-export function checkingForDriverUpdate() {
- return {
- type: actionTypes.CHECKING_FOR_DRIVER_UPDATE,
- meta: { source: actionSources[actionTypes.CHECKING_FOR_DRIVER_UPDATE] }
- };
-}
-
-export function driverUpdateAvailable(current, available) {
- return {
- type: actionTypes.DRIVER_UPDATE_AVAILABLE,
- payload: { current, available },
- meta: { source: actionSources[actionTypes.DRIVER_UPDATE_AVAILABLE] }
- };
-}
-
-export function driverUpdateNotAvailable() {
- return {
- type: actionTypes.DRIVER_UPDATE_NOT_AVAILABLE,
- meta: { source: actionSources[actionTypes.DRIVER_UPDATE_NOT_AVAILABLE] }
- };
-}
-
-export function dismissDriverUpdateAvailable() {
- return {
- type: actionTypes.DISMISS_DRIVER_UPDATE_AVAILABLE,
- meta: { source: actionSources[actionTypes.DISMISS_DRIVER_UPDATE_AVAILABLE] }
- };
-}
-
-export function driverInstall() {
- return {
- type: actionTypes.DRIVER_INSTALL,
- meta: {
- source: actionSources[actionTypes.DRIVER_INSTALL]
- }
- };
-}
-
-export function driverUpdateShellOpts(opts) {
- return {
- type: actionTypes.DRIVER_INSTALL_SHELL_OPTS,
- payload: { opts },
- meta: {source: actionSources[actionTypes.DRIVER_INSTALL_SHELL_OPTS] }
- };
-}
-
-export function deviceTimeIncorrect(callback, cfg, times) {
- return {
- type: actionTypes.DEVICE_TIME_INCORRECT,
- payload: { callback, cfg, times },
- meta: {
- source: actionSources[actionTypes.DEVICE_TIME_INCORRECT],
- metric: {
- eventName: metrics.DEVICE_TIME_INCORRECT,
- properties: { times },
- }
- },
- };
-}
-
-export function dismissedDeviceTimePrompt() {
- return {
- type: actionTypes.DISMISS_DEVICE_TIME_PROMPT,
- meta: { source: actionSources[actionTypes.DISMISS_DEVICE_TIME_PROMPT] }
- };
-}
-
-export function timezoneBlur() {
- return {
- type: actionTypes.TIMEZONE_BLUR,
- meta: { source: actionSources[actionTypes.TIMEZONE_BLUR] }
- };
-}
-
-/*
-* relating to ad hoc pairing dialog
-*/
-
-export function adHocPairingRequest(callback, cfg) {
- return {
- type: actionTypes.AD_HOC_PAIRING_REQUEST,
- payload: { callback, cfg },
- meta: { source: actionSources[actionTypes.AD_HOC_PAIRING_REQUEST] }
- };
-}
-
-export function dismissedAdHocPairingDialog() {
- return {
- type: actionTypes.AD_HOC_PAIRING_DISMISSED,
- meta: { source: actionSources[actionTypes.AD_HOC_PAIRING_DISMISSED] }
- };
-}
diff --git a/app/actions/utils.js b/app/actions/utils.js
deleted file mode 100644
index aefc09685..000000000
--- a/app/actions/utils.js
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * == BSD2 LICENSE ==
- * Copyright (c) 2015, Tidepool Project
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the associated License, which is identical to the BSD 2-Clause
- * License as published by the Open Source Initiative at opensource.org.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the License for more details.
- *
- * You should have received a copy of the License along with this program; if
- * not, you can obtain one from Tidepool Project at tidepool.org.
- * == BSD2 LICENSE ==
- */
-
-import _ from 'lodash';
-import stacktrace from 'stack-trace';
-
-import sundial from 'sundial';
-
-import errorText from '../constants/errors';
-import * as syncActions from './sync';
-
-const isBrowser = typeof window !== 'undefined';
-// eslint-disable-next-line no-console
-const debug = isBrowser ? require('bows')('utils') : console.log;
-
-export function getDeviceTargetsByUser(targetsByUser) {
- return _.mapValues(targetsByUser, (targets) => {
- return _.map(targets, 'key');
- });
-}
-
-export function getUploadTrackingId(device) {
- const source = device.source;
- if (source.type === 'device' || source.type === 'block') {
- return source.driverId;
- }
- if (source.type === 'carelink') {
- return 'CareLink';
- }
- return null;
-}
-
-export function getUtc(utc) {
- return _.isEmpty(utc) ? sundial.utcDateString() : utc;
-}
-
-export function makeProgressFn(dispatch) {
- return (step, percentage, isFirstUpload) => {
- dispatch(syncActions.uploadProgress(step, percentage, isFirstUpload));
- };
-}
-
-export function makeDisplayTimeModal(dispatch) {
- return (cb, cfg, times) => {
- dispatch(syncActions.deviceTimeIncorrect(cb, cfg, times));
- };
-}
-
-export function makeDisplayAdhocModal(dispatch) {
- return (cb, cfg) => {
- dispatch(syncActions.adHocPairingRequest(cb, cfg));
- };
-}
-
-export function makeUploadCb(dispatch, getState, errCode, utc) {
- return (err, recs) => {
- const { devices, uploadsByUser, uploadTargetDevice, uploadTargetUser, version } = getState();
- const targetDevice = devices[uploadTargetDevice];
-
- if (err) {
- if(err === 'deviceTimePromptClose'){
- return dispatch(syncActions.uploadCancelled(getUtc(utc)));
- }
- // the drivers sometimes just pass a string arg as err, instead of an actual error :/
- if (typeof err === 'string') {
- err = new Error(err);
- }
- const serverErr = 'Origin is not allowed by Access-Control-Allow-Origin';
- let displayErr = new Error(err.message === serverErr ?
- errorText.E_SERVER_ERR : errorText[err.code || errCode]);
- let uploadErrProps = {
- details: err.message,
- utc: getUtc(utc),
- name: err.name || 'Uncaught or API POST error',
- step: err.step || null,
- datasetId: err.datasetId || null,
- requestTrace: err.requestTrace || null,
- sessionTrace: err.sessionTrace || null,
- sessionToken: err.sessionToken || null,
- code: err.code || errCode,
- version: version,
- data: recs
- };
- displayErr.originalError = err;
-
- if (errCode === 'E_BLUETOOTH_PAIR') {
- displayErr.message = 'Couldn\'t connect to device.';
- displayErr.link = 'https://support.tidepool.org/hc/en-us/articles/360035332972';
- displayErr.linkText = 'Is it paired?';
- }
-
- if (!(process.env.NODE_ENV === 'test')) {
- uploadErrProps.stringifiedStack = _.map(
- _.filter(
- stacktrace.parse(err),
- (cs) => { return cs.functionName !== null; }
- ),
- 'functionName'
- ).join(', ');
- }
- return dispatch(syncActions.uploadFailure(displayErr, uploadErrProps, targetDevice));
- }
- const currentUpload = _.get(uploadsByUser, [uploadTargetUser, targetDevice.key], {});
- dispatch(syncActions.uploadSuccess(uploadTargetUser, targetDevice, currentUpload, recs, utc));
- };
-}
-
-export function viewDataPathForUser(uploadTargetUser) {
- return `/patients/${uploadTargetUser}/data`;
-}
-
-export function mergeProfileUpdates(profile, updates){
- // merge property values except arrays, which get replaced entirely
- return _.mergeWith(profile, updates, (original, update) => {
- if (_.isArray(original)) {
- return update;
- }
- });
-}
diff --git a/app/app.global.css b/app/app.global.css
deleted file mode 100755
index e69de29bb..000000000
diff --git a/app/app.html b/app/app.html
deleted file mode 100755
index 377ce7f0f..000000000
--- a/app/app.html
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
- Tidepool Uploader
-
-
-
-
-
-
-
diff --git a/app/app.icns b/app/app.icns
deleted file mode 100755
index 4f3cbbafa..000000000
Binary files a/app/app.icns and /dev/null differ
diff --git a/app/components/AdHocModal.js b/app/components/AdHocModal.js
deleted file mode 100644
index 1746794e7..000000000
--- a/app/components/AdHocModal.js
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
-* == BSD2 LICENSE ==
-* Copyright (c) 2014-2016, Tidepool Project
-*
-* This program is free software; you can redistribute it and/or modify it under
-* the terms of the associated License, which is identical to the BSD 2-Clause
-* License as published by the Open Source Initiative at opensource.org.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-* FOR A PARTICULAR PURPOSE. See the License for more details.
-*
-* You should have received a copy of the License along with this program; if
-* not, you can obtain one from Tidepool Project at tidepool.org.
-* == BSD2 LICENSE ==
-*/
-
-import _ from 'lodash';
-import React, { Component } from 'react';
-import { connect } from 'react-redux';
-import { bindActionCreators } from 'redux';
-
-import { sync as syncActions } from '../actions/';
-
-import styles from '../../styles/components/AdHocModal.module.less';
-import step1_img from '../../images/adhoc_s1.png';
-import step2_img from '../../images/adhoc_s2.png';
-
-//const remote = require('@electron/remote');
-// const i18n = remote.getGlobal( 'i18n' );
-let i18n = {t:string => string};
-
-export class AdHocModal extends Component {
- handleContinue = () => {
- const { showingAdHocPairingDialog, sync } = this.props;
- showingAdHocPairingDialog.callback('adHocModalClose');
- sync.dismissedAdHocPairingDialog();
- }
-
- render() {
- const { showingAdHocPairingDialog } = this.props;
-
- if(!showingAdHocPairingDialog){
- return null;
- }
-
- return (
-
-
-
-
{i18n.t('Allow the connection on the pump:')}
-
-
-
-
-
-
1. {i18n.t('Scroll down')}
-
-
-
-
2. {i18n.t('Select \"Yes\"')}
-
-
-
-
-
-
-
-
-
-
- );
- }
-};
-
-export default connect(
- (state, ownProps) => {
- return {
- showingAdHocPairingDialog: state.showingAdHocPairingDialog
- };
- },
- (dispatch) => {
- return {
- sync: bindActionCreators(syncActions, dispatch)
- };
- }
-)(AdHocModal);
diff --git a/app/components/ClinicUploadDone.js b/app/components/ClinicUploadDone.js
deleted file mode 100644
index 5a1fffc0a..000000000
--- a/app/components/ClinicUploadDone.js
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-* == BSD2 LICENSE ==
-* Copyright (c) 2014, Tidepool Project
-*
-* This program is free software; you can redistribute it and/or modify it under
-* the terms of the associated License, which is identical to the BSD 2-Clause
-* License as published by the Open Source Initiative at opensource.org.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-* FOR A PARTICULAR PURPOSE. See the License for more details.
-*
-* You should have received a copy of the License along with this program; if
-* not, you can obtain one from Tidepool Project at tidepool.org.
-* == BSD2 LICENSE ==
-*/
-
-var React = require('react');
-var _ = require('lodash');
-var PropTypes = require('prop-types');
-
-var styles = require('../../styles/components/ClinicUploadDone.module.less');
-
-//const remote = require('@electron/remote');
-// const i18n = remote.getGlobal( 'i18n' );
-let i18n = {t:string => string};
-
-class ClinicUploadDone extends React.Component {
- static propTypes = {
- onClicked: PropTypes.func.isRequired,
- uploadTargetUser: PropTypes.string.isRequired,
- uploadsByUser: PropTypes.object.isRequired
- };
-
- handleClick = () => {
- this.props.onClicked();
- };
-
- hasCompletedUpload = () => {
- return _.find(_.get(this.props.uploadsByUser, this.props.uploadTargetUser, {}), {completed: true});
- };
-
- render() {
- return (
-
- );
- }
-}
-
-module.exports = ClinicUploadDone;
diff --git a/app/components/ClinicUserBlock.js b/app/components/ClinicUserBlock.js
deleted file mode 100644
index 11f8cc05e..000000000
--- a/app/components/ClinicUserBlock.js
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
-* == BSD2 LICENSE ==
-* Copyright (c) 2014, Tidepool Project
-*
-* This program is free software; you can redistribute it and/or modify it under
-* the terms of the associated License, which is identical to the BSD 2-Clause
-* License as published by the Open Source Initiative at opensource.org.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-* FOR A PARTICULAR PURPOSE. See the License for more details.
-*
-* You should have received a copy of the License along with this program; if
-* not, you can obtain one from Tidepool Project at tidepool.org.
-* == BSD2 LICENSE ==
-*/
-
-var _ = require('lodash');
-var PropTypes = require('prop-types');
-var React = require('react');
-var sundial = require('sundial');
-var personUtils = require('../../lib/core/personUtils');
-var cx = require('classnames');
-
-//const remote = require('@electron/remote');
-// const i18n = remote.getGlobal( 'i18n' );
-let i18n = {t:string => string};
-
-var styles = require('../../styles/components/ClinicUserBlock.module.less');
-
-class ClinicUserBlock extends React.Component {
- static propTypes = {
- allUsers: PropTypes.object.isRequired,
- memberships: PropTypes.object.isRequired,
- targetId: PropTypes.string,
- timezoneDropdown: PropTypes.element,
- onEditUser: PropTypes.func.isRequired,
- isUploadInProgress: PropTypes.bool.isRequired
- };
-
- formatBirthday = (birthday) => {
- return sundial.translateMask(birthday, 'YYYY-MM-DD', 'M/D/YYYY');
- };
-
- noopHandler = (e) => {
- e.preventDefault();
- };
-
- render() {
- var { allUsers, isUploadInProgress, memberships, targetId } = this.props;
- var isCustodialAccount = _.has(_.get(memberships, [targetId, 'permissions']), 'custodian');
- var editClasses = cx({
- [styles.edit]: true,
- [styles.disabled]: isUploadInProgress
- });
-
- return (
-
- );
-
- renderDateError = (fields) => {
- const {month, day, year} = fields;
- if (!year || !year.meta.error) { return null; }
- // only render the error if each field has either been touched or has a value
- // and the user is not interacting with any of them
- const monthCheck = ((month.meta.touched || month.input.value) && !month.meta.active);
- const dayCheck = ((day.meta.touched || day.input.value) && !day.meta.active);
- const yearCheck = ((year.meta.touched || year.input.value) && !year.meta.active);
- return monthCheck && dayCheck && yearCheck &&
- (
- );
- }
-}
-
-module.exports = ClinicUserSelect;
diff --git a/app/components/DeviceSelection.js b/app/components/DeviceSelection.js
deleted file mode 100644
index 333cc6251..000000000
--- a/app/components/DeviceSelection.js
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
-* == BSD2 LICENSE ==
-* Copyright (c) 2014, Tidepool Project
-*
-* This program is free software; you can redistribute it and/or modify it under
-* the terms of the associated License, which is identical to the BSD 2-Clause
-* License as published by the Open Source Initiative at opensource.org.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-* FOR A PARTICULAR PURPOSE. See the License for more details.
-*
-* You should have received a copy of the License along with this program; if
-* not, you can obtain one from Tidepool Project at tidepool.org.
-* == BSD2 LICENSE ==
-*/
-
-var _ = require('lodash');
-var PropTypes = require('prop-types');
-var React = require('react');
-var cx = require('classnames');
-var node_os = require('os');
-//const remote = require('@electron/remote');
-// const i18n = remote.getGlobal( 'i18n' );
-let i18n = {t:string => string};
-
-import { urls } from '../constants/otherConstants';
-
-import styles from '../../styles/components/DeviceSelection.module.less';
-
-var hostMap = {
- 'darwin': 'mac',
- 'win32' : 'win',
- 'linux': 'linux',
-};
-
-class DeviceSelection extends React.Component {
- static propTypes = {
- disabled: PropTypes.bool.isRequired,
- devices: PropTypes.object.isRequired,
- targetDevices: PropTypes.array.isRequired,
- // targetId can be null when logged in user is not a data storage account
- // for example a clinic worker
- targetId: PropTypes.string,
- timezoneIsSelected: PropTypes.bool.isRequired,
- userDropdownShowing: PropTypes.bool.isRequired,
- userIsSelected: PropTypes.bool.isRequired,
- addDevice: PropTypes.func.isRequired,
- removeDevice: PropTypes.func.isRequired,
- onDone: PropTypes.func.isRequired,
- isClinicAccount: PropTypes.bool.isRequired
- };
-
- UNSAFE_componentWillReceiveProps(nextProps) {
- var self = this;
-
- if (!this.props.userIsSelected && nextProps.userIsSelected) {
- _.each(self.props.targetDevices, function(device) {
- self.props.addDevice(nextProps.targetId, device);
- });
- }
- }
-
- render() {
- var targetUser = this.props.targetId || 'noUserSelected';
- var addDevice = this.props.addDevice.bind(null, targetUser);
- var removeDevice = this.props.removeDevice.bind(null, targetUser);
- var devices = this.props.devices;
-
- var onCheckedChange = function(e) {
- if (e.target.checked) {
- addDevice(e.target.value);
- }
- else {
- removeDevice(e.target.value);
- }
- };
- var os = hostMap[node_os.platform()];
- var targetDevices = this.props.targetDevices;
-
- var items = _.map(devices, function(device) {
- var isChecked = _.includes(targetDevices, device.key);
-
- return (
-
-
-
-
-
-
- );
- });
-
- var carelink = _.remove(items, {'key': 'carelink'});
-
- // TODO: when this gets the ES6 treatment, use computed property syntax
- var formClassesObject = {};
- formClassesObject[styles.form] = true;
- formClassesObject[styles.onlyme] = !this.props.userDropdownShowing;
- formClassesObject[styles.groups] = this.props.userDropdownShowing;
- formClassesObject[styles.clinic] = this.props.isClinicAccount;
- var formClasses = cx(formClassesObject);
-
- var disabled = (this.props.targetDevices.length > 0 &&
- this.props.userIsSelected) &&
- !this.props.disabled ?
- false : true;
- return (
-
-
-
{i18n.t('Choose devices')}
-
-
-
-
-
-
- );
- }
-
- handleSubmit = () => {
- this.props.onDone();
- };
-}
-
-module.exports = DeviceSelection;
diff --git a/app/components/DeviceTimeModal.js b/app/components/DeviceTimeModal.js
deleted file mode 100644
index 99dbbaa71..000000000
--- a/app/components/DeviceTimeModal.js
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
-* == BSD2 LICENSE ==
-* Copyright (c) 2014-2016, Tidepool Project
-*
-* This program is free software; you can redistribute it and/or modify it under
-* the terms of the associated License, which is identical to the BSD 2-Clause
-* License as published by the Open Source Initiative at opensource.org.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-* FOR A PARTICULAR PURPOSE. See the License for more details.
-*
-* You should have received a copy of the License along with this program; if
-* not, you can obtain one from Tidepool Project at tidepool.org.
-* == BSD2 LICENSE ==
-*/
-
-import _ from 'lodash';
-import React, { Component } from 'react';
-import { connect } from 'react-redux';
-import { bindActionCreators } from 'redux';
-import sundial from 'sundial';
-
-import { sync as syncActions } from '../actions/';
-
-import styles from '../../styles/components/DeviceTimeModal.module.less';
-
-//const remote = require('@electron/remote');
-// const i18n = remote.getGlobal( 'i18n' );
-let i18n = {t:string => string};
-
-export class DeviceTimeModal extends Component {
- determineDeviceType = () => {
- const { showingDeviceTimePrompt } = this.props;
- const { tags } = showingDeviceTimePrompt.cfg.deviceInfo;
- if(_.indexOf(tags, 'insulin-pump') !== -1){
- return { value: 'insulin-pump', text: i18n.t('pump') };
- }
- if(_.indexOf(tags, 'cgm') !== -1){
- return { value: 'cgm', text: i18n.t('CGM') };
- }
- if(_.indexOf(tags, 'bgm') !== -1){
- return { value: 'bgm', text: i18n.t('meter') };
- }
- return 'unknown';
- }
-
- isDevice = (name) => {
- const { showingDeviceTimePrompt } = this.props;
- const {deviceInfo} = showingDeviceTimePrompt.cfg;
- return deviceInfo && deviceInfo.driverId && deviceInfo.driverId === name;
- }
-
- handleContinue = () => {
- const { sync, showingDeviceTimePrompt } = this.props;
- showingDeviceTimePrompt.callback('updateTime');
- sync.dismissedDeviceTimePrompt();
- }
-
- handleCancel = () => {
- const { sync, showingDeviceTimePrompt } = this.props;
- showingDeviceTimePrompt.callback('deviceTimePromptClose');
- sync.dismissedDeviceTimePrompt();
- }
-
- getActions = () => {
- const { showingDeviceTimePrompt: { cfg: { timezone }, times: { serverTime, deviceTime } } } = this.props;
- const type = this.determineDeviceType();
- const reminder = this.getReminder();
- const buttons = [];
- const footnote = type.value === 'bgm' ? '*' : '';
- if ( !this.isDevice('Animas') &&
- !this.isDevice('InsuletOmniPod') &&
- !this.isDevice('Medtronic') && // these two lines should be removed
- !this.isDevice('Medtronic600') && // when we can update time on Medtronic pumps
- !this.isDevice('Tandem') &&
- !this.isDevice('TrueMetrix')
- ) {
- buttons.push(
-
- {i18n.t('Is the time on your {{text}} incorrect?', { text: type.text })}
-
-
- );
- }
- buttons.push(
-
- {i18n.t('Are you in {{timezone}}? Double-check',{ timezone: timezone })}
- {i18n.t('selected time zone and current device time.')}
- {reminder}
-
-
- );
- }
-};
-
-export default connect(
- (state, ownProps) => {
- return {
- showingDeviceTimePrompt: state.showingDeviceTimePrompt
- };
- },
- (dispatch) => {
- return {
- sync: bindActionCreators(syncActions, dispatch)
- };
- }
-)(DeviceTimeModal);
diff --git a/app/components/Footer.js b/app/components/Footer.js
deleted file mode 100644
index cf47b701e..000000000
--- a/app/components/Footer.js
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-* == BSD2 LICENSE ==
-* Copyright (c) 2016, Tidepool Project
-*
-* This program is free software; you can redistribute it and/or modify it under
-* the terms of the associated License, which is identical to the BSD 2-Clause
-* License as published by the Open Source Initiative at opensource.org.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-* FOR A PARTICULAR PURPOSE. See the License for more details.
-*
-* You should have received a copy of the License along with this program; if
-* not, you can obtain one from Tidepool Project at tidepool.org.
-* == BSD2 LICENSE ==
-*/
-
-import PropTypes from 'prop-types';
-
-import React, { Component } from 'react';
-
-import styles from '../../styles/components/Footer.module.less';
-import logo from '../../images/JDRF_Reverse_Logo x2.png';
-import debugMode from '../utils/debugMode';
-import env from '../utils/env';
-
-let os, osName;
-if(env.electron){
- os = require('os');
- osName = require('os-name');
-}
-
-//const remote = require('@electron/remote');
-// const i18n = remote.getGlobal( 'i18n' );
-let i18n = {t:string => string};
-
-export default class Footer extends Component {
- static propTypes = {
- version: PropTypes.string.isRequired,
- };
-
- render() {
- const {version} = this.props;
- let osArch = '';
- let environment = '';
-
- if (debugMode.isDebug) {
- env.electron ? osArch = ` (${osName()} - ${os.arch()})`:'';
- environment = ` - ${this.props.environment}`;
- }
-
- return (
-
- );
- }
-}
diff --git a/app/components/Header.js b/app/components/Header.js
deleted file mode 100644
index 015b90836..000000000
--- a/app/components/Header.js
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
-* == BSD2 LICENSE ==
-* Copyright (c) 2016, Tidepool Project
-*
-* This program is free software; you can redistribute it and/or modify it under
-* the terms of the associated License, which is identical to the BSD 2-Clause
-* License as published by the Open Source Initiative at opensource.org.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-* FOR A PARTICULAR PURPOSE. See the License for more details.
-*
-* You should have received a copy of the License along with this program; if
-* not, you can obtain one from Tidepool Project at tidepool.org.
-* == BSD2 LICENSE ==
-*/
-
-import _ from 'lodash';
-import PropTypes from 'prop-types';
-import React, { Component } from 'react';
-import { bindActionCreators } from 'redux';
-import { connect } from 'react-redux';
-import actions from '../actions/';
-
-const asyncActions = actions.async;
-const syncActions = actions.sync;
-
-import LoggedInAs from '../components/LoggedInAs';
-
-import * as actionSources from '../constants/actionSources';
-import { pages, pagesMap } from '../constants/otherConstants';
-
-import styles from '../../styles/components/Header.module.less';
-import logo from '../../images/Tidepool_Logo_Light x2.png';
-
-//const remote = require('@electron/remote');
-// const i18n = remote.getGlobal( 'i18n' );
-let i18n = {t:string => string};
-
-export class Header extends Component {
- static propTypes = {
- location: PropTypes.object.isRequired,
- blipUrls: PropTypes.object.isRequired,
- dropdown: PropTypes.bool.isRequired,
- uploadIsInProgress: PropTypes.bool.isRequired,
- user: PropTypes.object,
- isClinicAccount: PropTypes.bool,
- targetUsersForUpload: PropTypes.array
- };
-
- handleClickChooseDevices = metric => {
- const { toggleDropdown } = this.props.sync;
- const { setPage } = this.props.async;
- // ensure dropdown closes after click
- setPage(pages.SETTINGS, true, metric);
- toggleDropdown(true, actionSources.UNDER_THE_HOOD);
- };
-
- handleCheckForUpdates = () => {
- const { toggleDropdown } = this.props.sync;
- toggleDropdown(true, actionSources.UNDER_THE_HOOD);
- };
-
- render() {
- const { allUsers, dropdown, location } = this.props;
- if (location.pathname === pagesMap.LOADING) {
- return null;
- }
-
- if (location.pathname === pagesMap.LOGIN) {
- return (
-
- );
- }
-}
-
-export default connect(
- (state, ownProps) => {
- function isClinicAccount(state) {
- return _.indexOf(_.get(_.get(state.allUsers, state.loggedInUser, {}), 'roles', []), 'clinic') !== -1;
- }
- return {
- // plain state
- allUsers: state.allUsers,
- blipUrls: state.blipUrls,
- dropdown: state.dropdown,
- loggedInUser: state.loggedInUser,
- targetUsersForUpload: state.targetUsersForUpload,
- uploadIsInProgress: state.working.uploading,
- // derived state
- isClinicAccount: isClinicAccount(state)
- };
- },
- (dispatch) => {
- return {
- async: bindActionCreators(asyncActions, dispatch),
- sync: bindActionCreators(syncActions, dispatch)
- };
- }
-)(Header);
diff --git a/app/components/Loading.js b/app/components/Loading.js
deleted file mode 100644
index 280d7c8d2..000000000
--- a/app/components/Loading.js
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * == BSD2 LICENSE ==
- * Copyright (c) 2014, Tidepool Project
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the associated License, which is identical to the BSD 2-Clause
- * License as published by the Open Source Initiative at opensource.org.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the License for more details.
- *
- * You should have received a copy of the License along with this program; if
- * not, you can obtain one from Tidepool Project at tidepool.org.
- * == BSD2 LICENSE ==
- */
-
-var React = require('react');
-var styles = require('../../styles/components/App.module.less');
-//const remote = require('@electron/remote');
-// const i18n = remote.getGlobal( 'i18n' );
-let i18n = {t:string => string};
-
-class Loading extends React.Component {
- render() {
- return
-
- {i18n.t('Loading...')}
-
-
;
- }
-}
-
-module.exports = Loading;
diff --git a/app/components/LoadingBar.js b/app/components/LoadingBar.js
deleted file mode 100644
index 39aba50bc..000000000
--- a/app/components/LoadingBar.js
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-* == BSD2 LICENSE ==
-* Copyright (c) 2014, Tidepool Project
-*
-* This program is free software; you can redistribute it and/or modify it under
-* the terms of the associated License, which is identical to the BSD 2-Clause
-* License as published by the Open Source Initiative at opensource.org.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-* FOR A PARTICULAR PURPOSE. See the License for more details.
-*
-* You should have received a copy of the License along with this program; if
-* not, you can obtain one from Tidepool Project at tidepool.org.
-* == BSD2 LICENSE ==
-*/
-
-var React = require('react');
-
-var styles = require('../../styles/components/LoadingBar.module.less');
-
-class LoadingBar extends React.Component {
- render() {
- return (
-
-
-
- );
- }
-}
-
-module.exports = LoadingBar;
diff --git a/app/components/LoggedInAs.js b/app/components/LoggedInAs.js
deleted file mode 100644
index 69e0d657d..000000000
--- a/app/components/LoggedInAs.js
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * == BSD2 LICENSE ==
- * Copyright (c) 2014, Tidepool Project
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the associated License, which is identical to the BSD 2-Clause
- * License as published by the Open Source Initiative at opensource.org.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the License for more details.
- *
- * You should have received a copy of the License along with this program; if
- * not, you can obtain one from Tidepool Project at tidepool.org.
- * == BSD2 LICENSE ==
- */
-import _ from 'lodash';
-import PropTypes from 'prop-types';
-import React, { Component } from 'react';
-import env from '../utils/env';
-
-let ipcRenderer;
-if(env.electron_renderer){
- ({ipcRenderer} = require('electron'));
-}
-//const remote = require('@electron/remote');
-// const i18n = remote.getGlobal( 'i18n' );
-let i18n = {t:string => string};
-
-import styles from '../../styles/components/LoggedInAs.module.less';
-
-export default class LoggedInAs extends Component {
- static propTypes = {
- dropMenu: PropTypes.bool.isRequired,
- isUploadInProgress: PropTypes.bool.isRequired,
- onCheckForUpdates: PropTypes.func.isRequired,
- onChooseDevices: PropTypes.func.isRequired,
- onClicked: PropTypes.func.isRequired,
- onLogout: PropTypes.func.isRequired,
- user: PropTypes.object,
- isClinicAccount: PropTypes.bool,
- targetUsersForUpload: PropTypes.array
- }
-
- constructor(props) {
- super(props);
- this.state = { loggingOut: false };
- }
-
- noopHandler(e) {
- if (e) {
- e.preventDefault();
- }
- }
-
- handleChooseDevices = e => {
- e.preventDefault();
- this.props.onChooseDevices();
- };
-
- handleCheckForUpdates = e => {
- e.preventDefault();
- this.props.onCheckForUpdates();
- if(env.electron_renderer){
- ipcRenderer.send('autoUpdater','checkForUpdates');
- }
- };
-
- handleLogout = e => {
- e.preventDefault();
- this.setState({
- loggingOut: true
- });
- var self = this;
- this.props.onLogout(function(err) {
- if (err) {
- self.setState({
- loggingOut: false
- });
- }
- });
- };
-
- renderChooseDevices() {
- var title = '';
- var uploadInProgress = this.props.isUploadInProgress;
- var isDisabled = uploadInProgress;
-
- if (this.props.isClinicAccount) {
- return null;
- }
-
- if (_.isEmpty(this.props.targetUsersForUpload)) {
- isDisabled = true;
- }
-
-
- if (uploadInProgress) {
- title = i18n.t('Upload in progress!\nPlease wait to change device selection.');
- } else if (isDisabled) {
- title = i18n.t('Set up data storage to upload devices.');
- }
-
- return (
-
- );
- }
-}
diff --git a/app/components/Login.js b/app/components/Login.js
deleted file mode 100644
index d8eb8b78e..000000000
--- a/app/components/Login.js
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * == BSD2 LICENSE ==
- * Copyright (c) 2014, Tidepool Project
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the associated License, which is identical to the BSD 2-Clause
- * License as published by the Open Source Initiative at opensource.org.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the License for more details.
- *
- * You should have received a copy of the License along with this program; if
- * not, you can obtain one from Tidepool Project at tidepool.org.
- * == BSD2 LICENSE ==
- */
-
-import PropTypes from 'prop-types';
-import React, { Component } from 'react';
-import styles from '../../styles/components/Login.module.less';
-import { connect } from 'react-redux';
-import { bindActionCreators } from 'redux';
-import actions from '../actions/';
-const asyncActions = actions.async;
-
-//const remote = require('@electron/remote');
-// const i18n = remote.getGlobal( 'i18n' );
-let i18n = {t:string => string};
-
-export class Login extends Component {
- renderForgotPasswordLink() {
- return (
-
- {i18n.t('Forgot password?')}
-
- );
- }
-
- renderButton() {
- var text = i18n.t('Log in');
-
- if (this.props.isFetching) {
- text = i18n.t('Logging in...');
- }
-
- return (
-
- );
- }
-
- handleLogin(e) {
- e.preventDefault();
- var username = this.username.value;
- var password = this.password.value;
- var remember = this.remember.checked;
-
- this.props.onLogin(
- {username: username, password: password},
- {remember: remember}
- );
- }
-
- renderError() {
- if (!this.props.errorMessage) {
- return null;
- }
-
- return {i18n.t(this.props.errorMessage)};
- }
-
- render() {
- return (
-
-
-
- );
- }
-}
-
-Login.propTypes = {
- disabled: PropTypes.bool.isRequired,
- errorMessage: PropTypes.string,
- forgotPasswordUrl: PropTypes.string.isRequired,
- isFetching: PropTypes.bool.isRequired,
- onLogin: PropTypes.func.isRequired
-};
-
-export default connect(
- (state) => {
- return {
- disabled: Boolean(state.unsupported),
- errorMessage: state.loginErrorMessage,
- forgotPasswordUrl: state.blipUrls.forgotPassword,
- isFetching: state.working.fetchingUserInfo,
- };
- },
- (dispatch) => {
- return {
- onLogin: bindActionCreators(asyncActions.doLogin, dispatch)
- };
- }
-)(Login);
diff --git a/app/components/NoUploadTargets.js b/app/components/NoUploadTargets.js
deleted file mode 100644
index f9a598e8b..000000000
--- a/app/components/NoUploadTargets.js
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-* == BSD2 LICENSE ==
-* Copyright (c) 2016, Tidepool Project
-*
-* This program is free software; you can redistribute it and/or modify it under
-* the terms of the associated License, which is identical to the BSD 2-Clause
-* License as published by the Open Source Initiative at opensource.org.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-* FOR A PARTICULAR PURPOSE. See the License for more details.
-*
-* You should have received a copy of the License along with this program; if
-* not, you can obtain one from Tidepool Project at tidepool.org.
-* == BSD2 LICENSE ==
-*/
-
-import PropTypes from 'prop-types';
-import React, { Component } from 'react';
-
-import { urls } from '../constants/otherConstants';
-
-import styles from '../../styles/components/NoUploadTargets.module.less';
-
-//const remote = require('@electron/remote');
-// const i18n = remote.getGlobal( 'i18n' );
-let i18n = {t:string => string};
-
-export default class NoUploadTargets extends Component {
- static propTypes = {
- newPatientLink: PropTypes.string.isRequired,
- };
-
- render() {
- const { newPatientLink } = this.props;
-
- return (
-
{i18n.t('Or, ask the person you are uploading for to grant you access to upload.')} {i18n.t('How?')}
-
-
- );
- }
-}
diff --git a/app/components/ProgressBar.js b/app/components/ProgressBar.js
deleted file mode 100644
index 1df3f4a7b..000000000
--- a/app/components/ProgressBar.js
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-* == BSD2 LICENSE ==
-* Copyright (c) 2014, Tidepool Project
-*
-* This program is free software; you can redistribute it and/or modify it under
-* the terms of the associated License, which is identical to the BSD 2-Clause
-* License as published by the Open Source Initiative at opensource.org.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-* FOR A PARTICULAR PURPOSE. See the License for more details.
-*
-* You should have received a copy of the License along with this program; if
-* not, you can obtain one from Tidepool Project at tidepool.org.
-* == BSD2 LICENSE ==
-*/
-
-var React = require('react');
-var PropTypes = require('prop-types');
-
-var styles = require('../../styles/components/ProgressBar.module.less');
-
-class ProgressBar extends React.Component {
- static propTypes = {
- // Percentage is an integer between 0 and 100
- percentage: PropTypes.number.isRequired
- };
-
- render() {
- // Minimum fill of 1%
- var width = this.props.percentage ? this.props.percentage : 1;
- return (
-
-
-
- );
- }
-}
-
-module.exports = ProgressBar;
diff --git a/app/components/TimezoneDropdown.js b/app/components/TimezoneDropdown.js
deleted file mode 100644
index ffd5df9f5..000000000
--- a/app/components/TimezoneDropdown.js
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
-* == BSD2 LICENSE ==
-* Copyright (c) 2014, Tidepool Project
-*
-* This program is free software; you can redistribute it and/or modify it under
-* the terms of the associated License, which is identical to the BSD 2-Clause
-* License as published by the Open Source Initiative at opensource.org.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-* FOR A PARTICULAR PURPOSE. See the License for more details.
-*
-* You should have received a copy of the License along with this program; if
-* not, you can obtain one from Tidepool Project at tidepool.org.
-* == BSD2 LICENSE ==
-*/
-import Select from 'react-select';
-
-var _ = require('lodash');
-var React = require('react');
-var PropTypes = require('prop-types');
-var sundial = require('sundial');
-var cx = require('classnames');
-
-var styles = require('../../styles/components/TimezoneDropdown.module.less');
-
-//const remote = require('@electron/remote');
-// const i18n = remote.getGlobal( 'i18n' );
-let i18n = {t:string => string};
-
-class TimezoneDropdown extends React.Component {
- constructor(props) {
- super(props);
-
- this.timezoneSelect = null;
-
- this.setTimezoneSelect = element => {
- this.timezoneSelect = element;
- };
- }
-
- static propTypes = {
- onTimezoneChange: PropTypes.func.isRequired,
- selectorLabel: PropTypes.string.isRequired,
- // targetId can be null when logged in user is not a data storage account
- // for example a clinic worker
- targetId: PropTypes.string,
- targetTimezone: PropTypes.string,
- updateProfileErrorMessage: PropTypes.string,
- updateProfileErrorDismissed: PropTypes.bool,
- dismissUpdateProfileError: PropTypes.func.isRequired,
- isClinicAccount: PropTypes.bool,
- userDropdownShowing: PropTypes.bool,
- isUploadInProgress: PropTypes.bool.isRequired,
- onBlur: PropTypes.func.isRequired,
- isTimezoneFocused: PropTypes.bool.isRequired
- };
-
- UNSAFE_componentWillReceiveProps(nextProps) {
- if (!this.props.targetId && nextProps.targetId !== null) {
- if (this.props.targetTimezone !== null) {
- this.props.onTimezoneChange(
- nextProps.targetId,
- this.props.targetTimezone
- );
- }
- }
- }
-
- componentDidMount() {
- var self = this;
- self.updateSuggestedInterval = setInterval(
- function(){
- self.setState({time: new Date()});
- }, 1000 * 60
- );
- }
-
- componentWillUnmount() {
- clearInterval(this.updateSuggestedInterval);
- }
-
- componentDidUpdate() {
- if (this.timezoneSelect && this.props.isTimezoneFocused) {
- this.timezoneSelect.focus();
- }
- }
-
- buildTzSelector = () => {
- function sortByOffset(timezones) {
- return _.sortBy(timezones, function(tz) {
- return tz.offset;
- });
- }
- var timezones = sundial.getTimezones();
- var opts = sortByOffset(timezones.bigFour)
- .concat(sortByOffset(timezones.unitedStates))
- .concat(sortByOffset(timezones.hoisted))
- .concat(sortByOffset(timezones.theRest));
- var targetUser = this.props.targetId || 'noUserSelected';
-
- return (
-
- );
- };
-
- renderSuggestedTime = () => {
- if(this.props.targetTimezone){
- let textClinic = i18n.t('The device times should be approximately');
- let textPatient = i18n.t('Your device times should be approximately');
- let text = this.props.isClinicAccount ? textClinic : textPatient;
- let timez = this.props.targetTimezone;
- return (
-
- );
- }
-}
-
-module.exports = TimezoneDropdown;
diff --git a/app/components/UpdateDriverModal.js b/app/components/UpdateDriverModal.js
deleted file mode 100644
index ffbd0a996..000000000
--- a/app/components/UpdateDriverModal.js
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
-* == BSD2 LICENSE ==
-* Copyright (c) 2014-2016, Tidepool Project
-*
-* This program is free software; you can redistribute it and/or modify it under
-* the terms of the associated License, which is identical to the BSD 2-Clause
-* License as published by the Open Source Initiative at opensource.org.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-* FOR A PARTICULAR PURPOSE. See the License for more details.
-*
-* You should have received a copy of the License along with this program; if
-* not, you can obtain one from Tidepool Project at tidepool.org.
-* == BSD2 LICENSE ==
-*/
-
-import _ from 'lodash';
-import React, { Component } from 'react';
-import { connect } from 'react-redux';
-import { bindActionCreators } from 'redux';
-
-import { sync as syncActions } from '../actions/';
-
-import styles from '../../styles/components/UpdateDriverModal.module.less';
-import env from '../utils/env';
-
-let sudo;
-if(env.electron_renderer){
- sudo = require('sudo-prompt');
-}
-
-//const remote = require('@electron/remote');
-// const i18n = remote.getGlobal( 'i18n' );
-let i18n = {t:string => string};
-
-export class UpdateDriverModal extends Component {
- handleInstall = () => {
- const { sync, driverUpdateShellOpts } = this.props;
- const { execString, options } = driverUpdateShellOpts.opts;
- if(env.electron_renderer){
- sudo.exec(execString, options,
- (error, stdout, stderr) => {
- console.log('sudo result: ' + stdout);
- if (error) {
- console.log(error);
- }
- sync.driverInstall();
- }
- );
- }
- };
-
- render() {
- const {
- checkingDriverUpdate,
- driverUpdateAvailable,
- driverUpdateAvailableDismissed,
- driverUpdateComplete,
- sync
- } = this.props;
-
- let title, text, actions;
-
- if(driverUpdateAvailableDismissed || driverUpdateComplete || !driverUpdateAvailable){
- return null;
- }
-
- if (checkingDriverUpdate){
- title = i18n.t('Checking for driver update...');
- } else {
- if (driverUpdateAvailable) {
- title = i18n.t('Driver Update Available!');
- text = i18n.t('After clicking Install, the uploader will ask for your password to complete the installation. This window will close when completed.');
- actions = [
- ,
-
- ];
- }
- }
-
- return (
-
-
-
- {title}
-
-
- {text}
-
-
- {actions}
-
-
-
- );
- }
-};
-
-export default connect(
- (state, ownProps) => {
- return {
- // plain state
- checkingDriverUpdate: state.working.checkingDriverUpdate,
- driverUpdateAvailableDismissed: state.driverUpdateAvailableDismissed,
- driverUpdateAvailable: state.driverUpdateAvailable,
- driverUpdateShellOpts: state.driverUpdateShellOpts,
- driverUpdateComplete: state.driverUpdateComplete
- };
- },
- (dispatch) => {
- return {
- sync: bindActionCreators(syncActions, dispatch)
- };
- }
-)(UpdateDriverModal);
diff --git a/app/components/UpdateModal.js b/app/components/UpdateModal.js
deleted file mode 100644
index dc51cef8f..000000000
--- a/app/components/UpdateModal.js
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
-* == BSD2 LICENSE ==
-* Copyright (c) 2014-2016, Tidepool Project
-*
-* This program is free software; you can redistribute it and/or modify it under
-* the terms of the associated License, which is identical to the BSD 2-Clause
-* License as published by the Open Source Initiative at opensource.org.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-* FOR A PARTICULAR PURPOSE. See the License for more details.
-*
-* You should have received a copy of the License along with this program; if
-* not, you can obtain one from Tidepool Project at tidepool.org.
-* == BSD2 LICENSE ==
-*/
-
-import _ from 'lodash';
-import React, { Component } from 'react';
-import { connect } from 'react-redux';
-import { bindActionCreators } from 'redux';
-
-import { sync as syncActions } from '../actions/';
-import config from '../../lib/config.js';
-
-import styles from '../../styles/components/UpdateModal.module.less';
-
-import env from '../utils/env';
-let ipcRenderer;
-if(env.electron_renderer) {
- ({ipcRenderer} = require('electron'));
-}
-
-//const remote = require('@electron/remote');
-// const i18n = remote.getGlobal( 'i18n' );
-let i18n = {t:string => string};
-
-export class UpdateModal extends Component {
- handleInstall = () => {
- const { sync } = this.props;
- sync.quitAndInstall();
- if(env.electron_renderer){
- ipcRenderer.send('autoUpdater', 'quitAndInstall');
- }
- };
-
- render() {
- const {
- checkingElectronUpdate,
- electronUpdateDownloaded,
- electronUpdateAvailable,
- electronUpdateManualChecked,
- electronUpdateAvailableDismissed,
- sync
- } = this.props;
-
- let title, text, actions;
-
- if(electronUpdateAvailableDismissed){
- return null;
- }
-
- if (electronUpdateManualChecked) {
- if (checkingElectronUpdate){
- title = i18n.t('Checking for update...');
- } else {
- if (electronUpdateAvailable) {
- title = i18n.t('Update Available!');
- if (!electronUpdateDownloaded) {
- text = i18n.t('Downloading update');
- } else { // available and downloaded
- text = i18n.t('After clicking Install, the uploader will restart to complete the installation.');
- actions = [
- ,
-
- ];
- }
- } else { // no update available
- title = i18n.t('Uploader is up-to-date!');
- text = i18n.t('You are running version {{text}}, the most recent one.', { text: config.version });
- actions = (
-
- );
- }
- }
- }
- else { // automatic background check
- if(electronUpdateAvailable && electronUpdateDownloaded){
- title = i18n.t('Update Available!');
- text = i18n.t('After clicking Install, the uploader will restart to complete the installation.');
- actions = [
- ,
-
- ];
- } else {
- return null;
- }
- }
-
- return (
-
-
-
- {title}
-
-
- {text}
-
-
- {actions}
-
-
-
- );
- }
-};
-
-export default connect(
- (state, ownProps) => {
- return {
- // plain state
- checkingElectronUpdate: state.working.checkingElectronUpdate,
- electronUpdateAvailableDismissed: state.electronUpdateAvailableDismissed,
- electronUpdateAvailable: state.electronUpdateAvailable,
- electronUpdateDownloaded: state.electronUpdateDownloaded,
- electronUpdateManualChecked: state.electronUpdateManualChecked
- };
- },
- (dispatch) => {
- return {
- sync: bindActionCreators(syncActions, dispatch)
- };
- }
-)(UpdateModal);
diff --git a/app/components/UpdatePlease.js b/app/components/UpdatePlease.js
deleted file mode 100644
index 68f40cba1..000000000
--- a/app/components/UpdatePlease.js
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-* == BSD2 LICENSE ==
-* Copyright (c) 2014-2016, Tidepool Project
-*
-* This program is free software; you can redistribute it and/or modify it under
-* the terms of the associated License, which is identical to the BSD 2-Clause
-* License as published by the Open Source Initiative at opensource.org.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-* FOR A PARTICULAR PURPOSE. See the License for more details.
-*
-* You should have received a copy of the License along with this program; if
-* not, you can obtain one from Tidepool Project at tidepool.org.
-* == BSD2 LICENSE ==
-*/
-
-import React, { Component } from 'react';
-import PropTypes from 'prop-types';
-
-import styles from '../../styles/components/VersionCheck.module.less';
-
-//const remote = require('@electron/remote');
-// const i18n = remote.getGlobal( 'i18n' );
-let i18n = {t:string => string};
-
-export default class UpdatePlease extends Component {
- static propTypes = {
- knowledgeBaseLink: PropTypes.string.isRequired,
- updateText: PropTypes.object.isRequired
- };
-
- static defaultProps = {
- updateText: {
- NEEDS_UPDATED: i18n.t('This uploader needs to be updated'),
- IMPROVEMENTS: i18n.t('because we made some improvements!')
- }
- };
-
- render() {
- const { knowledgeBaseLink, updateText } = this.props;
- return (
-
- {i18n.t('Medtronic has removed the CareLink export feature.')}
- {i18n.t('Click below to enable direct upload to Tidepool using a Contour Next Link.')}
-
;
- }
-
- let percentage = upload.progress && upload.progress.percentage;
-
- // can be equal to 0, so check for null or undefined
- if (percentage == null) {
- return null;
- }
-
- return
- );
- } else {
- return null;
- }
- }
-}
diff --git a/app/components/UserDropdown.js b/app/components/UserDropdown.js
deleted file mode 100644
index d63926c3e..000000000
--- a/app/components/UserDropdown.js
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
-* == BSD2 LICENSE ==
-* Copyright (c) 2014, Tidepool Project
-*
-* This program is free software; you can redistribute it and/or modify it under
-* the terms of the associated License, which is identical to the BSD 2-Clause
-* License as published by the Open Source Initiative at opensource.org.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-* FOR A PARTICULAR PURPOSE. See the License for more details.
-*
-* You should have received a copy of the License along with this program; if
-* not, you can obtain one from Tidepool Project at tidepool.org.
-* == BSD2 LICENSE ==
-*/
-import Select from 'react-select';
-
-var _ = require('lodash');
-var React = require('react');
-var PropTypes = require('prop-types');
-var personUtils = require('../../lib/core/personUtils');
-var pagesMap = require('../constants/otherConstants').pagesMap;
-
-var styles = require('../../styles/components/UserDropdown.module.less');
-
-//const remote = require('@electron/remote');
-// const i18n = remote.getGlobal( 'i18n' );
-let i18n = {t:string => string};
-
-class UserDropdown extends React.Component {
- static propTypes = {
- allUsers: PropTypes.object.isRequired,
- isUploadInProgress: PropTypes.bool,
- onGroupChange: PropTypes.func.isRequired,
- locationPath: PropTypes.string.isRequired,
- targetId: PropTypes.string,
- targetUsersForUpload: PropTypes.array.isRequired
- };
-
- groupSelector = () => {
- var allUsers = this.props.allUsers;
- var targets = this.props.targetUsersForUpload;
-
- // and now return them sorted them by name
- var sorted = _.sortBy(targets, function(targetId) {
- return personUtils.patientFullName(allUsers[targetId]);
- });
-
- var selectorOpts = _.map(sorted, function(targetId) {
- return {
- value: targetId,
- label: personUtils.patientFullName(allUsers[targetId])
- };
- });
-
- var disable = this.props.isUploadInProgress ? true : false;
-
- return (
-
- );
- };
-
- render() {
- // we're already doing a check to see if we want to render in App.js
- // but this is an extra measure of protection against trying to render
- // when we don't have the potential target users to do so
- if (_.isEmpty(this.props.targetUsersForUpload)) {
- return null;
- }
-
- var text = this.props.locationPath === pagesMap.MAIN ?
- i18n.t('Upload data for') : i18n.t('Choose devices for');
- var styleClass = this.props.locationPath.substring(1);
-
- return (
-
-
-
{text}
-
- {this.groupSelector()}
-
-
-
- );
- }
-}
-
-module.exports = UserDropdown;
diff --git a/app/components/VersionCheckError.js b/app/components/VersionCheckError.js
deleted file mode 100644
index ecfed7769..000000000
--- a/app/components/VersionCheckError.js
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
-* == BSD2 LICENSE ==
-* Copyright (c) 2016, Tidepool Project
-*
-* This program is free software; you can redistribute it and/or modify it under
-* the terms of the associated License, which is identical to the BSD 2-Clause
-* License as published by the Open Source Initiative at opensource.org.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-* FOR A PARTICULAR PURPOSE. See the License for more details.
-*
-* You should have received a copy of the License along with this program; if
-* not, you can obtain one from Tidepool Project at tidepool.org.
-* == BSD2 LICENSE ==
-*/
-
-import cx from 'classnames';
-import PropTypes from 'prop-types';
-import React, { Component } from 'react';
-
-import errorText from '../constants/errors';
-
-import styles from '../../styles/components/VersionCheck.module.less';
-import CloudOff from '@material-ui/icons/CloudOff';
-
-//const remote = require('@electron/remote');
-// const i18n = remote.getGlobal( 'i18n' );
-let i18n = {t:string => string};
-
-export default class VersionCheckError extends Component {
- static propTypes = {
- errorMessage: PropTypes.string.isRequired,
- errorText: PropTypes.object.isRequired
- };
-
- static defaultProps = {
- errorText: {
- CONNECT: i18n.t('Please check your connection, quit & relaunch to try again.'),
- ERROR_DETAILS: i18n.t('Details for Tidepool\'s developers:'),
- OFFLINE: i18n.t('You\'re not connected to the Internet.'),
- SERVERS_DOWN: i18n.t('We can\'t connect to Tidepool right now.'),
- TRY_AGAIN: i18n.t('Quit & relaunch the Uploader to try again.')
- }
- };
-
- constructor(props) {
- super(props);
- }
-
- render() {
- const { errorMessage } = this.props;
- const userErrorText = this.props.errorText;
- const offline = errorMessage === errorText.E_OFFLINE;
- const errorDetails = offline ? null : (
-
- );
- }
-}
diff --git a/app/components/ViewDataLink.js b/app/components/ViewDataLink.js
deleted file mode 100644
index 7a43ee5df..000000000
--- a/app/components/ViewDataLink.js
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-* == BSD2 LICENSE ==
-* Copyright (c) 2014, Tidepool Project
-*
-* This program is free software; you can redistribute it and/or modify it under
-* the terms of the associated License, which is identical to the BSD 2-Clause
-* License as published by the Open Source Initiative at opensource.org.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-* FOR A PARTICULAR PURPOSE. See the License for more details.
-*
-* You should have received a copy of the License along with this program; if
-* not, you can obtain one from Tidepool Project at tidepool.org.
-* == BSD2 LICENSE ==
-*/
-
-var _ = require('lodash');
-var PropTypes = require('prop-types');
-var React = require('react');
-
-var styles = require('../../styles/components/ViewDataLink.module.less');
-
-//const remote = require('@electron/remote');
-// const i18n = remote.getGlobal( 'i18n' );
-let i18n = {t:string => string};
-
-class ViewDataLink extends React.Component {
- static propTypes = {
- href: PropTypes.string.isRequired,
- onViewClicked: PropTypes.func.isRequired
- };
-
- render() {
- return (
-
- );
- }
-
- handleContextMenu = e => {
- e.preventDefault();
- const { clientX, clientY } = e;
- let template = [];
- if (process.env.NODE_ENV === 'development') {
- template.push({
- label: 'Inspect element',
- click() {
- remote.getCurrentWindow().inspectElement(clientX, clientY);
- }
- });
- template.push({
- type: 'separator'
- });
- }
- if (this.props.location.pathname === pagesMap.LOGIN) {
- const submenus = [];
- for (let server of _.keys(serverdata)) {
- submenus.push({
- label: server,
- click: this.setServer,
- type: 'radio',
- checked: this.state.server === server
- });
- }
- template.push({
- label: 'Change server',
- submenu: submenus,
- });
- template.push({
- label: 'Toggle Debug Mode',
- type: 'checkbox',
- checked: debugMode.isDebug,
- click() {
- debugMode.setDebug(!debugMode.isDebug);
- }
- });
- }
- const menu = remote.Menu.buildFromTemplate(template);
- menu.popup(remote.getCurrentWindow());
- };
-
- handleDismissDropdown = () => {
- const { dropdown } = this.props;
- // only toggle the dropdown by clicking elsewhere if it's open
- if (dropdown === true) {
- this.props.sync.toggleDropdown(dropdown);
- }
- };
-
- renderVersionCheck() {
- const { readyToRenderVersionCheckOverlay, unsupported } = this.props;
- if (readyToRenderVersionCheckOverlay === false || unsupported === false) {
- return null;
- }
- if (unsupported instanceof Error) {
- return (
-
- );
- }
- if (unsupported === true) {
- return (
-
- );
- }
- }
-}
-
-App.propTypes = {};
-
-export default hot(module)(connect(
- (state, ownProps) => {
- return {
- // plain state
- dropdown: state.dropdown,
- unsupported: state.unsupported,
- // derived state
- readyToRenderVersionCheckOverlay: (
- !state.working.initializingApp && !state.working.checkingVersion
- )
- };
- },
- (dispatch) => {
- return {
- async: bindActionCreators(asyncActions, dispatch),
- sync: bindActionCreators(syncActions, dispatch),
- dispatch: dispatch
- };
- }
-)(App));
diff --git a/app/containers/ClinicUserEditPage.js b/app/containers/ClinicUserEditPage.js
deleted file mode 100644
index 8eb0ed4a7..000000000
--- a/app/containers/ClinicUserEditPage.js
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * == BSD2 LICENSE ==
- * Copyright (c) 2014-2016, Tidepool Project
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the associated License, which is identical to the BSD 2-Clause
- * License as published by the Open Source Initiative at opensource.org.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the License for more details.
- *
- * You should have received a copy of the License along with this program; if
- * not, you can obtain one from Tidepool Project at tidepool.org.
- * == BSD2 LICENSE ==
- */
-
-import _ from 'lodash';
-import { bindActionCreators } from 'redux';
-import { connect } from 'react-redux';
-import { pages } from '../constants/otherConstants';
-import * as metrics from '../constants/metrics';
-import actions from '../actions/';
-import React, { Component } from 'react';
-import ClinicUserEdit from '../components/ClinicUserEdit';
-
-const asyncActions = actions.async;
-const syncActions = actions.sync;
-
-export class ClinicUserEditPage extends Component {
- handleClickChangePerson = (metric = {metric: {eventName: metrics.CLINIC_SEARCH_DISPLAYED}}) => {
- const { setUploadTargetUser } = this.props.sync;
- const { setPage } = this.props.async;
- setUploadTargetUser(null);
- setPage(pages.CLINIC_USER_SELECT, undefined, metric);
- };
-
- render() {
- const { allUsers, uploadTargetUser, memberships } = this.props;
- return (
-
-
-
- );
- }
-}
-
-export default connect(
- (state) => {
- return {
- allUsers: state.allUsers,
- loggedInUser: state.loggedInUser,
- targetUsersForUpload: state.targetUsersForUpload,
- uploadTargetUser: state.uploadTargetUser,
- updateProfileErrorMessage: state.updateProfileErrorMessage,
- updateProfileErrorDismissed: state.updateProfileErrorDismissed,
- createCustodialAccountErrorMessage: state.createCustodialAccountErrorMessage,
- createCustodialAccountErrorDismissed: state.createCustodialAccountErrorDismissed,
- memberships: state.memberships,
- };
- },
- (dispatch) => {
- return {
- async: bindActionCreators(asyncActions, dispatch),
- sync: bindActionCreators(syncActions, dispatch)
- };
- }
-)(ClinicUserEditPage);
diff --git a/app/containers/ClinicUserSelectPage.js b/app/containers/ClinicUserSelectPage.js
deleted file mode 100644
index a47d74161..000000000
--- a/app/containers/ClinicUserSelectPage.js
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * == BSD2 LICENSE ==
- * Copyright (c) 2014-2016, Tidepool Project
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the associated License, which is identical to the BSD 2-Clause
- * License as published by the Open Source Initiative at opensource.org.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the License for more details.
- *
- * You should have received a copy of the License along with this program; if
- * not, you can obtain one from Tidepool Project at tidepool.org.
- * == BSD2 LICENSE ==
- */
-
-import { bindActionCreators } from 'redux';
-import { connect } from 'react-redux';
-import actions from '../actions/';
-import React, { Component } from 'react';
-import ClinicUserSelect from '../components/ClinicUserSelect';
-
-const asyncActions = actions.async;
-const syncActions = actions.sync;
-
-export class ClinicUserSelectPage extends Component {
-
- render() {
- const { allUsers, targetUsersForUpload, uploadTargetUser } = this.props;
- return (
-
-
-
- );
- }
-}
-
-export default connect(
- (state) => {
- return {
- allUsers: state.allUsers,
- targetUsersForUpload: state.targetUsersForUpload,
- uploadTargetUser: state.uploadTargetUser,
- };
- },
- (dispatch) => {
- return {
- async: bindActionCreators(asyncActions, dispatch),
- sync: bindActionCreators(syncActions, dispatch)
- };
- }
-)(ClinicUserSelectPage);
diff --git a/app/containers/MainPage.js b/app/containers/MainPage.js
deleted file mode 100644
index b5acfc236..000000000
--- a/app/containers/MainPage.js
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * == BSD2 LICENSE ==
- * Copyright (c) 2014-2016, Tidepool Project
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the associated License, which is identical to the BSD 2-Clause
- * License as published by the Open Source Initiative at opensource.org.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the License for more details.
- *
- * You should have received a copy of the License along with this program; if
- * not, you can obtain one from Tidepool Project at tidepool.org.
- * == BSD2 LICENSE ==
- */
-
-import _ from 'lodash';
-import { bindActionCreators } from 'redux';
-import { connect } from 'react-redux';
-import { pages } from '../constants/otherConstants';
-import * as actionSources from '../constants/actionSources';
-import * as metrics from '../constants/metrics';
-import actions from '../actions/';
-import ClinicUploadDone from '../components/ClinicUploadDone';
-import ClinicUserBlock from '../components/ClinicUserBlock';
-import cx from 'classnames';
-import React, { Component } from 'react';
-import styles from '../../styles/components/App.module.less';
-import TimezoneDropdown from '../components/TimezoneDropdown';
-import UploadList from '../components/UploadList';
-import ViewDataLink from '../components/ViewDataLink';
-import UserDropdown from '../components/UserDropdown';
-//const remote = require('@electron/remote');
-
-const asyncActions = actions.async;
-const syncActions = actions.sync;
-
-// const i18n = remote.getGlobal('i18n');
-let i18n = {t:string => string};
-
-export class MainPage extends Component {
- handleClickEditUser = () => {
- const { setPage } = this.props.async;
- setPage(pages.CLINIC_USER_EDIT, undefined, {metric: {eventName: metrics.CLINIC_EDIT_INFO}});
- };
-
- handleClickChangePerson = (metric = {metric: {eventName: metrics.CLINIC_SEARCH_DISPLAYED}}) => {
- const { setUploadTargetUser } = this.props.sync;
- const { setPage } = this.props.async;
- setUploadTargetUser(null);
- setPage(pages.CLINIC_USER_SELECT, undefined, metric);
- };
-
- handleClickChooseDevices = metric => {
- const { toggleDropdown } = this.props.sync;
- const { setPage } = this.props.async;
- // ensure dropdown closes after click
- setPage(pages.SETTINGS, true, metric);
- toggleDropdown(true, actionSources.UNDER_THE_HOOD);
- };
-
- renderTimezoneDropdown() {
- const { uploadTargetUser } = this.props;
- return (
-
- );
- }
-
- renderUploadListDoneButton() {
- const { isClinicAccount } = this.props;
- if (isClinicAccount && this.props.uploadTargetUser) {
- return ;
- } else {
- const viewDataLink = _.get(this.props, ['blipUrls', 'viewDataLink'], '');
- return ;
- }
- }
-
- renderUserDropdown() {
- const { allUsers, targetUsersForUpload, uploadTargetUser, location } = this.props;
- return (
-
- );
- }
-
- renderChangePersonLink() {
- var classes = cx({
- [styles.changePerson]: true,
- [styles.linkDisabled]: this.props.uploadIsInProgress
- });
- return (
-
- );
- }
-}
-
-export default connect(
- (state) => {
- function getSelectedTimezone(state) {
- return _.get(
- state,
- ['targetTimezones', state.uploadTargetUser],
- // fall back to the timezone stored under 'noUserSelected', if any
- _.get(state, ['targetTimezones', 'noUserSelected'], null)
- );
- }
- function getActiveUploads(state) {
- const { devices, uploadsByUser, uploadTargetUser } = state;
- if (uploadTargetUser === null) {
- return [];
- }
- let activeUploads = [];
- const targetUsersUploads = _.get(uploadsByUser, uploadTargetUser, []);
- _.map(_.keys(targetUsersUploads), (deviceKey) => {
- const upload = uploadsByUser[uploadTargetUser][deviceKey];
- const device = _.pick(devices[deviceKey], ['instructions', 'image', 'key', 'name', 'source']);
- const progress = upload.uploading ? {progress: state.uploadProgress} :
- (upload.successful ? {progress: {percentage: 100}} : {});
- activeUploads.push(_.assign({}, device, upload, progress));
- });
- // ensure that carelink is last
- const carelink = _.remove(activeUploads, {'key': 'carelink'});
- if(!_.isEmpty(carelink)){
- activeUploads = activeUploads.concat(carelink);
- }
- return activeUploads;
- }
- function shouldShowUserSelectionDropdown(state) {
- if (!_.isEmpty(state.targetUsersForUpload) && !isClinicAccount(state)) {
- // if there's only one potential target for upload but it's *not* the loggedInUser
- if (state.targetUsersForUpload.length === 1 &&
- !_.includes(state.targetUsersForUpload, state.loggedInUser)) {
- return true;
- }
- if (state.targetUsersForUpload.length > 1) {
- return true;
- }
- }
- return false;
- }
- function isClinicAccount(state) {
- return _.indexOf(_.get(_.get(state.allUsers, state.loggedInUser, {}), 'roles', []), 'clinic') !== -1;
- }
- return {
- activeUploads: getActiveUploads(state),
- allUsers: state.allUsers,
- memberships: state.memberships,
- blipUrls: state.blipUrls,
- isClinicAccount: isClinicAccount(state),
- isTimezoneFocused: state.isTimezoneFocused,
- page: state.page,
- selectedTimezone: getSelectedTimezone(state),
- showingUserSelectionDropdown: shouldShowUserSelectionDropdown(state),
- targetUsersForUpload: state.targetUsersForUpload,
- unsupported: state.unsupported,
- updateProfileErrorMessage: state.updateProfileErrorMessage,
- uploadIsInProgress: state.working.uploading,
- uploadTargetUser: state.uploadTargetUser,
- uploadsByUser: state.uploadsByUser,
- };
- },
- (dispatch) => {
- return {
- async: bindActionCreators(asyncActions, dispatch),
- sync: bindActionCreators(syncActions, dispatch)
- };
- }
-)(MainPage);
diff --git a/app/containers/NoUploadTargetsPage.js b/app/containers/NoUploadTargetsPage.js
deleted file mode 100644
index b971bc31f..000000000
--- a/app/containers/NoUploadTargetsPage.js
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * == BSD2 LICENSE ==
- * Copyright (c) 2014-2016, Tidepool Project
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the associated License, which is identical to the BSD 2-Clause
- * License as published by the Open Source Initiative at opensource.org.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the License for more details.
- *
- * You should have received a copy of the License along with this program; if
- * not, you can obtain one from Tidepool Project at tidepool.org.
- * == BSD2 LICENSE ==
- */
-
-import _ from 'lodash';
-import { connect } from 'react-redux';
-import React, { Component } from 'react';
-import NoUploadTargets from '../components/NoUploadTargets';
-
-export class NoUploadTargetsPage extends Component {
-
- render() {
- const newPatientLink = _.get(this.props, ['blipUrls', 'newPatient'], '');
- return (
-
-
-
- );
- }
-}
-
-export default connect(
- (state) => {
- return {
- blipUrls: state.blipUrls,
- };
- }
-)(NoUploadTargetsPage);
diff --git a/app/containers/SettingsPage.js b/app/containers/SettingsPage.js
deleted file mode 100644
index f0c66f3d7..000000000
--- a/app/containers/SettingsPage.js
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * == BSD2 LICENSE ==
- * Copyright (c) 2014, Tidepool Project
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the associated License, which is identical to the BSD 2-Clause
- * License as published by the Open Source Initiative at opensource.org.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the License for more details.
- *
- * You should have received a copy of the License along with this program; if
- * not, you can obtain one from Tidepool Project at tidepool.org.
- * == BSD2 LICENSE ==
- */
-
-import _ from 'lodash';
-import React, { Component } from 'react';
-import DeviceSelection from '../components/DeviceSelection';
-import UserDropdown from '../components/UserDropdown';
-import ClinicUserBlock from '../components/ClinicUserBlock';
-import cx from 'classnames';
-import styles from '../../styles/components/App.module.less';
-import { pages } from '../constants/otherConstants';
-import * as metrics from '../constants/metrics';
-import { connect } from 'react-redux';
-import { bindActionCreators } from 'redux';
-import actions from '../actions/';
-//const remote = require('@electron/remote');
-
-const asyncActions = actions.async;
-const syncActions = actions.sync;
-
-// const i18n = remote.getGlobal('i18n');
-let i18n = {t:string => string};
-
-export class SettingsPage extends Component {
- handleClickChangePerson = (metric = {metric: {eventName: metrics.CLINIC_SEARCH_DISPLAYED}}) => {
- const { setUploadTargetUser } = this.props.sync;
- const { setPage } = this.props.async;
- setUploadTargetUser(null);
- setPage(pages.CLINIC_USER_SELECT, undefined, metric);
- };
-
- handleClickEditUser = () => {
- const { setPage } = this.props.async;
- setPage(pages.CLINIC_USER_EDIT, undefined, {metric: {eventName: metrics.CLINIC_EDIT_INFO}});
- };
-
- renderChangePersonLink() {
- var classes = cx({
- [styles.changePerson]: true,
- [styles.linkDisabled]: this.props.uploadIsInProgress
- });
- return (
-