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
461caaf9
Commit
461caaf9
authored
Apr 08, 2016
by
delanoe
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'refactoring-rom' into refactoring-alex
parents
e95e2317
baf93fa4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
138 additions
and
60 deletions
+138
-60
ngramlists.py
gargantext/views/api/ngramlists.py
+4
-8
tables.css
static/css/gargantext/tables.css
+5
-2
NGrams_dyna_chart_and_table.js
static/js/gargantext/NGrams_dyna_chart_and_table.js
+129
-50
No files found.
gargantext/views/api/ngramlists.py
View file @
461caaf9
...
@@ -174,13 +174,10 @@ class GroupChange(APIView):
...
@@ -174,13 +174,10 @@ class GroupChange(APIView):
NodeNgramNgram
.
ngram1_id
.
in_
(
all_nodes_involved
),
NodeNgramNgram
.
ngram1_id
.
in_
(
all_nodes_involved
),
NodeNgramNgram
.
ngram2_id
.
in_
(
all_nodes_involved
)))
NodeNgramNgram
.
ngram2_id
.
in_
(
all_nodes_involved
)))
)
)
n_removed
=
old_links
.
count
()
n_removed
=
old_links
.
delete
(
synchronize_session
=
False
)
old_links
.
delete
(
synchronize_session
=
'fetch'
)
session
.
commit
()
print
(
'n_removed'
,
n_removed
)
print
(
"links"
,
links
)
# add new groupings
print
(
[
i
for
i
in
((
group_node
,
mainform
,
subform
,
1.0
)
for
(
mainform
,
subform
)
in
links
)]
)
bulk_insert
(
bulk_insert
(
NodeNgramNgram
,
NodeNgramNgram
,
(
'node_id'
,
'ngram1_id'
,
'ngram2_id'
,
'weight'
),
(
'node_id'
,
'ngram1_id'
,
'ngram2_id'
,
'weight'
),
...
@@ -194,7 +191,6 @@ class GroupChange(APIView):
...
@@ -194,7 +191,6 @@ class GroupChange(APIView):
class
ListChange
(
APIView
):
class
ListChange
(
APIView
):
"""
"""
Any ngram action on standard NodeNgram lists (MAIN, MAP, STOP)
Any ngram action on standard NodeNgram lists (MAIN, MAP, STOP)
...
...
static/css/gargantext/tables.css
View file @
461caaf9
...
@@ -40,7 +40,10 @@ td .note {
...
@@ -40,7 +40,10 @@ td .note {
span
.note
{
span
.note
{
font-size
:
10px
;
font-size
:
10px
;
color
:
#333
;
}
span
.note.glyphicon
{
color
:
#555
;
}
}
p
.note
{
p
.note
{
...
@@ -99,7 +102,7 @@ tr:hover {
...
@@ -99,7 +102,7 @@ tr:hover {
#group_box_mainform
{
#group_box_mainform
{
margin-bottom
:
0
;
margin-bottom
:
0
;
line-height
:
1
;
line-height
:
1
;
margin-left
:
.0
5
em
;
margin-left
:
.0
8
em
;
}
}
#group_box_content
{
#group_box_content
{
...
...
static/js/gargantext/NGrams_dyna_chart_and_table.js
View file @
461caaf9
...
@@ -380,16 +380,18 @@ function saveActiveGroup() {
...
@@ -380,16 +380,18 @@ function saveActiveGroup() {
GroupsBuffer
[
mainform
]
=
activeGroup
.
now_links
GroupsBuffer
[
mainform
]
=
activeGroup
.
now_links
// ---------------------------------------------------
// ---------------------------------------------------
// also we prefix "*" to the name
console
.
log
(
AjaxRecords
[
mainform
])
AjaxRecords
[
mainform
].
name
=
"*"
+
AjaxRecords
[
mainform
].
name
// TODO check if necessary to update
// also we prefix "*" to the name if not already there
if
(
AjaxRecords
[
mainform
].
name
[
0
]
!=
'*'
)
{
AjaxRecords
[
mainform
].
name
=
"*"
+
AjaxRecords
[
mainform
].
name
}
// the previous mainforms that became subforms can't stay in the main records
// the previous mainforms that became subforms can't stay in the main records
for
(
downgradedNgramId
in
activeGroup
.
were_mainforms
)
{
for
(
downgradedNgramId
in
activeGroup
.
were_mainforms
)
{
if
(
downgradedNgramId
!=
mainform
)
{
if
(
downgradedNgramId
!=
mainform
)
{
AjaxRecords
[
downgradedNgramId
].
state
=
-
1
//
AjaxRecords[downgradedNgramId].state = -1
// they go to nodesmemory
// they go to nodesmemory
// NGrams.group.nodesmemory = AjaxRecords[downgradedNgramId]
// NGrams.group.nodesmemory = AjaxRecords[downgradedNgramId]
...
@@ -493,7 +495,8 @@ function seeGroup ( ngramId ) {
...
@@ -493,7 +495,8 @@ function seeGroup ( ngramId ) {
// 6/7 add a "modify group" button
// 6/7 add a "modify group" button
var
changeGroupsButton
=
'<button style="float:right"'
;
var
changeGroupsButton
=
'<button style="float:right"'
;
changeGroupsButton
+=
'onclick="modifyGroup('
+
ngramId
+
')">'
;
changeGroupsButton
+=
' title="add/remove contents of groups"'
;
changeGroupsButton
+=
' onclick="modifyGroup('
+
ngramId
+
')">'
;
changeGroupsButton
+=
'modify group'
;
changeGroupsButton
+=
'modify group'
;
changeGroupsButton
+=
'</button>'
;
changeGroupsButton
+=
'</button>'
;
subNgramHtml
.
append
(
changeGroupsButton
)
;
subNgramHtml
.
append
(
changeGroupsButton
)
;
...
@@ -525,21 +528,43 @@ function drawSublist (linkNamesArray) {
...
@@ -525,21 +528,43 @@ function drawSublist (linkNamesArray) {
return
sublistHtml
return
sublistHtml
}
}
function
drawActiveSublist
(
tgtElementId
,
linkIdsArray
,
ngInfos
)
{
function
drawActiveGroup
(
tgtElementId
,
mainformId
,
linkIdsArray
,
ngInfos
)
{
var
sublistHtml
=
""
;
var
groupHtml
=
'<p id="group_box_mainform">'
;
groupHtml
+=
mainformSpan
(
ngInfos
[
mainformId
])
groupHtml
+=
' <br> │<br>'
;
groupHtml
+=
'</p>'
;
// sublist
groupHtml
+=
'<p id="group_box_content">'
;
var
last_i
=
linkIdsArray
.
length
-
1
;
var
last_i
=
linkIdsArray
.
length
-
1
;
for
(
var
i
in
linkIdsArray
)
{
for
(
var
i
in
linkIdsArray
)
{
var
subNgramId
=
linkIdsArray
[
i
]
;
var
subNgramId
=
linkIdsArray
[
i
]
;
if
(
i
!=
last_i
)
{
if
(
i
!=
last_i
)
{
sublist
Html
+=
' ├── '
+
subformSpan
(
ngInfos
[
subNgramId
])
+
'<br>'
;
group
Html
+=
' ├── '
+
subformSpan
(
ngInfos
[
subNgramId
])
+
'<br>'
;
}
}
else
{
else
{
sublist
Html
+=
' └── '
+
subformSpan
(
ngInfos
[
subNgramId
])
;
group
Html
+=
' └── '
+
subformSpan
(
ngInfos
[
subNgramId
])
;
}
}
}
}
// write html
// save/cancel buttons
$
(
tgtElementId
).
html
(
sublistHtml
)
groupHtml
+=
'
\
n <p id="activeGroupButtons">'
;
// Ok - No
var
cancelGroupButton
=
'<button onclick="removeActiveGroup()">'
;
cancelGroupButton
+=
'cancel'
;
cancelGroupButton
+=
'</button>'
;
var
tempoSaveGroupButton
=
'<button onclick="saveActiveGroup()">'
;
tempoSaveGroupButton
+=
'finish'
;
tempoSaveGroupButton
+=
'</button>'
;
groupHtml
+=
cancelGroupButton
groupHtml
+=
tempoSaveGroupButton
groupHtml
+=
'</p>
\
n'
// write html to current DOM
$
(
tgtElementId
).
html
(
groupHtml
)
}
}
// makes each subform's html
// makes each subform's html
...
@@ -558,29 +583,94 @@ function subformSpan( subNgramInfo ) {
...
@@ -558,29 +583,94 @@ function subformSpan( subNgramInfo ) {
span
.
addClass
(
"usersubform"
)
span
.
addClass
(
"usersubform"
)
}
}
// remove button
// £TODO remove Button has a bug when mainform doesn't reappear in its row
// var removeButton = ' <span class="note glyphicon glyphicon-minus-sign"'
// var removeButton = ' <span class="note glyphicon glyphicon-minus-sign"'
// removeButton += ' title="remove from group (/!\\ bug: will be unattached if was previously a subform)"' ;
// removeButton += ' onclick="removeSubform('+ subNgramInfo.id +')"></span>'
// removeButton += ' onclick="removeSubform('+ subNgramInfo.id +')"></span>'
// span.append(removeButton)
// span.append(removeButton)
// makes this subform become the mainform
// var mainformButton = ' <span class="note glyphicon glyphicon-circle-arrow-up"'
// mainformButton += ' title="upgrade to mainform of this group"'
// mainformButton += ' onclick="makeMainform('+ subNgramInfo.id +')"></span>'
// span.append(mainformButton)
return
(
span
[
0
].
outerHTML
)
return
(
span
[
0
].
outerHTML
)
}
}
// makes mainform's span
function
mainformSpan
(
ngramInfo
)
{
// each item is a new ngram under the group
span
=
$
(
'<span/>'
,
{
text
:
ngramInfo
.
name
,
title
:
ngramInfo
.
id
,
id
:
'active-mainform-'
+
ngramInfo
.
id
})
return
(
span
[
0
].
outerHTML
)
}
function
makeMainform
(
ngramId
)
{
$
(
'#active-subform-'
+
ngramId
).
remove
()
// replace now_mainform_id property
previousMainformId
=
activeGroup
.
now_mainform_id
activeGroup
.
now_mainform_id
=
ngramId
// replace old subform by old mainform in now_links array
var
i
=
activeGroup
.
now_links
.
indexOf
(
ngramId
)
activeGroup
.
now_links
[
i
]
=
previousMainformId
// if it was previously a subform then:
// -> it had no entry in AjaxRecords
// -> it was not in any of the lists
if
(
!
(
mainform
in
activeGroup
.
were_mainforms
))
{
// update records
delete
activeGroup
.
ngraminfo
[
mainform
].
origin
AjaxRecords
[
mainform
]
=
activeGroup
.
ngraminfo
[
mainform
]
AjaxRecords
[
mainform
].
state
=
0
// update lists (inherits status of previous mainform)
}
// NB if it was previously a subform
// then absent from AjaxRecords
// => is solved in saveActiveGroup()
// redraw active group_box_content
drawActiveGroup
(
'#group_box'
,
activeGroup
.
now_mainform_id
,
activeGroup
.
now_links
,
activeGroup
.
ngraminfo
)
// and update
MyTable
.
data
(
'dynatable'
).
dom
.
update
();
}
function
removeSubform
(
ngramId
)
{
function
removeSubform
(
ngramId
)
{
$
(
'#active-subform-'
+
ngramId
).
remove
()
$
(
'#active-subform-'
+
ngramId
).
remove
()
if
(
activeGroup
.
now_links
.
length
==
1
)
{
if
(
activeGroup
.
now_links
.
length
==
1
)
{
removeActiveGroup
()
removeActiveGroup
()
}
}
else
{
else
{
// clean were_mainforms dict
delete
activeGroup
.
were_mainforms
[
ngramId
]
// clean now_links array
var
i
=
activeGroup
.
now_links
.
indexOf
(
ngramId
)
var
i
=
activeGroup
.
now_links
.
indexOf
(
ngramId
)
activeGroup
.
now_links
.
splice
(
i
,
1
)
activeGroup
.
now_links
.
splice
(
i
,
1
)
// if (activeGroup.ngraminfo[ngramId].origin == 'new') {
// if (activeGroup.ngraminfo[ngramId].origin == 'new') {
// AjaxRecords[ngramId].state = 0 ;
// AjaxRecords[ngramId].state = 0 ;
// }
// }
// redraw active group_box_content
// redraw active group_box_content
drawActiveSublist
(
drawActiveGroup
(
'#group_box_content'
,
'#group_box'
,
activeGroup
.
now_mainform_id
,
activeGroup
.
now_links
,
activeGroup
.
now_links
,
activeGroup
.
ngraminfo
activeGroup
.
ngraminfo
)
)
...
@@ -590,48 +680,34 @@ function removeSubform(ngramId) {
...
@@ -590,48 +680,34 @@ function removeSubform(ngramId) {
}
}
function
modifyGroup
(
mainFormNgramId
)
{
function
modifyGroup
(
mainFormNgramId
)
{
// create modification
dialog
// create modification
container
//
//
var
group_html
=
' <tr class="group_box" id="group_box">
\
n'
;
var
group_html
=
' <tr>
\
n'
;
group_html
+=
' <td colspan='
+
tableSpan
+
'>
\
n'
;
group_html
+=
' <td id="group_box" colspan='
+
tableSpan
+
'>
\
n'
;
// mainform
// -------------------------------------------------------------------
group_html
+=
' <p id="group_box_mainform">
\
n'
;
// mainform + sublist + buttons will be added here by drawActiveGroup
group_html
+=
' '
+
subformSpan
(
AjaxRecords
[
mainFormNgramId
])
+
'
\
n'
// -------------------------------------------------------------------
group_html
+=
' <br> │<br>'
;
group_html
+=
' </p>
\
n'
;
// sublist
group_html
+=
' <p id="group_box_content"></p>
\
n'
;
// save/cancel buttons
group_html
+=
' <p id="activeGroupButtons"></p>
\
n'
;
group_html
+=
' </td>
\
n'
;
group_html
+=
' </td>
\
n'
;
group_html
+=
' </tr>
\
n'
;
group_html
+=
' </tr>
\
n'
;
$
(
"#my-ajax-table > thead"
).
append
(
group_html
)
$
(
"#my-ajax-table > thead"
).
append
(
group_html
)
// Ok - No
var
cancelGroupButton
=
'<button onclick="removeActiveGroup()">'
;
cancelGroupButton
+=
'cancel'
;
cancelGroupButton
+=
'</button>'
;
var
tempoSaveGroupButton
=
'<button onclick="saveActiveGroup()">'
;
tempoSaveGroupButton
+=
'finish'
;
tempoSaveGroupButton
+=
'</button>'
;
$
(
"#activeGroupButtons"
).
append
(
cancelGroupButton
)
.
append
(
tempoSaveGroupButton
)
// set global 'grouping in progress' states
// set global 'grouping in progress' states
GState
=
1
;
GState
=
1
;
activeGroup
.
now_mainform_id
=
mainFormNgramId
;
activeGroup
.
now_mainform_id
=
mainFormNgramId
;
activeGroup
.
were_mainforms
[
mainFormNgramId
]
=
true
;
activeGroup
.
were_mainforms
[
mainFormNgramId
]
=
true
;
activeGroup
.
now_links
=
[]
;
activeGroup
.
now_links
=
[]
;
activeGroup
.
ngraminfo
=
{}
;
// standard rec info + 'origin' property
// ngraminfo = standard info of records + 'origin' property
activeGroup
.
ngraminfo
=
{}
activeGroup
.
ngraminfo
[
mainFormNgramId
]
=
AjaxRecords
[
mainFormNgramId
]
;
activeGroup
.
ngraminfo
[
mainFormNgramId
][
'origin'
]
=
'new'
;
// add relevant information from old & new links to activeGroup.now_links
// add relevant information from old & new links to activeGroup.now_links
updateActiveGroupInfo
(
mainFormNgramId
,
false
)
updateActiveGroupInfo
(
mainFormNgramId
,
false
)
// groupBox rendering
// groupBox rendering
drawActiveSublist
(
drawActiveGroup
(
'#group_box_content'
,
'#group_box'
,
activeGroup
.
now_mainform_id
,
activeGroup
.
now_links
,
activeGroup
.
now_links
,
activeGroup
.
ngraminfo
activeGroup
.
ngraminfo
)
)
...
@@ -643,7 +719,7 @@ function modifyGroup ( mainFormNgramId ) {
...
@@ -643,7 +719,7 @@ function modifyGroup ( mainFormNgramId ) {
// add new ngramid (and any present subforms) to currently modified group
// add new ngramid (and any present subforms) to currently modified group
function
add2group
(
ngramId
)
{
function
add2group
(
ngramId
)
{
console
.
log
(
"FUN add2group("
+
AjaxRecords
[
ngramId
].
name
+
")"
)
//
console.log("FUN add2group(" + AjaxRecords[ngramId].name + ")")
var
toOther
=
true
;
var
toOther
=
true
;
activeGroup
.
were_mainforms
[
ngramId
]
=
true
;
activeGroup
.
were_mainforms
[
ngramId
]
=
true
;
...
@@ -659,8 +735,9 @@ function add2group ( ngramId ) {
...
@@ -659,8 +735,9 @@ function add2group ( ngramId ) {
updateActiveGroupInfo
(
ngramId
,
toOther
)
updateActiveGroupInfo
(
ngramId
,
toOther
)
// redraw active group_box_content
// redraw active group_box_content
drawActiveSublist
(
drawActiveGroup
(
'#group_box_content'
,
'#group_box'
,
activeGroup
.
now_mainform_id
,
activeGroup
.
now_links
,
activeGroup
.
now_links
,
activeGroup
.
ngraminfo
activeGroup
.
ngraminfo
)
)
...
@@ -717,8 +794,8 @@ function updateActiveGroupInfo (ngramId, toOtherMainform) {
...
@@ -717,8 +794,8 @@ function updateActiveGroupInfo (ngramId, toOtherMainform) {
* @param ngramId - the record's id
* @param ngramId - the record's id
*/
*/
function
clickngram_action
(
ngramId
)
{
function
clickngram_action
(
ngramId
)
{
// cycle the statuses (0 => 1 => 2 => 0 => etc)
(we are omitting status 3 = group)
// cycle the statuses (0 => 1 => 2 => 0 => etc)
AjaxRecords
[
ngramId
].
state
=
(
AjaxRecords
[
ngramId
].
state
==
(
System
[
0
][
"states"
].
length
-
2
))?
0
:(
AjaxRecords
[
ngramId
].
state
+
1
);
AjaxRecords
[
ngramId
].
state
=
(
AjaxRecords
[
ngramId
].
state
==
(
System
[
0
][
"states"
].
length
-
1
))?
0
:(
AjaxRecords
[
ngramId
].
state
+
1
);
// State <=> term color <=> checked colums
// State <=> term color <=> checked colums
...
@@ -801,7 +878,7 @@ function transformContent(ngramId) {
...
@@ -801,7 +878,7 @@ function transformContent(ngramId) {
// normal situation: button allows to see group contents
// normal situation: button allows to see group contents
if
(
GState
==
0
)
{
if
(
GState
==
0
)
{
var
plusicon
=
''
;
var
plusicon
=
''
;
if
(
ngram
_info
[
"id"
]
in
vizopenGroup
)
{
if
(
ngram
Id
in
vizopenGroup
)
{
plusicon
=
"glyphicon-triangle-bottom"
plusicon
=
"glyphicon-triangle-bottom"
}
else
{
}
else
{
plusicon
=
"glyphicon-triangle-right"
plusicon
=
"glyphicon-triangle-right"
...
@@ -832,8 +909,8 @@ function transformContent(ngramId) {
...
@@ -832,8 +909,8 @@ function transformContent(ngramId) {
result
[
"score"
]
=
'<span class="'
+
atts
.
id
+
'">'
+
ngram_info
[
"score"
]
+
'</span>
\
n'
result
[
"score"
]
=
'<span class="'
+
atts
.
id
+
'">'
+
ngram_info
[
"score"
]
+
'</span>
\
n'
// <td> name </td> aka "ngrambox"
// <td> name </td> aka "ngrambox"
result
[
"name"
]
=
'<div class="ngrambox" id="box-'
+
ngram
_info
[
"id"
]
+
'">
\
n'
result
[
"name"
]
=
'<div class="ngrambox" id="box-'
+
ngram
Id
+
'">
\
n'
if
(
ngram
_info
[
"id"
]
!=
activeGroup
.
now_mainform_id
&&
!
(
ngram_info
[
"id"
]
in
activeGroup
.
were_mainforms
))
{
if
(
ngram
Id
!=
activeGroup
.
now_mainform_id
&&
!
(
ngramId
in
activeGroup
.
were_mainforms
))
{
result
[
"name"
]
+=
plus_event
+
'
\
n'
result
[
"name"
]
+=
plus_event
+
'
\
n'
result
[
"name"
]
+=
'<span title="'
+
ngram_info
[
"id"
]
+
'" class="'
+
atts
.
id
+
'" '
result
[
"name"
]
+=
'<span title="'
+
ngram_info
[
"id"
]
+
'" class="'
+
atts
.
id
+
'" '
...
@@ -914,7 +991,9 @@ function ulWriter(rowIndex, record, columns, cellWriter) {
...
@@ -914,7 +991,9 @@ function ulWriter(rowIndex, record, columns, cellWriter) {
//debug
//debug
if
(
typeof
AjaxRecords
[
record
.
id
]
==
"undefined"
)
{
if
(
typeof
AjaxRecords
[
record
.
id
]
==
"undefined"
)
{
console
.
log
(
'/!
\\
nothing for '
+
record
.
id
)
console
.
log
(
'/!
\\
nothing for '
+
record
.
id
)
return
false
;
}
else
if
(
AjaxRecords
[
record
.
id
].
state
<
0
)
{
}
else
if
(
AjaxRecords
[
record
.
id
].
state
<
0
)
{
// therefore state -1 ngrams will not be drawn
return
false
;
return
false
;
}
}
...
...
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