re-add some of the js/ajax actions
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
76
templates/Froxlor/src/js/components/customer.js
Normal file
76
templates/Froxlor/src/js/components/customer.js
Normal file
@@ -0,0 +1,76 @@
|
||||
$(document).ready(function () {
|
||||
|
||||
// Make inputs with enabled unlimited checked disabled
|
||||
$("input[name$='_ul']").each(function () {
|
||||
var fieldname = $(this).attr("name").substring(0, $(this).attr("name").length - 3);
|
||||
$("input[name='" + fieldname + "']").prop({
|
||||
readonly: $(this).is(":checked"),
|
||||
required: !$(this).is(":checked")
|
||||
});
|
||||
});
|
||||
// change state when unlimited checkboxes are clicked
|
||||
$("input[name$='_ul']").change(function () {
|
||||
var fieldname = $(this).attr("name").substring(0, $(this).attr("name").length - 3);
|
||||
$("input[name='" + fieldname + "']").prop({
|
||||
readonly: $(this).is(":checked"),
|
||||
required: !$(this).is(":checked")
|
||||
});
|
||||
if (!$(this).is(":checked")) {
|
||||
$("input[name='" + fieldname + "']").focus()
|
||||
}
|
||||
});
|
||||
|
||||
// set values from hosting plan when adding/editing a customer according to the plan's values
|
||||
$('#use_plan').change(function () {
|
||||
var pid = $(this).val();
|
||||
if (pid > 0) {
|
||||
$.ajax({
|
||||
url: "admin_plans.php?s=" + window.$session + "&page=overview&action=jqGetPlanValues",
|
||||
type: "POST",
|
||||
data: {
|
||||
planid: pid
|
||||
},
|
||||
dataType: "json",
|
||||
success: function (json) {
|
||||
for (var i in json) {
|
||||
if (i == 'email_imap' || i == 'email_pop3' || i == 'perlenabled' || i == 'phpenabled' || i == 'dnsenabled' || i == 'logviewenabled') {
|
||||
/** handle checkboxes **/
|
||||
if (json[i] == 1) {
|
||||
$("input[name='" + i + "']").prop('checked', true);
|
||||
} else {
|
||||
$("input[name='" + i + "']").prop('checked', false);
|
||||
}
|
||||
} else if (i == 'allowed_phpconfigs') {
|
||||
/** handle array of values **/
|
||||
$("input[name='allowed_phpconfigs[]']").each(function (index) {
|
||||
$(this).prop('checked', false);
|
||||
for (var j in json[i]) {
|
||||
if ($(this).val() == json[i][j]) {
|
||||
$(this).prop('checked', true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (json[i] == -1) {
|
||||
/** handle unlimited checkboxes **/
|
||||
$("input[name='" + i + "_ul']").attr('checked', 'checked');
|
||||
$("input[name='" + i + "']").prop({
|
||||
readonly: true
|
||||
});
|
||||
} else {
|
||||
/** handle normal value **/
|
||||
$("input[name='" + i + "']").val(json[i]);
|
||||
$("input[name='" + i + "']").prop({
|
||||
readonly: false
|
||||
});
|
||||
$("input[name='" + i + "_ul']").prop('checked', false);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (a, b) {
|
||||
console.log(a, b);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
32
templates/Froxlor/src/js/components/domains.js
Normal file
32
templates/Froxlor/src/js/components/domains.js
Normal file
@@ -0,0 +1,32 @@
|
||||
$(document).ready(function () {
|
||||
|
||||
// disable unusable php-configuration by customer settings
|
||||
$('#customerid').change(function () {
|
||||
var cid = $(this).val();
|
||||
$.ajax({
|
||||
url: "admin_domains.php?s=" + window.$session + "&page=domains&action=jqGetCustomerPHPConfigs",
|
||||
type: "POST",
|
||||
data: {
|
||||
customerid: cid
|
||||
},
|
||||
dataType: "json",
|
||||
success: function (json) {
|
||||
if (json.length > 0) {
|
||||
$('#phpsettingid option').each(function () {
|
||||
var pid = $(this).val();
|
||||
$(this).attr("disabled", "disabled");
|
||||
for (var i in json) {
|
||||
if (pid == json[i]) {
|
||||
$(this).removeAttr("disabled");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (a, b) {
|
||||
console.log(a, b);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
29
templates/Froxlor/src/js/components/ipsandports.js
Normal file
29
templates/Froxlor/src/js/components/ipsandports.js
Normal file
@@ -0,0 +1,29 @@
|
||||
$(document).ready(function () {
|
||||
|
||||
// check for internal ip and output a notice if private-range ip is given
|
||||
$('#ip').change(function () {
|
||||
var ipval = $(this).val();
|
||||
if (ipval.length > 0) {
|
||||
$('#ipnote').remove();
|
||||
$('#ip').removeClass('is-invalid');
|
||||
$.ajax({
|
||||
url: "admin_ipsandports.php?s=" + window.$session + "&page=overview&action=jqCheckIP",
|
||||
type: "POST",
|
||||
data: {
|
||||
ip: ipval
|
||||
},
|
||||
dataType: "json",
|
||||
success: function (json) {
|
||||
if (json != 0) {
|
||||
$('#ip').addClass('is-invalid');
|
||||
$('#ip').parent().append(json);
|
||||
}
|
||||
},
|
||||
error: function (a, b) {
|
||||
console.log(a, b);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
@@ -13,3 +13,6 @@ $(document).ready(function () {
|
||||
require('./components/search')
|
||||
require('./components/newsfeed')
|
||||
require('./components/updatecheck')
|
||||
require('./components/customer')
|
||||
require('./components/ipsandports')
|
||||
require('./components/domains')
|
||||
|
||||
Reference in New Issue
Block a user