Skip to content

Commit 0721e28

Browse files
authored
Merge pull request #217 from qccoders/develop
Initial Scanner implementation
2 parents 261e8ab + 9795cbe commit 0721e28

File tree

19 files changed

+390
-188
lines changed

19 files changed

+390
-188
lines changed

web/CONTRIBUTING.md renamed to CONTRIBUTING.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ This project is maintained for free and for a non profit organization, and we re
1414

1515
## Contribution Workflow
1616

17-
1. Assign yourself to the issue that you'll be working on. If there's no issue, your pull request is likely
18-
to be rejected until one is created and prioritized. Move the issue into the 'In progress' column on the project
19-
board, if you have the necessary access.
17+
1. Assign yourself to the issue that you'll be working on. Move the issue into the 'In progress' column on the project
18+
board, if you have the necessary access. If there's no issue associated with the work you'd like to do, your pull request is likely
19+
to be rejected until one is created and prioritized.
2020
2. Clone the repository and `git checkout develop` to ensure you are on the development branch.
2121
3. Create a new branch for your change with `git checkout -b <your-branch-name>` be descriptive, but terse.
2222
4. Make your changes. When finished, push your branch with `git push origin --set-upstream <your-branch-name>`.
@@ -48,16 +48,30 @@ You're free to use whichever development tools you prefer. If you don't yet hav
4848
## Debugging
4949
### Front End
5050

51-
Front debugging is most easily expressed as a series of console commands, executed from the root folder of the repository:
51+
Front end debugging is most easily expressed as a series of console commands, executed from the root folder of the repository:
5252

5353
```
5454
cd web
5555
npm install
5656
npm start
5757
```
5858

59-
On Windows, a browser should open and should navigate to the application. By default the development back end will be used for debugging.
59+
On Windows, a browser should open and should navigate to the application. By default the development environment will be used for debugging.
6060

6161
### Back End
6262

63-
TBD
63+
To debug the back end locally, you'll need to create the environment variable `QCVOC_DbConnectionString` and set it to the connection string for the development database. Visit us on Slack to discuss this.
64+
65+
Open the project in the 'api' folder in Visual Studio. On the toolbar, click the drop-down button next to 'IIS Express' and select 'QCVOC.Api' from the resulting list. This will tell Visual Studio to debug using the dotnet console command. Click the debug (green arrow) button to start debugging. A console should appear, displaying the following:
66+
67+
```
68+
Hosting environment: Development
69+
Content root path: C:\Users\JP.WHATNET\source\QCVOC\api\QCVOC.Api
70+
Now listening on: https://localhost:5001
71+
Now listening on: http://localhost:5000
72+
Application started. Press Ctrl+C to shut down.
73+
```
74+
75+
Open a browser and navigate to http://localhost:5000/swagger to interact with the api via Swagger UI.
76+
77+
Expand the `/security/login` POST operation and execute it, providing your credentials. Copy the `accessToken` value from the result, then click on the green 'Authorize' button near the top of the screen to set your session authorization. Enter `Bearer <accessToken>` into the box and click Login. All future requests will be authenticated using this token.

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
# QCVOC
1+
# Quad Cities Veteran Outreach Center
22

