Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
96037111
Commit
96037111
authored
May 27, 2015
by
Alessandro Verdura
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improvements on error handling + misc
TNL-925
parent
8dd4f6ef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
18 deletions
+32
-18
cms/static/js/factories/import.js
+24
-8
cms/static/js/views/import.js
+8
-10
No files found.
cms/static/js/factories/import.js
View file @
96037111
...
...
@@ -5,6 +5,14 @@ define([
'use strict'
;
return
function
(
feedbackUrl
,
library
)
{
var
dbError
;
if
(
library
)
{
dbError
=
gettext
(
'There was an error while importing the new library to our database.'
);
}
else
{
dbError
=
gettext
(
'There was an error while importing the new course to our database.'
);
}
var
bar
=
$
(
'.progress-bar'
),
fill
=
$
(
'.progress-fill'
),
submitBtn
=
$
(
'.submit-button'
),
...
...
@@ -15,8 +23,8 @@ define([
gettext
(
'There was an error while verifying the file you submitted.'
)
+
'
\
n'
,
dbError
+
'
\
n'
],
unloading
=
false
,
previousImport
=
Import
.
storedImport
(),
dbError
,
file
;
var
onComplete
=
function
()
{
...
...
@@ -26,11 +34,7 @@ define([
.
show
();
}
if
(
library
)
{
dbError
=
gettext
(
'There was an error while importing the new library to our database.'
);
}
else
{
dbError
=
gettext
(
'There was an error while importing the new course to our database.'
);
}
$
(
window
).
on
(
'beforeunload'
,
function
(
event
)
{
unloading
=
true
;
});
// Display the status of last file upload on page load
if
(
previousImport
)
{
...
...
@@ -77,9 +81,21 @@ define([
}
errMsg
=
serverMsg
.
hasOwnProperty
(
'ErrMsg'
)
?
serverMsg
.
ErrMsg
:
''
;
stage
=
Math
.
abs
(
serverMsg
.
Stage
||
0
);
Import
.
error
(
defaults
[
stage
]
+
errMsg
,
stage
);
if
(
serverMsg
.
hasOwnProperty
(
'Stage'
))
{
stage
=
Math
.
abs
(
serverMsg
.
Stage
);
Import
.
error
(
defaults
[
stage
]
+
errMsg
,
stage
);
}
// It could be that the user is simply refreshing the page
// so we need to be sure this is an actual error from the server
else
if
(
!
unloading
)
{
$
(
window
).
off
(
'beforeunload.import'
);
Import
.
reset
();
onComplete
();
alert
(
gettext
(
'Your import has failed.'
)
+
'
\
n
\
n'
+
errMsg
);
}
}
});
});
...
...
cms/static/js/views/import.js
View file @
96037111
...
...
@@ -9,7 +9,7 @@ define(
/********** Private properties ****************************************/
var
COOKIE_NAME
=
'last
file
upload'
;
var
COOKIE_NAME
=
'last
import
upload'
;
var
STAGE
=
{
'UPLOADING'
:
0
,
...
...
@@ -44,7 +44,7 @@ define(
*
*/
var
destroyEventListeners
=
function
()
{
window
.
onbeforeunload
=
null
;
$
(
window
).
off
(
'beforeunload.import'
)
;
};
/**
...
...
@@ -60,11 +60,11 @@ define(
*
*/
var
initEventListeners
=
function
()
{
window
.
onbeforeunload
=
function
()
{
$
(
window
).
on
(
'beforeunload.import'
,
function
()
{
if
(
current
.
stage
<=
STAGE
.
UNPACKING
)
{
return
gettext
(
'Your import is in progress; navigating away will abort it.'
);
}
}
}
);
};
/**
...
...
@@ -119,16 +119,13 @@ define(
}
function
errorStage
(
stage
)
{
var
$stage
=
$
(
stage
);
var
error
=
currStageMsg
;
if
(
!
$stage
.
hasClass
(
'has-error'
))
{
$stage
if
(
!
$
(
stage
).
hasClass
(
'has-error'
))
{
$
(
stage
)
.
removeClass
(
'is-started'
)
.
addClass
(
'has-error'
)
.
find
(
'p.copy'
)
.
hide
()
.
after
(
"<p class='copy error'>"
+
error
+
"</p>"
);
.
after
(
"<p class='copy error'>"
+
currStageMsg
+
"</p>"
);
}
}
...
...
@@ -251,6 +248,7 @@ define(
current
.
stage
=
STAGE
.
UPLOADING
;
current
.
state
=
STATE
.
READY
;
clearTimeout
(
timeout
.
id
);
updateFeedbackList
();
},
...
...
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