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 = [
|
let triggerTypes = [
|
||||||
"Devices", "Plugins_Objects"
|
"Devices"
|
||||||
];
|
];
|
||||||
|
|
||||||
let operatorTypes = [
|
let operatorTypes = [
|
||||||
@@ -474,6 +474,7 @@ function createEditableDropdown(jsonPath, labelText, options, selectedValue, id)
|
|||||||
jsonPath: jsonPath,
|
jsonPath: jsonPath,
|
||||||
class: "form-control col-sm-8 col-xs-12"
|
class: "form-control col-sm-8 col-xs-12"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Add options to the select dropdown
|
// Add options to the select dropdown
|
||||||
$.each(options, function (_, option) {
|
$.each(options, function (_, option) {
|
||||||
@@ -788,6 +789,8 @@ function removeAction(wfIndex, actionIndex) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(actionIndex);
|
||||||
|
|
||||||
// Remove the specified condition
|
// Remove the specified condition
|
||||||
target.actions.splice(actionIndex, 1);
|
target.actions.splice(actionIndex, 1);
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,6 @@ class AppEvent_obj:
|
|||||||
"""Generic function to create triggers dynamically."""
|
"""Generic function to create triggers dynamically."""
|
||||||
trigger_name = f"trg_{event}_{table_name.lower()}"
|
trigger_name = f"trg_{event}_{table_name.lower()}"
|
||||||
|
|
||||||
|
|
||||||
query = f"""
|
query = f"""
|
||||||
CREATE TRIGGER IF NOT EXISTS "{trigger_name}"
|
CREATE TRIGGER IF NOT EXISTS "{trigger_name}"
|
||||||
AFTER {event.upper()} ON "{table_name}"
|
AFTER {event.upper()} ON "{table_name}"
|
||||||
@@ -130,8 +129,8 @@ class AppEvent_obj:
|
|||||||
SELECT 1 FROM AppEvents
|
SELECT 1 FROM AppEvents
|
||||||
WHERE AppEventProcessed = 0
|
WHERE AppEventProcessed = 0
|
||||||
AND ObjectType = '{table_name}'
|
AND ObjectType = '{table_name}'
|
||||||
AND ObjectGUID = {config['fields']['ObjectGUID']}
|
AND ObjectGUID = {manage_prefix(config['fields']['ObjectGUID'], event)}
|
||||||
AND ObjectStatus = {config['fields']['ObjectStatus']}
|
AND ObjectStatus = {manage_prefix(config['fields']['ObjectStatus'], event)}
|
||||||
AND AppEventType = '{event.lower()}'
|
AND AppEventType = '{event.lower()}'
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
@@ -156,15 +155,15 @@ class AppEvent_obj:
|
|||||||
DATETIME('now'),
|
DATETIME('now'),
|
||||||
FALSE,
|
FALSE,
|
||||||
'{table_name}',
|
'{table_name}',
|
||||||
{config['fields']['ObjectGUID']}, -- ObjectGUID
|
{manage_prefix(config['fields']['ObjectGUID'], event)}, -- ObjectGUID
|
||||||
{config['fields']['ObjectPrimaryID']}, -- ObjectPrimaryID
|
{manage_prefix(config['fields']['ObjectPrimaryID'], event)}, -- ObjectPrimaryID
|
||||||
{config['fields']['ObjectSecondaryID']}, -- ObjectSecondaryID
|
{manage_prefix(config['fields']['ObjectSecondaryID'], event)}, -- ObjectSecondaryID
|
||||||
{config['fields']['ObjectStatus']}, -- ObjectStatus
|
{manage_prefix(config['fields']['ObjectStatus'], event)}, -- ObjectStatus
|
||||||
{config['fields']['ObjectStatusColumn']}, -- ObjectStatusColumn
|
{manage_prefix(config['fields']['ObjectStatusColumn'], event)}, -- ObjectStatusColumn
|
||||||
{config['fields']['ObjectIsNew']}, -- ObjectIsNew
|
{manage_prefix(config['fields']['ObjectIsNew'], event)}, -- ObjectIsNew
|
||||||
{config['fields']['ObjectIsArchived']}, -- ObjectIsArchived
|
{manage_prefix(config['fields']['ObjectIsArchived'], event)}, -- ObjectIsArchived
|
||||||
{config['fields']['ObjectForeignKey']}, -- ObjectForeignKey
|
{manage_prefix(config['fields']['ObjectForeignKey'], event)}, -- ObjectForeignKey
|
||||||
{config['fields']['ObjectPlugin']}, -- ObjectForeignKey
|
{manage_prefix(config['fields']['ObjectPlugin'], event)}, -- ObjectForeignKey
|
||||||
'{event.lower()}'
|
'{event.lower()}'
|
||||||
);
|
);
|
||||||
END;
|
END;
|
||||||
@@ -177,3 +176,10 @@ class AppEvent_obj:
|
|||||||
def save(self):
|
def save(self):
|
||||||
# Commit changes
|
# Commit changes
|
||||||
self.db.commitDB()
|
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",
|
"name": "Sample Device Update Workflow",
|
||||||
"trigger": {
|
"trigger": {
|
||||||
@@ -36,14 +23,14 @@
|
|||||||
"logic": "OR",
|
"logic": "OR",
|
||||||
"conditions": [
|
"conditions": [
|
||||||
{
|
{
|
||||||
"field": "devSite",
|
"field": "devIsNew",
|
||||||
"operator": "equals",
|
"operator": "equals",
|
||||||
"value": "Home"
|
"value": "1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"field": "devName",
|
"field": "devName",
|
||||||
"operator": "contains",
|
"operator": "contains",
|
||||||
"value": "Motorola"
|
"value": "Google"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -55,33 +42,14 @@
|
|||||||
"type": "update_field",
|
"type": "update_field",
|
||||||
"field": "devIsNew",
|
"field": "devIsNew",
|
||||||
"value": "0"
|
"value": "0"
|
||||||
}
|
},
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Sample Plugin Object Workflow",
|
|
||||||
"trigger": {
|
|
||||||
"object_type": "Plugins_Objects",
|
|
||||||
"event_type": "create"
|
|
||||||
},
|
|
||||||
"conditions": [
|
|
||||||
{
|
{
|
||||||
"logic": "AND",
|
"type": "run_plugin",
|
||||||
"conditions": [
|
"plugin": "SMTP",
|
||||||
{
|
"params": {
|
||||||
"field": "Plugin",
|
"message": "New device from Google detected."
|
||||||
"operator": "equals",
|
}
|
||||||
"value": "ARPSCAN"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"field": "Status",
|
|
||||||
"operator": "equals",
|
|
||||||
"value": "missing-in-last-scan"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
],
|
|
||||||
"actions": [
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
Reference in New Issue
Block a user