mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Initial version.
Features: - Upload PDF files let them analyze - Manage meta data and items - See processing in webapp
This commit is contained in:
@ -1,15 +1,36 @@
|
||||
module Page.Home.Data exposing (..)
|
||||
|
||||
import Http
|
||||
import Comp.SearchMenu
|
||||
import Comp.ItemList
|
||||
import Comp.ItemDetail
|
||||
import Api.Model.ItemLightList exposing (ItemLightList)
|
||||
import Api.Model.ItemDetail exposing (ItemDetail)
|
||||
|
||||
type alias Model =
|
||||
{
|
||||
{ searchMenuModel: Comp.SearchMenu.Model
|
||||
, itemListModel: Comp.ItemList.Model
|
||||
, searchInProgress: Bool
|
||||
, itemDetailModel: Comp.ItemDetail.Model
|
||||
, viewMode: ViewMode
|
||||
}
|
||||
|
||||
emptyModel: Model
|
||||
emptyModel =
|
||||
{
|
||||
{ searchMenuModel = Comp.SearchMenu.emptyModel
|
||||
, itemListModel = Comp.ItemList.emptyModel
|
||||
, itemDetailModel = Comp.ItemDetail.emptyModel
|
||||
, searchInProgress = False
|
||||
, viewMode = Listing
|
||||
}
|
||||
|
||||
type Msg
|
||||
= Dummy
|
||||
= Init
|
||||
| SearchMenuMsg Comp.SearchMenu.Msg
|
||||
| ItemListMsg Comp.ItemList.Msg
|
||||
| ItemSearchResp (Result Http.Error ItemLightList)
|
||||
| DoSearch
|
||||
| ItemDetailMsg Comp.ItemDetail.Msg
|
||||
| ItemDetailResp (Result Http.Error ItemDetail)
|
||||
|
||||
type ViewMode = Listing | Detail
|
||||
|
@ -3,7 +3,98 @@ module Page.Home.Update exposing (update)
|
||||
import Api
|
||||
import Data.Flags exposing (Flags)
|
||||
import Page.Home.Data exposing (..)
|
||||
import Comp.SearchMenu
|
||||
import Comp.ItemList
|
||||
import Comp.ItemDetail
|
||||
import Util.Update
|
||||
|
||||
update: Flags -> Msg -> Model -> (Model, Cmd Msg)
|
||||
update flags msg model =
|
||||
(model, Cmd.none)
|
||||
case msg of
|
||||
Init ->
|
||||
Util.Update.andThen1
|
||||
[ update flags (SearchMenuMsg Comp.SearchMenu.Init)
|
||||
, update flags (ItemDetailMsg Comp.ItemDetail.Init)
|
||||
, doSearch flags
|
||||
]
|
||||
model
|
||||
|
||||
SearchMenuMsg m ->
|
||||
let
|
||||
nextState = Comp.SearchMenu.update flags m model.searchMenuModel
|
||||
newModel = {model | searchMenuModel = Tuple.first nextState.modelCmd}
|
||||
(m2, c2) = if nextState.stateChange then doSearch flags newModel else (newModel, Cmd.none)
|
||||
in
|
||||
(m2, Cmd.batch [c2, Cmd.map SearchMenuMsg (Tuple.second nextState.modelCmd)])
|
||||
|
||||
ItemListMsg m ->
|
||||
let
|
||||
(m2, c2, mitem) = Comp.ItemList.update flags m model.itemListModel
|
||||
cmd = case mitem of
|
||||
Just item ->
|
||||
Api.itemDetail flags item.id ItemDetailResp
|
||||
Nothing ->
|
||||
Cmd.none
|
||||
in
|
||||
({model | itemListModel = m2}, Cmd.batch [ Cmd.map ItemListMsg c2, cmd ])
|
||||
|
||||
ItemSearchResp (Ok list) ->
|
||||
let
|
||||
m = {model|searchInProgress = False, viewMode = Listing}
|
||||
in
|
||||
update flags (ItemListMsg (Comp.ItemList.SetResults list)) m
|
||||
|
||||
ItemSearchResp (Err err) ->
|
||||
({model|searchInProgress = False}, Cmd.none)
|
||||
|
||||
DoSearch ->
|
||||
doSearch flags model
|
||||
|
||||
ItemDetailMsg m ->
|
||||
let
|
||||
(m2, c2, nav) = Comp.ItemDetail.update flags m model.itemDetailModel
|
||||
newModel = {model | itemDetailModel = m2}
|
||||
newCmd = Cmd.map ItemDetailMsg c2
|
||||
in
|
||||
case nav of
|
||||
Comp.ItemDetail.NavBack ->
|
||||
doSearch flags newModel
|
||||
Comp.ItemDetail.NavPrev ->
|
||||
case Comp.ItemList.prevItem model.itemListModel m2.item.id of
|
||||
Just n ->
|
||||
(newModel, Cmd.batch [newCmd, Api.itemDetail flags n.id ItemDetailResp])
|
||||
Nothing ->
|
||||
(newModel, newCmd)
|
||||
Comp.ItemDetail.NavNext ->
|
||||
case Comp.ItemList.nextItem model.itemListModel m2.item.id of
|
||||
Just n ->
|
||||
(newModel, Cmd.batch [newCmd, Api.itemDetail flags n.id ItemDetailResp])
|
||||
Nothing ->
|
||||
(newModel, newCmd)
|
||||
Comp.ItemDetail.NavNextOrBack ->
|
||||
case Comp.ItemList.nextItem model.itemListModel m2.item.id of
|
||||
Just n ->
|
||||
(newModel, Cmd.batch [newCmd, Api.itemDetail flags n.id ItemDetailResp])
|
||||
Nothing ->
|
||||
doSearch flags newModel
|
||||
Comp.ItemDetail.NavNone ->
|
||||
(newModel, newCmd)
|
||||
|
||||
ItemDetailResp (Ok item) ->
|
||||
let
|
||||
m = {model | viewMode = Detail}
|
||||
in
|
||||
update flags (ItemDetailMsg (Comp.ItemDetail.SetItem item)) m
|
||||
|
||||
ItemDetailResp (Err err) ->
|
||||
let
|
||||
_ = Debug.log "Error" err
|
||||
in
|
||||
(model, Cmd.none)
|
||||
|
||||
doSearch: Flags -> Model -> (Model, Cmd Msg)
|
||||
doSearch flags model =
|
||||
let
|
||||
mask = Comp.SearchMenu.getItemSearch model.searchMenuModel
|
||||
in
|
||||
({model|searchInProgress = True, viewMode = Listing}, Api.itemSearch flags mask ItemSearchResp)
|
||||
|
@ -6,18 +6,69 @@ import Html.Events exposing (onClick)
|
||||
|
||||
import Page exposing (Page(..))
|
||||
import Page.Home.Data exposing (..)
|
||||
import Comp.SearchMenu
|
||||
import Comp.ItemList
|
||||
import Comp.ItemDetail
|
||||
import Data.Flags
|
||||
import Util.Html exposing (onClickk)
|
||||
|
||||
view: Model -> Html Msg
|
||||
view model =
|
||||
div [class "home-page ui fluid grid"]
|
||||
[div [class "three wide column"]
|
||||
[h3 [][text "Menu"]
|
||||
div [class "home-page ui padded grid"]
|
||||
[div [class "four wide column"]
|
||||
[div [class "ui top attached ablue-comp menu"]
|
||||
[h4 [class "header item"]
|
||||
[text "Search"
|
||||
]
|
||||
,div [class "right floated menu"]
|
||||
[a [class "item"
|
||||
,onClick DoSearch
|
||||
,href ""
|
||||
]
|
||||
[i [class "ui search icon"][]
|
||||
]
|
||||
]
|
||||
]
|
||||
,div [class "ui attached fluid segment"]
|
||||
[(Html.map SearchMenuMsg (Comp.SearchMenu.view model.searchMenuModel))
|
||||
]
|
||||
]
|
||||
,div [class "seven wide column", style "border-left" "1px solid"]
|
||||
[h3 [][text "List"]
|
||||
,div [class "twelve wide column"]
|
||||
[case model.viewMode of
|
||||
Listing ->
|
||||
if model.searchInProgress then resultPlaceholder
|
||||
else (Html.map ItemListMsg (Comp.ItemList.view model.itemListModel))
|
||||
Detail ->
|
||||
Html.map ItemDetailMsg (Comp.ItemDetail.view model.itemDetailModel)
|
||||
]
|
||||
]
|
||||
|
||||
resultPlaceholder: Html Msg
|
||||
resultPlaceholder =
|
||||
div [class "ui basic segment"]
|
||||
[div [class "ui active inverted dimmer"]
|
||||
[div [class "ui medium text loader"]
|
||||
[text "Searching …"
|
||||
]
|
||||
]
|
||||
,div [class "six wide column", style "border-left" "1px solid", style "height" "100vh"]
|
||||
[h3 [][text "DocView"]
|
||||
,div [class "ui middle aligned very relaxed divided basic list segment"]
|
||||
[div [class "item"]
|
||||
[div [class "ui fluid placeholder"]
|
||||
[div [class "full line"][]
|
||||
,div [class "full line"][]
|
||||
]
|
||||
]
|
||||
,div [class "item"]
|
||||
[div [class "ui fluid placeholder"]
|
||||
[div [class "full line"][]
|
||||
,div [class "full line"][]
|
||||
]
|
||||
]
|
||||
,div [class "item"]
|
||||
[div [class "ui fluid placeholder"]
|
||||
[div [class "full line"][]
|
||||
,div [class "full line"][]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
Reference in New Issue
Block a user