33
[![Build Status](https://travis-ci.org/qccoders/QCVOC.svg?branch=master)](https://travis-ci.org/qccoders/QCVOC/branches)
44
![license](https://img.shields.io/github/license/qccoders/QCVOC.svg)
55

6-
Quad Cities Veteran Outreach Center
6+
An event management application for the Quad Cities Veteran's Outreach Center.
77

8+
Written in .NET Core, React, and Java, and hosted on AWS with RDS (PostgreSQL), Lambda, API Gateway, and S3.
9+
10+
## About Us
11+
12+
This project is developed and maintained by [QC Coders](http://www.qccoders.org/), a group of software enthusiasts from the [Quad Cities](https://en.wikipedia.org/wiki/Quad_Cities), a region on the border of Iowa and Illinois.
13+
14+
We get together for networking, presentations, and group projects several times a month; have a look at [our website]((http://www.qccoders.org/)) for a calendar of events, or find us on [Meetup](https://www.meetup.com/QCCoders/) or [Facebook](https://www.facebook.com/qccoders). We can also be found on Slack, which you can join via the invite link near the bottom of our site.
15+
16+
## Contributing
17+
18+
If you'd like to help with this project, join us on Slack and have a look at [CONTRIBUTING.md](https://github.com/qccoders/QCVOC/blob/develop/CONTRIBUTING.md) for some important notes about the nature of your contribution and an overview of our workflow and environment.

api/QCVOC.Api/Events/Data/Repository/EventRepository.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ LIMIT @limit OFFSET @offset
160160
var dates = new { start = eventFilters.DateStart, end = eventFilters.DateEnd };
161161

162162
builder
163-
.Where("e.startdate BETWEEN @start AND @end", dates)
163+
.OrWhere("e.startdate BETWEEN @start AND @end", dates)
164164
.OrWhere("e.enddate BETWEEN @start AND @end", dates)
165-
.OrWhere("(e.startdate < @start AND e.enddate > @end)", dates);
165+
.OrWhere("e.startdate < @start AND e.enddate > @end", dates);
166166
}
167167
}
168168

api/QCVOC.Api/Scans/Controller/ScansController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public IActionResult GetAll([FromQuery]ScanFilters filters)
7979
/// <response code="403">The Veteran has not checked in for the Event.</response>
8080
/// <response code="404">The specified Veteran, Event or Service was invalid.</response>
8181
/// <response code="500">The server encountered an error while processing the request.</response>
82-
[HttpPost("")]
82+
[HttpPut("")]
8383
[Authorize]
8484
[ProducesResponseType(typeof(Scan), 200)]
8585
[ProducesResponseType(typeof(Scan), 201)]

api/QCVOC.Api/Scans/Data/Model/Scan.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ public class Scan : IEquatable<Scan>
2222
/// </summary>
2323
public Guid VeteranId { get; set; }
2424

25+
/// <summary>
26+
/// Gets or sets the full name of the Veteran.
27+
/// </summary>
28+
public string Veteran { get; set; }
29+
2530
/// <summary>
2631
/// Gets or sets the id of the Service.
2732
/// </summary>

api/QCVOC.Api/Scans/Data/Repository/ScanRepository.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,11 @@ public IEnumerable<Scan> GetAll(Filters filters = null)
137137
s.plusone,
138138
s.scandate,
139139
s.scanbyid,
140-
a.name AS scanby
140+
a.name AS scanby,
141+
v.firstname || ' ' || v.lastname AS veteran
141142
FROM scans s
142143
LEFT JOIN accounts a ON s.scanbyid = a.id
144+
INNER JOIN veterans v ON s.veteranid = v.id
143145
/**where**/
144146
ORDER BY s.scandate {filters.OrderBy.ToString()}
145147
LIMIT @limit OFFSET @offset
@@ -160,7 +162,8 @@ LIMIT @limit OFFSET @offset
160162
.ApplyFilter(FilterType.Equals, "s.eventid", scanFilters.EventId)
161163
.ApplyFilter(FilterType.Equals, "s.veteranid", scanFilters.VeteranId)
162164
.ApplyFilter(FilterType.Equals, "s.serviceid", scanFilters.ServiceId)
163-
.ApplyFilter(FilterType.Equals, "s.plusone", scanFilters.PlusOne);
165+
.ApplyFilter(FilterType.Equals, "s.plusone", scanFilters.PlusOne)
166+
.ApplyFilter(FilterType.Equals, "v.firstname || ' ' || v.lastname", scanFilters.Veteran);
164167
}
165168

166169
using (var db = ConnectionFactory.CreateConnection())

api/QCVOC.Api/Scans/ScanFilters.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ public class ScanFilters : Filters
2525
/// </summary>
2626
public Guid? VeteranId { get; set; }
2727

28+
/// <summary>
29+
/// The full name of the Veteran.
30+
/// </summary>
31+
public string Veteran { get; set; }
32+
2833
/// <summary>
2934
/// The id of the Service.
3035
/// </summary>
Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// <copyright file="AccountFilters.cs" company="JP Dillingham, Nick Acosta, et. al.">
2-
// Copyright (c) JP Dillingham, Nick Acosta, et. al.. All rights reserved. Licensed under the GPLv3 license. See LICENSE file
1+
// <copyright file="AccountFilters.cs" company="QC Coders (JP Dillingham, Nick Acosta, et. al.)">
2+
// Copyright (c) QC Coders (JP Dillingham, Nick Acosta, et. al.). All rights reserved. Licensed under the GPLv3 license. See LICENSE file
33
// in the project root for full license information.
44
// </copyright>
55

@@ -34,35 +34,5 @@ public class AccountFilters : Filters
3434
/// The Role by which to filter results.
3535
/// </summary>
3636
public Role? Role { get; set; }
37-
38-
/// <summary>
39-
/// The starting time of the Account creation date range.
40-
/// </summary>
41-
public DateTime? CreationDateStart { get; set; }
42-
43-
/// <summary>
44-
/// The ending time of the Account creation date range.
45-
/// </summary>
46-
public DateTime? CreationDateEnd { get; set; }
47-
48-
/// <summary>
49-
/// The id of the user which created the Account.
50-
/// </summary>
51-
public Guid? CreationById { get; set; }
52-
53-
/// <summary>
54-
/// The starting time of a last updated date range.
55-
/// </summary>
56-
public DateTime? LastUpdateDateStart { get; set; }
57-
58-
/// <summary>
59-
/// The ending time of a last updated date range.
60-
/// </summary>
61-
public DateTime? LastUpdateDateEnd { get; set; }
62-
63-
/// <summary>
64-
/// The id of the user which performed the last update.
65-
/// </summary>
66-
public Guid? LastUpdateById { get; set; }
6737
}
6838
}

api/QCVOC.Api/Security/Data/Repository/AccountRepository.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,7 @@ LIMIT @limit OFFSET @offset
156156
.ApplyFilter(FilterType.Equals, "a1.id", accountFilters.Id)
157157
.ApplyFilter(FilterType.Equals, "a1.name", accountFilters.Name)
158158
.ApplyFilter(FilterType.Equals, "a1.passwordresetrequired", accountFilters.PasswordResetRequired)
159-
.ApplyFilter(FilterType.Equals, "a1.role", accountFilters.Role?.ToString())
160-
.ApplyFilter(FilterType.Between, "a1.creationdate", accountFilters.CreationDateStart, accountFilters.CreationDateEnd)
161-
.ApplyFilter(FilterType.Equals, "a1.creationbyid", accountFilters.CreationById)
162-
.ApplyFilter(FilterType.Between, "a1.lastupdatedate", accountFilters.LastUpdateDateStart, accountFilters.LastUpdateDateEnd)
163-
.ApplyFilter(FilterType.Equals, "a1.lastupdatebyid", accountFilters.LastUpdateById);
159+
.ApplyFilter(FilterType.Equals, "a1.role", accountFilters.Role?.ToString());
164160
}
165161

