fix js integrations

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2023-10-18 14:25:02 +02:00
parent 462a798cb6
commit a11d26522a
23 changed files with 596 additions and 583 deletions

View File

@@ -356,23 +356,6 @@ CREATE TABLE `panel_htpasswds` (
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
DROP TABLE IF EXISTS `panel_sessions`;
CREATE TABLE `panel_sessions` (
`hash` varchar(32) NOT NULL default '',
`userid` int(11) unsigned NOT NULL default '0',
`ipaddress` varchar(255) NOT NULL default '',
`useragent` varchar(255) NOT NULL default '',
`lastactivity` int(11) unsigned NOT NULL default '0',
`lastpaging` varchar(255) NOT NULL default '',
`formtoken` char(32) NOT NULL default '',
`language` varchar(64) NOT NULL default '',
`adminsession` tinyint(1) unsigned NOT NULL default '0',
`theme` varchar(255) NOT NULL default '',
PRIMARY KEY (`hash`),
KEY `userid` (`userid`)
) ENGINE=HEAP;
DROP TABLE IF EXISTS `panel_settings`; DROP TABLE IF EXISTS `panel_settings`;
CREATE TABLE `panel_settings` ( CREATE TABLE `panel_settings` (
`settingid` int(11) unsigned NOT NULL auto_increment, `settingid` int(11) unsigned NOT NULL auto_increment,

View File

@@ -1,33 +1,14 @@
import '@fortawesome/fontawesome-free'; import '@fortawesome/fontawesome-free';
import './bootstrap';
import jQuery from 'jquery';
window.$ = jQuery;
import 'jquery-validation';
import 'bootstrap';
import 'chart.js/auto';
// Axios
import axios from 'axios';
window.axios = axios;
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
// Vue // Vue
import { createApp } from 'vue'; import {createApp} from 'vue';
const app = createApp({}); const app = createApp({});
// import ExampleComponent from './components/ExampleComponent.vue';
// app.component('example-component', ExampleComponent);
//
// or
//
// Object.entries(import.meta.glob('./**/*.vue', { eager: true })).forEach(([path, definition]) => {
// app.component(path.split('/').pop().replace(/\.\w+$/, ''), definition.default);
// });
app.mount('#app');
// Load jquery components // Load jquery components
Object.entries(import.meta.glob('./jquery/*.js', { eager: true })).forEach(([path, definition]) => { Object.entries(import.meta.glob('./jquery/*.js', {eager: true})).forEach(([path, definition]) => {
definition.default(); definition.default();
}); });
app.mount('#app');

View File

@@ -0,0 +1,20 @@
import _ from 'lodash';
window._ = _;
// jQuery
import jQuery from 'jquery';
window.$ = jQuery;
import 'jquery-validation';
// Bootstrap
import * as bootstrap from 'bootstrap';
window.bootstrap = bootstrap;
// ChartJS
import Chart from 'chart.js/auto';
window.Chart = Chart;
// Axios
import axios from 'axios';
window.axios = axios;
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

View File

@@ -1,60 +1,68 @@
export default function() { export default function () {
$(function () {
var timer, delay = 500; var timer, delay = 500;
$('div[data-action="apikeys"] #allowed_from').on('keyup change', function () { $('div[data-action="apikeys"] #allowed_from').on('keyup change', function () {
var _this = $(this); var _this = $(this);
clearTimeout(timer); clearTimeout(timer);
timer = setTimeout(function () { timer = setTimeout(function () {
var akid = _this.closest('div[data-action="apikeys"]').data('entry'); var akid = _this.closest('div[data-action="apikeys"]').data('entry');
$.ajax({ $.ajax({
url: "lib/ajax.php?action=editapikey", url: "lib/ajax.php?action=editapikey",
type: "POST", type: "POST",
dataType: "json", dataType: "json",
data: { id: akid, allowed_from: _this.val(), valid_until: $('div[data-entry="' + akid + '"] #valid_until').val() }, data: {
success: function (data) { id: akid,
if (data.message) { allowed_from: _this.val(),
valid_until: $('div[data-entry="' + akid + '"] #valid_until').val()
},
success: function (data) {
if (data.message) {
_this.removeClass('is-valid');
_this.addClass('is-invalid');
} else {
_this.removeClass('is-invalid');
_this.addClass('is-valid');
_this.val(data.allowed_from);
}
},
error: function (request, status, error) {
_this.removeClass('is-valid'); _this.removeClass('is-valid');
_this.addClass('is-invalid'); _this.addClass('is-invalid');
} else {
_this.removeClass('is-invalid');
_this.addClass('is-valid');
_this.val(data.allowed_from);
} }
}, });
error: function (request, status, error) { }, delay);
_this.removeClass('is-valid'); });
_this.addClass('is-invalid');
}
});
}, delay);
});
$('div[data-action="apikeys"] #valid_until').on('keyup change', function () { $('div[data-action="apikeys"] #valid_until').on('keyup change', function () {
var _this = $(this); var _this = $(this);
clearTimeout(timer); clearTimeout(timer);
timer = setTimeout(function () { timer = setTimeout(function () {
var akid = _this.closest('div[data-action="apikeys"]').data('entry'); var akid = _this.closest('div[data-action="apikeys"]').data('entry');
$.ajax({ $.ajax({
url: "lib/ajax.php?action=editapikey", url: "lib/ajax.php?action=editapikey",
type: "POST", type: "POST",
dataType: "json", dataType: "json",
data: { id: akid, valid_until: _this.val(), allowed_from: $('div[data-entry="' + akid + '"] #allowed_from').val() }, data: {
success: function (data) { id: akid,
if (data.message) { valid_until: _this.val(),
allowed_from: $('div[data-entry="' + akid + '"] #allowed_from').val()
},
success: function (data) {
if (data.message) {
_this.removeClass('is-valid');
_this.addClass('is-invalid');
} else {
_this.removeClass('is-invalid');
_this.addClass('is-valid');
_this.val(data.valid_until);
}
},
error: function (request, status, error) {
_this.removeClass('is-valid'); _this.removeClass('is-valid');
_this.addClass('is-invalid'); _this.addClass('is-invalid');
} else {
_this.removeClass('is-invalid');
_this.addClass('is-valid');
_this.val(data.valid_until);
} }
}, });
error: function (request, status, error) { }, delay);
_this.removeClass('is-valid'); });
_this.addClass('is-invalid');
}
});
}, delay);
}); });
} }

View File

@@ -1,52 +1,54 @@
export default function() { export default function () {
/* $(function () {
* config files - select all recommended /*
*/ * config files - select all recommended
$('#selectRecommendedConfig').on('click', function () { */
$('input[data-recommended]').each(function () { $('#selectRecommendedConfig').on('click', function () {
if ($(this).data('recommended') == 1) { $('input[data-recommended]').each(function () {
$(this).prop('checked', true); if ($(this).data('recommended') == 1) {
} else { $(this).prop('checked', true);
$(this).prop('checked', false); } else {
} $(this).prop('checked', false);
}) }
}); })
/*
* export/download JSON file (e.g. for usage with config-services)
*/
$('#downloadSelectionAsJson').on('click', function () {
var formData = $(this).closest('form').serialize();
window.location = "lib/ajax.php?action=getConfigJsonExport&" + formData;
});
/*
* open modal window to show selected config-commands/files
* for selected daemon
*/
$('.show-config').on('click', function () {
var distro = $(this).data('dist');
var section = $(this).data('section');
var daemon = $(this).data('daemon');
$.ajax({
url: "lib/ajax.php?action=getConfigDetails",
type: "POST",
dataType: "json",
data: { distro: distro, section: section, daemon: daemon },
success: function (data) {
$('#configTplShowLabel').html(data.title);
$('#configTplShow .modal-body').html(data.content);
var myModal = new bootstrap.Modal(document.getElementById('configTplShow'));
myModal.show();
},
error: function (request, status, error) {
$('#configTplShowLabel').html('Error');
$('#configTplShow .modal-body').html('<div class="alert alert-danger" role="alert">' + request.responseJSON.message + '</div>');
var myModal = new bootstrap.Modal(document.getElementById('configTplShow'));
myModal.show();
}
}); });
/*
* export/download JSON file (e.g. for usage with config-services)
*/
$('#downloadSelectionAsJson').on('click', function () {
var formData = $(this).closest('form').serialize();
window.location = "lib/ajax.php?action=getConfigJsonExport&" + formData;
});
/*
* open modal window to show selected config-commands/files
* for selected daemon
*/
$('.show-config').on('click', function () {
const distro = $(this).data('dist');
const section = $(this).data('section');
const daemon = $(this).data('daemon');
$.ajax({
url: "lib/ajax.php?action=getConfigDetails",
type: "POST",
dataType: "json",
data: {distro: distro, section: section, daemon: daemon},
success: function (data) {
$('#configTplShowLabel').html(data.title);
$('#configTplShow .modal-body').html(data.content);
const myModal = new bootstrap.Modal(document.getElementById('configTplShow'));
myModal.show();
},
error: function (request, status, error) {
$('#configTplShowLabel').html('Error');
$('#configTplShow .modal-body').html('<div class="alert alert-danger" role="alert">' + request.responseJSON.message + '</div>');
const myModal = new bootstrap.Modal(document.getElementById('configTplShow'));
myModal.show();
}
});
});
}); });
} }

View File

@@ -1,76 +1,77 @@
export default function() { export default function () {
$(function () {
// Make inputs with enabled unlimited checked disabled // Make inputs with enabled unlimited checked disabled
$("input[name$='_ul']").each(function () { $("input[name$='_ul']").each(function () {
var fieldname = $(this).attr("name").substring(0, $(this).attr("name").length - 3); var fieldname = $(this).attr("name").substring(0, $(this).attr("name").length - 3);
$("input[name='" + fieldname + "']").prop({ $("input[name='" + fieldname + "']").prop({
readonly: $(this).is(":checked"), readonly: $(this).is(":checked"),
required: !$(this).is(":checked") required: !$(this).is(":checked")
});
});
// change state when unlimited checkboxes are clicked
$("input[name$='_ul']").on('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').on('change', function () {
var pid = $(this).val();
if (pid > 0) {
$.ajax({
url: "admin_plans.php?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);
}
}); });
} });
// change state when unlimited checkboxes are clicked
$("input[name$='_ul']").on('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').on('change', function () {
var pid = $(this).val();
if (pid > 0) {
$.ajax({
url: "admin_plans.php?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);
}
});
}
});
}); });
} }

View File

@@ -1,19 +1,20 @@
export default function() { export default function () {
$(function () {
// Display helptext to content box according to dns-record type selected // Display helptext to content box according to dns-record type selected
$("select[name='dns_type']").on('change', function () { $("select[name='dns_type']").on('change', function () {
var selVal = $(this).val(); var selVal = $(this).val();
$.ajax({ $.ajax({
url: "lib/ajax.php?action=loadLanguageString", url: "lib/ajax.php?action=loadLanguageString",
type: "POST", type: "POST",
dataType: "json", dataType: "json",
data: { langid: 'dnseditor.notes.' + selVal }, data: {langid: 'dnseditor.notes.' + selVal},
success: function (data) { success: function (data) {
$("#dns_content").next().html(data); $("#dns_content").next().html(data);
}, },
error: function (request, status, error) { error: function (request, status, error) {
console.log(request, status, error) console.log(request, status, error)
} }
});
}); });
}); });
} }

View File

@@ -1,54 +1,29 @@
export default function() { export default function () {
/* $(function () {
* domains /*
*/ * domains
// disable unusable php-configuration by customer settings */
$('#customerid').on('change', function () { // disable unusable php-configuration by customer settings
var cid = $(this).val(); $('#customerid').on('change', function () {
$.ajax({ var cid = $(this).val();
url: "admin_domains.php?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);
}
});
});
// show warning if speciallogfile option is toggled
if ($('input[name=speciallogverified]')) {
$('input[name=speciallogfile]').on('click', function () {
$('#speciallogfilenote').remove();
$('#speciallogfile').removeClass('is-invalid');
$('#speciallogverified').val(0);
$.ajax({ $.ajax({
url: window.location.pathname.substring(1) + "?page=overview&action=jqSpeciallogfileNote", url: "admin_domains.php?page=domains&action=jqGetCustomerPHPConfigs",
type: "POST", type: "POST",
data: { data: {
id: $('input[name=id]').val(), newval: +$('#speciallogfile').is(':checked') customerid: cid
}, },
dataType: "json", dataType: "json",
success: function (json) { success: function (json) {
if (json.changed) { if (json.length > 0) {
$('#speciallogfile').addClass('is-invalid'); $('#phpsettingid option').each(function () {
$('#speciallogfile').parent().append(json.info); var pid = $(this).val();
$('#speciallogverified').val(1); $(this).attr("disabled", "disabled");
for (var i in json) {
if (pid == json[i]) {
$(this).removeAttr("disabled");
}
}
});
} }
}, },
error: function (a, b) { error: function (a, b) {
@@ -56,54 +31,81 @@ export default function() {
} }
}); });
}); });
}
/** // show warning if speciallogfile option is toggled
* email only domain - hide unnecessary/unused sections if ($('input[name=speciallogverified]')) {
*/ $('input[name=speciallogfile]').on('click', function () {
if ($('#id') && $('#email_only').is(':checked')) { $('#speciallogfilenote').remove();
$('#section_b').hide(); $('#speciallogfile').removeClass('is-invalid');
$('#section_bssl').hide(); $('#speciallogverified').val(0);
$('#section_c').hide(); $.ajax({
$('#section_d').hide(); url: window.location.pathname.substring(1) + "?page=overview&action=jqSpeciallogfileNote",
} type: "POST",
data: {
id: $('input[name=id]').val(), newval: +$('#speciallogfile').is(':checked')
},
dataType: "json",
success: function (json) {
if (json.changed) {
$('#speciallogfile').addClass('is-invalid');
$('#speciallogfile').parent().append(json.info);
$('#speciallogverified').val(1);
}
},
error: function (a, b) {
console.log(a, b);
}
});
});
}
/** /**
* toggle show/hide of sections in case of email only flag * email only domain - hide unnecessary/unused sections
*/ */
$('#email_only').on('click', function () { if ($('#id') && $('#email_only').is(':checked')) {
if ($(this).is(':checked')) {
// hide unnecessary sections
$('#section_b').hide(); $('#section_b').hide();
$('#section_bssl').hide(); $('#section_bssl').hide();
$('#section_c').hide(); $('#section_c').hide();
$('#section_d').hide(); $('#section_d').hide();
} else {
// show sections
$('#section_b').show();
$('#section_bssl').show();
$('#section_c').show();
$('#section_d').show();
} }
})
/** /**
* ssl enabled domain - hide unnecessary/unused sections * toggle show/hide of sections in case of email only flag
*/ */
if ($('#id') && !$('#sslenabled').is(':checked')) { $('#email_only').on('click', function () {
$('#section_bssl>.formfields>.row').not(":first").addClass("d-none"); if ($(this).is(':checked')) {
} // hide unnecessary sections
$('#section_b').hide();
$('#section_bssl').hide();
$('#section_c').hide();
$('#section_d').hide();
} else {
// show sections
$('#section_b').show();
$('#section_bssl').show();
$('#section_c').show();
$('#section_d').show();
}
})
/** /**
* toggle show/hide of sections in case of ssl enabled flag * ssl enabled domain - hide unnecessary/unused sections
*/ */
$('#sslenabled').on('click', function () { if ($('#id') && !$('#sslenabled').is(':checked')) {
if ($(this).is(':checked')) {
// show sections
$('#section_bssl>.formfields>.row').removeClass("d-none");
} else {
// hide unnecessary sections
$('#section_bssl>.formfields>.row').not(":first").addClass("d-none"); $('#section_bssl>.formfields>.row').not(":first").addClass("d-none");
} }
})
/**
* toggle show/hide of sections in case of ssl enabled flag
*/
$('#sslenabled').on('click', function () {
if ($(this).is(':checked')) {
// show sections
$('#section_bssl>.formfields>.row').removeClass("d-none");
} else {
// hide unnecessary sections
$('#section_bssl>.formfields>.row').not(":first").addClass("d-none");
}
})
});
} }

