Skip to content

Commit

Permalink
bugfix/legacy-upload-error (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJJackson authored Jan 6, 2025
1 parent 4ab03a1 commit 4f33685
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 63 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hhd-ui",
"version": "0.18.8",
"version": "0.18.9",
"private": true,
"dependencies": {
"@ag-grid-community/client-side-row-model": "^30.0.3",
Expand Down
2 changes: 2 additions & 0 deletions src/app-bundles/collection-group-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export default createRestBundle({
forceFetchActions: [
'COLLECTIONGROUP_SAVE_FINISHED',
'COLLECTIONGROUP_DELETE_FINISHED',
'COLLECTIONGROUP_REMOVE_TIMESERIES_FINISH',
'COLLECTIONGROUP_ADD_TIMESERIES_FINISH',
],
urlParamSelectors: ['selectProjectsIdByRoute'],
prefetch: (store) => {
Expand Down
2 changes: 1 addition & 1 deletion src/app-bundles/create-jwt-api-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const processResponse = response => (
'json': json,
}))
// eslint-disable-next-line no-console
.catch(e => console.error(e));
.catch(e => console.error('Error parsing Response JSON', e));
}
})
);
Expand Down
26 changes: 8 additions & 18 deletions src/app-bundles/upload-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,24 +257,14 @@ const uploadBundle = {
});
} else {
// Safety meaasure until ?dry_run=true is complete on API for all uploaders
if (Array.isArray(data) && data.length > 0) {
dispatch({
type: 'UPLOAD_POST_FINISHED',
});
store.doNotificationFire({
message: 'Data Uploaded Successfully',
type: 'success',
autoClose: 10000,
});
} else {
data.errors.forEach((error) => {
store.doNotificationFire({
message: error,
type: 'error',
autoClose: 20000,
});
});
}
dispatch({
type: 'UPLOAD_POST_FINISHED',
});
store.doNotificationFire({
message: 'Data Uploaded Successfully',
type: 'success',
autoClose: 10000,
});
}
}
});
Expand Down
48 changes: 19 additions & 29 deletions src/app-pages/collection-group/collection-group.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react';
import { connect } from 'redux-bundler-react';
import { roundToNearestMinutes } from 'date-fns';
import { Add, KeyboardArrowDown, KeyboardArrowUp } from '@mui/icons-material';
import { Add } from '@mui/icons-material';

import Button from '../../app-components/button';
import Card from '../../app-components/card';
Expand Down Expand Up @@ -29,7 +29,6 @@ export default connect(
collectionGroupDetailByRoute: detail,
projectsByRoute: project,
}) => {
const [isShown, setIsShown] = useState(true);
const [timestampMode, setTimestampMode] = useState('now'); // One of ['now', 'choose']
const [date, setDate] = useState(new Date());

Expand Down Expand Up @@ -107,15 +106,9 @@ export default connect(
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
cursor: 'pointer',
}}
onClick={(_e) => setIsShown(!isShown)}
>
<div className='d-flex flex-row align-items-center'>
{isShown
? <KeyboardArrowUp sx={{ fontSize: '24px', marginRight: '5px' }} />
: <KeyboardArrowDown sx={{ fontSize: '24px', marginRight: '5px' }} />
}
<h5 className='p-0 m-0'>Timeseries</h5>
<RoleFilter allowRoles={[`${project.slug.toUpperCase()}.*`]}>
<Button
Expand All @@ -137,27 +130,24 @@ export default connect(
setDate={setDate}
/>
</Card.Header>

{isShown ? (
<Card.Body>
<div style={{ maxHeight: '600px', overflow: 'auto' }}>
<TimeseriesList
date={date}
project={project}
collectionGroup={detail}
items={detail.timeseries}
handleItemSaveValue={handleTimeseriesSaveValue}
handleItemDelete={(item) => {
doCollectionGroupRemoveTimeseries({
projectId: detail.project_id,
collectionGroupId: detail.id,
timeseriesId: item.id,
});
}}
/>
</div>
</Card.Body>
) : null}
<Card.Body>
<div style={{ maxHeight: '600px', overflow: 'auto' }}>
<TimeseriesList
date={date}
project={project}
collectionGroup={detail}
items={detail.timeseries}
handleItemSaveValue={handleTimeseriesSaveValue}
handleItemDelete={(item) => {
doCollectionGroupRemoveTimeseries({
projectId: detail.project_id,
collectionGroupId: detail.id,
timeseriesId: item.id,
});
}}
/>
</div>
</Card.Body>
</Card>
</div>
</div>
Expand Down
36 changes: 22 additions & 14 deletions src/app-pages/collection-group/collectiongroup-timeseries-list.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useState } from 'react';
import { Add, DeleteOutline, Lock, LockClock, LockOpen } from '@mui/icons-material';
import { DeleteOutline, Lock, LockClock, LockOpen } from '@mui/icons-material';
import { DragDropContext, Draggable, Droppable } from 'react-beautiful-dnd';
import { IconButton, List, ListItem } from '@mui/material';
import { Button, IconButton, List, ListItem } from '@mui/material';
import { formatDistanceToNow, parseISO } from 'date-fns';

