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
d4fe6e84
Commit
d4fe6e84
authored
Oct 25, 2016
by
c24b
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remobve include with
parent
97ca8f84
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
1121 additions
and
9 deletions
+1121
-9
myGraphs.html
templates/pages/corpora/myGraphs.html
+1
-1
sources.html
templates/pages/corpora/sources.html
+1
-1
terms.html
templates/pages/corpora/terms.html
+1
-1
titles.html
templates/pages/corpora/titles.html
+1
-1
menu.html
templates/pages/menu.html
+16
-3
corpora_list.tpl
templates/pages/projects/corpora_list.tpl
+120
-0
modals.tpl
templates/pages/projects/modals.tpl
+103
-0
moissonneurs.js
templates/pages/projects/moissonneurs.js
+290
-0
old_project.html
templates/pages/projects/old_project.html
+318
-0
overview.html
templates/pages/projects/overview.html
+1
-1
project.html
templates/pages/projects/project.html
+1
-1
statuses.tpl
templates/pages/projects/statuses.tpl
+81
-0
validate_form.js
templates/pages/projects/validate_form.js
+100
-0
validators.js
templates/pages/projects/validators.js
+87
-0
No files found.
templates/pages/corpora/myGraphs.html
View file @
d4fe6e84
{% extends "pages/menu.html" with user_parameters%}
{% extends "pages/menu.html" with user_parameters
=user_parameters
%}
{% block css %}
{% block css %}
...
...
templates/pages/corpora/sources.html
View file @
d4fe6e84
{% extends "pages/menu.html" with user_parameters%}
{% extends "pages/menu.html" with user_parameters
=user_parameters
%}
{% block css %}
{% block css %}
{% load staticfiles %}
{% load staticfiles %}
...
...
templates/pages/corpora/terms.html
View file @
d4fe6e84
{% extends "pages/menu.html" with user_parameters%}
{% extends "pages/menu.html" with user_parameters
=user_parameters
%}
{% load staticfiles %}
{% load staticfiles %}
{% block css %}
{% block css %}
...
...
templates/pages/corpora/titles.html
View file @
d4fe6e84
{% extends "pages/menu.html" with user_parameters%}
{% extends "pages/menu.html" with user_parameters
=user_parameters
%}
{% load staticfiles %}
{% load staticfiles %}
{% block css %}
{% block css %}
...
...
templates/pages/menu.html
View file @
d4fe6e84
...
@@ -68,6 +68,8 @@
...
@@ -68,6 +68,8 @@
{% endif %}
{% endif %}
</ul>
</ul>
<ul
class=
"nav navbar-nav pull-right"
>
<ul
class=
"nav navbar-nav pull-right"
>
<li
class=
"dropdown"
>
<li
class=
"dropdown"
>
<a
href=
"#"
role=
"button"
class=
"dropdown-toggle navbar-text"
data-toggle=
"dropdown"
title=
"That is your username"
>
<a
href=
"#"
role=
"button"
class=
"dropdown-toggle navbar-text"
data-toggle=
"dropdown"
title=
"That is your username"
>
...
@@ -102,10 +104,21 @@
...
@@ -102,10 +104,21 @@
{% endif %}
{% endif %}
</ul>
</ul>
</li>
</li>
<li
class=
"lang"
>
<a
href=
"#"
role=
"button"
class=
"dropdown-toggle navbar-text"
>
{% if user_parameters.language == "fr" %}
<img
value=
"{{user_parameters.language}}"
src=
"{% static "
img
/
fr
.
png
"%}"
width=
"45%"
/>
{%else %}
<img
value=
"{{user_parameters.language}}"
src=
"{% static "
img
/
en
.
png
"%}"
width=
"45%"
/>
{%endif%}
{{user_parameters.language}}
</a>
</li>
</ul>
</ul>
<ul
class=
"nav navbar-nav pull-right"
>
<button
class=
"btn primary_keylang"
>
{{user_parameters["language"]}}
</button>
</ul>
</div>
</div>
</div>
</div>
{% if corpus %}
{% if corpus %}
...
...
templates/pages/projects/corpora_list.tpl
0 → 100644
View file @
d4fe6e84
{
%
if
list_corpora
%
}
{% for key, corpora in list_corpora.items %}
<h2>
<div
class=
"row"
>
<div
class=
"col-md-1 content"
></div>
<span
class=
"glyphicon glyphicon-cd"
aria-hidden=
"true"
></span>
{{ key }}
</h2>
{% for corpus in corpora %}
<div
id=
"corpus_{
{
corpus
.
id
}
}"
>
<div
class=
"row"
>
<h4>
<div
class=
"col-md-1 content"
></div>
<div
class=
"col-md-5 content"
>
<a
href=
"/projects/{
{
project
.
id
}
}/corpora/{
{
corpus
.
id
}
}"
>
<span
class=
"glyphicon glyphicon-file"
aria-hidden=
"true"
></span>
{
{
corpus
.
name
}
}, {{ corpus.count }} documents {{ corpus.status_message }}
</a>
</div>
<div
class=
"col-md-3 content"
>
<!-- -->
{% for state in corpus.hyperdata.statuses %}
{% ifequal state.action "Workflow" %}
{% if state.complete %}
<a
href=
"/projects/{
{
project
.
id
}
}/corpora/{
{
corpus
.
id
}
}"
title=
"View the corpus"
>
<button
type=
"button"
class=
"btn btn-default"
aria-label=
"Left Align"
>
<span
class=
"glyphicon glyphicon-eye-open"
aria-hidden=
"true"
></span>
</button>
</a>
<button
type=
"button"
class=
"btn btn-default yopla"
data-container=
"body"
data-toggle=
"popover"
data-placement=
"bottom"
data-trigger=
"focus"
data-content=
"
<ul>
<li
onclick="
garganrest.metrics.update({
{
corpus
.
id
}
}, function()
{
alert
(
'The corpus ({{corpus.name|escapejs}}) was updated'
)
}
);
">
<a href='#'>Recalculate ngram metrics</a> <br/> (can take a little while)
</li>
</ul>
"
>
<span
class=
"glyphicon glyphicon-repeat"
aria-hidden=
"true"
title=
'Recalculate ngram scores and similarities'
></span>
</button>
{% endif %}
<!-- TODO: delete non seulement si state.complete mais aussi si state.error -->
<button
type=
"button"
class=
"btn btn-default"
data-container=
"body"
data-toggle=
"popover"
data-placement=
"bottom"
data-content=
"
<ul>
<li
onclick="
garganrest.nodes.delete({
{
corpus
.
id
}
}, function()
{
$
(
'#corpus_'
+
{{
corpus
.
id
}}
).
remove
()
}
);
$(this).parent().parent().remove();
">
<a href='#'>Delete this</a>
</li>
</ul>
"
>
<span
class=
"glyphicon glyphicon-trash"
aria-hidden=
"true"
title=
'Delete this corpus'
></span>
</button>
{% endifequal %}
{% endfor %}
</div>
<div
class=
"col-md-3 content"
>
{% for state in corpus.hyperdata.statuses %}
{% ifequal state.action "Workflow" %}
{% if state.complete %}
<span
class=
"glyphicon glyphicon-ok"
aria-hidden=
"true"
></span>
{% else %}
{% if state.error %}
<span
class=
"glyphicon glyphicon-exclamation-sign"
aria-hidden=
"true"
></span>
{{ state.error }}
{% else %}
<div
class=
"progress"
>
<div
class=
" progress-bar progress-bar-striped
progress-bar-success
"
role=
"progressbar"
aria-valuenow=
"45"
aria-valuemin=
"0"
aria-valuemax=
"100"
style=
"width: 20%"
>
<span>
Upload
</span>
</div>
{% for state in corpus.hyperdata.statuses %}
<div
class=
" progress-bar progress-bar-striped
{% if state.complete %}
progress-bar-success
{% else %}
active
{% endif %}
"
role=
"progressbar"
aria-valuenow=
"45"
aria-valuemin=
"0"
aria-valuemax=
"100"
style=
"width: 20%"
>
<span>
{{ state.action }}
{% if not state.complete %}
Processing
{% endif %}
</span>
</div>
{% endfor %}
</div>
{% endif %}
{% endif %}
{% endifequal %}
{% endfor %}
</div>
<div
class=
"col-md-1 content"
></div>
</h4>
</div>
</div>
{% endfor %}
{% endfor %}
{% endif %}
templates/pages/projects/modals.tpl
0 → 100644
View file @
d4fe6e84
<div
class=
"modal fade"
id=
"stack1"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"myModalLabel"
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-hidden=
"true"
>
×
</button>
<h3>
Query to PubMed
</h3>
</div>
<div
class=
"modal-body"
>
<p>
One fine body…
</p>
<input
id=
"daquery"
type=
"text"
class=
"input-lg"
data-tabindex=
"2"
>
<a
onclick=
"getGlobalResults();"
class=
"btn"
>
Scan
</a>
<div
id=
"results"
></div>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
Close
</button>
<button
onclick=
"doTheQuery();"
disabled
id=
"id_thebutton"
type=
"button"
class=
"btn btn-primary"
>
Explore a sample!
</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<!-- Modal -->
<div
class=
"modal fade"
id=
"addcorpus"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"myModalLabel2"
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-hidden=
"true"
>
×
</button>
<h3>
Add a Corpus
<a
href=
"https://gogs.iscpif.fr/humanities/faq_gargantext/wiki/FAQ#import--export-a-dataset"
>
<span
class=
"glyphicon glyphicon-question-sign"
aria-hidden=
"true"
></span>
</a>
</h3>
</div>
<div
class=
"modal-body"
>
<!-- FAQ -->
<form
id=
"id_form"
enctype=
"multipart/form-data"
action=
"/projects/{
{
project
.
id
}
}/"
method=
"post"
>
{% csrf_token %}
<table
cellpadding=
"5"
>
{% for field in form %}
<tr>
<th>
{
{
field
.
label_tag
}
}
</th>
<td>
{{ field.errors }}
{{ field }}
{% if field.name == 'name' %}
<span
onclick=
"getGlobalResults(this);"
id=
"scanpubmed"
></span>
<div
id=
"theresults"
></div>
{% endif %}
</td>
</tr>
{% endfor %}
<tr>
<th></th>
<td>
<div
id=
"pubmedcrawl"
style=
"visibility: hidden;"
>
Do you have a file already?
<input
type=
"radio"
id=
"file_yes"
name=
"file1"
onclick=
"FileOrNotFile(this.value);"
class=
"file1"
value=
"true"
checked
>
Yes
</input>
<input
type=
"radio"
id=
"file_no"
name=
"file1"
onclick=
"FileOrNotFile(this.value);"
class=
"file1"
value=
"false"
>
No
</input>
</div>
</td>
</tr>
</table>
</form>
<div
class=
"modal-footer"
>
<!-- <div id="pubmedcrawl" align="right" style="visibility: hidden;"><a data-toggle="modal" href="#stack1">➞ Query directly in PubMed</a></div> -->
<button
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
<span
class=
"glyphicon glyphicon-remove"
aria-hidden=
"true"
></span>
Close
</button>
<button
onclick=
'bringDaNoise();'
id=
"submit_thing"
disabled
class=
"btn btn-primary"
>
<span
class=
"glyphicon glyphicon-ok"
aria-hidden=
"true"
></span>
Process this!
</button><span
id=
"simpleloader"
></span>
</div>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<!-- Modal -->
<div
id=
"wait"
class=
"modal fade"
>
<div
class=
"modal-dialog"
role=
"document"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
>
<span
aria-hidden=
"true"
>
×
</span>
</button>
<h2
class=
"modal-title"
><h2><span
class=
"glyphicon glyphicon-info-sign"
aria-hidden=
"true"
></span>
Uploading corpus...
</h2>
</div>
<div
class=
"modal-body"
>
<h5>
Your file has been uploaded !
Gargantext need some time to eat it.
Duration depends on the size of the dish.
</h5>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-secondary"
data-dismiss=
"modal"
>
Continue on Gargantext
</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
templates/pages/projects/moissonneurs.js
0 → 100644
View file @
d4fe6e84
<
script
>
var
thequeries
=
[]
;
// load the template's value for N scan size
var
querySize
=
parseInt
({{
query_size
}})
;
// TODO if is_admin
function
doTheQuery
()
{
if
(
$
(
'#submit_thing'
).
prop
(
'disabled'
)
)
return
;
console
.
log
(
"in doTheQuery:"
);
var
origQuery
=
$
(
"#id_name"
).
val
()
var
pubmedifiedQuery
=
{
query
:
JSON
.
stringify
(
thequeries
)
,
string
:
origQuery
,
N
:
querySize
}
;
console
.
log
(
pubmedifiedQuery
)
var
projectid
=
window
.
location
.
href
.
split
(
"projects"
)[
1
].
replace
(
/
\/
/g
,
''
)
//replace all the slashes
$
.
ajax
({
// contentType: "application/json",
url
:
window
.
location
.
origin
+
"/moissonneurs/pubmed/save/"
+
projectid
,
data
:
pubmedifiedQuery
,
type
:
'POST'
,
beforeSend
:
function
(
xhr
)
{
xhr
.
setRequestHeader
(
"X-CSRFToken"
,
getCookie
(
"csrftoken"
));
},
success
:
function
(
data
)
{
console
.
log
(
"in doTheQuery() Ajax.Success:"
)
// console.log(data)
setTimeout
(
function
()
{
location
.
reload
();
},
3000
);
},
error
:
function
(
result
)
{
console
.
log
(
"in doTheQuery(). Data not found"
);
}
});
}
function
bringDaNoise
()
{
var
theresults
=
$
(
"#theresults"
).
html
()
if
(
theresults
&&
theresults
.
search
(
"No results"
)
==-
1
)
{
console
.
log
(
"we've in dynamic mode"
)
$
(
"#simpleloader"
).
html
(
'<img width="30px" src="{% static "img/loading-bar.gif" %}"></img>'
)
$
(
"#submit_thing"
).
prop
(
'onclick'
,
null
);
var
theType
=
$
(
"#id_type option:selected"
).
html
();
console
.
log
(
"consoling the type: "
)
console
.
log
(
theType
)
if
(
theType
==
"Pubmed (XML format)"
)
doTheQuery
();
if
(
theType
==
"ISTex"
)
{
var
origQuery
=
$
(
"#id_name"
).
val
()
console
.
log
(
"printing the results:"
)
console
.
log
(
origQuery
)
testISTEX
(
origQuery
.
replace
(
" "
,
"+"
),
querySize
)
}
}
else
{
console
.
log
(
"we dont have nothing inside results div"
)
if
(
$
(
"#id_file"
).
is
(
':visible'
)
)
{
console
.
log
(
"we're in upload-file mode"
)
var
namefield
=
$
(
"#id_name"
).
val
()
!=
""
var
typefield
=
$
(
"#id_type"
).
val
()
!=
""
var
filefield
=
$
(
"#id_file"
).
val
()
!=
""
if
(
namefield
&&
typefield
&&
filefield
)
{
$
(
"#simpleloader"
).
html
(
'<img width="30px" src="{% static "img/loading-bar.gif" %}"></img>'
)
$
(
"#submit_thing"
).
prop
(
'onclick'
,
null
);
$
(
"#id_form"
).
submit
();
}
}
}
}
function
getGlobalResults
(
value
){
console
.
log
(
"in getGlobalResults()"
)
// AJAX to django
var
pubmedquery
=
$
(
"#id_name"
).
val
()
// var Npubs = $("#id_N").val();
if
(
pubmedquery
==
""
)
return
;
var
formData
=
{
query
:
pubmedquery
,
N
:
querySize
}
$
(
"#theresults"
).
html
(
'<img width="30px" src="{% static "img/loading-bar.gif" %}"></img>'
)
console
.
log
(
"disabling "
+
"#"
+
value
.
id
)
$
(
"#"
+
value
.
id
).
prop
(
'onclick'
,
null
);
var
theType
=
$
(
"#id_type option:selected"
).
html
();
if
(
theType
==
"Pubmed (XML format)"
)
{
$
.
ajax
({
// contentType: "application/json",
url
:
window
.
location
.
origin
+
"/moissonneurs/pubmed/query"
,
data
:
formData
,
type
:
'POST'
,
beforeSend
:
function
(
xhr
)
{
xhr
.
setRequestHeader
(
"X-CSRFToken"
,
getCookie
(
"csrftoken"
));
},
success
:
function
(
data
)
{
console
.
log
(
"SUCCESS"
)
console
.
log
(
"in getGlobalResults"
)
// console.log(data)
console
.
log
(
"enabling "
+
"#"
+
value
.
id
)
$
(
"#"
+
value
.
id
).
attr
(
'onclick'
,
'getGlobalResults(this);'
);
// $("#submit_thing").prop('disabled' , false)
$
(
"#submit_thing"
).
html
(
"Process a {{ query_size }} sample!"
)
thequeries
=
data
var
N
=
0
,
k
=
0
;
for
(
var
i
in
thequeries
)
N
+=
thequeries
[
i
].
count
if
(
N
>
0
)
{
$
(
"#theresults"
).
html
(
"<i> <b>"
+
pubmedquery
+
"</b>: "
+
N
+
" publications in the last 5 years</i><br>"
)
$
(
'#submit_thing'
).
prop
(
'disabled'
,
false
);
}
else
{
$
(
"#theresults"
).
html
(
"<i> <b>"
+
pubmedquery
+
"</b>: No results!.</i><br>"
)
if
(
data
[
0
]
==
false
)
$
(
"#theresults"
).
html
(
"Pubmed connection error!</i><br>"
)
$
(
'#submit_thing'
).
prop
(
'disabled'
,
true
);
}
},
error
:
function
(
result
)
{
$
(
"#theresults"
).
html
(
"Pubmed connection error!</i><br>"
)
$
(
'#submit_thing'
).
prop
(
'disabled'
,
true
);
}
});
}
if
(
theType
==
"ISTex"
)
{
console
.
log
(
window
.
location
.
origin
+
"moissonneurs/istex/query"
)
$
.
ajax
({
// contentType: "application/json",
url
:
window
.
location
.
origin
+
"/moissonneurs/istex/query"
,
data
:
formData
,
type
:
'POST'
,
beforeSend
:
function
(
xhr
)
{
xhr
.
setRequestHeader
(
"X-CSRFToken"
,
getCookie
(
"csrftoken"
));
},
success
:
function
(
data
)
{
console
.
log
(
"in getGlobalResults: Ajax(ISTex)"
)
console
.
log
(
"enabling "
+
"#"
+
value
.
id
)
$
(
"#"
+
value
.
id
).
attr
(
'onclick'
,
'getGlobalResults(this);'
);
// $("#submit_thing").prop('disabled' , false)
$
(
"#submit_thing"
).
html
(
"Process a {{ query_size }} sample!"
)
thequeries
=
data
var
N
=
data
.
length
,
k
=
0
;
// for(var i in thequeries) N += thequeries[i].count
if
(
N
>
1
)
{
var
total
=
JSON
.
parse
(
data
).
total
console
.
log
(
"N: "
+
total
)
$
(
"#theresults"
).
html
(
"<i> <b>"
+
pubmedquery
+
"</b>: "
+
total
+
" publications.</i><br>"
)
$
(
'#submit_thing'
).
prop
(
'disabled'
,
false
);
}
else
{
$
(
"#theresults"
).
html
(
"<i> <b>"
+
data
[
0
]
+
"</b></i><br>"
)
$
(
'#submit_thing'
).
prop
(
'disabled'
,
true
);
}
},
error
:
function
(
result
)
{
console
.
log
(
"Data not found"
);
}
});
}
}
// CSS events for selecting one Radio-Input
function
FileOrNotFile
(
value
)
{
var
showfile
=
JSON
.
parse
(
value
)
var
theType
=
$
(
"#id_type option:selected"
).
html
();
// @upload-file events
if
(
showfile
)
{
console
.
log
(
"You've clicked the YES"
)
$
(
"#id_file"
).
show
()
$
(
'label[for=id_file]'
).
show
();
$
(
"#id_name"
).
attr
(
"placeholder"
,
""
);
$
(
"#scanpubmed"
).
html
(
""
)
$
(
"#theresults"
).
html
(
""
)
$
(
'#submit_thing'
).
prop
(
'disabled'
,
false
);
$
(
"#id_name"
).
on
(
'input'
,
null
);
$
(
"#submit_thing"
).
html
(
'<span class="glyphicon glyphicon-ok" aria-hidden="true" ></span> Process this!'
)
}
// @dynamic-query events
else
{
console
.
log
(
"You've clicked the NO"
)
$
(
"#id_file"
).
hide
()
$
(
'label[for=id_file]'
).
hide
();
$
(
"#id_name"
).
attr
(
"placeholder"
,
" [ Enter your query here ] "
);
$
(
"#id_name"
).
focus
();
$
(
"#scanpubmed"
).
html
(
'<a class="btn btn-primary">Scan</a>'
)
//+'Get: <input id="id_N" size="2" type="text"></input>')
$
(
"#theresults"
).
html
(
""
)
$
(
"#submit_thing"
).
prop
(
'disabled'
,
true
)
$
(
"#id_name"
).
on
(
'input'
,
function
(
e
){
console
.
log
(
$
(
this
).
val
())
if
(
theType
==
"Pubmed (XML format)"
)
testPUBMED
(
$
(
this
).
val
()
)
});
}
}
//CSS events for changing the Select element
function
CustomForSelect
(
selected
)
{
// show Radio-Inputs and trigger FileOrNotFile>@upload-file events
selected
=
selected
.
toLowerCase
()
var
is_pubmed
=
(
selected
.
indexOf
(
'pubmed'
)
!=
-
1
);
var
is_istex
=
(
selected
.
indexOf
(
'istex'
)
!=
-
1
);
if
(
is_pubmed
||
is_istex
)
{
// if(selected=="pubmed") {
console
.
log
(
"show the button for: "
+
selected
)
$
(
"#pubmedcrawl"
).
css
(
"visibility"
,
"visible"
);
$
(
"#pubmedcrawl"
).
show
();
$
(
"#file_yes"
).
click
();
$
(
"#submit_thing"
).
html
(
"Process this!"
)
}
// hide Radio-Inputs and trigger @upload-file events
else
{
console
.
log
(
"hide the button"
)
$
(
"#pubmedcrawl"
).
css
(
"visibility"
,
"hidden"
);
$
(
"#id_file"
).
show
()
$
(
'label[for=id_file]'
).
show
();
FileOrNotFile
(
"true"
)
}
}
var
LastData
=
[]
function
NSuggest_CreateData
(
q
,
data
)
{
console
.
log
(
"in the new NSuggest_CreateData:"
)
LastData
=
data
;
// console.log(LastData)
console
.
log
(
"adding class ui-widget"
)
$
(
"#id_name"
).
removeClass
(
"ui-widget"
).
addClass
(
"ui-widget"
)
$
(
"#id_name"
).
autocomplete
({
source
:
LastData
});
return
data
;
}
function
testPUBMED
(
query
)
{
LastData
=
[]
if
(
!
query
||
query
==
""
)
return
;
var
pubmedquery
=
encodeURIComponent
(
query
)
$
.
ajax
({
type
:
'GET'
,
url
:
"http://www.ncbi.nlm.nih.gov/portal/utils/autocomp.fcgi?dict=pm_related_queries_2&q="
+
pubmedquery
,
// data:"db="+db+"&query="+query,
contentType
:
"application/json"
,
dataType
:
'jsonp'
});
return
false
;
}
function
testISTEX
(
query
,
N
)
{
console
.
log
(
"in testISTEX:"
);
if
(
!
query
||
query
==
""
)
return
;
var
origQuery
=
query
var
postQuery
=
{
query
:
query
,
N
:
N
}
var
projectid
=
window
.
location
.
href
.
split
(
"projects"
)[
1
].
replace
(
/
\/
/g
,
''
)
//replace all the slashes
$
.
ajax
({
// contentType: "application/json",
url
:
window
.
location
.
origin
+
"/moissonneurs/istex/save/"
+
projectid
,
data
:
postQuery
,
type
:
'POST'
,
beforeSend
:
function
(
xhr
)
{
xhr
.
setRequestHeader
(
"X-CSRFToken"
,
getCookie
(
"csrftoken"
));
},
success
:
function
(
data
)
{
console
.
log
(
"ajax_success: in testISTEX()"
)
// console.log(data)
setTimeout
(
function
()
{
location
.
reload
();
},
5000
);
},
error
:
function
(
result
)
{
console
.
log
(
"in testISTEX(). Data not found"
);
}
});
}
<
/script
>
templates/pages/projects/old_project.html
0 → 100644
View file @
d4fe6e84
# all the corpus of this project
corpora = project.children('CORPUS', order=True).all()
if len(corpora) == 0:
return render(
template_name = 'pages/projects/project.html',
request = request,
context = {
'user': request.user,
'date': datetime.now(),
'project': project,
'resources': RESOURCETYPES,
'list_corpora': None,
'whitelists': [],
'blacklists': [],
'cooclists': [],
'number': 0,
'query_size': QUERY_SIZE_N_DEFAULT,
},
)
total_docs = sum([corpus.children('DOCUMENT').count() for corpus in corpora])
#all the possible resources
sources = [resource["name"] for resource in RESOURCETYPES]
sources_count = defaultdict.fromkeys(sources, 0)
sourcename2corpora = defaultdict.fromkeys(sources, [])
sourcename2corpora["default"] = []
for corpus in corpora:
resource = corpus.children('RESOURCE', order=True).first()
if resource is not None:
#print(resource["name"])
#counting docs by resource
sources_count[resource["name"]]=+ corpus.children('DOCUMENT').count()
#corpus.sources = corpus.children('RESOURCE', order=True).all()
else:
# if len(corpus.sources)
<
1:
print
("(
WARNING
)
PROJECT
view:
no
resources
found
for
this
corpus
")
#
GET
DOCS
#
One
corpus
has
multiples
docs
corpus
.
count =
corpus.children('DOCUMENT').count()
#
if
len
(
corpus
.
count
)
<
1:
#
print
("(
WARNING
)
PROJECT
view:
no
documents
found
for
this
corpus
")
#
GET
STATUS
#
One
corpus
has
a
current
status
#
TO
DO
a
method
to
get
current
status
of
the
corpus
status =
corpus.status()
if
status
is
not
None
and
not
status
['
complete
']
:
if
not
status
['
error
']
:
corpus
.
status_message =
'(in progress: %s, %d complete)'
%
(
status
['
action
'].
replace
('
_
',
'
'),
status
['
progress
'],
)
else:
corpus
.
status_message =
'(aborted: "%s" after %i docs)'
%
(
status
['
error
'][
-1
],
status
['
progress
']
)
else:
corpus
.
status_message =
''
#
try:
sourcename2corpora
[
resource
["
name
"]].
append
(
corpus
)
except:
sourcename2corpora
["
default
"].
append
(
corpus
)
#
calculate
repartition
donut =
[]
for
name
,
count
in
sources_count
.
items
()
:
if
not
count =
=
0:
donut
.
append
({"
source
"
:
name
.
strip
().
split
("[")[
0
],
"
count
"
:
count
,
"
part
"
:
round
(
count
*
100
.
0
/
total_docs
)})
corpus_list =
{}
for
name
,
corpora
in
sourcename2corpora
.
items
()
:
if
not
len
(
corpora
)
==
0:
corpus_list
[
name
]
=
corpora
#
TO
DO
all
the
resources
of
this
project
#
One
project
has
multiple
resource
that
has
multiple
corpus
that
has
multiple
documents
#
sources =
project.children('RESOURCE',
order=
True).all()
#
total_docs =
0
#
for
source
in
resources:
#
source
.
docs_nb =
0
#
corpora =
source.children('CORPUS',
order=
True).all()s
#
for
corpus
in
corpora:
#
docs =
corpus.children('DOCUMENT').count()
#
total_docs=
+
docs
#
source
.
docs_nb =
+docs
return
render
(
template_name =
'pages/projects/project.html'
,
request =
request,
context =
{
'
user
'
:
request
.
user
,
'
date
'
:
datetime
.
now
(),
'
project
'
:
project
,
'
resources
'
:
RESOURCETYPES
,
'
donut
'
:
donut
,
'
list_corpora
'
:
corpora
,
#'
list_corpora
'
:
dict
(
corpus_list
),
'
whitelists
'
:
[],
'
blacklists
'
:
[],
'
cooclists
'
:
[],
'
number
'
:
len
(
corpora
),
'
query_size
'
:
QUERY_SIZE_N_DEFAULT
,
},
)
</
div
>
<!-- {% if list_corpora != None %}
{% for key, corpora in list_corpora.items %}
<h2>
<div class="row">
<div class="col-md-1 content"></div>
<span class="glyphicon glyphicon-cd" aria-hidden="true"></span>
{{ key }}
</h2>
{% for corpus in corpora %}
<div id="corpus_{{corpus.id}}">
<div class="row">
<h4>
<div class="col-md-1 content"></div>
<div class="col-md-5 content">
<a href="/projects/{{project.id}}/corpora/{{corpus.id}}">
<span class="glyphicon glyphicon-file" aria-hidden="true"></span>
{{corpus.name}}, {{ corpus.count }} documents {{ corpus.status_message }}
</a>
</div>
<div class="col-md-3 content">
<a href="/projects/{{project.id}}/corpora/{{corpus.id}}"
title="View the corpus">
<button type="button" class="btn btn-default" aria-label="Left Align">
<span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span>
</button>
</a>
{% for state in corpus.hyperdata.statuses %}
{% ifequal state.action "Workflow" %}
{% if state.complete %}
<button type="button" class="btn btn-default yopla" data-container="body" data-toggle="popover" data-placement="bottom" data-trigger="focus"
data-content="
<ul>
<li
onclick="
garganrest.metrics.update({{corpus.id}}, function(){alert('The corpus ({{corpus.name|escapejs}}) was updated')});
">
<a href='#'>Recalculate ngram metrics</a> <br/> (can take a little while)
</li>
</ul>
">
<span class="glyphicon glyphicon-repeat" aria-hidden="true"
title='Recalculate ngram scores and similarities'></span>
</button>
{% endif %}
-->
<!-- TODO: delete non seulement si state.complete mais aussi si state.error -->
<!-- <button type="button" class="btn btn-default" data-container="body" data-toggle="popover" data-placement="bottom"
data-content="
<ul>
<li
onclick="
garganrest.nodes.delete({{corpus.id}}, function(){$('#corpus_'+{{corpus.id}}).remove()});
$(this).parent().parent().remove();
">
<a href='#'>Delete this</a>
</li>
</ul>
">
<span class="glyphicon glyphicon-trash" aria-hidden="true"
title='Delete this corpus'></span>
</button>
{% endifequal %}
{% endfor %}
</div>
<div class="col-md-3 content">
{% for state in corpus.hyperdata.statuses %}
{% ifequal state.action "Workflow" %}
{% if state.complete %}
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
{% else %}
{% if state.error %}
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
{{ state.error }}
{% else %}
<div class="progress">
{% for state in corpus.hyperdata.statuses %}
{% if state.action != "Workflow" %}
<div class=" progress-bar progress-bar-striped
{% if state.complete %}
progress-bar-success
{% else %}
active
{% endif %}
"
role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width: 25%">
<span>
{{ state.action }}
{% if state.complete %}
Ok
{% else %}
Processing
{% endif %}
</span>
</div>
{% endif %}
{% endfor %}
</div>
{% endif %}
{% endif %}
{% endifequal %}
{% endfor %}
</div>
<div class="col-md-1 content"></div>
</h4>
</div>
</div>
{% endfor %}
{% endfor %}
{% endif %} -->
<!-- Modal -->
<!-- <div class="modal fade" id="stack1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>Query to PubMed</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
<input id="daquery" type="text" class="input-lg" data-tabindex="2">
<a onclick="getGlobalResults();" class="btn">Scan</a>
<div id="results"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button onclick="doTheQuery();" disabled id="id_thebutton" type="button" class="btn btn-primary">Explore a sample!</button>
</div>
</div> /.modal-content -->
<!-- </div><!-- /.modal-dialog -->
<!-- </div> -->
<!-- /.modal -->
<!-- Modal -->
<div
class=
"modal fade"
id=
"addcorpus"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"myModalLabel2"
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-hidden=
"true"
>
×
</button>
<h3>
Add a Corpus
<a
href=
"https://gogs.iscpif.fr/humanities/faq_gargantext/wiki/FAQ#import--export-a-dataset"
>
<span
class=
"glyphicon glyphicon-question-sign"
aria-hidden=
"true"
></span>
</a>
</h3>
</div>
<div
class=
"modal-body"
>
<form
id=
"id_form"
enctype=
"multipart/form-data"
action=
"/projects/{{project.id}}/"
method=
"post"
>
{% csrf_token %}
<table
cellpadding=
"5"
>
{% for field in form %}
<tr>
<th>
{{field.label_tag}}
</th>
<td>
{{ field.errors }}
{{ field }}
{% if field.name == 'name' %}
<span
onclick=
"getGlobalResults(this);"
id=
"scanpubmed"
></span>
<div
id=
"theresults"
></div>
{% endif %}
</td>
</tr>
{% endfor %}
<tr>
<th></th>
<td>
<div
id=
"pubmedcrawl"
style=
"visibility: hidden;"
>
Do you have a file already?
<input
type=
"radio"
id=
"file_yes"
name=
"file1"
onclick=
"FileOrNotFile(this.value);"
class=
"file1"
value=
"true"
checked
>
Yes
</input>
<input
type=
"radio"
id=
"file_no"
name=
"file1"
onclick=
"FileOrNotFile(this.value);"
class=
"file1"
value=
"false"
>
No
</input>
</div>
</td>
</tr>
</table>
</form>
<div
class=
"modal-footer"
>
<!-- <div id="pubmedcrawl" align="right" style="visibility: hidden;"><a data-toggle="modal" href="#stack1">➞ Query directly in PubMed</a></div> -->
<button
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
<span
class=
"glyphicon glyphicon-remove"
aria-hidden=
"true"
></span>
Close
</button>
<button
onclick=
'bringDaNoise();'
id=
"submit_thing"
disabled
class=
"btn btn-primary"
>
<span
class=
"glyphicon glyphicon-ok"
aria-hidden=
"true"
></span>
Process this!
</button><span
id=
"simpleloader"
></span>
</div>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
-->
templates/pages/projects/overview.html
View file @
d4fe6e84
{% extends "pages/menu.html"
with user_parameters
%}
{% extends "pages/menu.html" %}
{% block css %}
{% block css %}
{% load staticfiles %}
{% load staticfiles %}
...
...
templates/pages/projects/project.html
View file @
d4fe6e84
{% extends "pages/menu.html"
with user_parameters
%}
{% extends "pages/menu.html" %}
{% block css %}
{% block css %}
{% load staticfiles %}
{% load staticfiles %}
...
...
templates/pages/projects/statuses.tpl
0 → 100644
View file @
d4fe6e84
{
%
for
state
in
corpus
.
hyperdata
.
statuses
%
}
{% ifequal state.action "Workflow" %}
{% if state.complete %}
<span
class=
"glyphicon glyphicon-ok"
aria-hidden=
"true"
></span>
{% else %}
{% if state.error %}
<span
class=
"glyphicon glyphicon-exclamation-sign"
aria-hidden=
"true"
></span>
{{ state.error }}
{% else %}
<div
class=
"progress"
>
{% for state in corpus.hyperdata.statuses %}
{% if state.action != "Workflow" %}
<div
class=
" progress-bar progress-bar-striped
{% if state.complete %}
progress-bar-success
{% else %}
active
{% endif %}
"
role=
"progressbar"
aria-valuenow=
"45"
aria-valuemin=
"0"
aria-valuemax=
"100"
style=
"width: 25%"
>
<span>
{{ state.action }}
{% if state.complete %}
Ok
{% else %}
Processing
{% endif %}
</span>
</div>
{% endif %}
{% endfor %}
</div>
{% endif %}
{% endif %}
{% endifequal %}
{% endfor %}
function manageStatus(statuses){
status_bar = ""
status_bar += '
<div
class=
"progress"
>
'
statuses.forEach(function (status){
if (status["action"] == "Workflow"){
if (status["complete"]){
status_bar += '
<span
class=
"glyphicon glyphicon-ok pull-right"
aria-hidden=
"true"
></span></div>
'
return status_bar;
};
else if (status["error"]) {
status_bar += '
<span
class=
"glyphicon glyphicon-exclamation-sign pull-right"
aria-hidden=
"true"
></span></div>
'
return status_bar;
};
else{
};
};
else{
status_bar +='
<div
class=
" progress-bar progress-bar-striped'
if (status["
complete
"]){
status_bar
+='
progress-bar-sucess
'
};
else
{
status_bar
+='
active
'
};
status_bar
+=
'"
role=
"progressbar"
aria-valuenow=
"45"
aria-valuemin=
"0"
aria-valuemax=
"100"
style=
"width: 25%"
>
<span>
'
if (status["action"]){
if (status["complete"]){
status_bar+= " OK
</span></div>
"
};
else{
status_bar+= " Processing
</span>
"
};
}
});
}
}
})
status_bar+="
</div>
"
return status_bar
};
templates/pages/projects/validate_form.js
0 → 100644
View file @
d4fe6e84
console
.
log
(
errors
)
errors
.
forEach
(
function
(
err
)
{
div
=
err
[
0
].
split
(
" "
)
logs
=
[]
logs
.
push
(
div
[
0
])
if
(
err
[
1
]
==
false
)
{
alert
(
div
[
0
])
//$(div[0]).parent().addClass("alert danger error");
$
(
div
[
0
]).
next
(
div
[
1
]).
collapse
(
"show"
);
//$(div[0]).find(div[1]).collapse("show")
}
else
{
$
(
"<span class='glyphicon glyphicon-ok' aria-hidden='true'>"
).
appendTo
(
div
[
0
])
}
});
return
errors
};
function
checkInput
(
source
){
if
(
source
.
val
().
length
>
0
){
return
true
}
else
{
return
false
}
}
function
checkSourceFormat
(){
source
=
$
(
"select#source"
).
find
(
':selected'
)
if
(
source
.
val
()
!=
''
)
{
console
.
log
(
source
)
source_data
=
source
.
data
(
"format"
)
alert
(
source_data
)
formats
=
source_data
.
split
(
','
);
alert
(
formats
);
extension
=
$
(
"#file"
).
val
().
substr
(
(
filename
.
lastIndexOf
(
'.'
)
+
1
)
);
if
(
$
.
inArray
(
extension
,
formats
)
==
-
1
){
//$("span.format").collapse("show");
return
false
;
}
else
{
//$("span.format").collapse("hide");
return
true
;
}
}
return
true
}
function
checkFileSize
(
filesize
,
max_size
){
if
(
filesize
>
max_size
){
return
true
}
else
{
return
false
}
};
//ADD CORPUS FORM
// //source
// $('#source').change(function() {
// $("#source").next("span.required").collapse("hide");
// source_type = $('#source').find(":selected");
// var formats = source_type.data("format").split(',');
// if (formats.length == 0){
// $("#source").next("span.required").collapse("show");
//
// }
// else{
// $("#source").next("span.required").collapse("hide");
// }
// });
// //file
// var max_size = parseInt($('#file').data("max-size"));
// $('#file').change(function() {
// var filesize = parseInt(this.files[0].size);
// if( filesize > max_size){
// alert("Upload file can't exceed 1 Mo because Gargantext would have an indigestion. Consult the special diet of Gargantext in our FAQ")
// $("#file").empty();
// };
// });
//
//
// });
$
(
"#create"
).
bind
(
"click"
,
function
(){
var
method
=
$
(
'#radioBtn'
).
find
(
'a.active'
).
data
(
"title"
);
errors
=
checkForm
()
if
(
has_error
==
"true"
){
alert
(
"Invalid Form"
);
}
else
{
alert
(
"OK"
)
//if (checkFileExtension() == true){
//preparePost(method, form)
//}
}
});
templates/pages/projects/validators.js
0 → 100644
View file @
d4fe6e84
/////////////////FORM VALIDATION
function
checkFilename
(
filename
){
if
(
filename
==
""
){
$
(
"#filename"
).
next
(
"span.required"
).
collapse
(
"show"
);
return
false
;
}
else
{
$
(
"#file"
).
next
(
"span.required"
).
collapse
(
"hide"
);
return
true
;
}
};
function
checkFileSize
(
filesize
,
max_size
){
if
(
filesize
>
max_size
){
$
(
"span.size"
).
collapse
(
"show"
);
}
else
{
$
(
"span.size"
).
collapse
(
"hide"
);
}
};
function
checkFileExtension
(){
filename
=
$
(
'#file'
).
val
()
source_type
=
$
(
'#source'
).
find
(
":selected"
);
if
(
filename
!=
""
&&
source_type
.
val
()
!==
"0"
){
fextension
=
filename
.
substr
(
(
filename
.
lastIndexOf
(
'.'
)
+
1
)
);
var
formats
=
source_type
.
data
(
"format"
).
split
(
','
);
if
(
$
.
inArray
(
extension
,
formats
)
==
-
1
){
$
(
"span.format"
).
collapse
(
"show"
);
return
false
;
}
else
{
$
(
"span.format"
).
collapse
(
"hide"
);
return
true
;
}
}
};
//name
$
(
"span.error"
).
collapse
(
"hide"
);
$
(
'#name'
).
on
(
'input'
,
function
()
{
var
input
=
$
(
this
);
var
is_name
=
input
.
val
();
if
(
is_name
.
length
<
0
){
$
(
"#name"
).
next
(
"span.required"
).
collapse
(
"show"
);
$
(
"form-group#name"
).
addClass
(
"error"
);
}
else
{
$
(
"#name"
).
next
(
"span"
).
collapse
(
"hide"
);
}
});
//source
$
(
'#source'
).
change
(
function
()
{
$
(
"#source"
).
next
(
"span.required"
).
collapse
(
"hide"
);
source_type
=
$
(
'#source'
).
find
(
":selected"
);
var
formats
=
source_type
.
data
(
"format"
).
split
(
','
);
if
(
formats
.
length
==
0
){
$
(
"#source"
).
next
(
"span.required"
).
collapse
(
"show"
);
}
else
{
$
(
"#source"
).
next
(
"span.required"
).
collapse
(
"hide"
);
}
});
//file
var
max_size
=
parseInt
(
$
(
'#file'
).
data
(
"max-size"
));
$
(
'#file'
).
change
(
function
()
{
$
(
'#name span'
).
collapse
(
"hide"
);
var
input
=
$
(
this
);
var
filename
=
input
.
val
()
var
filesize
=
parseInt
(
this
.
files
[
0
].
size
);
checkFileSize
(
filesize
,
max_size
);
});
//console.log("ERRORS?,)
$
(
"#create"
).
bind
(
"click"
,
function
(){
var
method
=
$
(
'#radioBtn'
).
find
(
'a.active'
).
data
(
"title"
);
has_error
=
$
(
"span.error"
).
hasClass
(
"collapse in"
);
if
(
has_error
==
"true"
){
alert
(
"Invalid Form"
);
}
else
{
if
(
checkFileExtension
()
==
true
){
//preparePost(method, form)
}
}
});
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