Skip to content

Commit

Permalink
fix: add uuid to capture detail dialog and top filter (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
tranquanghuy0801 authored Sep 25, 2021
1 parent 36f2d5b commit 5771c73
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/api/treeTrackerApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default {
limit: rowsPerPage,
skip,
fields: {
uuid: true,
imageUrl: true,
lat: true,
lon: true,
Expand Down
5 changes: 5 additions & 0 deletions src/components/CaptureDetailDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ function CaptureDetailDialog(props) {
copy: true,
link: true,
},
{
label: 'Capture UUID',
value: capture.uuid,
copy: true,
},
{
label: 'Planter Identifier',
value: capture.planterIdentifier,
Expand Down
11 changes: 11 additions & 0 deletions src/components/FilterTop.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ function Filter(props) {
const filterOptionAll = 'All';
const dateStartDefault = null;
const dateEndDefault = null;
const [uuid, setUUID] = useState(filter?.uuid || '');
const [captureId, setCaptureId] = useState(filter?.captureId || '');
const [planterId, setPlanterId] = useState(filter?.planterId || '');
const [deviceId, setDeviceId] = useState(filter?.deviceIdentifier || '');
Expand Down Expand Up @@ -123,6 +124,7 @@ function Filter(props) {
e.preventDefault();
// save the filer to context for editing & submit
const filter = new FilterModel();
filter.uuid = uuid;
filter.captureId = captureId;
filter.planterId = planterId;
filter.deviceIdentifier = deviceId;
Expand All @@ -140,6 +142,7 @@ function Filter(props) {

function handleReset() {
// reset form values, except 'approved' and 'active' which we'll keep
setUUID('');
setCaptureId('');
setPlanterId('');
setDeviceId('');
Expand Down Expand Up @@ -290,6 +293,14 @@ function Filter(props) {
value={captureId}
onChange={(e) => setCaptureId(e.target.value)}
/>
<TextField
htmlFor="uuid"
id="uuid"
label="Capture UUID"
placeholder=""
value={uuid}
onChange={(e) => setUUID(e.target.value)}
/>
<TextField
htmlFor="device-identifier"
id="device-identifier"
Expand Down
3 changes: 3 additions & 0 deletions src/components/tests/verify.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const CAPTURE = {
const CAPTURES = [
{
id: 10,
uuid: '11942400-6617-4c6c-bf5e',
planterId: 10,
planterIdentifier: '[email protected]',
deviceIdentifier: '1-abcdef123456',
Expand All @@ -68,6 +69,7 @@ const CAPTURES = [
},
{
id: 20,
uuid: '11942400-6617-4c6c-bf5e',
planterId: 11,
planterIdentifier: '[email protected]',
deviceIdentifier: '2-abcdef123456',
Expand All @@ -89,6 +91,7 @@ const CAPTURES = [
},
{
id: 30,
uuid: '11942400-6617-4c6c-bf5e',
planterId: 10,
planterIdentifier: '[email protected]',
deviceIdentifier: '3-abcdef123456',
Expand Down
5 changes: 5 additions & 0 deletions src/models/Filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const TAG_NOT_SET = 'TAG_NOT_SET';
import { tokenizationStates } from '../common/variables';

export default class Filter {
uuid;
captureId;
dateStart;
dateEnd;
Expand All @@ -30,6 +31,10 @@ export default class Filter {
getWhereObj() {
let where = {};

if (this.uuid) {
where.uuid = this.uuid;
}

if (this.captureId) {
where.id = this.captureId;
}
Expand Down
5 changes: 5 additions & 0 deletions src/models/Filter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ describe('Filter, with initial values about this filter object', () => {

beforeEach(() => {
filter = new Filter();
filter.uuid = '11942400-6617-4c6c-bf5e';
filter.captureId = 10;
filter.dateStart = '2019-07-25';
filter.dateEnd = '2019-07-30';
Expand All @@ -15,6 +16,10 @@ describe('Filter, with initial values about this filter object', () => {
filter.planterIdentifier = '1';
});

it('getWhereObj() should be: ', () => {
expect(filter.getWhereObj()).toEqual(expect.objectContaining({ uuid: '11942400-6617-4c6c-bf5e' }));
});

it('getWhereObj() should be: ', () => {
expect(filter.getWhereObj()).toEqual(expect.objectContaining({ id: 10 }));
});
Expand Down

0 comments on commit 5771c73

Please sign in to comment.