mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-04 10:29:34 +00:00
parent
c87163052b
commit
7cc290135a
@ -43,6 +43,7 @@ type alias Model =
|
||||
, newInviteModel : Page.NewInvite.Data.Model
|
||||
, itemDetailModel : Page.ItemDetail.Data.Model
|
||||
, navMenuOpen : Bool
|
||||
, userMenuOpen : Bool
|
||||
, subs : Sub Msg
|
||||
, uiSettings : UiSettings
|
||||
}
|
||||
@ -89,6 +90,7 @@ init key url flags_ settings =
|
||||
, newInviteModel = Page.NewInvite.Data.emptyModel
|
||||
, itemDetailModel = Page.ItemDetail.Data.emptyModel
|
||||
, navMenuOpen = False
|
||||
, userMenuOpen = False
|
||||
, subs = Sub.none
|
||||
, uiSettings = settings
|
||||
}
|
||||
@ -142,6 +144,7 @@ type Msg
|
||||
| LogoutResp (Result Http.Error ())
|
||||
| SessionCheckResp (Result Http.Error AuthResult)
|
||||
| ToggleNavMenu
|
||||
| ToggleUserMenu
|
||||
| GetUiSettings UiSettings
|
||||
|
||||
|
||||
|
@ -174,7 +174,29 @@ updateWithSub msg model =
|
||||
( model, Page.goto check, Sub.none )
|
||||
|
||||
ToggleNavMenu ->
|
||||
( { model | navMenuOpen = not model.navMenuOpen }
|
||||
( { model
|
||||
| navMenuOpen = not model.navMenuOpen
|
||||
, userMenuOpen =
|
||||
if not model.navMenuOpen then
|
||||
False
|
||||
|
||||
else
|
||||
model.userMenuOpen
|
||||
}
|
||||
, Cmd.none
|
||||
, Sub.none
|
||||
)
|
||||
|
||||
ToggleUserMenu ->
|
||||
( { model
|
||||
| userMenuOpen = not model.userMenuOpen
|
||||
, navMenuOpen =
|
||||
if not model.userMenuOpen then
|
||||
False
|
||||
|
||||
else
|
||||
model.navMenuOpen
|
||||
}
|
||||
, Cmd.none
|
||||
, Sub.none
|
||||
)
|
||||
|
@ -1,6 +1,7 @@
|
||||
module App.View exposing (view)
|
||||
|
||||
import App.Data exposing (..)
|
||||
import Data.Flags
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onClick)
|
||||
@ -16,7 +17,6 @@ import Page.Queue.View
|
||||
import Page.Register.View
|
||||
import Page.Upload.View
|
||||
import Page.UserSettings.View
|
||||
import Util.Maybe
|
||||
|
||||
|
||||
view : Model -> Html Msg
|
||||
@ -197,10 +197,51 @@ loginInfo : Model -> Html Msg
|
||||
loginInfo model =
|
||||
div [ class "right menu" ]
|
||||
(case model.flags.account of
|
||||
Just _ ->
|
||||
[ div
|
||||
Just acc ->
|
||||
[ a
|
||||
[ class "ui dropdown icon link item"
|
||||
, href "#"
|
||||
, onClick ToggleUserMenu
|
||||
, title ("Logged in as " ++ Data.Flags.accountString acc)
|
||||
]
|
||||
[ i [ class "user alternate icon" ] []
|
||||
, div
|
||||
[ classList
|
||||
[ ( "left menu", True )
|
||||
, ( "transition visible", model.userMenuOpen )
|
||||
, ( "transition hidden", not model.userMenuOpen )
|
||||
]
|
||||
]
|
||||
[ div [ class "header" ]
|
||||
[ i [ class "user outline icon" ] []
|
||||
, Data.Flags.accountString acc |> text
|
||||
]
|
||||
, div [ class "ui divider" ] []
|
||||
, menuEntry model
|
||||
CollectiveSettingPage
|
||||
[ i [ class "users circle icon" ] []
|
||||
, text "Collective Profile"
|
||||
]
|
||||
, menuEntry model
|
||||
UserSettingPage
|
||||
[ i [ class "user circle icon" ] []
|
||||
, text "User Profile"
|
||||
]
|
||||
, div [ class "divider" ] []
|
||||
, a
|
||||
[ class "icon item"
|
||||
, href ""
|
||||
, onClick Logout
|
||||
]
|
||||
[ i [ class "sign out icon" ] []
|
||||
, text "Logout"
|
||||
]
|
||||
]
|
||||
]
|
||||
, a
|
||||
[ class "ui dropdown icon link item"
|
||||
, onClick ToggleNavMenu
|
||||
, href "#"
|
||||
]
|
||||
[ i [ class "ui bars icon" ] []
|
||||
, div
|
||||
@ -220,17 +261,6 @@ loginInfo model =
|
||||
, text "Items"
|
||||
]
|
||||
, div [ class "divider" ] []
|
||||
, menuEntry model
|
||||
CollectiveSettingPage
|
||||
[ i [ class "users circle icon" ] []
|
||||
, text "Collective Profile"
|
||||
]
|
||||
, menuEntry model
|
||||
UserSettingPage
|
||||
[ i [ class "user circle icon" ] []
|
||||
, text "User Profile"
|
||||
]
|
||||
, div [ class "divider" ] []
|
||||
, menuEntry model
|
||||
ManageDataPage
|
||||
[ i [ class "cubes icon" ] []
|
||||
@ -277,15 +307,6 @@ loginInfo model =
|
||||
[ i [ class "external link icon" ] []
|
||||
]
|
||||
]
|
||||
, div [ class "divider" ] []
|
||||
, a
|
||||
[ class "icon item"
|
||||
, href ""
|
||||
, onClick Logout
|
||||
]
|
||||
[ i [ class "sign-out icon" ] []
|
||||
, text "Logout"
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
@ -1,6 +1,7 @@
|
||||
module Data.Flags exposing
|
||||
( Config
|
||||
, Flags
|
||||
, accountString
|
||||
, getToken
|
||||
, withAccount
|
||||
, withoutAccount
|
||||
@ -42,3 +43,12 @@ withAccount flags acc =
|
||||
withoutAccount : Flags -> Flags
|
||||
withoutAccount flags =
|
||||
{ flags | account = Nothing }
|
||||
|
||||
|
||||
accountString : AuthResult -> String
|
||||
accountString auth =
|
||||
if auth.collective == auth.user then
|
||||
auth.collective
|
||||
|
||||
else
|
||||
auth.collective ++ "/" ++ auth.user
|
||||
|
@ -65,7 +65,7 @@ view flags settings model =
|
||||
viewUsers settings model
|
||||
|
||||
Just InsightsTab ->
|
||||
viewInsights model
|
||||
viewInsights flags model
|
||||
|
||||
Just SettingsTab ->
|
||||
viewSettings flags settings model
|
||||
@ -77,14 +77,37 @@ view flags settings model =
|
||||
]
|
||||
|
||||
|
||||
viewInsights : Model -> List (Html Msg)
|
||||
viewInsights model =
|
||||
viewInsights : Flags -> Model -> List (Html Msg)
|
||||
viewInsights flags model =
|
||||
let
|
||||
( coll, user ) =
|
||||
Maybe.map (\a -> ( a.collective, a.user )) flags.account
|
||||
|> Maybe.withDefault ( "", "" )
|
||||
in
|
||||
[ h1 [ class "ui header" ]
|
||||
[ i [ class "chart bar outline icon" ] []
|
||||
, div [ class "content" ]
|
||||
[ text "Insights"
|
||||
]
|
||||
]
|
||||
, h2 [ class "ui sub header" ]
|
||||
[ div [ class "ui horizontal list" ]
|
||||
[ div
|
||||
[ class "item"
|
||||
, title "Collective"
|
||||
]
|
||||
[ i [ class "users circle icon" ] []
|
||||
, text coll
|
||||
]
|
||||
, div
|
||||
[ class "item"
|
||||
, title "User"
|
||||
]
|
||||
[ i [ class "user outline icon" ] []
|
||||
, text user
|
||||
]
|
||||
]
|
||||
]
|
||||
, div [ class "ui basic blue segment" ]
|
||||
[ h4 [ class "ui header" ]
|
||||
[ text "Items"
|
||||
|
Loading…
x
Reference in New Issue
Block a user