Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
bfdab6f5
Commit
bfdab6f5
authored
Jan 07, 2015
by
PkSM3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[UPDATE] paginator and ajax OK
parent
cbb9f8b9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
31 deletions
+69
-31
views.py
gargantext_web/views.py
+16
-0
corpus.html
templates/corpus.html
+42
-16
subcorpus.html
templates/subcorpus.html
+11
-15
No files found.
gargantext_web/views.py
View file @
bfdab6f5
...
...
@@ -503,6 +503,22 @@ def subcorpusJSON(request, project_id, corpus_id, start , end ):
return
HttpResponse
(
serializer
.
data
,
content_type
=
'application/json'
)
# for pagexample.html
from
django.core.paginator
import
Paginator
,
InvalidPage
,
EmptyPage
def
get_pagination_page
(
page
=
1
):
items
=
range
(
0
,
100
)
paginator
=
Paginator
(
items
,
10
)
try
:
page
=
int
(
page
)
except
ValueError
:
page
=
1
try
:
items
=
paginator
.
page
(
page
)
except
(
EmptyPage
,
InvalidPage
):
items
=
paginator
.
page
(
paginator
.
num_pages
)
return
items
...
...
templates/corpus.html
View file @
bfdab6f5
...
...
@@ -80,16 +80,9 @@
<div
id=
"collapseOne"
class=
"panel-collapse collapse"
role=
"tabpanel"
>
<div
class=
"panel-body"
>
<p
align=
"right"
>
Page
<a
href=
"#"
>
2
</a>
sur 100
</p>
</center>
{% if documents %}
<ul>
{% for doc in documents %}
<li>
<b>
{{ doc.date }}
</b>
,
<a
href=
"/admin/node/document/{{doc.id}}"
>
{{ doc.title}}
</a></li>
{% endfor %}
</ul>
{% endif %}
<!--{% include "subcorpus.html" %}-->
<div
id=
"subcorpusdiv"
></div>
</div>
</div>
...
...
@@ -161,14 +154,47 @@ function dateToInt(todayTime) {
}
function
updateDocuments
()
{
if
(
!
datesbuffer
)
return
;
// I've clicked "Read Documents":
function
updateDocuments
(
pagenumber
,
pagenav
)
{
pagenav
=
(
pagenav
)?
pagenav
:
true
;
pagenumber
=
(
pagenumber
)?
pagenumber
:
1
;
pr
(
"in here pagenav:"
+
pagenav
+
" - pagenumber:"
+
pagenumber
)
pr
(
$
(
"#collapseOne"
).
height
())
// if "Read Documents" collapsible is close, then... show some me pubs!
if
(
pagenav
||
$
(
"#collapseOne"
).
height
()
<
50
)
{
// Here u ask for the server some paginated results (pubs)
// if u havent select a timerange from the blue chart, then show me all pubs
if
(
!
datesbuffer
)
{
console
.
log
(
"nothing cause dont wanna"
)
}
// there's some timerange selected in the blue chart, so show me the pubs of that period
else
{
var
dataini
=
dateToInt
(
datesbuffer
[
0
])
var
datafin
=
dateToInt
(
datesbuffer
[
1
])
//http://localhost:8000/project/37525/corpus/37526/timerange/20040117/20040125?page=1
var
base
=
window
.
location
.
href
;
var
theurl
=
base
+
"timerange/"
+
dataini
+
"/"
+
datafin
+
"?page="
+
pagenumber
;
pr
(
"theurl: "
+
theurl
)
$
.
ajax
({
url
:
theurl
,
success
:
function
(
data
)
{
// console.log(data)
$
(
'#subcorpusdiv'
).
html
(
data
);
}
});
}
}
//else: "Read Documents" collapsible is open!, so do nothing
var
dataini
=
dateToInt
(
datesbuffer
[
0
])
var
datafin
=
dateToInt
(
datesbuffer
[
1
])
//http://localhost:8000/project/37525/corpus/37526/timerange/20040117/20040125?page=1
pr
(
"make_ajax_query"
+
window
.
location
.
href
+
"timerange/"
+
dataini
+
"/"
+
datafin
+
"?page=1"
)
}
...
...
templates/subcorpus.html
View file @
bfdab6f5
...
...
@@ -4,23 +4,10 @@
<p>
Today: {{date}}
</p>
{% endif %}
{% if documents %}
<p>
Paginator stuff
</p>
<ul>
{% for doc in documents %}
{% if doc.date %}
<li>
<b>
{{ doc.date }}
</b>
,
<a
href=
"/admin/node/document/{{doc.id}}"
>
id:{{ doc.id}} title:{{ doc.name}}
</a></li>
{% endif %}
{% endfor %}
</ul>
<div
class=
"pagination"
>
<span
class=
"step-links"
>
{% if documents.has_previous %}
<a
href=
"?page={{ documents.previous_page_number }}
"
>
previous
</a>
<a
onclick=
"updateDocuments({{ documents.previous_page_number }},true);
"
>
previous
</a>
{% endif %}
<span
class=
"current"
>
...
...
@@ -28,11 +15,20 @@
</span>
{% if documents.has_next %}
<a
href=
"?page={{ documents.next_page_number }}
"
>
next
</a>
<a
onclick=
"updateDocuments({{ documents.next_page_number }},true);
"
>
next
</a>
{% endif %}
</span>
</div>
{% if documents %}
<p>
Paginator stuff
</p>
<ul>
{% for doc in documents %}
{% if doc.date %}
<li>
<b>
{{ doc.date }}
</b>
,
<a
href=
"/admin/node/document/{{doc.id}}"
>
id:{{ doc.id}} title:{{ doc.name}}
</a></li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
\ No newline at end of file
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