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
8efadaec
Commit
8efadaec
authored
May 22, 2015
by
Alessandro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add timestamp on success step + refactoring
TNL-925
parent
4c0bf161
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
317 additions
and
222 deletions
+317
-222
cms/static/js/factories/import.js
+72
-39
cms/static/js/views/import.js
+227
-181
cms/static/sass/views/_import.scss
+13
-0
cms/templates/import.html
+5
-2
No files found.
cms/static/js/factories/import.js
View file @
8efadaec
define
([
define
([
'js/views/import'
,
'jquery'
,
'gettext'
,
'jquery.fileupload'
,
'jquery.cookie'
'domReady'
,
'js/views/import'
,
'jquery'
,
'gettext'
,
'jquery.fileupload'
,
'jquery.cookie'
],
function
(
Import
,
$
,
gettext
)
{
],
function
(
domReady
,
Import
,
$
,
gettext
)
{
'use strict'
;
'use strict'
;
return
function
(
feedbackUrl
,
library
)
{
return
function
(
feedbackUrl
,
library
)
{
var
dbError
;
var
dbError
;
if
(
library
)
{
if
(
library
)
{
dbError
=
gettext
(
'There was an error while importing the new library to our database.'
);
dbError
=
gettext
(
'There was an error while importing the new library to our database.'
);
}
else
{
}
else
{
dbError
=
gettext
(
'There was an error while importing the new course to our database.'
);
dbError
=
gettext
(
'There was an error while importing the new course to our database.'
);
}
}
var
bar
=
$
(
'.progress-bar'
),
var
bar
=
$
(
'.progress-bar'
),
fill
=
$
(
'.progress-fill'
),
fill
=
$
(
'.progress-fill'
),
submitBtn
=
$
(
'.submit-button'
),
submitBtn
=
$
(
'.submit-button'
),
chooseBtn
=
$
(
'.choose-file-button'
),
chooseBtn
=
$
(
'.
view-import .
choose-file-button'
),
defaults
=
[
defaults
=
[
gettext
(
'There was an error during the upload process.'
)
+
'
\
n'
,
gettext
(
'There was an error during the upload process.'
)
+
'
\
n'
,
gettext
(
'There was an error while unpacking the file.'
)
+
'
\
n'
,
gettext
(
'There was an error while unpacking the file.'
)
+
'
\
n'
,
gettext
(
'There was an error while verifying the file you submitted.'
)
+
'
\
n'
,
gettext
(
'There was an error while verifying the file you submitted.'
)
+
'
\
n'
,
dbError
+
'
\
n'
dbError
+
'
\
n'
],
],
// Display the status of last file upload on page load
previousImport
=
Import
.
storedImport
(),
lastFileUpload
=
$
.
cookie
(
'lastfileupload'
),
file
;
file
;
if
(
lastFileUpload
){
Import
.
callbacks
.
complete
=
function
()
{
Import
.
getAndStartUploadFeedback
(
feedbackUrl
.
replace
(
'fillerName'
,
lastFileUpload
),
lastFileUpload
);
bar
.
hide
();
chooseBtn
.
find
(
'.copy'
).
html
(
gettext
(
"Choose new file"
)).
end
()
.
show
();
};
// Display the status of last file upload on page load
if
(
previousImport
)
{
$
(
'.file-name-block'
)
.
find
(
'.file-name'
).
html
(
previousImport
.
file
.
name
).
end
()
.
show
();
if
(
previousImport
.
completed
!==
true
)
{
chooseBtn
.
hide
();
}
Import
.
resume
();
}
}
$
(
'#fileupload'
).
fileupload
({
$
(
'#fileupload'
).
fileupload
({
...
@@ -33,39 +52,41 @@ define([
...
@@ -33,39 +52,41 @@ define([
maxChunkSize
:
20
*
1000000
,
// 20 MB
maxChunkSize
:
20
*
1000000
,
// 20 MB
autoUpload
:
false
,
autoUpload
:
false
,
add
:
function
(
e
,
data
)
{
add
:
function
(
e
,
data
)
{
Import
.
clearImportDisplay
();
Import
.
reset
();
Import
.
okayToNavigateAway
=
false
;
submitBtn
.
unbind
(
'click'
);
submitBtn
.
unbind
(
'click'
);
file
=
data
.
files
[
0
];
file
=
data
.
files
[
0
];
if
(
file
.
name
.
match
(
/tar
\.
gz$/
))
{
if
(
file
.
name
.
match
(
/tar
\.
gz$/
))
{
submitBtn
.
click
(
function
(
event
){
submitBtn
.
click
(
function
(
event
)
{
event
.
preventDefault
();
event
.
preventDefault
();
$
.
cookie
(
'lastfileupload'
,
file
.
name
);
Import
.
start
(
file
.
name
,
feedbackUrl
.
replace
(
'fillerName'
,
file
.
name
)
);
submitBtn
.
hide
();
submitBtn
.
hide
();
Import
.
startUploadFeedback
();
data
.
submit
().
complete
(
function
(
result
,
textStatus
,
xhr
)
{
data
.
submit
().
complete
(
function
(
result
,
textStatus
,
xhr
)
{
if
(
xhr
.
status
!==
200
)
{
window
.
onbeforeunload
=
null
;
if
(
xhr
.
status
!=
200
)
{
var
serverMsg
,
errMsg
,
stage
;
var
serverMsg
,
errMsg
,
stage
;
try
{
try
{
serverMsg
=
$
.
parseJSON
(
result
.
responseText
);
serverMsg
=
$
.
parseJSON
(
result
.
responseText
);
}
catch
(
e
)
{
}
catch
(
e
)
{
return
;
return
;
}
}
errMsg
=
serverMsg
.
hasOwnProperty
(
'ErrMsg'
)
?
serverMsg
.
ErrMsg
:
''
;
errMsg
=
serverMsg
.
hasOwnProperty
(
'ErrMsg'
)
?
serverMsg
.
ErrMsg
:
''
;
if
(
serverMsg
.
hasOwnProperty
(
'Stage'
))
{
if
(
serverMsg
.
hasOwnProperty
(
'Stage'
))
{
stage
=
Math
.
abs
(
serverMsg
.
Stage
);
stage
=
Math
.
abs
(
serverMsg
.
Stage
);
Import
.
stageError
(
stage
,
defaults
[
stage
]
+
errMsg
);
Import
.
error
(
defaults
[
stage
]
+
errMsg
,
stage
);
}
}
else
{
else
{
alert
(
gettext
(
'Your import has failed.'
)
+
'
\
n
\
n'
+
errMsg
);
alert
(
gettext
(
'Your import has failed.'
)
+
'
\
n
\
n'
+
errMsg
);
}
}
chooseBtn
.
html
(
gettext
(
'Choose new file'
)).
show
();
bar
.
hide
();
}
}
Import
.
stopGetStatus
=
true
;
chooseBtn
.
html
(
gettext
(
'Choose new file'
)).
show
();
bar
.
hide
();
});
});
});
});
}
else
{
}
else
{
...
@@ -87,30 +108,42 @@ define([
...
@@ -87,30 +108,42 @@ define([
}
}
if
(
percentInt
>=
doneAt
)
{
if
(
percentInt
>=
doneAt
)
{
bar
.
hide
();
bar
.
hide
();
// Start feedback with delay so that current stage of import properly updates in session
setTimeout
(
// Start feedback with delay so that current stage of
function
()
{
Import
.
startServerFeedback
(
feedbackUrl
.
replace
(
'fillerName'
,
file
.
name
));},
// import properly updates in session
3000
setTimeout
(
function
()
{
Import
.
pollStatus
();
},
3000
);
);
}
else
{
}
else
{
bar
.
show
();
bar
.
show
();
fill
.
width
(
percentVal
).
html
(
percentVal
);
fill
.
width
(
percentVal
).
html
(
percentVal
);
}
}
},
},
done
:
function
(
event
,
data
){
bar
.
hide
();
window
.
onbeforeunload
=
null
;
Import
.
displayFinishedImport
();
},
start
:
function
(
event
)
{
window
.
onbeforeunload
=
function
()
{
if
(
!
Import
.
okayToNavigateAway
)
{
return
"${_('Your import is in progress; navigating away will abort it.')}"
;
}
};
},
sequentialUploads
:
true
,
sequentialUploads
:
true
,
notifyOnError
:
false
notifyOnError
:
false
});
});
var
showImportSubmit
=
function
(
e
)
{
var
filepath
=
$
(
this
).
val
();
if
(
filepath
.
substr
(
filepath
.
length
-
6
,
6
)
===
'tar.gz'
)
{
$
(
'.error-block'
).
hide
();
$
(
'.file-name'
).
html
(
$
(
this
).
val
().
replace
(
'C:
\\
fakepath
\
\'
, ''));
$('
.
file
-
name
-
block
').show();
chooseBtn.hide();
submitBtn.show();
$('
.
progress
').show();
} else {
$('
.
error
-
block
').html(gettext('
File
format
not
supported
.
Please
upload
a
file
with
a
<
code
>
tar
.
gz
<
/code> extension.'
))
.show
()
;
}
};
domReady
(
function
()
{
// import form setup
$
(
'.view-import .file-input'
).
bind
(
'change'
,
showImportSubmit
);
$
(
'.view-import .choose-file-button, .view-import .choose-file-button-inline'
).
bind
(
'click'
,
function
(
e
)
{
e
.
preventDefault
();
$
(
'.view-import .file-input'
).
click
();
});
});
};
};
});
});
cms/static/js/views/import.js
View file @
8efadaec
...
@@ -2,241 +2,287 @@
...
@@ -2,241 +2,287 @@
* Course import-related js.
* Course import-related js.
*/
*/
define
(
define
(
[
"
domReady"
,
"jquery"
,
"underscore"
,
"gettext
"
],
[
"
jquery"
,
"underscore"
,
"gettext"
,
"moment"
,
"jquery.cookie
"
],
function
(
domReady
,
$
,
_
,
gettex
t
)
{
function
(
$
,
_
,
gettext
,
momen
t
)
{
"use strict"
;
"use strict"
;
/********** Private functions ************************************************/
/********** Private properties ****************************************/
var
STATE
=
{
'READY'
:
1
,
'IN_PROGRESS'
:
2
,
'SUCCESS'
:
3
,
'ERROR'
:
4
}
var
error
=
null
;
var
current
=
{
stage
:
0
,
state
:
STATE
.
READY
};
var
file
=
{
name
:
null
,
url
:
null
};
var
timeout
=
{
id
:
null
,
delay
:
1000
};
var
$dom
=
{
stages
:
$
(
'ol.status-progress'
).
children
(),
successStage
:
$
(
'.item-progresspoint-success'
),
wrapper
:
$
(
'div.wrapper-status'
)
};
/********** Private functions *****************************************/
/**
/**
*
Toggle the spin on the progress cog.
*
Makes Import feedback status list visible
*
@param {boolean} isSpinning Turns cog spin on if true, off otherwise.
*
*/
*/
var
updateCog
=
function
(
elem
,
isSpinning
)
{
var
displayFeedbackList
=
function
()
{
var
cogI
=
elem
.
find
(
'i.fa-cog'
);
$dom
.
wrapper
.
removeClass
(
'is-hidden'
);
if
(
isSpinning
)
{
cogI
.
addClass
(
"fa-spin"
);}
else
{
cogI
.
removeClass
(
"fa-spin"
);}
};
};
/**
/**
*
Manipulate the DOM to reflect current status of upload.
*
Sets the Import on the "success" status
*
@param {int} stageNo Current stage.
*
*/
*/
var
updateStage
=
function
(
stageNo
)
{
var
success
=
function
()
{
var
all
=
$
(
'ol.status-progress'
).
children
()
;
window
.
onbeforeunload
=
null
;
var
prevList
=
all
.
slice
(
0
,
stageNo
)
;
current
.
state
=
STATE
.
SUCCESS
;
_
.
map
(
prevList
,
function
(
elem
){
$
(
elem
).
if
(
CourseImport
.
storedImport
().
completed
!==
true
)
{
removeClass
(
"is-not-started"
).
storeImport
(
true
);
removeClass
(
"is-started"
).
}
addClass
(
"is-complete"
);
updateCog
(
$
(
elem
),
false
);
updateFeedbackList
(
);
});
var
curList
=
all
.
eq
(
stageNo
);
if
(
typeof
CourseImport
.
callbacks
.
complete
===
'function'
)
{
curList
.
removeClass
(
"is-not-started"
).
addClass
(
"is-started"
);
CourseImport
.
callbacks
.
complete
(
);
updateCog
(
curList
,
true
);
}
};
};
/**
/**
* Check for import status updates every `timeout` milliseconds, and update
* Updates the Import feedback status list
* the page accordingly.
*
* @param {string} url Url to call for status updates.
* @param {int} timeout Number of milliseconds to wait in between ajax calls
* for new updates.
* @param {int} stage Starting stage.
*/
*/
var
getStatus
=
function
(
url
,
timeout
,
stage
)
{
var
updateFeedbackList
=
function
()
{
var
currentStage
=
stage
||
0
;
if
(
currentStage
>
1
)
{
CourseImport
.
okayToNavigateAway
=
true
;
}
function
completeStage
(
stage
)
{
if
(
CourseImport
.
stopGetStatus
)
{
return
;}
$
(
stage
)
.
removeClass
(
"is-not-started is-started"
)
if
(
currentStage
===
4
)
{
.
addClass
(
"is-complete"
);
// Succeeded
CourseImport
.
displayFinishedImport
();
$
(
'.view-import .choose-file-button'
).
html
(
gettext
(
"Choose new file"
)).
show
();
}
else
if
(
currentStage
<
0
)
{
// Failed
var
errMsg
=
gettext
(
"Error importing course"
);
var
failedStage
=
Math
.
abs
(
currentStage
);
CourseImport
.
stageError
(
failedStage
,
errMsg
);
$
(
'.view-import .choose-file-button'
).
html
(
gettext
(
"Choose new file"
)).
show
();
}
else
{
// In progress
updateStage
(
currentStage
);
}
}
var
time
=
timeout
||
1000
;
function
resetStage
(
stage
)
{
$
.
getJSON
(
url
,
$
(
stage
)
function
(
data
)
{
.
removeClass
(
"is-complete is-started has-error"
)
setTimeout
(
function
()
{
.
addClass
(
"is-not-started"
)
getStatus
(
url
,
time
,
data
.
ImportStatus
);
.
find
(
'p.error'
).
remove
().
end
()
},
time
);
.
find
(
'p.copy'
).
show
();
}
}
);
var
$checkmark
=
$dom
.
successStage
.
find
(
'.icon'
);
switch
(
current
.
state
)
{
case
STATE
.
READY
:
_
.
map
(
$dom
.
stages
,
resetStage
);
break
;
case
STATE
.
IN_PROGRESS
:
var
$prev
=
$dom
.
stages
.
slice
(
0
,
current
.
stage
);
var
$curr
=
$dom
.
stages
.
eq
(
current
.
stage
);
_
.
map
(
$prev
,
completeStage
);
$curr
.
removeClass
(
"is-not-started"
).
addClass
(
"is-started"
);
break
;
case
STATE
.
SUCCESS
:
var
successUnix
=
CourseImport
.
storedImport
().
date
;
var
date
=
moment
(
successUnix
).
utc
().
format
(
'MM/DD/YYYY'
);
var
time
=
moment
(
successUnix
).
utc
().
format
(
'HH:mm'
);
_
.
map
(
$dom
.
stages
,
completeStage
);
$dom
.
successStage
.
find
(
'.item-progresspoint-success-date'
)
.
html
(
'('
+
date
+
' at '
+
time
+
' UTC)'
);
break
;
case
STATE
.
ERROR
:
// Make all stages up to, and including, the error stage 'complete'.
var
$prev
=
$dom
.
stages
.
slice
(
0
,
current
.
stage
+
1
);
var
$curr
=
$dom
.
stages
.
eq
(
current
.
stage
);
var
$next
=
$dom
.
stages
.
slice
(
current
.
stage
+
1
);
var
message
=
error
||
gettext
(
"There was an error with the upload"
);
_
.
map
(
$prev
,
completeStage
);
_
.
map
(
$next
,
resetStage
);
if
(
!
$curr
.
hasClass
(
'has-error'
))
{
$curr
.
removeClass
(
'is-started'
)
.
addClass
(
'has-error'
)
.
find
(
'p.copy'
)
.
hide
()
.
after
(
"<p class='copy error'>"
+
message
+
"</p>"
);
}
break
;
}
if
(
current
.
state
===
STATE
.
SUCCESS
)
{
$checkmark
.
removeClass
(
'fa-square-o'
).
addClass
(
'fa-check-square-o'
);
}
else
{
$checkmark
.
removeClass
(
'fa-check-square-o'
).
addClass
(
'fa-square-o'
);
}
};
};
/**
* Stores in a cookie the current import data
*
* @param {boolean} [completed=false] If the import has been completed or not
*/
var
storeImport
=
function
(
completed
)
{
$
.
cookie
(
'lastfileupload'
,
JSON
.
stringify
({
file
:
file
,
date
:
moment
().
valueOf
(),
completed
:
completed
||
false
}));
}
/********** Public functions *************************************************/
/********** Public functions *************************************************/
var
CourseImport
=
{
var
CourseImport
=
{
/**
/**
* Whether to stop sending AJAX requests for updates on the import
* A collection of callbacks.
* progress.
* For now the only supported is 'complete', called on success/error
*/
*
stopGetStatus
:
false
,
/**
* Whether its fine to navigate away while import is in progress
*/
*/
okayToNavigateAway
:
false
,
callbacks
:
{}
,
/**
/**
* Update DOM to set all stages as not-started (for retrying an upload that
* Sets the Import in the "error" status.
* failed).
*
* Immediately stops any further polling from the server.
* Displays the error message at the list element that corresponds
* to the stage where the error occurred.
*
* @param {string} msg Error message to display.
* @param {int} [stage=current.stage] Stage of import process at which error occurred.
*/
*/
clearImportDisplay
:
function
()
{
error
:
function
(
msg
,
stage
)
{
var
all
=
$
(
'ol.status-progress'
).
children
();
window
.
onbeforeunload
=
null
_
.
map
(
all
,
function
(
elem
){
$
(
elem
).
removeClass
(
"is-complete"
).
removeClass
(
"is-started"
).
removeClass
(
"has-error"
).
addClass
(
"is-not-started"
);
$
(
elem
).
find
(
'p.error'
).
remove
();
// remove error messages
$
(
elem
).
find
(
'p.copy'
).
show
();
updateCog
(
$
(
elem
),
false
);
});
all
.
find
(
'.fa-check-square-o'
).
// Replace checkmark with unchecked box
removeClass
(
'fa-check-square-o'
).
addClass
(
'fa-square-o'
);
this
.
stopGetStatus
=
false
;
},
/**
current
.
stage
=
Math
.
abs
(
stage
||
current
.
stage
);
// Could be negative
* Update DOM to set all stages as complete, and stop asking for status
current
.
state
=
STATE
.
ERROR
;
* updates.
error
=
msg
;
*/
displayFinishedImport
:
function
()
{
clearTimeout
(
timeout
.
id
);
this
.
stopGetStatus
=
true
;
updateFeedbackList
();
var
all
=
$
(
'ol.status-progress'
).
children
();
_
.
map
(
all
,
function
(
elem
){
if
(
typeof
this
.
callbacks
.
complete
===
'function'
)
{
elem
=
$
(
elem
);
this
.
callbacks
.
complete
();
$
(
elem
).
}
removeClass
(
"is-not-started"
).
removeClass
(
"is-started"
).
addClass
(
"is-complete"
);
updateCog
(
$
(
elem
),
false
);
});
all
.
find
(
'.fa-square-o'
).
removeClass
(
'fa-square-o'
).
addClass
(
'fa-check-square-o'
);
},
},
/**
/**
* Make Import feedback status list visible.
* Entry point for server feedback
*
* Checks for import status updates every `timeout` milliseconds,
* and updates the page accordingly.
*
* @param {int} [stage=0] Starting stage.
*/
*/
displayFeedbackList
:
function
(){
pollStatus
:
function
(
stage
)
{
this
.
stopGetStatus
=
false
;
var
self
=
this
;
$
(
'div.wrapper-status'
).
removeClass
(
'is-hidden'
);
$
(
'.status-info'
).
show
();
if
(
current
.
state
!==
STATE
.
IN_PROGRESS
)
{
return
;
}
current
.
stage
=
stage
||
0
;
if
(
current
.
stage
===
4
)
{
// Succeeded
success
();
}
else
if
(
current
.
stage
<
0
)
{
// Failed
this
.
error
(
gettext
(
"Error importing course"
));
}
else
{
// In progress
updateFeedbackList
();
$
.
getJSON
(
file
.
url
,
function
(
data
)
{
timeout
.
id
=
setTimeout
(
function
()
{
self
.
pollStatus
(
data
.
ImportStatus
);
},
timeout
.
delay
);
});
}
},
},
/**
/**
*
Start upload feedback. Makes status list visible and starts
*
Resets the Import internally and visually
*
showing upload progress.
*
*/
*/
startUploadFeedback
:
function
(){
reset
:
function
()
{
this
.
displayFeedbackList
();
current
.
stage
=
0
;
updateStage
(
0
);
current
.
state
=
STATE
.
READY
;
updateFeedbackList
();
},
},
/**
/**
* Show last import status from server and start sending requests to the server for status updates.
* Show last import status from server and start sending requests
* to the server for status updates
*
*/
*/
getAndStartUploadFeedback
:
function
(
url
,
fileName
)
{
resume
:
function
()
{
var
self
=
this
;
var
self
=
this
;
$
.
getJSON
(
url
,
function
(
data
)
{
file
=
self
.
storedImport
().
file
;
if
(
data
.
ImportStatus
!=
0
)
{
$
(
'.file-name'
).
html
(
fileName
);
$
.
getJSON
(
file
.
url
,
function
(
data
)
{
$
(
'.file-name-block'
).
show
();
current
.
stage
=
data
.
ImportStatus
;
self
.
displayFeedbackList
();
if
(
data
.
ImportStatus
===
4
){
if
(
current
.
stage
!==
0
)
{
self
.
displayFinishedImport
();
current
.
state
=
STATE
.
IN_PROGRESS
;
}
else
{
displayFeedbackList
();
$
(
'.view-import .choose-file-button'
).
hide
();
var
time
=
1000
;
self
.
pollStatus
(
current
.
stage
);
setTimeout
(
function
()
{
getStatus
(
url
,
time
,
data
.
ImportStatus
);
},
time
);
}
}
}
}
);
}
);
},
},
/**
/**
* Entry point for server feedback. Makes status list visible and starts
* Starts the importing process.
* sending requests to the server for status updates.
* Makes status list visible and starts showing upload progress.
* @param {string} url The url to send Ajax GET requests for updates.
*
* @param {string} fileName The name of the file to import
* @param {string} fileUrl The full URL to use to query the server
* about the import status
*/
*/
startServerFeedback
:
function
(
url
){
start
:
function
(
fileName
,
fileUrl
)
{
this
.
stopGetStatus
=
false
;
window
.
onbeforeunload
=
function
()
{
getStatus
(
url
,
1000
,
0
);
if
(
current
.
stage
<=
1
)
{
return
gettext
(
'Your import is in progress; navigating away will abort it.'
);
}
}
file
.
name
=
fileName
;
file
.
url
=
fileUrl
;
current
.
state
=
STATE
.
IN_PROGRESS
;
storeImport
();
displayFeedbackList
();
updateFeedbackList
();
},
},
/**
/**
* Give error message at the list element that corresponds to the stage
* Fetches the previous stored import
* where the error occurred.
*
* @param {int} stageNo Stage of import process at which error occurred.
* @return {JSON} the data of the previous import
* @param {string} msg Error message to display.
*/
*/
stageError
:
function
(
stageNo
,
msg
)
{
storedImport
:
function
()
{
this
.
stopGetStatus
=
true
;
return
JSON
.
parse
(
$
.
cookie
(
'lastfileupload'
));
var
all
=
$
(
'ol.status-progress'
).
children
();
// Make all stages up to, and including, the error stage 'complete'.
var
prevList
=
all
.
slice
(
0
,
stageNo
+
1
);
_
.
map
(
prevList
,
function
(
elem
){
$
(
elem
).
removeClass
(
"is-not-started"
).
removeClass
(
"is-started"
).
addClass
(
"is-complete"
);
updateCog
(
$
(
elem
),
false
);
});
var
message
=
msg
||
gettext
(
"There was an error with the upload"
);
var
elem
=
$
(
'ol.status-progress'
).
children
().
eq
(
stageNo
);
if
(
!
elem
.
hasClass
(
'has-error'
))
{
elem
.
removeClass
(
'is-started'
).
addClass
(
'has-error'
);
elem
.
find
(
'p.copy'
).
hide
().
after
(
"<p class='copy error'>"
+
message
+
"</p>"
);
}
}
}
};
};
var
showImportSubmit
=
function
(
e
)
{
var
filepath
=
$
(
this
).
val
();
if
(
filepath
.
substr
(
filepath
.
length
-
6
,
6
)
==
'tar.gz'
)
{
$
(
'.error-block'
).
hide
();
$
(
'.file-name'
).
html
(
$
(
this
).
val
().
replace
(
'C:
\\
fakepath
\
\'
, ''));
$('
.
file
-
name
-
block
').show();
$('
.
view
-
import
.
choose
-
file
-
button
').hide();
$('
.
submit
-
button
').show();
$('
.
progress
').show();
} else {
$('
.
error
-
block
').html(gettext('
File
format
not
supported
.
Please
upload
a
file
with
a
<
code
>
tar
.
gz
<
/code> extension.'
))
.show
()
;
}
};
domReady
(
function
()
{
// import form setup
$
(
'.view-import .file-input'
).
bind
(
'change'
,
showImportSubmit
);
$
(
'.view-import .choose-file-button, .view-import .choose-file-button-inline'
).
bind
(
'click'
,
function
(
e
)
{
e
.
preventDefault
();
$
(
'.view-import .file-input'
).
click
();
});
});
return
CourseImport
;
return
CourseImport
;
});
});
cms/static/sass/views/_import.scss
View file @
8efadaec
...
@@ -186,6 +186,17 @@
...
@@ -186,6 +186,17 @@
// TYPE: success
// TYPE: success
&
.item-progresspoint-success
{
&
.item-progresspoint-success
{
.item-progresspoint-success-date
{
display
:
none
;
margin-left
:
5px
;
}
&
.is-complete
{
.item-progresspoint-success-date
{
display
:
inline
;
}
}
}
}
...
@@ -217,6 +228,8 @@
...
@@ -217,6 +228,8 @@
}
}
.fa-cog
{
.fa-cog
{
@include
animation
(
fa-spin
2s
infinite
linear
);
visibility
:
visible
;
visibility
:
visible
;
opacity
:
1
.0
;
opacity
:
1
.0
;
}
}
...
...
cms/templates/import.html
View file @
8efadaec
...
@@ -115,7 +115,7 @@ else:
...
@@ -115,7 +115,7 @@ else:
<li
class=
"item-progresspoint item-progresspoint-unpack is-started"
>
<li
class=
"item-progresspoint item-progresspoint-unpack is-started"
>
<span
class=
"deco status-visual"
>
<span
class=
"deco status-visual"
>
<i
class=
"icon fa fa-cog
fa-spin
"
></i>
<i
class=
"icon fa fa-cog"
></i>
<i
class=
"icon fa fa-warning"
></i>
<i
class=
"icon fa fa-warning"
></i>
</span>
</span>
...
@@ -167,7 +167,10 @@ else:
...
@@ -167,7 +167,10 @@ else:
</span>
</span>
<div
class=
"status-detail"
>
<div
class=
"status-detail"
>
<h3
class=
"title"
>
${_("Success")}
</h3>
<h3
class=
"title"
>
${_("Success")}
<span
class=
"item-progresspoint-success-date"
></span>
</h3>
<p
class=
"copy"
>
<p
class=
"copy"
>
%if library:
%if library:
${_("Your imported content has now been integrated into this library")}
${_("Your imported content has now been integrated into this library")}
...
...
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