@@ -0,0 +1,256 @@
1+module Index.Dashboard exposing
6+import Html exposing (..)
7+import Html.Attributes exposing (class, href, style, title)
9+import Elm.Config as Config exposing (Config)
10+import Elm.License as License
11+import Elm.Repo as Repo exposing (Repo)
12+import Elm.Version as Version exposing (Version)
13+import Index.Icon as Icon
14+import Index.Navigator as Navigator exposing ((</>))
15+import Index.Project as Project exposing (Project, File(..))
16+import Index.Skeleton as Skeleton
25+ , status : ProjectStatus
26+ , directory : Status Directory
35+ , project : Project.Project
36+ , exactDeps : List (Package.Name, Version.Version)
50+type alias Directory =
53+ , readme : Maybe String
67+decoder : D.Decoder Directory
70+ (D.field "path" (D.list D.string))
71+ (D.field "dirs" (D.list D.string))
72+ (D.field "files" (D.list fileDecoder))
73+ (D.field "readme" (D.nullable D.string))
76+fileDecoder : D.Decoder File
79+ (D.field "name" D.string)
80+ (D.field "runnable" D.bool)
89+ div [ class "not-found" ]
90+ [ div [ style "font-size" "12em" ] [ text "404" ]
91+ , div [ style "font-size" "3em" ] [ text "Page not found" ]
101+ div [ class "waiting" ]
102+ [ img [ src "/_elm/waiting.gif" ] []
110+viewDirectory : Project -> Directory -> Html msg
111+viewDirectory project directory =
113+ [ Navigator.view pwd
114+ , section [ class "left-column" ]
115+ [ viewFiles directory.dirs directory.files
116+ , viewReadme directory.readme
118+ , section [ class "right-column" ]
119+ [ viewProjectSummary project
121+ , viewTestDeps project
123+ , div [ style "clear" "both" ] []
131+viewReadme : Maybe String -> Html msg
138+ Skeleton.readmeBox markdown
145+viewFiles : List String -> List File -> Html msg
146+viewFiles dirs files =
148+ { title = "File Navigation"
149+ , items = List.map viewDir dirs ++ List.map viewFile files
154+viewDir : String -> List (Html msg)
156+ [ a [ href dir ] [ Icon.folder, text dir ]
160+viewFile : File -> List (Html msg)
162+ [ a [ href name ] [ Icon.lookup name, text name ]
170+viewProjectSummary : Project.Project -> Html msg
171+viewProjectSummary project =
173+ Project.Browser info ->
175+ { title = "Source Directories"
176+ , items = List.map (\dir -> [text dir]) info.dirs
179+ -- TODO show estimated bundle size here
181+ Project.Package info ->
183+ { title = "Package Info"
185+ [ [ text ("Name: " ++ info.name) ]
186+ , [ text ("Version: " ++ Version.toString info.version) ]
187+ , [ text ("License: " ++ License.toString info.license) ]
197+viewDeps : ExactDeps -> Project.Project -> Html msg
198+viewDeps exactDeps project =
202+ Project.Browser info ->
203+ List.map (viewDependency exactDeps) info.deps
205+ Project.Package info ->
206+ List.map (viewDependency exactDeps) info.deps
209+ { title = "Dependencies"
210+ , items = dependencies
211+ , footer = Nothing -- TODO Just ("/_elm/dependencies", "Add more dependencies?")
215+viewTestDeps : ExactDeps -> Project.Project -> Html msg
216+viewTestDeps exactDeps project =
220+ Project.Browser info ->
221+ List.map (viewDependency exactDeps) info.testDeps
223+ Project.Package info ->
224+ List.map (viewDependency exactDeps) info.testDeps
227+ { title = "Test Dependencies"
228+ , items = dependencies
229+ , footer = Nothing -- TODO Just ("/_elm/test-dependencies", "Add more test dependencies?")
233+viewDependency : ExactDeps -> (Package.Name, vsn) -> List (Html msg)
234+viewDependency exactDeps (pkg, _) =
235+ case Dict.get (Package.toString pkg) exactDeps of
237+ [ div [ style "float" "left" ]
239+ , text (Package.toString pkg)
241+ , div [ style "float" "right" ] [ text "???" ]
245+ [ div [ style "float" "left" ]
247+ , a [ href (toPackageUrl pkg version) ] [ text (Package.toString pkg) ]
249+ , div [ style "float" "right" ] [ text (Version.toString version) ]
253+toPackageUrl : Package.Name -> Version.Version -> String
254+toPackageUrl name version =
255+ "http://package.elm-lang.org/packages/"
256+ ++ Package.toString name ++ "/" ++ Version.toString version