Adding request now totally works

Also:
- added progress bar, integrated with journal loading
- updated Vue app dependencies
This commit is contained in:
Daniel J. Summers 2017-09-21 21:31:59 -05:00
parent f5a14fb66e
commit a6b5149b34
8 changed files with 135 additions and 64 deletions

View File

@ -29,7 +29,8 @@ export default function (pool) {
LIMIT 1) AS "asOf"
FROM mpj.request
WHERE "userId" = $1
GROUP BY request."requestId"`
GROUP BY request."requestId"
ORDER BY "asOf" DESC`
}, [userId])).rows,
/**
@ -41,7 +42,7 @@ export default function (pool) {
addNew: async (userId, requestText) => {
const id = cuid()
const enteredOn = Date.now()
;(async () => {
return (async () => {
const client = await pool.connect()
try {
await client.query('BEGIN')
@ -59,7 +60,10 @@ export default function (pool) {
client.release()
}
return { requestId: id, text: requestText, asOf: enteredOn }
})().catch(e => console.error(e.stack))
})().catch(e => {
console.error(e.stack)
return { requestId: '', text: 'error', asOf: 0 }
})
}
}
}

View File

@ -323,9 +323,9 @@
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
},
"auth0-js": {
"version": "8.9.3",
"resolved": "https://registry.npmjs.org/auth0-js/-/auth0-js-8.9.3.tgz",
"integrity": "sha1-wqpAnnu69tVV6luFhCPMTumdeYY=",
"version": "8.10.1",
"resolved": "https://registry.npmjs.org/auth0-js/-/auth0-js-8.10.1.tgz",
"integrity": "sha1-1p1VPFUZQELEAK+oRuHtQ6XZ2ng=",
"requires": {
"base64-js": "1.2.1",
"idtoken-verifier": "1.1.0",
@ -590,19 +590,49 @@
}
},
"babel-generator": {
"version": "6.25.0",
"resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.25.0.tgz",
"integrity": "sha1-M6GvcNXyiQrrRlpKd5PB32qeqfw=",
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.0.tgz",
"integrity": "sha1-rBriAHC3n248odMmlhMFN3TyDcU=",
"dev": true,
"requires": {
"babel-messages": "6.23.0",
"babel-runtime": "6.23.0",
"babel-types": "6.25.0",
"babel-runtime": "6.26.0",
"babel-types": "6.26.0",
"detect-indent": "4.0.0",
"jsesc": "1.3.0",
"lodash": "4.17.4",
"source-map": "0.5.6",
"trim-right": "1.0.1"
},
"dependencies": {
"babel-runtime": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz",
"integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=",
"dev": true,
"requires": {
"core-js": "2.4.1",
"regenerator-runtime": "0.11.0"
}
},
"babel-types": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz",
"integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=",
"dev": true,
"requires": {
"babel-runtime": "6.26.0",
"esutils": "2.0.2",
"lodash": "4.17.4",
"to-fast-properties": "1.0.3"
}
},
"regenerator-runtime": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.0.tgz",
"integrity": "sha512-/aA0kLeRb5N9K0d4fw7ooEbI+xDe+DKD499EQqygGqeS8N3xto15p09uY2xj7ixP81sNPXvRLnAQIqdVStgb1A==",
"dev": true
}
}
},
"babel-helper-bindify-decorators": {
@ -800,13 +830,13 @@
}
},
"babel-plugin-istanbul": {
"version": "4.1.4",
"resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.4.tgz",
"integrity": "sha1-GN3oS/POMp/d8/QQP66SFFbY5Yc=",
"version": "4.1.5",
"resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.5.tgz",
"integrity": "sha1-Z2DN2Xf0EdPhdbsGTyvDJ9mbK24=",
"dev": true,
"requires": {
"find-up": "2.1.0",
"istanbul-lib-instrument": "1.7.4",
"istanbul-lib-instrument": "1.8.0",
"test-exclude": "4.1.1"
}
},
@ -1801,16 +1831,16 @@
}
},
"chromedriver": {
"version": "2.32.2",
"resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-2.32.2.tgz",
"integrity": "sha512-Cyvq89aWTtQXPz2Rk8J887orGgCHwZ649MwP4pi3weU7lN7Iw4/qhrHJ9k5bEOitF1JdvxmJmuv0RPIc5Qvfdg==",
"version": "2.32.3",
"resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-2.32.3.tgz",
"integrity": "sha1-zoTwVb7ny/5W8xGCsnbzMlaxK/E=",
"dev": true,
"requires": {
"extract-zip": "1.6.5",
"kew": "0.7.0",
"mkdirp": "0.5.1",
"request": "2.81.0",
"rimraf": "2.6.1"
"rimraf": "2.6.2"
}
},
"cipher-base": {
@ -2779,7 +2809,7 @@
"object-assign": "4.1.1",
"pify": "2.3.0",
"pinkie-promise": "2.0.1",
"rimraf": "2.6.1"
"rimraf": "2.6.2"
}
},
"delayed-stream": {
@ -3447,13 +3477,13 @@
"loader-utils": "1.1.0",
"object-assign": "4.1.1",
"object-hash": "1.1.8",
"rimraf": "2.6.1"
"rimraf": "2.6.2"
}
},
"eslint-plugin-html": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-html/-/eslint-plugin-html-3.2.1.tgz",
"integrity": "sha512-zxcArJx7QTqE0Stm5BMpk1cuYwOxLecqKMqEYabRcvqImDrjcRdQVdXT5RtqFHdH1aVD2akzHe+/Q5Wou6Jvaw==",
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/eslint-plugin-html/-/eslint-plugin-html-3.2.2.tgz",
"integrity": "sha512-sSuafathF6ImPrzF2vUKEJY6Llq06d/riMTMzlsruDRDhNsQMYp2viUKo+jx+JRr1QevskeUpQcuptp2gN1XVQ==",
"dev": true,
"requires": {
"htmlparser2": "3.9.2",
@ -3997,7 +4027,7 @@
"jsonfile": "2.4.0",
"klaw": "1.3.1",
"path-is-absolute": "1.0.1",
"rimraf": "2.6.1"
"rimraf": "2.6.2"
}
},
"fs.realpath": {
@ -5075,18 +5105,26 @@
"dev": true
},
"istanbul-lib-instrument": {
"version": "1.7.4",
"resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-1.7.4.tgz",
"integrity": "sha1-6f2SDkdn89Ge3HZeLWs/XMvQ7qg=",
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-1.8.0.tgz",
"integrity": "sha1-ZvbJQhzJ7EcE928tsIS6kHiitTI=",
"dev": true,
"requires": {
"babel-generator": "6.25.0",
"babel-generator": "6.26.0",
"babel-template": "6.25.0",
"babel-traverse": "6.25.0",
"babel-types": "6.25.0",
"babylon": "6.17.4",
"babylon": "6.18.0",
"istanbul-lib-coverage": "1.1.1",
"semver": "5.4.1"
},
"dependencies": {
"babylon": {
"version": "6.18.0",
"resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz",
"integrity": "sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==",
"dev": true
}
}
},
"js-base64": {
@ -5261,7 +5299,7 @@
"optimist": "0.6.1",
"qjobs": "1.1.5",
"range-parser": "1.2.0",
"rimraf": "2.6.1",
"rimraf": "2.6.2",
"safe-buffer": "5.1.1",
"socket.io": "1.7.3",
"source-map": "0.5.6",
@ -6046,9 +6084,9 @@
"dev": true
},
"mocha": {
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-3.5.1.tgz",
"integrity": "sha512-2jD6NS4PNKVDpaICERx8vEkXaisx2MlRKxj5KuFJVZJdK1zRGs/HnS3OeH7zXhXAbGlzaMIan4Kwpm4O5hORnA==",
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-3.5.3.tgz",
"integrity": "sha512-/6na001MJWEtYxHOV1WLfsmR4YIynkUEhBwzsb+fk2qmQ3iqsi258l/Q2MWHJMImAcNpZ8DEdYAK72NHoIQ9Eg==",
"dev": true,
"requires": {
"browser-stdout": "1.3.0",
@ -9515,9 +9553,9 @@
}
},
"rimraf": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.1.tgz",
"integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=",
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz",
"integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==",
"dev": true,
"requires": {
"glob": "7.1.2"
@ -10662,9 +10700,9 @@
"integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w="
},
"vue": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/vue/-/vue-2.4.2.tgz",
"integrity": "sha512-GB5r+CsrCHIB1PoXt4wgBienjF3WGYOIaTK27tDk96sZxpL5RwRrsi9I3ECwFt8x8qAmxT2xk1vsY2Vpcn9nIw=="
"version": "2.4.4",
"resolved": "https://registry.npmjs.org/vue/-/vue-2.4.4.tgz",
"integrity": "sha512-PCiRmc8ZT1DD5+BN8QUAmnkBefcCLfZVSuhc1u7iu5JoPrSHyyk/+4nehm7k2xVMi8+RFLk5WIHAN14UKF0txw=="
},
"vue-hot-reload-api": {
"version": "2.1.0",
@ -10689,7 +10727,7 @@
"resolve": "1.3.3",
"source-map": "0.5.6",
"vue-hot-reload-api": "2.1.0",
"vue-style-loader": "3.0.1",
"vue-style-loader": "3.0.3",
"vue-template-es2015-compiler": "1.5.3"
},
"dependencies": {
@ -10749,15 +10787,20 @@
}
}
},
"vue-progressbar": {
"version": "0.7.3",
"resolved": "https://registry.npmjs.org/vue-progressbar/-/vue-progressbar-0.7.3.tgz",
"integrity": "sha1-KMqY+hr6YDZEpEPxjHxF/l0pAUQ="
},
"vue-router": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-2.7.0.tgz",
"integrity": "sha512-kxgsT50dDExua3i103nxNBjlfk8LeUmO9iujVxXV42MnISINHUjqMrknpOOJEg+i9nEkoVgG8N86Pklze35c/A=="
},
"vue-style-loader": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-3.0.1.tgz",
"integrity": "sha1-yLY5uy8kuvnXgnTcF+TyZMHe2gg=",
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-3.0.3.tgz",
"integrity": "sha512-P/ihpaZKU23T1kq3E0y4c+F8sbm1HQO69EFYoLoGMSGVAHroHsGir/WQ9qUavP8dyFYHmXenzHaJ/nqd8vfaxw==",
"dev": true,
"requires": {
"hash-sum": "1.0.2",
@ -10765,9 +10808,9 @@
}
},
"vue-template-compiler": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.4.2.tgz",
"integrity": "sha512-sKa2Bdvh+j6V9eQSyJRxsf8fak0FtQkCZ145aYFDVwZBhHOTt1vKrODLo4RelI1dUczKlDCp5aZ9MD7uJOZwvw==",
"version": "2.4.4",
"resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.4.4.tgz",
"integrity": "sha512-XdHsNi8Z5WqwuFl/Z5eLKgE2DOEEOdMk1aA459uSgvwyy+pjKLBlQWsUpAtoR6o6Wmpujw6NtinAUGuqSTituQ==",
"dev": true,
"requires": {
"de-indent": "1.0.2",

View File

@ -14,11 +14,12 @@
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
},
"dependencies": {
"auth0-js": "^8.9.3",
"auth0-js": "^8.10.1",
"axios": "^0.16.2",
"element-ui": "^1.4.4",
"pug": "^2.0.0-rc.4",
"vue": "^2.3.3",
"vue": "^2.4.4",
"vue-progressbar": "^0.7.3",
"vue-router": "^2.6.0",
"vuex": "^2.4.0"
},
@ -27,14 +28,14 @@
"babel-core": "^6.26.0",
"babel-eslint": "^7.1.1",
"babel-loader": "^7.1.2",
"babel-plugin-istanbul": "^4.1.1",
"babel-plugin-istanbul": "^4.1.5",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.26.0",
"chai": "^3.5.0",
"chalk": "^2.1.0",
"chromedriver": "^2.32.2",
"chromedriver": "^2.32.3",
"connect-history-api-fallback": "^1.3.0",
"copy-webpack-plugin": "^4.0.1",
"cross-env": "^5.0.5",
@ -45,7 +46,7 @@
"eslint-config-standard": "^6.2.1",
"eslint-friendly-formatter": "^3.0.0",
"eslint-loader": "^1.7.1",
"eslint-plugin-html": "^3.2.1",
"eslint-plugin-html": "^3.2.2",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^2.0.1",
"eventsource-polyfill": "^0.9.6",
@ -66,13 +67,13 @@
"karma-spec-reporter": "0.0.31",
"karma-webpack": "^2.0.2",
"lolex": "^1.5.2",
"mocha": "^3.5.1",
"mocha": "^3.5.3",
"nightwatch": "^0.9.12",
"opn": "^5.1.0",
"optimize-css-assets-webpack-plugin": "^2.0.0",
"ora": "^1.2.0",
"phantomjs-prebuilt": "^2.1.15",
"rimraf": "^2.6.0",
"rimraf": "^2.6.2",
"selenium-server": "^3.5.3",
"semver": "^5.4.1",
"shelljs": "^0.7.6",
@ -80,8 +81,8 @@
"sinon-chai": "^2.13.0",
"url-loader": "^0.5.8",
"vue-loader": "^12.1.0",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.3.3",
"vue-style-loader": "^3.0.3",
"vue-template-compiler": "^2.4.4",
"webpack": "^2.6.1",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-dev-middleware": "^1.12.0",

View File

@ -3,6 +3,7 @@
navigation
#content.container
router-view
vue-progress-bar
footer
p.text-right: i myPrayerJournal v0.8.0
</template>

View File

@ -21,8 +21,8 @@ import actions from '@/store/action-types'
export default {
name: 'dashboard',
data () {
this.$store.dispatch(actions.LOAD_JOURNAL)
async data () {
this.$store.dispatch(actions.LOAD_JOURNAL, this.$Progress)
return {}
},
components: {

View File

@ -1,5 +1,7 @@
<template lang="pug">
div
el-row.journal-request(:id="request.requestId")
el-col(:span='4') Action buttons
el-col(:span='20')
p Id {{ request.requestId }} as of {{ request.asOf }}
p {{ request.text }}
</template>
@ -10,6 +12,17 @@ export default {
props: ['request'],
data: function () {
return {}
},
methods: {
markPrayed: function (requestId) {
// TODO: write function
}
}
}
</script>
<style>
.journal-request {
border-bottom: dotted 1px lightgray;
}
</style>

View File

@ -2,6 +2,7 @@
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import ElementUI from 'element-ui'
import VueProgressBar from 'vue-progressbar'
import 'element-ui/lib/theme-default/index.css'
import App from './App'
@ -12,6 +13,12 @@ Vue.config.productionTip = false
Vue.use(ElementUI)
Vue.use(VueProgressBar, {
color: 'rgb(143, 255, 199)',
failedColor: 'red',
height: '2px'
})
/* eslint-disable no-new */
new Vue({
el: '#app',

View File

@ -60,8 +60,9 @@ export default new Vuex.Store({
}
},
actions: {
async [actions.LOAD_JOURNAL] ({ commit }) {
async [actions.LOAD_JOURNAL] ({ commit }, progress) {
commit(mutations.LOADED_JOURNAL, {})
progress.start()
commit(mutations.LOADING_JOURNAL, true)
api.setBearer(localStorage.getItem('id_token'))
try {
@ -71,12 +72,13 @@ export default new Vuex.Store({
logError(err)
} finally {
commit(mutations.LOADING_JOURNAL, false)
progress.finish()
}
},
async [actions.ADD_REQUEST] ({ commit }, requestText) {
try {
const newRequest = await api.addRequest(requestText)
commit(mutations.REQUEST_ADDED, newRequest)
commit(mutations.REQUEST_ADDED, newRequest.data)
} catch (err) {
logError(err)
}