diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-12-22 17:42:28 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2016-01-12 12:50:59 +0100 |
commit | c15cab7ed6bf2d3ce9009ca09c7c5f33b252860f (patch) | |
tree | 08d3aefd146ce159b23073958f2fb7e96ace4143 /settings/js | |
parent | 0c0829fbc73ce10ea1a951989c20973b6b5faa16 (diff) | |
download | nextcloud-server-c15cab7ed6bf2d3ce9009ca09c7c5f33b252860f.tar.gz nextcloud-server-c15cab7ed6bf2d3ce9009ca09c7c5f33b252860f.zip |
Allow admins to add system wide root certificates
Diffstat (limited to 'settings/js')
-rw-r--r-- | settings/js/certificates.js | 69 | ||||
-rw-r--r-- | settings/js/personal.js | 67 |
2 files changed, 69 insertions, 67 deletions
diff --git a/settings/js/certificates.js b/settings/js/certificates.js new file mode 100644 index 00000000000..9ce9f9aa8d8 --- /dev/null +++ b/settings/js/certificates.js @@ -0,0 +1,69 @@ +$(document).ready(function () { + var type = $('#sslCertificate').data('type'); + $('#sslCertificate').on('click', 'td.remove', function () { + var row = $(this).parent(); + $.ajax(OC.generateUrl('settings/' + type + '/certificate/{certificate}', {certificate: row.data('name')}), { + type: 'DELETE' + }); + row.remove(); + + if ($('#sslCertificate > tbody > tr').length === 0) { + $('#sslCertificate').hide(); + } + return true; + }); + + $('#sslCertificate tr > td').tipsy({gravity: 'n', live: true}); + + $('#rootcert_import').fileupload({ + submit: function (e, data) { + data.formData = _.extend(data.formData || {}, { + requesttoken: OC.requestToken + }); + }, + success: function (data) { + if (typeof data === 'string') { + data = $.parseJSON(data); + } else if (data && data.length) { + // fetch response from iframe + data = $.parseJSON(data[0].body.innerText); + } + if (!data || typeof(data) === 'string') { + // IE8 iframe workaround comes here instead of fail() + OC.Notification.showTemporary( + t('settings', 'An error occurred. Please upload an ASCII-encoded PEM certificate.')); + return; + } + var issueDate = new Date(data.validFrom * 1000); + var expireDate = new Date(data.validTill * 1000); + var now = new Date(); + var isExpired = !(issueDate <= now && now <= expireDate); + + var row = $('<tr/>'); + row.data('name', data.name); + row.addClass(isExpired ? 'expired' : 'valid'); + row.append($('<td/>').attr('title', data.organization).text(data.commonName)); + row.append($('<td/>').attr('title', t('core,', 'Valid until {date}', {date: data.validTillString})) + .text(data.validTillString)); + row.append($('<td/>').attr('title', data.issuerOrganization).text(data.issuer)); + row.append($('<td/>').addClass('remove').append( + $('<img/>').attr({ + alt: t('core', 'Delete'), + title: t('core', 'Delete'), + src: OC.imagePath('core', 'actions/delete.svg') + }).addClass('action') + )); + + $('#sslCertificate tbody').append(row); + $('#sslCertificate').show(); + }, + fail: function () { + OC.Notification.showTemporary( + t('settings', 'An error occurred. Please upload an ASCII-encoded PEM certificate.')); + } + }); + + if ($('#sslCertificate > tbody > tr').length === 0) { + $('#sslCertificate').hide(); + } +}); diff --git a/settings/js/personal.js b/settings/js/personal.js index da74f28d70c..3e1a0d7497b 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -339,73 +339,6 @@ $(document).ready(function () { } }); - $('#sslCertificate').on('click', 'td.remove > img', function () { - var row = $(this).parent().parent(); - $.ajax(OC.generateUrl('settings/personal/certificate/{certificate}', {certificate: row.data('name')}), { - type: 'DELETE' - }); - row.remove(); - - if ($('#sslCertificate > tbody > tr').length === 0) { - $('#sslCertificate').hide(); - } - return true; - }); - - $('#sslCertificate tr > td').tipsy({gravity: 'n', live: true}); - - $('#rootcert_import').fileupload({ - submit: function(e, data) { - data.formData = _.extend(data.formData || {}, { - requesttoken: OC.requestToken - }); - }, - success: function (data) { - if (typeof data === 'string') { - data = $.parseJSON(data); - } else if (data && data.length) { - // fetch response from iframe - data = $.parseJSON(data[0].body.innerText); - } - if (!data || typeof(data) === 'string') { - // IE8 iframe workaround comes here instead of fail() - OC.Notification.showTemporary( - t('settings', 'An error occurred. Please upload an ASCII-encoded PEM certificate.')); - return; - } - var issueDate = new Date(data.validFrom * 1000); - var expireDate = new Date(data.validTill * 1000); - var now = new Date(); - var isExpired = !(issueDate <= now && now <= expireDate); - - var row = $('<tr/>'); - row.data('name', data.name); - row.addClass(isExpired? 'expired': 'valid'); - row.append($('<td/>').attr('title', data.organization).text(data.commonName)); - row.append($('<td/>').attr('title', t('core,', 'Valid until {date}', {date: data.validTillString})) - .text(data.validTillString)); - row.append($('<td/>').attr('title', data.issuerOrganization).text(data.issuer)); - row.append($('<td/>').addClass('remove').append( - $('<img/>').attr({ - alt: t('core', 'Delete'), - title: t('core', 'Delete'), - src: OC.imagePath('core', 'actions/delete.svg') - }).addClass('action') - )); - - $('#sslCertificate tbody').append(row); - $('#sslCertificate').show(); - }, - fail: function () { - OC.Notification.showTemporary( - t('settings', 'An error occurred. Please upload an ASCII-encoded PEM certificate.')); - } - }); - - if ($('#sslCertificate > tbody > tr').length === 0) { - $('#sslCertificate').hide(); - } - // Load the big avatar if (oc_config.enable_avatars) { $('#avatar .avatardiv').avatar(OC.currentUser, 145); |