Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gabriel Silva Vinha
codespeed
Commits
43a95a36
Unverified
Commit
43a95a36
authored
Aug 23, 2017
by
str4d
Browse files
Add previous and next revision nav links to Changes view
Closes #174
parent
33b2a3d6
Changes
4
Hide whitespace changes
Inline
Side-by-side
codespeed/static/css/main.css
View file @
43a95a36
...
...
@@ -165,6 +165,18 @@ div#configbar span.options {
padding-right
:
1.8em
;
font-size
:
90%
;
white-space
:
nowrap
;
}
div
#configbar
input
{
margin-right
:
0
;
vertical-align
:
middle
;
}
div
#contentnav
a
{
font-size
:
small
;
padding-bottom
:
0.25em
;
}
div
#contentnav
a
:hover
{
text-decoration
:
underline
;
}
div
#contentnav
#previous
{
float
:
left
;
}
div
#contentnav
#next
{
float
:
right
;
}
div
#content
,
div
.about_content
{
margin-left
:
14.5em
;
text-align
:
center
;
...
...
codespeed/static/js/changes.js
View file @
43a95a36
...
...
@@ -5,10 +5,10 @@ var TIMELINE_URL = window.TIMELINE_URL, getLoadText = window.getLoadText;
var
currentproject
,
changethres
,
trendthres
,
projectmatrix
,
revisionboxes
=
{};
function
getConfiguration
()
{
function
getConfiguration
(
revision
)
{
return
{
tre
:
$
(
"
#trend option:selected
"
).
val
(),
rev
:
$
(
"
#revision option:selected
"
).
val
(),
rev
:
revision
||
$
(
"
#revision option:selected
"
).
val
(),
exe
:
$
(
"
input[name='executable']:checked
"
).
val
(),
env
:
$
(
"
input[name='environment']:checked
"
).
val
()
};
...
...
@@ -66,14 +66,40 @@ function updateTable() {
//Configure table as tablesorter
$
(
"
.tablesorter
"
).
tablesorter
({
widgets
:
[
'
zebra
'
]});
// Set prev and next links
$
(
"
#previous
"
).
click
(
function
()
{
refreshContentRev
(
$
(
"
#previous
"
).
data
(
"
revision
"
),
$
(
"
#previous
"
).
data
(
"
desc
"
)
);
});
$
(
"
#next
"
).
click
(
function
()
{
refreshContentRev
(
$
(
"
#next
"
).
data
(
"
revision
"
),
$
(
"
#next
"
).
data
(
"
desc
"
)
);
});
}
function
refreshContent
()
{
refreshContentTable
(
$
(
"
#revision option:selected
"
).
val
());
}
function
refreshContentRev
(
revision
,
desc
)
{
if
(
$
(
'
#revision option[value=
'
+
revision
+
'
]
'
).
length
==
0
)
{
$
(
"
#revision
"
).
append
(
$
(
"
<option value='
"
+
revision
+
"
'>
"
+
desc
+
"
</option>
"
));
}
$
(
"
#revision
"
).
val
(
revision
);
refreshContentTable
(
revision
);
}
function
refreshContentTable
(
revision
)
{
var
h
=
$
(
"
#content
"
).
height
();
//get height for loading text
$
(
"
#contentwrap
"
).
fadeOut
(
"
fast
"
,
function
()
{
$
(
this
).
show
();
$
(
this
).
html
(
getLoadText
(
"
Loading...
"
,
h
));
$
(
this
).
load
(
"
table/
"
,
$
.
param
(
getConfiguration
()),
function
()
{
updateTable
();
});
$
(
this
).
load
(
"
table/
"
,
$
.
param
(
getConfiguration
(
revision
)),
function
()
{
updateTable
();
});
});
}
...
...
codespeed/templates/codespeed/changes_table.html
View file @
43a95a36
{% load percentages %}
<div
id=
"contentnav"
>
{% if prev %}
<a
id=
"previous"
href=
"#"
data-revision=
"{{ prev.rev }}"
data-desc=
"{{ prev.desc }}"
>
← {{ prev.short_rev }}{% if prev.summary %} ({{ prev.summary }}){% endif %}
</a>
{% endif %}
{% if next %}
<a
id=
"next"
href=
"#"
data-revision=
"{{ next.rev }}"
data-desc=
"{{ next.desc }}"
>
{{ next.short_rev }}{% if next.summary %} ({{ next.summary }}){% endif %} →
</a>
{% endif %}
</div>
{% for units in tablelist %}
<table
class=
"tablesorter"
data-lessisbetter=
"{{ units.lessisbetter }}"
>
<thead>
...
...
codespeed/views.py
View file @
43a95a36
...
...
@@ -497,6 +497,47 @@ def getchangestable(request):
raise
Http404
()
selectedrev
=
get_object_or_404
(
Revision
,
commitid
=
request
.
GET
.
get
(
'rev'
),
branch__project
=
executable
.
project
)
prevrev
=
Revision
.
objects
.
filter
(
branch
=
selectedrev
.
branch
,
date__lt
=
selectedrev
.
date
,
).
order_by
(
'-date'
).
first
()
if
prevrev
:
try
:
summary
=
Report
.
objects
.
get
(
revision
=
prevrev
,
executable
=
executable
,
environment
=
environment
).
item_description
except
Report
.
DoesNotExist
:
summary
=
''
prevrev
=
{
'desc'
:
str
(
prevrev
),
'rev'
:
prevrev
.
commitid
,
'short_rev'
:
prevrev
.
get_short_commitid
(),
'summary'
:
summary
,
}
else
:
prevrev
=
None
nextrev
=
Revision
.
objects
.
filter
(
branch
=
selectedrev
.
branch
,
date__gt
=
selectedrev
.
date
,
).
order_by
(
'date'
).
first
()
if
nextrev
:
try
:
summary
=
Report
.
objects
.
get
(
revision
=
nextrev
,
executable
=
executable
,
environment
=
environment
).
item_description
except
Report
.
DoesNotExist
:
summary
=
''
nextrev
=
{
'desc'
:
str
(
nextrev
),
'rev'
:
nextrev
.
commitid
,
'short_rev'
:
nextrev
.
get_short_commitid
(),
'summary'
:
summary
,
}
else
:
nextrev
=
None
report
,
created
=
Report
.
objects
.
get_or_create
(
executable
=
executable
,
environment
=
environment
,
revision
=
selectedrev
...
...
@@ -515,6 +556,8 @@ def getchangestable(request):
'rev'
:
selectedrev
,
'exe'
:
executable
,
'env'
:
environment
,
'prev'
:
prevrev
,
'next'
:
nextrev
,
},
context_instance
=
RequestContext
(
request
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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