diff options
Diffstat (limited to 'apps/federation/js/settings-admin.js')
-rw-r--r-- | apps/federation/js/settings-admin.js | 65 |
1 files changed, 21 insertions, 44 deletions
diff --git a/apps/federation/js/settings-admin.js b/apps/federation/js/settings-admin.js index 251ea4c4a34..aa672e53e94 100644 --- a/apps/federation/js/settings-admin.js +++ b/apps/federation/js/settings-admin.js @@ -1,25 +1,12 @@ + /** - * @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/> - * + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ (function( $ ) { - + // ocFederationAddServer $.fn.ocFederationAddServer = function() { @@ -27,14 +14,13 @@ ========================================================================== */ var $wrapper = $(this), - + // Buttons $btnAddServer = $wrapper.find("#ocFederationAddServerButton"), $btnSubmit = $wrapper.find("#ocFederationSubmit"), - + // Inputs $inpServerUrl = $wrapper.find("#serverUrl"), - $inpAutoAddServers = $wrapper.find("#autoAddServers"), // misc $msgBox = $wrapper.find("#ocFederationAddServer .msg"), @@ -46,8 +32,8 @@ $btnAddServer.on('click', function() { $btnAddServer.addClass('hidden'); + $wrapper.find(".serverUrl").removeClass('hidden'); $inpServerUrl - .removeClass('hidden') .focus(); }); @@ -55,17 +41,8 @@ $srvList.on('click', 'li > .icon-delete', function() { var $this = $(this).parent(); var id = $this.attr('id'); - - removeServer( id ); - }); - $inpAutoAddServers.on("change", function() { - $.post( - OC.generateUrl('/apps/federation/auto-add-servers'), - { - autoAddServers: $(this).is(":checked") - } - ); + removeServer( id ); }); $btnSubmit.on("click", function() @@ -74,12 +51,9 @@ }); $inpServerUrl.on("change keyup", function (e) { - - console.log("typing away"); - var url = $(this).val(); - // toggle add-button visiblity based on input length + // toggle add-button visibility based on input length if ( url.length > 0 ) $btnSubmit.removeClass("hidden") else @@ -94,7 +68,7 @@ } }); }; - + /* private Functions ========================================================================== */ @@ -102,11 +76,14 @@ OC.msg.startSaving('#ocFederationAddServer .msg'); $.post( - OC.generateUrl('/apps/federation/trusted-servers'), + OC.getRootPath() + '/ocs/v2.php/apps/federation/trusted-servers', { url: url - } - ).done(function (data) { + }, + null, + 'json' + ).done(function({ ocs }) { + var data = ocs.data; $("#serverUrl").attr('value', ''); $("#listOfTrustedServers").prepend( $('<li>') @@ -118,13 +95,13 @@ OC.msg.finishedSuccess('#ocFederationAddServer .msg', data.message); }) .fail(function (jqXHR) { - OC.msg.finishedError('#ocFederationAddServer .msg', JSON.parse(jqXHR.responseText).message); + OC.msg.finishedError('#ocFederationAddServer .msg', JSON.parse(jqXHR.responseText).ocs.meta.message); }); }; function removeServer( id ) { $.ajax({ - url: OC.generateUrl('/apps/federation/trusted-servers/' + id), + url: OC.getRootPath() + '/ocs/v2.php/apps/federation/trusted-servers/' + id, type: 'DELETE', success: function(response) { $("#ocFederationSettings").find("#" + id).remove(); @@ -132,11 +109,11 @@ }); } - + })( jQuery ); window.addEventListener('DOMContentLoaded', function () { $('#ocFederationSettings').ocFederationAddServer(); - + }); |