Rerouted (regenerated, verified). Same repository and tag, but GitHub now builds the zip with different bytes, so it no longer matches the SHA-1 package.elm-lang.org recorded. The Lamdera package server serves a copy recovered from https://github.com/maca/postgrest-admin-preview.
What we checked: Rebuilt with git archive from commit 00bc53330d0e of https://github.com/maca/postgrest-admin-preview (zip prefix maca-postgrest-admin-preview-00bc533/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 689667c3e18fd2d53f7d18eba4757ba460f12795.
The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.
Details · package.elm-lang.org's zip: https://github.com/maca/postgrest-admin-preview/zipball/13.1.2/
Program configuration
PostgRestAdmin.application decoder with defaults.
main : PostgRestAdmin.Program Never Never
main =
PostgRestAdmin.application Config.initSpecify the postgREST host.
main : PostgRestAdmin.Program Never Never
main =
Config.init
|> Config.host "http://localhost:3000"
|> PostgRestAdmin.applicationAlternatively the host can be specified using flags, configuring using host.
Program flags take precedence.
Elm.Main.init({
flags: { host: "http://localhost:3000" }
})Specify a path prefix for all routes, in case the app is not mounted in the root path.
main : PostgRestAdmin.Program Never Never
main =
Config.init
|> Config.mountPoint "/back-office"
|> PostgRestAdmin.applicationAlternatively the host can be specified using flags, configuring using
mountPoint. Program flags take precedence.
Elm.Main.init({
flags: { mountPoint: "/back-office" }
})Specify which fields should be present in the the edit and create forms, overriding the table schema. By default a primary key field is not present in the forms.
main : PostgRestAdmin.Program Never Never
main =
Config.init
|> Config.formFields "posts" ["id", "title", "content"]
|> PostgRestAdmin.applicationAlternatively this parameter can be configured using flags, configuring using
formFields. Program flags take precedence.
Elm.Main.init({
flags: { formFields: { posts: [ "id", "title", "content" ]} }
})Specify a number of actions buttons to be shown in the detail page of a record along with Edit and Delete buttons.
detailActions expect a dict where the keys correspond with the name of a
table and the values are a list of tuples, the first element of the tuple
corresponds to the button text and the second is a function that takes the id of
the resource and returns a url string.
import Url.Builder as Url
main : PostgRestAdmin.Program Never Never
main =
Config.init
|> Config.detailActions "posts"
[ ( "View Comments"
, \_ id -> Url.absolute [ "posts", id, "comments" ] []
)
]
|> PostgRestAdmin.applicationPass a list of table names to restrict the editable resources, also sets the order of the left resources menu.
main : PostgRestAdmin.Program Never Never
main =
Config.init
|> Config.tables ["posts", "comments"]
|> PostgRestAdmin.applicationAlternatively the host can be specified using flags, configuring using
tables.
Program flags take precedence.
Elm.Main.init({
tables: ["posts", "comments"]
})Enable user credentials form and configure the parameters. Credentials are be used to obtain a JWT.
See FormAuth for configuration options.
import PostgRestAdmin.Config.FormAuth as FormAuth
main : PostgRestAdmin.Program Never Never
main =
Config.init
|> Config.formAuth FormAuth.config
|> PostgRestAdmin.applicationSet a JWT to authenticate postgREST requests. Even when using formAuth it's possible to set an initial JWT.
main : PostgRestAdmin.Program Never Never
main =
Config.init
|> Config.jwt "8abf3a...9ac36d"
|> PostgRestAdmin.applicationAlternatively the token can be passed using flags, configuring using jwt.
Program flags take precedence.
Elm.Main.init({
flags: { jwt: sessionStorage.getItem("jwt") }
})Callback triggered with a JWT string on successful login. Tipically used to persist the JWT to session storage.
port loginSuccess : String -> Cmd msg
main : PostgRestAdmin.Program Never Never
main =
Config.init
|> Config.onLogin loginSuccess
|> PostgRestAdmin.application// Elm init
app = Elm.Main.init({
flags: { jwt: sessionStorage.getItem("jwt") }
})
app.ports.loginSuccess.subscribe(jwt => {
sessionStorage.setItem("jwt", jwt)
});Callback triggered when authentication fails when attempting to perform a request. You can use to perform external authentication.
port authFailure : String -> Cmd msg
port tokenReceiver :
({ path : String, accessToken : String } -> msg)
-> Sub msg
main : PostgRestAdmin.Program Never Never
main =
Config.init
|> Config.withAuthFailed authFailed
|> Config.onExternalLogin tokenReceiver
|> PostgRestAdmin.application// Elm init
app = Elm.Main.init()
app.ports.authFailure.subscribe(requestedPath => {
authenticate(requestedPath).then((accessToken) => {
app.ports.tokenReceiver.send({
path : requestedPath,
accessToken : accessToken
})
})
});Subscribe to receive a JWT and a redirect path when login with an external provider.
See onAuthFailed.
Callback triggered when authentication fails when attempting to perform a request. You can use to perform external authentication.
port logout : () -> Cmd msg
main : PostgRestAdmin.Program Never Never
main =
Config.init
|> Config.onLogout logout
|> PostgRestAdmin.application// Elm init
app = Elm.Main.init()
app.ports.logout.subscribe(_ => {
externalLogout()
});Mount an application on a give path using Url.Parser. This is usefull if you want to override an existing page or add additional behaviour.
The component specification is similar to the specification for
Browser.element,
with the addition of onLogin param for which a msg should be provided to be
sent on successful login.
Note that the type signature changes from
PostgRestAdmin.Program Nothing Nothing.
Model and Msg are defined by your application.
The url parser should map to a Msg to be used to update your application when
navigating to this route built the parameters that the parser defines, you can
use
Url.Parser.oneOf
to parse many routes.
main : PostgRestAdmin.Program Model Msg
main =
Config.init
|> Config.routes
{ view = view
, update = update
, init = init
, onLogin = LoggedIn
}
(Parser.map MyPostLoadedMsg
(s "posts" </> Parser.string </> s "comments")
)
|> PostgRestAdmin.applicationThe application is initialized with a Client you can
use to perform requests.
PostgRestAdmin.application configuration params.