add progress percentage for save and load actions
parent
4fb6e9be3b
commit
806fd3cc93
|
@ -904,8 +904,25 @@ function loadFile(file){
|
||||||
path : file
|
path : file
|
||||||
}
|
}
|
||||||
var url = OC.generateUrl('/apps/gpxedit/getgpx');
|
var url = OC.generateUrl('/apps/gpxedit/getgpx');
|
||||||
|
$('#loadingpc').text('0 %');
|
||||||
showLoadingAnimation();
|
showLoadingAnimation();
|
||||||
gpxedit.currentAjax = $.post(url, req).done(function (response) {
|
gpxedit.currentAjax = $.ajax({
|
||||||
|
type: "POST",
|
||||||
|
async: true,
|
||||||
|
url: url,
|
||||||
|
data: req,
|
||||||
|
xhr: function(){
|
||||||
|
var xhr = new window.XMLHttpRequest();
|
||||||
|
xhr.addEventListener("progress", function(evt) {
|
||||||
|
if (evt.lengthComputable) {
|
||||||
|
var percentComplete = evt.loaded / evt.total * 100;
|
||||||
|
$('#loadingpc').text('('+parseInt(percentComplete)+' %)');
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
return xhr;
|
||||||
|
}
|
||||||
|
}).done(function (response) {
|
||||||
if ($('#clearbeforeload').is(':checked')){
|
if ($('#clearbeforeload').is(':checked')){
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
@ -1122,13 +1139,31 @@ function saveAction(targetPath){
|
||||||
var saveFilePath = targetPath+'/'+$('input#saveName').val();
|
var saveFilePath = targetPath+'/'+$('input#saveName').val();
|
||||||
var gpxText = generateGpx();
|
var gpxText = generateGpx();
|
||||||
hideExportingAnimation();
|
hideExportingAnimation();
|
||||||
|
$('#savingpc').text('0 %');
|
||||||
showSavingAnimation();
|
showSavingAnimation();
|
||||||
var req = {
|
var req = {
|
||||||
path: saveFilePath,
|
path: saveFilePath,
|
||||||
content: gpxText
|
content: gpxText
|
||||||
}
|
}
|
||||||
var url = OC.generateUrl('/apps/gpxedit/savegpx');
|
var url = OC.generateUrl('/apps/gpxedit/savegpx');
|
||||||
$.post(url, req).done(function (response) {
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
async: true,
|
||||||
|
url: url,
|
||||||
|
data: req,
|
||||||
|
xhr: function(){
|
||||||
|
var xhr = new window.XMLHttpRequest();
|
||||||
|
xhr.upload.addEventListener("progress", function(evt) {
|
||||||
|
if (evt.lengthComputable) {
|
||||||
|
var percentComplete = evt.loaded / evt.total * 100;
|
||||||
|
//Do something with upload progress here
|
||||||
|
$('#savingpc').text('('+parseInt(percentComplete)+' %)');
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
return xhr;
|
||||||
|
}
|
||||||
|
}).done(function (response) {
|
||||||
hideSavingAnimation();
|
hideSavingAnimation();
|
||||||
if (response.status === 'fiw'){
|
if (response.status === 'fiw'){
|
||||||
showSaveFailAnimation(saveFilePath, t('gpxedit', 'Impossible to write file')+' : '+t('gpxedit', 'write access denied'));
|
showSaveFailAnimation(saveFilePath, t('gpxedit', 'Impossible to write file')+' : '+t('gpxedit', 'write access denied'));
|
||||||
|
|
|
@ -49,7 +49,7 @@ p($_['gpxedit_version']);
|
||||||
</div>
|
</div>
|
||||||
<div id="loading"><p>
|
<div id="loading"><p>
|
||||||
<i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>
|
<i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>
|
||||||
<?php p($l->t('loading file')); ?> </p>
|
<?php p($l->t('loading file')); ?> <i id="loadingpc"></i></p>
|
||||||
</div>
|
</div>
|
||||||
<div id="exporting"><p>
|
<div id="exporting"><p>
|
||||||
<i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>
|
<i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>
|
||||||
|
@ -57,7 +57,7 @@ p($_['gpxedit_version']);
|
||||||
</div>
|
</div>
|
||||||
<div id="saving"><p>
|
<div id="saving"><p>
|
||||||
<i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>
|
<i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>
|
||||||
<?php p($l->t('saving file')); ?> </p>
|
<?php p($l->t('saving file')); ?> <i id="savingpc"></i></p>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue