Skip to content
This repository was archived by the owner on Sep 8, 2019. It is now read-only.

Commit 4185752

Browse files
Add proof-of-concept frontend in elm
Does get all, search, delete, update for users Written in elm because elm is not javascript This could use a lot of work.
1 parent 194bb1c commit 4185752

File tree

3 files changed

+561
-0
lines changed

3 files changed

+561
-0
lines changed

frontend/elm.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"type": "application",
3+
"source-directories": [
4+
"src"
5+
],
6+
"elm-version": "0.19.0",
7+
"dependencies": {
8+
"direct": {
9+
"NoRedInk/elm-json-decode-pipeline": "1.0.0",
10+
"cuducos/elm-format-number": "6.0.2",
11+
"elm/browser": "1.0.1",
12+
"elm/core": "1.0.2",
13+
"elm/html": "1.0.0",
14+
"elm/http": "2.0.0",
15+
"elm/json": "1.1.2",
16+
"elm/url": "1.0.0"
17+
},
18+
"indirect": {
19+
"elm/bytes": "1.0.7",
20+
"elm/file": "1.0.1",
21+
"elm/time": "1.0.0",
22+
"elm/virtual-dom": "1.0.2",
23+
"myrho/elm-round": "1.0.4"
24+
}
25+
},
26+
"test-dependencies": {
27+
"direct": {},
28+
"indirect": {}
29+
}
30+
}

frontend/src/Main.elm

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
module Main exposing (Model(..), Msg(..), Page(..), init, main, subscriptions, update, view)
2+
3+
import Browser
4+
import FormatNumber exposing (format)
5+
import FormatNumber.Locales exposing (usLocale)
6+
import Html exposing (Attribute, Html, div, h1, span, text, ul)
7+
import Http
8+
import Json.Decode as Decode exposing (Decoder, field, int, list, nullable, string)
9+
import Json.Decode.Pipeline exposing (required)
10+
import User
11+
12+
13+
main =
14+
Browser.element
15+
{ init = init
16+
, update = update
17+
, subscriptions = subscriptions
18+
, view = view
19+
}
20+
21+
22+
type Model
23+
= User User.UserModel
24+
25+
26+
type Msg
27+
= GotUserMsg User.UserMsg
28+
29+
30+
init : () -> ( Model, Cmd Msg )
31+
init i =
32+
let
33+
( userModel, userCmd ) =
34+
User.init i
35+
in
36+
( User userModel, Cmd.map GotUserMsg userCmd )
37+
38+
39+
type Page
40+
= Users
41+
42+
43+
update : Msg -> Model -> ( Model, Cmd Msg )
44+
update msg model =
45+
case ( msg, model ) of
46+
( GotUserMsg user_msg, User user_model ) ->
47+
let
48+
( userModel, userCmd ) =
49+
User.update user_msg user_model
50+
in
51+
( User userModel, Cmd.map GotUserMsg userCmd )
52+
53+
54+
subscriptions : Model -> Sub Msg
55+
subscriptions model =
56+
Sub.none
57+
58+
59+
view : Model -> Html Msg
60+
view model =
61+
case model of
62+
User user_model ->
63+
Html.map GotUserMsg (User.view user_model)

0 commit comments

Comments
 (0)