Files
docspell/modules/webapp/src/main/elm/Main.elm
Eike Kettner dd935454c9 First version of new ui based on tailwind
This drops fomantic-ui as css toolkit and introduces tailwindcss. With
tailwind there are no predefined components, but it's very easy to
create those. So customizing the look&feel is much simpler, most of
the time no additional css is needed.

This requires a complete rewrite of the markup + styles. Luckily all
logic can be kept as is. The now old ui is not removed, it is still
available by using a request header `Docspell-Ui` with a value of `1`
for the old ui and `2` for the new ui.

Another addition is "dev mode", where docspell serves assets with a
no-cache header, to disable browser caching. This makes developing a
lot easier.
2021-02-14 01:46:13 +01:00

96 lines
1.9 KiB
Elm

module Main exposing (init, main)
import Api
import App.Data exposing (..)
import App.Update exposing (..)
import App.View
import App.View2
import Browser exposing (Document)
import Browser.Navigation exposing (Key)
import Data.Flags exposing (Flags)
import Data.UiSettings
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Page exposing (Page(..))
import Ports
import Url exposing (Url)
-- MAIN
main : Program Flags Model Msg
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, ic ) =
App.Data.init key url flags Data.UiSettings.defaults
( m, cmd, s ) =
App.Update.initPage im im.page
in
( { m | subs = s }
, Cmd.batch
[ cmd
, ic
, Api.versionInfo flags VersionResp
, if Page.isSecured im.page then
Api.loginSession flags SessionCheckResp
else
Cmd.none
, Ports.getUiSettings flags
]
)
viewDoc : Model -> Document Msg
viewDoc model =
let
title =
case model.page of
ItemDetailPage _ ->
model.itemDetailModel.detail.item.name
_ ->
Page.pageName model.page
in
{ title = model.flags.config.appName ++ ": " ++ title
, body =
if model.flags.config.uiVersion == 2 then
App.View2.view model
else
[ App.View.view model
]
}
-- SUBSCRIPTIONS
subscriptions : Model -> Sub Msg
subscriptions model =
Sub.batch
[ model.subs
, Ports.loadUiSettings GetUiSettings
]