From 669ccd5ffceeccda045e7e50797753ae0eca4ee5 Mon Sep 17 00:00:00 2001 From: Michael Harding Date: Fri, 29 Jun 2018 10:50:32 -0400 Subject: [PATCH] SPARK-1428, SPARK-1430 --- src/web/ui/sass/main.scss | 22 +++++++++++++- src/web/ui/src/Accounts/Types.fs | 5 ++- src/web/ui/src/Accounts/View.fs | 52 ++++++++++++++------------------ src/web/ui/src/Users/State.fs | 2 +- src/web/ui/src/Users/View.fs | 28 ++++++----------- 5 files changed, 56 insertions(+), 53 deletions(-) diff --git a/src/web/ui/sass/main.scss b/src/web/ui/sass/main.scss index 696016156..17a1563d4 100644 --- a/src/web/ui/sass/main.scss +++ b/src/web/ui/sass/main.scss @@ -56,9 +56,29 @@ body { height: 100vh; } +.is-main-control-bar { + width:100%; + height:$tabs-height; + background:$grey-lighter; + overflow: hidden; + .is-light { + background:$grey-lighter; + border-right: 1px solid $grey-light; + &:hover { + background:$grey-light; + } + } + .is-danger-hover { + &:hover { + background: $red; + color: $white; + } + } +} + .is-tab-content { padding-left:3rem; - height: calc(100% - #{$tabs-height} - 1.5rem ); + height: calc(100% - #{$tabs-height} - #{$tabs-height} - 1.6rem); overflow: auto; input[type=text], input[type=password] { max-width: 43rem; diff --git a/src/web/ui/src/Accounts/Types.fs b/src/web/ui/src/Accounts/Types.fs index d9817eda2..43bd97d61 100644 --- a/src/web/ui/src/Accounts/Types.fs +++ b/src/web/ui/src/Accounts/Types.fs @@ -1,7 +1,6 @@ module Accounts.Types open bts.api.admin -open Fable.Core open bts.api open bts.api.orderman open JSMap @@ -9,8 +8,8 @@ open bts.co2 type Tab = | General - | ClipLimitsTab - | PositionLimitsTab + //| ClipLimitsTab + | LimitsTab | CreditLimitsTab | ExchangeSettingsTab | ConnectionsTab diff --git a/src/web/ui/src/Accounts/View.fs b/src/web/ui/src/Accounts/View.fs index 0b52324f3..237c98fe5 100644 --- a/src/web/ui/src/Accounts/View.fs +++ b/src/web/ui/src/Accounts/View.fs @@ -208,9 +208,9 @@ let clipLimitsView model dispatch = div [] [ div [ ClassName "columns" ][ + h1 [ ClassName "is-size-4 column is-narrow" ][str "Clip Limits" ] div [ ClassName "column is-size-7 has-text-grey-mid" ] [str "Clip limits can be set for one security, for all securities in a product (by selecting \"All\" for securities), or for all products within a security type (by selecting \"All\" for both symbol and security)"] - div [ ClassName "column" ][] ] TableControl.createDataTable (Some headerRow) rws span [ClassName "is-pulled-right"] [ Button.button "Add" "" "plus" Button.Enabled addRow ] @@ -482,8 +482,9 @@ let securityLimits model dispatch = ] -let positionLimitsView model dispatch = +let LimitsView model dispatch = div [] [ + clipLimitsView model dispatch productLimits model dispatch securityLimits model dispatch ] @@ -546,27 +547,30 @@ let tabContent model dispatch = div [Key (string model.scratch.id); ClassName "is-tab-content"] [ (match model.tab with | General -> generalView model dispatch - | ClipLimitsTab -> clipLimitsView model dispatch - | PositionLimitsTab -> positionLimitsView model dispatch + //| ClipLimitsTab -> clipLimitsView model dispatch + | LimitsTab -> LimitsView model dispatch | ConnectionsTab -> ConnectionsView model dispatch | CreditLimitsTab -> creditLimitsView model dispatch | ExchangeSettingsTab -> exchangeSettings model dispatch) ] -let accountControls selected (dispatch:Msg->unit) = +let accountControls model selected (dispatch:Msg->unit) = let remButton = match selected with - | None -> Button.button "Remove" "" "times" Disabled ignore - | Some acc -> Button.button "Remove" "" "times" Enabled (fun _ -> dispatch <| DeleteAccount acc) + | None -> Button.button "Remove Account" "is-light is-danger-hover" "times" Disabled ignore + | Some acc -> Button.button "Remove Account" "is-light is-danger-hover" "times" Enabled (fun _ -> dispatch <| DeleteAccount acc) + let revertFun = + match (selectedAccount model) with + | Some acc -> fun _ -> (dispatch <| SelectAccount acc) + | None -> ignore - div [ClassName "is-clearfix"] [ - p [ ClassName "" ][ - Button.button "Add" "" "plus" Enabled (fun _ -> dispatch AddAccount) - //nbsp.element - br [] + + div [ClassName "is-main-control-bar"] [ + saveButton model dispatch + Button.button "Revert" "is-light" "" (if isDirty model then Enabled else Disabled) revertFun + Button.button "Add Account" "is-light" "plus" Enabled (fun _ -> dispatch AddAccount) remButton - ] ] let isActive account = function @@ -590,7 +594,6 @@ let accountsMenu (accounts:BTSAccount[]) selectedAccount dispatch = str account.name] ] ] - accountControls selectedAccount dispatch ] ] @@ -625,8 +628,6 @@ let accountSelectionGrid (accountList:BTSAccount list) (currentAccount:BTSAccoun ] div[][ TableControl.createSelectorTable (Some headerRow) rws - accountControls (Some currentAccount) dispatch - //userControls usersList currentUser dispatch (not (State.userIsSelected currentUser State.defaultScratchUser)) ] @@ -672,12 +673,11 @@ let NavRoot (accounts:BTSAccount[]) selectedAccount dispatch = ] ] ] - accountControls selectedAccount dispatch ] let tabName = function - | ClipLimitsTab -> "Clip Limits" - | PositionLimitsTab -> "Position Limits" + //| ClipLimitsTab -> "Clip Limits" + | LimitsTab -> "Limits" | CreditLimitsTab -> "Credit Limits" | ConnectionsTab -> "Connections" | ExchangeSettingsTab -> "Exchange Settings" @@ -689,11 +689,6 @@ let tabHeader tab currentTab dispatch = ] let root (model:Model) dispatch = - let revertFun = - match (selectedAccount model) with - | Some acc -> fun _ -> (dispatch <| SelectAccount acc) - | None -> ignore - match model.adminData with | None -> div[][str "Loading account list..."] | Some data -> @@ -705,17 +700,14 @@ let root (model:Model) dispatch = div [ ClassName "tabs is-boxed" ] [ ul [] [ tabHeader General model.tab dispatch - tabHeader ClipLimitsTab model.tab dispatch - tabHeader PositionLimitsTab model.tab dispatch + //tabHeader ClipLimitsTab model.tab dispatch + tabHeader LimitsTab model.tab dispatch tabHeader ConnectionsTab model.tab dispatch // tabHeader CreditLimits model.tab dispatch tabHeader ExchangeSettingsTab model.tab dispatch ] ] - div [ ClassName "pull-right" ] [ - yield saveButton model dispatch - yield Button.button "Revert" "is-light" "" (if isDirty model then Enabled else Disabled) revertFun - ] tabContent model dispatch + accountControls model (selectedAccount model) dispatch ] ] \ No newline at end of file diff --git a/src/web/ui/src/Users/State.fs b/src/web/ui/src/Users/State.fs index 74b91b153..79a16a0f7 100644 --- a/src/web/ui/src/Users/State.fs +++ b/src/web/ui/src/Users/State.fs @@ -116,7 +116,7 @@ let getCurrentOrFirstUser (model:Model) (userList:BTSUser list) = | Some cu, _ -> cu | None, Some pu -> pu | None, None -> getFirstUser userList - | None, None -> defaultScratchUser + //| None, None -> defaultScratchUser let getCurrentUser (model:Model) = getCurrentOrFirstUser model model.userList diff --git a/src/web/ui/src/Users/View.fs b/src/web/ui/src/Users/View.fs index db262485c..76657f3af 100644 --- a/src/web/ui/src/Users/View.fs +++ b/src/web/ui/src/Users/View.fs @@ -161,14 +161,16 @@ let tabContent (model:Model) (dispatch:Msg->Unit) = | Tab.OrderRouting, true -> orderRoutingTabContent model dispatch) ] -let userControls (usersList:BTSUser list) (currentUser:BTSUser) (dispatch:Msg->Unit) (disabled:bool)= - div [ ClassName "is-pulled-right is-clearfix"; Style [Margin "1rem 2.5rem"] ] +let userControls (model:Model) (dispatch:Msg->Unit) = + let currentUser = State.getCurrentUser model + let dirty = State.userIsdirty State.defaultScratchUser model.scratchUser (State.getCurrentUser model) + + div [ ClassName "is-main-control-bar" ] [ - p [ ClassName "" ][ - Button.button "Add" "" "plus" Button.Enabled (fun _ -> dispatch <| AddUser) - //nbsp.element - //Button.button "Remove" "" "times" Button.Enabled (fun _ -> dispatch <| Delete currentUser) - ] + saveButton model dispatch + Button.button "Revert" "is-light" "" (if dirty then Button.Enabled else Button.Disabled) (fun _ -> SwitchUser (currentUser) |> dispatch) + Button.button "Add User" "is-light" "plus" Button.Enabled (fun _ -> dispatch <| AddUser) + Button.button "Remove User" "is-light is-danger-hover" "times" Button.Enabled (fun _ -> dispatch <| Delete currentUser) (*p [ ClassName "control" ] [ a [ ClassName "button is-light" Title "Clone" @@ -217,7 +219,6 @@ let usersMenu (usersList:BTSUser list) (currentUser:BTSUser) (dispatch:Msg->Unit ] ] - userControls usersList currentUser dispatch (not (State.userIsSelected currentUser State.defaultScratchUser)) ] ] @@ -252,7 +253,6 @@ let userSelectionGrid (usersList:BTSUser list) (currentUser:BTSUser) (dispatch:M ] div[][ TableControl.createSelectorTable (Some headerRow) rws - userControls usersList currentUser dispatch (not (State.userIsSelected currentUser State.defaultScratchUser)) ] @@ -277,7 +277,6 @@ let NavRoot (usersList:BTSUser list) (currentUser:BTSUser) (dispatch:Msg->Unit) ] ] ] - userControls usersList currentUser dispatch (not (State.userIsSelected currentUser State.defaultScratchUser)) ] let selectionPageContent (model:Model) (dispatch:Msg->Unit) = @@ -298,8 +297,6 @@ let selectionPageContent (model:Model) (dispatch:Msg->Unit) = let root (model:Model) (dispatch:Msg->Unit) = - let dirty = State.userIsdirty State.defaultScratchUser model.scratchUser (State.getCurrentUser model) - (match model.adminData with | None -> div[][str "Loading user list..."] | Some data -> @@ -325,13 +322,8 @@ let root (model:Model) (dispatch:Msg->Unit) = [ str "Order Routing" ] ] ] ] - div [ ClassName "pull-right" ] - [ - yield saveButton model dispatch - yield Button.button "Revert" "is-light" "" (if dirty then Button.Enabled else Button.Disabled) (fun _ -> SwitchUser (State.getCurrentUser model) |> dispatch) - ] tabContent model dispatch - + userControls model dispatch ] ]