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
4c3aa4b9
Commit
4c3aa4b9
authored
May 13, 2016
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ngrams table small corrections + deactivate prefetch because of lag issue
parent
2785cf15
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
23 deletions
+26
-23
NGrams_dyna_chart_and_table.js
static/lib/gargantext/NGrams_dyna_chart_and_table.js
+26
-23
No files found.
static/lib/gargantext/NGrams_dyna_chart_and_table.js
View file @
4c3aa4b9
...
...
@@ -29,8 +29,10 @@
* - unify table ids with ngram ids
* - new api routes + prefetch maplist terms
* - simplify UpdateTable
* - clarify cruds
* - better "created groups" handling
*
* @version 1.
1
* @version 1.
2
*
* @requires jquery.dynatable
* @requires d3
...
...
@@ -48,7 +50,6 @@
// with some expanding in AfterAjax
var
AjaxRecords
=
[]
;
// table element (+config +events)
// -------------------------------
var
MyTable
;
...
...
@@ -234,7 +235,7 @@ function printCorpuses() {
console
.
log
(
url
)
GET_
(
url
,
function
(
results
)
{
GET_
(
url
,
function
(
results
,
url
)
{
if
(
Object
.
keys
(
results
).
length
>
0
)
{
var
sub_ngrams_data
=
{
"ngrams"
:[],
...
...
@@ -1510,7 +1511,7 @@ function GROUPCRUD( groupnode_id , post_data , callback) {
*
* @param ngdata: a response from the api/node/CID/ngrams/list/ routes
* @param initial: initial score type "occs" or "tfidf"
* @param search_filter:
eg 'filter_all' (see SearchFilters.MODE
)
* @param search_filter:
value among {0,1,2,'reset'} (see #picklistmenu options
)
*/
function
MainTableAndCharts
(
ngdata
,
initial
,
search_filter
)
{
...
...
@@ -1768,14 +1769,11 @@ function MainTableAndCharts( ngdata , initial , search_filter) {
volumeChart
.
filterAll
();
dc
.
redrawAll
();
// test if array is enough to restore proper page range
// AjaxRecords per ngramid => dense array to maintain proper page range
// see MyTable.data('dynatable').settings.dataset.originalRecords
var
ArrayAjaxRecords
=
[]
;
var
i
=
0
;
var
idmap
=
{}
for
(
ngid
in
AjaxRecords
)
{
ArrayAjaxRecords
.
push
(
AjaxRecords
[
ngid
])
;
i
++
;
idmap
[
ngid
]
=
i
}
MyTable
=
[]
...
...
@@ -1823,7 +1821,8 @@ function MainTableAndCharts( ngdata , initial , search_filter) {
// nb: possible value are in {0,1,2} (see terms.html > #picklistmenu)
.
functions
[
'my_state_filter'
]
=
function
(
record
,
selectedValue
)
{
if
(
selectedValue
==
'reset'
)
{
return
(
AjaxRecords
[
record
.
id
].
state
>=
0
)
// return (AjaxRecords[record.id].state >= 0)
return
true
}
else
{
// return true or false
...
...
@@ -1832,7 +1831,8 @@ function MainTableAndCharts( ngdata , initial , search_filter) {
}
// and set this filter's initial status to 'maplist' (aka state == 1)
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
queries
[
'my_state_filter'
]
=
1
;
// MyTable.data('dynatable').settings.dataset.queries['my_state_filter'] = 1 ;
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
queries
[
'my_state_filter'
]
=
search_filter
;
MyTable
.
data
(
'dynatable'
).
process
();
// moves pagination over table
...
...
@@ -1946,10 +1946,10 @@ function GET_( url , callback ) {
url
:
url
,
dataType
:
"json"
,
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
callback
(
data
);
callback
(
data
,
url
);
},
error
:
function
(
exception
)
{
callback
(
false
);
callback
(
false
,
url
);
}
})
}
...
...
@@ -1969,18 +1969,19 @@ var NGrams = {
}
//
NEW AJAX x 2
//
MAIN AJAX
var
prefetch_url
=
window
.
location
.
origin
+
"/api/ngramlists/maplist?corpus="
+
corpus_id
;
var
new
_url
=
window
.
location
.
origin
+
"/api/ngramlists/family?corpus="
+
corpus_id
;
var
final
_url
=
window
.
location
.
origin
+
"/api/ngramlists/family?corpus="
+
corpus_id
;
// faster call: just the maplist, will return first
GET_
(
prefetch_url
,
HandleAjax
);
// 2016-05-13: deactivated because it causes a lag before the table is updated
// GET_(prefetch_url, HandleAjax);
// longer call (full list of terms) to return when ready and refresh all data
GET_
(
new
_url
,
HandleAjax
)
GET_
(
final
_url
,
HandleAjax
)
function
HandleAjax
(
res
)
{
function
HandleAjax
(
res
,
sourceUrl
)
{
if
(
res
&&
res
.
ngraminfos
)
{
main_ngrams_objects
=
{}
...
...
@@ -1993,8 +1994,6 @@ function HandleAjax(res) {
}
}
console
.
log
(
"===> AJAX INIT <===
\n
"
+
"source: "
+
new_url
)
// = = = = MIAM = = = = //
NGrams
[
"main"
]
=
{
"ngrams"
:
main_ngrams_objects
,
...
...
@@ -2035,10 +2034,10 @@ function HandleAjax(res) {
$
(
"input#stoplist_id"
).
val
(
res
.
nodeids
[
'stoplist'
])
$
(
"input#groups_id"
).
val
(
res
.
nodeids
[
'groups'
])
$
(
"input#scores_id"
).
val
(
res
.
nodeids
[
'scores'
])
AfterAjax
()
;
AfterAjax
(
sourceUrl
)
;
}
function
AfterAjax
()
{
function
AfterAjax
(
sourceUrl
)
{
// -------------------------------------------------------------------
// console.log(JSON.stringify(NGrams))
// -------------------------------------------------------------------
...
...
@@ -2130,8 +2129,12 @@ function AfterAjax() {
// }
// }
// show only map (option = 1) or all terms (option = "reset")
termsfilter
=
(
sourceUrl
==
final_url
)
?
"reset"
:
"1"
// Initializing the Charts and Table ---------------------------------------
var
result
=
MainTableAndCharts
(
NGrams
[
"main"
]
,
FirstScore
,
"filter_all"
)
var
result
=
MainTableAndCharts
(
NGrams
[
"main"
]
,
FirstScore
,
termsfilter
)
;
console
.
log
(
result
)
// OK
// -------------------------------------------------------------------------
...
...
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