mirror of
https://github.com/netdata/netdata.git
synced 2025-04-28 14:42:31 +00:00
Codacy js fixes (#5337)
* Ignore main.js which will be deprecated and fix some warnings in dashboard * Minor fixes to resolve codacy issues in dashboard.js.
This commit is contained in:
parent
ad6fdf8ba3
commit
59419c71f7
5 changed files with 111 additions and 102 deletions
|
@ -11,4 +11,5 @@ exclude_paths:
|
||||||
- web/gui/lib/**
|
- web/gui/lib/**
|
||||||
- web/gui/old/**
|
- web/gui/old/**
|
||||||
- web/gui/src/**
|
- web/gui/src/**
|
||||||
|
- web/gui/main.js
|
||||||
- tests/**
|
- tests/**
|
||||||
|
|
|
@ -2930,6 +2930,9 @@ NETDATA.sparklineChartCreate = function (state, data) {
|
||||||
};
|
};
|
||||||
// google charts
|
// google charts
|
||||||
|
|
||||||
|
// Codacy declarations
|
||||||
|
/* global google */
|
||||||
|
|
||||||
NETDATA.googleInitialize = function (callback) {
|
NETDATA.googleInitialize = function (callback) {
|
||||||
if (typeof netdataNoGoogleCharts === 'undefined' || !netdataNoGoogleCharts) {
|
if (typeof netdataNoGoogleCharts === 'undefined' || !netdataNoGoogleCharts) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -4988,6 +4991,7 @@ NETDATA.commonColors = {
|
||||||
|
|
||||||
// Codacy declarations
|
// Codacy declarations
|
||||||
/* global clipboard */
|
/* global clipboard */
|
||||||
|
/* global Ps */
|
||||||
|
|
||||||
if (NETDATA.options.debug.main_loop) {
|
if (NETDATA.options.debug.main_loop) {
|
||||||
console.log('welcome to NETDATA');
|
console.log('welcome to NETDATA');
|
||||||
|
@ -6256,6 +6260,55 @@ let chartState = function (element) {
|
||||||
this.tm.last_dom_created = 0;
|
this.tm.last_dom_created = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const maxMessageFontSize = () => {
|
||||||
|
let screenHeight = screen.height;
|
||||||
|
let el = this.element;
|
||||||
|
|
||||||
|
// normally we want a font size, as tall as the element
|
||||||
|
let h = el.clientHeight;
|
||||||
|
|
||||||
|
// but give it some air, 20% let's say, or 5 pixels min
|
||||||
|
let lost = Math.max(h * 0.2, 5);
|
||||||
|
h -= lost;
|
||||||
|
|
||||||
|
// center the text, vertically
|
||||||
|
let paddingTop = (lost - 5) / 2;
|
||||||
|
|
||||||
|
// but check the width too
|
||||||
|
// it should fit 10 characters in it
|
||||||
|
let w = el.clientWidth / 10;
|
||||||
|
if (h > w) {
|
||||||
|
paddingTop += (h - w) / 2;
|
||||||
|
h = w;
|
||||||
|
}
|
||||||
|
|
||||||
|
// and don't make it too huge
|
||||||
|
// 5% of the screen size is good
|
||||||
|
if (h > screenHeight / 20) {
|
||||||
|
paddingTop += (h - (screenHeight / 20)) / 2;
|
||||||
|
h = screenHeight / 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set it
|
||||||
|
this.element_message.style.fontSize = h.toString() + 'px';
|
||||||
|
this.element_message.style.paddingTop = paddingTop.toString() + 'px';
|
||||||
|
};
|
||||||
|
|
||||||
|
const showMessageIcon = (icon) => {
|
||||||
|
this.element_message.innerHTML = icon;
|
||||||
|
maxMessageFontSize();
|
||||||
|
$(this.element_message).removeClass('hidden');
|
||||||
|
this.tmp.___messageHidden___ = undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
const showLoading = () => {
|
||||||
|
if (!this.chart_created) {
|
||||||
|
showMessageIcon(NETDATA.icons.loading + ' netdata');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
let createDOM = () => {
|
let createDOM = () => {
|
||||||
if (!this.enabled) {
|
if (!this.enabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -6329,47 +6382,6 @@ let chartState = function (element) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const maxMessageFontSize = () => {
|
|
||||||
let screenHeight = screen.height;
|
|
||||||
let el = this.element;
|
|
||||||
|
|
||||||
// normally we want a font size, as tall as the element
|
|
||||||
let h = el.clientHeight;
|
|
||||||
|
|
||||||
// but give it some air, 20% let's say, or 5 pixels min
|
|
||||||
let lost = Math.max(h * 0.2, 5);
|
|
||||||
h -= lost;
|
|
||||||
|
|
||||||
// center the text, vertically
|
|
||||||
let paddingTop = (lost - 5) / 2;
|
|
||||||
|
|
||||||
// but check the width too
|
|
||||||
// it should fit 10 characters in it
|
|
||||||
let w = el.clientWidth / 10;
|
|
||||||
if (h > w) {
|
|
||||||
paddingTop += (h - w) / 2;
|
|
||||||
h = w;
|
|
||||||
}
|
|
||||||
|
|
||||||
// and don't make it too huge
|
|
||||||
// 5% of the screen size is good
|
|
||||||
if (h > screenHeight / 20) {
|
|
||||||
paddingTop += (h - (screenHeight / 20)) / 2;
|
|
||||||
h = screenHeight / 20;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set it
|
|
||||||
this.element_message.style.fontSize = h.toString() + 'px';
|
|
||||||
this.element_message.style.paddingTop = paddingTop.toString() + 'px';
|
|
||||||
};
|
|
||||||
|
|
||||||
const showMessageIcon = (icon) => {
|
|
||||||
this.element_message.innerHTML = icon;
|
|
||||||
maxMessageFontSize();
|
|
||||||
$(this.element_message).removeClass('hidden');
|
|
||||||
this.tmp.___messageHidden___ = undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
const hideMessage = () => {
|
const hideMessage = () => {
|
||||||
if (typeof this.tmp.___messageHidden___ === 'undefined') {
|
if (typeof this.tmp.___messageHidden___ === 'undefined') {
|
||||||
this.tmp.___messageHidden___ = true;
|
this.tmp.___messageHidden___ = true;
|
||||||
|
@ -6393,14 +6405,6 @@ let chartState = function (element) {
|
||||||
showMessageIcon(icon + ' netdata' + invisibleSearchableText());
|
showMessageIcon(icon + ' netdata' + invisibleSearchableText());
|
||||||
};
|
};
|
||||||
|
|
||||||
const showLoading = () => {
|
|
||||||
if (!this.chart_created) {
|
|
||||||
showMessageIcon(NETDATA.icons.loading + ' netdata');
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
const isHidden = () => {
|
const isHidden = () => {
|
||||||
return (typeof this.tmp.___chartIsHidden___ !== 'undefined');
|
return (typeof this.tmp.___chartIsHidden___ !== 'undefined');
|
||||||
};
|
};
|
||||||
|
@ -8828,7 +8832,7 @@ NETDATA.resetAllCharts = function (state) {
|
||||||
// if (NETDATA.globalPanAndZoom.isMaster(state) === false) {
|
// if (NETDATA.globalPanAndZoom.isMaster(state) === false) {
|
||||||
// master = false;
|
// master = false;
|
||||||
// }
|
// }
|
||||||
const master = NETDATA.globalPanAndZoom.isMaster(state)
|
const master = NETDATA.globalPanAndZoom.isMaster(state);
|
||||||
|
|
||||||
// clear the global Pan and Zoom
|
// clear the global Pan and Zoom
|
||||||
// this will also refresh the master
|
// this will also refresh the master
|
||||||
|
@ -9758,7 +9762,7 @@ NETDATA.registry = {
|
||||||
NETDATA.registry.hello(NETDATA.serverDefault, function (data) {
|
NETDATA.registry.hello(NETDATA.serverDefault, function (data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
NETDATA.registry.server = data.registry;
|
NETDATA.registry.server = data.registry;
|
||||||
if (data.cloud_base_url != "") {
|
if (data.cloud_base_url !== "") {
|
||||||
NETDATA.registry.isCloudEnabled = true;
|
NETDATA.registry.isCloudEnabled = true;
|
||||||
NETDATA.registry.cloudBaseURL = data.cloud_base_url;
|
NETDATA.registry.cloudBaseURL = data.cloud_base_url;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
// google charts
|
// google charts
|
||||||
|
|
||||||
|
// Codacy declarations
|
||||||
|
/* global google */
|
||||||
|
|
||||||
NETDATA.googleInitialize = function (callback) {
|
NETDATA.googleInitialize = function (callback) {
|
||||||
if (typeof netdataNoGoogleCharts === 'undefined' || !netdataNoGoogleCharts) {
|
if (typeof netdataNoGoogleCharts === 'undefined' || !netdataNoGoogleCharts) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
// Codacy declarations
|
// Codacy declarations
|
||||||
/* global clipboard */
|
/* global clipboard */
|
||||||
|
/* global Ps */
|
||||||
|
|
||||||
if (NETDATA.options.debug.main_loop) {
|
if (NETDATA.options.debug.main_loop) {
|
||||||
console.log('welcome to NETDATA');
|
console.log('welcome to NETDATA');
|
||||||
|
@ -1271,6 +1272,55 @@ let chartState = function (element) {
|
||||||
this.tm.last_dom_created = 0;
|
this.tm.last_dom_created = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const maxMessageFontSize = () => {
|
||||||
|
let screenHeight = screen.height;
|
||||||
|
let el = this.element;
|
||||||
|
|
||||||
|
// normally we want a font size, as tall as the element
|
||||||
|
let h = el.clientHeight;
|
||||||
|
|
||||||
|
// but give it some air, 20% let's say, or 5 pixels min
|
||||||
|
let lost = Math.max(h * 0.2, 5);
|
||||||
|
h -= lost;
|
||||||
|
|
||||||
|
// center the text, vertically
|
||||||
|
let paddingTop = (lost - 5) / 2;
|
||||||
|
|
||||||
|
// but check the width too
|
||||||
|
// it should fit 10 characters in it
|
||||||
|
let w = el.clientWidth / 10;
|
||||||
|
if (h > w) {
|
||||||
|
paddingTop += (h - w) / 2;
|
||||||
|
h = w;
|
||||||
|
}
|
||||||
|
|
||||||
|
// and don't make it too huge
|
||||||
|
// 5% of the screen size is good
|
||||||
|
if (h > screenHeight / 20) {
|
||||||
|
paddingTop += (h - (screenHeight / 20)) / 2;
|
||||||
|
h = screenHeight / 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set it
|
||||||
|
this.element_message.style.fontSize = h.toString() + 'px';
|
||||||
|
this.element_message.style.paddingTop = paddingTop.toString() + 'px';
|
||||||
|
};
|
||||||
|
|
||||||
|
const showMessageIcon = (icon) => {
|
||||||
|
this.element_message.innerHTML = icon;
|
||||||
|
maxMessageFontSize();
|
||||||
|
$(this.element_message).removeClass('hidden');
|
||||||
|
this.tmp.___messageHidden___ = undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
const showLoading = () => {
|
||||||
|
if (!this.chart_created) {
|
||||||
|
showMessageIcon(NETDATA.icons.loading + ' netdata');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
let createDOM = () => {
|
let createDOM = () => {
|
||||||
if (!this.enabled) {
|
if (!this.enabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -1344,47 +1394,6 @@ let chartState = function (element) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const maxMessageFontSize = () => {
|
|
||||||
let screenHeight = screen.height;
|
|
||||||
let el = this.element;
|
|
||||||
|
|
||||||
// normally we want a font size, as tall as the element
|
|
||||||
let h = el.clientHeight;
|
|
||||||
|
|
||||||
// but give it some air, 20% let's say, or 5 pixels min
|
|
||||||
let lost = Math.max(h * 0.2, 5);
|
|
||||||
h -= lost;
|
|
||||||
|
|
||||||
// center the text, vertically
|
|
||||||
let paddingTop = (lost - 5) / 2;
|
|
||||||
|
|
||||||
// but check the width too
|
|
||||||
// it should fit 10 characters in it
|
|
||||||
let w = el.clientWidth / 10;
|
|
||||||
if (h > w) {
|
|
||||||
paddingTop += (h - w) / 2;
|
|
||||||
h = w;
|
|
||||||
}
|
|
||||||
|
|
||||||
// and don't make it too huge
|
|
||||||
// 5% of the screen size is good
|
|
||||||
if (h > screenHeight / 20) {
|
|
||||||
paddingTop += (h - (screenHeight / 20)) / 2;
|
|
||||||
h = screenHeight / 20;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set it
|
|
||||||
this.element_message.style.fontSize = h.toString() + 'px';
|
|
||||||
this.element_message.style.paddingTop = paddingTop.toString() + 'px';
|
|
||||||
};
|
|
||||||
|
|
||||||
const showMessageIcon = (icon) => {
|
|
||||||
this.element_message.innerHTML = icon;
|
|
||||||
maxMessageFontSize();
|
|
||||||
$(this.element_message).removeClass('hidden');
|
|
||||||
this.tmp.___messageHidden___ = undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
const hideMessage = () => {
|
const hideMessage = () => {
|
||||||
if (typeof this.tmp.___messageHidden___ === 'undefined') {
|
if (typeof this.tmp.___messageHidden___ === 'undefined') {
|
||||||
this.tmp.___messageHidden___ = true;
|
this.tmp.___messageHidden___ = true;
|
||||||
|
@ -1408,14 +1417,6 @@ let chartState = function (element) {
|
||||||
showMessageIcon(icon + ' netdata' + invisibleSearchableText());
|
showMessageIcon(icon + ' netdata' + invisibleSearchableText());
|
||||||
};
|
};
|
||||||
|
|
||||||
const showLoading = () => {
|
|
||||||
if (!this.chart_created) {
|
|
||||||
showMessageIcon(NETDATA.icons.loading + ' netdata');
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
const isHidden = () => {
|
const isHidden = () => {
|
||||||
return (typeof this.tmp.___chartIsHidden___ !== 'undefined');
|
return (typeof this.tmp.___chartIsHidden___ !== 'undefined');
|
||||||
};
|
};
|
||||||
|
@ -3843,7 +3844,7 @@ NETDATA.resetAllCharts = function (state) {
|
||||||
// if (NETDATA.globalPanAndZoom.isMaster(state) === false) {
|
// if (NETDATA.globalPanAndZoom.isMaster(state) === false) {
|
||||||
// master = false;
|
// master = false;
|
||||||
// }
|
// }
|
||||||
const master = NETDATA.globalPanAndZoom.isMaster(state)
|
const master = NETDATA.globalPanAndZoom.isMaster(state);
|
||||||
|
|
||||||
// clear the global Pan and Zoom
|
// clear the global Pan and Zoom
|
||||||
// this will also refresh the master
|
// this will also refresh the master
|
||||||
|
|
|
@ -75,7 +75,7 @@ NETDATA.registry = {
|
||||||
NETDATA.registry.hello(NETDATA.serverDefault, function (data) {
|
NETDATA.registry.hello(NETDATA.serverDefault, function (data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
NETDATA.registry.server = data.registry;
|
NETDATA.registry.server = data.registry;
|
||||||
if (data.cloud_base_url != "") {
|
if (data.cloud_base_url !== "") {
|
||||||
NETDATA.registry.isCloudEnabled = true;
|
NETDATA.registry.isCloudEnabled = true;
|
||||||
NETDATA.registry.cloudBaseURL = data.cloud_base_url;
|
NETDATA.registry.cloudBaseURL = data.cloud_base_url;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue