fix: refs #6164 Fix search in rows
This commit is contained in:
parent
4a1df1c1bf
commit
58028afc45
87
main.js
87
main.js
|
@ -204,21 +204,41 @@ async function main(){
|
||||||
if (dashboard) {
|
if (dashboard) {
|
||||||
if (dashboard.panels)
|
if (dashboard.panels)
|
||||||
for (const panel of dashboard.panels) {
|
for (const panel of dashboard.panels) {
|
||||||
|
// Panels
|
||||||
if (panel.targets)
|
if (panel.targets)
|
||||||
for (const target of panel.targets) {
|
for (const target of panel.targets) {
|
||||||
isFound = regexRawSQL.test(target.rawSql);
|
isFound = regexRawSQL.test(target.rawSql);
|
||||||
if (isFound) {
|
if (isFound) {
|
||||||
if (panel.title)
|
if (panel.title)
|
||||||
if (panel.title==' ')
|
if (panel.title==' ')
|
||||||
titlePanels.push(`(null)`.italic);
|
titlePanels.push(`(null)`.italic);
|
||||||
|
else
|
||||||
|
titlePanels.push(panel.title);
|
||||||
else
|
else
|
||||||
titlePanels.push(panel.title);
|
titlePanels.push(`(undefined)`.italic);
|
||||||
else
|
numberOfPanels++;
|
||||||
titlePanels.push(`(undefined)`.italic);
|
isFoundSomething=true;
|
||||||
numberOfPanels++;
|
}
|
||||||
isFoundSomething=true;
|
}
|
||||||
|
// Rows
|
||||||
|
if (panel.panels)
|
||||||
|
for (const subpanel of panel.panels) {
|
||||||
|
if (subpanel.targets)
|
||||||
|
for (const target of subpanel.targets) {
|
||||||
|
isFound = regexRawSQL.test(target.rawSql);
|
||||||
|
if (isFound) {
|
||||||
|
if (subpanel.title)
|
||||||
|
if (subpanel.title==' ')
|
||||||
|
titlePanels.push(`(null)`.italic);
|
||||||
|
else
|
||||||
|
titlePanels.push(subpanel.title);
|
||||||
|
else
|
||||||
|
titlePanels.push(`(undefined)`.italic);
|
||||||
|
numberOfPanels++;
|
||||||
|
isFoundSomething=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dashboard.templating)
|
if (dashboard.templating)
|
||||||
|
@ -283,32 +303,35 @@ async function main(){
|
||||||
let allAlerts = await response.json();
|
let allAlerts = await response.json();
|
||||||
|
|
||||||
isFound = isFoundSomething = false;
|
isFound = isFoundSomething = false;
|
||||||
|
if (allAlerts.title === 'Access denied')
|
||||||
for (const alert of allAlerts)
|
console.log(`${allAlerts.title}\n`.red);
|
||||||
for (const data of alert.data)
|
else {
|
||||||
if (data?.model?.rawSql) {
|
for (const alert of allAlerts)
|
||||||
isFound = regexRawSQL.test(data.model.rawSql);
|
for (const data of alert.data)
|
||||||
if (isFound) {
|
if (data?.model?.rawSql) {
|
||||||
if (alert?.title)
|
isFound = regexRawSQL.test(data.model.rawSql);
|
||||||
if (alert.title == ' ')
|
if (isFound) {
|
||||||
titleAlerts.push(`(null)`.italic);
|
if (alert?.title)
|
||||||
else {
|
if (alert.title == ' ')
|
||||||
const linkUrl = `${grafanaUrl}/alerting/${alert.uid}/edit?orgId=${AllOrganizations[x].id}`;
|
titleAlerts.push(`(null)`.italic);
|
||||||
console.log((linkUrl).yellow.underline, alert.title, '\n');
|
else {
|
||||||
numberOfObjects++;
|
const linkUrl = `${grafanaUrl}/alerting/${alert.uid}/edit?orgId=${AllOrganizations[x].id}`;
|
||||||
totalObjects++;
|
console.log((linkUrl).yellow.underline, alert.title, '\n');
|
||||||
}
|
numberOfObjects++;
|
||||||
else
|
totalObjects++;
|
||||||
titleAlerts.push(`(undefined)`.italic);
|
}
|
||||||
isFoundSomething = true;
|
else
|
||||||
|
titleAlerts.push(`(undefined)`.italic);
|
||||||
|
isFoundSomething = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!isFoundSomething)
|
if (!isFoundSomething)
|
||||||
console.log(`No results found\n`.gray);
|
console.log(`No results found\n`.gray);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(colors.green.bold(`──────── Have been found ${numberOfObjects} similarities in ${totalObjects} objects ────────\n`));
|
console.log(colors.green.bold(`─────── Have been found ${numberOfObjects} similarities in ${totalObjects} objects ───────\n`));
|
||||||
|
|
||||||
if (!response) {
|
if (!response) {
|
||||||
console.log(`${error}The server don't exists`);
|
console.log(`${error}The server don't exists`);
|
||||||
|
|
Loading…
Reference in New Issue