Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
beat
beat.web
Commits
9bcfc867
There was a problem fetching the pipeline summary.
Commit
9bcfc867
authored
8 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[algo,libs] Properly handle error conditions
parent
b5992b52
No related branches found
No related tags found
1 merge request
!209
Issue 425
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
beat/web/algorithms/templates/algorithms/diff.html
+53
-81
53 additions, 81 deletions
beat/web/algorithms/templates/algorithms/diff.html
beat/web/libraries/templates/libraries/diff.html
+46
-78
46 additions, 78 deletions
beat/web/libraries/templates/libraries/diff.html
with
99 additions
and
159 deletions
beat/web/algorithms/templates/algorithms/diff.html
+
53
−
81
View file @
9bcfc867
...
...
@@ -2,21 +2,21 @@
{% comment %}
* Copyright (c) 2016 Idiap Research Institute, http://www.idiap.ch/
* Contact: beat.support@idiap.ch
*
*
* This file is part of the beat.web module of the BEAT platform.
*
*
* Commercial License Usage
* Licensees holding valid commercial BEAT licenses may use this file in
* accordance with the terms contained in a written agreement between you
* and Idiap. For further information contact tto@idiap.ch
*
*
* Alternatively, this file may be used under the terms of the GNU Affero
* Public License version 3 as published by the Free Software and appearing
* in the file LICENSE.AGPL included in the packaging of this file.
* The BEAT platform is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
*
*
* You should have received a copy of the GNU Affero Public License along
* with the BEAT platform. If not, see http://www.gnu.org/licenses/.
{% endcomment %}
...
...
@@ -129,13 +129,6 @@ function process_diff(lines, editor, diff_line_numbers_classname)
</div>
</div>
<div
id=
"errors"
class=
"row"
style=
"display:none"
>
<div
class=
"col-sm-offset-1 col-sm-10"
>
<h2></h2>
<p></p>
</div>
</div>
<script
type=
"text/javascript"
>
jQuery
(
document
).
ready
(
function
()
{
...
...
@@ -143,79 +136,58 @@ jQuery(document).ready(function() {
$
(
'
h4
'
).
hide
();
$
(
'
#progress
'
).
show
();
$
.
get
(
'
{% url
'
api_algorithms
:
diff
'
algorithm1_author algorithm1_name algorithm1_version algorithm2_author algorithm2_name algorithm2_version %}
'
)
.
done
(
function
(
data
)
{
$
(
'
#progress
'
).
hide
();
$
(
'
h4
'
).
show
();
var
source_code_lines
=
data
.
source_code_diff
.
split
(
'
\n
'
)
var
code
=
''
;
for
(
var
i
=
0
;
i
<
source_code_lines
.
length
;
++
i
)
code
+=
source_code_lines
[
i
].
substr
(
2
)
+
'
\n
'
;
var
declaration_lines
=
data
.
diff
.
split
(
'
\n
'
)
var
declaration
=
''
;
for
(
var
i
=
0
;
i
<
declaration_lines
.
length
;
++
i
)
declaration
+=
declaration_lines
[
i
].
substr
(
2
)
+
'
\n
'
;
var
diff_line_numbers_classname
=
(
Math
.
log10
(
Math
.
max
(
source_code_lines
.
length
,
declaration_lines
.
length
))
>
3
?
'
diff_line_numbers_large
'
:
'
diff_line_numbers
'
);
var
code_editor
=
CodeMirror
(
$
(
'
#code_editor_container
'
)[
0
],
{
value
:
code
,
mode
:
'
python
'
,
readOnly
:
true
,
lineNumbers
:
false
,
gutters
:
[
diff_line_numbers_classname
,
'
diff_addition_deletion
'
],
}
);
var
declaration_editor
=
CodeMirror
(
$
(
'
#declaration_container
'
)[
0
],
{
value
:
declaration
,
mode
:
'
javascript
'
,
readOnly
:
true
,
lineNumbers
:
false
,
gutters
:
[
diff_line_numbers_classname
,
'
diff_addition_deletion
'
],
}
);
process_diff
(
source_code_lines
,
code_editor
,
diff_line_numbers_classname
);
process_diff
(
declaration_lines
,
declaration_editor
,
diff_line_numbers_classname
);
})
.
fail
(
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
$
(
'
#title
'
).
hide
();
var
errors_box
=
$
(
'
.container #errors
'
);
if
(
jqXHR
.
status
==
404
)
{
errors_box
.
find
(
'
h2
'
).
text
(
'
Algorithm not found
'
);
errors_box
.
find
(
'
p
'
).
html
(
"
We are sorry, but the algorithm called <strong>
"
+
jqXHR
.
responseText
+
"
</strong> could not be found.
"
);
}
else
if
(
jqXHR
.
status
==
401
)
{
errors_box
.
find
(
'
h2
'
).
text
(
'
Unauthorized access
'
);
errors_box
.
find
(
'
p
'
).
html
(
"
We are sorry, but your aren't authorized to access the algorithm called <strong>
"
+
jqXHR
.
responseText
+
"
</strong>.
"
);
}
else
if
(
jqXHR
.
responseText
.
length
>
0
)
{
errors_box
.
find
(
'
h2
'
).
text
(
textStatus
);
errors_box
.
find
(
'
p
'
).
html
(
jqXHR
.
responseText
);
var
d
=
$
.
get
(
'
{% url
'
api_algorithms
:
diff
'
algorithm1_author algorithm1_name algorithm1_version algorithm2_author algorithm2_name algorithm2_version %}
'
);
d
.
done
(
function
(
data
)
{
$
(
'
#progress
'
).
hide
();
$
(
'
h4
'
).
show
();
var
source_code_lines
=
data
.
source_code_diff
.
split
(
'
\n
'
);
var
code
=
''
;
for
(
var
i
=
0
;
i
<
source_code_lines
.
length
;
++
i
)
{
code
+=
source_code_lines
[
i
].
substr
(
2
)
+
'
\n
'
;
}
else
{
errors_box
.
find
(
'
h2
'
).
text
(
textStatus
);
var
declaration_lines
=
data
.
diff
.
split
(
'
\n
'
);
var
declaration
=
''
;
for
(
var
i
=
0
;
i
<
declaration_lines
.
length
;
++
i
)
{
declaration
+=
declaration_lines
[
i
].
substr
(
2
)
+
'
\n
'
;
}
errors_box
.
show
();
var
diff_line_numbers_classname
=
(
Math
.
log10
(
Math
.
max
(
source_code_lines
.
length
,
declaration_lines
.
length
))
>
3
?
'
diff_line_numbers_large
'
:
'
diff_line_numbers
'
);
var
code_editor
=
CodeMirror
(
$
(
'
#code_editor_container
'
)[
0
],
{
value
:
code
,
mode
:
'
python
'
,
readOnly
:
true
,
lineNumbers
:
false
,
gutters
:
[
diff_line_numbers_classname
,
'
diff_addition_deletion
'
],
}
);
var
declaration_editor
=
CodeMirror
(
$
(
'
#declaration_container
'
)[
0
],
{
value
:
declaration
,
mode
:
'
javascript
'
,
readOnly
:
true
,
lineNumbers
:
false
,
gutters
:
[
diff_line_numbers_classname
,
'
diff_addition_deletion
'
],
}
);
process_diff
(
source_code_lines
,
code_editor
,
diff_line_numbers_classname
);
process_diff
(
declaration_lines
,
declaration_editor
,
diff_line_numbers_classname
);
});
d
.
fail
(
function
(
data
,
status_text
)
{
$
(
'
#progress
'
).
hide
();
process_error
(
data
,
status_text
,
document
.
referrer
);
});
});
...
...
This diff is collapsed.
Click to expand it.
beat/web/libraries/templates/libraries/diff.html
+
46
−
78
View file @
9bcfc867
...
...
@@ -2,21 +2,21 @@
{% comment %}
* Copyright (c) 2016 Idiap Research Institute, http://www.idiap.ch/
* Contact: beat.support@idiap.ch
*
*
* This file is part of the beat.web module of the BEAT platform.
*
*
* Commercial License Usage
* Licensees holding valid commercial BEAT licenses may use this file in
* accordance with the terms contained in a written agreement between you
* and Idiap. For further information contact tto@idiap.ch
*
*
* Alternatively, this file may be used under the terms of the GNU Affero
* Public License version 3 as published by the Free Software and appearing
* in the file LICENSE.AGPL included in the packaging of this file.
* The BEAT platform is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
*
*
* You should have received a copy of the GNU Affero Public License along
* with the BEAT platform. If not, see http://www.gnu.org/licenses/.
{% endcomment %}
...
...
@@ -129,93 +129,61 @@ function process_diff(lines, editor, diff_line_numbers_classname)
</div>
</div>
<div
id=
"errors"
class=
"row"
style=
"display:none"
>
<div
class=
"col-sm-offset-1 col-sm-10"
>
<h2></h2>
<p></p>
</div>
</div>
<script
type=
"text/javascript"
>
jQuery
(
document
).
ready
(
function
()
{
$
(
'
#progress
'
).
show
();
$
(
'
h4
'
).
hide
();
$
.
get
(
'
{% url
'
api_libraries
:
diff
'
library1_author library1_name library1_version library2_author library2_name library2_version %}
'
)
.
done
(
function
(
data
)
{
$
(
'
#progress
'
).
hide
();
$
(
'
h4
'
).
show
();
var
source_code_lines
=
data
.
source_code_diff
.
split
(
'
\n
'
)
var
code
=
''
;
for
(
var
i
=
0
;
i
<
source_code_lines
.
length
;
++
i
)
code
+=
source_code_lines
[
i
].
substr
(
2
)
+
'
\n
'
;
var
declaration_lines
=
data
.
diff
.
split
(
'
\n
'
)
var
declaration
=
''
;
for
(
var
i
=
0
;
i
<
declaration_lines
.
length
;
++
i
)
declaration
+=
declaration_lines
[
i
].
substr
(
2
)
+
'
\n
'
;
var
diff_line_numbers_classname
=
(
Math
.
log10
(
Math
.
max
(
source_code_lines
.
length
,
declaration_lines
.
length
))
>
3
?
'
diff_line_numbers_large
'
:
'
diff_line_numbers
'
);
var
code_editor
=
CodeMirror
(
$
(
'
#code_editor_container
'
)[
0
],
{
value
:
code
,
mode
:
'
python
'
,
readOnly
:
true
,
lineNumbers
:
false
,
gutters
:
[
diff_line_numbers_classname
,
'
diff_addition_deletion
'
],
}
);
var
declaration_editor
=
CodeMirror
(
$
(
'
#declaration_container
'
)[
0
],
{
value
:
declaration
,
mode
:
'
javascript
'
,
readOnly
:
true
,
lineNumbers
:
false
,
gutters
:
[
diff_line_numbers_classname
,
'
diff_addition_deletion
'
],
}
);
process_diff
(
source_code_lines
,
code_editor
,
diff_line_numbers_classname
);
process_diff
(
declaration_lines
,
declaration_editor
,
diff_line_numbers_classname
);
})
.
fail
(
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
var
d
=
$
.
get
(
'
{% url
'
api_libraries
:
diff
'
library1_author library1_name library1_version library2_author library2_name library2_version %}
'
);
d
.
done
(
function
(
data
)
{
$
(
'
#progress
'
).
hide
();
$
(
'
#title
'
).
hide
();
$
(
'
h4
'
).
show
();
var
errors_box
=
$
(
'
.container #errors
'
);
var
source_code_lines
=
data
.
source_code_diff
.
split
(
'
\n
'
);
if
(
jqXHR
.
status
==
404
)
{
errors_box
.
find
(
'
h2
'
).
text
(
'
Library not found
'
);
errors_box
.
find
(
'
p
'
).
html
(
"
We are sorry, but the library called <strong>
"
+
jqXHR
.
responseText
+
"
</strong> could not be found.
"
);
}
else
if
(
jqXHR
.
status
==
401
)
{
errors_box
.
find
(
'
h2
'
).
text
(
'
Unauthorized access
'
);
errors_box
.
find
(
'
p
'
).
html
(
"
We are sorry, but your aren't authorized to access the library called <strong>
"
+
jqXHR
.
responseText
+
"
</strong>.
"
);
var
code
=
''
;
for
(
var
i
=
0
;
i
<
source_code_lines
.
length
;
++
i
)
{
code
+=
source_code_lines
[
i
].
substr
(
2
)
+
'
\n
'
;
}
else
if
(
jqXHR
.
responseText
.
length
>
0
)
{
errors_box
.
find
(
'
h2
'
).
text
(
textStatus
);
errors_box
.
find
(
'
p
'
).
html
(
jqXHR
.
responseText
);
}
else
{
errors_box
.
find
(
'
h2
'
).
text
(
textStatus
);
var
declaration_lines
=
data
.
diff
.
split
(
'
\n
'
);
var
declaration
=
''
;
for
(
var
i
=
0
;
i
<
declaration_lines
.
length
;
++
i
)
{
declaration
+=
declaration_lines
[
i
].
substr
(
2
)
+
'
\n
'
;
}
errors_box
.
show
();
var
diff_line_numbers_classname
=
(
Math
.
log10
(
Math
.
max
(
source_code_lines
.
length
,
declaration_lines
.
length
))
>
3
?
'
diff_line_numbers_large
'
:
'
diff_line_numbers
'
);
var
code_editor
=
CodeMirror
(
$
(
'
#code_editor_container
'
)[
0
],
{
value
:
code
,
mode
:
'
python
'
,
readOnly
:
true
,
lineNumbers
:
false
,
gutters
:
[
diff_line_numbers_classname
,
'
diff_addition_deletion
'
],
}
);
var
declaration_editor
=
CodeMirror
(
$
(
'
#declaration_container
'
)[
0
],
{
value
:
declaration
,
mode
:
'
javascript
'
,
readOnly
:
true
,
lineNumbers
:
false
,
gutters
:
[
diff_line_numbers_classname
,
'
diff_addition_deletion
'
],
}
);
process_diff
(
source_code_lines
,
code_editor
,
diff_line_numbers_classname
);
process_diff
(
declaration_lines
,
declaration_editor
,
diff_line_numbers_classname
);
});
d
.
fail
(
process_error
);
});
</script>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment