Last active
April 23, 2024 06:01
-
-
Save inebritov/8e9b27b8cb721a6ba93138e0c3681ca5 to your computer and use it in GitHub Desktop.
Проверяет валидность конфигурации устройств в агенте
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 characters
| (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'; | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment