mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 01:26:11 -08:00
wf work
This commit is contained in:
@@ -51,31 +51,5 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Sample Plugin Object Workflow",
|
||||
"trigger": {
|
||||
"object_type": "Plugins_Objects",
|
||||
"event_type": "create"
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"logic": "AND",
|
||||
"conditions": [
|
||||
{
|
||||
"field": "Plugin",
|
||||
"operator": "equals",
|
||||
"value": "ARPSCAN"
|
||||
},
|
||||
{
|
||||
"field": "Status",
|
||||
"operator": "equals",
|
||||
"value": "missing-in-last-scan"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -38,7 +38,7 @@ let fieldOptions = [
|
||||
];
|
||||
|
||||
let triggerTypes = [
|
||||
"Devices", "Plugins_Objects"
|
||||
"Devices"
|
||||
];
|
||||
|
||||
let operatorTypes = [
|
||||
@@ -475,6 +475,7 @@ function createEditableDropdown(jsonPath, labelText, options, selectedValue, id)
|
||||
class: "form-control col-sm-8 col-xs-12"
|
||||
});
|
||||
|
||||
|
||||
// Add options to the select dropdown
|
||||
$.each(options, function (_, option) {
|
||||
let $option = $("<option>", { value: option }).text(option);
|
||||
@@ -788,6 +789,8 @@ function removeAction(wfIndex, actionIndex) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(actionIndex);
|
||||
|
||||
// Remove the specified condition
|
||||
target.actions.splice(actionIndex, 1);
|
||||
|
||||
|
||||
@@ -122,7 +122,6 @@ class AppEvent_obj:
|
||||
"""Generic function to create triggers dynamically."""
|
||||
trigger_name = f"trg_{event}_{table_name.lower()}"
|
||||
|
||||
|
||||
query = f"""
|
||||
CREATE TRIGGER IF NOT EXISTS "{trigger_name}"
|
||||
AFTER {event.upper()} ON "{table_name}"
|
||||
@@ -130,8 +129,8 @@ class AppEvent_obj:
|
||||
SELECT 1 FROM AppEvents
|
||||
WHERE AppEventProcessed = 0
|
||||
AND ObjectType = '{table_name}'
|
||||
AND ObjectGUID = {config['fields']['ObjectGUID']}
|
||||
AND ObjectStatus = {config['fields']['ObjectStatus']}
|
||||
AND ObjectGUID = {manage_prefix(config['fields']['ObjectGUID'], event)}
|
||||
AND ObjectStatus = {manage_prefix(config['fields']['ObjectStatus'], event)}
|
||||
AND AppEventType = '{event.lower()}'
|
||||
)
|
||||
BEGIN
|
||||
@@ -156,15 +155,15 @@ class AppEvent_obj:
|
||||
DATETIME('now'),
|
||||
FALSE,
|
||||
'{table_name}',
|
||||
{config['fields']['ObjectGUID']}, -- ObjectGUID
|
||||
{config['fields']['ObjectPrimaryID']}, -- ObjectPrimaryID
|
||||
{config['fields']['ObjectSecondaryID']}, -- ObjectSecondaryID
|
||||
{config['fields']['ObjectStatus']}, -- ObjectStatus
|
||||
{config['fields']['ObjectStatusColumn']}, -- ObjectStatusColumn
|
||||
{config['fields']['ObjectIsNew']}, -- ObjectIsNew
|
||||
{config['fields']['ObjectIsArchived']}, -- ObjectIsArchived
|
||||
{config['fields']['ObjectForeignKey']}, -- ObjectForeignKey
|
||||
{config['fields']['ObjectPlugin']}, -- ObjectForeignKey
|
||||
{manage_prefix(config['fields']['ObjectGUID'], event)}, -- ObjectGUID
|
||||
{manage_prefix(config['fields']['ObjectPrimaryID'], event)}, -- ObjectPrimaryID
|
||||
{manage_prefix(config['fields']['ObjectSecondaryID'], event)}, -- ObjectSecondaryID
|
||||
{manage_prefix(config['fields']['ObjectStatus'], event)}, -- ObjectStatus
|
||||
{manage_prefix(config['fields']['ObjectStatusColumn'], event)}, -- ObjectStatusColumn
|
||||
{manage_prefix(config['fields']['ObjectIsNew'], event)}, -- ObjectIsNew
|
||||
{manage_prefix(config['fields']['ObjectIsArchived'], event)}, -- ObjectIsArchived
|
||||
{manage_prefix(config['fields']['ObjectForeignKey'], event)}, -- ObjectForeignKey
|
||||
{manage_prefix(config['fields']['ObjectPlugin'], event)}, -- ObjectForeignKey
|
||||
'{event.lower()}'
|
||||
);
|
||||
END;
|
||||
@@ -177,3 +176,10 @@ class AppEvent_obj:
|
||||
def save(self):
|
||||
# Commit changes
|
||||
self.db.commitDB()
|
||||
|
||||
# Manage prefixes of column names
|
||||
def manage_prefix(field, event):
|
||||
if event == "delete":
|
||||
return field.replace("NEW.", "OLD.")
|
||||
return field
|
||||
|
||||
|
||||
@@ -1,17 +1,4 @@
|
||||
[
|
||||
{
|
||||
"name": "Empty Workflow",
|
||||
"trigger": {
|
||||
"object_type": "",
|
||||
"event_type": ""
|
||||
},
|
||||
"conditions": [
|
||||
|
||||
],
|
||||
"actions": [
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Sample Device Update Workflow",
|
||||
"trigger": {
|
||||
@@ -36,14 +23,14 @@
|
||||
"logic": "OR",
|
||||
"conditions": [
|
||||
{
|
||||
"field": "devSite",
|
||||
"field": "devIsNew",
|
||||
"operator": "equals",
|
||||
"value": "Home"
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"field": "devName",
|
||||
"operator": "contains",
|
||||
"value": "Motorola"
|
||||
"value": "Google"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -55,33 +42,14 @@
|
||||
"type": "update_field",
|
||||
"field": "devIsNew",
|
||||
"value": "0"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Sample Plugin Object Workflow",
|
||||
"trigger": {
|
||||
"object_type": "Plugins_Objects",
|
||||
"event_type": "create"
|
||||
},
|
||||
"conditions": [
|
||||
},
|
||||
{
|
||||
"logic": "AND",
|
||||
"conditions": [
|
||||
{
|
||||
"field": "Plugin",
|
||||
"operator": "equals",
|
||||
"value": "ARPSCAN"
|
||||
},
|
||||
{
|
||||
"field": "Status",
|
||||
"operator": "equals",
|
||||
"value": "missing-in-last-scan"
|
||||
}
|
||||
]
|
||||
"type": "run_plugin",
|
||||
"plugin": "SMTP",
|
||||
"params": {
|
||||
"message": "New device from Google detected."
|
||||
}
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
]
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user