Skip to content

Commit 0c20de1

Browse files
committed
console: Some work to make the UI look more like it should. #376
1 parent 32d4d91 commit 0c20de1

File tree

4 files changed

+50
-30
lines changed

4 files changed

+50
-30
lines changed

console/html/console.css

+5-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
background: red;
1+
#user {
2+
position: fixed;
3+
z-index: 2;
4+
right: 70px;
5+
}

console/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
},
3232
"dependencies": {
3333
"@statebox/stbx-js": "0.0.31",
34-
"@statebox/style": "0.0.6",
34+
"@statebox/style": "0.0.9",
3535
"dagre": "^0.8.4",
3636
"firebaseui": "^4.5.0"
3737
}

console/src/Statebox/Console.purs

+42-26
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ import Effect.Aff.Class (class MonadAff)
1616
import Effect.Console (log)
1717
import Halogen as H
1818
import Halogen (ComponentHTML)
19-
import Halogen.HTML (HTML, p, text, br, span, div, ul, li, h2, h3, table, tr, th, td, button)
19+
import Halogen.HTML (HTML, a, p, text, br, span, div, ul, li, h2, h3, h4, nav, table, tr, th, td, button)
20+
import Halogen.HTML.Core (ClassName(..))
21+
import Halogen.HTML.Properties (classes)
2022
import Halogen.HTML.Events (onClick, onValueInput)
2123
import Halogen.Query.HalogenM (HalogenM)
2224

@@ -29,13 +31,22 @@ import Debug.Trace (spy)
2931
-- TODO
3032
fakeCustomerId = "TODO"
3133

32-
type ApiKey = { hex :: Hex, name :: String }
3334
type RootId = String -- TODO get from stbx-core
3435
type TxHash = Hex -- TODO get from stbx-core
3536
type Hex = String -- TODO get from stbx-core
3637

3738
--------------------------------------------------------------------------------
3839

