Last active
April 23, 2024 06:01
-
-
Save inebritov/8e9b27b8cb721a6ba93138e0c3681ca5 to your computer and use it in GitHub Desktop.
Revisions
-
inebritov revised this gist
Apr 23, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1 @@ javascript:fetch("https://gist.githubusercontent.com/inebritov/8e9b27b8cb721a6ba93138e0c3681ca5/raw/agent-validator.js?cachebust="+Math.floor(1000*Math.random())).then((t=>t.text())).then((js=>{eval(js),window.__AgentValidator()})).catch((t=>console.error(t))); -
inebritov revised this gist
Apr 23, 2024 . 2 changed files with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1 @@ javascript:fetch("https://gist.githubusercontent.com/inebritov/8e9b27b8cb721a6ba93138e0c3681ca5/raw/agent-validator.js").then((t=>t.text())).then((js=>{eval(js),window.__AgentValidator()})).catch((t=>console.error(t))); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ */ window.__AgentValidator = () => { fetch(location.protocol + '//' + location.host + "/api/v1/devices") .then(response => console.log(response.status) || response) @@ -58,6 +58,7 @@ window['__AgentValidator'] = function () { } } } let text = 'Неверно сконфигурированных устройств: ' + errors + '\n' + message; console.log(text); alert(text); -
inebritov revised this gist
Apr 23, 2024 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -58,8 +58,8 @@ window['__AgentValidator'] = function () { } } } let text = 'Неверно сконфигурированных устройств: ' + errors + '\n' + message; console.log(text); alert(text); } } -
inebritov revised this gist
Apr 23, 2024 . 1 changed file with 22 additions and 21 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,12 +14,21 @@ */ window['__AgentValidator'] = function () { fetch(location.protocol + '//' + location.host + "/api/v1/devices") .then(response => console.log(response.status) || response) .then(response => response.text()) .then(body => validateDevices(body)); function addDeviceAlert(device, error) { error = error || ''; let row = document.querySelector('[data-row-key="' + device.id + '"]'); row.style.background = 'pink'; return device.name + ' - ' + error + '\n'; } function validateDevices(body) { let devices = JSON.parse(body).devices; if (!devices) alert('Нет устройств'); @@ -30,35 +39,27 @@ fetch(location.protocol + '//' + location.host + "/api/v1/devices") let map = device.feature_mappings; if (!map || Object.keys(map).length == 0) { errors++; message += addDeviceAlert(device, 'стёрлись функции'); continue; } for (let key in map) { if (!map[key].mappings || map[key].mappings.length == 0) { errors++; message += addDeviceAlert(device, 'нет функций'); continue; } for (let item of map[key].mappings) { if (!item.status_object) { errors++; message += addDeviceAlert(device, 'пустой топик статуса'); continue; } } } } let message = 'Неверно сконфигурированных устройств: ' + errors + '\n' + message; console.log(message); alert(message); } } -
inebritov revised this gist
Apr 22, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1 @@ javascript:!function(){function e(e,t){return t=t||"",document.querySelector('[data-row-key="'+e.id+'"]').style.background="pink",e.name+" "+t+"\n"}fetch(location.protocol+"//"+location.host+"/api/v1/devices").then((e=>console.log(e.status)||e)).then((e=>e.text())).then((t=>{let o=JSON.parse(t).devices;o||alert("Нет устройств"),console.log(o);let n=0,l="";for(let t of o){let o=t.feature_mappings;if(o&&0!=Object.keys(o).length)for(let s in o)if(o[s].mappings&&0!=o[s].mappings.length)for(let a of o[s].mappings)a.status_object||(n++,l+=e(t,"- пустой топик статуса"));else n++,l+=e(t,"- нет функций");else n++,l+=e(t,"- стерлись функции")}alert("Неверно сконфигурированных устройств: "+n+"\n"+l),console.log("Неверно сконфигурированных устройств: "+n+"\n"+l)}))}(); -
inebritov revised this gist
Apr 22, 2024 . 1 changed file with 39 additions and 23 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,33 +16,49 @@ (function () { fetch(location.protocol + '//' + location.host + "/api/v1/devices") .then(response => console.log(response.status) || response) .then(response => response.text()) .then(body => { let devices = JSON.parse(body).devices; if (!devices) alert('Нет устройств'); console.log(devices); let errors = 0, message = ''; for (let device of devices) { let map = device.feature_mappings; if (!map || Object.keys(map).length == 0) { errors++; message += addDeviceAlert(device, '- стерлись функции'); continue; } for (let key in map) { if (!map[key].mappings || map[key].mappings.length == 0) { errors++; message += addDeviceAlert(device, '- нет функций'); continue; } for (let item of map[key].mappings) { if (!item.status_object) { errors++; message += addDeviceAlert(device, '- пустой топик статуса'); continue; } } } } alert('Неверно сконфигурированных устройств: ' + errors + '\n' + message); console.log('Неверно сконфигурированных устройств: ' + errors + '\n' + message); }); function addDeviceAlert(device, error) { error = error || ''; let row = document.querySelector('[data-row-key="' + device.id + '"]'); row.style.background = 'pink'; return device.name + ' ' + error + '\n'; } })(); -
inebritov revised this gist
Apr 22, 2024 . 2 changed files with 17 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ javascript:!function(){function e(e,t){t=t||"";let o=document.querySelector('[data-row-key="'+e.id+'"]');o?o.style.background="pink":alert("Не найдено устройство: "+e.name+" ("+e.id+") "+t)}fetch(location.protocol+"//"+location.host+"/api/v1/devices").then((e=>console.log(e.status)||e)).then((e=>e.text())).then((t=>{let o=JSON.parse(t).devices;o||alert("Нет устройств"),console.log(o);let l=0;for(let t of o){let o=t.feature_mappings;o&&0!=Object.keys(o).length||(l++,e(t))}alert("Неверно сконфигурированных устройств: "+l)}))}(); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,19 @@ /* Валидация устройств агента. Как использовать: 1. Открываем страницу агента 2. Нажимаем Ctrl+Shift+B - отобразить панель закладок браузера 3. В панели закладок нажимаем правой кнопкой, выбираем добавить 4. Название "agent validate", а в URL вставляем содержимое файла agent-validator.bookmarklet.js 5. Сохраняем закладку Теперь если на странице агента нажать на эту закладку, скрипт подсветит красным устройства, у которых невалидная конфигурация. В последствии, валидация будет добавлена в функции агента по-умолчанию. */ (function () { fetch(location.protocol + '//' + location.host + "/api/v1/devices") -
inebritov revised this gist
Apr 22, 2024 . 1 changed file with 27 additions and 22 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,27 +1,32 @@ (function () { fetch(location.protocol + '//' + location.host + "/api/v1/devices") .then(response => console.log(response.status) || response) .then(response => response.text()) .then(body => { let devices = JSON.parse(body).devices; if (!devices) alert('Нет устройств'); console.log(devices); let errors = 0; for (let device of devices) { let map = device.feature_mappings; if (!map || Object.keys(map).length == 0) { errors++; addDeviceAlert(device) } } alert('Неверно сконфигурированных устройств: ' + errors); }); function addDeviceAlert(device, error) { error = error || ''; let row = document.querySelector('[data-row-key="' + device.id + '"]'); if (!row) {alert('Не найдено устройство: ' + device.name + ' (' + device.id + ') ' + error);return;} row.style.background = 'pink'; } })(); -
inebritov created this gist
Apr 22, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ fetch(location.protocol + '//' + location.host + "/api/v1/devices") .then(response => console.log(response.status) || response) .then(response => response.text()) .then(body => { let devices = JSON.parse(body).devices; if (!devices) alert('Нет устройств'); console.log(devices); let errors = 0; for (let device of devices) { let map = device.feature_mappings; if (!map || Object.keys(map).length == 0) { errors++; addDeviceAlert(device) } } alert('Неверно сконфигурированных устройств: ' + errors); }); function addDeviceAlert(device, error) { error = error || ''; let row = document.querySelector('[data-row-key="' + device.id + '"]'); if (!row) {alert('Не найдено устройство: ' + device.name + ' (' + device.id + ') ' + error);return;} row.style.background = 'pink'; }