2015-10-29 19:27:14 +03:00
|
|
|
/**
|
|
|
|
* @author Björn Schießle <schiessle@owncloud.com>
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2015, ownCloud, Inc.
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
|
|
|
|
// show input field to add a new trusted server
|
|
|
|
$("#ocFederationAddServer").on('click', function() {
|
|
|
|
$('#ocFederationAddServerButton').addClass('hidden');
|
|
|
|
$("#serverUrl").removeClass('hidden');
|
|
|
|
$("#serverUrl").focus();
|
|
|
|
});
|
|
|
|
|
|
|
|
// add new trusted server
|
|
|
|
$("#serverUrl").keyup(function (e) {
|
|
|
|
if (e.keyCode === 13) { // add server on "enter"
|
|
|
|
var url = $('#serverUrl').val();
|
|
|
|
OC.msg.startSaving('#ocFederationAddServer .msg');
|
|
|
|
$.post(
|
|
|
|
OC.generateUrl('/apps/federation/trusted-servers'),
|
|
|
|
{
|
|
|
|
url: url
|
|
|
|
}
|
|
|
|
).done(function (data) {
|
|
|
|
$('#serverUrl').attr('value', '');
|
|
|
|
$('ul#listOfTrustedServers').prepend(
|
2015-11-18 15:38:03 +03:00
|
|
|
$('<li>')
|
|
|
|
.attr('id', data.id)
|
2016-06-08 14:11:30 +03:00
|
|
|
.html('<span class="status indeterminate"></span>' +
|
|
|
|
data.url +
|
|
|
|
'<span class="icon icon-delete"></span>')
|
2015-10-29 19:27:14 +03:00
|
|
|
);
|
|
|
|
OC.msg.finishedSuccess('#ocFederationAddServer .msg', data.message);
|
|
|
|
})
|
|
|
|
.fail(function (jqXHR) {
|
|
|
|
OC.msg.finishedError('#ocFederationAddServer .msg', JSON.parse(jqXHR.responseText).message);
|
|
|
|
});
|
|
|
|
} else if (e.keyCode === 27) { // hide input filed again in ESC
|
|
|
|
$('#ocFederationAddServerButton').toggleClass('hidden');
|
|
|
|
$("#serverUrl").toggleClass('hidden');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-06-08 12:02:05 +03:00
|
|
|
// remove trusted server from list
|
|
|
|
$( "#listOfTrustedServers" ).on('click', 'li > .icon-delete', function() {
|
|
|
|
var $this = $(this).parent();
|
2016-06-08 13:19:18 +03:00
|
|
|
id = $this.attr('id');
|
2015-10-29 19:27:14 +03:00
|
|
|
$.ajax({
|
|
|
|
url: OC.generateUrl('/apps/federation/trusted-servers/' + id),
|
|
|
|
type: 'DELETE',
|
|
|
|
success: function(response) {
|
|
|
|
$this.remove();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-11-18 17:07:41 +03:00
|
|
|
$("#ocFederationSettings #autoAddServers").change(function() {
|
|
|
|
$.post(
|
|
|
|
OC.generateUrl('/apps/federation/auto-add-servers'),
|
|
|
|
{
|
|
|
|
autoAddServers: $(this).is(":checked")
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2015-10-29 19:27:14 +03:00
|
|
|
});
|