166162
using (var db = ConnectionFactory.CreateConnection())

api/QCVOC.Api/Services/Data/Repository/ServiceRepository.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,7 @@ LIMIT @limit OFFSET @offset
172172
builder
173173
.ApplyFilter(FilterType.Equals, "s.id", serviceFilters.Id)
174174
.ApplyFilter(FilterType.Equals, "s.name", serviceFilters.Name)
175-
.ApplyFilter(FilterType.Equals, "s.description", serviceFilters.Description)
176-
.ApplyFilter(FilterType.Equals, "creationby", serviceFilters.CreationBy)
177-
.ApplyFilter(FilterType.Equals, "creationbyid", serviceFilters.CreationById)
178-
.ApplyFilter(FilterType.Between, "creationdate", serviceFilters.CreationDateStart, serviceFilters.CreationDateEnd)
179-
.ApplyFilter(FilterType.Equals, "lastupdateby", serviceFilters.LastUpdateBy)
180-
.ApplyFilter(FilterType.Equals, "lastupdatebyid", serviceFilters.LastUpdateById)
181-
.ApplyFilter(FilterType.Between, "lastupdatedate", serviceFilters.LastUpdateDateStart, serviceFilters.LastUpdateDateEnd);
175+
.ApplyFilter(FilterType.Equals, "s.description", serviceFilters.Description);
182176
}
183177

