17 Commits
0.8.2 ... 0.9.3

Author SHA1 Message Date
Daniel J. Summers
d5a783304e updated API deps 2018-05-20 22:08:59 -05:00
Daniel J. Summers
a429a2d6c9 GDPR update; version bump
- added Terms of Service and Privacy Policy
- updated deps
- fixed vue-bootstrap warning
2018-05-19 23:22:44 -05:00
Daniel J. Summers
943492f175 Updated Auth0 and other deps #13; version bump 2018-03-10 22:50:39 -06:00
Daniel J. Summers
df76385d6a Added previously-ignored Vue build files
Those globs will git you...
2018-03-10 22:22:10 -06:00
Daniel J. Summers
8d8d112fff Updated front page text (#12) 2017-10-23 22:04:34 -05:00
Daniel J. Summers
6c4061e07d Updated docs/README; version bump
So long alpha - hello, beta!
2017-10-23 21:40:58 -05:00
Daniel J. Summers
9cdb505bb1 Renamed RequestListItem to RequestCard 2017-10-23 21:22:29 -05:00
Daniel J. Summers
40d765fb92 Journal is more mobile-friendly (#11)
Also:
- Updated deps
- Ensure the date is wrapped as a whole on the Answered Request page
2017-10-23 21:19:39 -05:00
Daniel J. Summers
56dee71377 Updated dox for #9; version bump 2017-10-23 05:53:30 -05:00
Daniel J. Summers
3c3f0a7981 Finished answered request layout (#9)
Also:
- rearranged API calls to be in alphabetical order (except the bearer
stuff at the top)
- modified the API base URL and Auth0 renewal URLs to be derived from
the browser's location (localhost / prod both work now with no change)
2017-10-22 22:50:26 -05:00
Daniel J. Summers
a1ce40ee83 Get version from package.json (#10)
...that was easy.
2017-10-19 15:11:51 -05:00
Daniel J. Summers
b8f1708012 Version bump
also updated e-mail address
2017-10-09 21:42:45 -05:00
Daniel J. Summers
69811cbf54 Added Notes feature (#8)
Also:
- Moved buttons to top of request
- Tweaked layout of full request view
- Added code to ensure that users may only add history and notes to
their own requests; security FTW!
2017-10-09 21:39:40 -05:00
Daniel J. Summers
b6d72d691b Docs update
Removed note about issue #5 that is fixed in v0.8.3
2017-10-08 22:08:43 -05:00
Daniel J. Summers
6f49a61822 Version bump (v0.8.3) 2017-10-08 22:07:49 -05:00
Daniel J. Summers
4db6d98011 Implemented auth renewal (#5) 2017-10-08 21:58:36 -05:00
Daniel J. Summers
3acec3dc25 Misc tweaks
- Updated SFCs per Vue Style Guide guidelines
- Added green gradient to header and off-white background color to body
- Changed DJS Consulting to Bit Badger Solutions in the docs
2017-10-08 19:19:24 -05:00
41 changed files with 3715 additions and 1706 deletions

3
.gitignore vendored
View File

@@ -253,7 +253,8 @@ paket-files/
*.sln.iml *.sln.iml
# Compiled files / application # Compiled files / application
src/api/build
src/api/public/index.html src/api/public/index.html
src/api/public/static src/api/public/static
src/api/appsettings.json src/api/appsettings.json
build/ /build

View File

@@ -1,7 +1,11 @@
# myPrayerJournal # myPrayerJournal
## About myPrayerJournal
Journaling has a long history; it helps people remember what happened, and the act of writing helps people think about what happened and process it. A prayer journal is not a new concept; it helps you keep track of the requests for which you've prayed, you can use it to pray over things repeatedly, and you can write the result when the answer comes _(or it was "no")_. Journaling has a long history; it helps people remember what happened, and the act of writing helps people think about what happened and process it. A prayer journal is not a new concept; it helps you keep track of the requests for which you've prayed, you can use it to pray over things repeatedly, and you can write the result when the answer comes _(or it was "no")_.
This is borne of out of a personal desire I had to have something that would help me with my prayer life. When it's time to pray, it's not really time to use an app, so the design goal here is to keep it simple and unobtrusive. It will also help eliminate some of the downsides to a paper prayer journal, like not remembering whether you've prayed for a request, or running out of room to write another update on one. myPrayerJournal was borne of out of a personal desire I (Daniel) had to have something that would help me with my prayer life. When it's time to pray, it's not really time to use an app, so the design goal here is to keep it simple and unobtrusive. It will also help eliminate some of the downsides to a paper prayer journal, like not remembering whether you've prayed for a request, or running out of room to write another update on one.
It is still a work-in-progress (WIP), but is available for public preview at <https://prayerjournal.me>. ## Futher Reading
The documentation for the site is at <https://danieljsummers.github.io/myPrayerJournal/>.

View File

@@ -1,6 +1,10 @@
## Caveats # Documentation
_myPrayerJournal is currently alpha software. There likely will be errors, the way things work may change, and parts of the application are unfinished or need polish. I **will** do my best to not lose any data, though; it is backed up the way other DJS Consulting sites have their data backed up. Throughout this document, current gotchas will be called out with italic text, like this notice._ ## About myPrayerJournal
Journaling has a long history; it helps people remember what happened, and the act of writing helps people think about what happened and process it. A prayer journal is not a new concept; it helps you keep track of the requests for which you've prayed, you can use it to pray over things repeatedly, and you can write the result when the answer comes _(or it was "no")_.
myPrayerJournal was borne of out of a personal desire I (Daniel) had to have something that would help me with my prayer life. When it's time to pray, it's not really time to use an app, so the design goal here is to keep it simple and unobtrusive. It will also help eliminate some of the downsides to a paper prayer journal, like not remembering whether you've prayed for a request, or running out of room to write another update on one.
## Finding the Site ## Finding the Site
@@ -12,7 +16,7 @@ myPrayerJournal uses login services using Google or Microsoft accounts. The only
## Your Prayer Journal ## Your Prayer Journal
Your current requests will be presented in three columns (or one, if you're using a mobile phone). Each request is in its own card, and the buttons at the bottom of each card apply to that request. The last line of each request also tells you how long it has been since anything has been done on that request. Any time you see something like "a few minutes ago," you can hover over that to see the actual date/time the action was taken. Your current requests will be presented in three columns (or two or one, depending on the size of your screen or device). Each request is in its own card, and the buttons at the top of each card apply to that request. The last line of each request also tells you how long it has been since anything has been done on that request. Any time you see something like "a few minutes ago," you can hover over that to see the actual date/time the action was taken.
## Adding a Request ## Adding a Request
@@ -26,16 +30,20 @@ The first button for each request has a checkmark icon; clicking this button wil
The second button for each request has a pencil icon. This allows you to edit the text of the request, pretty much the same way you entered it; it starts with the current text, and you can add to it, modify it, or completely replace it. By default, updates will go in with an "Updated" status; you have the option to also mark this update as "Prayed" or "Answered." Answered requests will drop off the journal list. The second button for each request has a pencil icon. This allows you to edit the text of the request, pretty much the same way you entered it; it starts with the current text, and you can add to it, modify it, or completely replace it. By default, updates will go in with an "Updated" status; you have the option to also mark this update as "Prayed" or "Answered." Answered requests will drop off the journal list.
## Adding Notes
The third button for each request has an icon that looks like a piece of paper with writing; this lets you record notes about the request. If there is something you want to record that doesn't change the text of the request, this is the place to do it. For example, you may be praying for a long-term health issue, and that person tells you that their status is the same; or, you may want to record something God said to you while you were praying for that request.
## Viewing a Request and Its History ## Viewing a Request and Its History
myPrayerJournal tracks all of the actions related to a request; the fourth button, with the magnifying glass icon, will show you the entire history, including the text as it changed, and all the times "Prayed" was recorded. myPrayerJournal tracks all of the actions related to a request; the fourth button, with the magnifying glass icon, will show you the entire history, including the text as it changed, and all the times "Prayed" was recorded.
## Answered Requests ## Answered Requests
Next to "Journal" on the top navigation is the word "Answered." This page lists all answered requests, from most recent to least recent, along with the text of the request at the time it was marked as answered. It will also show you when it was marked answered. The button with the magnifying class at the words "Show Full Request" behave the same way as the paragraph immediately preceding this describes. _(This will likely change before a 0.9.x release, but this gives at least some way to find and review answered requests.)_ Next to "Journal" on the top navigation is the word "Answered." This page lists all answered requests, from most recent to least recent, along with the text of the request at the time it was marked as answered. It will also show you when it was marked answered. The button at the bottom of each request, with the magnifying glass and the words "Show Full Request", link to a page that shows that request's complete history and notes, along with a few statistics about that request. The history and notes are listed from most recent to least recent; if you want to read it chronologically, just press the "End" key on your keyboard and read it from the bottom up.
## Known Issues ## Final Notes
See [the GitHub issues list](https://github.com/danieljsummers/myPrayerJournal/issues) for the most up-to-date list. - myPrayerJournal is currently in public beta. If you encounter errors, please [file an issue on GitHub](https://github.com/danieljsummers/myPrayerJournal/issues) with as much detail as possible. You can also browse the list of issues to see what has been done and what is still left to do.
- Prayer requests and their history are securely backed up nightly along with other Bit Badger Solutions data.
- _If you try to do something an get an error notification instead of a green checkmark, try logging off and logging back on again. The site currently doesn't check to see if your session has expired, but the server with which it's communicating does._ - Prayer changes things - most of all, the one doing the praying. I pray that this tool enables you to deepen and strengthen your prayer life.

View File

@@ -1,10 +1,10 @@
{ {
"name": "my-prayer-journal-api", "name": "my-prayer-journal-api",
"private": true, "private": true,
"version": "0.8.2", "version": "0.9.3",
"description": "Server API for myPrayerJournal", "description": "Server API for myPrayerJournal",
"main": "index.js", "main": "index.js",
"author": "Daniel J. Summers <daniel@djs-consulting.com>", "author": "Daniel J. Summers <daniel@bitbadger.solutions>",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"chalk": "^2.1.0", "chalk": "^2.1.0",

View File

@@ -46,6 +46,17 @@ const ddl = [
PRIMARY KEY ("requestId", "asOf")); PRIMARY KEY ("requestId", "asOf"));
COMMENT ON TABLE mpj.history IS 'Request update history'` COMMENT ON TABLE mpj.history IS 'Request update history'`
}, },
{
name: 'note Table',
check: tableSql('note'),
fix: `
CREATE TABLE mpj.note (
"requestId" varchar(25) NOT NULL REFERENCES mpj.request,
"asOf" bigint NOT NULL,
"notes" text NOT NULL,
PRIMARY KEY ("requestId", "asOf"));
COMMENT ON TABLE mpj.note IS 'Notes regarding a request'`
},
{ {
name: 'request.userId Index', name: 'request.userId Index',
check: indexSql('request', 'idx_request_userId'), check: indexSql('request', 'idx_request_userId'),

View File

@@ -18,21 +18,41 @@ const requestNotFound = {
} }
export default function (pool) { export default function (pool) {
/**
* Retrieve basic information about a single request
* @param {string} requestId The Id of the request to retrieve
* @param {string} userId The Id of the user to whom the request belongs
*/
let retrieveRequest = (requestId, userId) =>
pool.query(`
SELECT "requestId", "enteredOn"
FROM mpj.request
WHERE "requestId" = $1
AND "userId" = $2`,
[ requestId, userId ])
return { return {
/** /**
* Add a history entry for this request * Add a history entry for this request
* @param {string} requestId The Id of the request * @param {string} userId The Id of the user to whom this request belongs
* @param {string} requestId The Id of the request to which the update applies
* @param {string} status The status for this history entry * @param {string} status The status for this history entry
* @param {string} updateText The updated text for the request (pass blank if no update) * @param {string} updateText The updated text for the request (pass blank if no update)
* @return {number} 404 if the request is not found or does not belong to the given user, 204 if successful
*/ */
addHistory: async (requestId, status, updateText) => { addHistory: async (userId, requestId, status, updateText) => {
const asOf = Date.now() const req = retrieveRequest(requestId, userId)
if (req.rowCount === 0) {
return 404
}
await pool.query(` await pool.query(`
INSERT INTO mpj.history INSERT INTO mpj.history
("requestId", "asOf", "status", "text") ("requestId", "asOf", "status", "text")
VALUES VALUES
($1, $2, $3, NULLIF($4, ''))`, ($1, $2, $3, NULLIF($4, ''))`,
[ requestId, asOf, status, updateText ]) [ requestId, Date.now(), status, updateText ])
return 204
}, },
/** /**
@@ -68,6 +88,27 @@ export default function (pool) {
}) })
}, },
/**
* Add a note about a prayer request
* @param {string} userId The Id of the user to whom the request belongs
* @param {string} requestId The Id of the request to which the note applies
* @param {string} note The notes to add
* @return {number} 404 if the request is not found or does not belong to the given user, 204 if successful
*/
addNote: async (userId, requestId, note) => {
const req = retrieveRequest(requestId, userId)
if (req.rowCount === 0) {
return 404
}
await pool.query(`
INSERT INTO mpj.note
("requestId", "asOf", "notes")
VALUES
($1, $2, $3)`,
[ requestId, Date.now(), note ])
return 204
},
/** /**
* Get all answered requests with their text as of the "Answered" status * Get all answered requests with their text as of the "Answered" status
* @param {string} userId The Id of the user for whom requests should be retrieved * @param {string} userId The Id of the user for whom requests should be retrieved
@@ -101,12 +142,7 @@ export default function (pool) {
* @return The request, or a request-like object indicating that the request was not found * @return The request, or a request-like object indicating that the request was not found
*/ */
fullById: async (userId, requestId) => { fullById: async (userId, requestId) => {
const reqResults = await pool.query(` const reqResults = await retrieveRequest(requestId, userId)
SELECT "requestId", "enteredOn"
FROM mpj.request
WHERE "requestId" = $1
AND "userId" = $2`,
[ requestId, userId ])
if (0 === reqResults.rowCount) { if (0 === reqResults.rowCount) {
return requestNotFound return requestNotFound
} }
@@ -126,7 +162,27 @@ export default function (pool) {
* @param {string} userId The Id of the user * @param {string} userId The Id of the user
* @return The requests that make up the current journal * @return The requests that make up the current journal
*/ */
journal: async userId => (await pool.query(`${journalSql} ORDER BY "asOf"`, [ userId ])).rows journal: async userId => (await pool.query(`${journalSql} ORDER BY "asOf"`, [ userId ])).rows,
/**
* Get the notes for a request, most recent first
* @param {string} userId The Id of the user to whom the request belongs
* @param {string} requestId The Id of the request whose notes should be retrieved
* @return The notes for the request
*/
notesById: async (userId, requestId) => {
const reqResults = await retrieveRequest(requestId, userId)
if (0 === reqResults.rowCount) {
return requestNotFound
}
const notes = await pool.query(`
SELECT "asOf", "notes"
FROM mpj.note
WHERE "requestId" = $1
ORDER BY "asOf" DESC`,
[ requestId ])
return notes.rows
}
} }
} }

View File

@@ -16,8 +16,13 @@ export default function (checkJwt) {
// Add a request history entry (prayed, updated, answered, etc.) // Add a request history entry (prayed, updated, answered, etc.)
.post('/:id/history', checkJwt, async (ctx, next) => { .post('/:id/history', checkJwt, async (ctx, next) => {
const body = ctx.request.body const body = ctx.request.body
await db.request.addHistory(ctx.params.id, body.status, body.updateText) ctx.response.status = await db.request.addHistory(ctx.state.user.sub, ctx.params.id, body.status, body.updateText)
ctx.response.status = 204 await next()
})
// Add a note to a request
.post('/:id/note', checkJwt, async (ctx, next) => {
const body = ctx.request.body
ctx.response.status = await db.request.addNote(ctx.state.user.sub, ctx.params.id, body.notes)
await next() await next()
}) })
// Get a journal-style request by its Id // Get a journal-style request by its Id
@@ -40,6 +45,30 @@ export default function (checkJwt) {
} }
await next() await next()
}) })
// Get the notes for a request
.get('/:id/notes', checkJwt, async (ctx, next) => {
const notes = await db.request.notesById(ctx.state.user.sub, ctx.params.id)
if (notes.text && 'Not Found' === notes.text) {
ctx.response.status = 404
} else {
ctx.body = notes
ctx.response.status = 200
}
await next()
})
// Get a complete request; equivalent to full + notes
.get('/:id/complete', checkJwt, async (ctx, next) => {
const req = await db.request.fullById(ctx.state.user.sub, ctx.params.id)
if ('Not Found' === req.text) {
ctx.response.status = 404
} else {
ctx.response.status = 200
req.notes = await db.request.notesById(ctx.state.user.sub, ctx.params.id)
ctx.body = req
}
await next()
})
// Get all answered requests
.get('/answered', checkJwt, async (ctx, next) => { .get('/answered', checkJwt, async (ctx, next) => {
ctx.body = await db.request.answered(ctx.state.user.sub) ctx.body = await db.request.answered(ctx.state.user.sub)
ctx.response.status = 200 ctx.response.status = 200

File diff suppressed because it is too large Load Diff

35
src/app/build/build.js Normal file
View File

@@ -0,0 +1,35 @@
require('./check-versions')()
process.env.NODE_ENV = 'production'
var ora = require('ora')
var rm = require('rimraf')
var path = require('path')
var chalk = require('chalk')
var webpack = require('webpack')
var config = require('../config')
var webpackConfig = require('./webpack.prod.conf')
var spinner = ora('building for production...')
spinner.start()
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
if (err) throw err
webpack(webpackConfig, function (err, stats) {
spinner.stop()
if (err) throw err
process.stdout.write(stats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false
}) + '\n\n')
console.log(chalk.cyan(' Build complete.\n'))
console.log(chalk.yellow(
' Tip: built files are meant to be served over an HTTP server.\n' +
' Opening index.html over file:// won\'t work.\n'
))
})
})

View File

@@ -0,0 +1,48 @@
var chalk = require('chalk')
var semver = require('semver')
var packageConfig = require('../package.json')
var shell = require('shelljs')
function exec (cmd) {
return require('child_process').execSync(cmd).toString().trim()
}
var versionRequirements = [
{
name: 'node',
currentVersion: semver.clean(process.version),
versionRequirement: packageConfig.engines.node
},
]
if (shell.which('npm')) {
versionRequirements.push({
name: 'npm',
currentVersion: exec('npm --version'),
versionRequirement: packageConfig.engines.npm
})
}
module.exports = function () {
var warnings = []
for (var i = 0; i < versionRequirements.length; i++) {
var mod = versionRequirements[i]
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
warnings.push(mod.name + ': ' +
chalk.red(mod.currentVersion) + ' should be ' +
chalk.green(mod.versionRequirement)
)
}
}
if (warnings.length) {
console.log('')
console.log(chalk.yellow('To use this template, you must update following to modules:'))
console.log()
for (var i = 0; i < warnings.length; i++) {
var warning = warnings[i]
console.log(' ' + warning)
}
console.log()
process.exit(1)
}
}

View File

@@ -0,0 +1,9 @@
/* eslint-disable */
require('eventsource-polyfill')
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
hotClient.subscribe(function (event) {
if (event.action === 'reload') {
window.location.reload()
}
})

View File

@@ -0,0 +1,92 @@
require('./check-versions')()
var config = require('../config')
if (!process.env.NODE_ENV) {
process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV)
}
var opn = require('opn')
var path = require('path')
var express = require('express')
var webpack = require('webpack')
var proxyMiddleware = require('http-proxy-middleware')
var webpackConfig = process.env.NODE_ENV === 'testing'
? require('./webpack.prod.conf')
: require('./webpack.dev.conf')
// default port where dev server listens for incoming traffic
var port = process.env.PORT || config.dev.port
// automatically open browser, if not set will be false
var autoOpenBrowser = !!config.dev.autoOpenBrowser
// Define HTTP proxies to your custom API backend
// https://github.com/chimurai/http-proxy-middleware
var proxyTable = config.dev.proxyTable
var app = express()
var compiler = webpack(webpackConfig)
var devMiddleware = require('webpack-dev-middleware')(compiler, {
publicPath: webpackConfig.output.publicPath,
quiet: true
})
var hotMiddleware = require('webpack-hot-middleware')(compiler, {
log: () => {},
heartbeat: 2000
})
// force page reload when html-webpack-plugin template changes
compiler.plugin('compilation', function (compilation) {
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
hotMiddleware.publish({ action: 'reload' })
cb()
})
})
// proxy api requests
Object.keys(proxyTable).forEach(function (context) {
var options = proxyTable[context]
if (typeof options === 'string') {
options = { target: options }
}
app.use(proxyMiddleware(options.filter || context, options))
})
// handle fallback for HTML5 history API
app.use(require('connect-history-api-fallback')())
// serve webpack bundle output
app.use(devMiddleware)
// enable hot-reload and state-preserving
// compilation error display
app.use(hotMiddleware)
// serve pure static assets
var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
app.use(staticPath, express.static('./static'))
var uri = 'http://localhost:' + port
var _resolve
var readyPromise = new Promise(resolve => {
_resolve = resolve
})
console.log('> Starting dev server...')
devMiddleware.waitUntilValid(() => {
console.log('> Listening at ' + uri + '\n')
// when env is testing, don't need open it
if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
opn(uri)
}
_resolve()
})
var server = app.listen(port)
module.exports = {
ready: readyPromise,
close: () => {
server.close()
}
}

71
src/app/build/utils.js Normal file
View File

@@ -0,0 +1,71 @@
var path = require('path')
var config = require('../config')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
exports.assetsPath = function (_path) {
var assetsSubDirectory = process.env.NODE_ENV === 'production'
? config.build.assetsSubDirectory
: config.dev.assetsSubDirectory
return path.posix.join(assetsSubDirectory, _path)
}
exports.cssLoaders = function (options) {
options = options || {}
var cssLoader = {
loader: 'css-loader',
options: {
minimize: process.env.NODE_ENV === 'production',
sourceMap: options.sourceMap
}
}
// generate loader string to be used with extract text plugin
function generateLoaders (loader, loaderOptions) {
var loaders = [cssLoader]
if (loader) {
loaders.push({
loader: loader + '-loader',
options: Object.assign({}, loaderOptions, {
sourceMap: options.sourceMap
})
})
}
// Extract CSS when that option is specified
// (which is the case during production build)
if (options.extract) {
return ExtractTextPlugin.extract({
use: loaders,
fallback: 'vue-style-loader'
})
} else {
return ['vue-style-loader'].concat(loaders)
}
}
// https://vue-loader.vuejs.org/en/configurations/extract-css.html
return {
css: generateLoaders(),
postcss: generateLoaders(),
less: generateLoaders('less'),
sass: generateLoaders('sass', { indentedSyntax: true }),
scss: generateLoaders('sass'),
stylus: generateLoaders('stylus'),
styl: generateLoaders('stylus')
}
}
// Generate loaders for standalone style files (outside of .vue)
exports.styleLoaders = function (options) {
var output = []
var loaders = exports.cssLoaders(options)
for (var extension in loaders) {
var loader = loaders[extension]
output.push({
test: new RegExp('\\.' + extension + '$'),
use: loader
})
}
return output
}

View File

@@ -0,0 +1,18 @@
var utils = require('./utils')
var config = require('../config')
var isProduction = process.env.NODE_ENV === 'production'
module.exports = {
loaders: utils.cssLoaders({
sourceMap: isProduction
? config.build.productionSourceMap
: config.dev.cssSourceMap,
extract: isProduction
}),
transformToRequire: {
video: 'src',
source: 'src',
img: 'src',
image: 'xlink:href'
}
}

View File

@@ -0,0 +1,75 @@
var path = require('path')
var utils = require('./utils')
var config = require('../config')
var vueLoaderConfig = require('./vue-loader.conf')
function resolve (dir) {
return path.join(__dirname, '..', dir)
}
module.exports = {
entry: {
app: './src/main.js'
},
output: {
path: config.build.assetsRoot,
filename: '[name].js',
publicPath: process.env.NODE_ENV === 'production'
? config.build.assetsPublicPath
: config.dev.assetsPublicPath
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src')
}
},
module: {
rules: [
{
test: /\.(js|vue)$/,
loader: 'eslint-loader',
enforce: 'pre',
include: [resolve('src'), resolve('test')],
options: {
formatter: require('eslint-friendly-formatter')
}
},
{
test: /\.vue$/,
loader: 'vue-loader',
options: vueLoaderConfig
},
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('src'), resolve('test')]
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
},
{
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('media/[name].[hash:7].[ext]')
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}
]
}
}