View File

@@ -1,14 +1,20 @@
export default function() { export default function () {
/* $(function () {
* global /*
*/ * global
$('#historyback').on('click', function (e) { */
e.preventDefault(); $('#historyback').on('click', function (e) {
history.back(1); e.preventDefault();
}) history.back(1);
})
$('#copySysInfo').on('click', function (e) { $('#copySysInfo').on('click', function (e) {
e.preventDefault(); e.preventDefault();
navigator.clipboard.writeText($('#ccSysInfo').text().trim()); navigator.clipboard.writeText($('#ccSysInfo').text().trim());
}) })
$('[data-bs-toggle="popover"]').each(function () {
new bootstrap.Popover($(this));
})
});
} }

View File

@@ -1,62 +1,63 @@
export default function() { export default function () {
/* $(function () {
* switch between basic and advanced install mode /*
*/ * switch between basic and advanced installation mode
$('#switchInstallMode').on('click', function () { */
var checked = $(this).prop('checked'); $('#switchInstallMode').on('click', function () {
window.location = window.location.pathname + replaceQueryParam('extended', +checked, window.location.search); var checked = $(this).prop('checked');
}); window.location = window.location.pathname + replaceQueryParam('extended', +checked, window.location.search);
});
function replaceQueryParam(param, newval, search) { function replaceQueryParam(param, newval, search) {
var regex = new RegExp("([?;&])" + param + "[^&;]*[;&]?"); var regex = new RegExp("([?;&])" + param + "[^&;]*[;&]?");
if (search.match(regex)) { if (search.match(regex)) {
search = search.replace(regex, "$1").replace(/&$/, ''); search = search.replace(regex, "$1").replace(/&$/, '');
}
return search + '&' + param + '=' + newval;
} }
return search + '&' + param + '=' + newval;
}
function checkConfigState() { function checkConfigState() {
$.ajax({ $.ajax({
url: window.location.href, url: window.location.href,
type: "GET", type: "GET",
success: function (data, textStatus, request) { success: function (data, textStatus, request) {
if (request.status >= 300) { if (request.status >= 300) {
window.location = "http://" + srvName; window.location = "http://" + srvName;
} }
}, },
error: function (request, textStatus, errorThrown) { error: function (request, textStatus, errorThrown) {
// continue // continue
if (request.status >= 300) { if (request.status >= 300) {
window.location = "http://" + srvName; window.location = "http://" + srvName;
}
} }
});
}
var cTimer;
/**
* check manual-config switch
*/
$('#manual_config').on('click', function () {
clearInterval(cTimer);
var checked = $(this).prop('checked');
if (checked) {
// button zum login
$('#submitAuto').addClass('d-none');
$('#submitManual').removeClass('d-none');
} else {
cTimer = setInterval(checkConfigState, 1000);
// spinner fürs Warten
$('#submitAuto').removeClass('d-none');
$('#submitManual').addClass('d-none');
} }
}); });
}
var cTimer; if ($('#manual_config').length > 0) {
var srvName = $('#target_servername').val();
/** clearInterval(cTimer);
* check manual-config switch
*/
$('#manual_config').on('click', function () {
clearInterval(cTimer);
var checked = $(this).prop('checked');
if (checked) {
// button zum login
$('#submitAuto').addClass('d-none');
$('#submitManual').removeClass('d-none');
} else {
cTimer = setInterval(checkConfigState, 1000); cTimer = setInterval(checkConfigState, 1000);
// spinner fürs warten
$('#submitAuto').removeClass('d-none');
$('#submitManual').addClass('d-none');
} }
}); });
if ($('#manual_config').length > 0) {
var srvName = $('#target_servername').val();
clearInterval(cTimer);
cTimer = setInterval(checkConfigState, 1000);
}
} }

