summaryrefslogtreecommitdiffstats
path: root/apps/federation/js/settings-admin.js
diff options
context:
space:
mode:
authorBjörn Schießle <bjoern@schiessle.org>2015-10-29 17:27:14 +0100
committerBjörn Schießle <bjoern@schiessle.org>2015-11-19 18:06:38 +0100
commited039ee5ebdba6778b245f249fe206d2423a6a36 (patch)
treeaa7a172b02e20eb878399c39624ee47496b4fee2 /apps/federation/js/settings-admin.js
parent479cee66f40cbb6340b0c1f106101692edde821a (diff)
downloadnextcloud-server-ed039ee5ebdba6778b245f249fe206d2423a6a36.tar.gz
nextcloud-server-ed039ee5ebdba6778b245f249fe206d2423a6a36.zip
added app "federation", allows you to connect ownClouds and exchange user lists
Diffstat (limited to 'apps/federation/js/settings-admin.js')
-rw-r--r--apps/federation/js/settings-admin.js70
1 files changed, 70 insertions, 0 deletions
diff --git a/apps/federation/js/settings-admin.js b/apps/federation/js/settings-admin.js
new file mode 100644
index 00000000000..a1f02a09efe
--- /dev/null
+++ b/apps/federation/js/settings-admin.js
@@ -0,0 +1,70 @@
+/**
+ * @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(
+ $('<li>').attr('id', data.id).text(data.url)
+ );
+ 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');
+ }
+ });
+
+ // remove trusted server from list
+ $( "#listOfTrustedServers" ).on('click', 'li', function() {
+ var id = $(this).attr('id');
+ var $this = $(this);
+ $.ajax({
+ url: OC.generateUrl('/apps/federation/trusted-servers/' + id),
+ type: 'DELETE',
+ success: function(response) {
+ $this.remove();
+ }
+ });
+
+ });
+
+});