Skip to content

Commit a9021ac

Browse files
committed
abuse flag
1 parent ae16e47 commit a9021ac

15 files changed

+177
-58
lines changed

openapi/src/Api.elm

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
module Api exposing
22
( Request
3+
, baseUrl
4+
, effect
5+
, map
36
, request
47
, send
5-
, effect
6-
, sendWithCustomError
78
, sendAndAlsoReceiveHeaders
9+
, sendWithCustomError
810
, task
9-
, map
10-
, baseUrl
1111
, withBasePath
12-
, withTimeout
13-
, withTracker
1412
, withBearerToken
1513
, withHeader
1614
, withHeaders
15+
, withTimeout
16+
, withTracker
1717
)
1818

1919
import Dict exposing (Dict)
@@ -26,8 +26,8 @@ import Task
2626
import Url.Builder
2727

2828

29-
type Request a =
30-
Request
29+
type Request a
30+
= Request
3131
{ method : String
3232
, headers : List ( String, Maybe String )
3333
, basePath : String
@@ -42,10 +42,10 @@ type Request a =
4242

4343
baseUrl : String
4444
baseUrl =
45-
"http://localhost:9000"
45+
"http://192.168.1.243:9000"
4646

4747

48-
request : String -> String -> List ( String, String ) -> List (String, Maybe String) -> List (String, Maybe String) -> Maybe Json.Encode.Value -> Json.Decode.Decoder a -> Request a
48+
request : String -> String -> List ( String, String ) -> List ( String, Maybe String ) -> List ( String, Maybe String ) -> Maybe Json.Encode.Value -> Json.Decode.Decoder a -> Request a
4949
request method path pathParams queryParams headerParams body decoder =
5050
Request
5151
{ method = method
@@ -191,9 +191,9 @@ withHeaders headers_ (Request req) =
191191
-- HELPER
192192

193193

194-
headers : List (String, Maybe String) -> List Http.Header
194+
headers : List ( String, Maybe String ) -> List Http.Header
195195
headers =
196-
List.filterMap (\(key, value) -> Maybe.map (Http.header key) value)
196+
List.filterMap (\( key, value ) -> Maybe.map (Http.header key) value)
197197

198198

199199
effectHeaders : List ( String, Maybe String ) -> List SimulatedEffect.Http.Header
@@ -205,16 +205,16 @@ interpolatePath : String -> List ( String, String ) -> List String
205205
interpolatePath rawPath pathParams =
206206
let
207207
interpolate =
208-
(\(name, value) path -> String.replace ("{" ++ name ++ "}") value path)
208+
\( name, value ) path -> String.replace ("{" ++ name ++ "}") value path
209209
in
210210
List.foldl interpolate rawPath pathParams
211211
|> String.split "/"
212212
|> List.drop 1
213213

214214

215-
queries : List (String, Maybe String) -> List Url.Builder.QueryParameter
215+
queries : List ( String, Maybe String ) -> List Url.Builder.QueryParameter
216216
queries =
217-
List.filterMap (\(key, value) -> Maybe.map (Url.Builder.string key) value)
217+
List.filterMap (\( key, value ) -> Maybe.map (Url.Builder.string key) value)
218218

219219

220220
expectJson : (Http.Error -> e) -> (Result e a -> msg) -> Json.Decode.Decoder a -> Http.Expect msg

src/Css/Graph.elm

+5
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ addressFlags vc =
9292
vc.theme.graph.addressFlags
9393

9494

95+
abuseFlag : Config -> List Style
96+
abuseFlag vc =
97+
vc.theme.graph.abuseFlag
98+
99+
95100
addressLabel : Config -> List Style
96101
addressLabel vc =
97102
property "fill" "currentColor"

src/Css/Search.elm

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ frame vc =
1818
++ vc.theme.search.frame
1919

2020

21-
textarea : Config -> List Style
22-
textarea vc =
21+
textarea : Config -> String -> List Style
22+
textarea vc input =
2323
[ overflow hidden
2424
, resize none
2525
, ex 50 |> width
2626
]
27-
++ vc.theme.search.textarea
27+
++ vc.theme.search.textarea input
2828

2929

3030
result : Config -> List Style

src/Plugin.elm

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ type alias Plugin =
2525
{ view :
2626
{ graph :
2727
{ address :
28-
{ flags : View.Config -> Value -> List (Svg Value)
28+
{ flags : View.Config -> Value -> ( Float, List (Svg Value) )
2929
, contextMenu : View.Config -> Id.AddressId -> Value -> Maybe Value -> List (Html Value)
3030
, properties : View.Config -> Value -> Value -> List (Html Value)
3131
}
3232
, entity :
33-
{ flags : View.Config -> Value -> List (Svg Value)
33+
{ flags : View.Config -> Value -> ( Float, List (Svg Value) )
3434
, contextMenu : View.Config -> Id.EntityId -> Value -> Maybe Value -> List (Html Value)
3535
, properties : View.Config -> Value -> Value -> List (Html Value)
3636
}

src/Plugin/View/Graph/Address.elm

+27-8
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,39 @@ import Msg.Graph exposing (Msg(..))
1111
import Plugin as Plugin exposing (..)
1212
import Plugin.Model as Plugin exposing (..)
1313
import Svg.Styled as Svg exposing (Svg)
14+
import Svg.Styled.Attributes as Svg
15+
import Tuple exposing (..)
16+
import Util.Graph
1417

1518

16-
flags : Plugins -> View.Config -> Address -> List (Svg Msg)
17-
flags plugins vc address =
19+
flags : Plugins -> View.Config -> Float -> Address -> List (Svg Msg)
20+
flags plugins vc offset address =
1821
plugins
1922
|> Dict.toList
20-
|> List.map
21-
(\( pid, plugin ) ->
23+
|> List.foldl
24+
(\( pid, plugin ) ( off, otherFlags ) ->
2225
Dict.get pid address.plugins
23-
|> Maybe.map (plugin.view.graph.address.flags vc)
24-
|> Maybe.withDefault []
25-
|> List.map (Svg.map (PluginMsg pid))
26+
|> Maybe.map
27+
(plugin.view.graph.address.flags vc)
28+
|> Maybe.map
29+
(\( pOff, pFlags ) ->
30+
let
31+
newOff =
32+
off + vc.theme.graph.flagsGap
33+
in
34+
pFlags
35+
|> List.map (Svg.map (PluginMsg pid))
36+
|> Svg.g
37+
[ Util.Graph.translate -newOff 0
38+
|> Svg.transform
39+
]
40+
|> (\f -> f :: otherFlags)
41+
|> pair (newOff + pOff)
42+
)
43+
|> Maybe.withDefault ( off, otherFlags )
2644
)
27-
|> List.concat
45+
( offset, [] )
46+
|> second
2847

2948

3049
properties : Plugins -> PluginStates -> PluginStates -> View.Config -> List (Html Msg)

src/Plugin/View/Graph/Entity.elm

+27-8
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,39 @@ import Msg.Graph exposing (Msg(..))
1111
import Plugin as Plugin exposing (..)
1212
import Plugin.Model as Plugin exposing (..)
1313
import Svg.Styled as Svg exposing (Svg)
14+
import Svg.Styled.Attributes as Svg
15+
import Tuple exposing (..)
16+
import Util.Graph
1417

1518

16-
flags : Plugins -> View.Config -> Entity -> List (Svg Msg)
17-
flags plugins vc entity =
19+
flags : Plugins -> View.Config -> Float -> Entity -> List (Svg Msg)
20+
flags plugins vc offset entity =
1821
plugins
1922
|> Dict.toList
20-
|> List.map
21-
(\( pid, plugin ) ->
23+
|> List.foldl
24+
(\( pid, plugin ) ( off, otherFlags ) ->
2225
Dict.get pid entity.plugins
23-
|> Maybe.map (plugin.view.graph.entity.flags vc)
24-
|> Maybe.withDefault []
25-
|> List.map (Svg.map (PluginMsg pid))
26+
|> Maybe.map
27+
(plugin.view.graph.entity.flags vc)
28+
|> Maybe.map
29+
(\( pOff, pFlags ) ->
30+
let
31+
newOff =
32+
off + vc.theme.graph.flagsGap
33+
in
34+
pFlags
35+
|> List.map (Svg.map (PluginMsg pid))
36+
|> Svg.g
37+
[ Util.Graph.translate -newOff 0
38+
|> Svg.transform
39+
]
40+
|> (\f -> f :: otherFlags)
41+
|> pair (newOff + pOff)
42+
)
43+
|> Maybe.withDefault ( off, otherFlags )
2644
)
27-
|> List.concat
45+
( offset, [] )
46+
|> second
2847

2948

3049
properties : Plugins -> PluginStates -> PluginStates -> View.Config -> List (Html Msg)

src/RecordSetter.elm

+10
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ s_abuseConcepts value__ record__ =
2929
{ record__ | abuseConcepts = value__ }
3030

3131

32+
s_abuseFlag : a -> { b | abuseFlag : a } -> { b | abuseFlag : a }
33+
s_abuseFlag value__ record__ =
34+
{ record__ | abuseFlag = value__ }
35+
36+
3237
s_accumulatedFaces : a -> { b | accumulatedFaces : a } -> { b | accumulatedFaces : a }
3338
s_accumulatedFaces value__ record__ =
3439
{ record__ | accumulatedFaces = value__ }
@@ -4494,6 +4499,11 @@ s_url value__ record__ =
44944499
{ record__ | url = value__ }
44954500

44964501

4502+
s_urlMaxLength : a -> { b | urlMaxLength : a } -> { b | urlMaxLength : a }
4503+
s_urlMaxLength value__ record__ =
4504+
{ record__ | urlMaxLength = value__ }
4505+
4506+
44974507
s_user : a -> { b | user : a } -> { b | user : a }
44984508
s_user value__ record__ =
44994509
{ record__ | user = value__ }

src/Theme/Graph.elm

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import Model.Graph exposing (NodeType)
88
type alias Graph =
99
{ root : List Style
1010
, addressFlags : List Style
11+
, abuseFlag : List Style
12+
, flagsGap : Float
1113
, addressLabel : List Style
1214
, addressRect : List Style
1315
, nodeFrame : NodeType -> Bool -> List Style
@@ -61,6 +63,8 @@ default : Graph
6163
default =
6264
{ root = []
6365
, addressFlags = []
66+
, abuseFlag = []
67+
, flagsGap = 5
6468
, addressLabel = []
6569
, addressRect = []
6670
, nodeFrame = \_ _ -> []

src/Theme/Search.elm

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Css exposing (Style)
66
type alias Search =
77
{ form : List Style
88
, frame : List Style
9-
, textarea : List Style
9+
, textarea : String -> List Style
1010
, result : List Style
1111
, resultGroup : List Style
1212
, resultGroupList : List Style
@@ -21,7 +21,7 @@ default : Search
2121
default =
2222
{ form = []
2323
, frame = []
24-
, textarea = []
24+
, textarea = \_ -> []
2525
, result = []
2626
, resultGroup = []
2727
, resultGroupList = []

src/View/Graph/Address.elm

+53-8
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,59 @@ getLabel vc gc addr =
176176

177177
flags : Plugins -> Config -> Graph.Config -> Address -> Svg Msg
178178
flags plugins vc gc addr =
179-
g
180-
[ Css.addressFlags vc |> css
181-
, Graph.padding
182-
/ 2
183-
|> translate (Graph.addressWidth - Graph.padding / 2)
184-
|> transform
185-
]
186-
(Plugin.View.Graph.Address.flags plugins vc addr |> Log.log "View.Graph.Address flags result")
179+
let
180+
af =
181+
abuseFlag vc addr
182+
183+
offset =
184+
if List.isEmpty af then
185+
0
186+
187+
else
188+
10
189+
in
190+
af
191+
++ (Plugin.View.Graph.Address.flags plugins vc offset addr |> Log.log "View.Graph.Address flags result")
192+
|> g
193+
[ Css.addressFlags vc |> css
194+
, Graph.padding
195+
/ 2
196+
|> translate Graph.addressWidth
197+
|> Util.Graph.scale 0.75
198+
|> transform
199+
]
200+
201+
202+
abuseFlag : Config -> Address -> List (Svg Msg)
203+
abuseFlag vc addr =
204+
let
205+
hasAbuse =
206+
.abuse >> Maybe.map (\_ -> True)
207+
in
208+
addr.userTag
209+
|> Maybe.andThen hasAbuse
210+
|> Maybe.Extra.orElseLazy
211+
(\_ ->
212+
case addr.address.tags |> Maybe.map (List.any (hasAbuse >> Maybe.withDefault False)) of
213+
Just True ->
214+
Just True
215+
216+
_ ->
217+
Nothing
218+
)
219+
|> Maybe.map
220+
(\_ ->
221+
[ Svg.path
222+
[ translate 5 0
223+
|> Util.Graph.scale 0.025
224+
|> transform
225+
, Css.abuseFlag vc |> css
226+
, d "M296 160H180.6l42.6-129.8C227.2 15 215.7 0 200 0H56C44 0 33.8 8.9 32.2 20.8l-32 240C-1.7 275.2 9.5 288 24 288h118.7L96.6 482.5c-3.6 15.2 8 29.5 23.3 29.5 8.4 0 16.4-4.4 20.8-12l176-304c9.3-15.9-2.2-36-20.7-36z"
227+
]
228+
[]
229+
]
230+
)
231+
|> Maybe.withDefault []
187232

188233

189234
links : Config -> Graph.Config -> Float -> Float -> Address -> Svg Msg

src/View/Graph/Entity.elm

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ flags plugins vc gc ent =
194194
|> Util.Graph.scale 0.75
195195
|> transform
196196
]
197-
(Plugin.View.Graph.Entity.flags plugins vc ent)
197+
(Plugin.View.Graph.Entity.flags plugins vc 0 ent)
198198

199199

200200
currency : Config -> Graph.Config -> Entity -> Svg Msg

src/View/Graph/Tag.elm

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ inputHovercard plugins vc tc model =
3131
[ Search.search plugins
3232
vc
3333
{ searchable = Search.SearchTagsOnly
34-
, css = Css.searchTextarea vc
34+
, css = \_ -> Css.searchTextarea vc
3535
, resultsAsLink = False
3636
, multiline = False
3737
, showIcon = False

src/View/Search.elm

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import View.Locale as Locale
2626

2727
type alias SearchConfig =
2828
{ searchable : Searchable
29-
, css : List Style
29+
, css : String -> List Style
3030
, resultsAsLink : Bool
3131
, multiline : Bool
3232
, showIcon : Bool
@@ -55,7 +55,7 @@ search plugins vc sc model =
5555
else
5656
input
5757
)
58-
[ sc.css |> css
58+
[ sc.css model.input |> css
5959
, autocomplete False
6060
, spellcheck False
6161
, Locale.string vc.locale "The search" |> title

0 commit comments

Comments
 (0)