View File

@@ -1,30 +1,31 @@
export default function() { export default function () {
/* $(function () {
* ipsandports - check for internal ip and output a notice if private-range ip is given /*
*/ * ipsandports - check for internal ip and output a notice if private-range ip is given
$('#ip').on('change', function () { */
var ipval = $(this).val(); $('#ip').on('change', function () {
if (ipval.length > 0) { var ipval = $(this).val();
$('#ipnote').remove(); if (ipval.length > 0) {
$('#ip').removeClass('is-invalid'); $('#ipnote').remove();
$.ajax({ $('#ip').removeClass('is-invalid');
url: "admin_ipsandports.php?page=overview&action=jqCheckIP", $.ajax({
type: "POST", url: "admin_ipsandports.php?page=overview&action=jqCheckIP",
data: { type: "POST",
ip: ipval data: {
}, ip: ipval
dataType: "json", },
success: function (json) { dataType: "json",
if (json != 0) { success: function (json) {
$('#ip').addClass('is-invalid'); if (json != 0) {
$('#ip').parent().append(json); $('#ip').addClass('is-invalid');
$('#ip').parent().append(json);
}
},
error: function (a, b) {
console.log(a, b);
} }
}, });
error: function (a, b) { }
console.log(a, b); });
}
});
}
}); });
} }

