Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
seki-seki committed Jul 14, 2017
2 parents 0e76477 + ea671eb commit 6838b5a
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 35 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.6
1.1.0-BETA
87 changes: 53 additions & 34 deletions src/cljs/job_streamer/console/components/root.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -349,43 +349,62 @@
(init-state [_]
{:errors nil
:username ""
:password ""})
(render-state [_ {:keys [username password errors]}]
:password ""
:oauth-providers {}})
(will-mount [_]
(api/request "/oauth" :GET
{:handler (fn [response]
(om/set-state! owner :oauth-providers response))}))
(render-state [_ {:keys [username password errors oauth-providers]}]
(html
[:div.full.height
[:div.ui.fixed.inverted.teal.menu
[:div.header.item [:img.ui.image {:alt "JobStreamer" :src "/img/logo.png"}]]]
[:div.main.grid.content.full.height
[:div.ui.middle.aligned.center.aligned.login.grid
[:div.column
[:h2.ui.header
[:div.content
[:img.ui.image {:src "/img/logo.png"}]]]
[:form.ui.large.login.form
(merge {:on-submit (fn [e]
(.preventDefault e)
(api/request (api/url-for "/auth") :POST
{:user/id username :user/password password}
{:handler #(set! (.-href js/location) "/")
:error-handler #(om/set-state! owner :errors (or (:messages %)
["A Control bus is NOT found."]))
:unauthorized-handler #(om/set-state! owner :errors (:messages %))}))}
(when errors {:class "error"}))
[:div.ui.stacked.segment
[:div.ui.error.message
(map #(vec [:p %]) errors)]
[:div.field
[:div.ui.left.icon.input
[:i.user.icon]
[:input {:type "text" :name "username" :id "username" :placeholder "User name" :value username
:on-change (fn [e]
(let [username (.. js/document (getElementById "username") -value)]
(om/set-state! owner :username username)))}]]]
[:div.field
[:div.ui.left.icon.input
[:i.lock.icon]
[:input {:type "password" :name "password" :id "password" :placeholder "Password" :value password
:on-change (fn [e]
(let [password (.. js/document (getElementById "password") -value)]
(om/set-state! owner :password password)))}]]]
[:button.ui.fluid.large.teal.submit.button{:type "submit"} "Login"]]]]]]])))
[:div.row
[:div.column
[:h2.ui.header
[:div.content
[:img.ui.image {:src "/img/logo.png"}]]]
[:form.ui.large.login.form
(merge {:on-submit (fn [e]
(.preventDefault e)
(api/request (api/url-for "/auth") :POST
{:user/id username :user/password password}
{:handler #(set! (.-href js/location) "/")
:error-handler #(om/set-state! owner :errors (or (:messages %)
["A Control bus is NOT found."]))
:unauthorized-handler #(om/set-state! owner :errors (:messages %))}))}
(when errors {:class "error"}))
[:div.ui.stacked.segment
[:div.ui.error.message
(map #(vec [:p %]) errors)]
[:div.field
[:div.ui.left.icon.input
[:i.user.icon]
[:input {:type "text" :name "username" :id "username" :placeholder "User name" :value username
:on-change (fn [e]
(let [username (.. js/document (getElementById "username") -value)]
(om/set-state! owner :username username)))}]]]
[:div.field
[:div.ui.left.icon.input
[:i.lock.icon]
[:input {:type "password" :name "password" :id "password" :placeholder "Password" :value password
:on-change (fn [e]
(let [password (.. js/document (getElementById "password") -value)]
(om/set-state! owner :password password)))}]]]
[:button.ui.fluid.large.teal.submit.button{:type "submit"} "Login"]]]]]
(when (not-empty oauth-providers)
[:div.row
[:div.column
[:div.ui.stacked.segments
(for [[id {:keys [name class-name]}] oauth-providers]
[:div.ui.segment
[:button.ui.fluid.large.button {:class (or class-name "teal")
:on-click (fn [e]
(.preventDefault e)
(set! (.-href js/location) (api/url-for (str "/oauth/" id))))}
[:i.icon {:class (or class-name "openid")}]
(str "Login using " name)]])]]])]]])))

0 comments on commit 6838b5a

Please sign in to comment.