184178
using (var db = ConnectionFactory.CreateConnection())

api/QCVOC.Api/Services/ServiceFilters.cs

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -29,45 +29,5 @@ public class ServiceFilters : Filters
2929
/// The description of the service.
3030
/// </summary>
3131
public string Description { get; set; }
32-
33-
/// <summary>
34-
/// The name of the user who created the service.
35-
/// </summary>
36-
public string CreationBy { get; set; }
37-
38-
/// <summary>
39-
/// The id of the user who created the service.
40-
/// </summary>
41-
public Guid? CreationById { get; set; }
42-
43-
/// <summary>
44-
/// The starting time of a creation date range.
45-
/// </summary>
46-
public DateTime? CreationDateStart { get; set; }
47-
48-
/// <summary>
49-
/// The ending time of a creation date range.
50-
/// </summary>
51-
public DateTime? CreationDateEnd { get; set; }
52-
53-
/// <summary>
54-
/// The name of the user who last updated the service.
55-
/// </summary>
56-
public string LastUpdateBy { get; set; }
57-
58-
/// <summary>
59-
/// The id of the user who last updated the service.
60-
/// </summary>
61-
public Guid? LastUpdateById { get; set; }
62-
63-
/// <summary>
64-
/// The starting date of a last updated date range.
65-
/// </summary>
66-
public DateTime? LastUpdateDateStart { get; set; }
67-
68-
/// <summary>
69-
/// The ending date of a last updated date range.
70-
/// </summary>
71-
public DateTime? LastUpdateDateEnd { get; set; }
7232
}
7333
}

api/QCVOC.Api/Veterans/Data/Repository/VeteranRepository.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,9 @@ LIMIT @limit OFFSET @offset
188188
builder
189189
.ApplyFilter(FilterType.Equals, "v.address", veteranFilters.Address)
190190
.ApplyFilter(FilterType.Equals, "v.email", veteranFilters.Email)
191-
.ApplyFilter(FilterType.Between, "v.enrollmentdate", veteranFilters.EnrollmentDateStart, veteranFilters.EnrollmentDateEnd)
192-
.ApplyFilter(FilterType.Equals, "v.enrollmentbyid", veteranFilters.EnrollmentById)
193-
.ApplyFilter(FilterType.Equals, "enrollmentby", veteranFilters.EnrollmentBy)
194191
.ApplyFilter(FilterType.Equals, "v.firstname", veteranFilters.FirstName)
195192
.ApplyFilter(FilterType.Equals, "v.id", veteranFilters.Id)
196193
.ApplyFilter(FilterType.Equals, "v.lastname", veteranFilters.LastName)
197-
.ApplyFilter(FilterType.Between, "v.lastupdatedate", veteranFilters.LastUpdateDateStart, veteranFilters.LastUpdateDateEnd)
198-
.ApplyFilter(FilterType.Equals, "a.name", veteranFilters.LastUpdateBy)
199-
.ApplyFilter(FilterType.Equals, "v.lastupdatebyid", veteranFilters.LastUpdateById)
200-
.ApplyFilter(FilterType.Equals, "lastupdateby", veteranFilters.LastUpdateBy)
201194
.ApplyFilter(FilterType.Equals, "v.cardnumber", veteranFilters.CardNumber)
202195
.ApplyFilter(FilterType.Equals, "v.primaryphone", veteranFilters.PrimaryPhone)
203196
.ApplyFilter(FilterType.In, "v.verificationmethod", veteranFilters.VerificationMethod?.ToString());

