Skip to content

Commit

Permalink
Merge pull request #177 from CodeForBaltimore/revjtanton/issue-149
Browse files Browse the repository at this point in the history
Issue 149
  • Loading branch information
stoopidJSON authored Jul 13, 2020
2 parents 7c24578 + 38f0d66 commit 2d092b7
Show file tree
Hide file tree
Showing 9 changed files with 419 additions and 180 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/CodeForBaltimore/Healthcare-Rollcall.svg?branch=master)](https://travis-ci.org/CodeForBaltimore/Healthcare-Rollcall)
[![Build Status](https://travis-ci.org/CodeForBaltimore/Healthcare-Rollcall.svg?branch=master)](https://travis-ci.org/CodeForBaltimore/Healthcare-Rollcall) [![Netlify Status](https://api.netlify.com/api/v1/badges/83fb49cb-61e1-4c21-8893-03e17e75d972/deploy-status)](https://app.netlify.com/sites/healthcare-rollcall/deploys)

# Healthcare Rollcall

Expand All @@ -7,20 +7,20 @@ In the event of a disaster, Baltimore City and the Baltimore City Health Departm
<!-- TOC -->

- [Healthcare Rollcall](#healthcare-rollcall)
- [What is this?](#what-is-this)
- [Documentation](#documentation)
- [What is this?](#what-is-this)
- [Documentation](#documentation)
- [Project setup](#project-setup)
- [Docker and docker-compose](#docker-and-docker-compose)
- [Full .env example](#full-env-example)
- [Keeping your API up to date](#keeping-your-api-up-to-date)
- [Compiles and hot-reloads for development](#compiles-and-hot-reloads-for-development)
- [Compiles and minifies for production](#compiles-and-minifies-for-production)
- [Lints and fixes files](#lints-and-fixes-files)
- [Customize configuration](#customize-configuration)
- [Docker and docker-compose](#docker-and-docker-compose)
- [Full .env example](#full-env-example)
- [Keeping your API up to date](#keeping-your-api-up-to-date)
- [Compiles and hot-reloads for development](#compiles-and-hot-reloads-for-development)
- [Compiles and minifies for production](#compiles-and-minifies-for-production)
- [Lints and fixes files](#lints-and-fixes-files)
- [Customize configuration](#customize-configuration)
- [Using this product](#using-this-product)
- [Testing](#testing)
- [Testing](#testing)
- [Sources and Links](#sources-and-links)
- [Contributors ✨](#contributors-)
- [Contributors ✨](#contributors-)

<!-- /TOC -->

Expand Down
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"helmet": "3.23.0",
"vue": "^2.6.10",
"vue-cookies": "1.7.0",
"vue-country-region-select": "2.0.14",
"vue-helmet": "1.1.5",
"vue-multiselect": "^2.1.6",
"vuejs-jwt": "1.1.0",
Expand Down
1 change: 0 additions & 1 deletion src/components/quickForm.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<template>
<div>
<h5>{{ formName }}</h5>
<b-form @submit.prevent="addNewCheckin" v-if="showForm">
<h5>Comments</h5>
<b-form-group
Expand Down
190 changes: 96 additions & 94 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,118 +1,120 @@
import Vue from 'vue';
import App from './App.vue';
import router from './router';
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import BootstrapVue from 'bootstrap-vue';
import VueCookies from 'vue-cookies';
import VueJWT from 'vuejs-jwt';
import VueHelmet from 'vue-helmet';
import 'bootstrap/dist/css/bootstrap.min.css';
import 'bootstrap-vue/dist/bootstrap-vue.css';
import { mapState } from "vuex";
import { mapActions } from "vuex";
import axios from "axios";
import Multiselect from 'vue-multiselect';
import BootstrapVue from 'bootstrap-vue'
import VueCookies from 'vue-cookies'
import vueCountryRegionSelect from 'vue-country-region-select'
import VueJWT from 'vuejs-jwt'
import VueHelmet from 'vue-helmet'
import 'bootstrap/dist/css/bootstrap.min.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'
import { mapState } from "vuex"
import { mapActions } from "vuex"
import axios from "axios"
import Multiselect from 'vue-multiselect'

Vue.use(BootstrapVue);
Vue.use(VueCookies);
Vue.use(VueHelmet);
Vue.use(VueJWT, { storage: 'cookie' });
Vue.use(BootstrapVue)
Vue.use(VueCookies)
Vue.use(VueHelmet)
Vue.use(vueCountryRegionSelect)
Vue.use(VueJWT, { storage: 'cookie' })
Vue.component("Search-select", Multiselect)

Vue.config.productionTip = false;
Vue.config.productionTip = false

router.beforeEach((to, from, next) => {
if (Vue.$cookies.get('Health_Auth')) {
next();
next()
} else if (to.name === 'reset' && !store.state.authenticated) {
next();
next()
} else if (to.name === 'checkin' && !store.state.authenticated) {
next();
next()
} else if (to.name !== 'login' && !store.state.authenticated) {
next({ name: 'login' });
next({ name: 'login' })
} else {
next();
next()
}
});
})

Vue.filter('phone', function (phone) {
let phoneClean = ('' + phone).replace(/\D/g, '');
let phoneClean = ('' + phone).replace(/\D/g, '')
if (phoneClean.charAt(0) === "1") {
phoneClean = phoneClean.slice(1);
phoneClean = phoneClean.slice(1)
}
let output = null;
let output = null
if (phoneClean.length === 0) {
output = '';
output = ''
} else if (phoneClean.length > 0 && phoneClean.length <= 3) {
output = '(' + phoneClean.substring(0, 3) + ')';
output = '(' + phoneClean.substring(0, 3) + ')'
} else if (phoneClean.length >= 4 && phoneClean.length <= 6) {
output = '(' + phoneClean.substring(0, 3) + ') ' + phoneClean.substring(3, 6);
output = '(' + phoneClean.substring(0, 3) + ') ' + phoneClean.substring(3, 6)
} else if (phoneClean.length >= 7 && phoneClean.length <= 10) {
output = '(' + phoneClean.substring(0, 3) + ') ' + phoneClean.substring(3, 6) + '-' + phoneClean.substring(6, 10);
output = '(' + phoneClean.substring(0, 3) + ') ' + phoneClean.substring(3, 6) + '-' + phoneClean.substring(6, 10)
} else if (phoneClean.length > 10) {
output = '(' + phoneClean.substring(0, 3) + ') ' + phoneClean.substring(3, 6) + '-' + phoneClean.substring(6, 10) + ' ext: ' + phoneClean.substring(10);
output = '(' + phoneClean.substring(0, 3) + ') ' + phoneClean.substring(3, 6) + '-' + phoneClean.substring(6, 10) + ' ext: ' + phoneClean.substring(10)
}

return '+1 ' + output
});
})

Vue.filter('numberToLetter', function (number) {
switch (number) {
case 0:
return "A";
return "A"
case 1:
return "B";
return "B"
case 2:
return "C";
return "C"
case 3:
return "D";
return "D"
case 4:
return "E";
return "E"
case 5:
return "F";
return "F"
case 6:
return "G";
return "G"
case 7:
return "H";
return "H"
case 8:
return "I";
return "I"
case 9:
return "J";
return "J"
case 10:
return "K";
return "K"
}

});
})

Vue.filter('timestamp', function (input) {
let now = new Date();
let date = new Date(input);
let ampm = date.getHours() >= 12 ? 'pm' : 'am';
let hours = date.getHours() % 12;
let formattedHours = hours ? hours : 12;
let now = new Date()
let date = new Date(input)
let ampm = date.getHours() >= 12 ? 'pm' : 'am'
let hours = date.getHours() % 12
let formattedHours = hours ? hours : 12
let isToday = (now.getDate() === date.getDate() &&
now.getMonth() === date.getMonth() &&
now.getFullYear() === date.getFullYear());
now.getFullYear() === date.getFullYear())
let isYesterday = (now.getDate() === date.getDate() + 1 &&
now.getMonth() === date.getMonth() &&
now.getFullYear() === date.getFullYear());
let dateOutput = (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear() + ' at ';
now.getFullYear() === date.getFullYear())
let dateOutput = (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear() + ' at '
if (isToday) {
dateOutput = "Today at "
} else if (isYesterday) {
dateOutput = "Yesterday at "
}
return dateOutput + formattedHours + ':' +
(date.getMinutes() < 10 ? '0' : '') + date.getMinutes() + ampm;
});
(date.getMinutes() < 10 ? '0' : '') + date.getMinutes() + ampm
})

Vue.filter('nullToNone', function (value) {
if (value == null) {
return "None";
return "None"
} else {
return value;
return value
}
});
})

new Vue({
store,
Expand All @@ -129,107 +131,107 @@ new Vue({
},
created: function () {
if (!this.authenticated && this.getTokenFromCookie()) {
this.authenticateUser(this.getTokenFromCookie());
this.authenticateUser(this.getTokenFromCookie())
}
},
methods: {
...mapActions(["unsetAuth", "authenticate"]),
authenticateUser(response) {
this.setAuthCookie(response);
this.authenticate(response);
this.$emit("authenticated", true);
this.setAuthCookie(response)
this.authenticate(response)
this.$emit("authenticated", true)
},
setAuthCookie(response) {
if (this.getTokenFromCookie() && this.getTokenFromCookie() !== response) {
// Cookies are different - Replacing cookie
this.$cookies.remove('Health_Auth');
this.$cookies.set('Health_Auth', response, '1D', null);
this.$cookies.remove('Health_Auth')
this.$cookies.set('Health_Auth', response, '1D', null)
} else if (!this.getTokenFromCookie()) {
// No existing cookie - Adding cookie
this.$cookies.set('Health_Auth', response, '1D', null);
this.$cookies.set('Health_Auth', response, '1D', null)
} else {
// Cookies are the same - do nothing
}
},
getNavBarStatus() {
return this.$root.auth_state && this.$jwt.decode(this.$root.auth_token).type === 'user';
const userTypes = ['user', 'admin']
return this.$root.auth_state && userTypes.indexOf(this.$jwt.decode(this.$root.auth_token).type) > -1
},
getAuthenticationStatus() {
return this.auth_state;
return this.auth_state
},
getSavedToken() {
return this.auth_token;
return this.auth_token
},
getTokenFromCookie() {
return this.$cookies.get('Health_Auth');
return this.$cookies.get('Health_Auth')
},
destroySession() {
this.unsetAuth();
this.$cookies.remove('Health_Auth');
this.unsetAuth()
this.$cookies.remove('Health_Auth')
},
apiGETRequest(endpoint, callback) {
let self = this;
let self = this
axios
.get(self.api + endpoint, {
headers: {
'token': self.getSavedToken()
},
})
.then(function (response) {
callback(response.data);
callback(response.data)
})
.catch(function (err) {
console.log(err);
});
console.log(err)
})
},
apiPUTRequest(endpoint, payload, callback) {
let self = this;
let self = this
axios
.put(self.api + endpoint, payload, {
headers: {
'token': self.getSavedToken()
},
})
.then(function (response) {
callback(response);
callback(response)
})
.catch(function (err) {
console.log(err);
});
console.log(err)
})
},
apiPOSTRequest(endpoint, payload, callback) {
let self = this;
let self = this
axios
.post(self.api + endpoint, payload, {
headers: {
'token': self.getSavedToken()
},
})
.then(function (response) {
callback(response);
callback(response)
})
.catch(function (err) {
console.log(err);
callback(false);
});
console.log(err)
callback(false)
})
},
apiDELRequest(endpoint, payload, callback) {
let self = this;
apiDELRequest(endpoint, callback) {
let self = this
// requirement for axios
payload = { 'data': payload };
axios
.delete(self.api + endpoint, payload, {
.delete(self.api + endpoint, {
headers: {
'token': self.getSavedToken()
},
})
.then(function (response) {
callback(response);
callback(response)
})
.catch(function (err) {
console.log(err);
callback(false);
});
console.log(err)
callback(false)
})
},
getStatuses() {
return [
Expand All @@ -241,8 +243,8 @@ new Vue({
"Called. No Answer. Did not leave a message.",
"Wrong number",
"No Previous Check-in"
];
]
}
},
router
}).$mount('#app');
}).$mount('#app')
Loading

0 comments on commit 2d092b7

Please sign in to comment.