-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ajaxify Cors section in Personal settings
- Loading branch information
Showing
7 changed files
with
151 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Bugfix: Show error message at Settings Personal CORS | ||
|
||
Skipping a protocol at Settings Personal CORS silently refused to add the domain. | ||
Proper error message added. | ||
|
||
|
||
https://github.com/owncloud/core/pull/37560 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,67 @@ | ||
var PersonalCors = { | ||
renderRow: function(domain){ | ||
var row = $('<tr />').appendTo('#cors .grid tbody'); | ||
$('<td />').appendTo(row).text(domain); | ||
var col = $('<td />').appendTo(row); | ||
$('<input type="button" class="button icon-delete removeDomainButton" />') | ||
.data('value', domain) | ||
.data('confirm', t('settings', 'Are you sure you want to remove this domain?')) | ||
.appendTo(col) | ||
}, | ||
render: function (data) { | ||
$("#cors .grid tbody tr").remove(); | ||
for (var p in data) { | ||
PersonalCors.renderRow(data[p]); | ||
} | ||
var numDomains = $("#cors .grid tbody tr").length; | ||
if (numDomains === 0) { | ||
$("#noDomains").show(); | ||
$("#cors .grid").hide(); | ||
} else { | ||
$("#noDomains").hide(); | ||
$("#cors .grid").show(); | ||
} | ||
} | ||
}; | ||
|
||
$(document).ready(function () { | ||
$('.removeDomainButton').on('click', function () { | ||
var id = $(this).attr('data-id'); | ||
var confirmText = $(this).attr('data-confirm'); | ||
var token = OC.requestToken; | ||
$('#cors').on('click', '.removeDomainButton', function () { | ||
var confirmText = $(this).data('confirm'); | ||
var $el = $(this); | ||
|
||
OC.dialogs.confirm( | ||
t('settings', confirmText), t('settings','CORS'), | ||
confirmText, t('settings','CORS'), | ||
function (result) { | ||
if (result) { | ||
var value = encodeURIComponent($el.data('value')); | ||
$.ajax({ | ||
type: 'DELETE', | ||
url: OC.generateUrl('/settings/domains/{id}', {id: id}), | ||
data: { | ||
requesttoken: token | ||
} | ||
}).success(function() { | ||
var numDomains = $("#cors .grid tbody tr").length; | ||
if ($el.closest('tr').length === 1 && numDomains === 1) { | ||
// Means only one domain row remains and that is to be deleted | ||
// Show the No domains text | ||
$("#noDomains").text("No Domains."); | ||
// Remove the domain listing table | ||
$("#cors .grid").remove(); | ||
url: OC.generateUrl('/settings/domains/{domain}', {domain: value}), | ||
data: {} | ||
}).success(function(response) { | ||
if (response.domains) { | ||
PersonalCors.render(response.domains) | ||
} | ||
$el.closest('tr').remove(); | ||
}); | ||
} | ||
}, true | ||
); | ||
}); | ||
$('#corsAddNewDomain').on('click', function() { | ||
$('#corsAddNewDomain').attr('disabled', true); | ||
$.post( | ||
OC.generateUrl('/settings/domains'), | ||
{ domain : $('#domain').val()}, | ||
function(response) { | ||
if (response.message) { | ||
OC.Notification.showTemporary(response.message); | ||
} | ||
if (response.domains) { | ||
PersonalCors.render(response.domains) | ||
} | ||
$('#domain').val(''); | ||
$('#corsAddNewDomain').attr('disabled', false); | ||
} | ||
) | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.