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.panels)
|
||||
for (const panel of dashboard.panels) {
|
||||
// Panels
|
||||
if (panel.targets)
|
||||
for (const target of panel.targets) {
|
||||
isFound = regexRawSQL.test(target.rawSql);
|
||||
if (isFound) {
|
||||
if (panel.title)
|
||||
if (panel.title==' ')
|
||||
titlePanels.push(`(null)`.italic);
|
||||
for (const target of panel.targets) {
|
||||
isFound = regexRawSQL.test(target.rawSql);
|
||||
if (isFound) {
|
||||
if (panel.title)
|
||||
if (panel.title==' ')
|
||||
titlePanels.push(`(null)`.italic);
|
||||
else
|
||||
titlePanels.push(panel.title);
|
||||
else
|
||||
titlePanels.push(panel.title);
|
||||
else
|
||||
titlePanels.push(`(undefined)`.italic);
|
||||
numberOfPanels++;
|
||||
isFoundSomething=true;
|
||||
titlePanels.push(`(undefined)`.italic);
|
||||
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)
|
||||
|
@ -283,32 +303,35 @@ async function main(){
|
|||
let allAlerts = await response.json();
|
||||
|
||||
isFound = isFoundSomething = false;
|
||||
|
||||
for (const alert of allAlerts)
|
||||
for (const data of alert.data)
|
||||
if (data?.model?.rawSql) {
|
||||
isFound = regexRawSQL.test(data.model.rawSql);
|
||||
if (isFound) {
|
||||
if (alert?.title)
|
||||
if (alert.title == ' ')
|
||||
titleAlerts.push(`(null)`.italic);
|
||||
else {
|
||||
const linkUrl = `${grafanaUrl}/alerting/${alert.uid}/edit?orgId=${AllOrganizations[x].id}`;
|
||||
console.log((linkUrl).yellow.underline, alert.title, '\n');
|
||||
numberOfObjects++;
|
||||
totalObjects++;
|
||||
}
|
||||
else
|
||||
titleAlerts.push(`(undefined)`.italic);
|
||||
isFoundSomething = true;
|
||||
if (allAlerts.title === 'Access denied')
|
||||
console.log(`${allAlerts.title}\n`.red);
|
||||
else {
|
||||
for (const alert of allAlerts)
|
||||
for (const data of alert.data)
|
||||
if (data?.model?.rawSql) {
|
||||
isFound = regexRawSQL.test(data.model.rawSql);
|
||||
if (isFound) {
|
||||
if (alert?.title)
|
||||
if (alert.title == ' ')
|
||||
titleAlerts.push(`(null)`.italic);
|
||||
else {
|
||||
const linkUrl = `${grafanaUrl}/alerting/${alert.uid}/edit?orgId=${AllOrganizations[x].id}`;
|
||||
console.log((linkUrl).yellow.underline, alert.title, '\n');
|
||||
numberOfObjects++;
|
||||
totalObjects++;
|
||||
}
|
||||
else
|
||||
titleAlerts.push(`(undefined)`.italic);
|
||||
isFoundSomething = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isFoundSomething)
|
||||
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) {
|
||||
console.log(`${error}The server don't exists`);
|
||||
|
|
Loading…
Reference in New Issue