mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Initial application stub
This commit is contained in:
58
modules/webapp/src/main/elm/Main.elm
Normal file
58
modules/webapp/src/main/elm/Main.elm
Normal file
@ -0,0 +1,58 @@
|
||||
module Main exposing (..)
|
||||
|
||||
import Browser exposing (Document)
|
||||
import Browser.Navigation exposing (Key)
|
||||
import Url exposing (Url)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (..)
|
||||
|
||||
import Api
|
||||
import Ports
|
||||
import Data.Flags exposing (Flags)
|
||||
import App.Data exposing (..)
|
||||
import App.Update exposing (..)
|
||||
import App.View exposing (..)
|
||||
|
||||
|
||||
-- MAIN
|
||||
|
||||
|
||||
main =
|
||||
Browser.application
|
||||
{ init = init
|
||||
, view = viewDoc
|
||||
, update = update
|
||||
, subscriptions = subscriptions
|
||||
, onUrlRequest = NavRequest
|
||||
, onUrlChange = NavChange
|
||||
}
|
||||
|
||||
|
||||
-- MODEL
|
||||
|
||||
|
||||
init : Flags -> Url -> Key -> (Model, Cmd Msg)
|
||||
init flags url key =
|
||||
let
|
||||
im = App.Data.init key url flags
|
||||
(m, cmd) = App.Update.initPage im im.page
|
||||
sessionCheck =
|
||||
case m.flags.account of
|
||||
Just acc -> Api.loginSession flags SessionCheckResp
|
||||
Nothing -> Cmd.none
|
||||
in
|
||||
(m, Cmd.batch [ cmd, Ports.initElements(), Api.versionInfo flags VersionResp, sessionCheck ])
|
||||
|
||||
viewDoc: Model -> Document Msg
|
||||
viewDoc model =
|
||||
{ title = model.flags.config.appName
|
||||
, body = [ (view model) ]
|
||||
}
|
||||
|
||||
-- SUBSCRIPTIONS
|
||||
|
||||
|
||||
subscriptions : Model -> Sub Msg
|
||||
subscriptions model =
|
||||
Sub.none
|
Reference in New Issue
Block a user