mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 19:08:26 +00:00
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.
96 lines
2.6 KiB
Elm
96 lines
2.6 KiB
Elm
module Page.Queue.Update exposing (update)
|
|
|
|
import Api
|
|
import Comp.YesNoDimmer
|
|
import Data.Flags exposing (Flags)
|
|
import Page.Queue.Data exposing (..)
|
|
import Ports
|
|
import Task
|
|
import Time
|
|
import Util.Http
|
|
|
|
|
|
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
|
|
update flags msg model =
|
|
case msg of
|
|
Init ->
|
|
let
|
|
start =
|
|
if model.init then
|
|
Cmd.none
|
|
|
|
else
|
|
Cmd.batch
|
|
[ Api.getJobQueueState flags StateResp
|
|
, getNewTime
|
|
]
|
|
in
|
|
( { model | init = True, stopRefresh = False }, start )
|
|
|
|
StateResp (Ok s) ->
|
|
let
|
|
refresh =
|
|
if model.pollingInterval <= 0 || model.stopRefresh then
|
|
Cmd.none
|
|
|
|
else
|
|
Cmd.batch
|
|
[ Api.getJobQueueStateIn flags model.pollingInterval StateResp
|
|
, getNewTime
|
|
]
|
|
in
|
|
( { model | state = s, stopRefresh = False }, refresh )
|
|
|
|
StateResp (Err err) ->
|
|
( { model | error = Util.Http.errorToString err }, Cmd.none )
|
|
|
|
StopRefresh ->
|
|
( { model | stopRefresh = True, init = False }, Cmd.none )
|
|
|
|
NewTime t ->
|
|
( { model | currentMillis = Time.posixToMillis t }, Cmd.none )
|
|
|
|
ShowLog job ->
|
|
( { model | showLog = Just job }, Cmd.none )
|
|
|
|
QuitShowLog ->
|
|
( { model | showLog = Nothing }, Cmd.none )
|
|
|
|
RequestCancelJob job ->
|
|
let
|
|
newModel =
|
|
{ model | cancelJobRequest = Just job.id }
|
|
in
|
|
update flags (DimmerMsg job Comp.YesNoDimmer.Activate) newModel
|
|
|
|
DimmerMsg job m ->
|
|
let
|
|
( cm, confirmed ) =
|
|
Comp.YesNoDimmer.update m model.deleteConfirm
|
|
|
|
cmd =
|
|
if confirmed then
|
|
Api.cancelJob flags job.id CancelResp
|
|
|
|
else
|
|
Cmd.none
|
|
in
|
|
( { model | deleteConfirm = cm }, cmd )
|
|
|
|
CancelResp (Ok _) ->
|
|
( model, Cmd.none )
|
|
|
|
CancelResp (Err _) ->
|
|
( model, Cmd.none )
|
|
|
|
ChangePrio id prio ->
|
|
( model, Api.setJobPrio flags id prio CancelResp )
|
|
|
|
SetQueueView v ->
|
|
( { model | queueView = v }, Cmd.none )
|
|
|
|
|
|
getNewTime : Cmd Msg
|
|
getNewTime =
|
|
Task.perform NewTime Time.now
|