View File

@@ -0,0 +1,35 @@
var utils = require('./utils')
var webpack = require('webpack')
var config = require('../config')
var merge = require('webpack-merge')
var baseWebpackConfig = require('./webpack.base.conf')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
// add hot-reload related code to entry chunks
Object.keys(baseWebpackConfig.entry).forEach(function (name) {
baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])
})
module.exports = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
},
// cheap-module-eval-source-map is faster for development
devtool: '#cheap-module-eval-source-map',
plugins: [
new webpack.DefinePlugin({
'process.env': config.dev.env
}),
// https://github.com/glenjamin/webpack-hot-middleware#installation--usage
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
// https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true
}),
new FriendlyErrorsPlugin()
]
})

View File

@@ -0,0 +1,125 @@
var path = require('path')
var utils = require('./utils')
var webpack = require('webpack')
var config = require('../config')
var merge = require('webpack-merge')
var baseWebpackConfig = require('./webpack.base.conf')
var CopyWebpackPlugin = require('copy-webpack-plugin')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
var env = process.env.NODE_ENV === 'testing'
? require('../config/test.env')
: config.build.env
var webpackConfig = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({
sourceMap: config.build.productionSourceMap,
extract: true
}),
noParse: [/moment.js/]
},
devtool: config.build.productionSourceMap ? '#source-map' : false,
output: {
path: config.build.assetsRoot,
filename: utils.assetsPath('js/[name].[chunkhash].js'),
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
},
plugins: [
// http://vuejs.github.io/vue-loader/en/workflow/production.html
new webpack.DefinePlugin({
'process.env': env
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
sourceMap: true
}),
// extract css into its own file
new ExtractTextPlugin({
filename: utils.assetsPath('css/[name].[contenthash].css')
}),
// Compress extracted CSS. We are using this plugin so that possible
// duplicated CSS from different components can be deduped.
new OptimizeCSSPlugin({
cssProcessorOptions: {
safe: true
}
}),
// generate dist index.html with correct asset hash for caching.
// you can customize output by editing /index.html
// see https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: process.env.NODE_ENV === 'testing'
? 'index.html'
: config.build.index,
template: 'index.html',
inject: true,
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
},
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
chunksSortMode: 'dependency'
}),
// split vendor js into its own file
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: function (module, count) {
// any required modules inside node_modules are extracted to vendor
return (
module.resource &&
/\.js$/.test(module.resource) &&
module.resource.indexOf(
path.join(__dirname, '../node_modules')
) === 0
)
}
}),
// extract webpack runtime and module manifest to its own file in order to
// prevent vendor hash from being updated whenever app bundle is updated
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
chunks: ['vendor']
}),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.build.assetsSubDirectory,
ignore: ['.*']
}
])
]
})
if (config.build.productionGzip) {
var CompressionWebpackPlugin = require('compression-webpack-plugin')
webpackConfig.plugins.push(
new CompressionWebpackPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp(
'\\.(' +
config.build.productionGzipExtensions.join('|') +
')$'
),
threshold: 10240,
minRatio: 0.8
})
)
}
if (config.build.bundleAnalyzerReport) {
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
}
module.exports = webpackConfig

