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
No known key found for this signature in database
GPG Key ID: C121F97338D7A352
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;
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`;
CREATE TABLE `panel_settings` (
`settingid` int(11) unsigned NOT NULL auto_increment,

View File

@ -1,33 +1,14 @@
import '@fortawesome/fontawesome-free';
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';
import './bootstrap';
// Vue
import { createApp } from 'vue';
import {createApp} from 'vue';
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
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();
});
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() {
var timer, delay = 500;
$('div[data-action="apikeys"] #allowed_from').on('keyup change', function () {
var _this = $(this);
clearTimeout(timer);
timer = setTimeout(function () {
var akid = _this.closest('div[data-action="apikeys"]').data('entry');
$.ajax({
url: "lib/ajax.php?action=editapikey",
type: "POST",
dataType: "json",
data: { id: akid, allowed_from: _this.val(), valid_until: $('div[data-entry="' + akid + '"] #valid_until').val() },
success: function (data) {
if (data.message) {
export default function () {
$(function () {
var timer, delay = 500;
$('div[data-action="apikeys"] #allowed_from').on('keyup change', function () {
var _this = $(this);
clearTimeout(timer);
timer = setTimeout(function () {
var akid = _this.closest('div[data-action="apikeys"]').data('entry');
$.ajax({
url: "lib/ajax.php?action=editapikey",
type: "POST",
dataType: "json",
data: {
id: akid,
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.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.addClass('is-invalid');
}
});
}, delay);
});
});
}, delay);
});
$('div[data-action="apikeys"] #valid_until').on('keyup change', function () {
var _this = $(this);
clearTimeout(timer);
timer = setTimeout(function () {
var akid = _this.closest('div[data-action="apikeys"]').data('entry');
$.ajax({
url: "lib/ajax.php?action=editapikey",
type: "POST",
dataType: "json",
data: { id: akid, valid_until: _this.val(), allowed_from: $('div[data-entry="' + akid + '"] #allowed_from').val() },
success: function (data) {
if (data.message) {
$('div[data-action="apikeys"] #valid_until').on('keyup change', function () {
var _this = $(this);
clearTimeout(timer);
timer = setTimeout(function () {
var akid = _this.closest('div[data-action="apikeys"]').data('entry');
$.ajax({
url: "lib/ajax.php?action=editapikey",
type: "POST",
dataType: "json",
data: {
id: akid,
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.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.addClass('is-invalid');
}
});
}, delay);
});
}, delay);
});
});
}

View File

@ -1,52 +1,54 @@
export default function() {
/*
* config files - select all recommended
*/
$('#selectRecommendedConfig').on('click', function () {
$('input[data-recommended]').each(function () {
if ($(this).data('recommended') == 1) {
$(this).prop('checked', true);
} 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 default function () {
$(function () {
/*
* config files - select all recommended
*/
$('#selectRecommendedConfig').on('click', function () {
$('input[data-recommended]').each(function () {
if ($(this).data('recommended') == 1) {
$(this).prop('checked', true);
} 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 () {
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() {
// 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']").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);
}
export default function () {
$(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']").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() {
// Display helptext to content box according to dns-record type selected
$("select[name='dns_type']").on('change', function () {
var selVal = $(this).val();
$.ajax({
url: "lib/ajax.php?action=loadLanguageString",
type: "POST",
dataType: "json",
data: { langid: 'dnseditor.notes.' + selVal },
success: function (data) {
$("#dns_content").next().html(data);
},
error: function (request, status, error) {
console.log(request, status, error)
}
export default function () {
$(function () {
// Display helptext to content box according to dns-record type selected
$("select[name='dns_type']").on('change', function () {
var selVal = $(this).val();
$.ajax({
url: "lib/ajax.php?action=loadLanguageString",
type: "POST",
dataType: "json",
data: {langid: 'dnseditor.notes.' + selVal},
success: function (data) {
$("#dns_content").next().html(data);
},
error: function (request, status, error) {
console.log(request, status, error)
}
});
});
});
}

View File

@ -1,54 +1,29 @@
export default function() {
/*
* domains
*/
// disable unusable php-configuration by customer settings
$('#customerid').on('change', function () {
var cid = $(this).val();
$.ajax({
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);
export default function () {
$(function () {
/*
* domains
*/
// disable unusable php-configuration by customer settings
$('#customerid').on('change', function () {
var cid = $(this).val();
$.ajax({
url: window.location.pathname.substring(1) + "?page=overview&action=jqSpeciallogfileNote",
url: "admin_domains.php?page=domains&action=jqGetCustomerPHPConfigs",
type: "POST",
data: {
id: $('input[name=id]').val(), newval: +$('#speciallogfile').is(':checked')
customerid: cid
},
dataType: "json",
success: function (json) {
if (json.changed) {
$('#speciallogfile').addClass('is-invalid');
$('#speciallogfile').parent().append(json.info);
$('#speciallogverified').val(1);
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) {
@ -56,54 +31,81 @@ export default function() {
}
});
});
}
/**
* email only domain - hide unnecessary/unused sections
*/
if ($('#id') && $('#email_only').is(':checked')) {
$('#section_b').hide();
$('#section_bssl').hide();
$('#section_c').hide();
$('#section_d').hide();
}
// 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({
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').on('click', function () {
if ($(this).is(':checked')) {
// hide unnecessary sections
/**
* email only domain - hide unnecessary/unused sections
*/
if ($('#id') && $('#email_only').is(':checked')) {
$('#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();
}
})
/**
* ssl enabled domain - hide unnecessary/unused sections
*/
if ($('#id') && !$('#sslenabled').is(':checked')) {
$('#section_bssl>.formfields>.row').not(":first").addClass("d-none");
}
/**
* toggle show/hide of sections in case of email only flag
*/
$('#email_only').on('click', function () {
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
*/
$('#sslenabled').on('click', function () {
if ($(this).is(':checked')) {
// show sections
$('#section_bssl>.formfields>.row').removeClass("d-none");
} else {
// hide unnecessary sections
/**
* ssl enabled domain - hide unnecessary/unused sections
*/
if ($('#id') && !$('#sslenabled').is(':checked')) {
$('#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() {
/*
* global
*/
$('#historyback').on('click', function (e) {
e.preventDefault();
history.back(1);
})
export default function () {
$(function () {
/*
* global
*/
$('#historyback').on('click', function (e) {
e.preventDefault();
history.back(1);
})
$('#copySysInfo').on('click', function (e) {
e.preventDefault();
navigator.clipboard.writeText($('#ccSysInfo').text().trim());
})
$('#copySysInfo').on('click', function (e) {
e.preventDefault();
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() {
/*
* switch between basic and advanced install mode
*/
$('#switchInstallMode').on('click', function () {
var checked = $(this).prop('checked');
window.location = window.location.pathname + replaceQueryParam('extended', +checked, window.location.search);
});
export default function () {
$(function () {
/*
* switch between basic and advanced installation mode
*/
$('#switchInstallMode').on('click', function () {
var checked = $(this).prop('checked');
window.location = window.location.pathname + replaceQueryParam('extended', +checked, window.location.search);
});
function replaceQueryParam(param, newval, search) {
var regex = new RegExp("([?;&])" + param + "[^&;]*[;&]?");
if (search.match(regex)) {
search = search.replace(regex, "$1").replace(/&$/, '');
function replaceQueryParam(param, newval, search) {
var regex = new RegExp("([?;&])" + param + "[^&;]*[;&]?");
if (search.match(regex)) {
search = search.replace(regex, "$1").replace(/&$/, '');
}
return search + '&' + param + '=' + newval;
}
return search + '&' + param + '=' + newval;
}
function checkConfigState() {
$.ajax({
url: window.location.href,
type: "GET",
success: function (data, textStatus, request) {
if (request.status >= 300) {
window.location = "http://" + srvName;
}
},
error: function (request, textStatus, errorThrown) {
// continue
if (request.status >= 300) {
window.location = "http://" + srvName;
function checkConfigState() {
$.ajax({
url: window.location.href,
type: "GET",
success: function (data, textStatus, request) {
if (request.status >= 300) {
window.location = "http://" + srvName;
}
},
error: function (request, textStatus, errorThrown) {
// continue
if (request.status >= 300) {
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;
/**
* 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 {
if ($('#manual_config').length > 0) {
var srvName = $('#target_servername').val();
clearInterval(cTimer);
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() {
/*
* ipsandports - check for internal ip and output a notice if private-range ip is given
*/
$('#ip').on('change', function () {
var ipval = $(this).val();
if (ipval.length > 0) {
$('#ipnote').remove();
$('#ip').removeClass('is-invalid');
$.ajax({
url: "admin_ipsandports.php?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);
export default function () {
$(function () {
/*
* ipsandports - check for internal ip and output a notice if private-range ip is given
*/
$('#ip').on('change', function () {
var ipval = $(this).val();
if (ipval.length > 0) {
$('#ipnote').remove();
$('#ip').removeClass('is-invalid');
$.ajax({
url: "admin_ipsandports.php?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);
}
},
error: function (a, b) {
console.log(a, b);
}
});
}
});
}
});
});
}

View File

@ -1,24 +1,26 @@
export default function() {
/*
* newsfeed
*/
if (document.getElementById('newsfeed')) {
let role = "";
export default function () {
$(function () {
/*
* newsfeed
*/
if (document.getElementById('newsfeed')) {
let role = "";
if (typeof $("#newsfeed").data("role") !== "undefined") {
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>');
if (typeof $("#newsfeed").data("role") !== "undefined") {
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>');
}
});
}
});
}

View File

@ -1,59 +1,61 @@
export default function() {
/*
* search
*/
let search = $('#search')
export default function () {
$(function () {
/*
* search
*/
let search = $('#search')
search.on('submit', function (e) {
e.preventDefault();
});
search.on('submit', function (e) {
e.preventDefault();
});
search.find('input').on('keyup', function () {
let query = $(this).val();
let dropdown = $('#search .search-results');
// Hide search if query is empty
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
search.find('input').on('keyup', function () {
let query = $(this).val();
let dropdown = $('#search .search-results');
// Hide search if query is empty
if (!query.length) {
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();
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.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() {
/*
* table columns - manage columns modal
*/
$('.manageColumnsModal form').on('submit', function (event) {
$.ajax({
url: 'lib/ajax.php?action=updatetablelisting&listing=' + $(this).data('listing') + '&theme=' + window.$theme,
type: 'POST',
dataType: 'json',
data: $(this).serialize(),
success: function () {
window.location.href = '';
},
error: function (request) {
alert(request.responseJSON.message);
}
export default function () {
$(function () {
/*
* table columns - manage columns modal
*/
$('.manageColumnsModal form').on('submit', function (event) {
$.ajax({
url: 'lib/ajax.php?action=updatetablelisting&listing=' + $(this).data('listing') + '&theme=' + window.$theme,
type: 'POST',
dataType: 'json',
data: $(this).serialize(),
success: function () {
window.location.href = '';
},
error: function (request) {
alert(request.responseJSON.message);
}
});
event.preventDefault();
});
event.preventDefault();
});
$('.manageColumnsModal form button[data-action="reset"]').on('click', function () {
var form = $(this).parents('form:first');
$.ajax({
url: 'lib/ajax.php?action=resettablelisting&listing=' + form.data('listing') + '&theme=' + window.$theme,
type: 'POST',
dataType: 'json',
data: {},
success: function () {
window.location.href = '';
},
error: function (request) {
alert(request.responseJSON.message);
}
$('.manageColumnsModal form button[data-action="reset"]').on('click', function () {
var form = $(this).parents('form:first');
$.ajax({
url: 'lib/ajax.php?action=resettablelisting&listing=' + form.data('listing') + '&theme=' + window.$theme,
type: 'POST',
dataType: 'json',
data: {},
success: function () {
window.location.href = '';
},
error: function (request) {
alert(request.responseJSON.message);
}
});
});
});
$('.manageColumnsModal form button[data-action="select-all"]').on('click', function () {
$(this).parents('form:first').find('input:checkbox').prop('checked', true);
});
$('.manageColumnsModal form button[data-action="select-all"]').on('click', function () {
$(this).parents('form:first').find('input:checkbox').prop('checked', true);
});
$('.manageColumnsModal form button[data-action="unselect-all"]').on('click', function () {
$(this).parents('form:first').find('input:checkbox').prop('checked', false);
$('.manageColumnsModal form button[data-action="unselect-all"]').on('click', function () {
$(this).parents('form:first').find('input:checkbox').prop('checked', false);
});
});
}

View File

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

View File

@ -1,21 +1,23 @@
export default function() {
/*
* updatecheck
*/
if (document.getElementById('updatecheck')) {
$.ajax({
url: "lib/ajax.php?action=updatecheck&theme=" + window.$theme,
type: "GET",
success: function (data) {
$("#updatecheck").html(data);
new bootstrap.Popover(document.getElementById('ucheck'));
},
error: function (request, status, error) {
console.log(request, status, error)
let message = 'Can\'t check version';
$("#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'));
}
});
}
export default function () {
$(function () {
/*
* updatecheck
*/
if (document.getElementById('updatecheck')) {
$.ajax({
url: "lib/ajax.php?action=updatecheck&theme=" + window.$theme,
type: "GET",
success: function (data) {
$("#updatecheck").html(data);
new bootstrap.Popover(document.getElementById('ucheck'));
},
error: function (request, status, error) {
console.log(request, status, error)
let message = 'Can\'t check version';
$("#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() {
/*
* validation
*/
$('#customer_add,#customer_edit').each(function () {
$(this).validate({
rules: {
'name': {
required: function () {
return $('#company').val().length === 0 || $('#firstname').val().length > 0;
export default function () {
$(function () {
/*
* validation
*/
$('#customer_add,#customer_edit').each(function () {
$(this).validate({
rules: {
'name': {
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 () {
$(this).validate({
rules: {
'ipandport[]': {
required: true,
minlength: 1
$('#domain_add,#domain_edit').each(function () {
$(this).validate({
rules: {
'ipandport[]': {
required: true,
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-color: $body-color;
$heading-border-color: #dee2e6;
$heading-border-color-dark: rgba(0,0,0,0.15);
// Search
$search-bg: $navbar-bg;

View File

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

View File

@ -51,6 +51,6 @@
{# add translation for custom validations #}
{% 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 %}
{% endmacro %}

View File

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

View File

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