View File

@@ -1,24 +1,26 @@
export default function() { export default function () {
/* $(function () {
* newsfeed /*
*/ * newsfeed
if (document.getElementById('newsfeed')) { */
let role = ""; if (document.getElementById('newsfeed')) {
let role = "";
if (typeof $("#newsfeed").data("role") !== "undefined") { if (typeof $("#newsfeed").data("role") !== "undefined") {
role = "&role=" + $("#newsfeed").data("role"); role = "&role=" + $("#newsfeed").data("role");
}
$.ajax({
url: "lib/ajax.php?action=newsfeed" + role + "&theme=" + window.$theme,
type: "GET",
success: function (data) {
$("#newsfeeditems").html(data);
},
error: function (request, status, error) {
console.log(request, status, error)
$("#newsfeeditems").html('<div class="list-group-item text-center"><span class="badge bg-warning" role="alert">Error loading newsfeed</span></div>');
} }
});
} $.ajax({
url: "lib/ajax.php?action=newsfeed" + role + "&theme=" + window.$theme,
type: "GET",
success: function (data) {
$("#newsfeeditems").html(data);
},
error: function (request, status, error) {
console.log(request, status, error)
$("#newsfeeditems").html('<div class="list-group-item text-center"><span class="badge bg-warning" role="alert">Error loading newsfeed</span></div>');
}
});
}
});
} }

