-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexander Simmerl
committed
Feb 22, 2017
1 parent
23075a0
commit 08f89ff
Showing
19 changed files
with
26,177 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Rule.Api exposing (listRules) | ||
|
||
import Http | ||
import RemoteData exposing (WebData, sendRequest) | ||
|
||
import Rule.Model exposing (Rule, decodeList) | ||
|
||
listRules : String -> Cmd (WebData (List Rule)) | ||
listRules appId = | ||
Http.get ("/api/apps/" ++ appId ++ "/rules") decodeList | ||
|> sendRequest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
module Rule.Model exposing (Rule, decodeList) | ||
|
||
import Dict exposing (Dict) | ||
import Json.Decode as Decode | ||
|
||
-- MODEL | ||
|
||
|
||
type alias Recipient = | ||
{ query : Dict String String | ||
, templates : Dict String String | ||
, urn : String | ||
} | ||
|
||
type alias Rule = | ||
{ active : Bool | ||
, deleted : Bool | ||
, ecosystem : Int | ||
, entity : Int | ||
, id : String | ||
, name : String | ||
, recipients : List Recipient | ||
} | ||
|
||
|
||
-- DECODERS | ||
|
||
|
||
decode : Decode.Decoder Rule | ||
decode = | ||
Decode.map7 Rule | ||
(Decode.field "active" Decode.bool) | ||
(Decode.field "deleted" Decode.bool) | ||
(Decode.field "ecosystem" Decode.int) | ||
(Decode.field "entity" Decode.int) | ||
(Decode.field "id" Decode.string) | ||
(Decode.field "name" Decode.string) | ||
(Decode.field "recipients" (Decode.list decodeRecipient)) | ||
|
||
decodeList : Decode.Decoder (List Rule) | ||
decodeList = | ||
Decode.at [ "rules" ] (Decode.list decode) | ||
|
||
decodeRecipient : Decode.Decoder Recipient | ||
decodeRecipient = | ||
Decode.map3 Recipient | ||
(Decode.field "query" (Decode.dict Decode.string)) | ||
(Decode.field "templates" (Decode.dict Decode.string)) | ||
(Decode.field "urn" Decode.string) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
module Rule.View exposing (viewRuleItem, viewRuleTable) | ||
|
||
import Html exposing (Html, a, h2, section, span, table, tbody, td, text, th, thead, tr) | ||
import Html.Attributes exposing (class, title) | ||
import Html.Events exposing (onClick) | ||
|
||
import Rule.Model exposing (Rule) | ||
|
||
|
||
viewRuleItem : msg -> Rule -> Html msg | ||
viewRuleItem msg rule = | ||
let | ||
activated = | ||
if rule.active then | ||
span [ class "nc-icon-glyph ui-1_check-circle-07" ] [] | ||
else | ||
span [ class "nc-icon-glyph ui-1_circle-remove" ] [] | ||
|
||
ecosystem = | ||
case rule.ecosystem of | ||
1 -> | ||
span [ class "nc-icon-outline design-2_apple", title "iOS" ] [] | ||
_ -> | ||
span [ class "nc-icon-outline ui-2_alert", title "unknown" ] [] | ||
|
||
entity = | ||
case rule.entity of | ||
0 -> | ||
span [ class "nc-icon-outline arrows-2_conversion", title "Connection" ] [] | ||
1 -> | ||
span [ class "nc-icon-outline ui-1_bell-53", title "event" ] [] | ||
2 -> | ||
span [ class "nc-icon-outline ui-1_database", title "Object" ] [] | ||
3 -> | ||
span [ class "nc-icon-outline ui-2_like", title "Reaction" ] [] | ||
_ -> | ||
span [ class "nc-icon-outline ui-2_alert", title "Unknown" ] [] | ||
|
||
in | ||
tr [ onClick msg ] | ||
[ td [ class "icon" ] [ activated ] | ||
, td [ class "icon" ] [ ecosystem ] | ||
, td [ class "icon" ] [ entity ] | ||
, td [ class "icon" ] [ text (toString (List.length rule.recipients)) ] | ||
, td [] [ text rule.name ] | ||
] | ||
|
||
viewRuleTable : (Rule -> Html msg) -> List Rule -> Html msg | ||
viewRuleTable item rules = | ||
let | ||
list = | ||
List.sortBy .entity rules | ||
in | ||
table [] | ||
[ thead [] | ||
[ tr [] | ||
[ th [ class "icon" ] [ text "active" ] | ||
, th [ class "icon" ] [ text "ecosystem" ] | ||
, th [ class "icon" ] [ text "entity" ] | ||
, th [ class "icon" ] [ text "recipients" ] | ||
, th [] [ text "name" ] | ||
] | ||
] | ||
, tbody [] (List.map item list) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.