Skip to content

Commit ab14287

Browse files
committed
UI - fix exception on empty shelterluv
config file updates
1 parent 33fcb89 commit ab14287

File tree

9 files changed

+45
-69
lines changed

9 files changed

+45
-69
lines changed

src/client/src/pages/Admin.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { Component } from 'react';
2-
import {Tabs, Tab, Container, Paper } from "@material-ui/core";
2+
import {Tabs, Tab, Paper } from "@material-ui/core";
33
import TabPanel from '../components/TabPanel';
44
import Grid from '@material-ui/core/Grid';
55
import Table from '@material-ui/core/Table';
@@ -9,7 +9,6 @@ import TableContainer from '@material-ui/core/TableContainer';
99
import TableHead from '@material-ui/core/TableHead';
1010
import TableRow from '@material-ui/core/TableRow';
1111
import { withStyles } from '@material-ui/core/styles';
12-
import Divider from '@material-ui/core/Divider';
1312
import LinearProgress from '@material-ui/core/LinearProgress';
1413
import CircularProgress from '@material-ui/core/CircularProgress';
1514
import { UploadForm, DownloadForm, ExecuteForm } from '../components/Forms';

src/client/src/pages/DataView360/components/Adoptions.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ const StyledTableRow = withStyles((theme)=>({
2222

2323

2424
class Adoptions extends Component {
25-
constructor(props) {
26-
super(props);
27-
}
2825

2926
getAnimalIds() {
3027
let result = [];
@@ -35,13 +32,15 @@ class Adoptions extends Component {
3532
return _.isNaN(_.parseInt(item)) !== true;
3633
})
3734
}
35+
36+
return result;
3837
}
3938

4039
render() {
4140
// todo: update when we add pet info
4241
// todo: clean array of animal_id
4342
return (<Container style={{"marginTop":"1em"}}>
44-
<Typography align='center' gutterBottom='true' variant='h4'>Adoption/Foster Records(Top 3)</Typography>
43+
<Typography align='center' variant='h4'>Adoption/Foster Records(Top 3)</Typography>
4544
<TableContainer style={{"marginTop":"1em"}} component={Paper} variant='outlined'>
4645
<Table>
4746
<TableHead>

src/client/src/pages/DataView360/components/ContactInfo.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class ContactInfo extends Component {
1919
const phoneStr = _.get(this.props, "participant.phone");
2020
let phone = _.isEmpty(phoneStr) ? '-' : phoneStr.split(" ").join("");
2121

22-
return (<Container class="contactInfo">
23-
<Typography align='center' gutterBottom='true' variant='h4'>Contact Info</Typography>
22+
return (<Container className="contactInfo">
23+
<Typography align='center' variant='h4'>Contact Info</Typography>
2424
<Paper variant='outlined' style={{padding:'1em'}}>
2525
<div style={{"display":"flex", "justifyContent":"space-between"}}>
2626
<Typography>

src/client/src/pages/DataView360/components/Donations.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class Donations extends Component {
3838
donationsSorted = donationsSorted.reverse();
3939
const latestDonations = donationsSorted.slice(0,ROWS_TO_SHOW);
4040

41-
const result = _.map(latestDonations, donation => {
42-
return( <StyledTableRow>
41+
const result = _.map(latestDonations, (donation, index) => {
42+
return( <StyledTableRow key={index}>
4343
<TableCell align="center">{donation.close_date}</TableCell>
4444
<TableCell align="center">${donation.amount}</TableCell>
4545
<TableCell align="center">{donation.type}</TableCell>
@@ -52,7 +52,7 @@ class Donations extends Component {
5252
render() {
5353
return (
5454
<Container style={{"marginTop":"1em"}}>
55-
<Typography align='center' gutterBottom='true' variant='h4'>Financial Support Activity(Top 3)</Typography>
55+
<Typography align='center' variant='h4'>Financial Support Activity(Top 3)</Typography>
5656
<TableContainer style={{"marginTop":"1em"}} component={Paper} variant='outlined'>
5757
<Table>
5858
<TableHead>

src/client/src/pages/DataView360/components/SearchBar.js

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
import React, { Component } from 'react';
22
import {Button, Paper, Select, InputLabel, MenuItem, FormControl, TextField, IconButton} from '@material-ui/core';
33
import SearchIcon from '@material-ui/icons/Search';
4-
import { withStyles } from '@material-ui/core/styles';
54
import "./styles/SearchBar.css";
65
import CircularProgress from '@material-ui/core/CircularProgress';
76

87
import _ from 'lodash';
98

109
const LIST_LIMIT = 200;
1110

12-
const styles = theme => ({
13-
spinner: {
14-
display: 'flex',
15-
marginLeft: theme.spacing(2)
16-
}
17-
});
18-
1911
class SearchBar extends Component {
2012
constructor(props) {
2113
super(props);
@@ -55,7 +47,7 @@ class SearchBar extends Component {
5547
searchParticipant(event) {
5648
return (
5749
<form onSubmit={this.handleParticipantSearch} style={{"display":"flex"}}>
58-
<TextField style={{"min-width":"300px"}}
50+
<TextField style={{minWidth:300}}
5951
error={this.state.alertMinChars}
6052
helperText={this.state.alertMinChars ? "Requires 3 search characters for first and last name" : ""}
6153
id="participant-search"
@@ -91,7 +83,7 @@ class SearchBar extends Component {
9183
}
9284

9385
return (
94-
<FormControl style={{"minWidth":"20em"}}>
86+
<FormControl style={{minWidth:"20em"}}>
9587
<InputLabel id="paws-participant-label">Select Participant - Top 200 Results</InputLabel>
9688
<Select
9789
labelId="paws-participant-label"
@@ -124,8 +116,6 @@ class SearchBar extends Component {
124116
};
125117

126118
render() {
127-
const { classes } = this.props;
128-
129119
return (
130120
<Paper elevation={1} style={{
131121
"display":"flex",
@@ -135,15 +125,11 @@ class SearchBar extends Component {
135125
"justifyContent":"space-around"
136126
}}>
137127
{this.searchParticipant()}
138-
139-
140128
{this.state.isSearchBusy === true ?
141-
(<div className={classes.spinner}>
142-
<CircularProgress />
143-
</div>) : this.selectParticipant()}
129+
<CircularProgress /> : this.selectParticipant()}
144130
</Paper>
145131
)
146132
}
147133
}
148134

149-
export default withStyles(styles)(SearchBar);
135+
export default SearchBar;

src/client/src/pages/DataView360/components/Volunteer.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ const StyledTableRow = withStyles((theme)=>({
2424
const SHIFTS_TO_SHOW = 3;
2525

2626
class Volunteer extends Component {
27-
constructor(props) {
28-
super(props);
29-
}
3027

3128
createShiftRows(shifts) {
3229
const shiftsSorted = _.sortBy(shifts, shift => {
@@ -35,8 +32,8 @@ class Volunteer extends Component {
3532

3633
const lastShifts = shiftsSorted.slice(shiftsSorted.length - SHIFTS_TO_SHOW, shiftsSorted.length)
3734

38-
const result = _.map(lastShifts, shift => {
39-
return(<StyledTableRow>
35+
const result = _.map(lastShifts, (shift, index) => {
36+
return(<StyledTableRow key={index}>
4037
<TableCell align="center">{moment(shift.from).format("YYYY-MM-DD")}</TableCell>
4138
<TableCell align="center">{shift.assignment}</TableCell>
4239
</StyledTableRow>);
@@ -51,7 +48,7 @@ class Volunteer extends Component {
5148
return (
5249
<div>
5350
<Container style={{"marginTop":"1em"}}>
54-
<Typography align='center' gutterBottom='true' variant='h4'>Volunteer Activity</Typography>
51+
<Typography align='center' variant='h4'>Volunteer Activity</Typography>
5552
<TableContainer style={{"marginTop":"1em"}} component={Paper} variant='outlined'>
5653
<Table>
5754
<TableHead>
@@ -75,7 +72,7 @@ class Volunteer extends Component {
7572
</Container>
7673

7774
<Container style={{"marginTop":"1em"}}>
78-
<Typography align='center' gutterBottom='true' variant='h4'>Volunteer History(Top 3)</Typography>
75+
<Typography align='center' variant='h4'>Volunteer History(Top 3)</Typography>
7976
<TableContainer style={{"marginTop":"1em"}} component={Paper} variant='outlined'>
8077
<Table>
8178
<TableHead>

src/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ services:
1919
depends_on:
2020
- db
2121
volumes:
22-
- src_archive:/app/static/uploads
22+
- src_archive:/app/static/raw_data
2323
environment:
2424
FLASK_ENV: development
2525

src/server/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ RUN pip install --no-cache-dir -r /requirements.txt
1515
COPY . .
1616

1717
RUN mkdir /app/static \
18-
/app/static/uploads \
19-
/app/static/uploads/current \
18+
/app/static/raw_data \
19+
/app/static/raw_data/current \
2020
/app/static/output \
2121
/app/static/output/reports \
2222
/app/static/logs \

src/server/config.py

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,40 @@
22
import sqlalchemy as db
33
from sqlalchemy_utils import database_exists, create_database
44

5-
# Determine if app is ran from docker or local by env var IS_LOCAL
6-
BASE_PATH = '/app/static/'
7-
POSTGRES_PASSWORD=os.getenv('POSTGRES_PASSWORD', 'thispasswordisverysecure')
8-
POSTGRES_DATABASE=os.getenv('POSTGRES_DATABASE', 'paws')
9-
POSTGRES_USER=os.getenv('POSTGRES_USER', 'postgres')
10-
DB = 'postgresql://' + POSTGRES_USER + ':'+ POSTGRES_PASSWORD + '@paws-compose-db/' + POSTGRES_DATABASE
11-
12-
IS_LOCAL = os.getenv('IS_LOCAL', False)
13-
14-
if IS_LOCAL:
15-
BASE_PATH = '../local_files/'
16-
DB = os.getenv('LOCAL_DB_IP',
17-
'postgresql://postgres:'+ POSTGRES_PASSWORD + '@localhost:5432/' + POSTGRES_DATABASE)
18-
19-
#best practices is to have only one engine per application process
20-
#https://docs.sqlalchemy.org/en/13/core/connections.html
5+
# Determine if app is ran from docker or local by testing the env var "IS_LOCAL"
6+
IS_LOCAL = os.getenv('IS_LOCAL')
7+
BASE_PATH = '../local_files/' if IS_LOCAL == 'True' else '/app/static/'
8+
9+
# Initiate postgres DB
10+
# best practices is to have only one engine per application process
11+
# https://docs.sqlalchemy.org/en/13/core/connections.html
12+
POSTGRES_PASSWORD = os.getenv('POSTGRES_PASSWORD', 'thispasswordisverysecure')
13+
POSTGRES_DATABASE = os.getenv('POSTGRES_DATABASE', 'paws')
14+
POSTGRES_USER = os.getenv('POSTGRES_USER', 'postgres')
15+
16+
if IS_LOCAL == 'True':
17+
DB = os.getenv('LOCAL_DB_IP', 'postgresql://postgres:' + POSTGRES_PASSWORD + '@localhost:5432/' + POSTGRES_DATABASE)
18+
else:
19+
DB = 'postgresql://' + POSTGRES_USER + ':' + POSTGRES_PASSWORD + '@paws-compose-db/' + POSTGRES_DATABASE
20+
2121
engine = db.create_engine(DB)
2222

2323
if not database_exists(engine.url):
2424
create_database(engine.url)
2525

26-
# print(database_exists(engine.url))
27-
28-
# Define global reusable paths
26+
# Initiate local file system
2927
RAW_DATA_PATH = BASE_PATH + 'raw_data/'
3028
OUTPUT_PATH = BASE_PATH + 'output/'
3129
LOGS_PATH = BASE_PATH + 'logs/'
3230
CURRENT_SOURCE_FILES_PATH = RAW_DATA_PATH + 'current/'
3331
REPORT_PATH = OUTPUT_PATH + 'reports/'
3432
ZIPPED_FILES = BASE_PATH + 'zipped/'
3533

36-
if BASE_PATH != '/app/static/':
37-
try:
38-
os.mkdir(BASE_PATH)
39-
os.mkdir(RAW_DATA_PATH)
40-
os.mkdir(OUTPUT_PATH)
41-
os.mkdir(LOGS_PATH)
42-
os.mkdir(CURRENT_SOURCE_FILES_PATH)
43-
os.mkdir(REPORT_PATH)
44-
os.mkdir(ZIPPED_FILES)
45-
except FileExistsError as e:
46-
print(e)
34+
os.makedirs(BASE_PATH, exist_ok=True)
35+
os.makedirs(RAW_DATA_PATH, exist_ok=True)
36+
os.makedirs(OUTPUT_PATH, exist_ok=True)
37+
os.makedirs(LOGS_PATH, exist_ok=True)
38+
os.makedirs(CURRENT_SOURCE_FILES_PATH, exist_ok=True)
39+
os.makedirs(REPORT_PATH, exist_ok=True)
40+
os.makedirs(ZIPPED_FILES, exist_ok=True)
41+

0 commit comments

Comments
 (0)