Ahora ya busca bien en todas las organizaciones
This commit is contained in:
parent
cb8fd76e46
commit
034f6d1f82
29
main.js
29
main.js
|
@ -126,10 +126,16 @@ async function main(){
|
|||
|
||||
if (AllOrganizations.message==='invalid username or password') {
|
||||
console.error(`\n${error}Invalid username or password\n`.red);
|
||||
process.exit(0);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.clear();
|
||||
console.log(
|
||||
`----------`.white,
|
||||
`Grafana-Find (${packageJson.description})`.yellow.bold,
|
||||
`v${packageJson.version}`.cyan.bold,
|
||||
`---------`.white
|
||||
);
|
||||
console.log(colors.green.bold(`-------------------- Starting process --------------------\n`));
|
||||
|
||||
for (let x in AllOrganizations) {
|
||||
|
@ -146,6 +152,9 @@ async function main(){
|
|||
if (response.status === 302) {
|
||||
response = await fetch(`${urlDashboards}${AllOrganizations[x].id}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json'
|
||||
},
|
||||
redirect: 'manual'
|
||||
});
|
||||
}
|
||||
|
@ -153,15 +162,25 @@ async function main(){
|
|||
let allUID = await response.json();
|
||||
|
||||
for (let i in allUID) {
|
||||
|
||||
let url = urlUID + allUID[i].uid;
|
||||
let url = `${urlUID}${allUID[i].uid}`;
|
||||
response = await fetch(url, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: credentials,
|
||||
}
|
||||
},
|
||||
redirect: 'manual'
|
||||
});
|
||||
|
||||
if (response.status === 404) {
|
||||
response = await fetch(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json'
|
||||
},
|
||||
redirect: 'manual'
|
||||
});
|
||||
}
|
||||
|
||||
let data = await response.json();
|
||||
|
||||
let isFound = false;
|
||||
|
@ -222,6 +241,6 @@ async function main(){
|
|||
|
||||
console.log(colors.green.bold(`-------- Have been found ${numberOfObjects} results in ${numberOfDashboards} dashboards -------\n`));
|
||||
|
||||
process.exit(0);
|
||||
process.exit();
|
||||
}
|
||||
main();
|
Loading…
Reference in New Issue