View File

@@ -1,59 +1,61 @@
export default function() { export default function () {
/* $(function () {
* search /*
*/ * search
let search = $('#search') */
let search = $('#search')
search.on('submit', function (e) { search.on('submit', function (e) {
e.preventDefault(); e.preventDefault();
}); });
search.find('input').on('keyup', function () { search.find('input').on('keyup', function () {
let query = $(this).val(); let query = $(this).val();
let dropdown = $('#search .search-results'); let dropdown = $('#search .search-results');
// Hide search if query is empty // Hide search if query is empty
if (!query.length) { if (!query.length) {
dropdown.html('');
dropdown.parent().hide();
return;
}
// Show notification for short search query
if (query.length && query.length < 3) {
dropdown.html('<li class="list-group-item text-body-secondary py-1">Please enter more than 2 characters</li>');
dropdown.parent().show();
return;
}
// Search
$.ajax({
url: "lib/ajax.php?action=searchglobal&theme=" + window.$theme,
type: "POST",
data: {
searchtext: query
},
dataType: "json",
success: data => {
// Show notification if we got no results
if (Object.keys(data).length === 0) {
dropdown.html('<li class="list-group-item text-body-secondary py-1">Nothing found!</li>');
dropdown.parent().show();
return;
}
// Clear dropdown and show results
dropdown.html(''); dropdown.html('');
dropdown.parent().show(); dropdown.parent().hide();
Object.keys(data).forEach(key => { return;
dropdown.append('<li class="list-group-item text-body-secondary text-capitalize fw-bold py-1 border-bottom">' + key + '</li>');
data[key].forEach(item => {
dropdown.append('<li class="list-group-item mt-1"><a href="' + item.href + '" tabindex="2" class="text-decoration-none">' + item.title + '</a></li>');
});
});
},
error: function (a, b) {
console.log(a, b);
dropdown.html('<li class="list-group-item text-body-secondary py-1">Whoops we got some errors!</li>');
dropdown.parent().show();
} }
// Show notification for short search query
if (query.length && query.length < 3) {
dropdown.html('<li class="list-group-item text-body-secondary py-1">Please enter more than 2 characters</li>');
dropdown.parent().show();
return;
}
// Search
$.ajax({
url: "lib/ajax.php?action=searchglobal&theme=" + window.$theme,
type: "POST",
data: {
searchtext: query
},
dataType: "json",
success: data => {
// Show notification if we got no results
if (Object.keys(data).length === 0) {
dropdown.html('<li class="list-group-item text-body-secondary py-1">Nothing found!</li>');
dropdown.parent().show();
return;
}
// Clear dropdown and show results
dropdown.html('');
dropdown.parent().show();
Object.keys(data).forEach(key => {
dropdown.append('<li class="list-group-item text-body-secondary text-capitalize fw-bold py-1 border-bottom">' + key + '</li>');
data[key].forEach(item => {
dropdown.append('<li class="list-group-item mt-1"><a href="' + item.href + '" tabindex="2" class="text-decoration-none">' + item.title + '</a></li>');
});
});
},
error: function (a, b) {
console.log(a, b);
dropdown.html('<li class="list-group-item text-body-secondary py-1">Whoops we got some errors!</li>');
dropdown.parent().show();
}
});
}); });
}); });
} }

