[Web] add manage identity provider

This commit is contained in:
FreddleSpl0it
2023-03-14 14:10:46 +01:00
parent df129bb488
commit 8324484a27
17 changed files with 366 additions and 123 deletions

View File

@@ -749,4 +749,38 @@ jQuery(function($){
$('#add_f2b_regex_row').click(function() {
add_table_row($('#f2b_regex_table'), "f2b_regex");
});
// IAM test connection
$('#iam_test_connection').click(async function(e){
e.preventDefault();
var res = await fetch("/api/v1/get/status/identity-provider", { method:'GET', cache:'no-cache' });
res = await res.json();
console.log(res);
if (res.type === 'success'){
return mailcow_alert_box(lang_success.iam_test_connection, 'success');
}
return mailcow_alert_box(lang_danger.iam_test_connection, 'danger');
});
$('#iam_rolemap_add').click(async function(e){
e.preventDefault();
var parent = $(this).parent().parent();
$(parent).children().last().clone().appendTo(parent);
var newChild = $(parent).children().last();
$(newChild).find('input').val('');
$(newChild).find('.dropdown-toggle').remove();
$(newChild).find('.dropdown-menu').remove();
$(newChild).find('.bs-title-option').remove();
$(newChild).find('select').selectpicker('destroy');
$(newChild).find('select').selectpicker();
$('.iam_rolemap_del').off('click');
$('.iam_rolemap_del').click(async function(e){
e.preventDefault();
$(this).parent().remove();
});
});
$('.iam_rolemap_del').click(async function(e){
e.preventDefault();
$(this).parent().remove();
});
});

View File

@@ -162,6 +162,17 @@ $(document).ready(function() {
}
});
});
// @selecting identity provider mbox_add_modal
$('#mbox_add_iam').on('change', function(){
// toggle password fields
if (this.value === 'mailcow'){
$('#mbox_add_pwds').removeClass('d-none');
$('#mbox_add_pwds').find('.form-control').prop('required', true);
} else {
$('#mbox_add_pwds').addClass('d-none');
$('#mbox_add_pwds').find('.form-control').prop('required', false);
}
});
// Sieve data modal
$('#sieveDataModal').on('show.bs.modal', function(e) {
var sieveScript = $(e.relatedTarget).data('sieve-script');
@@ -269,6 +280,15 @@ $(document).ready(function() {
}
function setMailboxTemplateData(template){
$("#addInputQuota").val(template.quota / 1048576);
$('#mbox_add_iam').selectpicker('val', template.authsource);
// toggle password fields
if (template.authsource === 'mailcow'){
$('#mbox_add_pwds').removeClass('d-none');
$('#mbox_add_pwds').find('.form-control').prop('required', true);
} else {
$('#mbox_add_pwds').addClass('d-none');
$('#mbox_add_pwds').find('.form-control').prop('required', false);
}
if (template.quarantine_notification === "never"){
$('#quarantine_notification_never').prop('checked', true);
@@ -1009,7 +1029,16 @@ jQuery(function($){
title: lang.domain,
data: 'domain',
defaultContent: '',
className: 'none'
className: 'none',
},
{
title: lang.iam,
data: 'authsource',
defaultContent: '',
className: 'none',
render: function (data, type) {
return '<span class="badge bg-primary">' + data + '<i class="ms-2 bi bi-person-circle"></i></i></span>';
}
},
{
title: lang.tls_enforce_in,
@@ -1240,6 +1269,15 @@ jQuery(function($){
data: 'attributes.quota',
defaultContent: '',
},
{
title: lang.iam,
data: 'attributes.authsource',
defaultContent: '',
render: function (data, type) {
data = data ? '<span class="badge bg-primary">' + data + '<i class="ms-2 bi bi-person-circle"></i></i></span>' : '<i class="bi bi-x-lg"></i>';
return data;
}
},
{
title: lang.tls_enforce_in,
data: 'attributes.tls_enforce_in',