Compare commits
59 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee9326d7a5 | ||
|
|
2c34650ceb | ||
|
|
9f1e258180 | ||
|
|
0c21e6c1c0 | ||
|
|
a6144f67ec | ||
|
|
e351fe5b56 | ||
|
|
d3aff4a110 | ||
|
|
c0dd6b5dd6 | ||
|
|
5bba499251 | ||
|
|
96f2f2f7e0 | ||
|
|
2bf3bc4865 | ||
|
|
95175d2c57 | ||
|
|
3f71d75a99 | ||
|
|
8becb8cea4 | ||
|
|
d1fd5f68e7 | ||
|
|
d0ea7cf3c6 | ||
|
|
05990d537a | ||
|
|
67cdd5a9b0 | ||
|
|
650bda6bc5 | ||
|
|
6424cde1b6 | ||
|
|
d429d6c9ac | ||
|
|
91daa387cb | ||
|
|
d57e2e863a | ||
|
|
9de713fc6a | ||
|
|
79ced40470 | ||
|
|
bad430fc37 | ||
|
|
d5a783304e | ||
|
|
a429a2d6c9 | ||
|
|
2b6f7c63d0 | ||
|
|
419c181eff | ||
|
|
9637b38a3f | ||
|
|
59b5574b16 | ||
|
|
b248f7ca7f | ||
|
|
8d84bdb2e6 | ||
|
|
b7406bd827 | ||
|
|
d92ac4430e | ||
|
|
0cde2fb6db | ||
|
|
943492f175 | ||
|
|
df76385d6a | ||
|
|
8c801ea49f | ||
|
|
0807aa300a | ||
|
|
8d8d112fff | ||
|
|
6c4061e07d | ||
|
|
9cdb505bb1 | ||
|
|
40d765fb92 | ||
|
|
56dee71377 | ||
|
|
3c3f0a7981 | ||
|
|
a1ce40ee83 | ||
|
|
b8f1708012 | ||
|
|
69811cbf54 | ||
|
|
b6d72d691b | ||
|
|
6f49a61822 | ||
|
|
4db6d98011 | ||
|
|
3acec3dc25 | ||
|
|
8055c34f7c | ||
|
|
e0d27a708d | ||
|
|
834eaf2416 | ||
|
|
ef88964cd0 | ||
|
|
1e1afa9d89 |
10
.gitignore
vendored
10
.gitignore
vendored
@@ -253,7 +253,9 @@ paket-files/
|
||||
*.sln.iml
|
||||
|
||||
# Compiled files / application
|
||||
src/api/public/index.html
|
||||
src/api/public/static
|
||||
src/api/appsettings.json
|
||||
build/
|
||||
src/api/build
|
||||
src/api/MyPrayerJournal.Api/wwwroot/index.html
|
||||
src/api/MyPrayerJournal.Api/wwwroot/static
|
||||
src/api/MyPrayerJournal.Api/appsettings.development.json
|
||||
/build
|
||||
src/*.exe
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
# 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")_.
|
||||
|
||||
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 [Daniel](https://github.com/danieljsummers) had to have something that would help him with his 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). It will eventually be hosted at <https://prayerjournal.me>, and will be available for public use.
|
||||
## Futher Reading
|
||||
|
||||
The documentation for the site is at <https://bit-badger.github.io/myPrayerJournal/>.
|
||||
|
||||
@@ -1,34 +1,55 @@
|
||||
# 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
|
||||
|
||||
# Finding the Site
|
||||
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 [Daniel](https://github.com/danieljsummers) had to have something that would help him with his 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
|
||||
|
||||
The application is at <https://prayerjournal.me>.
|
||||
|
||||
# Signing Up
|
||||
## Signing Up
|
||||
|
||||
myPrayerJournal uses login services using Google or Microsoft accounts. The only information the application stores in its database is your user Id token it receives from these services, so there are no permissions you should have to accept from these provider other than establishing that you can log on with that account. Because of this, you'll want to pick the same one each time; the tokens between the two accounts are different, even if you use the same e-mail address to log on to both.
|
||||
|
||||
# Adding a Request
|
||||
## Your Prayer Journal
|
||||
|
||||
To add a request, click the "Add a New Request" button in your "Journal". Then, enter the text of the request as you see fit; there is no right or wrong way, and you are the only person who will see the text you enter. When you save the request, it will go to the bottom of the list of requests.
|
||||
Your current requests will be presented in columns (usually three, but it could be more or less, 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.
|
||||
|
||||
# Praying for Requests
|
||||
## Adding a Request
|
||||
|
||||
The first button for each request has a checkmark icon; clicking this button will mark the request as "Prayed" and move it to the bottom of the list. This allows you, if you're praying through your requests, to start at the top (with the request that it's been the longest since you've prayed) and click the button as you pray; when the request goes to the bottom of the list, the next will move up to the top.
|
||||
To add a request, click the "Add a New Request" button at the top of your journal. Then, enter the text of the request as you see fit; there is no right or wrong way, and you are the only person who will see the text you enter. When you save the request, it will go to the bottom of the list of requests.
|
||||
|
||||
# Editing Requests
|
||||
## Setting Request Recurrence
|
||||
|
||||
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. _(There is currently no way to see answered requests once they have been answered; this functionality is planned soon.)_
|
||||
When you add or update a request, you can choose whether requests go to the bottom of the journal once they have been marked "Prayed" or whether they will reappear after a delay. You can set recurrence in terms of hours, days, or weeks, but it cannot be longer than 365 days. If you decide you want a request to reappear sooner, you can skip the current delay; click the "Active" menu link, find the request in the list (likely near the bottom), and click the "Show Now" button.
|
||||
|
||||
# Viewing a Request and Its History
|
||||
## Praying for Requests
|
||||
|
||||
myPrayerJournal tracks all of the actions related to a request; the third button, with the document icon, will show you the entire history, including the text as it changed, and all the times "Prayed" was recorded.
|
||||
The first button for each request has a checkmark icon; clicking this button will mark the request as "Prayed" and move it to the bottom of the list (or off, if you've set a recurrence period for the request). This allows you, if you're praying through your requests, to start at the top left (with the request that it's been the longest since you've prayed) and click the button as you pray; when the request move below or away, the next-least-recently-prayed request will take the top spot.
|
||||
|
||||
# Known Issues
|
||||
## Editing Requests
|
||||
|
||||
See [the GitHub issues list](https://github.com/danieljsummers/myPrayerJournal/issues) for the most up-to-date 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.
|
||||
|
||||
- _There is no way to view "Answered" requests; the absence of this functionality is a big reason this is still considered alpha. Going back through requests to see how God has answered them is an encouraging benefit of taking the time to journal._
|
||||
- _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._
|
||||
## Adding Notes
|
||||
|
||||
The third button for each request has an icon that looks like a speech bubble with lines on it; 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.
|
||||
|
||||
## Snoozing Requests
|
||||
|
||||
There may be a time where a request does not need to appear. The fourth button, with the clock icon, allows you to snooze requests until the day you specify. Additionally, if you have any snoozed requests, a "Snoozed" menu item will appear next to the "Journal" one; this page allows you to see what requests are snoozed, and return them to your journal by canceling the snooze.
|
||||
|
||||
## Viewing a Request and Its History
|
||||
|
||||
myPrayerJournal tracks all of the actions related to a request; from the "Active" and "Answered" menu links (and "Snoozed", if it's showing), there is a "View Full Request" button. That page will show the current text of the request; how many times it has been marked as prayed; how long it has been an active request; and a log of all updates, prayers, and notes you have recorded. That log is 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.
|
||||
|
||||
The "Active" link will show all requests that have not yet been marked answered, including snoozed and recurring requests. If requests are snoozed, or in a recurrence period off the journal, there will be a button where you can return the request to the list (either "Cancel Snooze" or "Show Now"). The "Answered" link shows all requests that have been marked answered. The "Snoozed" link just shows snoozed requests.
|
||||
|
||||
## Final Notes
|
||||
|
||||
- myPrayerJournal is nearing the end of its public beta, approaching its first official release. If you encounter errors, please [file an issue on GitHub](https://github.com/bit-badger/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.
|
||||
- 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.
|
||||
|
||||
283
src/api/MyPrayerJournal.Api/Data.fs
Normal file
283
src/api/MyPrayerJournal.Api/Data.fs
Normal file
@@ -0,0 +1,283 @@
|
||||
namespace MyPrayerJournal
|
||||
|
||||
open FSharp.Control.Tasks.ContextInsensitive
|
||||
open Microsoft.EntityFrameworkCore
|
||||
|
||||
/// Helpers for this file
|
||||
[<AutoOpen>]
|
||||
module private Helpers =
|
||||
|
||||
/// Convert any item to an option (Option.ofObj does not work for non-nullable types)
|
||||
let toOption<'T> (x : 'T) = match box x with null -> None | _ -> Some x
|
||||
|
||||
|
||||
/// Entities for use in the data model for myPrayerJournal
|
||||
[<AutoOpen>]
|
||||
module Entities =
|
||||
|
||||
open FSharp.EFCore.OptionConverter
|
||||
open System.Collections.Generic
|
||||
|
||||
/// Type alias for a Collision-resistant Unique IDentifier
|
||||
type Cuid = string
|
||||
|
||||
/// Request ID is a CUID
|
||||
type RequestId = Cuid
|
||||
|
||||
/// User ID is a string (the "sub" part of the JWT)
|
||||
type UserId = string
|
||||
|
||||
/// History is a record of action taken on a prayer request, including updates to its text
|
||||
type [<CLIMutable; NoComparison; NoEquality>] History =
|
||||
{ /// The ID of the request to which this history entry applies
|
||||
requestId : RequestId
|
||||
/// The time when this history entry was made
|
||||
asOf : int64
|
||||
/// The status for this history entry
|
||||
status : string
|
||||
/// The text of the update, if applicable
|
||||
text : string option
|
||||
}
|
||||
with
|
||||
/// An empty history entry
|
||||
static member empty =
|
||||
{ requestId = ""
|
||||
asOf = 0L
|
||||
status = ""
|
||||
text = None
|
||||
}
|
||||
|
||||
static member configureEF (mb : ModelBuilder) =
|
||||
mb.Entity<History> (
|
||||
fun m ->
|
||||
m.ToTable "history" |> ignore
|
||||
m.HasKey ("requestId", "asOf") |> ignore
|
||||
m.Property(fun e -> e.requestId).IsRequired () |> ignore
|
||||
m.Property(fun e -> e.asOf).IsRequired () |> ignore
|
||||
m.Property(fun e -> e.status).IsRequired() |> ignore
|
||||
m.Property(fun e -> e.text) |> ignore)
|
||||
|> ignore
|
||||
let typ = mb.Model.FindEntityType(typeof<History>)
|
||||
let prop = typ.FindProperty("text")
|
||||
mb.Model.FindEntityType(typeof<History>).FindProperty("text").SetValueConverter (OptionConverter<string> ())
|
||||
|
||||
/// Note is a note regarding a prayer request that does not result in an update to its text
|
||||
and [<CLIMutable; NoComparison; NoEquality>] Note =
|
||||
{ /// The ID of the request to which this note applies
|
||||
requestId : RequestId
|
||||
/// The time when this note was made
|
||||
asOf : int64
|
||||
/// The text of the notes
|
||||
notes : string
|
||||
}
|
||||
with
|
||||
/// An empty note
|
||||
static member empty =
|
||||
{ requestId = ""
|
||||
asOf = 0L
|
||||
notes = ""
|
||||
}
|
||||
|
||||
static member configureEF (mb : ModelBuilder) =
|
||||
mb.Entity<Note> (
|
||||
fun m ->
|
||||
m.ToTable "note" |> ignore
|
||||
m.HasKey ("requestId", "asOf") |> ignore
|
||||
m.Property(fun e -> e.requestId).IsRequired () |> ignore
|
||||
m.Property(fun e -> e.asOf).IsRequired () |> ignore
|
||||
m.Property(fun e -> e.notes).IsRequired () |> ignore)
|
||||
|> ignore
|
||||
|
||||
/// Request is the identifying record for a prayer request
|
||||
and [<CLIMutable; NoComparison; NoEquality>] Request =
|
||||
{ /// The ID of the request
|
||||
requestId : RequestId
|
||||
/// The time this request was initially entered
|
||||
enteredOn : int64
|
||||
/// The ID of the user to whom this request belongs ("sub" from the JWT)
|
||||
userId : string
|
||||
/// The time at which this request should reappear in the user's journal by manual user choice
|
||||
snoozedUntil : int64
|
||||
/// The time at which this request should reappear in the user's journal by recurrence
|
||||
showAfter : int64
|
||||
/// The type of recurrence for this request
|
||||
recurType : string
|
||||
/// How many of the recurrence intervals should occur between appearances in the journal
|
||||
recurCount : int16
|
||||
/// The history entries for this request
|
||||
history : ICollection<History>
|
||||
/// The notes for this request
|
||||
notes : ICollection<Note>
|
||||
}
|
||||
with
|
||||
/// An empty request
|
||||
static member empty =
|
||||
{ requestId = ""
|
||||
enteredOn = 0L
|
||||
userId = ""
|
||||
snoozedUntil = 0L
|
||||
showAfter = 0L
|
||||
recurType = "immediate"
|
||||
recurCount = 0s
|
||||
history = List<History> ()
|
||||
notes = List<Note> ()
|
||||
}
|
||||
|
||||
static member configureEF (mb : ModelBuilder) =
|
||||
mb.Entity<Request> (
|
||||
fun m ->
|
||||
m.ToTable "request" |> ignore
|
||||
m.HasKey(fun e -> e.requestId :> obj) |> ignore
|
||||
m.Property(fun e -> e.requestId).IsRequired () |> ignore
|
||||
m.Property(fun e -> e.enteredOn).IsRequired () |> ignore
|
||||
m.Property(fun e -> e.userId).IsRequired () |> ignore
|
||||
m.Property(fun e -> e.snoozedUntil).IsRequired () |> ignore
|
||||
m.Property(fun e -> e.showAfter).IsRequired () |> ignore
|
||||
m.Property(fun e -> e.recurType).IsRequired() |> ignore
|
||||
m.Property(fun e -> e.recurCount).IsRequired() |> ignore
|
||||
m.HasMany(fun e -> e.history :> IEnumerable<History>)
|
||||
.WithOne()
|
||||
.HasForeignKey(fun e -> e.requestId :> obj)
|
||||
|> ignore
|
||||
m.HasMany(fun e -> e.notes :> IEnumerable<Note>)
|
||||
.WithOne()
|
||||
.HasForeignKey(fun e -> e.requestId :> obj)
|
||||
|> ignore)
|
||||
|> ignore
|
||||
|
||||
/// JournalRequest is the form of a prayer request returned for the request journal display. It also contains
|
||||
/// properties that may be filled for history and notes
|
||||
[<CLIMutable; NoComparison; NoEquality>]
|
||||
type JournalRequest =
|
||||
{ /// The ID of the request
|
||||
requestId : RequestId
|
||||
/// The ID of the user to whom the request belongs
|
||||
userId : string
|
||||
/// The current text of the request
|
||||
text : string
|
||||
/// The last time action was taken on the request
|
||||
asOf : int64
|
||||
/// The last status for the request
|
||||
lastStatus : string
|
||||
/// The time that this request should reappear in the user's journal
|
||||
snoozedUntil : int64
|
||||
/// The time after which this request should reappear in the user's journal by configured recurrence
|
||||
showAfter : int64
|
||||
/// The type of recurrence for this request
|
||||
recurType : string
|
||||
/// How many of the recurrence intervals should occur between appearances in the journal
|
||||
recurCount : int16
|
||||
/// History entries for the request
|
||||
history : History list
|
||||
/// Note entries for the request
|
||||
notes : Note list
|
||||
}
|
||||
with
|
||||
static member configureEF (mb : ModelBuilder) =
|
||||
mb.Query<JournalRequest> (
|
||||
fun m ->
|
||||
m.ToView "journal" |> ignore
|
||||
m.Ignore(fun e -> e.history :> obj) |> ignore
|
||||
m.Ignore(fun e -> e.notes :> obj) |> ignore)
|
||||
|> ignore
|
||||
|
||||
|
||||
open System.Linq
|
||||
open System.Threading.Tasks
|
||||
|
||||
/// Data context
|
||||
type AppDbContext (opts : DbContextOptions<AppDbContext>) =
|
||||
inherit DbContext (opts)
|
||||
|
||||
[<DefaultValue>]
|
||||
val mutable private history : DbSet<History>
|
||||
[<DefaultValue>]
|
||||
val mutable private notes : DbSet<Note>
|
||||
[<DefaultValue>]
|
||||
val mutable private requests : DbSet<Request>
|
||||
[<DefaultValue>]
|
||||
val mutable private journal : DbQuery<JournalRequest>
|
||||
|
||||
member this.History
|
||||
with get () = this.history
|
||||
and set v = this.history <- v
|
||||
member this.Notes
|
||||
with get () = this.notes
|
||||
and set v = this.notes <- v
|
||||
member this.Requests
|
||||
with get () = this.requests
|
||||
and set v = this.requests <- v
|
||||
member this.Journal
|
||||
with get () = this.journal
|
||||
and set v = this.journal <- v
|
||||
|
||||
override __.OnModelCreating (mb : ModelBuilder) =
|
||||
base.OnModelCreating mb
|
||||
[ History.configureEF
|
||||
Note.configureEF
|
||||
Request.configureEF
|
||||
JournalRequest.configureEF
|
||||
]
|
||||
|> List.iter (fun x -> x mb)
|
||||
|
||||
/// Register a disconnected entity with the context, having the given state
|
||||
member private this.RegisterAs<'TEntity when 'TEntity : not struct> state e =
|
||||
this.Entry<'TEntity>(e).State <- state
|
||||
|
||||
/// Add an entity instance to the context
|
||||
member this.AddEntry e =
|
||||
this.RegisterAs EntityState.Added e
|
||||
|
||||
/// Update the entity instance's values
|
||||
member this.UpdateEntry e =
|
||||
this.RegisterAs EntityState.Modified e
|
||||
|
||||
/// Retrieve all answered requests for the given user
|
||||
member this.AnsweredRequests userId : JournalRequest seq =
|
||||
upcast this.Journal
|
||||
.Where(fun r -> r.userId = userId && r.lastStatus = "Answered")
|
||||
.OrderByDescending(fun r -> r.asOf)
|
||||
|
||||
/// Retrieve the user's current journal
|
||||
member this.JournalByUserId userId : JournalRequest seq =
|
||||
upcast this.Journal
|
||||
.Where(fun r -> r.userId = userId && r.lastStatus <> "Answered")
|
||||
.OrderBy(fun r -> r.asOf)
|
||||
|
||||
/// Retrieve a request by its ID and user ID
|
||||
member this.TryRequestById reqId userId =
|
||||
task {
|
||||
let! req = this.Requests.AsNoTracking().FirstOrDefaultAsync(fun r -> r.requestId = reqId && r.userId = userId)
|
||||
return toOption req
|
||||
}
|
||||
|
||||
/// Retrieve notes for a request by its ID and user ID
|
||||
member this.NotesById reqId userId =
|
||||
task {
|
||||
match! this.TryRequestById reqId userId with
|
||||
| Some _ -> return this.Notes.AsNoTracking().Where(fun n -> n.requestId = reqId) |> List.ofSeq
|
||||
| None -> return []
|
||||
}
|
||||
|
||||
/// Retrieve a journal request by its ID and user ID
|
||||
member this.TryJournalById reqId userId =
|
||||
task {
|
||||
let! req = this.Journal.FirstOrDefaultAsync(fun r -> r.requestId = reqId && r.userId = userId)
|
||||
return toOption req
|
||||
}
|
||||
|
||||
/// Retrieve a request, including its history and notes, by its ID and user ID
|
||||
member this.TryFullRequestById requestId userId =
|
||||
task {
|
||||
match! this.TryJournalById requestId userId with
|
||||
| Some req ->
|
||||
let! fullReq =
|
||||
this.Requests.AsNoTracking()
|
||||
.Include(fun r -> r.history)
|
||||
.Include(fun r -> r.notes)
|
||||
.FirstOrDefaultAsync(fun r -> r.requestId = requestId && r.userId = userId)
|
||||
match toOption fullReq with
|
||||
| Some _ -> return Some { req with history = List.ofSeq fullReq.history; notes = List.ofSeq fullReq.notes }
|
||||
| None -> return None
|
||||
| None -> return None
|
||||
}
|
||||
320
src/api/MyPrayerJournal.Api/Handlers.fs
Normal file
320
src/api/MyPrayerJournal.Api/Handlers.fs
Normal file
@@ -0,0 +1,320 @@
|
||||
/// HTTP handlers for the myPrayerJournal API
|
||||
[<RequireQualifiedAccess>]
|
||||
module MyPrayerJournal.Api.Handlers
|
||||
|
||||
open Giraffe
|
||||
open MyPrayerJournal
|
||||
open System
|
||||
|
||||
/// Handler to return Vue files
|
||||
module Vue =
|
||||
|
||||
/// The application index page
|
||||
let app : HttpHandler = htmlFile "wwwroot/index.html"
|
||||
|
||||
|
||||
/// Handlers for error conditions
|
||||
module Error =
|
||||
|
||||
open Microsoft.Extensions.Logging
|
||||
|
||||
/// Handle errors
|
||||
let error (ex : Exception) (log : ILogger) =
|
||||
log.LogError (EventId(), ex, "An unhandled exception has occurred while executing the request.")
|
||||
clearResponse >=> setStatusCode 500 >=> json ex.Message
|
||||
|
||||
/// Handle 404s from the API, sending known URL paths to the Vue app so that they can be handled there
|
||||
let notFound : HttpHandler =
|
||||
fun next ctx ->
|
||||
[ "/journal"; "/legal"; "/request"; "/user" ]
|
||||
|> List.filter ctx.Request.Path.Value.StartsWith
|
||||
|> List.length
|
||||
|> function
|
||||
| 0 -> (setStatusCode 404 >=> json ([ "error", "not found" ] |> dict)) next ctx
|
||||
| _ -> Vue.app next ctx
|
||||
|
||||
|
||||
/// Handler helpers
|
||||
[<AutoOpen>]
|
||||
module private Helpers =
|
||||
|
||||
open Microsoft.AspNetCore.Http
|
||||
open System.Threading.Tasks
|
||||
open System.Security.Claims
|
||||
|
||||
/// Get the database context from DI
|
||||
let db (ctx : HttpContext) =
|
||||
ctx.GetService<AppDbContext> ()
|
||||
|
||||
/// Get the user's "sub" claim
|
||||
let user (ctx : HttpContext) =
|
||||
ctx.User.Claims |> Seq.tryFind (fun u -> u.Type = ClaimTypes.NameIdentifier)
|
||||
|
||||
/// Get the current user's ID
|
||||
// NOTE: this may raise if you don't run the request through the authorize handler first
|
||||
let userId ctx =
|
||||
((user >> Option.get) ctx).Value
|
||||
|
||||
/// Return a 201 CREATED response
|
||||
let created next ctx =
|
||||
setStatusCode 201 next ctx
|
||||
|
||||
/// The "now" time in JavaScript
|
||||
let jsNow () =
|
||||
DateTime.UtcNow.Subtract(DateTime (1970, 1, 1, 0, 0, 0)).TotalSeconds |> int64 |> (*) 1000L
|
||||
|
||||
/// Handler to return a 403 Not Authorized reponse
|
||||
let notAuthorized : HttpHandler =
|
||||
setStatusCode 403 >=> fun _ _ -> Task.FromResult<HttpContext option> None
|
||||
|
||||
/// Handler to require authorization
|
||||
let authorize : HttpHandler =
|
||||
fun next ctx -> match user ctx with Some _ -> next ctx | None -> notAuthorized next ctx
|
||||
|
||||
/// Flip JSON result so we can pipe into it
|
||||
let asJson<'T> next ctx (o : 'T) =
|
||||
json o next ctx
|
||||
|
||||
|
||||
/// Strongly-typed models for post requests
|
||||
module Models =
|
||||
|
||||
/// A history entry addition (AKA request update)
|
||||
[<CLIMutable>]
|
||||
type HistoryEntry =
|
||||
{ /// The status of the history update
|
||||
status : string
|
||||
/// The text of the update
|
||||
updateText : string
|
||||
}
|
||||
|
||||
/// An additional note
|
||||
[<CLIMutable>]
|
||||
type NoteEntry =
|
||||
{ /// The notes being added
|
||||
notes : string
|
||||
}
|
||||
|
||||
/// Recurrence update
|
||||
[<CLIMutable>]
|
||||
type Recurrence =
|
||||
{ /// The recurrence type
|
||||
recurType : string
|
||||
/// The recurrence cound
|
||||
recurCount : int16
|
||||
}
|
||||
|
||||
/// A prayer request
|
||||
[<CLIMutable>]
|
||||
type Request =
|
||||
{ /// The text of the request
|
||||
requestText : string
|
||||
/// The recurrence type
|
||||
recurType : string
|
||||
/// The recurrence count
|
||||
recurCount : int16
|
||||
}
|
||||
|
||||
/// Reset the "showAfter" property on a request
|
||||
[<CLIMutable>]
|
||||
type Show =
|
||||
{ /// The time after which the request should appear
|
||||
showAfter : int64
|
||||
}
|
||||
|
||||
/// The time until which a request should not appear in the journal
|
||||
[<CLIMutable>]
|
||||
type SnoozeUntil =
|
||||
{ /// The time at which the request should reappear
|
||||
until : int64
|
||||
}
|
||||
|
||||
|
||||
/// /api/journal URLs
|
||||
module Journal =
|
||||
|
||||
/// GET /api/journal
|
||||
let journal : HttpHandler =
|
||||
authorize
|
||||
>=> fun next ctx ->
|
||||
userId ctx
|
||||
|> (db ctx).JournalByUserId
|
||||
|> asJson next ctx
|
||||
|
||||
|
||||
/// /api/request URLs
|
||||
module Request =
|
||||
|
||||
open NCuid
|
||||
|
||||
/// Ticks per recurrence
|
||||
let private recurrence =
|
||||
[ "immediate", 0L
|
||||
"hours", 3600000L
|
||||
"days", 86400000L
|
||||
"weeks", 604800000L
|
||||
]
|
||||
|> Map.ofList
|
||||
|
||||
/// POST /api/request
|
||||
let add : HttpHandler =
|
||||
authorize
|
||||
>=> fun next ctx ->
|
||||
task {
|
||||
let! r = ctx.BindJsonAsync<Models.Request> ()
|
||||
let db = db ctx
|
||||
let reqId = Cuid.Generate ()
|
||||
let usrId = userId ctx
|
||||
let now = jsNow ()
|
||||
{ Request.empty with
|
||||
requestId = reqId
|
||||
userId = usrId
|
||||
enteredOn = now
|
||||
showAfter = now
|
||||
recurType = r.recurType
|
||||
recurCount = r.recurCount
|
||||
}
|
||||
|> db.AddEntry
|
||||
{ History.empty with
|
||||
requestId = reqId
|
||||
asOf = now
|
||||
status = "Created"
|
||||
text = Some r.requestText
|
||||
}
|
||||
|> db.AddEntry
|
||||
let! _ = db.SaveChangesAsync ()
|
||||
match! db.TryJournalById reqId usrId with
|
||||
| Some req -> return! (setStatusCode 201 >=> json req) next ctx
|
||||
| None -> return! Error.notFound next ctx
|
||||
}
|
||||
|
||||
/// POST /api/request/[req-id]/history
|
||||
let addHistory reqId : HttpHandler =
|
||||
authorize
|
||||
>=> fun next ctx ->
|
||||
task {
|
||||
let db = db ctx
|
||||
match! db.TryRequestById reqId (userId ctx) with
|
||||
| Some req ->
|
||||
let! hist = ctx.BindJsonAsync<Models.HistoryEntry> ()
|
||||
let now = jsNow ()
|
||||
{ History.empty with
|
||||
requestId = reqId
|
||||
asOf = now
|
||||
status = hist.status
|
||||
text = match hist.updateText with null | "" -> None | x -> Some x
|
||||
}
|
||||
|> db.AddEntry
|
||||
match hist.status with
|
||||
| "Prayed" ->
|
||||
db.UpdateEntry { req with showAfter = now + (recurrence.[req.recurType] * int64 req.recurCount) }
|
||||
| _ -> ()
|
||||
let! _ = db.SaveChangesAsync ()
|
||||
return! created next ctx
|
||||
| None -> return! Error.notFound next ctx
|
||||
}
|
||||
|
||||
/// POST /api/request/[req-id]/note
|
||||
let addNote reqId : HttpHandler =
|
||||
authorize
|
||||
>=> fun next ctx ->
|
||||
task {
|
||||
let db = db ctx
|
||||
match! db.TryRequestById reqId (userId ctx) with
|
||||
| Some _ ->
|
||||
let! notes = ctx.BindJsonAsync<Models.NoteEntry> ()
|
||||
{ Note.empty with
|
||||
requestId = reqId
|
||||
asOf = jsNow ()
|
||||
notes = notes.notes
|
||||
}
|
||||
|> db.AddEntry
|
||||
let! _ = db.SaveChangesAsync ()
|
||||
return! created next ctx
|
||||
| None -> return! Error.notFound next ctx
|
||||
}
|
||||
|
||||
/// GET /api/requests/answered
|
||||
let answered : HttpHandler =
|
||||
authorize
|
||||
>=> fun next ctx ->
|
||||
userId ctx
|
||||
|> (db ctx).AnsweredRequests
|
||||
|> asJson next ctx
|
||||
|
||||
/// GET /api/request/[req-id]
|
||||
let get reqId : HttpHandler =
|
||||
authorize
|
||||
>=> fun next ctx ->
|
||||
task {
|
||||
match! (db ctx).TryJournalById reqId (userId ctx) with
|
||||
| Some req -> return! json req next ctx
|
||||
| None -> return! Error.notFound next ctx
|
||||
}
|
||||
|
||||
/// GET /api/request/[req-id]/full
|
||||
let getFull reqId : HttpHandler =
|
||||
authorize
|
||||
>=> fun next ctx ->
|
||||
task {
|
||||
match! (db ctx).TryFullRequestById reqId (userId ctx) with
|
||||
| Some req -> return! json req next ctx
|
||||
| None -> return! Error.notFound next ctx
|
||||
}
|
||||
|
||||
/// GET /api/request/[req-id]/notes
|
||||
let getNotes reqId : HttpHandler =
|
||||
authorize
|
||||
>=> fun next ctx ->
|
||||
task {
|
||||
let! notes = (db ctx).NotesById reqId (userId ctx)
|
||||
return! json notes next ctx
|
||||
}
|
||||
|
||||
/// PATCH /api/request/[req-id]/show
|
||||
let show reqId : HttpHandler =
|
||||
authorize
|
||||
>=> fun next ctx ->
|
||||
task {
|
||||
let db = db ctx
|
||||
match! db.TryRequestById reqId (userId ctx) with
|
||||
| Some req ->
|
||||
let! show = ctx.BindJsonAsync<Models.Show> ()
|
||||
{ req with showAfter = show.showAfter }
|
||||
|> db.UpdateEntry
|
||||
let! _ = db.SaveChangesAsync ()
|
||||
return! setStatusCode 204 next ctx
|
||||
| None -> return! Error.notFound next ctx
|
||||
}
|
||||
|
||||
/// PATCH /api/request/[req-id]/snooze
|
||||
let snooze reqId : HttpHandler =
|
||||
authorize
|
||||
>=> fun next ctx ->
|
||||
task {
|
||||
let db = db ctx
|
||||
match! db.TryRequestById reqId (userId ctx) with
|
||||
| Some req ->
|
||||
let! until = ctx.BindJsonAsync<Models.SnoozeUntil> ()
|
||||
{ req with snoozedUntil = until.until; showAfter = until.until }
|
||||
|> db.UpdateEntry
|
||||
let! _ = db.SaveChangesAsync ()
|
||||
return! setStatusCode 204 next ctx
|
||||
| None -> return! Error.notFound next ctx
|
||||
}
|
||||
|
||||
/// PATCH /api/request/[req-id]/recurrence
|
||||
let updateRecurrence reqId : HttpHandler =
|
||||
authorize
|
||||
>=> fun next ctx ->
|
||||
task {
|
||||
let db = db ctx
|
||||
match! db.TryRequestById reqId (userId ctx) with
|
||||
| Some req ->
|
||||
let! recur = ctx.BindJsonAsync<Models.Recurrence> ()
|
||||
{ req with recurType = recur.recurType; recurCount = recur.recurCount }
|
||||
|> db.UpdateEntry
|
||||
let! _ = db.SaveChangesAsync ()
|
||||
return! setStatusCode 204 next ctx
|
||||
| None -> return! Error.notFound next ctx
|
||||
}
|
||||
30
src/api/MyPrayerJournal.Api/MyPrayerJournal.Api.fsproj
Normal file
30
src/api/MyPrayerJournal.Api/MyPrayerJournal.Api.fsproj
Normal file
@@ -0,0 +1,30 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="Data.fs" />
|
||||
<Compile Include="Handlers.fs" />
|
||||
<Compile Include="Program.fs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FSharp.EFCore.OptionConverter" Version="1.0.0" />
|
||||
<PackageReference Include="Giraffe" Version="1.1.0" />
|
||||
<PackageReference Include="Giraffe.TokenRouter" Version="0.1.0-beta-110" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="NCuid.NetCore" Version="1.0.1" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.1.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Update="FSharp.Core" Version="4.5.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="wwwroot\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
127
src/api/MyPrayerJournal.Api/Program.fs
Normal file
127
src/api/MyPrayerJournal.Api/Program.fs
Normal file
@@ -0,0 +1,127 @@
|
||||
namespace MyPrayerJournal.Api
|
||||
|
||||
open Microsoft.AspNetCore.Builder
|
||||
open Microsoft.AspNetCore.Hosting
|
||||
open System
|
||||
|
||||
|
||||
/// Configuration functions for the application
|
||||
module Configure =
|
||||
|
||||
open Giraffe
|
||||
open Giraffe.TokenRouter
|
||||
open Microsoft.AspNetCore.Authentication.JwtBearer
|
||||
open Microsoft.AspNetCore.Server.Kestrel.Core
|
||||
open Microsoft.EntityFrameworkCore
|
||||
open Microsoft.Extensions.Configuration
|
||||
open Microsoft.Extensions.DependencyInjection
|
||||
open Microsoft.Extensions.Logging
|
||||
open MyPrayerJournal
|
||||
|
||||
/// Set up the configuration for the app
|
||||
let configuration (ctx : WebHostBuilderContext) (cfg : IConfigurationBuilder) =
|
||||
cfg.SetBasePath(ctx.HostingEnvironment.ContentRootPath)
|
||||
.AddJsonFile("appsettings.json", optional = true, reloadOnChange = true)
|
||||
.AddJsonFile(sprintf "appsettings.%s.json" ctx.HostingEnvironment.EnvironmentName)
|
||||
.AddEnvironmentVariables()
|
||||
|> ignore
|
||||
|
||||
/// Configure Kestrel from appsettings.json
|
||||
let kestrel (ctx : WebHostBuilderContext) (opts : KestrelServerOptions) =
|
||||
(ctx.Configuration.GetSection >> opts.Configure >> ignore) "Kestrel"
|
||||
|
||||
/// Configure dependency injection
|
||||
let services (sc : IServiceCollection) =
|
||||
use sp = sc.BuildServiceProvider()
|
||||
let cfg = sp.GetRequiredService<IConfiguration> ()
|
||||
sc.AddGiraffe()
|
||||
.AddAuthentication(
|
||||
/// Use HTTP "Bearer" authentication with JWTs
|
||||
fun opts ->
|
||||
opts.DefaultAuthenticateScheme <- JwtBearerDefaults.AuthenticationScheme
|
||||
opts.DefaultChallengeScheme <- JwtBearerDefaults.AuthenticationScheme)
|
||||
.AddJwtBearer(
|
||||
/// Configure JWT options with Auth0 options from configuration
|
||||
fun opts ->
|
||||
let jwtCfg = cfg.GetSection "Auth0"
|
||||
opts.Authority <- sprintf "https://%s/" jwtCfg.["Domain"]
|
||||
opts.Audience <- jwtCfg.["Id"])
|
||||
|> ignore
|
||||
sc.AddDbContext<AppDbContext>(fun opts -> opts.UseNpgsql(cfg.GetConnectionString "mpj") |> ignore)
|
||||
|> ignore
|
||||
|
||||
/// Routes for the available URLs within myPrayerJournal
|
||||
let webApp =
|
||||
router Handlers.Error.notFound [
|
||||
route "/" Handlers.Vue.app
|
||||
subRoute "/api/" [
|
||||
GET [
|
||||
route "journal" Handlers.Journal.journal
|
||||
subRoute "request" [
|
||||
route "s/answered" Handlers.Request.answered
|
||||
routef "/%s/full" Handlers.Request.getFull
|
||||
routef "/%s/notes" Handlers.Request.getNotes
|
||||
routef "/%s" Handlers.Request.get
|
||||
]
|
||||
]
|
||||
PATCH [
|
||||
subRoute "request" [
|
||||
routef "/%s/recurrence" Handlers.Request.updateRecurrence
|
||||
routef "/%s/show" Handlers.Request.show
|
||||
routef "/%s/snooze" Handlers.Request.snooze
|
||||
]
|
||||
]
|
||||
POST [
|
||||
subRoute "request" [
|
||||
route "" Handlers.Request.add
|
||||
routef "/%s/history" Handlers.Request.addHistory
|
||||
routef "/%s/note" Handlers.Request.addNote
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
/// Configure the web application
|
||||
let application (app : IApplicationBuilder) =
|
||||
let env = app.ApplicationServices.GetService<IHostingEnvironment> ()
|
||||
match env.IsDevelopment () with
|
||||
| true -> app.UseDeveloperExceptionPage ()
|
||||
| false -> app.UseGiraffeErrorHandler Handlers.Error.error
|
||||
|> function
|
||||
| a ->
|
||||
a.UseAuthentication()
|
||||
.UseStaticFiles()
|
||||
.UseGiraffe webApp
|
||||
|> ignore
|
||||
|
||||
/// Configure logging
|
||||
let logging (log : ILoggingBuilder) =
|
||||
let env = log.Services.BuildServiceProvider().GetService<IHostingEnvironment> ()
|
||||
match env.IsDevelopment () with
|
||||
| true -> log
|
||||
| false -> log.AddFilter(fun l -> l > LogLevel.Information)
|
||||
|> function l -> l.AddConsole().AddDebug()
|
||||
|> ignore
|
||||
|
||||
|
||||
module Program =
|
||||
|
||||
open System.IO
|
||||
|
||||
let exitCode = 0
|
||||
|
||||
let CreateWebHostBuilder _ =
|
||||
let contentRoot = Directory.GetCurrentDirectory ()
|
||||
WebHostBuilder()
|
||||
.UseContentRoot(contentRoot)
|
||||
.ConfigureAppConfiguration(Configure.configuration)
|
||||
.UseKestrel(Configure.kestrel)
|
||||
.UseWebRoot(Path.Combine (contentRoot, "wwwroot"))
|
||||
.ConfigureServices(Configure.services)
|
||||
.ConfigureLogging(Configure.logging)
|
||||
.Configure(Action<IApplicationBuilder> Configure.application)
|
||||
|
||||
[<EntryPoint>]
|
||||
let main args =
|
||||
CreateWebHostBuilder(args).Build().Run()
|
||||
exitCode
|
||||
27
src/api/MyPrayerJournal.Api/Properties/launchSettings.json
Normal file
27
src/api/MyPrayerJournal.Api/Properties/launchSettings.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:61905",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"MyPrayerJournal.Api": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "http://localhost:5000",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
9
src/api/MyPrayerJournal.Api/appsettings.json
Normal file
9
src/api/MyPrayerJournal.Api/appsettings.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Kestrel": {
|
||||
"EndPoints": {
|
||||
"Http": {
|
||||
"Url": "http://localhost:3000"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
25
src/api/MyPrayerJournal.sln
Normal file
25
src/api/MyPrayerJournal.sln
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27703.2035
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "MyPrayerJournal.Api", "MyPrayerJournal.Api\MyPrayerJournal.Api.fsproj", "{E0E5240C-00DC-428A-899A-DA4F06625B8A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E0E5240C-00DC-428A-899A-DA4F06625B8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E0E5240C-00DC-428A-899A-DA4F06625B8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E0E5240C-00DC-428A-899A-DA4F06625B8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E0E5240C-00DC-428A-899A-DA4F06625B8A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {7EAB6243-94B3-49A5-BA64-7F01B8BE7CB9}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,35 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
const chalk = require('chalk')
|
||||
|
||||
const { env } = require('./appsettings.json') // process.env.NODE_ENV || 'dev'
|
||||
|
||||
if ('dev' === env) require('babel-register')
|
||||
const src = (env === 'dev') ? './src' : './build'
|
||||
|
||||
const app = require(`${src}/index`).default
|
||||
const db = require(`${src}/db`).default
|
||||
|
||||
const fullEnv = ('dev' === env) ? 'Development' : 'Production'
|
||||
|
||||
const { port } = require('./appsettings.json')
|
||||
|
||||
/**
|
||||
* Log a start-up message for the app
|
||||
* @param {string} status The status to display
|
||||
*/
|
||||
const startupMsg = (status) => {
|
||||
console.log(chalk`{reset myPrayerJournal ${status} | Port: {bold ${port}} | Mode: {bold ${fullEnv}}}`)
|
||||
}
|
||||
|
||||
// Ensure the database exists before starting up
|
||||
db.verify()
|
||||
.then(() => app.listen(port, () => startupMsg('ready')))
|
||||
.catch(err => {
|
||||
console.log(chalk`\n{reset {bgRed.white.bold || Error connecting to PostgreSQL }}`)
|
||||
for (let key of Object.keys(err)) {
|
||||
console.log(chalk`${key}: {reset {bold ${err[key]}}}`)
|
||||
}
|
||||
console.log('')
|
||||
startupMsg('failed')
|
||||
})
|
||||
@@ -1,12 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
import fs from 'fs'
|
||||
|
||||
/**
|
||||
* Read and parse a JSON file
|
||||
* @param {string} path The path to the file
|
||||
* @param {string} encoding The encoding of the file (defaults to UTF-8)
|
||||
* @return {*} The parsed contents of the file
|
||||
*/
|
||||
export default (path, encoding = 'utf-8') =>
|
||||
JSON.parse(fs.readFileSync(path, encoding))
|
||||
@@ -1,45 +0,0 @@
|
||||
{
|
||||
"name": "my-prayer-journal-api",
|
||||
"private": true,
|
||||
"version": "0.8.1",
|
||||
"description": "Server API for myPrayerJournal",
|
||||
"main": "index.js",
|
||||
"author": "Daniel J. Summers <daniel@djs-consulting.com>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"chalk": "^2.1.0",
|
||||
"cuid": "^1.3.8",
|
||||
"jwks-rsa-koa": "^1.1.3",
|
||||
"koa": "^2.3.0",
|
||||
"koa-bodyparser": "^4.2.0",
|
||||
"koa-jwt": "^3.2.2",
|
||||
"koa-router": "^7.2.1",
|
||||
"koa-send": "^4.1.0",
|
||||
"koa-static": "^4.0.1",
|
||||
"pg": "^7.3.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node app.js",
|
||||
"build": "babel src -d build",
|
||||
"vue": "cd ../app && node build/build.js prod && cd ../api && node app.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel": "^6.23.0",
|
||||
"babel-cli": "^6.26.0",
|
||||
"babel-preset-env": "^1.6.0",
|
||||
"babel-register": "^6.26.0",
|
||||
"koa-morgan": "^1.0.1"
|
||||
},
|
||||
"babel": {
|
||||
"presets": [
|
||||
[
|
||||
"env",
|
||||
{
|
||||
"targets": {
|
||||
"node": "current"
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
import { Pool } from 'pg'
|
||||
|
||||
/**
|
||||
* SQL to check the existence of a table in the mpj schema
|
||||
* @param {string} table The name of the table whose existence should be checked
|
||||
*/
|
||||
const tableSql = table => `SELECT 1 FROM pg_tables WHERE schemaname='mpj' AND tablename='${table}'`
|
||||
|
||||
/**
|
||||
* SQL to determine if an index exists
|
||||
* @param {string} table The name of the table which the given index indexes
|
||||
* @param {string} index The name of the index
|
||||
*/
|
||||
const indexSql = (table, index) =>
|
||||
`SELECT 1 FROM pg_indexes WHERE schemaname='mpj' AND tablename='${table}' AND indexname='${index}'`
|
||||
|
||||
const ddl = [
|
||||
{
|
||||
name: 'myPrayerJournal Schema',
|
||||
check: `SELECT 1 FROM pg_namespace WHERE nspname='mpj'`,
|
||||
fix: `
|
||||
CREATE SCHEMA mpj;
|
||||
COMMENT ON SCHEMA mpj IS 'myPrayerJournal data'`
|
||||
},
|
||||
{
|
||||
name: 'request Table',
|
||||
check: tableSql('request'),
|
||||
fix: `
|
||||
CREATE TABLE mpj.request (
|
||||
"requestId" varchar(25) PRIMARY KEY,
|
||||
"enteredOn" bigint NOT NULL,
|
||||
"userId" varchar(100) NOT NULL);
|
||||
COMMENT ON TABLE mpj.request IS 'Requests'`
|
||||
},
|
||||
{
|
||||
name: 'history Table',
|
||||
check: tableSql('history'),
|
||||
fix: `
|
||||
CREATE TABLE mpj.history (
|
||||
"requestId" varchar(25) NOT NULL REFERENCES mpj.request,
|
||||
"asOf" bigint NOT NULL,
|
||||
"status" varchar(25),
|
||||
"text" text,
|
||||
PRIMARY KEY ("requestId", "asOf"));
|
||||
COMMENT ON TABLE mpj.history IS 'Request update history'`
|
||||
},
|
||||
{
|
||||
name: 'request.userId Index',
|
||||
check: indexSql('request', 'idx_request_userId'),
|
||||
fix: `
|
||||
CREATE INDEX "idx_request_userId" ON mpj.request ("userId");
|
||||
COMMENT ON INDEX "idx_request_userId" IS 'Requests are retrieved by user'`
|
||||
},
|
||||
{
|
||||
name: 'journal View',
|
||||
check: `SELECT 1 FROM pg_views WHERE schemaname='mpj' AND viewname='journal'`,
|
||||
fix: `
|
||||
CREATE VIEW mpj.journal AS
|
||||
SELECT
|
||||
request."requestId",
|
||||
request."userId",
|
||||
(SELECT "text"
|
||||
FROM mpj.history
|
||||
WHERE history."requestId" = request."requestId"
|
||||
AND "text" IS NOT NULL
|
||||
ORDER BY "asOf" DESC
|
||||
LIMIT 1) AS "text",
|
||||
(SELECT "asOf"
|
||||
FROM mpj.history
|
||||
WHERE history."requestId" = request."requestId"
|
||||
ORDER BY "asOf" DESC
|
||||
LIMIT 1) AS "asOf",
|
||||
(SELECT "status"
|
||||
FROM mpj.history
|
||||
WHERE history."requestId" = request."requestId"
|
||||
ORDER BY "asOf" DESC
|
||||
LIMIT 1) AS "lastStatus"
|
||||
FROM mpj.request;
|
||||
COMMENT ON VIEW mpj.journal IS 'Requests with latest text'`
|
||||
}
|
||||
]
|
||||
|
||||
export default function (query) {
|
||||
return {
|
||||
/**
|
||||
* Ensure that the database schema, tables, and indexes exist
|
||||
*/
|
||||
ensureDatabase: async () => {
|
||||
for (let item of ddl) {
|
||||
const result = await query(item.check, [])
|
||||
if (1 > result.rowCount) await query(item.fix, [])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
import { Pool, types } from 'pg'
|
||||
|
||||
import appConfig from '../../appsettings.json'
|
||||
import ddl from './ddl'
|
||||
import request from './request'
|
||||
|
||||
/** Pooled PostgreSQL instance */
|
||||
const pool = new Pool(appConfig.pgPool)
|
||||
|
||||
// Return "bigint" (int8) instances as number instead of strings
|
||||
// ref: https://github.com/brianc/node-pg-types
|
||||
types.setTypeParser(20, val => parseInt(val))
|
||||
|
||||
/**
|
||||
* Run a SQL query
|
||||
* @param {string} text The SQL command
|
||||
* @param {*[]} params The parameters for the query
|
||||
*/
|
||||
const query = (text, params) => pool.query(text, params)
|
||||
|
||||
export default {
|
||||
query: query,
|
||||
request: request(pool),
|
||||
verify: ddl(query).ensureDatabase
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
import { Pool } from 'pg'
|
||||
import cuid from 'cuid'
|
||||
|
||||
const currentRequestSql = `
|
||||
SELECT "requestId", "text", "asOf", "lastStatus"
|
||||
FROM mpj.journal`
|
||||
|
||||
const journalSql = `${currentRequestSql}
|
||||
WHERE "userId" = $1
|
||||
AND "lastStatus" <> 'Answered'`
|
||||
|
||||
const requestNotFound = {
|
||||
requestId: '',
|
||||
text: 'Not Found',
|
||||
asOf: 0
|
||||
}
|
||||
|
||||
export default function (pool) {
|
||||
return {
|
||||
/**
|
||||
* Add a history entry for this request
|
||||
* @param {string} requestId The Id of the request
|
||||
* @param {string} status The status for this history entry
|
||||
* @param {string} updateText The updated text for the request (pass blank if no update)
|
||||
*/
|
||||
addHistory: async (requestId, status, updateText) => {
|
||||
const asOf = Date.now()
|
||||
await pool.query(`
|
||||
INSERT INTO mpj.history
|
||||
("requestId", "asOf", "status", "text")
|
||||
VALUES
|
||||
($1, $2, $3, NULLIF($4, ''))`,
|
||||
[ requestId, asOf, status, updateText ])
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a new prayer request
|
||||
* @param {string} userId The Id of the user
|
||||
* @param {string} requestText The text of the request
|
||||
* @return The created request
|
||||
*/
|
||||
addNew: async (userId, requestText) => {
|
||||
const id = cuid()
|
||||
const enteredOn = Date.now()
|
||||
return (async () => {
|
||||
const client = await pool.connect()
|
||||
try {
|
||||
await client.query('BEGIN')
|
||||
await client.query(
|
||||
'INSERT INTO mpj.request ("requestId", "enteredOn", "userId") VALUES ($1, $2, $3)',
|
||||
[ id, enteredOn, userId ])
|
||||
await client.query(
|
||||
`INSERT INTO mpj.history ("requestId", "asOf", "status", "text") VALUES ($1, $2, 'Created', $3)`,
|
||||
[ id, enteredOn, requestText ])
|
||||
await client.query('COMMIT')
|
||||
} catch (e) {
|
||||
await client.query('ROLLBACK')
|
||||
throw e
|
||||
} finally {
|
||||
client.release()
|
||||
}
|
||||
return { requestId: id, text: requestText, asOf: enteredOn, lastStatus: 'Created' }
|
||||
})().catch(e => {
|
||||
console.error(e.stack)
|
||||
return { requestId: '', text: 'error', asOf: 0, lastStatus: 'Errored' }
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the "current" version of a request by its Id
|
||||
* @param {string} requestId The Id of the request to retrieve
|
||||
* @param {string} userId The Id of the user to which the request belongs
|
||||
* @return The request, or a request-like object indicating that the request was not found
|
||||
*/
|
||||
byId: async (userId, requestId) => {
|
||||
const reqs = await pool.query(`${currentRequestSql}
|
||||
WHERE "requestId" = $1
|
||||
AND "userId" = $2`,
|
||||
[ requestId, userId ])
|
||||
return (0 < reqs.rowCount) ? reqs.rows[0] : requestNotFound
|
||||
},
|
||||
|
||||
/**
|
||||
* Get a prayer request, including its full history, by its Id
|
||||
* @param {string} userId The Id of the user to which the request belongs
|
||||
* @param {string} requestId The Id of the request to retrieve
|
||||
* @return The request, or a request-like object indicating that the request was not found
|
||||
*/
|
||||
fullById: async (userId, requestId) => {
|
||||
const reqResults = await pool.query(`
|
||||
SELECT "requestId", "enteredOn"
|
||||
FROM mpj.request
|
||||
WHERE "requestId" = $1
|
||||
AND "userId" = $2`,
|
||||
[ requestId, userId ])
|
||||
if (0 === reqResults.rowCount) {
|
||||
return requestNotFound
|
||||
}
|
||||
const req = reqResults.rows[0]
|
||||
const history = await pool.query(`
|
||||
SELECT "asOf", "status", COALESCE("text", '') AS "text"
|
||||
FROM mpj.history
|
||||
WHERE "requestId" = $1
|
||||
ORDER BY "asOf"`,
|
||||
[ requestId ])
|
||||
req.history = history.rows
|
||||
return req
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the current requests for a user (i.e., their complete current journal)
|
||||
* @param {string} userId The Id of the user
|
||||
* @return The requests that make up the current journal
|
||||
*/
|
||||
journal: async userId => (await pool.query(`${journalSql} ORDER BY "asOf"`, [ userId ])).rows
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
import Koa from 'koa'
|
||||
import bodyParser from 'koa-bodyparser'
|
||||
import morgan from 'koa-morgan'
|
||||
import send from 'koa-send'
|
||||
import serveFrom from 'koa-static'
|
||||
|
||||
import appConfig from '../appsettings.json'
|
||||
import router from './routes'
|
||||
|
||||
/** Koa app */
|
||||
const app = new Koa()
|
||||
|
||||
if (appConfig.env === 'dev') app.use(morgan('dev'))
|
||||
|
||||
export default app
|
||||
// Serve the Vue files from /public
|
||||
.use(serveFrom('public'))
|
||||
// Parse the body into ctx.request.body, if present
|
||||
.use(bodyParser())
|
||||
// Tie in all the routes
|
||||
.use(router.routes())
|
||||
.use(router.allowedMethods())
|
||||
// Send the index.html file for what would normally get a 404
|
||||
.use(async (ctx, next) => {
|
||||
if (ctx.url.indexOf('/api') === -1) {
|
||||
try {
|
||||
await send(ctx, 'index.html', { root: __dirname + '/../public/' })
|
||||
}
|
||||
catch (err) {
|
||||
return await next(err)
|
||||
}
|
||||
}
|
||||
return await next()
|
||||
})
|
||||
@@ -1,39 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
import jwt from 'koa-jwt'
|
||||
import jwksRsa from 'jwks-rsa-koa'
|
||||
import Router from 'koa-router'
|
||||
|
||||
import appConfig from '../../appsettings.json'
|
||||
import journal from './journal'
|
||||
import request from './request'
|
||||
|
||||
/** Authentication middleware to verify the access token against the Auth0 JSON Web Key Set */
|
||||
const checkJwt = jwt({
|
||||
// Dynamically provide a signing key
|
||||
// based on the kid in the header and
|
||||
// the singing keys provided by the JWKS endpoint.
|
||||
secret: jwksRsa.koaJwt2Key({
|
||||
cache: true,
|
||||
rateLimit: true,
|
||||
jwksRequestsPerMinute: 5,
|
||||
jwksUri: `https://${appConfig.auth0.domain}/.well-known/jwks.json`
|
||||
}),
|
||||
|
||||
// Validate the audience and the issuer.
|
||||
audience: appConfig.auth0.clientId,
|
||||
issuer: `https://${appConfig.auth0.domain}/`,
|
||||
algorithms: ['RS256']
|
||||
})
|
||||
|
||||
/** /api/journal routes */
|
||||
const journalRoutes = journal(checkJwt)
|
||||
/** /api/request routes */
|
||||
const requestRoutes = request(checkJwt)
|
||||
|
||||
/** Combined router */
|
||||
const router = new Router({ prefix: '/api' })
|
||||
router.use('/journal', journalRoutes.routes(), journalRoutes.allowedMethods())
|
||||
router.use('/request', requestRoutes.routes(), requestRoutes.allowedMethods())
|
||||
|
||||
export default router
|
||||
@@ -1,16 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
import Router from 'koa-router'
|
||||
import db from '../db'
|
||||
|
||||
const router = new Router()
|
||||
|
||||
export default function (checkJwt) {
|
||||
|
||||
router.get('/', checkJwt, async (ctx, next) => {
|
||||
const reqs = await db.request.journal(ctx.state.user.sub)
|
||||
ctx.body = reqs
|
||||
return await next()
|
||||
})
|
||||
return router
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
import Router from 'koa-router'
|
||||
import db from '../db'
|
||||
|
||||
const router = new Router()
|
||||
|
||||
export default function (checkJwt) {
|
||||
|
||||
router
|
||||
// Add a new request
|
||||
.post('/', checkJwt, async (ctx, next) => {
|
||||
ctx.body = await db.request.addNew(ctx.state.user.sub, ctx.request.body.requestText)
|
||||
await next()
|
||||
})
|
||||
// Add a request history entry (prayed, updated, answered, etc.)
|
||||
.post('/:id/history', checkJwt, async (ctx, next) => {
|
||||
const body = ctx.request.body
|
||||
await db.request.addHistory(ctx.params.id, body.status, body.updateText)
|
||||
ctx.response.status = 204
|
||||
await next()
|
||||
})
|
||||
// Get a journal-style request by its Id
|
||||
.get('/:id', checkJwt, async (ctx, next) => {
|
||||
const req = await db.request.byId(ctx.state.user.sub, ctx.params.id)
|
||||
if ('Not Found' === req.text) {
|
||||
ctx.response.status = 404
|
||||
} else {
|
||||
ctx.body = req
|
||||
}
|
||||
await next()
|
||||
})
|
||||
// Get a request, along with its full history
|
||||
.get('/:id/full', 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.body = req
|
||||
}
|
||||
await next()
|
||||
})
|
||||
// Get the least-recently-updated request (used for the "pray through the journal" feature)
|
||||
.get('/:id/oldest', checkJwt, async (ctx, next) => {
|
||||
ctx.body = await db.request.oldest(ctx.state.user.sub)
|
||||
await next()
|
||||
})
|
||||
|
||||
|
||||
return router
|
||||
}
|
||||
2194
src/api/yarn.lock
2194
src/api/yarn.lock
File diff suppressed because it is too large
Load Diff
35
src/app/build/build.js
Normal file
35
src/app/build/build.js
Normal 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'
|
||||
))
|
||||
})
|
||||
})
|
||||
48
src/app/build/check-versions.js
Normal file
48
src/app/build/check-versions.js
Normal 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)
|
||||
}
|
||||
}
|
||||
9
src/app/build/dev-client.js
Normal file
9
src/app/build/dev-client.js
Normal 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()
|
||||
}
|
||||
})
|
||||
92
src/app/build/dev-server.js
Normal file
92
src/app/build/dev-server.js
Normal 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
71
src/app/build/utils.js
Normal 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
|
||||
}
|
||||
18
src/app/build/vue-loader.conf.js
Normal file
18
src/app/build/vue-loader.conf.js
Normal 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'
|
||||
}
|
||||
}
|
||||
75
src/app/build/webpack.base.conf.js
Normal file
75
src/app/build/webpack.base.conf.js
Normal 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]')
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
35
src/app/build/webpack.dev.conf.js
Normal file
35
src/app/build/webpack.dev.conf.js
Normal 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()
|
||||
]
|
||||
})
|
||||
125
src/app/build/webpack.prod.conf.js
Normal file
125
src/app/build/webpack.prod.conf.js
Normal 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
|
||||
31
src/app/build/webpack.test.conf.js
Normal file
31
src/app/build/webpack.test.conf.js
Normal 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
|
||||
@@ -4,8 +4,8 @@ var path = require('path')
|
||||
module.exports = {
|
||||
build: {
|
||||
env: require('./prod.env'),
|
||||
index: path.resolve(__dirname, '../../api/public/index.html'),
|
||||
assetsRoot: path.resolve(__dirname, '../../api/public'),
|
||||
index: path.resolve(__dirname, '../../api/MyPrayerJournal.Api/wwwroot/index.html'),
|
||||
assetsRoot: path.resolve(__dirname, '../../api/MyPrayerJournal.Api/wwwroot'),
|
||||
assetsSubDirectory: 'static',
|
||||
assetsPublicPath: '/',
|
||||
productionSourceMap: true,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "my-prayer-journal",
|
||||
"version": "0.8.1",
|
||||
"version": "0.9.8",
|
||||
"description": "myPrayerJournal - Front End",
|
||||
"author": "Daniel J. Summers <daniel@djs-consulting.com>",
|
||||
"author": "Daniel J. Summers <daniel@bitbadger.solutions>",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "node build/dev-server.js",
|
||||
@@ -11,18 +11,20 @@
|
||||
"unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run",
|
||||
"e2e": "node test/e2e/runner.js",
|
||||
"test": "npm run unit && npm run e2e",
|
||||
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
|
||||
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs",
|
||||
"apistart": "cd ../api/MyPrayerJournal.Api && dotnet run",
|
||||
"vue": "node build/build.js prod && cd ../api/MyPrayerJournal.Api && dotnet run"
|
||||
},
|
||||
"dependencies": {
|
||||
"auth0-js": "^8.10.1",
|
||||
"axios": "^0.16.2",
|
||||
"element-ui": "^1.4.4",
|
||||
"auth0-js": "^9.3.3",
|
||||
"axios": "^0.18.0",
|
||||
"moment": "^2.18.1",
|
||||
"pug": "^2.0.0-rc.4",
|
||||
"vue": "^2.4.4",
|
||||
"pug": "^2.0.1",
|
||||
"vue": "^2.5.15",
|
||||
"vue-progressbar": "^0.7.3",
|
||||
"vue-router": "^2.6.0",
|
||||
"vuex": "^2.4.0"
|
||||
"vue-router": "^3.0.0",
|
||||
"vue-toast": "^3.1.0",
|
||||
"vuex": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"autoprefixer": "^7.1.4",
|
||||
|
||||
@@ -1,65 +1,241 @@
|
||||
<template lang="pug">
|
||||
#app
|
||||
#app(role='application')
|
||||
navigation
|
||||
#content.container
|
||||
#content
|
||||
router-view
|
||||
vue-progress-bar
|
||||
footer
|
||||
p.text-right: i myPrayerJournal v0.8.1
|
||||
toast(ref='toast')
|
||||
footer.mpj-text-right.mpj-muted-text
|
||||
p
|
||||
| myPrayerJournal v{{ version }}
|
||||
br
|
||||
em: small.
|
||||
#[router-link(:to="{ name: 'PrivacyPolicy' }") Privacy Policy] •
|
||||
#[router-link(:to="{ name: 'TermsOfService' }") Terms of Service] •
|
||||
#[a(href='https://github.com/bit-badger/myprayerjournal' target='_blank') Developed] and hosted by
|
||||
#[a(href='https://bitbadger.solutions' target='_blank') Bit Badger Solutions]
|
||||
</template>
|
||||
|
||||
<script>
|
||||
'use strict'
|
||||
|
||||
import Navigation from './components/Navigation.vue'
|
||||
import Navigation from './components/common/Navigation.vue'
|
||||
|
||||
import { version } from '../package.json'
|
||||
|
||||
export default {
|
||||
name: 'app',
|
||||
components: {
|
||||
Navigation
|
||||
},
|
||||
data () {
|
||||
return { version }
|
||||
},
|
||||
mounted () {
|
||||
this.$refs.toast.setOptions({ position: 'bottom right' })
|
||||
},
|
||||
computed: {
|
||||
toast () {
|
||||
return this.$refs.toast
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@import url('../node_modules/element-ui/lib/theme-default/index.css');
|
||||
html, body {
|
||||
background-color: whitesmoke;
|
||||
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
|
||||
font-size: 1rem;
|
||||
}
|
||||
body {
|
||||
font-family: -apple-system,system-ui,BlinkMacSystemFont,"Segoe UI","Roboto","Helvetica Neue", Arial, sans-serif;
|
||||
padding-top: 60px;
|
||||
padding-top: 50px;
|
||||
margin: 0;
|
||||
}
|
||||
#content {
|
||||
padding: 0 10px;
|
||||
h1, h2, h3, h4, h5 {
|
||||
font-weight: 500;
|
||||
margin-top: 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2.5rem;
|
||||
}
|
||||
h2 {
|
||||
font-size: 2rem;
|
||||
}
|
||||
h3 {
|
||||
font-size: 1.75rem;
|
||||
}
|
||||
h4 {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
h5 {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
p {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
input, textarea, select {
|
||||
border-radius: .25rem;
|
||||
font-size: 1rem;
|
||||
}
|
||||
textarea {
|
||||
font-family: "SFMono-Regular",Consolas,"Liberation Mono",Menlo,Courier,monospace;
|
||||
}
|
||||
input, select {
|
||||
font-family: inherit;
|
||||
}
|
||||
button,
|
||||
a[role="button"] {
|
||||
border: solid 1px #050;
|
||||
border-radius: .5rem;
|
||||
background-color: rgb(235, 235, 235);
|
||||
padding: .25rem;
|
||||
font-size: 1rem;
|
||||
}
|
||||
a[role="button"]:link,
|
||||
a[role="button"]:visited {
|
||||
color: black;
|
||||
}
|
||||
button.primary,
|
||||
a[role="button"].primary {
|
||||
background-color: white;
|
||||
border-width: 3px;
|
||||
}
|
||||
button:hover,
|
||||
a[role="button"]:hover {
|
||||
cursor: pointer;
|
||||
background-color: #050;
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
}
|
||||
label {
|
||||
font-variant: small-caps;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
label.normal {
|
||||
font-variant: unset;
|
||||
font-size: unset;
|
||||
}
|
||||
footer {
|
||||
border-top: solid 1px lightgray;
|
||||
margin-top: 1rem;
|
||||
padding: 0 1rem;
|
||||
|
||||
}
|
||||
footer p {
|
||||
margin: 0;
|
||||
}
|
||||
.text-right {
|
||||
a:link, a:visited {
|
||||
color: #050;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.mpj-main-content {
|
||||
max-width: 60rem;
|
||||
margin: auto;
|
||||
}
|
||||
.mpj-main-content-wide {
|
||||
margin: .5rem;
|
||||
}
|
||||
@media screen and (max-width: 21rem) {
|
||||
.mpj-main-content-wide {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
.mpj-request-text {
|
||||
white-space: pre-line;
|
||||
}
|
||||
.mpj-request-list p {
|
||||
border-top: solid 1px lightgray;
|
||||
}
|
||||
.mpj-request-list p:first-child {
|
||||
border-top: none;
|
||||
}
|
||||
.mpj-request-log {
|
||||
width: 100%;
|
||||
}
|
||||
.mpj-request-log thead th {
|
||||
border-top: solid 1px lightgray;
|
||||
border-bottom: solid 2px lightgray;
|
||||
text-align: left;
|
||||
}
|
||||
.mpj-request-log tbody td {
|
||||
border-bottom: dotted 1px lightgray;
|
||||
vertical-align: top;
|
||||
}
|
||||
.mpj-bg {
|
||||
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);
|
||||
}
|
||||
.mpj-text-center {
|
||||
text-align: center;
|
||||
}
|
||||
.mpj-text-nowrap {
|
||||
white-space: nowrap;
|
||||
}
|
||||
.mpj-text-right {
|
||||
text-align: right;
|
||||
}
|
||||
.material-icons.md-18 {
|
||||
font-size: 18px;
|
||||
.mpj-muted-text {
|
||||
color: rgba(0, 0, 0, .6);
|
||||
}
|
||||
.material-icons.md-24 {
|
||||
font-size: 24px;
|
||||
.mpj-narrow {
|
||||
max-width: 40rem;
|
||||
margin: auto;
|
||||
}
|
||||
.material-icons.md-36 {
|
||||
font-size: 36px;
|
||||
.mpj-skinny {
|
||||
max-width: 20rem;
|
||||
margin: auto;
|
||||
}
|
||||
.material-icons.md-48 {
|
||||
font-size: 48px;
|
||||
.mpj-full-width {
|
||||
width: 100%;
|
||||
}
|
||||
.mpj-modal {
|
||||
position: fixed;
|
||||
z-index: 8;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
background-color: rgba(0, 0, 0, .4);
|
||||
}
|
||||
.mpj-modal-content {
|
||||
background-color: whitesmoke;
|
||||
border: solid 1px #050;
|
||||
border-radius: .5rem;
|
||||
animation-name: animatetop;
|
||||
animation-duration: 0.4s;
|
||||
padding: 1rem;
|
||||
margin-top: 4rem;
|
||||
}
|
||||
@keyframes animatetop {
|
||||
from {
|
||||
top: -300px;
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
top: 0;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
.mpj-modal-content header {
|
||||
margin: -1rem -1rem .5rem;
|
||||
border-radius: .4rem;
|
||||
}
|
||||
.mpj-modal-content header h5 {
|
||||
color: white;
|
||||
margin: 0;
|
||||
padding: 1rem;
|
||||
}
|
||||
.mpj-margin {
|
||||
margin-left: 1rem;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
.material-icons {
|
||||
vertical-align: middle;
|
||||
}
|
||||
.mpj-page-title {
|
||||
border-bottom: solid 1px lightgray;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
'use strict'
|
||||
|
||||
import axios from 'axios'
|
||||
|
||||
const http = axios.create({
|
||||
baseURL: 'http://localhost:3000/api/'
|
||||
baseURL: `${location.protocol}//${location.host}/api/`
|
||||
})
|
||||
|
||||
/**
|
||||
@@ -21,24 +23,36 @@ export default {
|
||||
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
|
||||
* @param {string} requestText The text of the request to be added
|
||||
* @param {string} recurType The type of recurrence for this request
|
||||
* @param {number} recurCount The number of intervals of recurrence
|
||||
*/
|
||||
addRequest: requestText => http.post('request/', { requestText }),
|
||||
addRequest: (requestText, recurType, recurCount) => http.post('request', { requestText, recurType, recurCount }),
|
||||
|
||||
/**
|
||||
* Update a prayer request
|
||||
* @param request The request (should have requestId, status, and updateText properties)
|
||||
* Get all answered requests, along with the text they had when it was answered
|
||||
*/
|
||||
updateRequest: request => http.post(`request/${request.requestId}/history`, {
|
||||
status: request.status,
|
||||
updateText: request.updateText
|
||||
}),
|
||||
getAnsweredRequests: () => http.get('requests/answered'),
|
||||
|
||||
/**
|
||||
* Get a prayer request (full; includes all history and notes)
|
||||
* @param {string} requestId The Id of the request to retrieve
|
||||
*/
|
||||
getFullRequest: requestId => http.get(`request/${requestId}/full`),
|
||||
|
||||
/**
|
||||
* Get past notes for a prayer request
|
||||
* @param {string} requestId The Id of the request for which notes should be retrieved
|
||||
*/
|
||||
getNotes: requestId => http.get(`request/${requestId}/notes`),
|
||||
|
||||
/**
|
||||
* Get a prayer request (journal-style; only latest update)
|
||||
@@ -47,9 +61,38 @@ export default {
|
||||
getRequest: requestId => http.get(`request/${requestId}`),
|
||||
|
||||
/**
|
||||
* Get a prayer request (full; includes all history)
|
||||
* @param {string} requestId The Id of the request to retrieve
|
||||
* Get all prayer requests and their most recent updates
|
||||
*/
|
||||
getFullRequest: requestId => http.get(`request/${requestId}/full`)
|
||||
journal: () => http.get('journal'),
|
||||
|
||||
/**
|
||||
* Show a request after the given date (used for "show now")
|
||||
* @param {string} requestId The ID of the request which should be shown
|
||||
* @param {number} showAfter The ticks after which the request should be shown
|
||||
*/
|
||||
showRequest: (requestId, showAfter) => http.patch(`request/${requestId}/show`, { showAfter }),
|
||||
|
||||
/**
|
||||
* Snooze a request until the given time
|
||||
* @param {string} requestId The ID of the prayer request to be snoozed
|
||||
* @param {number} until The ticks until which the request should be snoozed
|
||||
*/
|
||||
snoozeRequest: (requestId, until) => http.patch(`request/${requestId}/snooze`, { until }),
|
||||
|
||||
/**
|
||||
* Update recurrence for a prayer request
|
||||
* @param {string} requestId The ID of the prayer request for which recurrence is being updated
|
||||
* @param {string} recurType The type of recurrence to set
|
||||
* @param {number} recurCount The number of recurrence intervals to set
|
||||
*/
|
||||
updateRecurrence: (requestId, recurType, recurCount) =>
|
||||
http.patch(`request/${requestId}/recurrence`, { recurType, recurCount }),
|
||||
|
||||
/**
|
||||
* Update a prayer request
|
||||
* @param {string} requestId The ID of the request to be updated
|
||||
* @param {string} status The status of the update
|
||||
* @param {string} updateText The text of the update (optional)
|
||||
*/
|
||||
updateRequest: (requestId, status, updateText) => http.post(`request/${requestId}/history`, { status, updateText })
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import auth0 from 'auth0-js'
|
||||
import AUTH_CONFIG from './auth0-variables'
|
||||
import mutations from '@/store/mutation-types'
|
||||
|
||||
var tokenRenewalTimeout
|
||||
|
||||
export default class AuthService {
|
||||
|
||||
constructor () {
|
||||
@@ -17,7 +19,7 @@ export default class AuthService {
|
||||
auth0 = new auth0.WebAuth({
|
||||
domain: AUTH_CONFIG.domain,
|
||||
clientID: AUTH_CONFIG.clientId,
|
||||
redirectUri: AUTH_CONFIG.callbackUrl,
|
||||
redirectUri: AUTH_CONFIG.appDomain + AUTH_CONFIG.callbackUrl,
|
||||
audience: `https://${AUTH_CONFIG.domain}/userinfo`,
|
||||
responseType: 'token id_token',
|
||||
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) {
|
||||
// Set the time that the access token will expire at
|
||||
let expiresAt = JSON.stringify(
|
||||
@@ -86,10 +98,30 @@ export default class AuthService {
|
||||
localStorage.setItem('access_token', authResult.accessToken)
|
||||
localStorage.setItem('id_token', authResult.idToken)
|
||||
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) {
|
||||
// Clear access token and ID token from local storage
|
||||
clearTimeout(tokenRenewalTimeout)
|
||||
localStorage.removeItem('access_token')
|
||||
localStorage.removeItem('id_token')
|
||||
localStorage.removeItem('expires_at')
|
||||
|
||||
@@ -1,26 +1,22 @@
|
||||
<template lang="pug">
|
||||
article
|
||||
page-title(title='Welcome!' hideOnPage='true')
|
||||
article.mpj-main-content(role='main')
|
||||
page-title(title='Welcome!'
|
||||
hideOnPage='true')
|
||||
p
|
||||
p.
|
||||
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. It will also
|
||||
allow individuals to review their answered prayers.
|
||||
update them as God moves in the situation, and record a final answer received on that request. It will also allow
|
||||
individuals to review their answered prayers.
|
||||
p.
|
||||
This site is currently in very limited alpha, as it is being developed with a core group of test users. If
|
||||
this is something in which you are interested, check back around mid-November 2017 for an update on the
|
||||
development progress.
|
||||
This site is currently in beta, but it is open and available to the general public. To get started, simply click
|
||||
the “Log On” link above, and log on with either a Microsoft or Google account. You can also learn more
|
||||
about the site at the “Docs” link, also above.
|
||||
</template>
|
||||
|
||||
<script>
|
||||
'use strict'
|
||||
|
||||
import PageTitle from './common/PageTitle.vue'
|
||||
|
||||
export default {
|
||||
name: 'home',
|
||||
components: {
|
||||
PageTitle
|
||||
}
|
||||
name: 'home'
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,47 +1,72 @@
|
||||
<template lang="pug">
|
||||
article
|
||||
article.mpj-main-content-wide(role='main')
|
||||
page-title(:title='title')
|
||||
p(v-if='isLoadingJournal') Loading your prayer journal...
|
||||
template(v-if='!isLoadingJournal')
|
||||
new-request
|
||||
el-row
|
||||
el-col(:span='4'): strong Actions
|
||||
el-col(:span='16'): strong Request
|
||||
el-col(:span='4'): strong As Of
|
||||
request-list-item(v-if='journal.length > 0' v-for='request in journal' :request='request' :key='request.requestId')
|
||||
p.text-center(v-if='journal.length === 0'): em No requests found; click the "Add a New Request" button to add one
|
||||
template(v-else)
|
||||
.mpj-text-center
|
||||
router-link(:to="{ name: 'EditRequest', params: { id: 'new' } }"
|
||||
role='button').
|
||||
#[md-icon(icon='add_box')] Add a New Request
|
||||
br
|
||||
.mpj-journal(v-if='journal.length > 0')
|
||||
request-card(v-for='request in journal'
|
||||
:key='request.requestId'
|
||||
:request='request'
|
||||
:events='eventBus'
|
||||
:toast='toast')
|
||||
p.text-center(v-else): em.
|
||||
No requests found; click the “Add a New Request” button to add one
|
||||
notes-edit(:events='eventBus'
|
||||
:toast='toast')
|
||||
snooze-request(:events='eventBus'
|
||||
:toast='toast')
|
||||
</template>
|
||||
|
||||
<script>
|
||||
'use strict'
|
||||
|
||||
import Vue from 'vue'
|
||||
import { mapState } from 'vuex'
|
||||
|
||||
import PageTitle from './common/PageTitle'
|
||||
import NewRequest from './request/NewRequest'
|
||||
import RequestListItem from './request/RequestListItem'
|
||||
import NotesEdit from './request/NotesEdit'
|
||||
import RequestCard from './request/RequestCard'
|
||||
import SnoozeRequest from './request/SnoozeRequest'
|
||||
|
||||
import actions from '@/store/action-types'
|
||||
|
||||
export default {
|
||||
name: 'journal',
|
||||
components: {
|
||||
PageTitle,
|
||||
NewRequest,
|
||||
RequestListItem
|
||||
NotesEdit,
|
||||
RequestCard,
|
||||
SnoozeRequest
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
eventBus: new Vue()
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
title () {
|
||||
return `${this.user.given_name}'s Prayer Journal`
|
||||
return `${this.user.given_name}’s Prayer Journal`
|
||||
},
|
||||
toast () {
|
||||
return this.$parent.$refs.toast
|
||||
},
|
||||
...mapState(['user', 'journal', 'isLoadingJournal'])
|
||||
},
|
||||
async created () {
|
||||
await this.$store.dispatch(actions.LOAD_JOURNAL, this.$Progress)
|
||||
this.$message({
|
||||
message: `Loaded ${this.journal.length} prayer requests`,
|
||||
type: 'success'
|
||||
})
|
||||
this.toast.showToast(`Loaded ${this.journal.length} prayer requests`, { theme: 'success' })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.mpj-journal {
|
||||
display: flex;
|
||||
flex-flow: row wrap;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
}
|
||||
</style>
|
||||
@@ -1,50 +0,0 @@
|
||||
<template lang="pug">
|
||||
el-menu(theme='dark' mode='horizontal' class='mpj-top-nav' router='true')
|
||||
el-menu-item(index='/')
|
||||
span(style='font-weight:100;') my
|
||||
span(style='font-weight:600;') Prayer
|
||||
span(style='font-weight:700;') Journal
|
||||
el-menu-item(v-if='isAuthenticated' index='/journal') Journal
|
||||
el-menu-item(v-if='isAuthenticated' index='3'): a(@click.stop='logOff()') Log Off
|
||||
el-menu-item(v-if='!isAuthenticated' index='4'): a(@click.stop='logOn()') Log On
|
||||
el-menu-item(index='5'): a(href='https://danieljsummers.github.io/myPrayerJournal/' target='_blank' @click.stop='') Docs
|
||||
</template>
|
||||
|
||||
<script>
|
||||
'use strict'
|
||||
|
||||
import { mapState } from 'vuex'
|
||||
import AuthService from '@/auth/AuthService'
|
||||
|
||||
export default {
|
||||
name: 'navigation',
|
||||
data () {
|
||||
return {
|
||||
auth0: new AuthService()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
logOn () {
|
||||
this.auth0.login()
|
||||
},
|
||||
logOff () {
|
||||
this.auth0.logout(this.$store, this.$router)
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState([ 'isAuthenticated' ])
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.mpj-top-nav {
|
||||
position: fixed;
|
||||
top: 0px;
|
||||
width: 100%;
|
||||
}
|
||||
.mpj-top-nav a:link,
|
||||
.mpj-top-nav a:visited {
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
@@ -25,6 +25,11 @@ export default {
|
||||
intervalId: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
actual () {
|
||||
return moment(this.value).format('LLLL')
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.intervalId = setInterval(this.updateFromNow, this.interval)
|
||||
this.$watch('value', this.updateFromNow)
|
||||
@@ -39,7 +44,12 @@ export default {
|
||||
}
|
||||
},
|
||||
render (createElement) {
|
||||
return createElement(this.tag, this.fromNow)
|
||||
return createElement(this.tag, {
|
||||
domProps: {
|
||||
title: this.actual,
|
||||
innerText: this.fromNow
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
15
src/app/src/components/common/MaterialDesignIcon.vue
Normal file
15
src/app/src/components/common/MaterialDesignIcon.vue
Normal file
@@ -0,0 +1,15 @@
|
||||
<template lang="pug">
|
||||
i.material-icons(v-html='icon')
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'md-icon',
|
||||
props: {
|
||||
icon: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
96
src/app/src/components/common/Navigation.vue
Normal file
96
src/app/src/components/common/Navigation.vue
Normal file
@@ -0,0 +1,96 @@
|
||||
<template lang="pug">
|
||||
nav.mpj-top-nav.mpj-bg(role='menubar')
|
||||
router-link.title(:to="{ name: 'Home' }"
|
||||
role='menuitem')
|
||||
span(style='font-weight:100;') my
|
||||
span(style='font-weight:600;') Prayer
|
||||
span(style='font-weight:700;') Journal
|
||||
router-link(v-if='isAuthenticated'
|
||||
:to="{ name: 'Journal' }"
|
||||
role='menuitem') Journal
|
||||
router-link(v-if='isAuthenticated'
|
||||
:to="{ name: 'ActiveRequests' }"
|
||||
role='menuitem') Active
|
||||
router-link(v-if='hasSnoozed'
|
||||
:to="{ name: 'SnoozedRequests' }"
|
||||
role='menuitem') Snoozed
|
||||
router-link(v-if='isAuthenticated'
|
||||
:to="{ name: 'AnsweredRequests' }"
|
||||
role='menuitem') Answered
|
||||
a(v-if='isAuthenticated'
|
||||
href='#'
|
||||
role='menuitem'
|
||||
@click.stop='logOff()') Log Off
|
||||
a(v-if='!isAuthenticated'
|
||||
href='#'
|
||||
role='menuitem'
|
||||
@click.stop='logOn()') Log On
|
||||
a(href='https://bit-badger.github.io/myPrayerJournal/'
|
||||
target='_blank'
|
||||
role='menuitem'
|
||||
@click.stop='') Docs
|
||||
</template>
|
||||
|
||||
<script>
|
||||
'use strict'
|
||||
|
||||
import { mapState } from 'vuex'
|
||||
|
||||
import AuthService from '@/auth/AuthService'
|
||||
|
||||
export default {
|
||||
name: 'navigation',
|
||||
data () {
|
||||
return {
|
||||
auth0: new AuthService()
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
hasSnoozed () {
|
||||
return this.isAuthenticated &&
|
||||
Array.isArray(this.journal) &&
|
||||
this.journal.filter(req => req.snoozedUntil > Date.now()).length > 0
|
||||
},
|
||||
...mapState([ 'journal', 'isAuthenticated' ])
|
||||
},
|
||||
methods: {
|
||||
logOn () {
|
||||
this.auth0.login()
|
||||
},
|
||||
logOff () {
|
||||
this.auth0.logout(this.$store, this.$router)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.mpj-top-nav {
|
||||
position: fixed;
|
||||
display: flex;
|
||||
flex-flow: row wrap;
|
||||
align-items: center;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
padding-left: .5rem;
|
||||
min-height: 50px;
|
||||
}
|
||||
.mpj-top-nav a:link,
|
||||
.mpj-top-nav a:visited {
|
||||
text-decoration: none;
|
||||
color: rgba(255, 255, 255, .75);
|
||||
padding-left: 1rem;
|
||||
}
|
||||
.mpj-top-nav a:link.router-link-active,
|
||||
.mpj-top-nav a:visited.router-link-active,
|
||||
.mpj-top-nav a:hover {
|
||||
color: white;
|
||||
}
|
||||
.mpj-top-nav .title {
|
||||
font-size: 1.25rem;
|
||||
color: white;
|
||||
padding-left: 1.25rem;
|
||||
padding-right: 1.25rem;
|
||||
}
|
||||
</style>
|
||||
@@ -1,5 +1,6 @@
|
||||
<template lang="pug">
|
||||
h2.mpj-page-title(v-if='!hideOnPage' v-html='title')
|
||||
h2.mpj-page-title(v-if='!hideOnPage'
|
||||
v-html='title')
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -15,13 +16,20 @@ export default {
|
||||
default: false
|
||||
}
|
||||
},
|
||||
created () {
|
||||
document.title = `${this.title} « myPrayerJournal`
|
||||
},
|
||||
watch: {
|
||||
title () {
|
||||
document.title = `${this.title} « myPrayerJournal`
|
||||
document.title = `${this.title.replace('’', "'")} « myPrayerJournal`
|
||||
}
|
||||
},
|
||||
created () {
|
||||
document.title = `${this.title.replace('’', "'")} « myPrayerJournal`
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.mpj-page-title {
|
||||
border-bottom: solid 1px lightgray;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
</style>
|
||||
|
||||
54
src/app/src/components/legal/PrivacyPolicy.vue
Normal file
54
src/app/src/components/legal/PrivacyPolicy.vue
Normal 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 (“sub”) 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 “Log Off” 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 “monetize” 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>
|
||||
35
src/app/src/components/legal/TermsOfService.vue
Normal file
35
src/app/src/components/legal/TermsOfService.vue
Normal 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>
|
||||
59
src/app/src/components/request/ActiveRequests.vue
Normal file
59
src/app/src/components/request/ActiveRequests.vue
Normal file
@@ -0,0 +1,59 @@
|
||||
<template lang="pug">
|
||||
article.mpj-main-content(role='main')
|
||||
page-title(title='Active Requests')
|
||||
div(v-if='loaded').mpj-request-list
|
||||
p.mpj-text-center(v-if='requests.length === 0'): em.
|
||||
No active requests found; return to #[router-link(:to='{ name: "Journal" } ') your journal]
|
||||
request-list-item(v-for='req in requests'
|
||||
:key='req.requestId'
|
||||
:request='req'
|
||||
:toast='toast')
|
||||
p(v-else) Loading journal...
|
||||
</template>
|
||||
|
||||
<script>
|
||||
'use strict'
|
||||
|
||||
import { mapState } from 'vuex'
|
||||
|
||||
import RequestListItem from '@/components/request/RequestListItem'
|
||||
|
||||
import actions from '@/store/action-types'
|
||||
|
||||
export default {
|
||||
name: 'active-requests',
|
||||
components: {
|
||||
RequestListItem
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
requests: [],
|
||||
loaded: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
toast () {
|
||||
return this.$parent.$refs.toast
|
||||
},
|
||||
...mapState(['journal', 'isLoadingJournal'])
|
||||
},
|
||||
created () {
|
||||
this.$on('requestUnsnoozed', this.ensureJournal)
|
||||
this.$on('requestNowShown', this.ensureJournal)
|
||||
},
|
||||
methods: {
|
||||
async ensureJournal () {
|
||||
if (!Array.isArray(this.journal)) {
|
||||
this.loaded = false
|
||||
await this.$store.dispatch(actions.LOAD_JOURNAL, this.$Progress)
|
||||
}
|
||||
this.requests = this.journal
|
||||
.sort((a, b) => a.showAfter - b.showAfter)
|
||||
this.loaded = true
|
||||
}
|
||||
},
|
||||
async mounted () {
|
||||
await this.ensureJournal()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
52
src/app/src/components/request/AnsweredRequests.vue
Normal file
52
src/app/src/components/request/AnsweredRequests.vue
Normal file
@@ -0,0 +1,52 @@
|
||||
<template lang="pug">
|
||||
article.mpj-main-content(role='main')
|
||||
page-title(title='Answered Requests')
|
||||
div(v-if='loaded').mpj-request-list
|
||||
p.text-center(v-if='requests.length === 0'): em.
|
||||
No answered requests found; once you have marked one as “Answered”, it will appear here
|
||||
request-list-item(v-for='req in requests'
|
||||
:key='req.requestId'
|
||||
:request='req'
|
||||
:toast='toast')
|
||||
p(v-else) Loading answered requests...
|
||||
</template>
|
||||
|
||||
<script>
|
||||
'use strict'
|
||||
|
||||
import api from '@/api'
|
||||
|
||||
import RequestListItem from '@/components/request/RequestListItem'
|
||||
|
||||
export default {
|
||||
name: 'answered-requests',
|
||||
components: {
|
||||
RequestListItem
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
requests: [],
|
||||
loaded: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
toast () {
|
||||
return this.$parent.$refs.toast
|
||||
}
|
||||
},
|
||||
async mounted () {
|
||||
this.$Progress.start()
|
||||
try {
|
||||
const reqs = await api.getAnsweredRequests()
|
||||
this.requests = reqs.data
|
||||
this.$Progress.finish()
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
this.toast.showToast('Error loading requests; check console for details', { theme: 'danger' })
|
||||
this.$Progress.fail()
|
||||
} finally {
|
||||
this.loaded = true
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1,70 +1,204 @@
|
||||
<template lang="pug">
|
||||
span
|
||||
el-button(icon='edit' @click='openDialog()' title='Edit')
|
||||
el-dialog(title='Edit Prayer Request' :visible.sync='editVisible')
|
||||
el-form(:model='form' :label-position='top')
|
||||
el-form-item(label='Prayer Request')
|
||||
el-input(type='textarea' v-model='form.requestText' :rows='10' @blur="trimText()")
|
||||
el-form-item(label='Also Mark As')
|
||||
el-radio-group(v-model='form.status')
|
||||
el-radio-button(label='Updated') Updated
|
||||
el-radio-button(label='Prayed') Prayed
|
||||
el-radio-button(label='Answered') Answered
|
||||
span.dialog-footer(slot='footer')
|
||||
el-button(@click='closeDialog()') Cancel
|
||||
el-button(type='primary' @click='saveRequest()') Save
|
||||
article.mpj-main-content(role='main')
|
||||
page-title(:title='title')
|
||||
.mpj-narrow
|
||||
label(for='request_text')
|
||||
| Prayer Request
|
||||
br
|
||||
textarea(v-model='form.requestText'
|
||||
:rows='10'
|
||||
@blur='trimText()'
|
||||
autofocus).mpj-full-width
|
||||
br
|
||||
template(v-if='!isNew')
|
||||
label Also Mark As
|
||||
br
|
||||
label.normal
|
||||
input(v-model='form.status'
|
||||
type='radio'
|
||||
name='status'
|
||||
value='Updated')
|
||||
| Updated
|
||||
|
|
||||
label.normal
|
||||
input(v-model='form.status'
|
||||
type='radio'
|
||||
name='status'
|
||||
value='Prayed')
|
||||
| Prayed
|
||||
|
|
||||
label.normal
|
||||
input(v-model='form.status'
|
||||
type='radio'
|
||||
name='status'
|
||||
value='Answered')
|
||||
| Answered
|
||||
br
|
||||
label Recurrence
|
||||
|
|
||||
em.mpj-muted-text After prayer, request reappears...
|
||||
br
|
||||
label.normal
|
||||
input(v-model='form.recur.typ'
|
||||
type='radio'
|
||||
name='recur'
|
||||
value='immediate')
|
||||
| Immediately
|
||||
|
|
||||
label.normal
|
||||
input(v-model='form.recur.typ'
|
||||
type='radio'
|
||||
name='recur'
|
||||
value='other')
|
||||
| Every...
|
||||
input(v-model='form.recur.count'
|
||||
type='number'
|
||||
:disabled='!showRecurrence').mpj-recur-count
|
||||
select(v-model='form.recur.other'
|
||||
:disabled='!showRecurrence').mpj-recur-type
|
||||
option(value='hours') hours
|
||||
option(value='days') days
|
||||
option(value='weeks') weeks
|
||||
.mpj-text-right
|
||||
button(:disabled='!isValidRecurrence'
|
||||
@click.stop='saveRequest()').primary.
|
||||
#[md-icon(icon='save')] Save
|
||||
|
|
||||
button(@click.stop='goBack()').
|
||||
#[md-icon(icon='arrow_back')] Cancel
|
||||
</template>
|
||||
|
||||
<script>
|
||||
'use strict'
|
||||
|
||||
import { mapState } from 'vuex'
|
||||
|
||||
import actions from '@/store/action-types'
|
||||
|
||||
export default {
|
||||
name: 'edit-request',
|
||||
props: [ 'request' ],
|
||||
props: {
|
||||
id: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
editVisible: false,
|
||||
title: 'Edit Prayer Request',
|
||||
isNew: false,
|
||||
form: {
|
||||
requestText: this.request.text,
|
||||
status: 'Updated'
|
||||
},
|
||||
formLabelWidth: '120px'
|
||||
requestId: '',
|
||||
requestText: '',
|
||||
status: 'Updated',
|
||||
recur: {
|
||||
typ: 'immediate',
|
||||
other: '',
|
||||
count: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isValidRecurrence () {
|
||||
if (this.form.recur.typ === 'immediate') return true
|
||||
const count = Number.parseInt(this.form.recur.count)
|
||||
if (isNaN(count) || this.form.recur.other === '') return false
|
||||
if (this.form.recur.other === 'hours' && count > (365 * 24)) return false
|
||||
if (this.form.recur.other === 'days' && count > 365) return false
|
||||
if (this.form.recur.other === 'weeks' && count > 52) return false
|
||||
return true
|
||||
},
|
||||
showRecurrence () {
|
||||
return this.form.recur.typ !== 'immediate'
|
||||
},
|
||||
toast () {
|
||||
return this.$parent.$refs.toast
|
||||
},
|
||||
...mapState(['journal'])
|
||||
},
|
||||
async mounted () {
|
||||
await this.ensureJournal()
|
||||
if (this.id === 'new') {
|
||||
this.title = 'Add Prayer Request'
|
||||
this.isNew = true
|
||||
this.form.requestId = ''
|
||||
this.form.requestText = ''
|
||||
this.form.status = 'Created'
|
||||
this.form.recur.typ = 'immediate'
|
||||
this.form.recur.other = ''
|
||||
this.form.recur.count = ''
|
||||
} else {
|
||||
this.title = 'Edit Prayer Request'
|
||||
this.isNew = false
|
||||
if (this.journal.length === 0) {
|
||||
await this.$store.dispatch(actions.LOAD_JOURNAL, this.$Progress)
|
||||
}
|
||||
const req = this.journal.filter(r => r.requestId === this.id)[0]
|
||||
this.form.requestId = this.id
|
||||
this.form.requestText = req.text
|
||||
this.form.status = 'Updated'
|
||||
if (req.recurType === 'immediate') {
|
||||
this.form.recur.typ = 'immediate'
|
||||
this.form.recur.other = ''
|
||||
this.form.recur.count = ''
|
||||
} else {
|
||||
this.form.recur.typ = 'other'
|
||||
this.form.recur.other = req.recurType
|
||||
this.form.recur.count = req.recurCount
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
closeDialog () {
|
||||
this.form.requestText = ''
|
||||
this.form.status = 'Updated'
|
||||
this.editVisible = false
|
||||
},
|
||||
openDialog () {
|
||||
this.editVisible = true
|
||||
goBack () {
|
||||
this.$router.go(-1)
|
||||
},
|
||||
trimText () {
|
||||
this.form.requestText = this.form.requestText.trim()
|
||||
},
|
||||
async saveRequest () {
|
||||
await this.$store.dispatch(actions.UPDATE_REQUEST, {
|
||||
progress: this.$Progress,
|
||||
requestId: this.request.requestId,
|
||||
updateText: this.form.requestText,
|
||||
status: this.form.status
|
||||
})
|
||||
if (this.form.status === 'Answered') {
|
||||
this.$message({
|
||||
message: 'Request updated and removed from active journal',
|
||||
type: 'success'
|
||||
})
|
||||
} else {
|
||||
this.$message({
|
||||
message: 'Request updated',
|
||||
type: 'success'
|
||||
})
|
||||
async ensureJournal () {
|
||||
if (!Array.isArray(this.journal)) {
|
||||
await this.$store.dispatch(actions.LOAD_JOURNAL, this.$Progress)
|
||||
}
|
||||
this.editVisible = false
|
||||
},
|
||||
async saveRequest () {
|
||||
if (this.isNew) {
|
||||
await this.$store.dispatch(actions.ADD_REQUEST, {
|
||||
progress: this.$Progress,
|
||||
requestText: this.form.requestText,
|
||||
recurType: this.form.recur.typ === 'immediate' ? 'immediate' : this.form.recur.other,
|
||||
recurCount: this.form.recur.typ === 'immediate' ? 0 : Number.parseInt(this.form.recur.count)
|
||||
})
|
||||
this.toast.showToast('New prayer request added', { theme: 'success' })
|
||||
} else {
|
||||
await this.$store.dispatch(actions.UPDATE_REQUEST, {
|
||||
progress: this.$Progress,
|
||||
requestId: this.form.requestId,
|
||||
updateText: this.form.requestText,
|
||||
status: this.form.status,
|
||||
recurType: this.form.recur.typ === 'immediate' ? 'immediate' : this.form.recur.other,
|
||||
recurCount: this.form.recur.typ === 'immediate' ? 0 : Number.parseInt(this.form.recur.count)
|
||||
})
|
||||
if (this.form.status === 'Answered') {
|
||||
this.toast.showToast('Request updated and removed from active journal', { theme: 'success' })
|
||||
} else {
|
||||
this.toast.showToast('Request updated', { theme: 'success' })
|
||||
}
|
||||
}
|
||||
this.goBack()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.mpj-recur-count {
|
||||
width: 3rem;
|
||||
border-top-right-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
.mpj-recur-type {
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,44 +1,91 @@
|
||||
<template lang="pug">
|
||||
span
|
||||
el-button(icon='document' @click='openDialog()' title='Show History')
|
||||
el-dialog(title='Prayer Request History' :visible.sync='historyVisible')
|
||||
span(v-if='null !== full')
|
||||
full-request-history(v-for='item in full.history' :history='item' :key='item.asOf')
|
||||
span.dialog-footer(slot='footer')
|
||||
el-button(type='primary' @click='closeDialog()') Close
|
||||
article.mpj-main-content(role='main')
|
||||
page-title(title='Full Prayer Request')
|
||||
template(v-if='request')
|
||||
p
|
||||
span(v-if='isAnswered') Answered {{ formatDate(answered) }} (#[date-from-now(:value='answered')])
|
||||
small: em.mpj-muted-text prayed {{ prayedCount }} times, open {{ openDays }} days
|
||||
p.mpj-request-text {{ lastText }}
|
||||
br
|
||||
table.mpj-request-log
|
||||
thead
|
||||
tr
|
||||
th Action
|
||||
th Update / Notes
|
||||
tbody
|
||||
tr(v-for='item in log' :key='item.asOf')
|
||||
td {{ item.status }} on #[span.mpj-text-nowrap {{ formatDate(item.asOf) }}]
|
||||
td(v-if='item.text').mpj-request-text {{ item.text.fields[0] }}
|
||||
td(v-else)
|
||||
p(v-else) Loading request...
|
||||
</template>
|
||||
|
||||
<script>
|
||||
'use strict'
|
||||
|
||||
import FullRequestHistory from './FullRequestHistory'
|
||||
import moment from 'moment'
|
||||
|
||||
import api from '@/api'
|
||||
|
||||
const asOfDesc = (a, b) => b.asOf - a.asOf
|
||||
|
||||
export default {
|
||||
name: 'full-request',
|
||||
props: [ 'request' ],
|
||||
data () {
|
||||
return {
|
||||
historyVisible: false,
|
||||
full: null
|
||||
props: {
|
||||
id: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
components: {
|
||||
FullRequestHistory
|
||||
data () {
|
||||
return {
|
||||
request: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
answered () {
|
||||
return this.request.history.find(hist => hist.status === 'Answered').asOf
|
||||
},
|
||||
isAnswered () {
|
||||
return this.request.history.filter(hist => hist.status === 'Answered').length > 0
|
||||
},
|
||||
lastText () {
|
||||
return this.request.history
|
||||
.filter(hist => hist.text)
|
||||
.sort(asOfDesc)[0].text.fields[0]
|
||||
},
|
||||
log () {
|
||||
const allHistory = (this.request.notes || [])
|
||||
.map(note => ({ asOf: note.asOf, text: { case: 'Some', fields: [ note.notes ] }, status: 'Notes' }))
|
||||
.concat(this.request.history)
|
||||
.sort(asOfDesc)
|
||||
// Skip the first entry for answered requests; that info is already displayed
|
||||
return this.isAnswered ? allHistory.slice(1) : allHistory
|
||||
},
|
||||
openDays () {
|
||||
const asOf = this.isAnswered ? this.answered : Date.now()
|
||||
return Math.floor(
|
||||
(asOf - 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.getFullRequest(this.id)
|
||||
this.request = req.data
|
||||
this.$Progress.finish()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
this.$Progress.fail()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
closeDialog () {
|
||||
this.full = null
|
||||
this.historyVisible = false
|
||||
},
|
||||
async openDialog () {
|
||||
this.historyVisible = true
|
||||
this.$Progress.start()
|
||||
const req = await api.getFullRequest(this.request.requestId)
|
||||
this.full = req.data
|
||||
this.$Progress.finish()
|
||||
formatDate (asOf) {
|
||||
return moment(asOf).format('LL')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
<template lang="pug">
|
||||
p.journal-request
|
||||
| {{ history.status }} {{ asOf }}
|
||||
span(v-if='0 < history.text.length') » {{ history.text }}
|
||||
</template>
|
||||
|
||||
<script>
|
||||
'use strict'
|
||||
|
||||
import moment from 'moment'
|
||||
|
||||
export default {
|
||||
name: 'full-request-history',
|
||||
props: [ 'history' ],
|
||||
computed: {
|
||||
asOf () {
|
||||
return moment(this.history.asOf).fromNow()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1,53 +0,0 @@
|
||||
<template lang="pug">
|
||||
div
|
||||
el-button(icon='plus' @click='openDialog()') Add a New Request
|
||||
el-dialog(title='Add a New Prayer Request' :visible.sync='showNewVisible')
|
||||
el-form(:model='form' :label-position='top')
|
||||
el-form-item(label='Prayer Request')
|
||||
el-input(type='textarea' v-model='form.requestText' :rows='10' @blur='trimText()')
|
||||
span.dialog-footer(slot='footer')
|
||||
el-button(@click='closeDialog()') Cancel
|
||||
el-button(type='primary' @click='saveRequest()') Save
|
||||
</template>
|
||||
|
||||
<script>
|
||||
'use strict'
|
||||
|
||||
import actions from '@/store/action-types'
|
||||
|
||||
export default {
|
||||
name: 'new-request',
|
||||
data () {
|
||||
return {
|
||||
showNewVisible: false,
|
||||
form: {
|
||||
requestText: ''
|
||||
},
|
||||
formLabelWidth: '120px'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
closeDialog () {
|
||||
this.form.requestText = ''
|
||||
this.showNewVisible = false
|
||||
},
|
||||
openDialog () {
|
||||
this.showNewVisible = true
|
||||
},
|
||||
trimText () {
|
||||
this.form.requestText = this.form.requestText.trim()
|
||||
},
|
||||
async saveRequest () {
|
||||
await this.$store.dispatch(actions.ADD_REQUEST, {
|
||||
progress: this.$Progress,
|
||||
requestText: this.form.requestText
|
||||
})
|
||||
this.$message({
|
||||
message: 'New prayer request added',
|
||||
type: 'success'
|
||||
})
|
||||
this.closeDialog()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
114
src/app/src/components/request/NotesEdit.vue
Normal file
114
src/app/src/components/request/NotesEdit.vue
Normal file
@@ -0,0 +1,114 @@
|
||||
<template lang="pug">
|
||||
.mpj-modal(v-show='notesVisible')
|
||||
.mpj-modal-content.mpj-narrow
|
||||
header.mpj-bg
|
||||
h5 Add Notes to Prayer Request
|
||||
label
|
||||
| Notes
|
||||
br
|
||||
textarea(v-model='form.notes'
|
||||
:rows='10'
|
||||
@blur='trimText()').mpj-full-width
|
||||
.mpj-text-right
|
||||
button(@click='saveNotes()').primary.
|
||||
#[md-icon(icon='save')] Save
|
||||
|
|
||||
button(@click='closeDialog()').
|
||||
#[md-icon(icon='undo')] Cancel
|
||||
hr
|
||||
div(v-if='hasPriorNotes')
|
||||
p.mpj-text-center: strong Prior Notes for This Request
|
||||
.mpj-note-list
|
||||
p(v-for='note in priorNotes'
|
||||
:key='note.asOf')
|
||||
small.mpj-muted-text: date-from-now(:value='note.asOf')
|
||||
br
|
||||
span.mpj-request-text {{ note.notes }}
|
||||
div(v-else-if='noPriorNotes').mpj-text-center.mpj-muted-text There are no prior notes for this request
|
||||
div(v-else).mpj-text-center
|
||||
button(@click='loadNotes()').
|
||||
#[md-icon(icon='cloud_download')] Load Prior Notes
|
||||
</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
|
||||
},
|
||||
async loadNotes () {
|
||||
this.$Progress.start()
|
||||
try {
|
||||
const notes = await api.getNotes(this.form.requestId)
|
||||
this.priorNotes = notes.data
|
||||
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
|
||||
},
|
||||
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>
|
||||
|
||||
<style>
|
||||
.mpj-note-list p {
|
||||
border-top: dotted 1px lightgray;
|
||||
}
|
||||
</style>
|
||||
93
src/app/src/components/request/RequestCard.vue
Normal file
93
src/app/src/components/request/RequestCard.vue
Normal file
@@ -0,0 +1,93 @@
|
||||
<template lang="pug">
|
||||
.mpj-request-card(v-if='shouldDisplay')
|
||||
header.mpj-card-header(role='toolbar').
|
||||
#[button(@click='markPrayed()' title='Pray').primary: md-icon(icon='done')]
|
||||
#[button(@click.stop='showEdit()' title='Edit'): md-icon(icon='edit')]
|
||||
#[button(@click.stop='showNotes()' title='Add Notes'): md-icon(icon='comment')]
|
||||
#[button(@click.stop='snooze()' title='Snooze Request'): md-icon(icon='schedule')]
|
||||
div
|
||||
p.card-text.mpj-request-text
|
||||
| {{ request.text }}
|
||||
p.as-of.mpj-text-right: small.mpj-muted-text: 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 }
|
||||
},
|
||||
computed: {
|
||||
shouldDisplay () {
|
||||
const now = Date.now()
|
||||
return Math.max(now, this.request.showAfter, this.request.snoozedUntil) === now
|
||||
}
|
||||
},
|
||||
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.$router.push({ name: 'EditRequest', params: { id: this.request.requestId } })
|
||||
},
|
||||
showNotes () {
|
||||
this.events.$emit('notes', this.request)
|
||||
},
|
||||
snooze () {
|
||||
this.events.$emit('snooze', this.request.requestId)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.mpj-request-card {
|
||||
border: solid 1px darkgray;
|
||||
border-radius: 5px;
|
||||
width: 20rem;
|
||||
margin: .5rem;
|
||||
}
|
||||
@media screen and (max-width: 20rem) {
|
||||
.mpj-request-card {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.mpj-card-header {
|
||||
display: flex;
|
||||
flex-flow: row;
|
||||
justify-content: center;
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(lightgray), to(whitesmoke));
|
||||
background-image: -webkit-linear-gradient(top, lightgray, whitesmoke);
|
||||
background-image: -moz-linear-gradient(top, lightgray, whitesmoke);
|
||||
background-image: linear-gradient(to bottom, lightgray, whitesmoke);
|
||||
}
|
||||
.mpj-card-header button {
|
||||
margin: .25rem;
|
||||
padding: 0 .25rem;
|
||||
}
|
||||
.mpj-card-header button .material-icons {
|
||||
font-size: 1.3rem;
|
||||
}
|
||||
.mpj-request-card .card-text {
|
||||
margin-left: 1rem;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
.mpj-request-card .as-of {
|
||||
margin-right: .25rem;
|
||||
}
|
||||
</style>
|
||||
@@ -1,62 +1,86 @@
|
||||
<template lang="pug">
|
||||
el-row.journal-request
|
||||
el-col(:span='4'): p
|
||||
el-button(icon='check' @click='markPrayed()' title='Pray')
|
||||
edit-request(:request='request')
|
||||
full-request(:request='request')
|
||||
el-col(:span='16'): p {{ text }}
|
||||
el-col(:span='4'): p: date-from-now(:value='request.asOf')
|
||||
p.mpj-request-text
|
||||
| {{ request.text }}
|
||||
br
|
||||
br
|
||||
button(@click='viewFull'
|
||||
title='View Full Request').
|
||||
#[md-icon(icon='description')] View Full Request
|
||||
|
|
||||
template(v-if='!isAnswered')
|
||||
button(@click='editRequest'
|
||||
title='Edit Request').
|
||||
#[md-icon(icon='edit')] Edit Request
|
||||
|
|
||||
template(v-if='isSnoozed')
|
||||
button(@click='cancelSnooze()').
|
||||
#[md-icon(icon='restore')] Cancel Snooze
|
||||
|
|
||||
template(v-if='isPending')
|
||||
button(@click='showNow()').
|
||||
#[md-icon(icon='restore')] Show Now
|
||||
br(v-if='isSnoozed || isPending || isAnswered')
|
||||
small(v-if='isSnoozed').mpj-muted-text: em.
|
||||
Snooze expires #[date-from-now(:value='request.snoozedUntil')]
|
||||
small(v-if='isPending').mpj-muted-text: em.
|
||||
Request scheduled to reappear #[date-from-now(:value='request.showAfter')]
|
||||
small(v-if='isAnswered').mpj-muted-text: em.
|
||||
Answered #[date-from-now(:value='request.asOf')]
|
||||
</template>
|
||||
|
||||
<script>
|
||||
'use strict'
|
||||
|
||||
import moment from 'moment'
|
||||
|
||||
import DateFromNow from '../common/DateFromNow'
|
||||
import EditRequest from './EditRequest'
|
||||
import FullRequest from './FullRequest'
|
||||
|
||||
import actions from '@/store/action-types'
|
||||
|
||||
export default {
|
||||
name: 'request-list-item',
|
||||
props: [ 'request' ],
|
||||
props: {
|
||||
request: { required: true },
|
||||
toast: { required: true }
|
||||
},
|
||||
data () {
|
||||
return { interval: null }
|
||||
},
|
||||
components: {
|
||||
DateFromNow,
|
||||
EditRequest,
|
||||
FullRequest
|
||||
},
|
||||
methods: {
|
||||
async markPrayed () {
|
||||
await this.$store.dispatch(actions.UPDATE_REQUEST, {
|
||||
progress: this.$Progress,
|
||||
requestId: this.request.requestId,
|
||||
status: 'Prayed',
|
||||
updateText: ''
|
||||
})
|
||||
this.$message({
|
||||
message: 'Request marked as prayed',
|
||||
type: 'success'
|
||||
})
|
||||
}
|
||||
return {}
|
||||
},
|
||||
computed: {
|
||||
asOf () {
|
||||
return moment(this.request.asOf).fromNow()
|
||||
answered () {
|
||||
return this.request.history.find(hist => hist.status === 'Answered').asOf
|
||||
},
|
||||
text () {
|
||||
return this.request.text.split('\n').join('<br>')
|
||||
isAnswered () {
|
||||
return this.request.lastStatus === 'Answered'
|
||||
},
|
||||
isPending () {
|
||||
return !this.isSnoozed && this.request.showAfter > Date.now()
|
||||
},
|
||||
isSnoozed () {
|
||||
return this.request.snoozedUntil > Date.now()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async cancelSnooze () {
|
||||
await this.$store.dispatch(actions.SNOOZE_REQUEST, {
|
||||
progress: this.$Progress,
|
||||
requestId: this.request.requestId,
|
||||
until: 0
|
||||
})
|
||||
this.toast.showToast('Request un-snoozed', { theme: 'success' })
|
||||
this.$parent.$emit('requestUnsnoozed')
|
||||
},
|
||||
editRequest () {
|
||||
this.$router.push({ name: 'EditRequest', params: { id: this.request.requestId } })
|
||||
},
|
||||
async showNow () {
|
||||
await this.$store.dispatch(actions.SHOW_REQUEST_NOW, {
|
||||
progress: this.$Progress,
|
||||
requestId: this.request.requestId,
|
||||
showAfter: Date.now()
|
||||
})
|
||||
this.toast.showToast('Recurrence skipped; request now shows in journal', { theme: 'success' })
|
||||
this.$parent.$emit('requestNowShown')
|
||||
},
|
||||
viewFull () {
|
||||
this.$router.push({ name: 'FullRequest', params: { id: this.request.requestId } })
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.journal-request {
|
||||
border-bottom: dotted 1px lightgray;
|
||||
}
|
||||
</style>
|
||||
|
||||
71
src/app/src/components/request/SnoozeRequest.vue
Normal file
71
src/app/src/components/request/SnoozeRequest.vue
Normal file
@@ -0,0 +1,71 @@
|
||||
<template lang="pug">
|
||||
.mpj-modal(v-show='snoozeVisible')
|
||||
.mpj-modal-content.mpj-skinny
|
||||
header.mpj-bg
|
||||
h5 Snooze Prayer Request
|
||||
p.mpj-text-center
|
||||
label
|
||||
= 'Until '
|
||||
input(v-model='form.snoozedUntil'
|
||||
type='date'
|
||||
autofocus)
|
||||
br
|
||||
.mpj-text-right
|
||||
button.primary(:disabled='!isValid'
|
||||
@click='snoozeRequest()').
|
||||
#[md-icon(icon='snooze')] Snooze
|
||||
|
|
||||
button(@click='closeDialog()').
|
||||
#[md-icon(icon='undo')] Cancel
|
||||
</template>
|
||||
|
||||
<script>
|
||||
'use strict'
|
||||
|
||||
import actions from '@/store/action-types'
|
||||
|
||||
export default {
|
||||
name: 'snooze-request',
|
||||
props: {
|
||||
toast: { required: true },
|
||||
events: { required: true }
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
snoozeVisible: false,
|
||||
form: {
|
||||
requestId: '',
|
||||
snoozedUntil: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.events.$on('snooze', this.openDialog)
|
||||
},
|
||||
computed: {
|
||||
isValid () {
|
||||
return !isNaN(Date.parse(this.form.snoozedUntil))
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
closeDialog () {
|
||||
this.form.requestId = ''
|
||||
this.form.snoozedUntil = ''
|
||||
this.snoozeVisible = false
|
||||
},
|
||||
openDialog (requestId) {
|
||||
this.form.requestId = requestId
|
||||
this.snoozeVisible = true
|
||||
},
|
||||
async snoozeRequest () {
|
||||
await this.$store.dispatch(actions.SNOOZE_REQUEST, {
|
||||
progress: this.$Progress,
|
||||
requestId: this.form.requestId,
|
||||
until: Date.parse(this.form.snoozedUntil)
|
||||
})
|
||||
this.toast.showToast(`Request snoozed until ${this.form.snoozedUntil}`, { theme: 'success' })
|
||||
this.closeDialog()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
59
src/app/src/components/request/SnoozedRequests.vue
Normal file
59
src/app/src/components/request/SnoozedRequests.vue
Normal file
@@ -0,0 +1,59 @@
|
||||
<template lang="pug">
|
||||
article.mpj-main-content(role='main')
|
||||
page-title(title='Snoozed Requests')
|
||||
div(v-if='loaded').mpj-request-list
|
||||
p.mpj-text-center(v-if='requests.length === 0'): em.
|
||||
No snoozed requests found; return to #[router-link(:to='{ name: "Journal" } ') your journal]
|
||||
request-list-item(v-for='req in requests'
|
||||
:key='req.requestId'
|
||||
:request='req'
|
||||
:toast='toast')
|
||||
p(v-else) Loading journal...
|
||||
</template>
|
||||
|
||||
<script>
|
||||
'use strict'
|
||||
|
||||
import { mapState } from 'vuex'
|
||||
|
||||
import actions from '@/store/action-types'
|
||||
|
||||
import RequestListItem from '@/components/request/RequestListItem'
|
||||
|
||||
export default {
|
||||
name: 'snoozed-requests',
|
||||
components: {
|
||||
RequestListItem
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
requests: [],
|
||||
loaded: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
toast () {
|
||||
return this.$parent.$refs.toast
|
||||
},
|
||||
...mapState(['journal', 'isLoadingJournal'])
|
||||
},
|
||||
created () {
|
||||
this.$on('requestUnsnoozed', this.ensureJournal)
|
||||
},
|
||||
methods: {
|
||||
async ensureJournal () {
|
||||
if (!Array.isArray(this.journal)) {
|
||||
this.loaded = false
|
||||
await this.$store.dispatch(actions.LOAD_JOURNAL, this.$Progress)
|
||||
}
|
||||
this.requests = this.journal
|
||||
.filter(req => req.snoozedUntil > Date.now())
|
||||
.sort((a, b) => a.snoozedUntil - b.snoozedUntil)
|
||||
this.loaded = true
|
||||
}
|
||||
},
|
||||
async mounted () {
|
||||
await this.ensureJournal()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1,5 +1,5 @@
|
||||
<template lang="pug">
|
||||
article
|
||||
article.mpj-main-content(role='main')
|
||||
pageTitle(title='Logging On')
|
||||
p Logging you on...
|
||||
</template>
|
||||
@@ -7,14 +7,10 @@ article
|
||||
<script>
|
||||
'use strict'
|
||||
|
||||
import PageTitle from '../common/PageTitle'
|
||||
import AuthService from '@/auth/AuthService'
|
||||
|
||||
export default {
|
||||
name: 'log-on',
|
||||
components: {
|
||||
PageTitle
|
||||
},
|
||||
created () {
|
||||
this.$Progress.start()
|
||||
new AuthService().handleAuthentication(this.$store, this.$router)
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
// The Vue build version to load with the `import` command
|
||||
// (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 VueToast from 'vue-toast'
|
||||
|
||||
import 'vue-toast/dist/vue-toast.min.css'
|
||||
|
||||
import App from './App'
|
||||
import router from './router'
|
||||
import store from './store'
|
||||
import DateFromNow from './components/common/DateFromNow'
|
||||
import MaterialDesignIcon from './components/common/MaterialDesignIcon'
|
||||
import PageTitle from './components/common/PageTitle'
|
||||
|
||||
Vue.config.productionTip = false
|
||||
|
||||
Vue.use(ElementUI)
|
||||
|
||||
Vue.use(VueProgressBar, {
|
||||
color: 'rgb(32, 160, 255)',
|
||||
color: 'yellow',
|
||||
failedColor: 'red',
|
||||
height: '5px',
|
||||
transition: {
|
||||
@@ -24,6 +26,11 @@ Vue.use(VueProgressBar, {
|
||||
}
|
||||
})
|
||||
|
||||
Vue.component('date-from-now', DateFromNow)
|
||||
Vue.component('md-icon', MaterialDesignIcon)
|
||||
Vue.component('page-title', PageTitle)
|
||||
Vue.component('toast', VueToast)
|
||||
|
||||
/* eslint-disable no-new */
|
||||
new Vue({
|
||||
el: '#app',
|
||||
|
||||
@@ -1,17 +1,82 @@
|
||||
'use strict'
|
||||
|
||||
import Vue from 'vue'
|
||||
import Router from 'vue-router'
|
||||
|
||||
import ActiveRequests from '@/components/request/ActiveRequests'
|
||||
import AnsweredRequests from '@/components/request/AnsweredRequests'
|
||||
import EditRequest from '@/components/request/EditRequest'
|
||||
import FullRequest from '@/components/request/FullRequest'
|
||||
import Home from '@/components/Home'
|
||||
import Journal from '@/components/Journal'
|
||||
import LogOn from '@/components/user/LogOn'
|
||||
import PrivacyPolicy from '@/components/legal/PrivacyPolicy'
|
||||
import SnoozedRequests from '@/components/request/SnoozedRequests'
|
||||
import TermsOfService from '@/components/legal/TermsOfService'
|
||||
|
||||
Vue.use(Router)
|
||||
|
||||
export default new Router({
|
||||
mode: 'history',
|
||||
scrollBehavior (to, from, savedPosition) {
|
||||
if (savedPosition) {
|
||||
return savedPosition
|
||||
} else {
|
||||
return { x: 0, y: 0 }
|
||||
}
|
||||
},
|
||||
routes: [
|
||||
{ path: '/', name: 'Home', component: Home },
|
||||
{ path: '/journal', name: 'Journal', component: Journal },
|
||||
{ path: '/user/log-on', name: 'LogOn', component: LogOn }
|
||||
{
|
||||
path: '/',
|
||||
name: 'Home',
|
||||
component: Home
|
||||
},
|
||||
{
|
||||
path: '/journal',
|
||||
name: 'Journal',
|
||||
component: Journal
|
||||
},
|
||||
{
|
||||
path: '/legal/privacy-policy',
|
||||
name: 'PrivacyPolicy',
|
||||
component: PrivacyPolicy
|
||||
},
|
||||
{
|
||||
path: '/legal/terms-of-service',
|
||||
name: 'TermsOfService',
|
||||
component: TermsOfService
|
||||
},
|
||||
{
|
||||
path: '/request/:id/edit',
|
||||
name: 'EditRequest',
|
||||
component: EditRequest,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: '/request/:id/full',
|
||||
name: 'FullRequest',
|
||||
component: FullRequest,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: '/requests/active',
|
||||
name: 'ActiveRequests',
|
||||
component: ActiveRequests
|
||||
},
|
||||
{
|
||||
path: '/requests/answered',
|
||||
name: 'AnsweredRequests',
|
||||
component: AnsweredRequests
|
||||
},
|
||||
{
|
||||
path: '/requests/snoozed',
|
||||
name: 'SnoozedRequests',
|
||||
component: SnoozedRequests
|
||||
},
|
||||
{
|
||||
path: '/user/log-on',
|
||||
name: 'LogOn',
|
||||
component: LogOn
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
@@ -6,5 +6,9 @@ export default {
|
||||
/** Action to load the user's prayer journal */
|
||||
LOAD_JOURNAL: 'load-journal',
|
||||
/** Action to update a request */
|
||||
UPDATE_REQUEST: 'update-request'
|
||||
UPDATE_REQUEST: 'update-request',
|
||||
/** Action to skip the remaining recurrence period */
|
||||
SHOW_REQUEST_NOW: 'show-request-now',
|
||||
/** Action to snooze a request */
|
||||
SNOOZE_REQUEST: 'snooze-request'
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
|
||||
@@ -9,7 +11,7 @@ import actions from './action-types'
|
||||
|
||||
Vue.use(Vuex)
|
||||
|
||||
this.auth0 = new AuthService()
|
||||
const auth0 = new AuthService()
|
||||
|
||||
const logError = function (error) {
|
||||
if (error.response) {
|
||||
@@ -33,7 +35,13 @@ const logError = function (error) {
|
||||
export default new Vuex.Store({
|
||||
state: {
|
||||
user: JSON.parse(localStorage.getItem('user_profile') || '{}'),
|
||||
isAuthenticated: this.auth0.isAuthenticated(),
|
||||
isAuthenticated: (() => {
|
||||
auth0.scheduleRenewal()
|
||||
if (auth0.isAuthenticated()) {
|
||||
api.setBearer(localStorage.getItem('id_token'))
|
||||
}
|
||||
return auth0.isAuthenticated()
|
||||
})(),
|
||||
journal: {},
|
||||
isLoadingJournal: false
|
||||
},
|
||||
@@ -65,10 +73,10 @@ export default new Vuex.Store({
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async [actions.ADD_REQUEST] ({ commit }, { progress, requestText }) {
|
||||
async [actions.ADD_REQUEST] ({ commit }, { progress, requestText, recurType, recurCount }) {
|
||||
progress.start()
|
||||
try {
|
||||
const newRequest = await api.addRequest(requestText)
|
||||
const newRequest = await api.addRequest(requestText, recurType, recurCount)
|
||||
commit(mutations.REQUEST_ADDED, newRequest.data)
|
||||
progress.finish()
|
||||
} catch (err) {
|
||||
@@ -92,10 +100,40 @@ export default new Vuex.Store({
|
||||
commit(mutations.LOADING_JOURNAL, false)
|
||||
}
|
||||
},
|
||||
async [actions.UPDATE_REQUEST] ({ commit }, { progress, requestId, status, updateText }) {
|
||||
async [actions.UPDATE_REQUEST] ({ commit, state }, { progress, requestId, status, updateText, recurType, recurCount }) {
|
||||
progress.start()
|
||||
try {
|
||||
await api.updateRequest({ requestId, status, updateText })
|
||||
let oldReq = (state.journal.filter(req => req.requestId === requestId) || [])[0] || {}
|
||||
if (status !== 'Updated' || oldReq.text !== updateText) {
|
||||
await api.updateRequest(requestId, status, updateText)
|
||||
}
|
||||
if (status === 'Updated' && (oldReq.recurType !== recurType || oldReq.recurCount !== recurCount)) {
|
||||
await api.updateRecurrence(requestId, recurType, recurCount)
|
||||
}
|
||||
const request = await api.getRequest(requestId)
|
||||
commit(mutations.REQUEST_UPDATED, request.data)
|
||||
progress.finish()
|
||||
} catch (err) {
|
||||
logError(err)
|
||||
progress.fail()
|
||||
}
|
||||
},
|
||||
async [actions.SHOW_REQUEST_NOW] ({ commit }, { progress, requestId, showAfter }) {
|
||||
progress.start()
|
||||
try {
|
||||
await api.showRequest(requestId, showAfter)
|
||||
const request = await api.getRequest(requestId)
|
||||
commit(mutations.REQUEST_UPDATED, request.data)
|
||||
progress.finish()
|
||||
} catch (err) {
|
||||
logError(err)
|
||||
progress.fail()
|
||||
}
|
||||
},
|
||||
async [actions.SNOOZE_REQUEST] ({ commit }, { progress, requestId, until }) {
|
||||
progress.start()
|
||||
try {
|
||||
await api.snoozeRequest(requestId, until)
|
||||
const request = await api.getRequest(requestId)
|
||||
commit(mutations.REQUEST_UPDATED, request.data)
|
||||
progress.finish()
|
||||
|
||||
22
src/app/static/silent.html
Normal file
22
src/app/static/silent.html
Normal 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>
|
||||
2886
src/app/yarn.lock
2886
src/app/yarn.lock
File diff suppressed because it is too large
Load Diff
31
src/sql/16-recurrence.sql
Normal file
31
src/sql/16-recurrence.sql
Normal file
@@ -0,0 +1,31 @@
|
||||
ALTER TABLE mpj.request
|
||||
ADD COLUMN "showAfter" BIGINT NOT NULL DEFAULT 0;
|
||||
ALTER TABLE mpj.request
|
||||
ADD COLUMN "recurType" VARCHAR(10) NOT NULL DEFAULT 'immediate';
|
||||
ALTER TABLE mpj.request
|
||||
ADD COLUMN "recurCount" SMALLINT NOT NULL DEFAULT 0;
|
||||
CREATE OR REPLACE VIEW mpj.journal AS
|
||||
SELECT
|
||||
request."requestId",
|
||||
request."userId",
|
||||
(SELECT "text"
|
||||
FROM mpj.history
|
||||
WHERE history."requestId" = request."requestId"
|
||||
AND "text" IS NOT NULL
|
||||
ORDER BY "asOf" DESC
|
||||
LIMIT 1) AS "text",
|
||||
(SELECT "asOf"
|
||||
FROM mpj.history
|
||||
WHERE history."requestId" = request."requestId"
|
||||
ORDER BY "asOf" DESC
|
||||
LIMIT 1) AS "asOf",
|
||||
(SELECT "status"
|
||||
FROM mpj.history
|
||||
WHERE history."requestId" = request."requestId"
|
||||
ORDER BY "asOf" DESC
|
||||
LIMIT 1) AS "lastStatus",
|
||||
request."snoozedUntil",
|
||||
request."showAfter",
|
||||
request."recurType",
|
||||
request."recurCount"
|
||||
FROM mpj.request;
|
||||
Reference in New Issue
Block a user