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
215784f9
Commit
215784f9
authored
Nov 09, 2015
by
PkSM3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[UPDATE] add to map-list, delete ngrams, OK
parent
38fcc5d6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
49 deletions
+74
-49
ngrams.py
rest_v1_0/ngrams.py
+22
-1
urls.py
rest_v1_0/urls.py
+4
-10
NGrams_dyna_chart_and_table.js
static/js/NGrams_dyna_chart_and_table.js
+45
-35
terms.html
templates/corpus/terms.html
+3
-3
No files found.
rest_v1_0/ngrams.py
View file @
215784f9
...
...
@@ -59,6 +59,7 @@ _ngrams_order_columns = {
from
rest_framework.authentication
import
SessionAuthentication
,
BasicAuthentication
from
rest_framework.views
import
APIView
from
rest_framework.response
import
Response
from
rest_framework.renderers
import
JSONRenderer
from
rest_framework.exceptions
import
APIException
as
_APIException
class
APIException
(
_APIException
):
...
...
@@ -332,6 +333,26 @@ class Group(APIView):
class
Keep
(
APIView
):
pass
"""
Actions on one existing Ngram in one list
"""
renderer_classes
=
(
JSONRenderer
,)
authentication_classes
=
(
SessionAuthentication
,
BasicAuthentication
)
def
put
(
self
,
request
,
list_id
,
ngram_ids
):
"""
Add ngrams to map list
"""
print
(
"list_id:"
,
list_id
)
print
(
"ngram_ids:"
,
ngram_ids
)
# for ngram_id in ngram_ids.split('+'):
# print('ngram_id', ngram_id)
# ngram_id = int(ngram_id)
# (session.query(NodeNgram)
# .filter(NodeNgram.node_id==list_id)
# .filter(NodeNgram.ngram_id==ngram_id).delete()
# )
# session.commit()
return
JsonHttpResponse
(
True
,
201
)
rest_v1_0/urls.py
View file @
215784f9
...
...
@@ -4,6 +4,8 @@ from gargantext_web import views_optimized
from
rest_v1_0
import
api
,
ngrams
,
graph
from
annotations
import
views
urlpatterns
=
patterns
(
''
,
# REST URLS
# What is REST ?
...
...
@@ -11,31 +13,23 @@ urlpatterns = patterns('',
#url(r'^api$', rest_v1_0.api.Root), # = ?
url
(
r'nodes$'
,
api
.
NodesList
.
as_view
()),
url
(
r'nodes$'
,
api
.
NodesList
.
as_view
()),
url
(
r'nodes/(\d+)$'
,
api
.
Nodes
.
as_view
()),
url
(
r'nodes/(\d+)$'
,
api
.
Nodes
.
as_view
()),
url
(
r'nodes/(\d+)/children/ngrams$'
,
api
.
NodesChildrenNgrams
.
as_view
()),
# => repeated children ?
url
(
r'nodes/(\d+)/children/ngrams$'
,
api
.
NodesChildrenNgrams
.
as_view
()),
# => repeated children ?
# NGRAMS table & annotations
url
(
r'node/(\d+)/ngrams$'
,
ngrams
.
Ngrams
.
as_view
()),
url
(
r'node/(\d+)/ngrams/group$'
,
ngrams
.
Group
.
as_view
()),
url
(
r'node/(\d+)/ngrams/keep$'
,
ngrams
.
Keep
.
as_view
()),
url
(
r'node/(?P<list_id>[0-9]+)/ngrams/keep/(?P<ngram_ids>[0-9,\+]+)+$'
,
ngrams
.
Keep
.
as_view
()),
url
(
r'node/(?P<list_id>[0-9]+)/ngrams/(?P<ngram_ids>[0-9,\+]+)+$'
,
views
.
NgramEdit
.
as_view
()),
url
(
r'node/(\d+)/ngrams/list$'
,
ngrams
.
List
.
as_view
()),
#url(r'nodes/(\d+)/children/hyperdata$', api.NodesChildrenMetatadata.as_view()),
#url(r'nodes/(\d+)/children/hyperdata$', api.NodesChildrenMetatadata.as_view()),
url
(
r'nodes/(\d+)/children/queries$'
,
api
.
NodesChildrenQueries
.
as_view
()),
url
(
r'nodes/(\d+)/children/queries$'
,
api
.
NodesChildrenQueries
.
as_view
()),
url
(
r'nodes/(\d+)/children/duplicates$'
,
api
.
NodesChildrenDuplicates
.
as_view
()),
url
(
r'nodes/(\d+)/children/duplicates$'
,
api
.
NodesChildrenDuplicates
.
as_view
()),
# url(r'^api/nodes/(\d+)/children/duplicates/delete$', api.NodesChildrenDuplicates.delete ),
url
(
r'nodes/(\d+)/ngrams$'
,
api
.
CorpusController
.
ngrams
),
url
(
r'nodes/(\d+)/ngrams$'
,
api
.
CorpusController
.
ngrams
),
url
(
r'nodes/(\d+)/graph$'
,
graph
.
Graph
.
as_view
()),
url
(
r'corpus/(\d+)/graph$'
,
graph
.
Graph
.
as_view
()),
...
...
static/js/NGrams_dyna_chart_and_table.js
View file @
215784f9
...
...
@@ -26,12 +26,12 @@ var TheBuffer = false
var
PossibleActions
=
[
{
"id"
:
"
to_
delete"
,
"id"
:
"delete"
,
"name"
:
"Delete"
,
"color"
:
"red"
},
{
"id"
:
"
to_
keep"
,
"id"
:
"keep"
,
"name"
:
"Keep"
,
"color"
:
"green"
},
...
...
@@ -47,7 +47,7 @@ var System = {
// 1: {
// },
0
:
{
"states"
:
[
"normal"
,
"
to_keep"
,
"to_delete"
,
"grouped
"
]
,
"states"
:
[
"normal"
,
"
keep"
,
"delete"
,
"group
"
]
,
"statesD"
:
{}
,
"dict"
:
{
"normal"
:
{
...
...
@@ -55,18 +55,18 @@ var System = {
"name"
:
"Normal"
,
"color"
:
"black"
},
"
to_
delete"
:
{
"id"
:
"
to_
delete"
,
"delete"
:
{
"id"
:
"delete"
,
"name"
:
"Delete"
,
"color"
:
"red"
},
"
to_
keep"
:
{
"id"
:
"
to_
keep"
,
"keep"
:
{
"id"
:
"keep"
,
"name"
:
"Keep"
,
"color"
:
"green"
},
"group
ed
"
:
{
"id"
:
"group
ed
"
,
"group"
:
{
"id"
:
"group"
,
"name"
:
"MainForm"
,
"color"
:
"white"
}
...
...
@@ -208,7 +208,7 @@ function save_groups() {
if
(
count
==
0
)
{
if
(
writeflag
)
{
// AjaxRecords[RecDict[nid]].name += "*"
FlagsBuffer
[
"group
ed
"
][
nid
]
=
[]
FlagsBuffer
[
"group"
][
nid
]
=
[]
mainform
=
nid
AjaxRecords
[
RecDict
[
nid
]].
state
=
1
}
else
{
...
...
@@ -216,7 +216,7 @@ function save_groups() {
}
}
else
{
if
(
writeflag
)
{
FlagsBuffer
[
"group
ed
"
][
mainform
].
push
(
nid
)
FlagsBuffer
[
"group"
][
mainform
].
push
(
nid
)
AjaxRecords
[
RecDict
[
nid
]].
state
=
-
1
}
}
...
...
@@ -263,7 +263,7 @@ function add2groupdiv( elem_id ) {
MyTable
.
data
(
'dynatable'
).
dom
.
update
();
})
.
appendTo
(
'#group_box_content'
)
AjaxRecords
[
elem_id
].
state
=
3
;
// 3: "group
ed
" state
AjaxRecords
[
elem_id
].
state
=
3
;
// 3: "group" state
}
// new
function
add2group
(
elem
)
{
...
...
@@ -282,14 +282,14 @@ function add2group ( elem ) {
var
elem_id
=
$
(
elem
).
data
(
"stuff"
)
add2groupdiv
(
elem_id
)
if
(
FlagsBuffer
[
"group
ed
"
][
AjaxRecords
[
elem_id
].
id
]
)
{
for
(
var
i
in
FlagsBuffer
[
"group
ed
"
][
AjaxRecords
[
elem_id
].
id
]
)
{
var
nodeid
=
FlagsBuffer
[
"group
ed
"
][
AjaxRecords
[
elem_id
].
id
][
i
]
if
(
FlagsBuffer
[
"group"
][
AjaxRecords
[
elem_id
].
id
]
)
{
for
(
var
i
in
FlagsBuffer
[
"group"
][
AjaxRecords
[
elem_id
].
id
]
)
{
var
nodeid
=
FlagsBuffer
[
"group"
][
AjaxRecords
[
elem_id
].
id
][
i
]
add2groupdiv
(
RecDict
[
nodeid
]
)
}
}
delete
FlagsBuffer
[
"group
ed
"
][
AjaxRecords
[
elem_id
].
id
]
delete
FlagsBuffer
[
"group"
][
AjaxRecords
[
elem_id
].
id
]
MyTable
.
data
(
'dynatable'
).
dom
.
update
();
}
...
...
@@ -307,8 +307,8 @@ function clickngram_action ( elem ) {
// var sum__selected_elems = 0;
// for(var i in FlagsBuffer["group
ed
"])
// sum__selected_elems += Object.keys( FlagsBuffer["group
ed
"][i] ).length
// for(var i in FlagsBuffer["group"])
// sum__selected_elems += Object.keys( FlagsBuffer["group"][i] ).length
// for(var i in FlagsBuffer)
// sum__selected_elems += Object.keys(FlagsBuffer[i]).length;
...
...
@@ -328,10 +328,10 @@ function transformContent(rec_id) {
var
result
=
{}
var
atts
=
System
[
0
][
"dict"
][
System
[
0
][
"states"
][
elem
.
state
]
]
var
plus_event
=
""
if
(
GState
==
0
&&
elem
.
state
!=
System
[
0
][
"statesD"
][
"
to_
delete"
]
)
// if deleted, no + button
if
(
GState
==
0
&&
elem
.
state
!=
System
[
0
][
"statesD"
][
"delete"
]
)
// if deleted, no + button
plus_event
=
" <a class=
\"
plusclass
\"
onclick=
\"
add2group(this.parentNode.parentNode)
\"
>(+)</a>"
if
(
GState
==
1
)
{
if
(
elem
.
state
!=
System
[
0
][
"statesD"
][
"
to_delete"
]
&&
elem
.
state
!=
System
[
0
][
"statesD"
][
"grouped"
])
{
// if deleted and already grouped
, no Up button
if
(
elem
.
state
!=
System
[
0
][
"statesD"
][
"
delete"
]
&&
elem
.
state
!=
System
[
0
][
"statesD"
][
"group"
])
{
// if deleted and already group
, no Up button
plus_event
=
" <a class=
\"
plusclass
\"
onclick=
\"
add2group(this.parentNode.parentNode)
\"
>(▲)</a>"
}
}
...
...
@@ -483,8 +483,8 @@ $("#Save_All").click(function(){
console
.
log
(
"click in save all 01"
)
var
sum__selected_elems
=
0
;
FlagsBuffer
[
"
to_
delete"
]
=
{}
FlagsBuffer
[
"
to_
keep"
]
=
{}
FlagsBuffer
[
"delete"
]
=
{}
FlagsBuffer
[
"keep"
]
=
{}
for
(
var
id
in
AjaxRecords
)
{
if
(
AjaxRecords
[
id
][
"state"
]
>
0
)
{
...
...
@@ -497,29 +497,39 @@ $("#Save_All").click(function(){
console
.
log
(
FlagsBuffer
)
// // [ = = = = For deleting subforms = = = = ]
// for(var i in FlagsBuffer["group
ed
"]) {
// if(FlagsBuffer["
to_
delete"][i]) {
// for(var j in FlagsBuffer["group
ed
"][i] ) {
// FlagsBuffer["
to_delete"][FlagsBuffer["grouped
"][i][j]] = true
// for(var i in FlagsBuffer["group"]) {
// if(FlagsBuffer["delete"][i]) {
// for(var j in FlagsBuffer["group"][i] ) {
// FlagsBuffer["
delete"][FlagsBuffer["group
"][i][j]] = true
// }
// }
// }
// // [ = = = = / For deleting subforms = = = = ]
var
nodes_2del
=
Object
.
keys
(
FlagsBuffer
[
"
to_
delete"
]).
map
(
Number
)
var
nodes_2keep
=
Object
.
keys
(
FlagsBuffer
[
"
to_
keep"
]).
map
(
Number
)
var
nodes_2group
=
FlagsBuffer
[
"group
ed
"
]
var
nodes_2del
=
Object
.
keys
(
FlagsBuffer
[
"delete"
]).
map
(
Number
)
var
nodes_2keep
=
Object
.
keys
(
FlagsBuffer
[
"keep"
]).
map
(
Number
)
var
nodes_2group
=
FlagsBuffer
[
"group"
]
var
list_id
=
$
(
"#list_id"
).
val
()
//DELETING
if
(
Object
.
keys
(
FlagsBuffer
[
"to_delete"
]).
length
>
0
)
{
var
corpus_id
=
getIDFromURL
(
"corpus"
)
// not used
CRUD
(
list_id
,
""
,
nodes_2del
,
"DELETE"
)
CRUD
(
list_id
,
"/keep"
,
nodes_2keep
,
"PUT"
)
});
function
CRUD
(
parent_id
,
action
,
nodes
,
http_method
)
{
var
the_url
=
window
.
location
.
origin
+
"/api/node/"
+
parent_id
+
"/ngrams"
+
action
+
"/"
+
nodes
.
join
(
"+"
);
if
(
nodes
.
length
>
0
)
{
$
.
ajax
({
method
:
"DELETE"
,
url
:
window
.
location
.
origin
+
'/annotations/lists/'
+
list_id
+
"/ngrams/"
+
nodes_2del
.
join
(
"+"
)
,
method
:
http_method
,
url
:
the_url
,
beforeSend
:
function
(
xhr
)
{
xhr
.
setRequestHeader
(
"X-CSRFToken"
,
getCookie
(
"csrftoken"
));
},
success
:
function
(
data
){
console
.
log
(
http_method
+
" ok!!"
)
console
.
log
(
nodes
)
console
.
log
(
data
)
},
error
:
function
(
result
)
{
...
...
@@ -527,9 +537,9 @@ $("#Save_All").click(function(){
console
.
log
(
result
)
}
});
}
});
}
}
function
Main_test
(
data
,
initial
)
{
...
...
templates/corpus/terms.html
View file @
215784f9
...
...
@@ -44,15 +44,15 @@ tr:hover {
background-color: #F5A9A9;
}*/
.
to_
delete
{
.delete
{
color
:
red
;
opacity
:
0.8
;
}
.
to_
keep
{
.keep
{
color
:
green
;
}
.group
ed
{
.group
{
color
:
white
;
pointer-events
:
none
;
cursor
:
default
;
...
...
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