Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Gepetto
dashboard
Commits
07ce94ba
Commit
07ce94ba
authored
Jul 11, 2018
by
Guilhem Saurel
Browse files
fix graph view
parent
d002e0ea
Pipeline
#915
failed with stages
in 6 minutes and 47 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
rainboard/templates/base.html
View file @
07ce94ba
...
...
@@ -8,6 +8,7 @@
{% block navbarleft %}
<li
class=
"nav-item"
><a
class=
"nav-link"
href=
"{% url 'rainboard:forges' %}"
>
Forges
</a></li>
<li
class=
"nav-item"
><a
class=
"nav-link"
href=
"{% url 'rainboard:namespaces' %}"
>
Namespaces
</a></li>
<li
class=
"nav-item"
><a
class=
"nav-link"
href=
"{% url 'rainboard:graph' %}"
>
Graph
</a></li>
<li
class=
"nav-item"
><a
class=
"nav-link"
href=
"{% url 'rainboard:contributors' %}"
>
Contributors
</a></li>
<li
class=
"nav-item"
><a
class=
"nav-link"
href=
"{% url 'rainboard:gepetto' %}"
>
Gepetto
</a></li>
{% endblock %}
...
...
rainboard/templates/rainboard/graph.html
0 → 100644
View file @
07ce94ba
{% extends 'base.html' %}
{% block content %}
<h1>
Graph
</h1>
<img
src=
"{% url 'rainboard:graph_svg' %}"
alt=
"graph"
/>
{% endblock %}
rainboard/urls.py
View file @
07ce94ba
from
django.urls
import
path
from
django.views.generic
import
RedirectView
from
django.views.generic
import
RedirectView
,
TemplateView
from
.
import
views
...
...
@@ -19,4 +19,6 @@ urlpatterns = [
path
(
'project/<str:slug>/.gitlab-ci.yml'
,
views
.
ProjectGitlabView
.
as_view
(),
name
=
'project-gitlab'
),
path
(
'doc'
,
views
.
json_doc
,
name
=
'doc'
),
path
(
'docker'
,
views
.
docker
,
name
=
'docker'
),
path
(
'graph.svg'
,
views
.
graph_svg
,
name
=
'graph_svg'
),
path
(
'graph'
,
TemplateView
.
as_view
(
template_name
=
'rainboard/graph.html'
),
name
=
'graph'
),
]
rainboard/views.py
View file @
07ce94ba
from
subprocess
import
PIPE
,
run
from
django.http.response
import
HttpResponse
,
JsonResponse
from
django.views.generic
import
DetailView
...
...
@@ -108,13 +110,13 @@ def docker(request):
def
graph
(
request
):
def
graph
_svg
(
request
):
with
open
(
'/tmp/graph'
,
'w'
)
as
f
:
print
(
'digraph {'
,
file
=
f
)
for
project
in
Project
.
objects
.
all
():
for
project
in
models
.
Project
.
objects
.
all
():
print
(
f
'{{I
{
project
.
pk
}
[label="
{
project
}
"];}}'
,
file
=
f
)
for
dep
in
Dependency
.
objects
.
all
():
for
dep
in
models
.
Dependency
.
objects
.
all
():
print
(
f
'I
{
dep
.
project
.
pk
}
-> I
{
dep
.
library
.
pk
}
;'
,
file
=
f
)
print
(
'}'
,
file
=
f
)
svg
=
run
([
'dot'
,
'/tmp/graph'
,
'-Tsvg'
],
capture_output
=
True
).
stdout
.
decode
()
svg
=
run
([
'dot'
,
'/tmp/graph'
,
'-Tsvg'
],
stdout
=
PIPE
).
stdout
.
decode
()
return
HttpResponse
(
svg
,
content_type
=
'image/svg+xml'
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment