Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pull bug fixes into dev #284

Merged
merged 4 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion backend/django/core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ def read_data_file(data_file):
elif data_file.content_type.startswith(
"application/vnd"
) and data_file.name.endswith(".xlsx"):
data = pd.read_excel(data_file, dtype=str).dropna(axis=0, how="all").replace(r'\n',' ', regex=True)
data = (
pd.read_excel(data_file, dtype=str)
.dropna(axis=0, how="all")
.replace(r"\n", " ", regex=True)
)
else:
raise ValidationError(
"File type is not supported. Received {0} but only {1} are supported.".format(
Expand Down
5 changes: 2 additions & 3 deletions backend/django/core/utils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,8 +749,7 @@ def get_projects_umbrellas(self):


def get_unlabelled_data_objs(project_id: int) -> int:
"""
Function to retrieve the total count of unlabelled data objects for a project.
"""Function to retrieve the total count of unlabelled data objects for a project.

This SQL query is comprised of 5 subqueries, each of which retrieves the ids of
data objects that are in a particular table. The first sub-query is the total list
Expand Down Expand Up @@ -799,7 +798,7 @@ def get_unlabelled_data_objs(project_id: int) -> int:
)
SELECT COUNT(*)
FROM (
SELECT p.id
SELECT p.id
FROM project_ids p
LEFT JOIN queue_ids q ON p.id = q.id
LEFT JOIN irr_log_ids irr ON p.id = irr.id
Expand Down
19 changes: 0 additions & 19 deletions backend/django/core/views/api_annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,22 +1109,3 @@ def modify_metadata_values(request, data_pk):
metadata.value = m["value"]
metadata.save()
return Response({})


@api_view(["GET"])
@permission_classes((IsCoder,))
def get_labels(request, project_pk):
"""Grab data using get_assignments and send it to the frontend react app.

Args:
request: The request to the endpoint
project_pk: Primary key of project
Returns:
labels: The project labels
data: The data in the queue
"""
project = Project.objects.get(pk=project_pk)
labels = Label.objects.all().filter(project=project)

return Response({"labels": LabelSerializer(labels, many=True).data,})

25 changes: 25 additions & 0 deletions frontend/src/actions/smart.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import 'whatwg-fetch';
import { getConfig } from '../utils/fetch_configs';

export const SET_AVAILABLE = 'SET_AVAILABLE';
export const SET_LABEL = 'SET_LABEL';


export const set_available = createAction(SET_AVAILABLE);
export const setLabel = createAction(SET_LABEL);

//check if another admin is already using the admin tabs
export const getAdminTabsAvailable = (projectID) => {
Expand Down Expand Up @@ -35,3 +38,25 @@ export const getAdminTabsAvailable = (projectID) => {
};
};

// Get the set of labels for the project
export const getLabels = (projectID) => {
let apiURL = `/api/get_labels/${projectID}/`;
return dispatch => {
return fetch(apiURL, getConfig())
.then(response => {
if (response.ok) {
return response.json();
} else {
const error = new Error(response.statusText);
error.response = response;
throw error;
}
})
.then(response => {
// If error was in the response then set that message
if ('error' in response) console.log(response);
dispatch(setLabel(response.labels));
})
.catch(err => console.log("Error: ", err));
};
};
6 changes: 3 additions & 3 deletions frontend/src/components/History/HistoryTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ const HistoryTable = () => {
);
}
})}
<Form.Label className="d-flex m-0 p-0">
{/* <Form.Label className="d-flex m-0 p-0">
<Form.Check
className="p-0"
{...{
Expand All @@ -282,8 +282,8 @@ const HistoryTable = () => {
onChange: table.getToggleAllColumnsVisibilityHandler(),
}}
/>
<span className="ml-2">All</span>
</Form.Label>
<span className="ml-2">Select/Deselect All</span>
</Form.Label> */}
</GrayBox>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/Smart/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Smart extends React.Component {

componentDidMount() {
this.props.getAdminTabsAvailable();
this.props.getLabels();
}

renderAdminTabSkew() {
Expand Down Expand Up @@ -130,6 +131,7 @@ class Smart extends React.Component {

Smart.propTypes = {
adminTabsAvailable: PropTypes.bool,
getLabels: PropTypes.func.isRequired,
};

export default Smart;
5 changes: 4 additions & 1 deletion frontend/src/containers/smart_container.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { connect } from 'react-redux';

import { getAdminTabsAvailable } from '../actions/smart';
import { getAdminTabsAvailable, getLabels } from '../actions/smart';
import Smart from '../components/Smart';

const PROJECT_ID = window.PROJECT_ID;
Expand All @@ -20,6 +20,9 @@ const mapDispatchToProps = (dispatch) => {
getAdminTabsAvailable: () => {
dispatch(getAdminTabsAvailable(PROJECT_ID));
},
getLabels: () => {
dispatch(getLabels(PROJECT_ID));
}
};
};

Expand Down
Loading