gridftp ui: fixes in error handling in saving favorites locations
authorMaciej Tronowski <mtro@man.poznan.pl>
Wed, 22 Apr 2015 15:17:38 +0000 (17:17 +0200)
committerMaciej Tronowski <mtro@man.poznan.pl>
Wed, 22 Apr 2015 15:17:38 +0000 (17:17 +0200)
filex/static/filex/filex.js

index 26bec82..ac71ea5 100644 (file)
@@ -265,6 +265,7 @@ $(function(){
                         callback_called = false;
 
                     $form[0].reset();
+                    $form.find('.alert-danger').remove();
                     $form.find('#id_host').val(parts.shift());
 
                     if (parts.length)
@@ -277,6 +278,7 @@ $(function(){
 
                         e.preventDefault();
                         $btn.button('loading');
+                        $this.find('.alert-danger').remove();
 
                         $.post($this.attr('action'), $this.serialize(), function(data) {
                             callback(data);
@@ -288,6 +290,13 @@ $(function(){
                             console.error(arguments);
                             var error = (xhr.responseJSON || {}).error || undefined;
 
+                            if (error.__all__) {
+                                error = 'Podana lokalizacja jest już zapisana'
+                            }
+                            else if (xhr.status == 400) {
+                                error = 'Niepoprawna nazwa hosta lub ścieżka'
+                            }
+
                             if (typeof error === 'string') {
                                 $('<div>', {
                                     'class': 'alert alert-danger',