2013-10-10 09:10:32 +00:00
|
|
|
(function(){
|
|
|
|
|
|
|
|
function updateStatus(statusEl, result){
|
2013-10-11 10:36:30 +00:00
|
|
|
statusEl.removeClass('success error loading-small');
|
2014-08-14 16:48:34 +00:00
|
|
|
if (result && result.status === 'success' && result.data.message) {
|
2013-10-10 09:10:32 +00:00
|
|
|
statusEl.addClass('success');
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
statusEl.addClass('error');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-21 13:11:21 +00:00
|
|
|
function getSelection($row) {
|
|
|
|
var values = $row.find('.applicableUsers').select2('val');
|
|
|
|
if (!values || values.length === 0) {
|
|
|
|
values = ['all'];
|
|
|
|
}
|
|
|
|
return values;
|
|
|
|
}
|
|
|
|
|
2014-10-13 16:40:57 +00:00
|
|
|
function highlightBorder($element, highlight) {
|
|
|
|
$element.toggleClass('warning-input', highlight);
|
2014-08-14 16:48:34 +00:00
|
|
|
return highlight;
|
|
|
|
}
|
|
|
|
|
2014-10-13 16:40:57 +00:00
|
|
|
function highlightInput($input) {
|
|
|
|
if ($input.attr('type') === 'text' || $input.attr('type') === 'password') {
|
|
|
|
return highlightBorder($input,
|
|
|
|
($input.val() === '' && !$input.hasClass('optional')));
|
2014-08-14 16:48:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-13 21:09:37 +00:00
|
|
|
OC.MountConfig={
|
2014-10-13 16:40:57 +00:00
|
|
|
saveStorage:function($tr, callback) {
|
|
|
|
var mountPoint = $tr.find('.mountPoint input').val();
|
|
|
|
var oldMountPoint = $tr.find('.mountPoint input').data('mountpoint');
|
2014-08-14 16:48:34 +00:00
|
|
|
if (mountPoint === '') {
|
2012-06-08 15:42:00 +00:00
|
|
|
return false;
|
|
|
|
}
|
2014-10-13 16:40:57 +00:00
|
|
|
var statusSpan = $tr.find('.status span');
|
|
|
|
var backendClass = $tr.find('.backend').data('class');
|
|
|
|
var configuration = $tr.find('.configuration input');
|
2012-06-08 15:42:00 +00:00
|
|
|
var addMountPoint = true;
|
|
|
|
if (configuration.length < 1) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
var classOptions = {};
|
|
|
|
$.each(configuration, function(index, input) {
|
2014-08-14 16:48:34 +00:00
|
|
|
if ($(input).val() === '' && !$(input).hasClass('optional')) {
|
2012-06-08 15:42:00 +00:00
|
|
|
addMountPoint = false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if ($(input).is(':checkbox')) {
|
|
|
|
if ($(input).is(':checked')) {
|
|
|
|
classOptions[$(input).data('parameter')] = true;
|
|
|
|
} else {
|
|
|
|
classOptions[$(input).data('parameter')] = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
classOptions[$(input).data('parameter')] = $(input).val();
|
|
|
|
}
|
|
|
|
});
|
2012-12-24 18:55:37 +00:00
|
|
|
if ($('#externalStorage').data('admin') === true) {
|
2014-10-13 16:40:57 +00:00
|
|
|
var multiselect = getSelection($tr);
|
2012-12-24 18:55:37 +00:00
|
|
|
}
|
2012-06-08 15:42:00 +00:00
|
|
|
if (addMountPoint) {
|
2012-12-24 18:45:52 +00:00
|
|
|
var status = false;
|
2012-06-28 21:54:53 +00:00
|
|
|
if ($('#externalStorage').data('admin') === true) {
|
2012-06-08 15:42:00 +00:00
|
|
|
var isPersonal = false;
|
2014-10-13 16:40:57 +00:00
|
|
|
var oldGroups = $tr.find('.applicable').data('applicable-groups');
|
|
|
|
var oldUsers = $tr.find('.applicable').data('applicable-users');
|
2012-12-28 22:38:24 +00:00
|
|
|
var groups = [];
|
|
|
|
var users = [];
|
2012-06-08 15:42:00 +00:00
|
|
|
$.each(multiselect, function(index, value) {
|
|
|
|
var pos = value.indexOf('(group)');
|
|
|
|
if (pos != -1) {
|
|
|
|
var mountType = 'group';
|
|
|
|
var applicable = value.substr(0, pos);
|
|
|
|
if ($.inArray(applicable, oldGroups) != -1) {
|
|
|
|
oldGroups.splice($.inArray(applicable, oldGroups), 1);
|
|
|
|
}
|
2012-12-28 22:38:24 +00:00
|
|
|
groups.push(applicable);
|
2012-06-08 15:42:00 +00:00
|
|
|
} else {
|
|
|
|
var mountType = 'user';
|
|
|
|
var applicable = value;
|
|
|
|
if ($.inArray(applicable, oldUsers) != -1) {
|
|
|
|
oldUsers.splice($.inArray(applicable, oldUsers), 1);
|
|
|
|
}
|
2012-12-28 22:38:24 +00:00
|
|
|
users.push(applicable);
|
2012-06-08 15:42:00 +00:00
|
|
|
}
|
2013-10-11 10:36:30 +00:00
|
|
|
statusSpan.addClass('loading-small').removeClass('error success');
|
2013-01-01 21:19:40 +00:00
|
|
|
$.ajax({type: 'POST',
|
|
|
|
url: OC.filePath('files_external', 'ajax', 'addMountPoint.php'),
|
|
|
|
data: {
|
|
|
|
mountPoint: mountPoint,
|
2013-02-20 00:12:14 +00:00
|
|
|
'class': backendClass,
|
2013-01-01 21:19:40 +00:00
|
|
|
classOptions: classOptions,
|
|
|
|
mountType: mountType,
|
|
|
|
applicable: applicable,
|
2014-07-07 13:40:01 +00:00
|
|
|
isPersonal: isPersonal,
|
|
|
|
oldMountPoint: oldMountPoint
|
2013-01-01 21:19:40 +00:00
|
|
|
},
|
|
|
|
success: function(result) {
|
2014-10-13 16:40:57 +00:00
|
|
|
$tr.find('.mountPoint input').data('mountpoint', mountPoint);
|
2013-10-10 09:10:32 +00:00
|
|
|
status = updateStatus(statusSpan, result);
|
2013-12-06 16:23:51 +00:00
|
|
|
if (callback) {
|
|
|
|
callback(status);
|
|
|
|
}
|
2013-10-10 09:10:32 +00:00
|
|
|
},
|
|
|
|
error: function(result){
|
|
|
|
status = updateStatus(statusSpan, result);
|
2013-12-06 16:23:51 +00:00
|
|
|
if (callback) {
|
|
|
|
callback(status);
|
|
|
|
}
|
2012-12-24 18:45:52 +00:00
|
|
|
}
|
|
|
|
});
|
2012-06-08 15:42:00 +00:00
|
|
|
});
|
2014-10-13 16:40:57 +00:00
|
|
|
$tr.find('.applicable').data('applicable-groups', groups);
|
|
|
|
$tr.find('.applicable').data('applicable-users', users);
|
2012-06-08 15:42:00 +00:00
|
|
|
var mountType = 'group';
|
|
|
|
$.each(oldGroups, function(index, applicable) {
|
2013-01-01 21:19:40 +00:00
|
|
|
$.ajax({type: 'POST',
|
|
|
|
url: OC.filePath('files_external', 'ajax', 'removeMountPoint.php'),
|
|
|
|
data: {
|
|
|
|
mountPoint: mountPoint,
|
2013-06-12 08:30:54 +00:00
|
|
|
'class': backendClass,
|
2013-01-01 21:19:40 +00:00
|
|
|
classOptions: classOptions,
|
|
|
|
mountType: mountType,
|
|
|
|
applicable: applicable,
|
|
|
|
isPersonal: isPersonal
|
2013-10-10 09:10:32 +00:00
|
|
|
}
|
2013-01-01 21:19:40 +00:00
|
|
|
});
|
2012-06-08 15:42:00 +00:00
|
|
|
});
|
|
|
|
var mountType = 'user';
|
|
|
|
$.each(oldUsers, function(index, applicable) {
|
2013-01-01 21:19:40 +00:00
|
|
|
$.ajax({type: 'POST',
|
|
|
|
url: OC.filePath('files_external', 'ajax', 'removeMountPoint.php'),
|
|
|
|
data: {
|
|
|
|
mountPoint: mountPoint,
|
2013-06-12 08:30:54 +00:00
|
|
|
'class': backendClass,
|
2013-01-01 21:19:40 +00:00
|
|
|
classOptions: classOptions,
|
|
|
|
mountType: mountType,
|
|
|
|
applicable: applicable,
|
|
|
|
isPersonal: isPersonal
|
2013-10-10 09:10:32 +00:00
|
|
|
}
|
2013-01-01 21:19:40 +00:00
|
|
|
});
|
2012-06-08 15:42:00 +00:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
var isPersonal = true;
|
|
|
|
var mountType = 'user';
|
|
|
|
var applicable = OC.currentUser;
|
2013-10-11 10:36:30 +00:00
|
|
|
statusSpan.addClass('loading-small').removeClass('error success');
|
2013-01-01 21:19:40 +00:00
|
|
|
$.ajax({type: 'POST',
|
|
|
|
url: OC.filePath('files_external', 'ajax', 'addMountPoint.php'),
|
|
|
|
data: {
|
|
|
|
mountPoint: mountPoint,
|
2013-02-20 00:12:14 +00:00
|
|
|
'class': backendClass,
|
2013-01-01 21:19:40 +00:00
|
|
|
classOptions: classOptions,
|
|
|
|
mountType: mountType,
|
|
|
|
applicable: applicable,
|
2014-07-07 13:40:01 +00:00
|
|
|
isPersonal: isPersonal,
|
|
|
|
oldMountPoint: oldMountPoint
|
2013-01-01 21:19:40 +00:00
|
|
|
},
|
|
|
|
success: function(result) {
|
2014-10-13 16:40:57 +00:00
|
|
|
$tr.find('.mountPoint input').data('mountpoint', mountPoint);
|
2013-10-10 09:10:32 +00:00
|
|
|
status = updateStatus(statusSpan, result);
|
2013-12-06 16:23:51 +00:00
|
|
|
if (callback) {
|
|
|
|
callback(status);
|
|
|
|
}
|
2013-10-10 09:10:32 +00:00
|
|
|
},
|
|
|
|
error: function(result){
|
|
|
|
status = updateStatus(statusSpan, result);
|
2013-12-06 16:23:51 +00:00
|
|
|
if (callback) {
|
|
|
|
callback(status);
|
|
|
|
}
|
2012-12-24 18:45:52 +00:00
|
|
|
}
|
|
|
|
});
|
2012-06-08 15:42:00 +00:00
|
|
|
}
|
2013-01-01 21:19:40 +00:00
|
|
|
return status;
|
2012-06-08 15:42:00 +00:00
|
|
|
}
|
2012-06-12 15:36:25 +00:00
|
|
|
}
|
2012-09-05 20:17:33 +00:00
|
|
|
};
|
2012-06-12 15:36:25 +00:00
|
|
|
|
|
|
|
$(document).ready(function() {
|
2014-10-13 16:40:57 +00:00
|
|
|
var $externalStorage = $('#externalStorage');
|
|
|
|
|
2014-05-08 13:25:46 +00:00
|
|
|
//initialize hidden input field with list of users and groups
|
2014-10-13 16:40:57 +00:00
|
|
|
$externalStorage.find('tr:not(#addMountPoint)').each(function(i,tr) {
|
|
|
|
var $tr = $(tr);
|
|
|
|
var $applicable = $tr.find('.applicable');
|
|
|
|
if ($applicable.length > 0) {
|
|
|
|
var groups = $applicable.data('applicable-groups');
|
2014-05-08 13:25:46 +00:00
|
|
|
var groupsId = [];
|
|
|
|
$.each(groups, function () {
|
2014-10-13 16:40:57 +00:00
|
|
|
groupsId.push(this + '(group)');
|
2014-05-08 13:25:46 +00:00
|
|
|
});
|
2014-10-13 16:40:57 +00:00
|
|
|
var users = $applicable.data('applicable-users');
|
2014-05-08 13:25:46 +00:00
|
|
|
if (users.indexOf('all') > -1) {
|
2014-10-13 16:40:57 +00:00
|
|
|
$tr.find('.applicableUsers').val('');
|
2014-05-08 13:25:46 +00:00
|
|
|
} else {
|
2014-10-13 16:40:57 +00:00
|
|
|
$tr.find('.applicableUsers').val(groupsId.concat(users).join(','));
|
2014-05-08 13:25:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var userListLimit = 30;
|
|
|
|
function addSelect2 ($elements) {
|
|
|
|
if ($elements.length > 0) {
|
|
|
|
$elements.select2({
|
|
|
|
placeholder: t('files_external', 'All users. Type to select user or group.'),
|
|
|
|
allowClear: true,
|
|
|
|
multiple: true,
|
|
|
|
//minimumInputLength: 1,
|
|
|
|
ajax: {
|
|
|
|
url: OC.generateUrl('apps/files_external/applicable'),
|
|
|
|
dataType: 'json',
|
|
|
|
quietMillis: 100,
|
|
|
|
data: function (term, page) { // page is the one-based page number tracked by Select2
|
|
|
|
return {
|
|
|
|
pattern: term, //search term
|
|
|
|
limit: userListLimit, // page size
|
2014-08-21 13:11:21 +00:00
|
|
|
offset: userListLimit*(page-1) // page number starts with 0
|
2014-05-08 13:25:46 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
results: function (data, page) {
|
2014-10-13 16:40:57 +00:00
|
|
|
if (data.status === 'success') {
|
2014-05-08 13:25:46 +00:00
|
|
|
|
|
|
|
var results = [];
|
|
|
|
var userCount = 0; // users is an object
|
|
|
|
|
|
|
|
// add groups
|
|
|
|
$.each(data.groups, function(i, group) {
|
|
|
|
results.push({name:group+'(group)', displayname:group, type:'group' });
|
|
|
|
});
|
|
|
|
// add users
|
|
|
|
$.each(data.users, function(id, user) {
|
|
|
|
userCount++;
|
|
|
|
results.push({name:id, displayname:user, type:'user' });
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var more = (userCount >= userListLimit) || (data.groups.length >= userListLimit);
|
|
|
|
return {results: results, more: more};
|
|
|
|
} else {
|
|
|
|
//FIXME add error handling
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
initSelection: function(element, callback) {
|
2014-08-22 16:16:55 +00:00
|
|
|
var users = {};
|
|
|
|
users['users'] = [];
|
|
|
|
var toSplit = element.val().split(",");
|
|
|
|
for (var i = 0; i < toSplit.length; i++) {
|
|
|
|
users['users'].push(toSplit[i]);
|
|
|
|
}
|
|
|
|
|
2014-08-22 14:07:48 +00:00
|
|
|
$.ajax(OC.generateUrl('displaynames'), {
|
2014-08-22 16:16:55 +00:00
|
|
|
type: 'POST',
|
|
|
|
contentType: 'application/json',
|
|
|
|
data: JSON.stringify(users),
|
2014-10-13 16:40:57 +00:00
|
|
|
dataType: 'json'
|
2014-08-22 14:07:48 +00:00
|
|
|
}).done(function(data) {
|
|
|
|
var results = [];
|
2014-10-13 16:40:57 +00:00
|
|
|
if (data.status === 'success') {
|
2014-08-22 14:07:48 +00:00
|
|
|
$.each(data.users, function(user, displayname) {
|
|
|
|
if (displayname !== false) {
|
|
|
|
results.push({name:user, displayname:displayname, type:'user'});
|
2014-05-08 13:25:46 +00:00
|
|
|
}
|
|
|
|
});
|
2014-08-22 14:07:48 +00:00
|
|
|
callback(results);
|
|
|
|
} else {
|
|
|
|
//FIXME add error handling
|
2014-05-08 13:25:46 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
id: function(element) {
|
|
|
|
return element.name;
|
|
|
|
},
|
|
|
|
formatResult: function (element) {
|
|
|
|
var $result = $('<span><div class="avatardiv"/><span>'+escapeHTML(element.displayname)+'</span></span>');
|
|
|
|
var $div = $result.find('.avatardiv')
|
|
|
|
.attr('data-type', element.type)
|
|
|
|
.attr('data-name', element.name)
|
|
|
|
.attr('data-displayname', element.displayname);
|
|
|
|
if (element.type === 'group') {
|
|
|
|
var url = OC.imagePath('core','places/contacts-dark'); // TODO better group icon
|
|
|
|
$div.html('<img width="32" height="32" src="'+url+'">');
|
|
|
|
}
|
|
|
|
return $result.get(0).outerHTML;
|
|
|
|
},
|
|
|
|
formatSelection: function (element) {
|
|
|
|
if (element.type === 'group') {
|
|
|
|
return '<span title="'+escapeHTML(element.name)+'" class="group">'+escapeHTML(element.displayname+' '+t('files_external', '(group)'))+'</span>';
|
|
|
|
} else {
|
|
|
|
return '<span title="'+escapeHTML(element.name)+'" class="user">'+escapeHTML(element.displayname)+'</span>';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
escapeMarkup: function (m) { return m; } // we escape the markup in formatResult and formatSelection
|
2014-10-13 16:40:57 +00:00
|
|
|
}).on('select2-loaded', function() {
|
|
|
|
$.each($('.avatardiv'), function(i, div) {
|
|
|
|
var $div = $(div);
|
2014-05-08 13:25:46 +00:00
|
|
|
if ($div.data('type') === 'user') {
|
|
|
|
$div.avatar($div.data('name'),32);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
addSelect2($('tr:not(#addMountPoint) .applicableUsers'));
|
|
|
|
|
2014-10-13 16:40:57 +00:00
|
|
|
$externalStorage.on('change', '#selectBackend', function() {
|
|
|
|
var $tr = $(this).closest('tr');
|
|
|
|
$externalStorage.find('tbody').append($tr.clone());
|
|
|
|
$externalStorage.find('tbody tr').last().find('.mountPoint input').val('');
|
2012-06-12 15:36:25 +00:00
|
|
|
var selected = $(this).find('option:selected').text();
|
|
|
|
var backendClass = $(this).val();
|
2014-10-13 16:40:57 +00:00
|
|
|
$tr.find('.backend').text(selected);
|
|
|
|
if ($tr.find('.mountPoint input').val() === '') {
|
|
|
|
$tr.find('.mountPoint input').val(suggestMountPoint(selected));
|
2012-08-13 21:09:37 +00:00
|
|
|
}
|
2014-10-13 16:40:57 +00:00
|
|
|
$tr.addClass(backendClass);
|
|
|
|
$tr.find('.status').append('<span></span>');
|
|
|
|
$tr.find('.backend').data('class', backendClass);
|
2012-06-12 15:36:25 +00:00
|
|
|
var configurations = $(this).data('configurations');
|
2014-10-13 16:40:57 +00:00
|
|
|
var $td = $tr.find('td.configuration');
|
2012-06-12 15:36:25 +00:00
|
|
|
$.each(configurations, function(backend, parameters) {
|
2014-08-14 16:48:34 +00:00
|
|
|
if (backend === backendClass) {
|
2012-06-12 15:36:25 +00:00
|
|
|
$.each(parameters['configuration'], function(parameter, placeholder) {
|
2014-03-21 13:51:45 +00:00
|
|
|
var is_optional = false;
|
|
|
|
if (placeholder.indexOf('&') === 0) {
|
|
|
|
is_optional = true;
|
|
|
|
placeholder = placeholder.substring(1);
|
|
|
|
}
|
2014-08-14 16:48:34 +00:00
|
|
|
var newElement;
|
2014-03-21 13:51:45 +00:00
|
|
|
if (placeholder.indexOf('*') === 0) {
|
2014-07-15 20:33:30 +00:00
|
|
|
var class_string = is_optional ? ' optional' : '';
|
2014-08-14 16:48:34 +00:00
|
|
|
newElement = $('<input type="password" class="added' + class_string + '" data-parameter="'+parameter+'" placeholder="'+placeholder.substring(1)+'" />');
|
2014-03-24 13:27:46 +00:00
|
|
|
} else if (placeholder.indexOf('!') === 0) {
|
2014-08-14 16:48:34 +00:00
|
|
|
newElement = $('<label><input type="checkbox" class="added" data-parameter="'+parameter+'" />'+placeholder.substring(1)+'</label>');
|
2014-03-24 13:27:46 +00:00
|
|
|
} else if (placeholder.indexOf('#') === 0) {
|
2014-08-14 16:48:34 +00:00
|
|
|
newElement = $('<input type="hidden" class="added" data-parameter="'+parameter+'" />');
|
2014-03-24 13:27:46 +00:00
|
|
|
} else {
|
2014-07-15 20:33:30 +00:00
|
|
|
var class_string = is_optional ? ' optional' : '';
|
2014-08-14 16:48:34 +00:00
|
|
|
newElement = $('<input type="text" class="added' + class_string + '" data-parameter="'+parameter+'" placeholder="'+placeholder+'" />');
|
2012-06-12 15:36:25 +00:00
|
|
|
}
|
2014-08-14 16:48:34 +00:00
|
|
|
highlightInput(newElement);
|
2014-10-13 16:40:57 +00:00
|
|
|
$td.append(newElement);
|
2012-06-12 15:36:25 +00:00
|
|
|
});
|
2014-10-13 16:40:57 +00:00
|
|
|
if (parameters['custom'] && $externalStorage.find('tbody tr.'+backendClass.replace(/\\/g, '\\\\')).length === 1) {
|
2012-06-12 15:36:25 +00:00
|
|
|
OC.addScript('files_external', parameters['custom']);
|
|
|
|
}
|
2014-10-13 16:40:57 +00:00
|
|
|
$td.children().not('[type=hidden]').first().focus();
|
2012-06-12 15:36:25 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
2014-10-13 16:40:57 +00:00
|
|
|
$tr.find('td').last().attr('class', 'remove');
|
|
|
|
$tr.find('td').last().removeAttr('style');
|
|
|
|
$tr.removeAttr('id');
|
2012-06-12 15:36:25 +00:00
|
|
|
$(this).remove();
|
2014-10-13 16:40:57 +00:00
|
|
|
addSelect2($tr.find('.applicableUsers'));
|
2012-06-12 15:36:25 +00:00
|
|
|
});
|
|
|
|
|
2012-08-13 21:09:37 +00:00
|
|
|
function suggestMountPoint(defaultMountPoint) {
|
2012-12-28 20:56:48 +00:00
|
|
|
var pos = defaultMountPoint.indexOf('/');
|
|
|
|
if (pos !== -1) {
|
|
|
|
defaultMountPoint = defaultMountPoint.substring(0, pos);
|
|
|
|
}
|
|
|
|
defaultMountPoint = defaultMountPoint.replace(/\s+/g, '');
|
2012-08-13 21:09:37 +00:00
|
|
|
var i = 1;
|
|
|
|
var append = '';
|
|
|
|
var match = true;
|
|
|
|
while (match && i < 20) {
|
|
|
|
match = false;
|
2014-10-13 16:40:57 +00:00
|
|
|
$externalStorage.find('tbody td.mountPoint input').each(function(index, mountPoint) {
|
2014-08-14 16:48:34 +00:00
|
|
|
if ($(mountPoint).val() === defaultMountPoint+append) {
|
2012-08-13 21:09:37 +00:00
|
|
|
match = true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (match) {
|
|
|
|
append = i;
|
|
|
|
i++;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return defaultMountPoint+append;
|
2012-08-29 06:42:49 +00:00
|
|
|
}
|
2012-08-13 21:09:37 +00:00
|
|
|
|
2014-10-13 16:40:57 +00:00
|
|
|
$externalStorage.on('paste', 'td input', function() {
|
|
|
|
var $me = $(this);
|
|
|
|
var $tr = $me.closest('tr');
|
2012-12-26 18:35:22 +00:00
|
|
|
setTimeout(function() {
|
2014-10-13 16:40:57 +00:00
|
|
|
highlightInput($me);
|
|
|
|
OC.MountConfig.saveStorage($tr);
|
2012-12-26 18:35:22 +00:00
|
|
|
}, 20);
|
|
|
|
});
|
|
|
|
|
|
|
|
var timer;
|
|
|
|
|
2014-10-13 16:40:57 +00:00
|
|
|
$externalStorage.on('keyup', 'td input', function() {
|
2012-12-26 18:35:22 +00:00
|
|
|
clearTimeout(timer);
|
2014-10-13 16:40:57 +00:00
|
|
|
var $tr = $(this).closest('tr');
|
2014-08-14 16:48:34 +00:00
|
|
|
highlightInput($(this));
|
2012-12-26 18:35:22 +00:00
|
|
|
if ($(this).val) {
|
|
|
|
timer = setTimeout(function() {
|
2014-10-13 16:40:57 +00:00
|
|
|
OC.MountConfig.saveStorage($tr);
|
2012-12-26 18:35:22 +00:00
|
|
|
}, 2000);
|
|
|
|
}
|
2012-05-24 15:06:03 +00:00
|
|
|
});
|
|
|
|
|
2014-10-13 16:40:57 +00:00
|
|
|
$externalStorage.on('change', 'td input:checkbox', function() {
|
|
|
|
OC.MountConfig.saveStorage($(this).closest('tr'));
|
2013-01-02 17:13:59 +00:00
|
|
|
});
|
|
|
|
|
2014-10-13 16:40:57 +00:00
|
|
|
$externalStorage.on('change', '.applicable', function() {
|
|
|
|
OC.MountConfig.saveStorage($(this).closest('tr'));
|
2014-08-14 16:48:34 +00:00
|
|
|
});
|
|
|
|
|
2014-10-13 16:40:57 +00:00
|
|
|
$externalStorage.on('click', '.status>span', function() {
|
|
|
|
OC.MountConfig.saveStorage($(this).closest('tr'));
|
2012-12-28 22:38:24 +00:00
|
|
|
});
|
|
|
|
|
2014-03-05 14:47:12 +00:00
|
|
|
$('#sslCertificate').on('click', 'td.remove>img', function() {
|
2014-10-13 16:40:57 +00:00
|
|
|
var $tr = $(this).closest('tr');
|
2014-08-14 16:48:34 +00:00
|
|
|
$.post(OC.filePath('files_external', 'ajax', 'removeRootCertificate.php'), {cert: $tr.attr('id')});
|
2013-06-12 08:30:54 +00:00
|
|
|
$tr.remove();
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
2014-10-13 16:40:57 +00:00
|
|
|
$externalStorage.on('click', 'td.remove>img', function() {
|
|
|
|
var $tr = $(this).closest('tr');
|
|
|
|
var mountPoint = $tr.find('.mountPoint input').val();
|
2013-06-12 08:30:54 +00:00
|
|
|
|
2014-10-13 16:40:57 +00:00
|
|
|
if ($externalStorage.data('admin') === true) {
|
2012-06-08 15:42:00 +00:00
|
|
|
var isPersonal = false;
|
2014-10-13 16:40:57 +00:00
|
|
|
var multiselect = getSelection($tr);
|
2014-08-21 13:11:21 +00:00
|
|
|
$.each(multiselect, function(index, value) {
|
|
|
|
var pos = value.indexOf('(group)');
|
|
|
|
if (pos != -1) {
|
|
|
|
var mountType = 'group';
|
|
|
|
var applicable = value.substr(0, pos);
|
|
|
|
} else {
|
|
|
|
var mountType = 'user';
|
|
|
|
var applicable = value;
|
|
|
|
}
|
|
|
|
$.post(OC.filePath('files_external', 'ajax', 'removeMountPoint.php'), { mountPoint: mountPoint, mountType: mountType, applicable: applicable, isPersonal: isPersonal });
|
|
|
|
});
|
2012-06-08 15:42:00 +00:00
|
|
|
} else {
|
|
|
|
var mountType = 'user';
|
|
|
|
var applicable = OC.currentUser;
|
|
|
|
var isPersonal = true;
|
2012-12-28 22:38:24 +00:00
|
|
|
$.post(OC.filePath('files_external', 'ajax', 'removeMountPoint.php'), { mountPoint: mountPoint, mountType: mountType, applicable: applicable, isPersonal: isPersonal });
|
2012-06-08 15:42:00 +00:00
|
|
|
}
|
2014-10-13 16:40:57 +00:00
|
|
|
$tr.remove();
|
2012-05-24 15:06:03 +00:00
|
|
|
});
|
|
|
|
|
2014-10-13 16:40:57 +00:00
|
|
|
var $allowUserMounting = $('#allowUserMounting');
|
|
|
|
$allowUserMounting.bind('change', function() {
|
2014-02-18 15:36:02 +00:00
|
|
|
OC.msg.startSaving('#userMountingMsg');
|
2012-06-08 15:42:00 +00:00
|
|
|
if (this.checked) {
|
|
|
|
OC.AppConfig.setValue('files_external', 'allow_user_mounting', 'yes');
|
2014-06-13 16:14:41 +00:00
|
|
|
$('input[name="allowUserMountingBackends\\[\\]"]').prop('checked', true);
|
2014-06-16 09:33:51 +00:00
|
|
|
$('#userMountingBackends').removeClass('hidden');
|
2014-06-16 09:35:48 +00:00
|
|
|
$('input[name="allowUserMountingBackends\\[\\]"]').eq(0).trigger('change');
|
2012-06-08 15:42:00 +00:00
|
|
|
} else {
|
|
|
|
OC.AppConfig.setValue('files_external', 'allow_user_mounting', 'no');
|
2014-06-16 09:33:51 +00:00
|
|
|
$('#userMountingBackends').addClass('hidden');
|
2012-06-08 15:42:00 +00:00
|
|
|
}
|
2014-02-18 15:36:02 +00:00
|
|
|
OC.msg.finishedSaving('#userMountingMsg', {status: 'success', data: {message: t('settings', 'Saved')}});
|
2012-05-24 15:06:03 +00:00
|
|
|
});
|
|
|
|
|
2014-02-18 15:36:02 +00:00
|
|
|
$('input[name="allowUserMountingBackends\\[\\]"]').bind('change', function() {
|
|
|
|
OC.msg.startSaving('#userMountingMsg');
|
2014-06-16 09:35:48 +00:00
|
|
|
var userMountingBackends = $('input[name="allowUserMountingBackends\\[\\]"]:checked').map(function(){return $(this).val();}).get();
|
|
|
|
OC.AppConfig.setValue('files_external', 'user_mounting_backends', userMountingBackends.join());
|
2014-02-18 15:36:02 +00:00
|
|
|
OC.msg.finishedSaving('#userMountingMsg', {status: 'success', data: {message: t('settings', 'Saved')}});
|
2014-06-13 16:14:41 +00:00
|
|
|
|
|
|
|
// disable allowUserMounting
|
2014-06-16 09:35:48 +00:00
|
|
|
if(userMountingBackends.length === 0) {
|
2014-10-13 16:40:57 +00:00
|
|
|
$allowUserMounting.prop('checked', false);
|
|
|
|
$allowUserMounting.trigger('change');
|
2014-06-13 16:14:41 +00:00
|
|
|
|
|
|
|
}
|
2014-02-18 15:36:02 +00:00
|
|
|
});
|
2012-09-05 20:17:33 +00:00
|
|
|
});
|
2013-10-10 09:10:32 +00:00
|
|
|
|
|
|
|
})();
|