Plugins 0.4 - ForeignKey support added
This commit is contained in:
@@ -63,6 +63,9 @@ function getFormControl(dbColumnDef, value, index) {
|
||||
case 'url':
|
||||
result = `<span><a href="${value}" target="_blank">${value}</a><span>`;
|
||||
break;
|
||||
case 'devicemac':
|
||||
result = `<span><a href="/deviceDetails.php?mac=${value}" target="_blank">${value}</a><span>`;
|
||||
break;
|
||||
case 'threshold':
|
||||
$.each(dbColumnDef.options, function(index, obj) {
|
||||
if(Number(value) < obj.maximum && result == '')
|
||||
@@ -94,7 +97,7 @@ function saveData (id) {
|
||||
index = $(`#${id}`).attr('data-my-index')
|
||||
columnValue = $(`#${id}`).val()
|
||||
|
||||
$.get(`php/server/dbHelper.php?action=update&dbtable=Plugins_Objects&key=Index&id=${index}&columns=UserData&values=${columnValue}`, function(data) {
|
||||
$.get(`php/server/dbHelper.php?action=update&dbtable=Plugins_Objects&columnName=Index&id=${index}&columns=UserData&values=${columnValue}`, function(data) {
|
||||
|
||||
// var result = JSON.parse(data);
|
||||
console.log(data)
|
||||
@@ -242,18 +245,25 @@ function generateTabs()
|
||||
|
||||
// Generate the history rows
|
||||
var histCount = 0
|
||||
var histCountDisplayed = 0
|
||||
|
||||
for(i=0;i<pluginHistory.length;i++)
|
||||
{
|
||||
if(pluginHistory[i].Plugin == obj.unique_prefix)
|
||||
{
|
||||
clm = ""
|
||||
if(histCount < 50) // only display 50 entries to optimize performance
|
||||
{
|
||||
clm = ""
|
||||
|
||||
for(j=0;j<colDefinitions.length;j++)
|
||||
{
|
||||
clm += '<td>'+ pluginHistory[i][colDefinitions[j].column] +'</td>'
|
||||
}
|
||||
hiRows += `<tr data-my-index="${pluginHistory[i]["Index"]}" >${clm}</tr>`
|
||||
histCount++;
|
||||
for(j=0;j<colDefinitions.length;j++)
|
||||
{
|
||||
clm += '<td>'+ pluginHistory[i][colDefinitions[j].column] +'</td>'
|
||||
}
|
||||
hiRows += `<tr data-my-index="${pluginHistory[i]["Index"]}" >${clm}</tr>`
|
||||
|
||||
histCountDisplayed++;
|
||||
}
|
||||
histCount++; // count and display the total
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,7 +309,7 @@ function generateTabs()
|
||||
<li >
|
||||
<a href="#historyTarget_${obj.unique_prefix}" data-toggle="tab" >
|
||||
|
||||
<i class="fa fa-clock"></i> <?= lang('Plugins_History');?> (${histCount})
|
||||
<i class="fa fa-clock"></i> <?= lang('Plugins_History');?> (${histCountDisplayed} out of ${histCount} )
|
||||
|
||||
</a>
|
||||
</li>
|
||||
@@ -320,7 +330,7 @@ function generateTabs()
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="plugin-obj-purge">
|
||||
<button class="btn btn-primary" onclick="purgeAll('${obj.unique_prefix}', 'Plugins_Objects' )"><?= lang('Gen_Purge');?></button>
|
||||
<button class="btn btn-primary" onclick="purgeAll('${obj.unique_prefix}', 'Plugins_Objects' )"><?= lang('Gen_DeleteAll');?></button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="eventsTarget_${obj.unique_prefix}" class="tab-pane">
|
||||
@@ -334,7 +344,7 @@ function generateTabs()
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="plugin-obj-purge">
|
||||
<button class="btn btn-primary" onclick="purgeAll('${obj.unique_prefix}', 'Plugins_Events' )"><?= lang('Gen_Purge');?></button>
|
||||
<button class="btn btn-primary" onclick="purgeAll('${obj.unique_prefix}', 'Plugins_Events' )"><?= lang('Gen_DeleteAll');?></button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="historyTarget_${obj.unique_prefix}" class="tab-pane">
|
||||
@@ -348,7 +358,7 @@ function generateTabs()
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="plugin-obj-purge">
|
||||
<button class="btn btn-primary" onclick="purgeAll('${obj.unique_prefix}', 'Plugins_History' )"><?= lang('Gen_Purge');?></button>
|
||||
<button class="btn btn-primary" onclick="purgeAll('${obj.unique_prefix}', 'Plugins_History' )"><?= lang('Gen_DeleteAll');?></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -373,8 +383,6 @@ function generateTabs()
|
||||
|
||||
// --------------------------------------------------------
|
||||
// handle first tab (objectsTarget_) display
|
||||
var lastPrefix = ''
|
||||
|
||||
function initTabs()
|
||||
{
|
||||
// events on tab change
|
||||
@@ -384,26 +392,28 @@ function initTabs()
|
||||
// save the last prefix
|
||||
if(target.includes('_') == false )
|
||||
{
|
||||
lastPrefix = target.split('#')[1]
|
||||
pref = target.split('#')[1]
|
||||
} else
|
||||
{
|
||||
pref = target.split('_')[1]
|
||||
}
|
||||
|
||||
|
||||
everythingHidden = false;
|
||||
|
||||
if($('#objectsTarget_'+ lastPrefix) && $('#historyTarget_'+ lastPrefix) && $('#eventsTarget_'+ lastPrefix))
|
||||
if($('#objectsTarget_'+ pref) != undefined && $('#historyTarget_'+ pref) != undefined && $('#eventsTarget_'+ pref) != undefined)
|
||||
{
|
||||
everythingHidden = $('#objectsTarget_'+ lastPrefix).attr('class').includes('active') == false && $('#historyTarget_'+ lastPrefix).attr('class').includes('active') == false && $('#eventsTarget_'+ lastPrefix).attr('class').includes('active') == false;
|
||||
everythingHidden = $('#objectsTarget_'+ pref).attr('class').includes('active') == false && $('#historyTarget_'+ pref).attr('class').includes('active') == false && $('#eventsTarget_'+ pref).attr('class').includes('active') == false;
|
||||
}
|
||||
|
||||
// show the objectsTarget if no specific pane selected or if selected is hidden
|
||||
if((target == '#'+lastPrefix ) && everythingHidden) //|| target == '#objectsTarget_'+ lastPrefix
|
||||
if((target == '#'+pref ) && everythingHidden)
|
||||
{
|
||||
var classTmp = $('#objectsTarget_'+ lastPrefix).attr('class');
|
||||
var classTmp = $('#objectsTarget_'+ pref).attr('class');
|
||||
|
||||
if($('#objectsTarget_'+ lastPrefix).attr('class').includes('active') == false)
|
||||
{
|
||||
console.log('show')
|
||||
if($('#objectsTarget_'+ pref).attr('class').includes('active') == false)
|
||||
{
|
||||
classTmp += ' active';
|
||||
$('#objectsTarget_'+ lastPrefix).attr('class', classTmp)
|
||||
$('#objectsTarget_'+ pref).attr('class', classTmp)
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -422,20 +432,27 @@ function purgeAll(callback) {
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
dbIndexes = ''
|
||||
|
||||
function purgeAllExecute() {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "php/server/dbHelper.php",
|
||||
data: { action: "delete", dbtable: dbTable, columnName: 'Plugin', id:plugPrefix },
|
||||
success: function(data, textStatus) {
|
||||
showModalOk ('Result', data );
|
||||
}
|
||||
})
|
||||
|
||||
// Execute
|
||||
// console.log("targetLogFile:" + targetLogFile)
|
||||
// console.log("logFileAction:" + logFileAction)
|
||||
}
|
||||
|
||||
idArr = $('#NMAPSRV table[data-my-dbtable="Plugins_Objects"] tr[data-my-index]').map(function(){return $(this).attr("data-my-index");}).get();
|
||||
// --------------------------------------------------------
|
||||
function purgeVisible() {
|
||||
|
||||
idArr = $(`#${plugPrefix} table[data-my-dbtable="${dbTable}"] tr[data-my-index]`).map(function(){return $(this).attr("data-my-index");}).get();
|
||||
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "php/server/dbHelper.php",
|
||||
data: { action: "delete", dbtable: 'Plugins_Objects', key: 'Index', id:idArr.toString() },
|
||||
data: { action: "delete", dbtable: dbTable, columnName: 'Index', id:idArr.toString() },
|
||||
success: function(data, textStatus) {
|
||||
showModalOk ('Result', data );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user