Skip to content

Commit

Permalink
ngrx 4.x migration (#154)
Browse files Browse the repository at this point in the history
* Upgrade npm dependencies

* Create separate files for actions and update reducers to use 4.x interface

* Perform secondary refactor of reducers

* Refactor actions and reducers and update specs

* Update service usages

* Update service specs

* Upgrade dependencies

* Update component usages

* Rename Location to Site and temporarily remove Rx implementation for create organization

* Update specs

* Update remaining dispatches in services

* Destroy subscriptions in ngOnDestroy hook

* Rename check-in button to Check In

* Upgrade jasmine-node back to 2.0.0
  • Loading branch information
tlmader authored Oct 1, 2017
1 parent 1a60ec6 commit d7b802e
Show file tree
Hide file tree
Showing 84 changed files with 2,538 additions and 1,662 deletions.
50 changes: 25 additions & 25 deletions cerberus-app.postman_collection
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
},
"item": [
{
"name": "location",
"name": "site",
"description": "",
"item": [
{
"name": "Insert location",
"name": "Insert site",
"event": [
{
"listen": "test",
Expand All @@ -38,7 +38,7 @@
}
],
"request": {
"url": "localhost:3000/api/location",
"url": "localhost:3000/api/site",
"method": "POST",
"header": [
{
Expand All @@ -61,7 +61,7 @@
"response": []
},
{
"name": "Get all locations",
"name": "Get all sites",
"event": [
{
"listen": "test",
Expand All @@ -85,7 +85,7 @@
}
],
"request": {
"url": "localhost:3000/api/locations",
"url": "localhost:3000/api/sites",
"method": "GET",
"header": [
{
Expand All @@ -100,7 +100,7 @@
"response": []
},
{
"name": "Get location by ID",
"name": "Get site by ID",
"event": [
{
"listen": "test",
Expand All @@ -126,7 +126,7 @@
}
],
"request": {
"url": "localhost:3000/api/location/59bc1e7ad92a6ac6f6252bfa",
"url": "localhost:3000/api/site/59bc1e7ad92a6ac6f6252bfa",
"method": "GET",
"header": [
{
Expand All @@ -141,7 +141,7 @@
"response": []
},
{
"name": "Count all locations",
"name": "Count all sites",
"event": [
{
"listen": "test",
Expand All @@ -158,7 +158,7 @@
}
],
"request": {
"url": "localhost:3000/api/locations/count",
"url": "localhost:3000/api/sites/count",
"method": "GET",
"header": [
{
Expand All @@ -176,7 +176,7 @@
"response": []
},
{
"name": "Update location by ID",
"name": "Update site by ID",
"event": [
{
"listen": "test",
Expand Down Expand Up @@ -204,7 +204,7 @@
}
],
"request": {
"url": "localhost:3000/api/location/59bc1e7ad92a6ac6f6252bfa",
"url": "localhost:3000/api/site/59bc1e7ad92a6ac6f6252bfa",
"method": "PUT",
"header": [
{
Expand All @@ -227,7 +227,7 @@
"response": []
},
{
"name": "Delete location by ID",
"name": "Delete site by ID",
"event": [
{
"listen": "test",
Expand All @@ -242,7 +242,7 @@
}
],
"request": {
"url": "localhost:3000/api/location/59bc1e7ad92a6ac6f6252bfa",
"url": "localhost:3000/api/site/59bc1e7ad92a6ac6f6252bfa",
"method": "DELETE",
"header": [
{
Expand Down Expand Up @@ -527,7 +527,7 @@
"if (responseCode.code === 201) {",
" tests[\"_id is correct\"] = jsonData._id === \"674a861ace7ca574af9070c8\";",
" tests[\"organizationId is correct\"] = jsonData.organizationId === \"59a7055733bfe28af47cff40\";",
" tests[\"locationId is correct\"] = jsonData.locationId === \"59bc1e7ad92a6ac6f6252bfa\";",
" tests[\"siteId is correct\"] = jsonData.siteId === \"59bc1e7ad92a6ac6f6252bfa\";",
" tests[\"volunteerId is correct\"] = jsonData.volunteerId === \"594a861ace7ca574ae9070c8\";",
" tests[\"startedAt is correct\"] = jsonData.startedAt === \"2017-07-17T21:20:31.814Z\";",
" tests[\"timezone is correct\"] = jsonData.timezone === \"America/Los_Angeles\";",
Expand Down Expand Up @@ -557,7 +557,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n\t\"_id\": \"674a861ace7ca574af9070c8\",\n\t\"organizationId\": \"59a7055733bfe28af47cff40\",\n\t\"locationId\": \"59bc1e7ad92a6ac6f6252bfa\",\n\t\"volunteerId\": \"594a861ace7ca574ae9070c8\",\n\t\"startedAt\": \"2017-07-17T21:20:31.814Z\",\n\t\"timezone\": \"America/Los_Angeles\"\n}"
"raw": "{\n\t\"_id\": \"674a861ace7ca574af9070c8\",\n\t\"organizationId\": \"59a7055733bfe28af47cff40\",\n\t\"siteId\": \"59bc1e7ad92a6ac6f6252bfa\",\n\t\"volunteerId\": \"594a861ace7ca574ae9070c8\",\n\t\"startedAt\": \"2017-07-17T21:20:31.814Z\",\n\t\"timezone\": \"America/Los_Angeles\"\n}"
},
"description": ""
},
Expand All @@ -578,7 +578,7 @@
" tests[\"__v is correct\"] = jsonData[0].__v === 0;",
" tests[\"_id is correct\"] = jsonData[0]._id === \"674a861ace7ca574af9070c8\";",
" tests[\"organizationId is correct\"] = jsonData.organizationId === \"59a7055733bfe28af47cff40\";",
" tests[\"locationId is correct\"] = jsonData.locationId === \"59bc1e7ad92a6ac6f6252bfa\";",
" tests[\"siteId is correct\"] = jsonData.siteId === \"59bc1e7ad92a6ac6f6252bfa\";",
" tests[\"volunteerId is correct\"] = jsonData[0].volunteerId === \"594a861ace7ca574ae9070c8\";",
" tests[\"startedAt is correct\"] = jsonData.startedAt === \"2017-07-17T21:20:31.814Z\";",
" tests[\"timezone is correct\"] = jsonData[0].timezone === \"America/Los_Angeles\";",
Expand Down Expand Up @@ -621,7 +621,7 @@
" var jsonData = JSON.parse(responseBody);",
" tests[\"_id is correct\"] = jsonData._id === \"674a861ace7ca574af9070c8\";",
" tests[\"organizationId is correct\"] = jsonData.organizationId === \"59a7055733bfe28af47cff40\";",
" tests[\"locationId is correct\"] = jsonData.locationId === \"59bc1e7ad92a6ac6f6252bfa\";",
" tests[\"siteId is correct\"] = jsonData.siteId === \"59bc1e7ad92a6ac6f6252bfa\";",
" tests[\"volunteerId is correct\"] = jsonData.volunteerId === \"594a861ace7ca574ae9070c8\";",
" tests[\"timezone is correct\"] = jsonData.timezone === \"America/Los_Angeles\";",
"} else if (responseCode.code === 404) {",
Expand Down Expand Up @@ -701,7 +701,7 @@
" var jsonData = JSON.parse(responseBody);",
" tests[\"_id is correct\"] = jsonData._id === \"674a861ace7ca574af9070c8\";",
" tests[\"organizationId is correct\"] = jsonData.organizationId === \"59a7055733bfe28af47cff40\";",
" tests[\"locationId is correct\"] = jsonData.locationId === \"59bc1e7ad92a6ac6f6252bfa\";",
" tests[\"siteId is correct\"] = jsonData.siteId === \"59bc1e7ad92a6ac6f6252bfa\";",
" tests[\"volunteerId is correct\"] = jsonData.volunteerId === \"594a861ace7ca574ae9070c8\";",
" tests[\"startedAt is correct\"] = jsonData.startedAt === \"2017-07-17T21:20:31.814Z\";",
" tests[\"endedAt is correct\"] = jsonData.endedAt === \"2017-07-17T22:20:31.814Z\";",
Expand Down Expand Up @@ -755,7 +755,7 @@
"if (jsonData.length > 0) {",
" tests[\"_id is correct\"] = jsonData[0]._id === \"674a861ace7ca574af9070c8\";",
" tests[\"organizationId is correct\"] = jsonData.organizationId === \"59a7055733bfe28af47cff40\";",
" tests[\"locationId is correct\"] = jsonData.locationId === \"59bc1e7ad92a6ac6f6252bfa\";",
" tests[\"siteId is correct\"] = jsonData.siteId === \"59bc1e7ad92a6ac6f6252bfa\";",
" tests[\"volunteerId is correct\"] = jsonData[0].volunteerId === \"594a861ace7ca574ae9070c8\";",
" tests[\"startedAt is correct\"] = jsonData.startedAt === \"2017-07-17T21:20:31.814Z\";",
" tests[\"timezone is correct\"] = jsonData.timezone === \"America/Los_Angeles\";",
Expand Down Expand Up @@ -837,7 +837,7 @@
"if (responseCode.code === 201) {",
" tests[\"_id is correct\"] = jsonData._id === \"594a861ace7ca574ae9070c8\";",
" tests[\"organizationId is correct\"] = jsonData.organizationId === \"59a7055733bfe28af47cff40\";",
" tests[\"locationId is correct\"] = jsonData.locationId === \"59bc1e7ad92a6ac6f6252bfa\";",
" tests[\"siteId is correct\"] = jsonData.siteId === \"59bc1e7ad92a6ac6f6252bfa\";",
" tests[\"firstName is correct\"] = jsonData.firstName === \"Ted\";",
" tests[\"lastName is correct\"] = jsonData.lastName === \"Mader\";",
" tests[\"petName is correct\"] = jsonData.petName === \"Mimi\";",
Expand Down Expand Up @@ -867,7 +867,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n\t\"organizationId\": \"59a7055733bfe28af47cff40\",\n\t\"locationId\": \"59bc1e7ad92a6ac6f6252bfa\",\n\t\"_id\": \"594a861ace7ca574ae9070c8\",\n\t\"firstName\": \"Ted\",\n\t\"lastName\": \"Mader\",\n\t\"petName\": \"Mimi\"\n}\n"
"raw": "{\n\t\"organizationId\": \"59a7055733bfe28af47cff40\",\n\t\"siteId\": \"59bc1e7ad92a6ac6f6252bfa\",\n\t\"_id\": \"594a861ace7ca574ae9070c8\",\n\t\"firstName\": \"Ted\",\n\t\"lastName\": \"Mader\",\n\t\"petName\": \"Mimi\"\n}\n"
},
"description": "volunteer: {\n firstName: String,\n lastName: String,\n petName: String\n}"
},
Expand All @@ -888,7 +888,7 @@
" tests[\"__v is correct\"] = jsonData[0].__v === 0;",
" tests[\"_id is correct\"] = jsonData[0]._id === \"594a861ace7ca574ae9070c8\";",
" tests[\"organizationId is correct\"] = jsonData.organizationId === \"59a7055733bfe28af47cff40\";",
" tests[\"locationId is correct\"] = jsonData.locationId === \"59bc1e7ad92a6ac6f6252bfa\";",
" tests[\"siteId is correct\"] = jsonData.siteId === \"59bc1e7ad92a6ac6f6252bfa\";",
" tests[\"firstName is correct\"] = jsonData[0].firstName === \"Ted\";",
" tests[\"lastName is correct\"] = jsonData[0].lastName === \"Mader\";",
" tests[\"petName is correct\"] = jsonData[0].petName === \"Mimi\";",
Expand Down Expand Up @@ -933,7 +933,7 @@
" tests[\"__v is correct\"] = jsonData[0].__v === 0;",
" tests[\"_id is correct\"] = jsonData._id === \"594a861ace7ca574ae9070c8\";",
" tests[\"organizationId is correct\"] = jsonData.organizationId === \"59a7055733bfe28af47cff40\";",
" tests[\"locationId is correct\"] = jsonData.locationId === \"59bc1e7ad92a6ac6f6252bfa\";",
" tests[\"siteId is correct\"] = jsonData.siteId === \"59bc1e7ad92a6ac6f6252bfa\";",
" tests[\"firstName is correct\"] = jsonData.firstName === \"Ted\";",
" tests[\"lastName is correct\"] = jsonData.lastName === \"Mader\";",
" tests[\"petName is correct\"] = jsonData.petName === \"Mimi\";",
Expand Down Expand Up @@ -1017,7 +1017,7 @@
" tests[\"__v is correct\"] = jsonData.__v === 0;",
" tests[\"_id is correct\"] = jsonData._id === \"594a861ace7ca574ae9070c8\";",
" tests[\"organizationId is correct\"] = jsonData.organizationId === \"59a7055733bfe28af47cff40\";",
" tests[\"locationId is correct\"] = jsonData.locationId === \"59bc1e7ad92a6ac6f6252bfa\";",
" tests[\"siteId is correct\"] = jsonData.siteId === \"59bc1e7ad92a6ac6f6252bfa\";",
" tests[\"firstName is correct\"] = jsonData.firstName === \"EDIT-Ted\";",
" tests[\"lastName is correct\"] = jsonData.lastName === \"EDIT-Mader\";",
" tests[\"petName is correct\"] = jsonData.petName === \"EDIT-Mimi\";",
Expand Down Expand Up @@ -1406,4 +1406,4 @@
]
}
]
}
}
29 changes: 29 additions & 0 deletions client/app/actions/organizations.actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Action } from '@ngrx/store';
import { Organization } from '../models/organization';

export const LOAD = '[Organizations] Load';
export const ADD = '[Organizations] Add';
export const MODIFY = '[Organizations] Modify';

export class Load implements Action {
readonly type = LOAD;

constructor(public payload: Organization[]) {}
}

export class Add implements Action {
readonly type = ADD;

constructor(public payload: Organization) {}
}

export class Modify implements Action {
readonly type = MODIFY;

constructor(public payload: Organization) {}
}

export type All
= Load
| Add
| Modify;
38 changes: 38 additions & 0 deletions client/app/actions/sites.actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Action } from '@ngrx/store';
import { Site } from '../models/site';

export const LOAD = '[Sites] Load';
export const ADD = '[Sites] Add';
export const MODIFY = '[Sites] Modify';

/**
* Every action is comprised of at least a type and an optional
* payload. Expressing actions as classes enables powerful
* type checking in reducer functions.
*/
export class Load implements Action {
readonly type = LOAD;

constructor(public payload: Site[]) {}
}

export class Add implements Action {
readonly type = ADD;

constructor(public payload: Site) {}
}

export class Modify implements Action {
readonly type = MODIFY;

constructor(public payload: Site) {}
}

/**
* Export a type alias of all actions in this action group
* so that reducers can easily compose action types.
*/
export type All
= Load
| Add
| Modify;
29 changes: 29 additions & 0 deletions client/app/actions/users.actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Action } from '@ngrx/store';
import { User } from '../models/user';

export const LOAD = '[Users] Load';
export const ADD = '[Users] Add';
export const MODIFY = '[Users] Modify';

export class Load implements Action {
readonly type = LOAD;

constructor(public payload: User[]) {}
}

export class Add implements Action {
readonly type = ADD;

constructor(public payload: User) {}
}

export class Modify implements Action {
readonly type = MODIFY;

constructor(public payload: User) {}
}

export type All
= Load
| Add
| Modify;
29 changes: 29 additions & 0 deletions client/app/actions/visits.actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Action } from '@ngrx/store';
import { Visit } from '../models/visit';

export const LOAD = '[Visits] Load';
export const ADD = '[Visits] Add';
export const MODIFY = '[Visits] Modify';

export class Load implements Action {
readonly type = LOAD;

constructor(public payload: Visit[]) {}
}

export class Add implements Action {
readonly type = ADD;

constructor(public payload: Visit) {}
}

export class Modify implements Action {
readonly type = MODIFY;

constructor(public payload: Visit) {}
}

export type All
= Load
| Add
| Modify;
29 changes: 29 additions & 0 deletions client/app/actions/volunteers.actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Action } from '@ngrx/store';
import { Volunteer } from '../models/volunteer';

export const LOAD = '[Volunteers] Load';
export const ADD = '[Volunteers] Add';
export const MODIFY = '[Volunteers] Modify';

export class Load implements Action {
readonly type = LOAD;

constructor(public payload: Volunteer[]) {}
}

export class Add implements Action {
readonly type = ADD;

constructor(public payload: Volunteer) {}
}

export class Modify implements Action {
readonly type = MODIFY;

constructor(public payload: Volunteer) {}
}

export type All
= Load
| Add
| Modify;
4 changes: 2 additions & 2 deletions client/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { RouterModule, Routes } from '@angular/router';
import { OrganizationDashboardComponent } from './components/organization-dashboard/organization-dashboard.component';
import { LoginComponent } from './components/login/login.component';
import { Guard } from './guard';
import { LocationCheckInComponent } from './components/location-check-in/location-check-in.component';
import { CheckInComponent } from './components/check-in/check-in.component';
import { GettingStartedComponent } from './components/getting-started/getting-started.component';

const routes: Routes = [
{ path: 'login', component: LoginComponent },
{ path: 'dashboard', component: OrganizationDashboardComponent, canActivate : [Guard] },
{ path: 'checkin/:id', component: LocationCheckInComponent, canActivate : [Guard] },
{ path: 'checkin/:id', component: CheckInComponent, canActivate : [Guard] },
{ path: 'start', component: GettingStartedComponent },
{ path: '**', redirectTo: 'dashboard', pathMatch: 'full' }
];
Expand Down
Loading

0 comments on commit d7b802e

Please sign in to comment.