View File

@@ -0,0 +1,31 @@
// This is the webpack config used for unit tests.
var utils = require('./utils')
var webpack = require('webpack')
var merge = require('webpack-merge')
var baseConfig = require('./webpack.base.conf')
var webpackConfig = merge(baseConfig, {
// use inline sourcemap for karma-sourcemap-loader
module: {
rules: utils.styleLoaders()
},
devtool: '#inline-source-map',
resolveLoader: {
alias: {
// necessary to to make lang="scss" work in test when using vue-loader's ?inject option
// see discussion at https://github.com/vuejs/vue-loader/issues/724
'scss-loader': 'sass-loader'
}
},
plugins: [
new webpack.DefinePlugin({
'process.env': require('../config/test.env')
})
]
})
// no need for app entry during tests
delete webpackConfig.entry
module.exports = webpackConfig

View File

@@ -1,8 +1,8 @@
{ {
"name": "my-prayer-journal", "name": "my-prayer-journal",
"version": "0.8.2", "version": "0.9.3",
"description": "myPrayerJournal - Front End", "description": "myPrayerJournal - Front End",
"author": "Daniel J. Summers <daniel@djs-consulting.com>", "author": "Daniel J. Summers <daniel@bitbadger.solutions>",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "node build/dev-server.js", "dev": "node build/dev-server.js",
@@ -14,17 +14,18 @@
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs" "lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
}, },
"dependencies": { "dependencies": {
"auth0-js": "^8.10.1", "auth0-js": "^9.3.3",
"axios": "^0.16.2", "axios": "^0.18.0",
"bootstrap": "^4.0.0",
"bootstrap-vue": "^1.0.0-beta.9", "bootstrap-vue": "^1.0.0-beta.9",
"moment": "^2.18.1", "moment": "^2.18.1",
"pug": "^2.0.0-rc.4", "pug": "^2.0.1",
"vue": "^2.4.4", "vue": "^2.5.15",
"vue-awesome": "^2.3.3", "vue-awesome": "^2.3.3",
"vue-progressbar": "^0.7.3", "vue-progressbar": "^0.7.3",
"vue-router": "^2.6.0", "vue-router": "^3.0.0",
"vue-toast": "^3.1.0", "vue-toast": "^3.1.0",
"vuex": "^2.4.0" "vuex": "^3.0.0"
}, },
"devDependencies": { "devDependencies": {
"autoprefixer": "^7.1.4", "autoprefixer": "^7.1.4",

View File

@@ -6,7 +6,14 @@
vue-progress-bar vue-progress-bar
toast(ref='toast') toast(ref='toast')
footer footer
p.text-right: i myPrayerJournal v0.8.2 p.text-right.text-muted
| myPrayerJournal v{{ version }}
br
em: small.
#[router-link(:to="{ name: 'PrivacyPolicy' }") Privacy Policy] &bull;
#[router-link(:to="{ name: 'TermsOfService' }") Terms of Service] &bull;
#[a(href='https://github.com/danieljsummers/myprayerjournal') Developed] and hosted by
#[a(href='https://bitbadger.solutions') Bit Badger Solutions]
</template> </template>
<script> <script>
@@ -14,11 +21,16 @@
import Navigation from './components/Navigation.vue' import Navigation from './components/Navigation.vue'
import { version } from '../package.json'
export default { export default {
name: 'app', name: 'app',
components: { components: {
Navigation Navigation
}, },
data () {
return { version }
},
mounted () { mounted () {
this.$refs.toast.setOptions({ position: 'bottom right' }) this.$refs.toast.setOptions({ position: 'bottom right' })
}, },
@@ -31,6 +43,9 @@ export default {
</script> </script>
<style> <style>
html, body {
background-color: whitesmoke;
}
body { body {
padding-top: 60px; padding-top: 60px;
} }
@@ -42,11 +57,16 @@ footer {
footer p { footer p {
margin: 0; margin: 0;
} }
.mpj-page-title { a:link, a:visited {
border-bottom: solid 1px lightgray; color: #050;
margin-bottom: 20px;
} }
.mpj-request-text { .mpj-request-text {
white-space: pre-line; white-space: pre-line;
} }
.bg-mpj {
background-image: -webkit-gradient(linear, left top, left bottom, from(#050), to(whitesmoke));
background-image: -webkit-linear-gradient(top, #050, whitesmoke);
background-image: -moz-linear-gradient(top, #050, whitesmoke);
background-image: linear-gradient(to bottom, #050, whitesmoke);
}
</style> </style>

View File

@@ -1,7 +1,7 @@
import axios from 'axios' import axios from 'axios'
const http = axios.create({ const http = axios.create({
baseURL: 'http://localhost:3000/api/' baseURL: `${location.protocol}//${location.host}/api/`
}) })
/** /**
@@ -21,9 +21,11 @@ export default {
removeBearer: () => delete http.defaults.headers.common['authorization'], removeBearer: () => delete http.defaults.headers.common['authorization'],
/** /**
* Get all prayer requests and their most recent updates * Add a note for a prayer request
* @param {string} requestId The Id of the request to which the note applies
* @param {string} notes The notes to be added
*/ */
journal: () => http.get('journal/'), addNote: (requestId, notes) => http.post(`request/${requestId}/note`, { notes }),
/** /**
* Add a new prayer request * Add a new prayer request
@@ -32,19 +34,9 @@ export default {
addRequest: requestText => http.post('request/', { requestText }), addRequest: requestText => http.post('request/', { requestText }),
/** /**
* Update a prayer request * Get all answered requests, along with the text they had when it was answered
* @param request The request (should have requestId, status, and updateText properties)
*/ */
updateRequest: request => http.post(`request/${request.requestId}/history`, { getAnsweredRequests: () => http.get('request/answered'),
status: request.status,
updateText: request.updateText
}),
/**
* Get a prayer request (journal-style; only latest update)
* @param {string} requestId The Id of the request to retrieve
*/
getRequest: requestId => http.get(`request/${requestId}`),
/** /**
* Get a prayer request (full; includes all history) * Get a prayer request (full; includes all history)
@@ -53,8 +45,34 @@ export default {
getFullRequest: requestId => http.get(`request/${requestId}/full`), getFullRequest: requestId => http.get(`request/${requestId}/full`),
/** /**
* Get all answered requests, along with the text they had when it was answered * Get past notes for a prayer request
* @param {string} requestId The Id of the request for which notes should be retrieved
*/ */
getAnsweredRequests: () => http.get('request/answered') getNotes: requestId => http.get(`request/${requestId}/notes`),
/**
* Get a prayer request (journal-style; only latest update)
* @param {string} requestId The Id of the request to retrieve
*/
getRequest: requestId => http.get(`request/${requestId}`),
/**
* Get a complete request; equivalent of "full" and "notes" combined
*/
getRequestComplete: requestId => http.get(`request/${requestId}/complete`),
/**
* Get all prayer requests and their most recent updates
*/
journal: () => http.get('journal/'),
/**
* Update a prayer request
* @param request The request (should have requestId, status, and updateText properties)
*/
updateRequest: request => http.post(`request/${request.requestId}/history`, {
status: request.status,
updateText: request.updateText
})
} }

View File

@@ -5,6 +5,8 @@ import auth0 from 'auth0-js'
import AUTH_CONFIG from './auth0-variables' import AUTH_CONFIG from './auth0-variables'
import mutations from '@/store/mutation-types' import mutations from '@/store/mutation-types'
var tokenRenewalTimeout
export default class AuthService { export default class AuthService {
constructor () { constructor () {
@@ -17,7 +19,7 @@ export default class AuthService {
auth0 = new auth0.WebAuth({ auth0 = new auth0.WebAuth({
domain: AUTH_CONFIG.domain, domain: AUTH_CONFIG.domain,
clientID: AUTH_CONFIG.clientId, clientID: AUTH_CONFIG.clientId,
redirectUri: AUTH_CONFIG.callbackUrl, redirectUri: AUTH_CONFIG.appDomain + AUTH_CONFIG.callbackUrl,
audience: `https://${AUTH_CONFIG.domain}/userinfo`, audience: `https://${AUTH_CONFIG.domain}/userinfo`,
responseType: 'token id_token', responseType: 'token id_token',
scope: 'openid profile email' scope: 'openid profile email'
@@ -78,6 +80,16 @@ export default class AuthService {
}) })
} }
scheduleRenewal () {
let expiresAt = JSON.parse(localStorage.getItem('expires_at'))
let delay = expiresAt - Date.now()
if (delay > 0) {
tokenRenewalTimeout = setTimeout(() => {
this.renewToken()
}, delay)
}
}
setSession (authResult) { setSession (authResult) {
// Set the time that the access token will expire at // Set the time that the access token will expire at
let expiresAt = JSON.stringify( let expiresAt = JSON.stringify(
@@ -86,10 +98,30 @@ export default class AuthService {
localStorage.setItem('access_token', authResult.accessToken) localStorage.setItem('access_token', authResult.accessToken)
localStorage.setItem('id_token', authResult.idToken) localStorage.setItem('id_token', authResult.idToken)
localStorage.setItem('expires_at', expiresAt) localStorage.setItem('expires_at', expiresAt)
this.scheduleRenewal()
}
renewToken () {
console.log('attempting renewal...')
this.auth0.renewAuth(
{
audience: `https://${AUTH_CONFIG.domain}/userinfo`,
redirectUri: `${AUTH_CONFIG.appDomain}/static/silent.html`,
usePostMessage: true
},
(err, result) => {
if (err) {
console.log(err)
} else {
this.setSession(result)
}
}
)
} }
logout (store, router) { logout (store, router) {
// Clear access token and ID token from local storage // Clear access token and ID token from local storage
clearTimeout(tokenRenewalTimeout)
localStorage.removeItem('access_token') localStorage.removeItem('access_token')
localStorage.removeItem('id_token') localStorage.removeItem('id_token')
localStorage.removeItem('expires_at') localStorage.removeItem('expires_at')

View File

@@ -2,35 +2,38 @@
article article
page-title(title='Answered Requests') page-title(title='Answered Requests')
p(v-if='!loaded') Loading answered requests... p(v-if='!loaded') Loading answered requests...
div(v-if='loaded') div(v-if='loaded').mpj-answered-list
p.mpj-request-text(v-for='req in requests') p.mpj-request-text(v-for='req in requests' :key='req.requestId')
b-btn(@click='showFull(req.requestId)' size='sm' variant='outline-secondary') | {{ req.text }}
br
br
b-btn(:to='{ name: "AnsweredDetail", params: { id: req.requestId }}'
size='sm'
variant='outline-secondary')
icon(name='search') icon(name='search')
| &nbsp;View Full Request = ' View Full Request'
| &nbsp; &nbsp; {{ req.text }} &nbsp;
small.text-muted: em. small.text-muted: em.
(Answered #[date-from-now(:value='req.asOf')]) &nbsp; Answered #[date-from-now(:value='req.asOf')]
full-request(:events='eventBus')
</template> </template>
<script> <script>
'use static' 'use static'
import Vue from 'vue'
import FullRequest from './request/FullRequest'
import api from '@/api' import api from '@/api'
export default { export default {
name: 'answered', name: 'answered',
data () { data () {
return { return {
eventBus: new Vue(),
requests: [], requests: [],
loaded: false loaded: false
} }
}, },
computed: {
toast () {
return this.$parent.$refs.toast
}
},
async mounted () { async mounted () {
this.$Progress.start() this.$Progress.start()
try { try {
@@ -44,19 +47,15 @@ export default {
} finally { } finally {
this.loaded = true this.loaded = true
} }
},
components: {
FullRequest
},
computed: {
toast () {
return this.$parent.$refs.toast
}
},
methods: {
showFull (requestId) {
this.eventBus.$emit('full', requestId)
}
} }
} }
</script> </script>
<style>
.mpj-answered-list p {
border-top: solid 1px lightgray;
}
.mpj-answered-list p:first-child {
border-top: none;
}
</style>

View File

@@ -0,0 +1,82 @@
<template lang="pug">
article
page-title(title='Answered Request')
p(v-if='!request') Loading request...
template(v-if='request')
p.
Answered {{ formatDate(answered) }} (#[date-from-now(:value='answered')]) &nbsp;
#[small: em.text-muted prayed {{ prayedCount }} times, open {{ openDays }} days]
p.mpj-request-text {{ lastText }}
b-table(small hover :fields='fields' :items='log')
template(slot='action' scope='data').
{{ data.item.status }} on #[span.text-nowrap {{ formatDate(data.item.asOf) }}]
</template>
<script>
'use strict'
import moment from 'moment'
import api from '@/api'
const asOfDesc = (a, b) => b.asOf - a.asOf
export default {
name: 'answer-detail',
props: {
id: {
type: String,
required: true
}
},
data () {
return {
request: null,
fields: [
{ key: 'action', label: 'Action' },
{ key: 'text', label: 'Update / Notes' }
]
}
},
computed: {
answered () {
return this.request.history.find(hist => hist.status === 'Answered').asOf
},
lastText () {
return this.request.history
.filter(hist => hist.text > '')
.sort(asOfDesc)[0].text
},
log () {
return this.request.notes
.map(note => ({ asOf: note.asOf, text: note.notes, status: 'Notes' }))
.concat(this.request.history)
.sort(asOfDesc)
.slice(1)
},
openDays () {
return Math.floor(
(this.answered - this.request.history.find(hist => hist.status === 'Created').asOf) / 1000 / 60 / 60 / 24)
},
prayedCount () {
return this.request.history.filter(hist => hist.status === 'Prayed').length
}
},
async mounted () {
this.$Progress.start()
try {
const req = await api.getRequestComplete(this.id)
this.request = req.data
this.$Progress.finish()
} catch (e) {
console.log(e)
this.$Progress.fail()
}
},
methods: {
formatDate (asOf) {
return moment(asOf).format('LL')
}
}
}
</script>

View File

@@ -1,15 +1,16 @@
<template lang="pug"> <template lang="pug">
article article
page-title(title='Welcome!' hideOnPage='true') page-title(title='Welcome!'
hideOnPage='true')
p &nbsp; p &nbsp;
p. p.
myPrayerJournal is a place where individuals can record their prayer requests, record that they prayed for them, myPrayerJournal is a place where individuals can record their prayer requests, record that they prayed for them,
update them as God moves in the situation, and record a final answer received on that request.&nbsp; It will also update them as God moves in the situation, and record a final answer received on that request. It will also allow
allow individuals to review their answered prayers. individuals to review their answered prayers.
p. p.
This site is currently in very limited alpha, as it is being developed with a core group of test users.&nbsp; If This site is currently in beta, but it is open and available to the general public. To get started, simply click
this is something in which you are interested, check back around mid-November 2017 for an update on the the &ldquo;Log On&rdquo; link above, and log on with either a Microsoft or Google account. You can also learn more
development progress. about the site at the &ldquo;Docs&rdquo; link, also above.
</template> </template>
<script> <script>

View File

@@ -5,14 +5,17 @@ article
template(v-if='!isLoadingJournal') template(v-if='!isLoadingJournal')
new-request new-request
br br
request-list-item(v-if='journal.length > 0' b-row(v-if='journal.length > 0')
v-for='row in journalCardRows' request-card(v-for='request in journal'
:row='row' :key='request.requestId'
:events='eventBus' :request='request'
:toast='toast' :events='eventBus'
:key='row[0].requestId') :toast='toast')
p.text-center(v-if='journal.length === 0'): em No requests found; click the "Add a New Request" button to add one p.text-center(v-if='journal.length === 0'): em No requests found; click the "Add a New Request" button to add one
edit-request(:events='eventBus' :toast='toast' ) edit-request(:events='eventBus'
:toast='toast')
notes-edit(:events='eventBus'
:toast='toast')
full-request(:events='eventBus') full-request(:events='eventBus')
</template> </template>
@@ -26,22 +29,24 @@ import chunk from 'lodash/chunk'
import EditRequest from './request/EditRequest' import EditRequest from './request/EditRequest'
import FullRequest from './request/FullRequest' import FullRequest from './request/FullRequest'
import NewRequest from './request/NewRequest' import NewRequest from './request/NewRequest'
import RequestListItem from './request/RequestListItem' import NotesEdit from './request/NotesEdit'
import RequestCard from './request/RequestCard'
import actions from '@/store/action-types' import actions from '@/store/action-types'
export default { export default {
name: 'journal', name: 'journal',
data () {
return {
eventBus: new Vue()
}
},
components: { components: {
EditRequest, EditRequest,
FullRequest, FullRequest,
NewRequest, NewRequest,
RequestListItem NotesEdit,
RequestCard
},
data () {
return {
eventBus: new Vue()
}
}, },
computed: { computed: {
title () { title () {

View File

@@ -1,17 +1,24 @@
<template lang="pug"> <template lang="pug">
b-navbar(toggleable='sm' type='dark' variant='mpj' fixed='top') b-navbar(toggleable='sm'
type='dark'
variant='mpj'
fixed='top')
b-nav-toggle(target='nav_collapse') b-nav-toggle(target='nav_collapse')
b-navbar-brand(to='/') b-navbar-brand(to='/')
span(style='font-weight:100;') my span(style='font-weight:100;') my
span(style='font-weight:600;') Prayer span(style='font-weight:600;') Prayer
span(style='font-weight:700;') Journal span(style='font-weight:700;') Journal
b-collapse#nav_collapse(is-nav) b-collapse#nav_collapse(is-nav)
b-nav(is-nav-bar) b-navbar-nav
b-nav-item(v-if='isAuthenticated' to='/journal') Journal b-nav-item(v-if='isAuthenticated'
b-nav-item(v-if='isAuthenticated' to='/answered') Answered to='/journal') Journal
b-nav-item(v-if='isAuthenticated'
to='/answered') Answered
b-nav-item(v-if='isAuthenticated'): a(@click.stop='logOff()') Log Off b-nav-item(v-if='isAuthenticated'): a(@click.stop='logOff()') Log Off
b-nav-item(v-if='!isAuthenticated'): a(@click.stop='logOn()') Log On b-nav-item(v-if='!isAuthenticated'): a(@click.stop='logOn()') Log On
b-nav-item(href='https://danieljsummers.github.io/myPrayerJournal/' target='_blank' @click.stop='') Docs b-nav-item(href='https://danieljsummers.github.io/myPrayerJournal/'
target='_blank'
@click.stop='') Docs
</template> </template>
<script> <script>
@@ -27,6 +34,9 @@ export default {
auth0: new AuthService() auth0: new AuthService()
} }
}, },
computed: {
...mapState([ 'isAuthenticated' ])
},
methods: { methods: {
logOn () { logOn () {
this.auth0.login() this.auth0.login()
@@ -34,15 +44,6 @@ export default {
logOff () { logOff () {
this.auth0.logout(this.$store, this.$router) this.auth0.logout(this.$store, this.$router)
} }
},
computed: {
...mapState([ 'isAuthenticated' ])
} }
} }
</script> </script>
<style>
.bg-mpj {
background-color: #1e7e34 !important;
}
</style>

View File

@@ -1,5 +1,6 @@
<template lang="pug"> <template lang="pug">
h2.mpj-page-title(v-if='!hideOnPage' v-html='title') h2.mpj-page-title(v-if='!hideOnPage'
v-html='title')
</template> </template>
<script> <script>
@@ -15,13 +16,20 @@ export default {
default: false default: false
} }
}, },
created () {
document.title = `${this.title} « myPrayerJournal`
},
watch: { watch: {
title () { title () {
document.title = `${this.title} « myPrayerJournal` document.title = `${this.title} « myPrayerJournal`
} }
},
created () {
document.title = `${this.title} « myPrayerJournal`
} }
} }
</script> </script>
<style scoped>
.mpj-page-title {
border-bottom: solid 1px lightgray;
margin-bottom: 20px;
}
</style>

View File

@@ -0,0 +1,54 @@
<template lang="pug">
article
page-title(title='Privacy Policy')
p: small: em (as of May 21, 2018)
p.
The nature of the service is one where privacy is a must. The items below will help you understand the data we
collect, access, and store on your behalf as you use this service.
hr
h3 Third Party Services
p.
myPrayerJournal utilizes a third-party authentication and identity provider. You should familiarize yourself with
the privacy policy for #[a(href='https://auth0.com/privacy' target='_blank') Auth0], as well as your chosen provider
(#[a(href='https://privacy.microsoft.com/en-us/privacystatement' target='_blank') Microsoft] or
#[a(href='https://policies.google.com/privacy' target='_blank') Google]).
hr
h3 What We Collect
h4 Identifying Data
ul
li.
The only identifying data myPrayerJournal stores is the subscriber (&ldquo;sub&rdquo;) field from the token we
receive from Auth0, once you have signed in through their hosted service. All information is associated with you
via this field.
li.
While you are signed in, within your browser, the service has access to your first and last names, along with a
URL to the profile picture (provided by your selected identity provider). This information is not transmitted to
the server, and is removed when &ldquo;Log Off&rdquo; is clicked.
h4 User Provided Data
ul
li.
myPrayerJournal stores the information you provide, including the text of prayer requests, updates, and notes;
and the date/time when certain actions are taken.
hr
h3 How Your Data Is Accessed / Secured
ul
li.
Your provided data is returned to you, as required, to display your journal or your answered requests.
On the server, it is stored in a controlled-access database.
li.
Your data is backed up, along with other Bit Badger Solutions hosted systems, in a rolling manner; backups are
preserved for the prior 7 days, and backups from the 1st and 15th are preserved for 3 months. These backups are
stored in a private cloud data repository.
li.
The data collected and stored is the absolute minimum necessary for the functionality of the service. There are
no plans to &ldquo;monetize&rdquo; this service, and storing the minimum amount of information means that the
data we have is not interesting to purchasers (or those who may have more nefarious purposes).
li Access to servers and backups is strictly controlled and monitored for unauthorized access attempts.
hr
h3 Removing Your Data
p.
At any time, you may choose to discontinue using this service. Both Microsoft and Google provide ways to revoke
access from this application. However, if you want your data removed from the database, please contact daniel at
bitbadger.solutions (via e-mail, replacing at with @) prior to doing so, to ensure we can determine which
subscriber ID belongs to you.
</template>

View File

@@ -0,0 +1,35 @@
<template lang="pug">
article
page-title(title='Terms of Service')
p: small: em (as of May 21, 2018)
h3 1. Acceptance of Terms
p.
By accessing this web site, you are agreeing to be bound by these Terms and Conditions, and that you are
responsible to ensure that your use of this site complies with all applicable laws. Your continued use of this
site implies your acceptance of these terms.
h3 2. Description of Service and Registration
p.
myPrayerJournal is a service that allows individuals to enter and amend their prayer requests. It requires no
registration by itself, but access is granted based on a successful login with an external identity provider. See
#[router-link(:to="{ name: 'PrivacyPolicy' }") our privacy policy] for details on how that information is accessed
and stored.
h3 3. Third Party Services
p.
This service utilizes a third-party service provider for identity management. Review the terms of service for
#[a(href='https://auth0.com/terms' target='_blank') Auth0], as well as those for the selected authorization
provider (#[a(href='https://www.microsoft.com/en-us/servicesagreement' target='_blank') Microsoft] or
#[a(href='https://policies.google.com/terms' target='_blank') Google]).
h3 4. Liability
p.
This service is provided "as is", and no warranty (express or implied) exists. The service and its developers may
not be held liable for any damages that may arise through the use of this service.
h3 5. Updates to Terms
p.
These terms and conditions may be updated at any time, and this service does not have the capability to notify
users when these change. The date at the top of the page will be updated when any of the text of these terms is
updated.
hr
p.
You may also wish to review our #[router-link(:to="{ name: 'PrivacyPolicy' }") privacy policy] to learn how we
handle your data.
</template>

View File

@@ -1,25 +1,30 @@
<template lang="pug"> <template lang="pug">
span b-modal(v-model='editVisible'
//- b-btn(@click='openDialog()' title='Edit' size='sm' variant='outline-secondary'): icon(name='pencil') header-bg-variant='mpj'
b-modal(title='Edit Prayer Request' header-text-variant='light'
v-model='editVisible' size='lg'
size='lg' title='Edit Prayer Request'
header-bg-variant='dark' @edit='openDialog()'
header-text-variant='light' @shows='focusRequestText')
@edit='openDialog()' b-form
@shows='focusRequestText') b-form-group(label='Prayer Request'
b-form label-for='request_text')
b-form-group(label='Prayer Request' label-for='request_text') b-textarea#request_text(ref='toFocus'
b-textarea#request_text(v-model='form.requestText' :rows='10' @blur='trimText()' ref='toFocus') v-model='form.requestText'
b-form-group(label='Also Mark As') :rows='10'
b-radio-group(v-model='form.status' buttons) @blur='trimText()')
b-radio(value='Updated') Updated b-form-group(label='Also Mark As')
b-radio(value='Prayed') Prayed b-radio-group(v-model='form.status'
b-radio(value='Answered') Answered buttons)
div.w-100.text-right(slot='modal-footer') b-radio(value='Updated') Updated
b-btn(variant='primary' @click='saveRequest()') Save b-radio(value='Prayed') Prayed
| &nbsp; &nbsp; b-radio(value='Answered') Answered
b-btn(variant='outline-secondary' @click='closeDialog()') Cancel div.w-100.text-right(slot='modal-footer')
b-btn(variant='primary'
@click='saveRequest()') Save
| &nbsp; &nbsp;
b-btn(variant='outline-secondary'
@click='closeDialog()') Cancel
</template> </template>
<script> <script>

View File

@@ -1,15 +1,19 @@
<template lang="pug"> <template lang="pug">
span span
b-modal(title='Prayer Request History' b-modal(v-model='historyVisible'
v-model='historyVisible' header-bg-variant='mpj'
size='lg'
header-bg-variant='dark'
header-text-variant='light' header-text-variant='light'
size='lg'
title='Prayer Request History'
@shows='focusRequestText') @shows='focusRequestText')
b-list-group(v-if='null !== full' flush) b-list-group(v-if='null !== full'
full-request-history(v-for='item in full.history' :history='item' :key='item.asOf') flush)
full-request-history(v-for='item in full.history'
:key='item.asOf'
:history='item')
div.w-100.text-right(slot='modal-footer') div.w-100.text-right(slot='modal-footer')
b-btn(variant='primary' @click='closeDialog()') Close b-btn(variant='primary'
@click='closeDialog()') Close
</template> </template>
<script> <script>
@@ -21,6 +25,9 @@ import api from '@/api'
export default { export default {
name: 'full-request', name: 'full-request',
components: {
FullRequestHistory
},
props: { props: {
events: { required: true } events: { required: true }
}, },
@@ -33,9 +40,6 @@ export default {
created () { created () {
this.events.$on('full', this.openDialog) this.events.$on('full', this.openDialog)
}, },
components: {
FullRequestHistory
},
methods: { methods: {
closeDialog () { closeDialog () {
this.full = null this.full = null

View File

@@ -1,7 +1,9 @@
<template lang="pug"> <template lang="pug">
b-list-group-item b-list-group-item
| {{ history.status }} {{ asOf }} | {{ history.status }}
span(v-if='0 < history.text.length') &nbsp;&raquo; {{ history.text }} |
small.text-muted {{ asOf }}
div(v-if='hasText').mpj-request-text {{ history.text }}
</template> </template>
<script> <script>
@@ -17,6 +19,9 @@ export default {
computed: { computed: {
asOf () { asOf () {
return moment(this.history.asOf).fromNow() return moment(this.history.asOf).fromNow()
},
hasText () {
return this.history.text.length > 0
} }
} }
} }

View File

@@ -3,19 +3,25 @@ div
b-btn(@click='openDialog()' size='sm' variant='primary') b-btn(@click='openDialog()' size='sm' variant='primary')
icon(name='plus') icon(name='plus')
| &nbsp; Add a New Request | &nbsp; Add a New Request
b-modal(title='Add a New Prayer Request' b-modal(v-model='showNewVisible'
v-model='showNewVisible' header-bg-variant='mpj'
size='lg'
header-bg-variant='dark'
header-text-variant='light' header-text-variant='light'
size='lg'
title='Add a New Prayer Request'
@shown='focusRequestText') @shown='focusRequestText')
b-form b-form
b-form-group(label='Prayer Request' label-for='request_text') b-form-group(label='Prayer Request'
b-textarea#request_text(v-model='form.requestText' :rows='10' @blur='trimText()' ref='toFocus') label-for='request_text')
b-textarea#request_text(ref='toFocus'
v-model='form.requestText'
:rows='10'
@blur='trimText()')
div.w-100.text-right(slot='modal-footer') div.w-100.text-right(slot='modal-footer')
b-btn(variant='primary' @click='saveRequest()') Save b-btn(variant='primary'
@click='saveRequest()') Save
| &nbsp; &nbsp; | &nbsp; &nbsp;
b-btn(variant='outline-secondary' @click='closeDialog()') Cancel b-btn(variant='outline-secondary'
@click='closeDialog()') Cancel
toast(ref='toast') toast(ref='toast')
</template> </template>

View File

@@ -0,0 +1,116 @@
<template lang="pug">
b-modal(v-model='notesVisible'
header-bg-variant='mpj'
header-text-variant='light'
size='lg'
title='Add Notes to Prayer Request'
@edit='openDialog()'
@shows='focusNotes')
b-form
b-form-group(label='Notes'
label-for='notes')
b-textarea#notes(ref='toFocus'
v-model='form.notes'
:rows='10'
@blur='trimText()')
div(v-if='hasPriorNotes')
p.text-center: strong Prior Notes for This Request
b-list-group(flush)
b-list-group-item(v-for='note in priorNotes'
:key='note.asOf')
small.text-muted: date-from-now(:value='note.asOf')
br
div.mpj-request-text {{ note.notes }}
div(v-else-if='noPriorNotes').text-center.text-muted There are no prior notes for this request
div(v-else).text-center
b-btn(variant='outline-secondary'
@click='loadNotes()') Load Prior Notes
div.w-100.text-right(slot='modal-footer')
b-btn(variant='primary'
@click='saveNotes()') Save
| &nbsp; &nbsp;
b-btn(variant='outline-secondary'
@click='closeDialog()') Cancel
</template>
<script>
'use strict'
import api from '@/api'
export default {
name: 'notes-edit',
props: {
toast: { required: true },
events: { required: true }
},
data () {
return {
notesVisible: false,
form: {
requestId: '',
notes: ''
},
priorNotes: [],
priorNotesLoaded: false
}
},
computed: {
hasPriorNotes () {
return this.priorNotesLoaded && this.priorNotes.length > 0
},
noPriorNotes () {
return this.priorNotesLoaded && this.priorNotes.length === 0
}
},
created () {
this.events.$on('notes', this.openDialog)
},
methods: {
closeDialog () {
this.form.requestId = ''
this.form.notes = ''
this.priorNotes = []
this.priorNotesLoaded = false
this.notesVisible = false
},
focusNotes (e) {
this.$refs.toFocus.focus()
},
async loadNotes () {
this.$Progress.start()
try {
const notes = await api.getNotes(this.form.requestId)
this.priorNotes = notes.data
console.log(this.priorNotes)
this.$Progress.finish()
} catch (e) {
console.error(e)
this.$Progress.fail()
} finally {
this.priorNotesLoaded = true
}
},
openDialog (request) {
this.form.requestId = request.requestId
this.notesVisible = true
this.focusNotes(null)
},
async saveNotes () {
this.$Progress.start()
try {
await api.addNote(this.form.requestId, this.form.notes)
this.$Progress.finish()
this.toast.showToast('Added notes', { theme: 'success' })
this.closeDialog()
} catch (e) {
console.error(e)
this.$Progress.fail()
}
},
trimText () {
this.form.notes = this.form.notes.trim()
}
}
}
</script>

View File

@@ -0,0 +1,59 @@
<template lang="pug">
b-col(md='6' lg='4')
.mpj-request-card
b-card-header.text-center.py-1.
#[b-btn(@click='markPrayed()' variant='outline-primary' title='Pray' size='sm'): icon(name='check')]
#[b-btn(@click.stop='showEdit()' variant='outline-secondary' title='Edit' size='sm'): icon(name='pencil')]
#[b-btn(@click.stop='showNotes()' variant='outline-secondary' title='Add Notes' size='sm'): icon(name='file-text-o')]
#[b-btn(@click.stop='showFull()' variant='outline-secondary' title='View Full Request' size='sm'): icon(name='search')]
b-card-body.p-0
p.card-text.mpj-request-text.mb-1.px-3.pt-3
| {{ request.text }}
p.card-text.p-0.pr-1.text-right: small.text-muted: em
= '(last activity '
date-from-now(:value='request.asOf')
| )
</template>
<script>
'use strict'
import actions from '@/store/action-types'
export default {
name: 'request-card',
props: {
request: { required: true },
toast: { required: true },
events: { required: true }
},
methods: {
async markPrayed () {
await this.$store.dispatch(actions.UPDATE_REQUEST, {
progress: this.$Progress,
requestId: this.request.requestId,
status: 'Prayed',
updateText: ''
})
this.toast.showToast('Request marked as prayed', { theme: 'success' })
},
showEdit () {
this.events.$emit('edit', this.request)
},
showFull () {
this.events.$emit('full', this.request.requestId)
},
showNotes () {
this.events.$emit('notes', this.request)
}
}
}
</script>
<style>
.mpj-request-card {
border: solid 1px darkgray;
border-radius: 5px;
margin-bottom: 15px;
}
</style>

View File

@@ -1,51 +0,0 @@
<template lang="pug">
div
b-card-group.w-100(deck)
b-card(v-for='(request, idx) in row' border-variant='dark' no-body)
b-card-body.p-0
p.card-text.mpj-request-text.mb-1.px-3.pt-3
| {{ request.text }}
p.card-text.p-0.pr-1.text-right: small.text-muted: em
= '(last activity '
date-from-now(:value='request.asOf')
| )
b-card-footer.text-center.py-1.
#[b-btn(@click='markPrayed(idx)' variant='outline-primary' title='Pray' size='sm'): icon(name='check')]
#[b-btn(@click.stop='showEdit(request)' variant='outline-secondary' title='Edit' size='sm'): icon(name='pencil')]
#[b-btn(disabled variant='outline-secondary' title='Add Notes' size='sm'): icon(name='file-text-o')]
#[b-btn(@click.stop='showFull(idx)' variant='outline-secondary' title='View Full Request' size='sm'): icon(name='search')]
b-card(v-for='it in 3 - row.length')
br
</template>
<script>
'use strict'
import actions from '@/store/action-types'
export default {
name: 'request-list-item',
props: {
row: { required: true },
toast: { required: true },
events: { required: true }
},
methods: {
async markPrayed (idx) {
await this.$store.dispatch(actions.UPDATE_REQUEST, {
progress: this.$Progress,
requestId: this.row[idx].requestId,
status: 'Prayed',
updateText: ''
})
this.toast.showToast('Request marked as prayed', { theme: 'success' })
},
showEdit (request) {
this.events.$emit('edit', request)
},
showFull (idx) {
this.events.$emit('full', this.row[idx].requestId)
}
}
}
</script>

View File

@@ -2,18 +2,53 @@ import Vue from 'vue'
import Router from 'vue-router' import Router from 'vue-router'
import Answered from '@/components/Answered' import Answered from '@/components/Answered'
import AnsweredDetail from '@/components/AnsweredDetail'
import Home from '@/components/Home' import Home from '@/components/Home'
import Journal from '@/components/Journal' import Journal from '@/components/Journal'
import LogOn from '@/components/user/LogOn' import LogOn from '@/components/user/LogOn'
import PrivacyPolicy from '@/components/legal/PrivacyPolicy'
import TermsOfService from '@/components/legal/TermsOfService'
Vue.use(Router) Vue.use(Router)
export default new Router({ export default new Router({
mode: 'history', mode: 'history',
routes: [ routes: [
{ path: '/', name: 'Home', component: Home }, {
{ path: '/answered', name: 'Answered', component: Answered }, path: '/',
{ path: '/journal', name: 'Journal', component: Journal }, name: 'Home',
{ path: '/user/log-on', name: 'LogOn', component: LogOn } component: Home
},
{
path: '/answered/:id',
name: 'AnsweredDetail',
component: AnsweredDetail,
props: true
},
{
path: '/answered',
name: 'Answered',
component: Answered
},
{
path: '/journal',
name: 'Journal',
component: Journal
},
{
path: '/legal/privacy-policy',
name: 'PrivacyPolicy',
component: PrivacyPolicy
},
{
path: '/legal/terms-of-service',
name: 'TermsOfService',
component: TermsOfService
},
{
path: '/user/log-on',
name: 'LogOn',
component: LogOn
}
] ]
}) })

View File

@@ -34,6 +34,7 @@ export default new Vuex.Store({
state: { state: {
user: JSON.parse(localStorage.getItem('user_profile') || '{}'), user: JSON.parse(localStorage.getItem('user_profile') || '{}'),
isAuthenticated: (() => { isAuthenticated: (() => {
this.auth0.scheduleRenewal()
if (this.auth0.isAuthenticated()) { if (this.auth0.isAuthenticated()) {
api.setBearer(localStorage.getItem('id_token')) api.setBearer(localStorage.getItem('id_token'))
} }

View File

@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.auth0.com/js/auth0/8.9/auth0.min.js"></script>
<script>
var webAuth = new auth0.WebAuth({
domain: 'djs-consulting.auth0.com',
clientID: 'Of2s0RQCQ3mt3dwIkOBY5h85J9sXbF2n',
scope: 'openid profile email',
responseType: 'token id_token',
redirectUri: location.protocol + '//' + location.host + '/static/silent.html'
})
</script>
<script>
webAuth.parseHash(window.location.hash, function (err, response) {
parent.postMessage(err || response, location.protocol + '//' + location.host);
})
</script>
</head>
<body></body>
</html>

File diff suppressed because it is too large Load Diff