diff --git a/apps/files_external/js/dropbox.js b/apps/files_external/js/dropbox.js
index 247d6bb8bb..92a92467c7 100644
--- a/apps/files_external/js/dropbox.js
+++ b/apps/files_external/js/dropbox.js
@@ -24,14 +24,12 @@ $(document).ready(function() {
$(tr).find('.configuration input').attr('disabled', 'disabled');
$(tr).find('.configuration').append(''+t('files_external', 'Access granted')+'');
} else {
- OC.dialogs.alert(result.data.message,
- t('files_external', 'Error configuring Dropbox storage')
- );
+ OC.dialogs.alert(result.data.message, t('files_external', 'Error configuring Dropbox storage'));
}
});
}
- } else if ($(this).find('.mountPoint input').val() != '' && $(config).find('[data-parameter="app_key"]').val() != '' && $(config).find('[data-parameter="app_secret"]').val() != '' && $(this).find('.dropbox').length == 0) {
- $(this).find('.configuration').append(''+t('files_external', 'Grant access')+'');
+ } else {
+ onDropboxInputsChange($(this));
}
}
});
@@ -39,18 +37,27 @@ $(document).ready(function() {
$('#externalStorage tbody tr.OC_Filestorage_Dropbox td').live('paste', function() {
var tr = $(this).parent();
setTimeout(function() {
- showButton(tr);
+ onDropboxInputsChange(tr);
}, 20);
});
$('#externalStorage tbody tr.OC_Filestorage_Dropbox td').live('keyup', function() {
- showButton($(this).parent());
+ onDropboxInputsChange($(this).parent());
});
- function showButton(tr) {
+ $('#externalStorage tbody tr.OC_Filestorage_Dropbox .chzn-select').live('change', function() {
+ onDropboxInputsChange($(this).parent().parent());
+ });
+
+ function onDropboxInputsChange(tr) {
if ($(tr).find('[data-parameter="configured"]').val() != 'true') {
var config = $(tr).find('.configuration');
- if ($(tr).find('.mountPoint input').val() != '' && $(config).find('[data-parameter="app_key"]').val() != '' && $(config).find('[data-parameter="app_secret"]').val() != '') {
+ if ($(tr).find('.mountPoint input').val() != ''
+ && $(config).find('[data-parameter="app_key"]').val() != ''
+ && $(config).find('[data-parameter="app_secret"]').val() != ''
+ && ($(tr).find('.chzn-select').length == 0
+ || $(tr).find('.chzn-select').val() != null))
+ {
if ($(tr).find('.dropbox').length == 0) {
$(config).append(''+t('files_external', 'Grant access')+'');
} else {
@@ -64,8 +71,10 @@ $(document).ready(function() {
$('.dropbox').live('click', function(event) {
event.preventDefault();
+ var tr = $(this).parent().parent();
var app_key = $(this).parent().find('[data-parameter="app_key"]').val();
var app_secret = $(this).parent().find('[data-parameter="app_secret"]').val();
+ var statusSpan = $(tr).find('.status span');
if (app_key != '' && app_secret != '') {
var tr = $(this).parent().parent();
var configured = $(this).parent().find('[data-parameter="configured"]');
@@ -76,25 +85,19 @@ $(document).ready(function() {
$(configured).val('false');
$(token).val(result.data.request_token);
$(token_secret).val(result.data.request_token_secret);
- if (OC.MountConfig.saveStorage(tr)) {
- window.location = result.data.url;
- } else {
- OC.dialogs.alert(
- t('files_external', 'Fill out all required fields'),
- t('files_external', 'Error configuring Dropbox storage')
- );
- }
+ OC.MountConfig.saveStorage(tr);
+ statusSpan.removeClass();
+ statusSpan.addClass('waiting');
+ window.location = result.data.url;
} else {
- OC.dialogs.alert(result.data.message,
- t('files_external', 'Error configuring Dropbox storage')
- );
+ OC.dialogs.alert(result.data.message, t('files_external', 'Error configuring Dropbox storage'));
}
});
} else {
OC.dialogs.alert(
- t('files_external', 'Please provide a valid Dropbox app key and secret.'),
- t('files_external', 'Error configuring Dropbox storage')
- );
+ t('files_external', 'Please provide a valid Dropbox app key and secret.'),
+ t('files_external', 'Error configuring Dropbox storage')
+ );
}
});
diff --git a/apps/files_external/js/google.js b/apps/files_external/js/google.js
index f9fb807861..a3b3e9cb3d 100644
--- a/apps/files_external/js/google.js
+++ b/apps/files_external/js/google.js
@@ -3,8 +3,7 @@ $(document).ready(function() {
$('#externalStorage tbody tr.OC_Filestorage_Google').each(function() {
var configured = $(this).find('[data-parameter="configured"]');
if ($(configured).val() == 'true') {
- $(this).find('.configuration')
- .append(''+t('files_external', 'Access granted')+'');
+ $(this).find('.configuration').append(''+t('files_external', 'Access granted')+'');
} else {
var token = $(this).find('[data-parameter="token"]');
var token_secret = $(this).find('[data-parameter="token_secret"]');
@@ -22,37 +21,44 @@ $(document).ready(function() {
OC.MountConfig.saveStorage(tr);
$(tr).find('.configuration').append(''+t('files_external', 'Access granted')+'');
} else {
- OC.dialogs.alert(result.data.message,
- t('files_external', 'Error configuring Google Drive storage')
- );
+ OC.dialogs.alert(result.data.message, t('files_external', 'Error configuring Google Drive storage'));
}
});
- } else if ($(this).find('.google').length == 0) {
- $(this).find('.configuration').append(''+t('files_external', 'Grant access')+'');
- }
- }
- });
-
- $('#externalStorage tbody tr').live('change', function() {
- if ($(this).hasClass('OC_Filestorage_Google') && $(this).find('[data-parameter="configured"]').val() != 'true') {
- if ($(this).find('.mountPoint input').val() != '') {
- if ($(this).find('.google').length == 0) {
- $(this).find('.configuration').append(''+t('files_external', 'Grant access')+'');
- }
- }
- }
- });
-
- $('#externalStorage tbody tr .mountPoint input').live('keyup', function() {
- var tr = $(this).parent().parent();
- if ($(tr).hasClass('OC_Filestorage_Google') && $(tr).find('[data-parameter="configured"]').val() != 'true' && $(tr).find('.google').length > 0) {
- if ($(this).val() != '') {
- $(tr).find('.google').show();
} else {
+ onGoogleInputsChange(this);
+ }
+ }
+ });
+
+ $('#externalStorage tbody tr.OC_Filestorage_Google td').live('paste', function() {
+ var tr = $(this).parent();
+ setTimeout(function() {
+ onGoogleInputsChange(tr);
+ }, 20);
+ });
+
+ $('#externalStorage tbody tr.OC_Filestorage_Google td').live('keyup', function() {
+ onGoogleInputsChange($(this).parent());
+ });
+
+ $('#externalStorage tbody tr.OC_Filestorage_Google .chzn-select').live('change', function() {
+ onGoogleInputsChange($(this).parent().parent());
+ });
+
+ function onGoogleInputsChange(tr) {
+ if ($(tr).find('[data-parameter="configured"]').val() != 'true') {
+ var config = $(tr).find('.configuration');
+ if ($(tr).find('.mountPoint input').val() != '' && ($(tr).find('.chzn-select').length == 0 || $(tr).find('.chzn-select').val() != null)) {
+ if ($(tr).find('.google').length == 0) {
+ $(config).append(''+t('files_external', 'Grant access')+'');
+ } else {
+ $(tr).find('.google').show();
+ }
+ } else if ($(tr).find('.google').length > 0) {
$(tr).find('.google').hide();
}
}
- });
+ }
$('.google').live('click', function(event) {
event.preventDefault();
@@ -60,23 +66,18 @@ $(document).ready(function() {
var configured = $(this).parent().find('[data-parameter="configured"]');
var token = $(this).parent().find('[data-parameter="token"]');
var token_secret = $(this).parent().find('[data-parameter="token_secret"]');
+ var statusSpan = $(tr).find('.status span');
$.post(OC.filePath('files_external', 'ajax', 'google.php'), { step: 1, callback: location.protocol + '//' + location.host + location.pathname }, function(result) {
if (result && result.status == 'success') {
$(configured).val('false');
$(token).val(result.data.request_token);
$(token_secret).val(result.data.request_token_secret);
- if (OC.MountConfig.saveStorage(tr)) {
- window.location = result.data.url;
- } else {
- OC.dialogs.alert(
- t('files_external', 'Fill out all required fields'),
- t('files_external', 'Error configuring Google Drive storage')
- );
- }
+ OC.MountConfig.saveStorage(tr);
+ statusSpan.removeClass();
+ statusSpan.addClass('waiting');
+ window.location = result.data.url;
} else {
- OC.dialogs.alert(result.data.message,
- t('files_external', 'Error configuring Google Drive storage')
- );
+ OC.dialogs.alert(result.data.message, t('files_external', 'Error configuring Google Drive storage'));
}
});
});
diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js
index 25f6ed5798..b98fcf1b0a 100644
--- a/apps/files_external/js/settings.js
+++ b/apps/files_external/js/settings.js
@@ -58,12 +58,25 @@ OC.MountConfig={
}
users.push(applicable);
}
- $.post(OC.filePath('files_external', 'ajax', 'addMountPoint.php'), { mountPoint: mountPoint, class: backendClass, classOptions: classOptions, mountType: mountType, applicable: applicable, isPersonal: isPersonal }, function(result) {
- statusSpan.removeClass();
- if (result && result.status == 'success' && result.data.message) {
- statusSpan.addClass('success');
- } else {
- statusSpan.addClass('error');
+ $.ajax({type: 'POST',
+ url: OC.filePath('files_external', 'ajax', 'addMountPoint.php'),
+ data: {
+ mountPoint: mountPoint,
+ class: backendClass,
+ classOptions: classOptions,
+ mountType: mountType,
+ applicable: applicable,
+ isPersonal: isPersonal
+ },
+ async: false,
+ success: function(result) {
+ statusSpan.removeClass();
+ if (result && result.status == 'success' && result.data.message) {
+ status = true;
+ statusSpan.addClass('success');
+ } else {
+ statusSpan.addClass('error');
+ }
}
});
});
@@ -71,26 +84,61 @@ OC.MountConfig={
$(tr).find('.applicable').data('applicable-users', users);
var mountType = 'group';
$.each(oldGroups, function(index, applicable) {
- $.post(OC.filePath('files_external', 'ajax', 'removeMountPoint.php'), { mountPoint: mountPoint, mountType: mountType, applicable: applicable, isPersonal: isPersonal });
+ $.ajax({type: 'POST',
+ url: OC.filePath('files_external', 'ajax', 'removeMountPoint.php'),
+ data: {
+ mountPoint: mountPoint,
+ class: backendClass,
+ classOptions: classOptions,
+ mountType: mountType,
+ applicable: applicable,
+ isPersonal: isPersonal
+ },
+ async: false
+ });
});
var mountType = 'user';
$.each(oldUsers, function(index, applicable) {
- $.post(OC.filePath('files_external', 'ajax', 'removeMountPoint.php'), { mountPoint: mountPoint, mountType: mountType, applicable: applicable, isPersonal: isPersonal });
+ $.ajax({type: 'POST',
+ url: OC.filePath('files_external', 'ajax', 'removeMountPoint.php'),
+ data: {
+ mountPoint: mountPoint,
+ class: backendClass,
+ classOptions: classOptions,
+ mountType: mountType,
+ applicable: applicable,
+ isPersonal: isPersonal
+ },
+ async: false
+ });
});
} else {
var isPersonal = true;
var mountType = 'user';
var applicable = OC.currentUser;
- $.post(OC.filePath('files_external', 'ajax', 'addMountPoint.php'), { mountPoint: mountPoint, class: backendClass, classOptions: classOptions, mountType: mountType, applicable: applicable, isPersonal: isPersonal }, function(result) {
- statusSpan.removeClass();
- if (result && result.status == 'success' && result.data.message) {
- statusSpan.addClass('success');
- } else {
- statusSpan.addClass('error');
+ $.ajax({type: 'POST',
+ url: OC.filePath('files_external', 'ajax', 'addMountPoint.php'),
+ data: {
+ mountPoint: mountPoint,
+ class: backendClass,
+ classOptions: classOptions,
+ mountType: mountType,
+ applicable: applicable,
+ isPersonal: isPersonal
+ },
+ async: false,
+ success: function(result) {
+ statusSpan.removeClass();
+ if (result && result.status == 'success' && result.data.message) {
+ status = true;
+ statusSpan.addClass('success');
+ } else {
+ statusSpan.addClass('error');
+ }
}
});
}
- return true;
+ return status;
}
}
};