Skip to content

Commit e920d9f

Browse files
Merge pull request #276 from nmarklund10/nmarklund10/274-issue
Nmarklund10/274 issue
2 parents 0ceb406 + e42403a commit e920d9f

File tree

13 files changed

+53
-43
lines changed

13 files changed

+53
-43
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ In the event of a disaster, Baltimore City and the Baltimore City Health Departm
1010
- [What is this?](#what-is-this)
1111
- [Documentation](#documentation)
1212
- [Project setup](#project-setup)
13-
- [Docker and docker-compose](#docker-and-docker-compose)
14-
- [Full .env example](#full-env-example)
15-
- [Keeping your API up to date](#keeping-your-api-up-to-date)
13+
- [Keeping your API up to date](#keeping-your-api-up-to-date)
1614
- [Compiles and hot-reloads for development](#compiles-and-hot-reloads-for-development)
1715
- [Compiles and minifies for production](#compiles-and-minifies-for-production)
1816
- [Lints and fixes files](#lints-and-fixes-files)
1917
- [Customize configuration](#customize-configuration)
2018
- [Using this product](#using-this-product)
2119
- [Testing](#testing)
20+
- [Using Jest for unit testing](#using-jest-for-unit-testing)
21+
- [Using Snyk to check for security vulnerabilities](#using-snyk-to-check-for-security-vulnerabilities)
2222
- [Sources and Links](#sources-and-links)
2323
- [Contributors ✨](#contributors-)
2424

@@ -47,6 +47,7 @@ Add the following to a file named `.env` in your project directory:
4747
```conf
4848
PORT=3000
4949
VUE_APP_BASE_API_URL=http://localhost:3001
50+
VUE_APP_API_VERSION=1
5051
DATABASE_PASSWORD= # Custom value
5152
JWT_KEY= # Custom value
5253
```

src/App.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ export default {
6969
const user = this.$root.auth_token
7070
? this.$jwt.decode(this.$root.auth_token).email
7171
: false;
72-
const role = this.$jwt.decode(this.$root.auth_token).type || '';
72+
const role = this.$root.auth_token
73+
? this.$jwt.decode(this.$root.auth_token).type
74+
: '';
7375
return {
7476
user,
7577
navBar,

src/components/Facility.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
>{{ contact.contact.name }}</router-link>
8686
<p v-if="contact.contact.phone && contact.contact.phone[0]">
8787
Phone:
88-
<a v-bind:href="'tel:' + contact.contact.phone[0].number">{{ contact.contact.phone[0].number | phone }}</a>
88+
<a v-bind:href="'tel:' + contact.contact.phone[0].number">{{ contact.contact.phone[0].number | phone }}</a>
8989
</p>
9090
<p v-if="contact.contact.email && contact.contact.email[0]">
9191
Email:
@@ -617,14 +617,14 @@ export default {
617617
this.entity.checkIn.checkIns.push(this.newCheckIn);
618618
this.entityCheckIn.checkIn = this.newCheckIn;
619619
this.$root.apiPUTRequest(
620-
"/entity",
620+
"entity",
621621
this.entityCheckIn,
622622
this.setLastCheckInData
623623
);
624624
},
625625
getEntity() {
626626
this.$root.apiGETRequest(
627-
"/entity/" + this.$route.params.entityID,
627+
"entity/" + this.$route.params.entityID,
628628
this.updateFacilityData
629629
);
630630
},

src/components/covidForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ export default {
437437
this.showForm = false;
438438
this.newCheckIn.date = new Date();
439439
this.entityCheckIn.checkIn = this.newCheckIn;
440-
this.$root.apiPUTRequest("/entity", this.entityCheckIn, function() {
440+
this.$root.apiPUTRequest("entity", this.entityCheckIn, function() {
441441
self.updateParent();
442442
});
443443
const token = this.$jwt.decode(this.$root.auth_token);

src/components/quickForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export default {
205205
this.showForm = false;
206206
this.newCheckIn.date = new Date();
207207
this.entityCheckIn.checkIn = this.newCheckIn;
208-
this.$root.apiPUTRequest("/entity", this.entityCheckIn, function() {
208+
this.$root.apiPUTRequest("entity", this.entityCheckIn, function() {
209209
self.updateParent();
210210
});
211211
const token = this.$jwt.decode(this.$root.auth_token)

src/components/vaccForm.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
name="question-2b-radio"
8787
value="Not Applicable"
8888
>Not Applicable</b-form-radio>
89-
</b-form-group>
89+
</b-form-group>
9090
<h6>Part C</h6>
9191
<b-form-group
9292
id="check-in-input-question-2c"
@@ -387,7 +387,7 @@ export default {
387387
this.showForm = false;
388388
this.newCheckIn.date = new Date();
389389
this.entityCheckIn.checkIn = this.newCheckIn;
390-
this.$root.apiPUTRequest("/entity", this.entityCheckIn, function() {
390+
this.$root.apiPUTRequest("entity", this.entityCheckIn, function() {
391391
self.updateParent();
392392
});
393393
const token = this.$jwt.decode(this.$root.auth_token);

src/main.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Vue from 'vue'
22
import App from './App.vue'
33
import router from './router'
44
import store from './store'
5+
import { api } from './utils/api'
56
import {BootstrapVue, BootstrapVueIcons} from 'bootstrap-vue'
67
import VueCookies from 'vue-cookies'
78
import vueCountryRegionSelect from 'vue-country-region-select'
@@ -126,7 +127,7 @@ new Vue({
126127
}),
127128
data() {
128129
return {
129-
api: process.env.VUE_APP_BASE_API_URL,
130+
api: api,
130131
authenticated: false
131132
}
132133
},
@@ -172,9 +173,10 @@ new Vue({
172173
this.$cookies.remove('Health_Auth')
173174
},
174175
apiGETRequest(endpoint, callback) {
176+
const fullUrl = new URL(endpoint, api)
175177
let self = this
176178
axios
177-
.get(self.api + endpoint, {
179+
.get(fullUrl.toString(), {
178180
headers: {
179181
'token': self.getSavedToken()
180182
},
@@ -187,9 +189,10 @@ new Vue({
187189
})
188190
},
189191
apiPUTRequest(endpoint, payload, callback) {
192+
const fullUrl = new URL(endpoint, api)
190193
let self = this
191194
axios
192-
.put(self.api + endpoint, payload, {
195+
.put(fullUrl.toString(), payload, {
193196
headers: {
194197
'token': self.getSavedToken()
195198
},
@@ -202,9 +205,10 @@ new Vue({
202205
})
203206
},
204207
apiPOSTRequest(endpoint, payload, callback) {
208+
const fullUrl = new URL(endpoint, api)
205209
let self = this
206210
axios
207-
.post(self.api + endpoint, payload, {
211+
.post(fullUrl.toString(), payload, {
208212
headers: {
209213
'token': self.getSavedToken()
210214
},
@@ -218,10 +222,11 @@ new Vue({
218222
})
219223
},
220224
apiDELRequest(endpoint, callback) {
225+
const fullUrl = new URL(endpoint, api)
221226
let self = this
222227
// requirement for axios
223228
axios
224-
.delete(self.api + endpoint, {
229+
.delete(fullUrl.toString(), {
225230
headers: {
226231
'token': self.getSavedToken()
227232
},

src/templates/Contact.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ export default {
195195
this.populateEntitiesDropdown();
196196
},
197197
getContact(id) {
198-
this.$root.apiGETRequest("/contact/" + id, this.updateContact);
198+
this.$root.apiGETRequest("contact/" + id, this.updateContact);
199199
},
200200
populateEntitiesDropdown() {
201201
for (let entity_ of this.contact.entities) {
@@ -222,7 +222,7 @@ export default {
222222
}
223223
},
224224
getAllContacts() {
225-
this.$root.apiGETRequest("/contact/", this.populateContactsDropdown);
225+
this.$root.apiGETRequest("contact/", this.populateContactsDropdown);
226226
},
227227
returnToLastPage() {
228228
if (this.$route.name === "get-single-contact" || this.$route.name === "create-contact") {
@@ -263,9 +263,9 @@ export default {
263263
newContact.attributes = null;
264264
}
265265
if (this.$route.params.contactID) {
266-
this.$root.apiPUTRequest("/contact", newContact, this.returnToLastPage);
266+
this.$root.apiPUTRequest("contact", newContact, this.returnToLastPage);
267267
} else {
268-
this.$root.apiPOSTRequest("/contact", newContact, this.returnToLastPage);
268+
this.$root.apiPOSTRequest("contact", newContact, this.returnToLastPage);
269269
}
270270
}
271271
},
@@ -274,7 +274,7 @@ export default {
274274
contacts: [{ id: this.selectedContact.id, title: this.selectedContact.relationshipTitle }],
275275
};
276276
this.$root.apiPOSTRequest(
277-
"/entity/link/" + this.$route.params.entityID,
277+
"entity/link/" + this.$route.params.entityID,
278278
body,
279279
this.returnToLastPage
280280
);
@@ -288,7 +288,7 @@ export default {
288288
contacts: [{ id: this.$route.params.contactID }],
289289
};
290290
this.$root.apiPOSTRequest(
291-
"/entity/unlink/" + this.selectedEntityID,
291+
"entity/unlink/" + this.selectedEntityID,
292292
body,
293293
this.returnToLastPage
294294
);
@@ -299,7 +299,7 @@ export default {
299299
return;
300300
}
301301
this.$root.apiDELRequest(
302-
"/contact/" + this.$route.params.contactID,
302+
"contact/" + this.$route.params.contactID,
303303
{},
304304
this.returnToLastPage
305305
);

src/templates/ContactList.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<router-link :to="{ name: 'create-contact' }">
3434
<b-button v-if="showAdmin">Create Contact</b-button>
3535
</router-link>
36-
36+
3737
<b-button v-if="showAdmin" v-on:click="downloadCSV()" class="ml-1">Download CSV</b-button>
3838
</b-col>
3939
</b-row>
@@ -132,7 +132,7 @@ export default {
132132
},
133133
methods: {
134134
getContacts() {
135-
this.$root.apiGETRequest("/contact/", this.handleContactsResponse);
135+
this.$root.apiGETRequest("contact/", this.handleContactsResponse);
136136
},
137137
handleContactsResponse(response) {
138138
this.contacts = response.results;
@@ -143,7 +143,7 @@ export default {
143143
},
144144
sendEmail() {
145145
// send emails
146-
this.$root.apiPOSTRequest(`/contact/send/contact/${this.actionedContact.id}`, {}, this.handleSendResponse)
146+
this.$root.apiPOSTRequest(`contact/send/contact/${this.actionedContact.id}`, {}, this.handleSendResponse)
147147
// close modal
148148
this.$nextTick(() => {
149149
this.showEmailErr = false;
@@ -161,7 +161,7 @@ export default {
161161
})
162162
},
163163
downloadCSV() {
164-
const path = this.filter.keyword ? `/csv/Contact?filter=${this.filter.keyword}` : '/csv/Contact';
164+
const path = this.filter.keyword ? `csv/Contact?filter=${this.filter.keyword}` : 'csv/Contact';
165165
this.$root.apiGETRequest(path, this.createDownload)
166166
},
167167
createDownload(data) {

src/templates/Dashboard.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@
4141
<b-button v-if="showAdmin" v-on:click="addFacility()">Create Facility</b-button>
4242
<b-button v-if="showAdmin" class="ml-1" v-on:click="downloadCSV()">Download CSV</b-button>
4343
<b-button v-if="showAdmin || showUser" @click="actionedFacility = null" class="ml-1" v-b-modal.email-facility-modal>
44-
Email
44+
Email
4545
{{ selectedEntityIds.length ? 'Selected' : '' }}
4646
Facilities
4747
</b-button>
4848
</b-col>
4949
<div>
50-
<b-modal id="email-facility-modal" title="Send Emails to Facilities" ok-title="Send" @ok="sendEmails">
50+
<b-modal id="email-facility-modal" title="Send Emails to Facilities" ok-title="Send" @ok="sendEmails">
5151
<div v-if="selectedEntityIds.length || actionedFacility">
5252
Are you sure you want to send an email to the contacts of the following facilities?
5353
<ul>
@@ -73,7 +73,7 @@
7373
</div>
7474
</b-row>
7575
<b-table
76-
ref="entityTable"
76+
ref="entityTable"
7777
id="dashboard-table"
7878
striped
7979
hover
@@ -122,7 +122,7 @@
122122
name="selectEntityAll"
123123
v-bind:value='true'
124124
v-model='selectAllEntities'
125-
id="selectEntityAll"
125+
id="selectEntityAll"
126126
@change="selectEntityAllClick"
127127
>
128128
<span class='sr-only'>
@@ -257,7 +257,7 @@ export default {
257257
payload.entityType = this.facilityTypeSelected !== FACILITY_TYPE_ALL ? this.facilityTypeSelected : null;
258258
}
259259
260-
this.$root.apiPOSTRequest("/contact/send", payload, this.handleSendEmailsResponse)
260+
this.$root.apiPOSTRequest("contact/send", payload, this.handleSendEmailsResponse)
261261
// close modal
262262
this.$nextTick(() => {
263263
// Reset selected Entities
@@ -311,7 +311,7 @@ export default {
311311
this.selectAllEntities = checkedValue.length === this.entities.length
312312
},
313313
downloadCSV() {
314-
const path = this.filter.keyword ? `/csv/Entity?filter=${this.filter.keyword}` : '/csv/Entity';
314+
const path = this.filter.keyword ? `csv/Entity?filter=${this.filter.keyword}` : 'csv/Entity';
315315
this.$root.apiGETRequest(path, this.createDownload)
316316
},
317317
createDownload(data) {
@@ -331,7 +331,7 @@ export default {
331331
return {value: status, text: status, disabled: false}
332332
})
333333
this.statusOptions = [{value: null, text: "All"}, ...options]
334-
this.$root.apiGETRequest("/entity", this.updateEntities)
334+
this.$root.apiGETRequest("entity", this.updateEntities)
335335
},
336336
}
337337
</script>

0 commit comments

Comments
 (0)