Skip to content

Commit

Permalink
Merge pull request #466 from ECLK/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
MrClemRkz authored Mar 11, 2020
2 parents 762de7a + 6a85058 commit dd1b00b
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 37 deletions.
3 changes: 1 addition & 2 deletions backend/seeddata/police.json
Original file line number Diff line number Diff line change
Expand Up @@ -528,14 +528,13 @@
}
},
{
"model": "common.policestation",
"model": "common.policedivision",
"pk": "49",
"fields": {
"code": "ALL",
"name": "All Island",
"sn_name": "මුළු දිවයිනම",
"tm_name": "தீவு முழுவதும்",
"division": "ALL",
"created_date": "2019-06-27T00:00:00Z"
}
},
Expand Down
3 changes: 2 additions & 1 deletion backend/seeddata/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
94,
97,
99,
104
104,
105
]
}
},
Expand Down
7 changes: 3 additions & 4 deletions backend/src/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def env_var(key, default=None):
DEBUG = env_var('django_debug', True)

ALLOWED_HOSTS = [
"api.incidents.ecdev.opensource.lk",
"127.0.0.1",
"localhost"
]
Expand Down Expand Up @@ -66,10 +65,10 @@ def env_var(key, default=None):
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
Expand Down Expand Up @@ -103,7 +102,7 @@ def env_var(key, default=None):
DATABASES = {
'default': {
'ENGINE': 'mysql.connector.django',
'NAME': env_var('DATABASE_NAME', 'incident_prod'),
'NAME': env_var('DATABASE_NAME', 'incidents'),
'USER': env_var('DATABASE_USER', 'root'),
'PASSWORD': env_var('DATABASE_PWD', 'root'),
'HOST': env_var('DATABASE_HOST', 'localhost'), # Or an IP Address that your DB is hosted on
Expand Down
15 changes: 10 additions & 5 deletions frontend/src/incident-filing/components/IncidentFormInternal.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,9 @@ function IncidentFormInternal(props) {
};

// function used to get filtered inquiries for title text field
const handleSimilarInquiries = async (title) => {
const handleSimilarInquiries = async (title, type) => {
const filters = {
incidentType: state.incidentType,
incidentType: type,
title: title
}
const response = await getIncidents(filters);
Expand Down Expand Up @@ -584,9 +584,10 @@ function IncidentFormInternal(props) {
</Grid>
<Grid item xs={12}>
<TitleAutoComplete
incidentType={values.incidentType}
data={similarIncidents}
onChange={(event) => handleChange(event)}
onFetchSimilarInquiries={title => handleSimilarInquiries(title)}
onFetchSimilarInquiries={(title, type) => handleSimilarInquiries(title, type)}
className={classes.textField}
onBlur={handleBlur}
error={(touched.title && errors.title) == 'Required' ? true : false}
Expand All @@ -597,7 +598,7 @@ function IncidentFormInternal(props) {
<TextField
type="text"
name="description"
label="Description*"
label={(values.incidentType === "INQUIRY") ? "Letter reference number*" : "Description*"}
placeholder="Press enter for new lines."
className={classes.textField}
multiline
Expand Down Expand Up @@ -1057,7 +1058,7 @@ function IncidentFormInternal(props) {
{/* contact information of the complianer */}
<Paper className={classes.paper}>
<Typography variant="h5" gutterBottom>
Reporter Information
Reporter / Complainer Information
</Typography>
<Grid container spacing={24}>
<Grid item xs={12} sm={6}>
Expand Down Expand Up @@ -1203,6 +1204,8 @@ function IncidentFormInternal(props) {
</Grid>
</Paper>

{values.incidentType === "COMPLAINT" && (
<>
{/* Incident location information */}
<Paper className={classes.paper}>
<Typography variant="h5" gutterBottom>
Expand Down Expand Up @@ -1557,6 +1560,8 @@ function IncidentFormInternal(props) {
</ExpansionPanelDetails>
</ExpansionPanel>
</div>
</>
)}

{/* action panel */}
<Grid container spacing={24}>
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/incident-filing/components/TitleAutoComplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class AutosuggestInput extends React.Component {

handleSuggestionsFetchRequested = ({ value, reason }) => {
if (value.length > 2 && reason == "input-changed") {
this.props.onFetchSimilarInquiries(value);
this.props.onFetchSimilarInquiries(value, this.props.incidentType);
} else if (reason == "input-focused") {
this.setState({
suggestions: this.state.suggestions,
Expand All @@ -125,8 +125,8 @@ class AutosuggestInput extends React.Component {
};

render() {
const { classes } = this.props;

const { classes, incidentType } = this.props;
const autosuggestProps = {
renderInputComponent,
suggestions: this.state.suggestions,
Expand All @@ -143,8 +143,8 @@ class AutosuggestInput extends React.Component {
classes,
type: "text",
name: "title",
label: "Title*",
placeholder: 'Title*',
label: (incidentType==="INQUIRY") ? "Topic*" : "Title*",
placeholder: "Start typing in to see if there are similar ones..",
value: this.state.value,
onChange: this.handleChange(),
className: this.props.className,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { userCan, USER_ACTIONS } from '../../../user/userUtils';

// pdf output
import axios from 'axios'
import handler from '../../../api/apiHandler'
import { API_BASE_URL } from '../../../config'

const styles = (theme) => ({
Expand Down Expand Up @@ -106,23 +107,25 @@ const EventActions = (props) => {
}

async function printSlip(){
axios(`${API_BASE_URL}/pdfgen/?template_type=slip&id=`+activeIncident.id, {
method: 'GET',
responseType: 'blob' //Force to receive data in a Blob Format
})
.then(response => {
//Create a Blob from the PDF Stream
const file = new Blob(
[response.data],
{type: 'application/pdf'});
//Build a URL from the file
const fileURL = URL.createObjectURL(file);
//Open the URL on new Window
window.open(fileURL);
})
.catch(error => {
console.log(error);
});
const response = (await handler.get(`${API_BASE_URL}/pdfgen/?template_type=slip&id=`+activeIncident.id))
const data = response.data
const blob = new Blob([data], { type: 'application/pdf' });
const uri = URL.createObjectURL(blob);
window.open(uri);

// .then(response => {
// //Create a Blob from the PDF Stream
// const file = new Blob(
// [response.data],
// {type: 'application/pdf'});
// //Build a URL from the file
// const fileURL = URL.createObjectURL(file);
// //Open the URL on new Window
// window.open(fileURL);
// })
// .catch(error => {
// console.log(error);
// });
}

return (
Expand Down Expand Up @@ -214,10 +217,11 @@ const EventActions = (props) => {
</Button>
}

<Button color="primary" size="large" variant='text' className={classes.button} onClick={() => { dispatch(showModal('REQUEST_ADVICE_MODAL', { activeIncident, users, divisions })) }}>
{/* TODO: add User Action permissions here */}
{/* <Button color="primary" size="large" variant='text' className={classes.button} onClick={() => { dispatch(showModal('REQUEST_ADVICE_MODAL', { activeIncident, users, divisions })) }}>
<HelpIcon className={classes.actionButtonIcon} />
Request for advice
</Button>
</Button> */}

{userCan(currentUser, activeIncident, USER_ACTIONS.CAN_CLOSE_INCIDENT) &&

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ongoing-incidents/components/SearchForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function SearchForm(props) {
</Button>
</Grid>
<ExpansionPanel>
<ExpansionPanelSummary
<ExpansionPanelSummary style={{ display: 'none'}}
expandIcon={<ExpandMoreIcon />}
aria-controls="panel1a-content"
id="panel1a-header"
Expand Down

0 comments on commit dd1b00b

Please sign in to comment.