40+
type ApiKey =
41+
{ name :: String
42+
, hex :: Hex
43+
, billingAccount :: Maybe BillingAccount
44+
}
45+
46+
type BillingAccount = Unit -- TODO tentative
47+
48+
--------------------------------------------------------------------------------
49+
3950
-- | projects are collections of root-transactions and are used to manage the public keys associated to those.
4051
type Project =
4152
{ name :: String
@@ -223,35 +234,38 @@ render state =
223234

224235
navMenuHtml :: m. MonadAff m => State -> ComponentHTML Action ChildSlots m
225236
navMenuHtml state =
226-
div []
227-
[ button [ onClick \e -> Just $ SelectRoute $ Home ] [ text "Home" ]
228-
, button [ onClick \e -> Just $ SelectRoute $ Projects ] [ text "Projects" ]
229-
, button [ onClick \e -> Just $ SelectRoute $ APIKeys ] [ text "API Keys" ]
230-
, button [ onClick \e -> Just $ SelectRoute $ Invoices fakeCustomerId ] [ text "Invoices" ]
231-
, button [ onClick \e -> Just $ SelectRoute $ Subscription ] [ text "Subscriptions" ]
232-
, button [ onClick \e -> Just $ SelectRoute $ Plan ] [ text "Plans" ]
237+
nav [ classes [ ClassName "stbx-menu" ] ]
238+
[ ul []
239+
[ text "Statebox Cloud Admin Console"
240+
, a [ onClick \e -> Just $ SelectRoute $ Home ] [ text "Home" ]
241+
, a [ onClick \e -> Just $ SelectRoute $ Projects ] [ text "Projects" ]
242+
, a [ onClick \e -> Just $ SelectRoute $ APIKeys ] [ text "API Keys" ]
243+
, a [ onClick \e -> Just $ SelectRoute $ Subscription ] [ text "Subscriptions" ]
244+
, a [ onClick \e -> Just $ SelectRoute $ Plan ] [ text "Plans" ]
245+
]
233246
]
234247

235248
contentHtml :: m. MonadAff m => State -> ComponentHTML Action ChildSlots m
236249
contentHtml state = case state.route of
237250
Home ->
238-
div []
239-
[ h2 [] [ text "Statebox Cloud Admin Console" ]
240-
241-
, h3 [] [ text "Projects" ]
242-
, ul [] $ Map.toUnfoldable state.projects <#> (\(projectId /\ project) ->
243-
li [] [ button [ onClick \e -> Just $ SelectRoute $ ProjectR projectId ] [ text project.name ] ])
244-
245-
, h3 [] [ text "Billing accounts" ]
246-
, ul [] $ customers <#> \customer ->
247-
li [] [ button [ onClick \e -> Just $ SelectRoute $ Account customer.id ] [ text $ fold customer.name ]
248-
, text $ fold customer.description
251+
div [ classes [ ClassName "container", ClassName "is-flex", ClassName "has-rows" ] ]
252+
[ h4 [] [ text "Projects" ]
253+
, ul [ classes [ ClassName "stbx-cards" ] ] $ Map.toUnfoldable state.projects <#> \(projectId /\ project) ->
254+
li [ onClick \e -> Just $ SelectRoute $ ProjectR projectId ]
255+
[ h3 [] [ text project.name ] ]
256+
257+
, h4 [] [ text "Billing accounts" ]
258+
, ul [ classes [ ClassName "stbx-cards" ] ] $ customers <#> \customer ->
259+
li [ onClick \e -> Just $ SelectRoute $ Account customer.id ]
260+
[ h3 [] [ text $ fold customer.name ]
261+
, p [] [ text $ fold customer.description ]
262+
]
263+
264+
, h4 [] [ text "API keys" ]
265+
, ul [ classes [ ClassName "stbx-cards" ] ] $ state.apiKeys <#> \key ->
266+
li [] [ h3 [] [ text key.name ]
267+
, p [] [ text key.hex ]
249268
]
250-
251-
, h3 [] [ text "API keys" ]
252-
, ul [] $ state.apiKeys <#> \key -> li [] [ p [] [ text key.name ]
253-
, p [] [ text key.hex ]
254-
]
255269
]
256270
where
257271
-- TODO in reality we should have multiple customers
@@ -281,6 +295,7 @@ contentHtml state = case state.route of
281295
, p [] [ button [ onClick \e -> Just $ CreateApiKey ] [ text "Create new API key" ] ]
282296
, ul [] $ state.apiKeys <#> \key -> li [] [ p [] [ text key.name ]
283297
, p [] [ text key.hex ]
298+
, p [] [ text $ show key.billingAccount ]
284299
, p [] [ button [ onClick \e -> Just $ DeprecateApiKey key ] [ text "Deprecate" ] ]
285300
]
286301
, p [] [ text "* Assign to a root" ]
@@ -296,7 +311,8 @@ contentHtml state = case state.route of
296311
]
297312
Account customerId ->
298313
div []
299-
[ h2 [] [ text "Customer" ]
314+
[ button [ onClick \e -> Just $ SelectRoute $ Invoices fakeCustomerId ] [ text "Invoices" ]
315+
, h2 [] [ text "Customer" ]
300316
, div [] (maybe [] (pure <<< customerHtml) state.customer)
301317
, h3 [] [ text "Customer's payment methods" ]
302318
, div [] (state.paymentMethods <#> paymentMethodHtml)

console/src/Statebox/Console/Main.purs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ main = runHalogenAff do
3434
, subscriptions: mempty
3535
, plans: mempty
3636
, accounts: [ { invoices: mempty } ]
37-
, apiKeys : [ { name: "My API key #1", hex: "01010101" }
38-
, { name: "My API key #2", hex: "02020202" }
37+
, apiKeys : [ { name: "My API key #1", hex: "01010101", billingAccount: Nothing }
38+
, { name: "My API key #2", hex: "02020202", billingAccount: Nothing }
3939
]
4040
, projects: exampleProjects
4141
, rootTransactions: ["00AA00", "00BB00", "00CC00" ]

0 commit comments

Comments
 (0)