View File

@@ -1,44 +1,46 @@
export default function() { export default function () {
/* $(function () {
* table columns - manage columns modal /*
*/ * table columns - manage columns modal
$('.manageColumnsModal form').on('submit', function (event) { */
$.ajax({ $('.manageColumnsModal form').on('submit', function (event) {
url: 'lib/ajax.php?action=updatetablelisting&listing=' + $(this).data('listing') + '&theme=' + window.$theme, $.ajax({
type: 'POST', url: 'lib/ajax.php?action=updatetablelisting&listing=' + $(this).data('listing') + '&theme=' + window.$theme,
dataType: 'json', type: 'POST',
data: $(this).serialize(), dataType: 'json',
success: function () { data: $(this).serialize(),
window.location.href = ''; success: function () {
}, window.location.href = '';
error: function (request) { },
alert(request.responseJSON.message); error: function (request) {
} alert(request.responseJSON.message);
}
});
event.preventDefault();
}); });
event.preventDefault();
});
$('.manageColumnsModal form button[data-action="reset"]').on('click', function () { $('.manageColumnsModal form button[data-action="reset"]').on('click', function () {
var form = $(this).parents('form:first'); var form = $(this).parents('form:first');
$.ajax({ $.ajax({
url: 'lib/ajax.php?action=resettablelisting&listing=' + form.data('listing') + '&theme=' + window.$theme, url: 'lib/ajax.php?action=resettablelisting&listing=' + form.data('listing') + '&theme=' + window.$theme,
type: 'POST', type: 'POST',
dataType: 'json', dataType: 'json',
data: {}, data: {},
success: function () { success: function () {
window.location.href = ''; window.location.href = '';
}, },
error: function (request) { error: function (request) {
alert(request.responseJSON.message); alert(request.responseJSON.message);
} }
});
}); });
});
$('.manageColumnsModal form button[data-action="select-all"]').on('click', function () { $('.manageColumnsModal form button[data-action="select-all"]').on('click', function () {
$(this).parents('form:first').find('input:checkbox').prop('checked', true); $(this).parents('form:first').find('input:checkbox').prop('checked', true);
}); });
$('.manageColumnsModal form button[data-action="unselect-all"]').on('click', function () { $('.manageColumnsModal form button[data-action="unselect-all"]').on('click', function () {
$(this).parents('form:first').find('input:checkbox').prop('checked', false); $(this).parents('form:first').find('input:checkbox').prop('checked', false);
});
}); });
} }

View File

@@ -1,10 +1,12 @@
export default function() { export default function () {
/* $(function () {
* traffic - display helptext to content box according to dns-record type selected /*
*/ * traffic - display helptext to content box according to dns-record type selected
$("select[name='range']").on('change', function () { */
var selVal = $(this).val(); $("select[name='range']").on('change', function () {
var baseRef = $(this).data('baseref'); var selVal = $(this).val();
window.location.href = baseRef + '?range=' + selVal; var baseRef = $(this).data('baseref');
window.location.href = baseRef + '?range=' + selVal;
});
}); });
} }

View File

@@ -1,21 +1,23 @@
export default function() { export default function () {
/* $(function () {
* updatecheck /*
*/ * updatecheck
if (document.getElementById('updatecheck')) { */
$.ajax({ if (document.getElementById('updatecheck')) {
url: "lib/ajax.php?action=updatecheck&theme=" + window.$theme, $.ajax({
type: "GET", url: "lib/ajax.php?action=updatecheck&theme=" + window.$theme,
success: function (data) { type: "GET",
$("#updatecheck").html(data); success: function (data) {
new bootstrap.Popover(document.getElementById('ucheck')); $("#updatecheck").html(data);
}, new bootstrap.Popover(document.getElementById('ucheck'));
error: function (request, status, error) { },
console.log(request, status, error) error: function (request, status, error) {
let message = 'Can\'t check version'; console.log(request, status, error)
$("#updatecheck").html('<span id="ucheck" class="text-decoration-none badge bg-warning mt-2 me-2" data-bs-toggle="tooltip" data-bs-placement="left" title="' + message + '"><i class="fa-solid fa-exclamation-triangle"></i> <span class="d-md-none d-xl-inline">' + message + '</span></span>'); let message = 'Can\'t check version';
new bootstrap.Tooltip(document.getElementById('ucheck')); $("#updatecheck").html('<span id="ucheck" class="text-decoration-none badge bg-warning mt-2 me-2" data-bs-toggle="tooltip" data-bs-placement="left" title="' + message + '"><i class="fa-solid fa-exclamation-triangle"></i> <span class="d-md-none d-xl-inline">' + message + '</span></span>');
} new bootstrap.Tooltip(document.getElementById('ucheck'));
}); }
} });
}
});
} }

