Skip to content

Commit

Permalink
Add image export option
Browse files Browse the repository at this point in the history
Setup frontend with actions and reducers.
Receiving request in the backend.
Can create annotations for image files.
Ability to download zipped annotations.
  • Loading branch information
2knal committed Mar 9, 2020
1 parent e025f84 commit b3cf801
Show file tree
Hide file tree
Showing 9 changed files with 518 additions and 145 deletions.
32 changes: 31 additions & 1 deletion labellab-client/src/actions/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import {
FETCH_IMAGE_FAILURE,
FETCH_IMAGE_REQUEST,
FETCH_IMAGE_SUCCESS,
SET_IMAGE_STATE
SET_IMAGE_STATE,
DOWNLOAD_REQUEST,
DOWNLOAD_FAILURE,
DOWNLOAD_SUCCESS
} from '../constants/index'

import FetchApi from '../utils/FetchAPI'
Expand Down Expand Up @@ -106,3 +109,30 @@ export const setNextPrev = (next, prev) => {
return { type: SET_IMAGE_STATE, payload: data }
}
}

export const exportDataset = callback => {
return dispatch => {
dispatch(request())
FetchApi('GET', '/api/v1/image/export', null, true)
.then(res => {
dispatch(success(res.data.body))
callback()
})
.catch(err => {
if (err.response) {
err.response.data
? dispatch(failure(err.response.data.msg))
: dispatch(failure(err.response.statusText, null))
}
})
}
function request() {
return { type: DOWNLOAD_REQUEST }
}
function success(data) {
return { type: DOWNLOAD_SUCCESS, payload: data }
}
function failure(error) {
return { type: DOWNLOAD_FAILURE, payload: error }
}
}
2 changes: 2 additions & 0 deletions labellab-client/src/components/labeller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ class LabelingLoader extends Component {
labels={lab}
labelData={(img && img.labelData) || {}}
imageUrl={
'http://' +
process.env.REACT_APP_HOST +
':' +
process.env.REACT_APP_SERVER_PORT +
`/static/uploads/${image.imageUrl}?${Date.now()}`
}
Expand Down
Loading

0 comments on commit b3cf801

Please sign in to comment.