From dc2c9ef0f5fd41e2cb14cc921f1df6c1778ec373 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Tue, 19 Nov 2019 14:42:43 +0100 Subject: [PATCH 1/2] feat: webview --- api/dvmodel.proto | 2 +- gen.sum | 2 +- go.mod | 14 ++++----- go.sum | 28 ++++++++++++------ internal/dvcore/store.go | 9 ++++-- internal/dvserver/api.go | 3 +- static/depviz.js | 62 ++++++++++++++++++++++++++++++++++++---- static/index.html | 19 ++++++++---- tool/go.mod | 4 +++ tool/go.sum | 14 +++++++++ 10 files changed, 124 insertions(+), 33 deletions(-) diff --git a/api/dvmodel.proto b/api/dvmodel.proto index 288cb4b00..ad80b763f 100644 --- a/api/dvmodel.proto +++ b/api/dvmodel.proto @@ -157,4 +157,4 @@ message Batch { repeated Task tasks = 1; repeated Owner owners = 2; repeated Topic topics = 3; -} \ No newline at end of file +} diff --git a/gen.sum b/gen.sum index dbc3f999b..be65577b2 100644 --- a/gen.sum +++ b/gen.sum @@ -1,3 +1,3 @@ 32ff25c90d1d2680a429d90a796d7152f3bb7e6d Makefile -b5fbeef6563e56622e63d86a1b0d822237f1b305 ./api/dvmodel.proto +4668890e2f9fc8852ff7696d493dab0d644fc5f4 ./api/dvmodel.proto d8a569f515deddba8c2bbdcac334afee3529eee5 ./api/dvserver.proto diff --git a/go.mod b/go.mod index b2fa02fc8..8e7f41471 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/gogo/protobuf v1.3.1 github.com/golang/protobuf v1.3.2 github.com/google/go-github/v28 v28.1.1 - github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 + github.com/grpc-ecosystem/go-grpc-middleware v1.1.0 github.com/grpc-ecosystem/grpc-gateway v1.12.1 github.com/oklog/run v1.0.0 github.com/peterbourgon/ff v1.6.1-0.20190916204019-6cd704ec2eeb @@ -26,15 +26,15 @@ require ( go.uber.org/multierr v1.4.0 // indirect go.uber.org/zap v1.13.0 golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f // indirect - golang.org/x/net v0.0.0-20191116160921-f9c825593386 // indirect + golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 // indirect golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 - golang.org/x/sys v0.0.0-20191115151921-52ab43148777 // indirect - golang.org/x/tools v0.0.0-20191116214431-80313e1ba718 // indirect + golang.org/x/sys v0.0.0-20191119060738-e882bf8e40c2 // indirect + golang.org/x/tools v0.0.0-20191118222007-07fc4c7f2b98 // indirect google.golang.org/appengine v1.6.5 // indirect - google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c - google.golang.org/grpc v1.24.0 + google.golang.org/genproto v0.0.0-20191115221424-83cc0476cb11 + google.golang.org/grpc v1.25.1 gopkg.in/yaml.v2 v2.2.5 - gopkg.in/yaml.v3 v3.0.0-20191107175235-0b070bb63a18 // indirect + gopkg.in/yaml.v3 v3.0.0-20191119115237-b5595aa38866 // indirect moul.io/godev v1.3.0 moul.io/graphman v1.5.0 moul.io/graphman/viz v0.0.0-20190925205035-97b8bdad4639 diff --git a/go.sum b/go.sum index 086417883..365169395 100644 --- a/go.sum +++ b/go.sum @@ -32,6 +32,7 @@ github.com/cayleygraph/cayley v0.7.7/go.mod h1:VUd+PInYf94/VY41ePeFtFyP99BAs953k github.com/cayleygraph/quad v1.1.0 h1:w1nXAmn+nz07+qlw89dke9LwWkYpeX+OcvfTvGQRBpM= github.com/cayleygraph/quad v1.1.0/go.mod h1:maWODEekEhrO0mdc9h5n/oP7cH1h/OTgqQ2qWbuI9M4= github.com/cenkalti/backoff v2.1.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.0 h1:yTUvW7Vhb89inJ+8irsUqiWjh8iT6sQPZiQzI6ReGkA= @@ -78,6 +79,8 @@ github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25Kn github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/flimzy/diff v0.1.5/go.mod h1:lFJtC7SPsK0EroDmGTSrdtWKAxOk3rO+q+e04LL05Hs= github.com/flimzy/diff v0.1.6/go.mod h1:lFJtC7SPsK0EroDmGTSrdtWKAxOk3rO+q+e04LL05Hs= github.com/flimzy/kivik v1.8.1/go.mod h1:S2aPycbG0eDFll4wgXt9uacSNkXISPufutnc9sv+mdA= @@ -163,6 +166,8 @@ github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoA github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 h1:Iju5GlWwrvL6UBg4zJJt3btmonfrMlCDdsejg4CZE7c= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-middleware v1.1.0 h1:THDBEeQ9xZ8JEaCLyLQqXMMdRqNr0QAUJTIkQAUtFjg= +github.com/grpc-ecosystem/go-grpc-middleware v1.1.0/go.mod h1:f5nM7jw/oeRSadq3xCzHAvxcr8HZnzsqU6ILg/0NiiE= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.9.0 h1:bM6ZAFZmc/wPFaRDi0d5L7hGEZEx/2u+Tmr2evNHDiI= @@ -237,6 +242,7 @@ github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQ github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= github.com/opencontainers/selinux v1.0.0/go.mod h1:+BLncwf63G4dgOzykXAxcmnFlUaOlkDdmw/CqsW6pjs= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= github.com/ory/dockertest v3.3.4+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= @@ -397,8 +403,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190628185345-da137c7871d7 h1:rTIdg5QFRR7XCaK4LCjBiPbx8j4DQRpdYMnGn/bJUEU= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191116160921-f9c825593386 h1:ktbWvQrW08Txdxno1PiDpSxPXG6ndGsfnJjRRtkM0LQ= -golang.org/x/net v0.0.0-20191116160921-f9c825593386/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 h1:MlY3mEfbnWGmUi4rtHOtNnnnN4UJRGSyLPx+DXA5Sq4= +golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a h1:tImsplftrFpALCYumobsd0K86vlAs/eXGFms2txfJfA= @@ -429,8 +435,8 @@ golang.org/x/sys v0.0.0-20190614160838-b47fdc937951/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191009170203-06d7bd2c5f4f h1:hjzMYz/7Ea1mNKfOnFOfktR0mlA5jqhvywClCMHM/qw= golang.org/x/sys v0.0.0-20191009170203-06d7bd2c5f4f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191115151921-52ab43148777 h1:wejkGHRTr38uaKRqECZlsCsJ1/TGxIyFbH32x5zUdu4= -golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191119060738-e882bf8e40c2 h1:wAW1U21MfVN0sUipAD8952TBjGXMRHFKQugDlQ9RwwE= +golang.org/x/sys v0.0.0-20191119060738-e882bf8e40c2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= @@ -454,8 +460,8 @@ golang.org/x/tools v0.0.0-20191010075000-0337d82405ff h1:XdBG6es/oFDr1HwaxkxgVve golang.org/x/tools v0.0.0-20191010075000-0337d82405ff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191116214431-80313e1ba718 h1:cWviR33VVbwok1/RNvFm9XHNcdJCsaSocBflkEXrIdo= -golang.org/x/tools v0.0.0-20191116214431-80313e1ba718/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191118222007-07fc4c7f2b98 h1:tZwpOHmF1OEL9wJGSgBALnhFg/8VKjQTtctCX51GLNI= +golang.org/x/tools v0.0.0-20191118222007-07fc4c7f2b98/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= @@ -471,15 +477,21 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c h1:hrpEMCZ2O7DR5gC1n2AJGVhrwiEjOi35+jxtIuZpTMo= google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191115221424-83cc0476cb11 h1:51D++eCgOHufw5VfDE9Uzqyyc+OyQIjb9hkYy9LN5Fk= +google.golang.org/genproto v0.0.0-20191115221424-83cc0476cb11/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.24.0 h1:vb/1TCsVn3DcJlQ0Gs1yB1pKI6Do2/QNwxdKqmc/b0s= google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA= +google.golang.org/grpc v1.25.1 h1:wdKvqQk7IttEw92GoRyKG2IDrUIpgpj6H6m81yfeMW0= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= @@ -499,8 +511,8 @@ gopkg.in/yaml.v2 v2.2.5 h1:ymVxjfMaHvXD8RqPRmzHHsB3VvucivSkIAvJFDI5O3c= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20190709130402-674ba3eaed22 h1:0efs3hwEZhFKsCoP8l6dDB1AZWMgnEl3yWXWRZTOaEA= gopkg.in/yaml.v3 v3.0.0-20190709130402-674ba3eaed22/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20191107175235-0b070bb63a18 h1:VaaR1yHVgJQaTGM1DXum4OU6He6gaZXAPII85hHgSzQ= -gopkg.in/yaml.v3 v3.0.0-20191107175235-0b070bb63a18/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20191119115237-b5595aa38866 h1:pa/TcUpKdhpQ7j8rBo/jLESw0/lEhxakOmJX7Vm0G1g= +gopkg.in/yaml.v3 v3.0.0-20191119115237-b5595aa38866/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/internal/dvcore/store.go b/internal/dvcore/store.go index d3e3a8807..3dbcfacba 100644 --- a/internal/dvcore/store.go +++ b/internal/dvcore/store.go @@ -40,13 +40,16 @@ func GetStoreDump(ctx context.Context, h *cayley.Handle, schema *schema.Config) Topics: make([]*dvmodel.Topic, len(topics)), } for idx, owner := range owners { - dump.Owners[idx] = &owner + clone := owner + dump.Owners[idx] = &clone } for idx, task := range tasks { - dump.Tasks[idx] = &task + clone := task + dump.Tasks[idx] = &clone } for idx, topic := range topics { - dump.Topics[idx] = &topic + clone := topic + dump.Topics[idx] = &clone } return &dump, nil diff --git a/internal/dvserver/api.go b/internal/dvserver/api.go index e51ca8fd1..1179b7e78 100644 --- a/internal/dvserver/api.go +++ b/internal/dvserver/api.go @@ -39,7 +39,8 @@ func (s *service) Graph(ctx context.Context, in *Graph_Input) (*Graph_Output, er Tasks: make([]*dvmodel.Task, len(tasks)), } for idx, task := range tasks { - ret.Tasks[idx] = &task + clone := task + ret.Tasks[idx] = &clone } return &ret, nil } diff --git a/static/depviz.js b/static/depviz.js index 83a1412be..4e0ff4725 100644 --- a/static/depviz.js +++ b/static/depviz.js @@ -1,17 +1,67 @@ $(document).ready(function() { - $("#submit").click(function() { + $('#targets').focus(); + + let searchParams = new URLSearchParams(window.location.search); + if (searchParams.has("targets")) { + let targets = searchParams.get("targets"); + $('#targets').val(targets); $("#result").html("loading JSON..."); + let url = "/api/graph?targets=" + searchParams.get("targets"); + $.ajax({ - url: "/api/issues.json?targets=" + $("#targets").attr("value"), + url: url, success: function(result, status, xhr) { - console.dir(result); - $("#result").html(JSON.stringify(result)); - $("#image-link").attr("href", "/api/graph/image?targets=" + $("#targets").attr("value")); + var nodes = []; + var edges = []; + + result.tasks.forEach(task => { + let node = { + id: task.id, + label: task.local_id, + } + //if (task.has_owner !== undefined) { edges.push({from: task.has_owner, to: task.id}) } + //if (task.has_author !== undefined) { edges.push({from: task.has_author, to: task.id}) } + //if (task.has_milestone !== undefined) { edges.push({from: task.has_milestone, to: task.id}) } + if (task.is_depending_on !== undefined) { + task.is_depending_on.forEach(other => edges.push({ + from: task.id, + to: other, + relation: "is_depending_on", + arrows: "to", + color: {color: 'red'}, + })) + } + if (task.is_blocking !== undefined) { + task.is_blocking.forEach(other => edges.push({ + from: other, + to: task.id, + relation: "is_depending_on", + arrows: "to", + color: {color: 'red'}, + })) } + //if (task.has_assignee !== undefined) { task.has_assignee.forEach(other => edges.push({from: other, to: task.id})) } + //if (task.has_reviewer !== undefined) { task.has_reviewer.forEach(other => edges.push({from: other, to: task.id})) } + //if (task.has_label !== undefined) { task.has_label.forEach(other => edges.push({from: other, to: task.id})) } + //if (task.is_related_with !== undefined) { task.is_related_with.forEach(other => edges.push({from: other, to: task.id})) } + //if (task.is_part_of !== undefined) { task.is_part_of.forEach(other => edges.push({from: other, to: task.id})) } + //if (task.has_part !== undefined) { task.has_part.forEach(other => edges.push({from: other, to: task.id})) } + // console.log(task); + nodes.push(node) + }) + // create a network + var container = document.getElementById('network'); + var data = { + nodes: new vis.DataSet(nodes), + edges: new vis.DataSet(edges), + }; + var options = {}; + var network = new vis.Network(container, data, options); + console.log("network", network); }, error: function(xhr, status, error) { console.error("failed", xhr, status, error); alert("failed: " + error); }, }) - }); + } }); diff --git a/static/index.html b/static/index.html index 5b61dcbc4..3f75b289f 100644 --- a/static/index.html +++ b/static/index.html @@ -1,15 +1,22 @@ - DepViz + DepViz Web + +
+ + +
+
+
+ + - - -
- download image - diff --git a/tool/go.mod b/tool/go.mod index 1ad6ac1ff..9fdd73f61 100644 --- a/tool/go.mod +++ b/tool/go.mod @@ -4,6 +4,10 @@ go 1.13 require ( github.com/gilliek/go-opml v1.0.0 + github.com/golang/protobuf v1.3.2 // indirect github.com/google/go-github/v28 v28.1.1 + golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f // indirect + golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 // indirect golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 + google.golang.org/appengine v1.6.5 // indirect ) diff --git a/tool/go.sum b/tool/go.sum index e649047c3..a18313844 100644 --- a/tool/go.sum +++ b/tool/go.sum @@ -3,16 +3,25 @@ github.com/gilliek/go-opml v1.0.0 h1:X8xVjtySRXU/x6KvaiXkn7OV3a4DHqxY8Rpv6U/JvCY github.com/gilliek/go-opml v1.0.0/go.mod h1:fOxmtlzyBvUjU6bjpdjyxCGlWz+pgtAHrHf/xRZl3lk= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/google/go-github/v28 v28.1.1 h1:kORf5ekX5qwXO2mGzXXOjMe/g6ap8ahVe0sBEulhSxo= github.com/google/go-github/v28 v28.1.1/go.mod h1:bsqJWQX05omyWVmc00nEUql9mhQyv38lDZ8kPZcQVoM= github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f h1:kz4KIr+xcPUsI3VMoqWfPMvtnJ6MGfiVwsWSVzphMO4= +golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 h1:MlY3mEfbnWGmUi4rtHOtNnnnN4UJRGSyLPx+DXA5Sq4= +golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -20,7 +29,12 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 h1:bjcUS9ztw9kFmmIxJInhon/0Is3p+EHBKNgquIzo1OI= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= From c00ab8497215e87a27d7e5af6702a5aa1c096f44 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Tue, 19 Nov 2019 15:30:35 +0100 Subject: [PATCH 2/2] chore: improve webview styling --- static/depviz.js | 57 +++++++++++++++++++++++++++++++++++++---------- static/index.html | 11 +++++++++ 2 files changed, 56 insertions(+), 12 deletions(-) diff --git a/static/depviz.js b/static/depviz.js index 4e0ff4725..23032c852 100644 --- a/static/depviz.js +++ b/static/depviz.js @@ -1,12 +1,14 @@ $(document).ready(function() { $('#targets').focus(); - let searchParams = new URLSearchParams(window.location.search); + let searchParams = new URLSearchParams(window.location.search) if (searchParams.has("targets")) { - let targets = searchParams.get("targets"); - $('#targets').val(targets); - $("#result").html("loading JSON..."); - let url = "/api/graph?targets=" + searchParams.get("targets"); + let targets = searchParams.get("targets") + $('#targets').val(targets) + $("#result").html("loading JSON...") + let url = "/api/graph?targets=" + searchParams.get("targets") + let taskTemplate = $('#task-template').html() + Mustache.parse(taskTemplate) $.ajax({ url: url, @@ -15,10 +17,19 @@ $(document).ready(function() { var edges = []; result.tasks.forEach(task => { + // node + let svg = Mustache.render(taskTemplate, task) + let svgUrl = "data:image/svg+xml;charset=utf-8,"+encodeURIComponent(svg); let node = { id: task.id, - label: task.local_id, + image: svgUrl, + shape: 'image', + multi: 'html', } + nodes.push(node) + //console.log(task); + + // relationships //if (task.has_owner !== undefined) { edges.push({from: task.has_owner, to: task.id}) } //if (task.has_author !== undefined) { edges.push({from: task.has_author, to: task.id}) } //if (task.has_milestone !== undefined) { edges.push({from: task.has_milestone, to: task.id}) } @@ -45,18 +56,40 @@ $(document).ready(function() { //if (task.is_related_with !== undefined) { task.is_related_with.forEach(other => edges.push({from: other, to: task.id})) } //if (task.is_part_of !== undefined) { task.is_part_of.forEach(other => edges.push({from: other, to: task.id})) } //if (task.has_part !== undefined) { task.has_part.forEach(other => edges.push({from: other, to: task.id})) } - // console.log(task); - nodes.push(node) }) // create a network var container = document.getElementById('network'); var data = { - nodes: new vis.DataSet(nodes), - edges: new vis.DataSet(edges), + nodes: nodes, + edges: edges, + }; + var options = { + edges: { + smooth: { + forceDirection: 'none', + roundness: 0.8, + }, + length: 100, + }, + nodes: { + size: 24, + }, + physics: { + minVelocity: 0.1, + //solver: 'repulsion', + //solver: 'hierarchicalRepulsion', + solver: 'barnesHut', + barnesHut: { + avoidOverlap: 0.5, + }, + hierarchicalRepulsion: { + avoidOverlap: 0.6, + }, + stabilization: false, + }, }; - var options = {}; var network = new vis.Network(container, data, options); - console.log("network", network); + //console.log("network", network); }, error: function(xhr, status, error) { console.error("failed", xhr, status, error); diff --git a/static/index.html b/static/index.html index 3f75b289f..cb1db7f89 100644 --- a/static/index.html +++ b/static/index.html @@ -15,8 +15,19 @@
+ +