View File

@@ -1,40 +1,42 @@
export default function() { export default function () {
/* $(function () {
* validation /*
*/ * validation
$('#customer_add,#customer_edit').each(function () { */
$(this).validate({ $('#customer_add,#customer_edit').each(function () {
rules: { $(this).validate({
'name': { rules: {
required: function () { 'name': {
return $('#company').val().length === 0 || $('#firstname').val().length > 0; required: function () {
return $('#company').val().length === 0 || $('#firstname').val().length > 0;
}
},
'firstname': {
required: function () {
return $('#company').val().length === 0 || $('#name').val().length > 0;
}
},
'company': {
required: function () {
return $('#name').val().length === 0
&& $('#firstname').val().length === 0;
}
} }
}, },
'firstname': { });
required: function () {
return $('#company').val().length === 0 || $('#name').val().length > 0;
}
},
'company': {
required: function () {
return $('#name').val().length === 0
&& $('#firstname').val().length === 0;
}
}
},
}); });
}); $('#domain_add,#domain_edit').each(function () {
$('#domain_add,#domain_edit').each(function () { $(this).validate({
$(this).validate({ rules: {
rules: { 'ipandport[]': {
'ipandport[]': { required: true,
required: true, minlength: 1
minlength: 1 }
},
errorPlacement: function (error, element) {
$(error).prependTo($(element).parent().parent());
} }
}, });
errorPlacement: function(error, element) {
$(error).prependTo($(element).parent().parent());
}
}); });
}); });
} }

View File

@@ -1,2 +0,0 @@
// Heading
$heading-border-color-dark: rgba(0,0,0,0.15);

View File

@@ -82,6 +82,7 @@ $card-border-width: 0;
$heading-bg: $navbar-bg; $heading-bg: $navbar-bg;
$heading-color: $body-color; $heading-color: $body-color;
$heading-border-color: #dee2e6; $heading-border-color: #dee2e6;
$heading-border-color-dark: rgba(0,0,0,0.15);
// Search // Search
$search-bg: $navbar-bg; $search-bg: $navbar-bg;

View File

@@ -2,7 +2,6 @@
// Bootstrap // Bootstrap
@import "variables"; @import "variables";
@import "variables-dark";
@import "bootstrap/scss/bootstrap"; @import "bootstrap/scss/bootstrap";
// Theme // Theme

View File

@@ -51,6 +51,6 @@
{# add translation for custom validations #} {# add translation for custom validations #}
{% if form_data.id is defined and form_data.id in ['customer_add', 'customer_edit', 'domain_add', 'domain_edit'] %} {% if form_data.id is defined and form_data.id in ['customer_add', 'customer_edit', 'domain_add', 'domain_edit'] %}
<script>$(function() { $.extend($.validator.messages, {required: "{{ lng('error.requiredfield') }}"}) });</script> <script type="module">$(function() { $.extend($.validator.messages, {required: "{{ lng('error.requiredfield') }}"}) });</script>
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}

View File

@@ -106,7 +106,7 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
<script> <script type="module">
const labelsS = ['{{ lng('traffic.http') }}', '{{ lng('traffic.ftp') }}', '{{ lng('traffic.mail') }}']; const labelsS = ['{{ lng('traffic.http') }}', '{{ lng('traffic.ftp') }}', '{{ lng('traffic.mail') }}'];
const dataS = { const dataS = {

View File

@@ -5,9 +5,6 @@ import { viteRequire } from 'vite-require'
export default defineConfig({ export default defineConfig({
build: { build: {
rollupOptions: {
external: ['extras/install'],
},
chunkSizeWarningLimit: 1000, chunkSizeWarningLimit: 1000,
}, },
plugins: [ plugins: [