mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-04 10:29:34 +00:00
Show new data about spaces in web-ui
This commit is contained in:
parent
60a08fc786
commit
0365c1980a
@ -221,10 +221,19 @@ getSpaceDetail flags id receive =
|
||||
}
|
||||
|
||||
|
||||
getSpaces : Flags -> String -> (Result Http.Error SpaceList -> msg) -> Cmd msg
|
||||
getSpaces flags query receive =
|
||||
getSpaces : Flags -> String -> Bool -> (Result Http.Error SpaceList -> msg) -> Cmd msg
|
||||
getSpaces flags query owningOnly receive =
|
||||
Http2.authGet
|
||||
{ url = flags.config.baseUrl ++ "/api/v1/sec/space?q=" ++ Url.percentEncode query
|
||||
{ url =
|
||||
flags.config.baseUrl
|
||||
++ "/api/v1/sec/space?q="
|
||||
++ Url.percentEncode query
|
||||
++ (if owningOnly then
|
||||
"&owning=true"
|
||||
|
||||
else
|
||||
""
|
||||
)
|
||||
, account = getAccount flags
|
||||
, expect = Http.expectJson receive Api.Model.SpaceList.decoder
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import Comp.SpaceTable
|
||||
import Data.Flags exposing (Flags)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onClick, onInput)
|
||||
import Html.Events exposing (onCheck, onClick, onInput)
|
||||
import Http
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@ type alias Model =
|
||||
, spaces : List SpaceItem
|
||||
, users : List User
|
||||
, query : String
|
||||
, owningOnly : Bool
|
||||
, loading : Bool
|
||||
}
|
||||
|
||||
@ -40,6 +41,7 @@ type Msg
|
||||
| SpaceDetailResp (Result Http.Error SpaceDetail)
|
||||
| SetQuery String
|
||||
| InitNewSpace
|
||||
| ToggleOwningOnly
|
||||
|
||||
|
||||
empty : Model
|
||||
@ -49,6 +51,7 @@ empty =
|
||||
, spaces = []
|
||||
, users = []
|
||||
, query = ""
|
||||
, owningOnly = True
|
||||
, loading = False
|
||||
}
|
||||
|
||||
@ -58,7 +61,7 @@ init flags =
|
||||
( empty
|
||||
, Cmd.batch
|
||||
[ Api.getUsers flags UserListResp
|
||||
, Api.getSpaces flags "" SpaceListResp
|
||||
, Api.getSpaces flags empty.query empty.owningOnly SpaceListResp
|
||||
]
|
||||
)
|
||||
|
||||
@ -94,7 +97,7 @@ update flags msg model =
|
||||
|
||||
cmd =
|
||||
if back then
|
||||
Api.getSpaces flags model.query SpaceListResp
|
||||
Api.getSpaces flags model.query model.owningOnly SpaceListResp
|
||||
|
||||
else
|
||||
Cmd.none
|
||||
@ -117,7 +120,18 @@ update flags msg model =
|
||||
( model, Cmd.none )
|
||||
|
||||
SetQuery str ->
|
||||
( { model | query = str }, Api.getSpaces flags str SpaceListResp )
|
||||
( { model | query = str }
|
||||
, Api.getSpaces flags str model.owningOnly SpaceListResp
|
||||
)
|
||||
|
||||
ToggleOwningOnly ->
|
||||
let
|
||||
newOwning =
|
||||
not model.owningOnly
|
||||
in
|
||||
( { model | owningOnly = newOwning }
|
||||
, Api.getSpaces flags model.query newOwning SpaceListResp
|
||||
)
|
||||
|
||||
UserListResp (Ok ul) ->
|
||||
( { model | users = ul.items }, Cmd.none )
|
||||
@ -187,6 +201,17 @@ viewTable model =
|
||||
[]
|
||||
]
|
||||
]
|
||||
, div [ class "item" ]
|
||||
[ div [ class "ui checkbox" ]
|
||||
[ input
|
||||
[ type_ "checkbox"
|
||||
, onCheck (\_ -> ToggleOwningOnly)
|
||||
, checked model.owningOnly
|
||||
]
|
||||
[]
|
||||
, label [] [ text "Show owning spaces only" ]
|
||||
]
|
||||
]
|
||||
, div [ class "right menu" ]
|
||||
[ div [ class "item" ]
|
||||
[ a
|
||||
|
@ -8,10 +8,10 @@ module Comp.SpaceTable exposing
|
||||
)
|
||||
|
||||
import Api.Model.SpaceItem exposing (SpaceItem)
|
||||
import Api.Model.SpaceList exposing (SpaceList)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onClick)
|
||||
import Util.Html
|
||||
import Util.Time
|
||||
|
||||
|
||||
@ -48,6 +48,8 @@ view _ items =
|
||||
[ th [ class "collapsing" ] []
|
||||
, th [] [ text "Name" ]
|
||||
, th [] [ text "Owner" ]
|
||||
, th [] [ text "Owner or Member" ]
|
||||
, th [] [ text "#Member" ]
|
||||
, th [] [ text "Created" ]
|
||||
]
|
||||
, tbody []
|
||||
@ -75,6 +77,13 @@ viewItem item =
|
||||
, td []
|
||||
[ text item.owner.name
|
||||
]
|
||||
, td []
|
||||
[ Util.Html.checkbox item.isMember
|
||||
]
|
||||
, td []
|
||||
[ String.fromInt item.memberCount
|
||||
|> text
|
||||
]
|
||||
, td []
|
||||
[ Util.Time.formatDateShort item.created
|
||||
|> text
|
||||
|
Loading…
x
Reference in New Issue
Block a user