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
1f77b82b
Commit
1f77b82b
authored
Jul 26, 2016
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[GRAPH] better messages between client and server + clickable links in messages
parent
f4c42b8f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
32 deletions
+52
-32
rest.py
graph/rest.py
+31
-23
example_start_explorer.html
static/lib/graphExplorer/example_start_explorer.html
+5
-3
main.js
static/lib/graphExplorer/tinawebJS/main.js
+11
-3
explorer.html
templates/graphExplorer/explorer.html
+5
-3
No files found.
graph/rest.py
View file @
1f77b82b
...
...
@@ -48,6 +48,13 @@ def compress_graph(graphdata):
return
graphdata
def
format_html
(
link
):
"""
Build an html link adapted to our json message format
"""
return
"<a class='msglink' href='
%
s'>
%
s</a>"
%
(
link
,
link
)
# TODO check authentication
class
Graph
(
APIView
):
...
...
@@ -146,7 +153,7 @@ class Graph(APIView):
# data :: Either (Dic Nodes Links) (Dic State Length)
# data_test :: Either String Bool
data_test
=
data
.
get
(
"state"
,
True
)
...
...
@@ -158,70 +165,71 @@ class Graph(APIView):
status
=
200
)
# --------------------------------------------
else
:
# All other cases (more probable are higher in the if list)
if
data
[
"state"
]
==
"saveOnly"
:
# async data case
link
=
"http://
%
s/projects/
%
d/corpora/
%
d/myGraphs"
%
(
request
.
get_host
(),
corpus
.
parent_id
,
corpus
.
id
)
return
JsonHttpResponse
({
'msg'
:
'''Your graph is saved:
http://
%
sgargantext.org/projects/
%
d/corpora/
%
d/myGraph
s
'''
%
(
"dev."
,
corpus
.
parent_id
,
corpus
.
id
),
},
status
=
4
00
)
%
s
'''
%
format_html
(
link
),
},
status
=
2
00
)
elif
data
[
"state"
]
==
"corpusMin"
:
# async data case
link
=
"http://
%
s/projects/
%
d/"
%
(
request
.
get_host
(),
corpus
.
parent_id
)
return
JsonHttpResponse
({
'msg'
:
'''Problem: your corpus is too small (only
%
d documents).
Solution: Add more documents (more than
%
d documents)
Solution: Add more documents (more than
%
d documents)
in order to get a graph.
You can manage your corpus here:
http://
%
sgargantext.org/projects/
%
d/
%
s
'''
%
(
data
[
"length"
]
,
graph_constraints
[
'corpusMin'
]
,
"dev."
,
corpus
.
parent_id
,
format_html
(
link
)
),
},
status
=
400
)
elif
data
[
"state"
]
==
"mapListError"
:
# async data case
link
=
'http://
%
s/projects/
%
d/corpora/
%
d/terms'
%
(
request
.
get_host
(),
corpus
.
parent_id
,
corpus
.
id
)
return
JsonHttpResponse
({
'msg'
:
'''Problem: your map list is too small (currently
%
d terms).
Solution: Add some terms (more than
%
d terms)
Solution: Add some terms (more than
%
d terms)
in order to get a graph.
You can manage your map terms here:
http://
%
sgargantext.org/projects/
%
d/corpora/
%
d/term
s
%
s
'''
%
(
data
[
"length"
]
,
graph_constraints
[
'mapList'
]
,
"dev."
,
corpus
.
parent_id
,
corpus
.
id
,
format_html
(
link
)
),
},
status
=
400
)
elif
data
[
"state"
]
==
"corpusMax"
:
# async data case
link
=
'http://
%
s/projects/
%
d/corpora/
%
d/myGraphs'
%
(
request
.
get_host
(),
corpus
.
parent_id
,
corpus
.
id
)
return
JsonHttpResponse
({
'msg'
:
'''Warning: Async graph generation since your corpus is
big (about
%
d documents).
Wait a while and discover your graph very soon.
Click on the link below and see your current graph
Click on the link below and see your current graph
processing on top of the list:
http://
%
sgargantext.org/projects/
%
d/corpora/
%
d/myGraph
s
'''
%
(
data
[
"length"
],
"dev."
,
corpus
.
parent_id
,
corpus
.
id
),
},
status
=
4
00
)
%
s
'''
%
(
data
[
"length"
],
format_html
(
link
)
),
},
status
=
2
00
)
else
:
...
...
static/lib/graphExplorer/example_start_explorer.html
View file @
1f77b82b
...
...
@@ -357,17 +357,19 @@
</div>
</div>
<div
id=
"
error
modal"
class=
"modal fade"
>
<div
id=
"
msg
modal"
class=
"modal fade"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-hidden=
"true"
>
×
</button>
<h4
class=
"modal-title"
>
Graph generation error
</h4>
<h4
id=
"msgtitle"
class=
"modal-title"
>
Graph generation message
</h4>
</div>
<div
class=
"modal-body form-horizontal"
>
<div
id=
"
errormsg
"
></div>
<div
id=
"
msgcontent
"
></div>
</div>
<div
class=
"modal-footer"
>
...
...
static/lib/graphExplorer/tinawebJS/main.js
View file @
1f77b82b
...
...
@@ -89,16 +89,24 @@ $.ajax({
});
function
showDialog
(
url
,
hasError
,
status
,
msg
)
{
console
.
log
(
'FUN t.main:show
ErrorDialog'
)
console
.
log
(
'FUN t.main:show
Dialog'
+
'hasError:'
+
hasError
)
// hide loader gif etc
$
(
"#semLoader"
).
hide
();
$
(
"#closeloader"
).
click
();
if
(
hasError
)
{
$
(
'#msgtitle'
).
html
(
'Graph generation error'
)
$
(
'#msgtitle'
).
css
(
'color'
,
'red'
)
}
else
{
$
(
'#msgtitle'
).
html
(
'Graph generation info'
)
}
// copy message content
$
(
'#
errormsg
'
).
html
(
msg
.
replace
(
/
\n
/g
,
'<br/>'
))
$
(
'#
msgcontent
'
).
html
(
msg
.
replace
(
/
\n
/g
,
'<br/>'
))
// show the dialog box
$
(
'#
error
modal'
).
modal
(
'show'
);
$
(
'#
msg
modal'
).
modal
(
'show'
);
}
function
MainFunction
(
RES
)
{
...
...
templates/graphExplorer/explorer.html
View file @
1f77b82b
...
...
@@ -372,17 +372,19 @@
</div>
</div>
<div
id=
"
error
modal"
class=
"modal fade"
>
<div
id=
"
msg
modal"
class=
"modal fade"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-hidden=
"true"
>
×
</button>
<h4
class=
"modal-title"
>
Graph generation error
</h4>
<h4
id=
"msgtitle"
class=
"modal-title"
>
Graph generation message
</h4>
</div>
<div
class=
"modal-body form-horizontal"
>
<div
id=
"
errormsg
"
></div>
<div
id=
"
msgcontent
"
></div>
</div>
<div
class=
"modal-footer"
>
...
...
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