save success and failure messages ok

merge-requests/1/head
Julien Veyssier 2016-12-02 15:31:45 +01:00
parent dd26abf70c
commit 1d884b89bc
3 changed files with 26 additions and 9 deletions

View File

@ -227,11 +227,11 @@ h3 {
margin-left:20px; margin-left:20px;
list-style-type:circle; list-style-type:circle;
} }
#saved { #saved, #failed {
/*width: 330px;*/ /*width: 330px;*/
padding-left: 5px; padding-left: 5px;
/*height: 35px;*/ /*height: 35px;*/
text-align: right; text-align: left;
font-weight: bold; font-weight: bold;
font-size: 22px; font-size: 22px;
color: white; color: white;
@ -247,11 +247,14 @@ h3 {
display:none; display:none;
/*z-index: 1000;*/ /*z-index: 1000;*/
} }
#saved .fa { #failed{
background-color: red;
}
#saved .fa, #failed .fa {
font-size: 22px; font-size: 22px;
} }
#saved p{ #saved p, #failed p{
padding: 6px 6px 6px 6px; padding: 6px 6px 6px 6px;
} }
.clear { .clear {

View File

@ -434,6 +434,16 @@ function checkKey(e){
} }
} }
function showFailedSuccessAnimation(path, message){
$('#failed').find('b#content').html('Failed to save file '+path+'<br/>'+message);
$('#failed').fadeIn();
setTimeout(hideFailedSuccessAnimation, 4000);
}
function hideFailedSuccessAnimation(){
$('#failed').fadeOut();
}
function showSaveSuccessAnimation(path){ function showSaveSuccessAnimation(path){
$('#saved').find('b#content').html('File successfully saved as<br/>'+path); $('#saved').find('b#content').html('File successfully saved as<br/>'+path);
//$('#saved').show(); //$('#saved').show();
@ -504,16 +514,16 @@ $(document).ready(function(){
var url = OC.generateUrl('/apps/gpxedit/savegpx'); var url = OC.generateUrl('/apps/gpxedit/savegpx');
$.post(url, req).done(function (response) { $.post(url, req).done(function (response) {
if (response.status === 'fiw'){ if (response.status === 'fiw'){
alert('Impossible to write file : write access denied'); showFailedSuccessAnimation(saveFilePath, 'Impossible to write file : write access denied');
} }
else if (response.status === 'fu'){ else if (response.status === 'fu'){
alert('Impossible to write file : folder does not exist'); showFailedSuccessAnimation(saveFilePath, 'Impossible to write file : folder does not exist');
} }
else if (response.status === 'fw'){ else if (response.status === 'fw'){
alert('Impossible to write file : folder write access denied'); showFailedSuccessAnimation(saveFilePath, 'Impossible to write file : folder write access denied');
} }
else if (response.status === 'bfn'){ else if (response.status === 'bfn'){
alert('Bad file name, must end with ".gpx"'); showFailedSuccessAnimation(saveFilePath, 'Bad file name, must end with ".gpx"');
} }
else{ else{
showSaveSuccessAnimation(saveFilePath); showSaveSuccessAnimation(saveFilePath);

View File

@ -41,7 +41,11 @@ p($_['gpxedit_version']);
<button id="clearButton">Clear map</button> <button id="clearButton">Clear map</button>
<div id="saved"><p> <div id="saved"><p>
<i class="fa fa-save fa-spin fa-3x fa-fw"></i> <i class="fa fa-save fa-spin fa-3x fa-fw"></i>
<b id="content"><?php p($l->t('File saved')); ?></b></p> <b id="content"></b></p>
</div>
<div id="failed"><p>
<i class="fa fa-save fa-spin fa-3x fa-fw"></i>
<b id="content"></b></p>
</div> </div>
<?php <?php