import Button from '../../app-components/button';
import RoleFilter from '../../app-components/role-filter';
import { connect } from 'redux-bundler-react';
import { useDeepCompareEffect } from 'react-use';

const TimeseriesListEntry = ({
handleItemSaveValue,
Expand All @@ -31,13 +31,14 @@ const TimeseriesListEntry = ({
<a href={`/${project.slug}/instruments/${item.instrument_slug}`}>
{item.instrument}
</a>
<Button
<IconButton
variant='link'
className='text-secondary h-100'
handleClick={() => handleItemDelete(item)}
icon={<DeleteOutline color='error' fontSize='small' sx={{ marginBottom: '4px' }} />}
onClick={() => handleItemDelete(item)}
title='Remove from group'
/>
>
<DeleteOutline color='error' fontSize='small' sx={{ marginBottom: '4px' }} />
</IconButton>
</>
</RoleFilter>
</div>
Expand Down Expand Up @@ -65,7 +66,7 @@ const TimeseriesListEntry = ({
{/* Column 3 */}
<RoleFilter allowRoles={[`${project.slug.toUpperCase()}.*`]}>
<div className='d-flex flex-row'>
<div className='input-group'>
<div className='input-group'>
<input
type='number'
value={value}
Expand All @@ -75,14 +76,17 @@ const TimeseriesListEntry = ({
/>
<div className='input-group-append'>
<Button
variant='secondary'
handleClick={() => {
variant='outlined'
color='success'
sx={{ borderRadius: '0 2px 2px 0' }}
onClick={() => {
handleItemSaveValue(item, value);
setValue('');
}}
text='Add'
icon={<Add fontSize='inherit' sx={{ marginBottom: '3px' }} />}
/>
title='Add Measurement'
>
+ Add
</Button>
</div>
</div>
</div>
Expand Down Expand Up @@ -143,6 +147,10 @@ const CollectionGroupTimeseriesList = connect(
});
};

useDeepCompareEffect(() => {
setSortedItems(items);
}, [items]);

return (
<>
<IconButton
Expand All @@ -165,7 +173,7 @@ const CollectionGroupTimeseriesList = connect(
{isDraggingDisabled ? 'Dragging Disabled' : 'Dragging Enabled'}
{isDirty ? ' | Click lock to save changes.' :''}
</i>
<div className='w-100 list-group'>
<div className='w-100 list-group mt-2'>
<DragDropContext onDragEnd={handleDragEnd}>
<Droppable droppableId='legend-order' direction='vertical'>
{(provided) => (
Expand Down

0 comments on commit 4f33685

Please sign in to comment.