api/QCVOC.Api/Veterans/VeteranFilters.cs

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,6 @@ public class VeteranFilters : Filters
2525
/// </summary>
2626
public string Email { get; set; }
2727

28-
/// <summary>
29-
/// Gets the name of the user which enrolled the Veteran.
30-
/// </summary>
31-
public string EnrollmentBy { get; }
32-
33-
/// <summary>
34-
/// The id of the user which enrolled the Veteran.
35-
/// </summary>
36-
public string EnrollmentById { get; set; }
37-
38-
/// <summary>
39-
/// The starting time of an enrollment date range.
40-
/// </summary>
41-
public DateTime? EnrollmentDateStart { get; set; }
42-
43-
/// <summary>
44-
/// The ending time of an enrollment date range.
45-
/// </summary>
46-
public DateTime? EnrollmentDateEnd { get; set; }
47-
4828
/// <summary>
4929
/// The first name of the Veteran.
5030
/// </summary>
@@ -60,26 +40,6 @@ public class VeteranFilters : Filters
6040
/// </summary>
6141
public string LastName { get; set; }
6242

63-
/// <summary>
64-
/// The starting time of a last updated date range.
65-
/// </summary>
66-
public DateTime? LastUpdateDateStart { get; set; }
67-
68-
/// <summary>
69-
/// The ending time of a last updated date range.
70-
/// </summary>
71-
public DateTime? LastUpdateDateEnd { get; set; }
72-
73-
/// <summary>
74-
/// The name of the user which performed the last update.
75-
/// </summary>
76-
public string LastUpdateBy { get; set; }
77-
78-
/// <summary>
79-
/// The id of the user which performed the last update.
80-
/// </summary>
81-
public Guid? LastUpdateById { get; set; }
82-
8343
/// <summary>
8444
/// The number of the card presently assigned to the Veteran.
8545
/// </summary>

web/src/app/App.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import Services from '../services/Services';
2424
import Events from '../events/Events';
2525
import LoginForm from '../security/LoginForm';
2626
import LinkList from './LinkList';
27+
import Scanner from '../scans/Scanner';
2728
import { CircularProgress, ListSubheader } from '@material-ui/core';
2829
import { getEnvironment } from '../util';
2930

@@ -167,6 +168,7 @@ class App extends Component {
167168
<Route path='/veterans' component={Veterans}/>
168169
<Route path='/services' component={Services}/>
169170
<Route path='/events' component={Events}/>
171+
<Route path='/scanner' component={Scanner}/>
170172
</Switch>
171173
</div> :
172174
<LoginForm onLogin={this.handleLogin}/>

web/src/events/EventList.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ const EventList = (props) => {
3333

3434
return (
3535
<List>
36-
{events.sort(sortByProp('startDate')).map(e =>
36+
{events.sort(sortByProp('startDate')).map((e, index) =>
3737
<ListItem
38-
key={e.id}
38+
key={index}
3939
button={onItemClick !== undefined && userCanView() }
4040
onClick={onItemClick !== undefined && userCanView() ? () => onItemClick(e) : () => {}}
4141
>

web/src/mobile.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
Copyright (c) QC Coders. All rights reserved. Licensed under the GPLv3 license. See LICENSE file
3+
in the project root for full license information.
4+
*/
5+
6+
export const isMobileAttached = () => {
7+
return isAndroidAttached();
8+
}
9+
10+
export const isAndroidAttached = () => {
11+
return window["Android"] !== undefined;
12+
}
13+
14+
export const initiateMobileScan = () => {
15+
if (isAndroidAttached()) {
16+
initiateAndroidScan();
17+
}
18+
}
19+
20+
export const initiateAndroidScan = () => {
21+
window["Android"]["scanBarcode"]();
22+
}

0 commit comments

Comments
 (0)