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
c5f3fa91
Commit
c5f3fa91
authored
Jun 16, 2015
by
PkSM3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[UPDATE] Journals-table View
parent
23c71efb
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
821 additions
and
2 deletions
+821
-2
urls.py
gargantext_web/urls.py
+2
-0
Docs_dyna_chart_and_table.js
static/js/Docs_dyna_chart_and_table.js
+0
-0
Journals_dyna_chart_and_table.js
static/js/Journals_dyna_chart_and_table.js
+507
-0
NGrams_dyna_chart_and_table.js
static/js/NGrams_dyna_chart_and_table.js
+0
-0
corpus.html
templates/corpus.html
+1
-1
journals.html
templates/tests/journals.html
+257
-0
ngrams.html
templates/tests/ngrams.html
+1
-1
views.py
tests/ngramstable/views.py
+53
-0
No files found.
gargantext_web/urls.py
View file @
c5f3fa91
...
...
@@ -86,6 +86,8 @@ urlpatterns = patterns('',
url
(
r'^tests/move2trash/$'
,
views
.
move_to_trash_multiple
),
url
(
r'^project/(\d+)/corpus/(\d+)/ngrams/ngrams.json$'
,
samtest
.
test_ngrams
),
url
(
r'^project/(\d+)/corpus/(\d+)/ngrams$'
,
samtest
.
get_ngrams
),
url
(
r'^project/(\d+)/corpus/(\d+)/journals/journals.json$'
,
samtest
.
test_journals
),
url
(
r'^project/(\d+)/corpus/(\d+)/journals$'
,
samtest
.
get_journals
),
url
(
r'^corpus/(\d+)/document/(\d+)/testpage$'
,
samtest
.
test_test
)
)
...
...
static/js/dyna_chart_and_table.js
→
static/js/
Docs_
dyna_chart_and_table.js
View file @
c5f3fa91
File moved
static/js/Journals_dyna_chart_and_table.js
0 → 100644
View file @
c5f3fa91
function
pr
(
msg
)
{
console
.
log
(
msg
)
}
function
getCookie
(
name
)
{
var
cookieValue
=
null
;
if
(
document
.
cookie
&&
document
.
cookie
!=
''
)
{
var
cookies
=
document
.
cookie
.
split
(
';'
);
for
(
var
i
=
0
;
i
<
cookies
.
length
;
i
++
)
{
var
cookie
=
jQuery
.
trim
(
cookies
[
i
]);
// Does this cookie string begin with the name we want?
if
(
cookie
.
substring
(
0
,
name
.
length
+
1
)
==
(
name
+
'='
))
{
cookieValue
=
decodeURIComponent
(
cookie
.
substring
(
name
.
length
+
1
));
break
;
}
}
}
return
cookieValue
;
}
var
latest
,
oldest
;
var
TheBuffer
=
false
var
PossibleActions
=
[]
var
action1
=
{
"id"
:
"to_delete"
,
"name"
:
"Delete"
,
"color"
:
"red"
}
var
action2
=
{
"id"
:
"to_keep"
,
"name"
:
"Keep"
,
"color"
:
"green"
}
var
action3
=
{
"id"
:
"to_group"
,
"name"
:
"Group"
,
"color"
:
"blue"
}
PossibleActions
.
push
(
action1
)
PossibleActions
.
push
(
action2
)
PossibleActions
.
push
(
action3
)
var
FlagsBuffer
=
{}
for
(
var
i
in
PossibleActions
)
{
FlagsBuffer
[
PossibleActions
[
i
].
id
]
=
{}
}
var
MyTable
;
var
RecDict
=
{};
var
AjaxRecords
=
[]
// D3.js: Interactive timerange variables.
var
LineChart
=
dc
.
lineChart
(
"#monthly-move-chart"
);
var
volumeChart
=
dc
.
barChart
(
"#monthly-volume-chart"
);
function
Push2Buffer
(
NewVal
)
{
if
(
TheBuffer
==
false
)
{
if
(
!
NewVal
)
{
var
limits
=
[
oldest
,
latest
];
NewVal
=
limits
;
}
console
.
log
(
" - - - - - - "
)
console
.
log
(
"
\
tchanging to:"
)
console
.
log
(
NewVal
)
TheBuffer
=
NewVal
;
Final_UpdateTable
(
"changerange"
)
console
.
log
(
"- - - - - - -
\n
"
)
return
1
;
}
if
(
TheBuffer
!=
false
)
{
var
past
=
TheBuffer
[
0
]
+
"_"
+
TheBuffer
[
1
]
if
(
!
NewVal
)
{
var
limits
=
[
oldest
,
latest
];
NewVal
=
limits
;
}
var
now
=
NewVal
[
0
]
+
"_"
+
NewVal
[
1
]
if
(
past
!=
now
)
{
console
.
log
(
" - - - - - - "
)
console
.
log
(
"
\
tchanging to:"
)
console
.
log
(
NewVal
)
TheBuffer
=
NewVal
;
Final_UpdateTable
(
"changerange"
)
console
.
log
(
"- - - - - - -
\n
"
)
}
return
1
;
}
}
function
Final_UpdateTable
(
action
)
{
// (1) Identifying if the button is collapsed:
var
isCollapsed
=
false
;
var
accordiontext
=
$
(
"#collapseOne"
).
attr
(
"class"
)
if
(
accordiontext
.
indexOf
(
"collapse in"
)
>-
1
)
isCollapsed
=
true
;
var
UpdateTable
=
false
if
(
(
action
==
"click"
&&
!
isCollapsed
)
||
(
action
==
"changerange"
&&
isCollapsed
)
)
{
UpdateTable
=
true
;
$
(
"#corpusdisplayer"
).
html
(
"Close Folder"
)
}
else
$
(
"#corpusdisplayer"
).
html
(
"Open Folder"
)
pr
(
"update table??: "
+
UpdateTable
)
if
(
!
UpdateTable
)
return
false
;
//stop whatever you wanted to do.
var
TimeRange
=
AjaxRecords
;
var
dataini
=
(
TheBuffer
[
0
])?
TheBuffer
[
0
]:
oldest
;
var
datafin
=
(
TheBuffer
[
1
])?
TheBuffer
[
1
]:
latest
;
pr
(
"show me the pubs of the selected period"
)
pr
(
"
\
tfrom ["
+
dataini
+
"] to ["
+
datafin
+
"]"
)
pr
(
"
\
tfrom ["
+
oldest
+
"] to ["
+
latest
+
"]"
)
TimeRange
=
[]
for
(
var
i
in
AjaxRecords
)
{
if
(
AjaxRecords
[
i
].
score
>=
dataini
&&
AjaxRecords
[
i
].
score
<=
datafin
){
// pr( AjaxRecords[i].date+" : "+AjaxRecords[i].id )
TimeRange
.
push
(
AjaxRecords
[
i
])
}
}
MyTable
=
$
(
'#my-ajax-table'
).
dynatable
({
dataset
:
{
records
:
TimeRange
},
features
:
{
pushState
:
false
,
// sort: false
},
writers
:
{
_rowWriter
:
ulWriter
// _cellWriter: customCellWriter
}
});
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
originalRecords
=
[]
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
originalRecords
=
TimeRange
;
MyTable
.
data
(
'dynatable'
).
paginationPage
.
set
(
1
);
MyTable
.
data
(
'dynatable'
).
process
();
}
// STEP 01:
// Get all the duplicates using the Django-Garg API
var
current_docs
=
{}
var
BIS_dict
=
{}
var
url_elems
=
window
.
location
.
href
.
split
(
"/"
)
var
url_mainIDs
=
{}
for
(
var
i
=
0
;
i
<
url_elems
.
length
;
i
++
)
{
// if the this element is a number:
if
(
url_elems
[
i
]
!=
""
&&
!
isNaN
(
Number
(
url_elems
[
i
])))
{
url_mainIDs
[
url_elems
[
i
-
1
]]
=
Number
(
url_elems
[
i
]);
}
}
var
theurl
=
"/api/nodes/"
+
url_mainIDs
[
"corpus"
]
+
"/children/duplicates?keys=title&limit=9999"
// $.ajax({
// url: theurl,
// success: function(data) {
// bisarray = data.data
// for(var i in bisarray) {
// untitlebis = bisarray[i].values
// BIS_dict[untitlebis[0]] = [bisarray[i].count , 0];// [ total amount , removed ]
// }
// pr(BIS_dict)
// if(Object.keys(BIS_dict).length>0) $("#delAll").css("visibility", "visible"); $("#delAll").show();
// }
// });
function
getRecord
(
rec_id
)
{
return
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
originalRecords
[
rec_id
];
// return AjaxRecords[rec_id]
}
function
getRecords
()
{
return
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
originalRecords
;
}
function
transformContent2
(
rec_id
)
{
// pr("\t\ttransformContent2: "+rec_id)
var
elem
=
AjaxRecords
[
rec_id
];
var
result
=
{}
// console.log("\t\t\telement flag : "+elem["flag"])
if
(
elem
[
"flag"
])
{
result
[
"id"
]
=
elem
[
"id"
]
result
[
"score"
]
=
'<div class="'
+
elem
[
"flag"
]
+
'"><i>'
+
elem
[
"score"
]
+
'</div>'
result
[
"name"
]
=
'<div class="'
+
elem
[
"flag"
]
+
'"><i>'
+
elem
[
"name"
]
+
'</div>'
result
[
"flag"
]
=
'<input id='
+
rec_id
+
' onclick="overRide(this)" type="checkbox" checked/>'
}
else
{
result
[
"id"
]
=
elem
[
"id"
]
result
[
"score"
]
=
elem
[
"score"
]
result
[
"name"
]
=
elem
[
"name"
]
result
[
"flag"
]
=
'<input id='
+
rec_id
+
' onclick="overRide(this)" type="checkbox"/>'
}
return
result
;
}
function
overRide
(
elem
)
{
var
id
=
elem
.
id
var
current_flag
=
$
(
"input[type='radio'][name='radios']:checked"
).
val
()
var
this_newflag
=
(
current_flag
==
AjaxRecords
[
id
][
"flag"
])?
false
:
current_flag
console
.
log
(
"striking: "
+
id
+
" | this-elem_flag: "
+
AjaxRecords
[
id
][
"flag"
]
+
" | current_flag: "
+
current_flag
)
console
.
log
(
"
\
t so the new flag is: "
+
this_newflag
)
AjaxRecords
[
id
][
"flag"
]
=
Mark_NGram
(
id
,
AjaxRecords
[
id
][
"flag"
]
,
this_newflag
);
MyTable
.
data
(
'dynatable'
).
dom
.
update
();
}
function
transformContent
(
rec_id
,
header
,
content
)
{
if
(
header
==
"flag"
)
{
// pr("\t\ttransformContent1: "+rec_id)
if
(
content
==
true
)
return
'<input id='
+
rec_id
+
' onclick="overRide(this)" type="checkbox" checked/>'
if
(
content
==
false
)
return
'<input id='
+
rec_id
+
' onclick="overRide(this)" type="checkbox"/>'
}
else
return
content
;
}
function
Mark_NGram
(
ngram_id
,
old_flag
,
new_flag
)
{
if
(
new_flag
){
for
(
var
f
in
FlagsBuffer
)
{
if
(
new_flag
==
f
)
FlagsBuffer
[
f
][
ngram_id
]
=
true
;
else
delete
FlagsBuffer
[
f
][
ngram_id
];
}
}
else
{
delete
FlagsBuffer
[
old_flag
][
ngram_id
];
}
return
new_flag
;
}
//generic enough
function
ulWriter
(
rowIndex
,
record
,
columns
,
cellWriter
)
{
// pr("\tulWriter: "+record.id)
var
tr
=
''
;
var
cp_rec
=
{}
if
(
!
MyTable
)
{
for
(
var
i
in
record
)
{
cp_rec
[
i
]
=
transformContent
(
RecDict
[
record
.
id
],
i
,
record
[
i
])
}
}
else
{
// pr("\t\tbfr transf2: rec_id="+record.id+" | arg="+RecDict[record.id])
cp_rec
=
transformContent2
(
RecDict
[
record
.
id
])
}
// grab the record's attribute for each column
// console.log("\tin ulWriter:")
// console.log(record)
for
(
var
i
=
0
,
len
=
columns
.
length
;
i
<
len
;
i
++
)
{
tr
+=
cellWriter
(
columns
[
i
],
cp_rec
);
}
var
data_id
=
RecDict
[
record
.
id
]
return
'<tr data-stuff='
+
data_id
+
'>'
+
tr
+
'</tr>'
;
}
function
Main_test
(
data
,
initial
)
{
var
DistributionDict
=
{}
for
(
var
i
in
DistributionDict
)
delete
DistributionDict
[
i
];
delete
DistributionDict
;
DistributionDict
=
{}
AjaxRecords
=
[]
var
FirstScore
=
initial
;
var
arrayd3
=
[]
// div_table += "\t"+"\t"+"\t"+'<input type="checkbox" id="multiple_selection" onclick="SelectAll(this);" /> Select'+"\n"
$
(
"#div-table"
).
html
(
""
)
$
(
"#div-table"
).
empty
();
var
div_table
=
'<p align="right">'
+
"
\n
"
div_table
+=
'<table id="my-ajax-table" class="table table-bordered table-hover">'
+
"
\n
"
div_table
+=
"
\
t"
+
'<thead>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<th data-dynatable-column="name">Title</th>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<th data-dynatable-column="score" data-dynatable-sorts="score">No. Pubs</th>'
+
"
\n
"
// div_table += "\t"+"\t"+'<th id="score_column_id" data-dynatable-sorts="score" data-dynatable-column="score">Score</th>'+"\n"
div_table
+=
"
\
t"
+
"
\
t"
+
'</th>'
+
"
\n
"
div_table
+=
"
\
t"
+
'</thead>'
+
"
\n
"
div_table
+=
"
\
t"
+
'<tbody>'
+
"
\n
"
div_table
+=
"
\
t"
+
'</tbody>'
+
"
\n
"
div_table
+=
'</table>'
+
"
\n
"
div_table
+=
'</p>'
;
$
(
"#div-table"
).
html
(
div_table
)
// $("#stats").html(div_stats)
var
ID
=
0
for
(
var
i
in
data
)
{
console
.
log
(
i
)
// var le_ngram = data.ngrams[i]
var
orig_id
=
ID
var
arr_id
=
parseInt
(
ID
)
RecDict
[
orig_id
]
=
arr_id
;
var
url_title
=
encodeURIComponent
(
i
)
//.replace(" ","+")
// url_title = i.replace(" ","+")
var
node_info
=
{
"id"
:
ID
,
"name"
:
'<a target=_blank href="http://google.com/search?q='
+
url_title
+
'">'
+
i
+
'</a>'
,
"score"
:
data
[
i
],
}
AjaxRecords
.
push
(
node_info
)
if
(
!
DistributionDict
[
node_info
.
score
]
)
DistributionDict
[
node_info
.
score
]
=
0
;
DistributionDict
[
node_info
.
score
]
++
;
ID
++
;
}
// console.log("The Distribution!:")
// console.log(Distribution)
var
DistributionList
=
[]
var
min_occ
=
99999
,
max_occ
=-
1
,
min_frec
=
99999
,
max_frec
=-
1
;
for
(
var
i
in
DistributionDict
)
{
var
info
=
{
"x_occ"
:
Number
(
i
),
"y_frec"
:
DistributionDict
[
i
]
}
DistributionList
.
push
(
info
)
if
(
info
.
x_occ
>
max_occ
)
max_occ
=
info
.
x_occ
if
(
info
.
x_occ
<
min_occ
)
min_occ
=
info
.
x_occ
if
(
info
.
y_frec
>
max_frec
)
max_frec
=
info
.
y_frec
if
(
info
.
y_frec
<
min_frec
)
min_frec
=
info
.
y_frec
}
oldest
=
Number
(
min_occ
);
latest
=
Number
(
max_occ
);
var
ndx
=
false
;
ndx
=
crossfilter
();
ndx
.
add
(
DistributionList
);
// x_occs = ndx.dimension(dc.pluck('x_occ'));
var
x_occs
=
ndx
.
dimension
(
function
(
d
)
{
return
d
.
x_occ
;
});
var
y_frecs
=
x_occs
.
group
().
reduceSum
(
function
(
d
)
{
return
d
.
y_frec
;
});
console
.
log
(
"scores: [ "
+
min_occ
+
" , "
+
max_occ
+
" ] "
)
console
.
log
(
"frecs: [ "
+
min_frec
+
" , "
+
max_frec
+
" ] "
)
LineChart
.
width
(
800
)
.
height
(
150
)
.
margins
({
top
:
10
,
right
:
50
,
bottom
:
25
,
left
:
40
})
.
group
(
y_frecs
)
.
dimension
(
x_occs
)
.
transitionDuration
(
500
)
.
x
(
d3
.
scale
.
linear
().
domain
([
min_occ
,
max_occ
+
min_occ
]))
// .y(d3.scale.log().domain([min_frec/2,max_frec*2]))
.
renderArea
(
true
)
// .valueAccessor(function (d) {
// return d.value;
// })
// .stack(y_frecs, function (d) {
// return d.value;
// })
// .ordinalColors(d3.scale.category10())
.
elasticY
(
true
)
// .round(dc.round.floor)
.
renderHorizontalGridLines
(
true
)
.
renderVerticalGridLines
(
true
)
// .colors('red')
// .interpolate("monotone")
// .renderDataPoints({radius: 2, fillOpacity: 0.8, strokeOpacity: 0.8})
.
brushOn
(
false
)
.
title
(
function
(
d
)
{
var
value
=
d
.
value
.
avg
?
d
.
value
.
avg
:
d
.
value
;
if
(
isNaN
(
value
))
value
=
0
;
return
value
+
" ngrams with "
+
FirstScore
+
"="
+
Number
(
d
.
key
);
})
.
xAxis
();
LineChart
.
yAxis
().
ticks
(
5
)
LineChart
.
render
()
volumeChart
.
width
(
800
)
.
height
(
100
)
.
margins
({
top
:
30
,
right
:
50
,
bottom
:
20
,
left
:
40
})
.
dimension
(
x_occs
)
.
group
(
y_frecs
)
.
centerBar
(
true
)
.
gap
(
5
)
.
x
(
d3
.
scale
.
linear
().
domain
([
min_occ
/
2
,
max_occ
+
min_occ
]))
.
y
(
d3
.
scale
.
sqrt
().
domain
([
min_frec
/
2
,
max_frec
+
min_frec
]))
// .elasticY(true)
// // .round(d3.time.month.round)
// // .xUnits(d3.time.months)
.
renderlet
(
function
(
chart
)
{
chart
.
select
(
"g.y"
).
style
(
"display"
,
"none"
);
LineChart
.
filter
(
chart
.
filter
());
console
.
log
(
"lalaal moveChart.focus(chartfilt);"
)
})
.
on
(
"filtered"
,
function
(
chart
)
{
dc
.
events
.
trigger
(
function
()
{
var
chartfilt
=
chart
.
filter
()
// tricky part: identifying when the moveChart changes.
if
(
chartfilt
)
{
Push2Buffer
(
chart
.
filter
()
)
}
else
{
if
(
TheBuffer
)
{
Push2Buffer
(
false
)
}
}
LineChart
.
focus
(
chartfilt
);
});
})
.
xAxis
()
volumeChart
.
yAxis
().
ticks
(
5
)
volumeChart
.
render
()
LineChart
.
filterAll
();
volumeChart
.
filterAll
();
dc
.
redrawAll
();
MyTable
=
[]
MyTable
=
$
(
'#my-ajax-table'
).
dynatable
({
dataset
:
{
records
:
AjaxRecords
},
features
:
{
pushState
:
false
,
// sort: false //i need to fix the sorting function... the current one just sucks
},
writers
:
{
_rowWriter
:
ulWriter
// _cellWriter: customCellWriter
}
});
// MyTable.data('dynatable').settings.dataset.records = []
// MyTable.data('dynatable').settings.dataset.originalRecords = []
// MyTable.data('dynatable').settings.dataset.originalRecords = AjaxRecords;
MyTable
.
data
(
'dynatable'
).
paginationPage
.
set
(
1
);
// MyTable.data('dynatable').process();
// MyTable.data('dynatable').sorts.clear();
MyTable
.
data
(
'dynatable'
).
process
();
// // // $("#score_column_id").children()[0].text = FirstScore
// // // // MyTable.data('dynatable').process();
if
(
$
(
".imadiv"
).
length
>
0
)
return
1
;
$
(
'<br><br><div class="imadiv"></div>'
).
insertAfter
(
".dynatable-per-page"
)
$
(
".dynatable-record-count"
).
insertAfter
(
".imadiv"
)
$
(
".dynatable-pagination-links"
).
insertAfter
(
".imadiv"
)
return
"OK"
}
console
.
log
(
window
.
location
.
href
+
"/journals.json"
)
$
.
ajax
({
url
:
window
.
location
.
href
+
"/journals.json"
,
success
:
function
(
data
){
console
.
log
(
data
)
// // Initializing the Charts and Table
var
result
=
Main_test
(
data
,
"FirstScore"
)
console
.
log
(
result
)
}
});
\ No newline at end of file
static/js/
test
_dyna_chart_and_table.js
→
static/js/
NGrams
_dyna_chart_and_table.js
View file @
c5f3fa91
File moved
templates/corpus.html
View file @
c5f3fa91
...
...
@@ -201,7 +201,7 @@ th a {
<script
type=
"text/javascript"
src=
"{% static "
js
/
jquery
/
jquery
.
dynatable
.
js
"
%}"
></script>
<!-- custom-lib for dynatable.js and dc.js -->
<script
type=
"text/javascript"
src=
"{% static "
js
/
dyna_chart_and_table
.
js
"
%}"
></script>
<script
type=
"text/javascript"
src=
"{% static "
js
/
Docs_
dyna_chart_and_table
.
js
"
%}"
></script>
...
...
templates/tests/journals.html
0 → 100644
View file @
c5f3fa91
{% extends "menu.html" %}
{% block css %}
{% load staticfiles %}
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static "
css
/
bootstrap
.
css
"
%}"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static "
css
/
morris
.
css
"
%}"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static "
css
/
jquery
.
easy-pie-chart
.
css
"%}"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static "
css
/
dc
.
css
"%}"
/>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static "
css
/
jquery
.
dynatable
.
css
"%}"
/>
<script
type=
"text/javascript"
src=
"{% static "
js
/
charts
/
d3
.
js
"%}"
></script>
<script
type=
"text/javascript"
src=
"{% static "
js
/
charts
/
crossfilter
.
js
"%}"
></script>
<!-- <script type="text/javascript" src="http://localhost/i7/js_examples/DC_linear/dc.js"></script> -->
<script
type=
"text/javascript"
src=
"{% static "
js
/
charts
/
dc
.
js
"%}"
></script>
<style>
.no-transition
{
-webkit-transition
:
height
0.1s
;
-moz-transition
:
height
0.1s
;
-ms-transition
:
height
0.1s
;
-o-transition
:
height
0.1s
;
transition
:
height
0.1s
;
}
th
{
color
:
#fff
;
}
th
a
{
color
:
#fff
;
font-weight
:
normal
;
font-style
:
italic
;
font-size
:
0.9em
;
}
/*tr:hover {
cursor: pointer;
color: #000;
font-weight: bold;
}*/
.to_delete
{
color
:
red
;
opacity
:
0.8
;
}
.to_group
{
color
:
blue
;
}
.to_keep
{
color
:
green
;
}
.dynatable-record-count
{
font-size
:
0.7em
;
}
.dynatable-pagination-links
{
font-size
:
0.7em
;
}
input
[
type
=
radio
]
{
display
:
none
;
}
input
[
type
=
radio
]
+
label
{
display
:
inline-block
;
margin
:
-2px
;
padding
:
4px
12px
;
margin-bottom
:
0
;
font-size
:
14px
;
line-height
:
20px
;
color
:
#333
;
text-align
:
center
;
text-shadow
:
0
1px
1px
rgba
(
255
,
255
,
255
,
0.75
);
vertical-align
:
middle
;
cursor
:
pointer
;
background-color
:
#f5f5f5
;
background-image
:
-moz-linear-gradient
(
top
,
#fff
,
#e6e6e6
);
background-image
:
-webkit-gradient
(
linear
,
0
0
,
0
100%
,
from
(
#fff
),
to
(
#e6e6e6
));
background-image
:
-webkit-linear-gradient
(
top
,
#fff
,
#e6e6e6
);
background-image
:
-o-linear-gradient
(
top
,
#fff
,
#e6e6e6
);
background-image
:
linear-gradient
(
to
bottom
,
#fff
,
#e6e6e6
);
background-repeat
:
repeat-x
;
border
:
1px
solid
#ccc
;
border-color
:
#e6e6e6
#e6e6e6
#bfbfbf
;
border-color
:
rgba
(
0
,
0
,
0
,
0.1
)
rgba
(
0
,
0
,
0
,
0.1
)
rgba
(
0
,
0
,
0
,
0.25
);
border-bottom-color
:
#b3b3b3
;
filter
:
progid
:
DXImageTransform
.
Microsoft
.
gradient
(
startColorstr
=
'#ffffffff'
,
endColorstr
=
'#ffe6e6e6'
,
GradientType
=
0
);
filter
:
progid
:
DXImageTransform
.
Microsoft
.
gradient
(
enabled
=
false
);
-webkit-box-shadow
:
inset
0
1px
0
rgba
(
255
,
255
,
255
,
0.2
),
0
1px
2px
rgba
(
0
,
0
,
0
,
0.05
);
-moz-box-shadow
:
inset
0
1px
0
rgba
(
255
,
255
,
255
,
0.2
),
0
1px
2px
rgba
(
0
,
0
,
0
,
0.05
);
box-shadow
:
inset
0
1px
0
rgba
(
255
,
255
,
255
,
0.2
),
0
1px
2px
rgba
(
0
,
0
,
0
,
0.05
);
}
input
[
type
=
radio
]
:checked
+
label
{
background-image
:
none
;
outline
:
0
;
-webkit-box-shadow
:
inset
0
2px
4px
rgba
(
0
,
0
,
0
,
0.15
),
0
1px
2px
rgba
(
0
,
0
,
0
,
0.05
);
-moz-box-shadow
:
inset
0
2px
4px
rgba
(
0
,
0
,
0
,
0.15
),
0
1px
2px
rgba
(
0
,
0
,
0
,
0.05
);
box-shadow
:
inset
0
2px
4px
rgba
(
0
,
0
,
0
,
0.15
),
0
1px
2px
rgba
(
0
,
0
,
0
,
0.05
);
background-color
:
#e0e0e0
;
}
</style>
{% endblock %}
{% block content %}
<div
class=
"container theme-showcase"
role=
"main"
>
<div
class=
"jumbotron"
>
{% if project %}
<h1>
{{ project.name }}, {{ corpus.name }}
</h1>
{% endif %}
{% if corpus %}
<p>
Created on {{ corpus.date }}
</p>
<div
id=
"stats"
></div>
{% endif %}
<!-- <a class="btn btn-primary btn-lg" role="button" href="/admin/documents/corpus/{{ corpus.id }}/">Add file</a> -->
<a
class=
"btn btn-primary btn-lg"
role=
"button"
href=
"/project/{{project.id}}/corpus/{{ corpus.id }}/corpus.csv"
>
Save as
</a>
<a
class=
"btn btn-primary btn-lg"
role=
"button"
href=
"/delete/{{ corpus.id }}"
>
Delete
</a></p>
{% if number == 0 %}
<a
class=
"btn btn-primary btn-lg"
role=
"button"
href=
"/admin/documents/corpus/{{ corpus.id }}/"
>
Add documents
</a></p>
{% endif %}
</div>
</div>
<div
class=
"container"
>
<div
class=
"container"
>
<div
class=
"row"
>
<center>
<div
id=
"ScoresBox"
></div>
<br>
(Blue bars: all, Green line: zoom)
<a
class=
"reset"
href=
"javascript:volumeChart.filterAll();dc.redrawAll();"
style=
"display: none;"
>
reset
</a>
<div
class=
"clearfix"
></div>
</center>
<div
id=
"monthly-move-chart"
></div>
</div>
<div
class=
"row"
>
<div
id=
"monthly-volume-chart"
></div>
<p
class=
"muted pull-left"
style=
"margin-right: 15px;"
>
Select a time range to zoom in
</p>
</div>
</div>
<p
align=
"center"
>
<a
class=
"btn btn-xs btn-default"
role=
"button"
href=
"/chart/corpus/{{ corpus.id }}/data.csv"
>
Save
</a></p>
<div
class=
"container"
>
<div
class=
"jumbotron"
>
<div
class=
"panel-group"
id=
"accordion"
role=
"tablist"
aria-multiselectable=
"true"
>
<div
class=
"panel panel-body"
>
<div
class=
"panel-heading"
>
<h4
class=
"panel-title"
>
<a
data-toggle=
"collapse"
data-parent=
"#accordion"
href=
"#collapseOne"
>
<p
id=
"corpusdisplayer"
onclick=
'Final_UpdateTable("click")'
class=
"btn btn-primary btn-lg"
style=
"width:200px; margin:0 auto; display:block;"
>
Open Folder
</h2></p>
</a>
</h4>
</div>
<div
id=
"collapseOne"
class=
"panel-collapse collapse no-transition"
role=
"tabpanel"
>
<div
class=
"panel-body"
>
<div
id=
"div-table"
></div>
<!-- <p align="right">
<table id="my-ajax-table" class="table table-bordered">
<thead>
<th data-dynatable-column="name">Title</th>
<th id="score_column_id" data-dynatable-sorts="score" data-dynatable-column="score">Score</th>
<th data-dynatable-column="del" data-dynatable-no-sort="true">
<input type="checkbox" id="multiple_selection" onclick="SelectAll(this);" /> Select
</th>
</thead>
<tbody>
</tbody>
</table>
</p> -->
</div>
</div>
</div>
</div>
</div>
</div>
<div
class=
"container"
>
<div
class=
"row"
>
<div
class=
"col-md-4"
>
<div
class=
"jumbotron"
>
<h3><a
href=
"/project/{{project.id}}/corpus/{{corpus.id}}/chart"
>
Advanced charts
</a></h3>
<ol>
<li>
Count
</li>
<!-- read, compute -->
<li>
Filter
</li>
<!-- count, compute -->
<li>
Compare
</li>
<!-- select, cut -->
</ol>
<h4><a
href=
"/project/{{project.id}}/corpus/{{corpus.id}}/"
>
Back to corpus
</a></h3>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"jumbotron"
>
<h3><a
href=
"/project/{{project.id}}/corpus/{{corpus.id}}/matrix"
>
Matrix
</a></h3>
<ol>
<li>
Sort
</li>
<li>
Group
</li>
<li>
Cluster
</li>
</ol>
<h4><a
href=
"/project/{{project.id}}/corpus/{{corpus.id}}/"
>
Back to corpus
</a></h3>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"jumbotron"
>
{% if processing > 0 %}
<h3>
<img
width=
"20px"
src=
"{% static "
js
/
libs
/
img2
/
loading-bar
.
gif
"
%}"
></img>
Graph (later)
</h3>
{% else %}
<h3><a
href=
"/project/{{project.id}}/corpus/{{ corpus.id }}/explorer"
>
Graph
</a></h3>
{% endif %}
<ol>
<li>
Visualize
</li>
<li>
Explore
</li>
<li>
Read
</li>
</ol>
<h4><a
href=
"/project/{{project.id}}/corpus/{{corpus.id}}/"
>
Back to corpus
</a></h3>
</div>
</div>
</div>
</div>
<script
type=
"text/javascript"
src=
"{% static "
js
/
jquery
/
jquery
.
min
.
js
"
%}"
></script>
<script
src=
"{% static "
js
/
charts
/
bootstrap
.
min
.
js
"
%}"
></script>
<script
type=
"text/javascript"
src=
"{% static "
js
/
jquery
/
jquery
.
dynatable
.
js
"
%}"
></script>
<!-- custom-lib for dynatable.js and dc.js -->
<script
type=
"text/javascript"
src=
"{% static "
js
/
Journals_dyna_chart_and_table
.
js
"
%}"
></script>
{% endblock %}
templates/tests/ngrams.html
View file @
c5f3fa91
...
...
@@ -281,7 +281,7 @@ input[type=radio]:checked + label {
<script
type=
"text/javascript"
src=
"{% static "
js
/
jquery
/
jquery
.
dynatable
.
js
"
%}"
></script>
<!-- custom-lib for dynatable.js and dc.js -->
<script
type=
"text/javascript"
src=
"{% static "
js
/
test
_dyna_chart_and_table
.
js
"
%}"
></script>
<script
type=
"text/javascript"
src=
"{% static "
js
/
NGrams
_dyna_chart_and_table
.
js
"
%}"
></script>
...
...
tests/ngramstable/views.py
View file @
c5f3fa91
...
...
@@ -162,6 +162,59 @@ def test_test(request , corpus_id , doc_id):
return
JsonHttpResponse
(
results
)
def
get_journals
(
request
,
project_id
,
corpus_id
):
if
not
request
.
user
.
is_authenticated
():
return
redirect
(
'/login/?next=
%
s'
%
request
.
path
)
try
:
offset
=
int
(
project_id
)
offset
=
int
(
corpus_id
)
except
ValueError
:
raise
Http404
()
t
=
get_template
(
'tests/journals.html'
)
user
=
cache
.
User
[
request
.
user
.
username
]
.
id
date
=
datetime
.
datetime
.
now
()
project
=
cache
.
Node
[
int
(
project_id
)]
corpus
=
cache
.
Node
[
int
(
corpus_id
)]
type_doc_id
=
cache
.
NodeType
[
'Document'
]
.
id
number
=
session
.
query
(
func
.
count
(
Node
.
id
))
.
filter
(
Node
.
parent_id
==
corpus_id
,
Node
.
type_id
==
type_doc_id
)
.
all
()[
0
][
0
]
try
:
processing
=
corpus
.
hyperdata
[
'Processing'
]
except
Exception
as
error
:
print
(
error
)
processing
=
0
html
=
t
.
render
(
Context
({
'debug'
:
settings
.
DEBUG
,
'user'
:
user
,
'date'
:
date
,
'project'
:
project
,
'corpus'
:
corpus
,
'processing'
:
processing
,
'number'
:
number
,
}))
return
HttpResponse
(
html
)
def
test_journals
(
request
,
project_id
,
corpus_id
):
results
=
[
"hola"
,
"mundo"
]
JournalsDict
=
{}
user_id
=
request
.
user
.
id
document_type_id
=
cache
.
NodeType
[
'Document'
]
.
id
documents
=
session
.
query
(
Node
)
.
filter
(
Node
.
user_id
==
user_id
,
Node
.
parent_id
==
corpus_id
,
Node
.
type_id
==
document_type_id
)
.
all
()
for
doc
in
documents
:
if
"journal"
in
doc
.
hyperdata
:
journal
=
doc
.
hyperdata
[
"journal"
]
if
journal
not
in
JournalsDict
:
JournalsDict
[
journal
]
=
0
JournalsDict
[
journal
]
+=
1
return
JsonHttpResponse
(
JournalsDict
)
def
test_ngrams
(
request
,
project_id
,
corpus_id
):
results
=
[
"hola"
,
"mundo"
]
...
...
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