mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-02 16:22:20 -07:00
feat: authoritative plugin fields
Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
@@ -174,6 +174,12 @@ $db->close();
|
||||
</div>
|
||||
<div class="db_tools_table_cell_b"><?= lang('Maintenance_Tool_del_allevents30_text');?></div>
|
||||
</div>
|
||||
<div class="db_info_table_row">
|
||||
<div class="db_tools_table_cell_a" >
|
||||
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnUnlockFields" onclick="askUnlockFields()"><?= lang('Maintenance_Tool_UnlockFields');?></button>
|
||||
</div>
|
||||
<div class="db_tools_table_cell_b"><?= lang('Maintenance_Tool_UnlockFields_text');?></div>
|
||||
</div>
|
||||
<div class="db_info_table_row">
|
||||
<div class="db_tools_table_cell_a" >
|
||||
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteActHistory" onclick="askDeleteActHistory()"><?= lang('Maintenance_Tool_del_ActHistory');?></button>
|
||||
@@ -464,6 +470,46 @@ function deleteEvents30()
|
||||
});
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------
|
||||
// Unlock/clear sources
|
||||
function askUnlockFields () {
|
||||
// Ask
|
||||
showModalWarning('<?= lang('Maintenance_Tool_UnlockFields_noti');?>', '<?= lang('Maintenance_Tool_UnlockFields_noti_text');?>',
|
||||
'<?= lang('Gen_Cancel');?>', '<?= lang('Gen_Delete');?>', 'unlockFields');
|
||||
}
|
||||
function unlockFields() {
|
||||
const apiBase = getApiBase();
|
||||
const apiToken = getSetting("API_TOKEN");
|
||||
const url = `${apiBase}/devices/fields/unlock`;
|
||||
|
||||
// Payload: clear all sources for all devices and all fields
|
||||
const payload = {
|
||||
mac: null, // null = all devices
|
||||
fields: null, // null = all tracked fields
|
||||
clearAll: true // clear all source values
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: "POST",
|
||||
contentType: "application/json",
|
||||
headers: {
|
||||
"Authorization": `Bearer ${apiToken}`
|
||||
},
|
||||
data: JSON.stringify(payload),
|
||||
success: function(response) {
|
||||
showMessage(response.success
|
||||
? "All device fields unlocked/cleared successfully"
|
||||
: (response.error || "Unknown error")
|
||||
);
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error("Error unlocking fields:", status, error);
|
||||
showMessage("Error: " + (xhr.responseJSON?.error || error));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------
|
||||
// delete History
|
||||
function askDeleteActHistory () {
|
||||
|
||||
Reference in New Issue
Block a user