mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
wf work
This commit is contained in:
@@ -1,55 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"name": "Sample Device Update Workflow",
|
|
||||||
"trigger": {
|
|
||||||
"object_type": "Devices",
|
|
||||||
"event_type": "update"
|
|
||||||
},
|
|
||||||
"conditions": [
|
|
||||||
{
|
|
||||||
"logic": "AND",
|
|
||||||
"conditions": [
|
|
||||||
{
|
|
||||||
"field": "devVendor",
|
|
||||||
"operator": "contains",
|
|
||||||
"value": "Google"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"field": "devIsNew",
|
|
||||||
"operator": "equals",
|
|
||||||
"value": "1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"logic": "OR",
|
|
||||||
"conditions": [
|
|
||||||
{
|
|
||||||
"field": "devIsNew",
|
|
||||||
"operator": "equals",
|
|
||||||
"value": "1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"field": "devName",
|
|
||||||
"operator": "contains",
|
|
||||||
"value": "Google"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"actions": [
|
|
||||||
{
|
|
||||||
"type": "update_field",
|
|
||||||
"field": "devIsNew",
|
|
||||||
"value": "0"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "run_plugin",
|
|
||||||
"plugin": "SMTP",
|
|
||||||
"params": {
|
|
||||||
"message": "New device from Google detected."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -37,7 +37,6 @@ export INSTALL_DIR=/app # Specify the installation directory here
|
|||||||
# DO NOT CHANGE ANYTHING BELOW THIS LINE!
|
# DO NOT CHANGE ANYTHING BELOW THIS LINE!
|
||||||
|
|
||||||
CONF_FILE="app.conf"
|
CONF_FILE="app.conf"
|
||||||
WF_FILE="workflows.json"
|
|
||||||
NGINX_CONF_FILE=netalertx.conf
|
NGINX_CONF_FILE=netalertx.conf
|
||||||
DB_FILE="app.db"
|
DB_FILE="app.db"
|
||||||
FULL_FILEDB_PATH="${INSTALL_DIR}/db/${DB_FILE}"
|
FULL_FILEDB_PATH="${INSTALL_DIR}/db/${DB_FILE}"
|
||||||
@@ -97,9 +96,8 @@ fi
|
|||||||
|
|
||||||
echo "[INSTALL] Copy starter ${DB_FILE} and ${CONF_FILE} if they don't exist"
|
echo "[INSTALL] Copy starter ${DB_FILE} and ${CONF_FILE} if they don't exist"
|
||||||
|
|
||||||
# Copy starter app.db, app.conf, workflows.json if they don't exist
|
# Copy starter app.db, app.conf if they don't exist
|
||||||
cp -na "${INSTALL_DIR}/back/${CONF_FILE}" "${INSTALL_DIR}/config/${CONF_FILE}"
|
cp -na "${INSTALL_DIR}/back/${CONF_FILE}" "${INSTALL_DIR}/config/${CONF_FILE}"
|
||||||
cp -na "${INSTALL_DIR}/back/${WF_FILE}" "${INSTALL_DIR}/config/${WF_FILE}"
|
|
||||||
cp -na "${INSTALL_DIR}/back/${DB_FILE}" "${FULL_FILEDB_PATH}"
|
cp -na "${INSTALL_DIR}/back/${DB_FILE}" "${FULL_FILEDB_PATH}"
|
||||||
|
|
||||||
# if custom variables not set we do not need to do anything
|
# if custom variables not set we do not need to do anything
|
||||||
|
|||||||
@@ -1524,10 +1524,11 @@ input[readonly] {
|
|||||||
margin:0px;
|
margin:0px;
|
||||||
align-items:center;
|
align-items:center;
|
||||||
border-radius:20px;
|
border-radius:20px;
|
||||||
width:190px; /* Don't change, smaller causes line break in network view */
|
/* width:190px; Don't change, smaller causes line break in network view */
|
||||||
display:flex;
|
/* display:flex; */
|
||||||
flex-direction:column;
|
flex-direction:column;
|
||||||
justify-content:center;
|
justify-content:center;
|
||||||
|
display: inline-grid;
|
||||||
}
|
}
|
||||||
.networkHelpIcon
|
.networkHelpIcon
|
||||||
{
|
{
|
||||||
@@ -1597,7 +1598,7 @@ input[readonly] {
|
|||||||
|
|
||||||
.spanNetworkTree {
|
.spanNetworkTree {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 135px;
|
/* width: 135px; */
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden !important;
|
overflow: hidden !important;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
@@ -1871,6 +1872,7 @@ input[readonly] {
|
|||||||
.workflows .add-button-wrap .button-container
|
.workflows .add-button-wrap .button-container
|
||||||
{
|
{
|
||||||
padding-bottom: 5px;
|
padding-bottom: 5px;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.workflows .actions-list {
|
.workflows .actions-list {
|
||||||
@@ -1901,12 +1903,21 @@ input[readonly] {
|
|||||||
color: #000;
|
color: #000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.workflows .button-container button
|
.workflows .button-container
|
||||||
{
|
{
|
||||||
display: inline-table;
|
display: contents;
|
||||||
|
text-align: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.workflows .panel:hover{
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.workflows .panel{
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
.workflows .bottom-buttons button
|
.workflows .bottom-buttons button
|
||||||
{
|
{
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
@@ -1914,8 +1925,8 @@ input[readonly] {
|
|||||||
|
|
||||||
.workflows .button-container
|
.workflows .button-container
|
||||||
{
|
{
|
||||||
padding-right: 5px !important;
|
padding-right: 0px !important;
|
||||||
padding-left: 5px !important;
|
padding-left: 0px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* .workflows .condition-list button
|
/* .workflows .condition-list button
|
||||||
@@ -1928,6 +1939,11 @@ input[readonly] {
|
|||||||
width:100%;
|
width:100%;
|
||||||
} */
|
} */
|
||||||
|
|
||||||
|
.workflows .workflow-card
|
||||||
|
{
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
.workflow-card .panel-title
|
.workflow-card .panel-title
|
||||||
{
|
{
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
|||||||
@@ -744,4 +744,5 @@
|
|||||||
.thresholdFormControl
|
.thresholdFormControl
|
||||||
{
|
{
|
||||||
color:#000;
|
color:#000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -743,6 +743,7 @@ function initializeDatatable (status) {
|
|||||||
'ordering' : true,
|
'ordering' : true,
|
||||||
'info' : true,
|
'info' : true,
|
||||||
'autoWidth' : false,
|
'autoWidth' : false,
|
||||||
|
'dom': '<"top"f>rtl<"bottom"ip><"clear">',
|
||||||
|
|
||||||
// Parameters
|
// Parameters
|
||||||
'pageLength' : tableRows,
|
'pageLength' : tableRows,
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -440,17 +440,15 @@ function askImportPastedConfig() {
|
|||||||
// Upload Settings Config
|
// Upload Settings Config
|
||||||
function UploadConfig()
|
function UploadConfig()
|
||||||
{
|
{
|
||||||
// alert("aaa")
|
|
||||||
|
|
||||||
appConf = $('#modal-input-textarea').val()
|
appConf = $('#modal-input-textarea').val()
|
||||||
// encode for import
|
// encode for import
|
||||||
appConfBase64 = btoa(appConf)
|
appConfBase64 = btoa(appConf)
|
||||||
|
|
||||||
// import
|
// import
|
||||||
$.post('php/server/query_replace_config.php', { config: appConfBase64 }, function(msg) {
|
$.post('php/server/query_replace_config.php', { base64data: appConfBase64, fileName: "app.conf" }, function(msg) {
|
||||||
console.log(msg);
|
console.log(msg);
|
||||||
// showMessage(msg);
|
// showMessage(msg);
|
||||||
write_notification(`[Maintenance] Settings imported from backup: ${msg}`, 'interrupt');
|
write_notification(`[Maintenance]: ${msg}`, 'interrupt');
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -465,7 +465,7 @@
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<script src="lib/treeviz/bundle.js"></script>
|
<script src="lib/treeviz/bundle.js"></script>
|
||||||
<script src="lib/treeviz/bundle.js.map"></script>
|
|
||||||
|
|
||||||
|
|
||||||
<script defer>
|
<script defer>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
ini_set('error_log', '../../log/app.php_errors.log'); // initializing the app.php_errors.log file for the maintenance section
|
ini_set('error_log', '../../log/app.php_errors.log'); // initializing the app.php_errors.log file for the maintenance section
|
||||||
require dirname(__FILE__).'/../templates/timezone.php';
|
require dirname(__FILE__).'/../templates/globals.php';
|
||||||
require dirname(__FILE__).'/db.php';
|
require dirname(__FILE__).'/db.php';
|
||||||
require dirname(__FILE__).'/util.php';
|
require dirname(__FILE__).'/util.php';
|
||||||
require dirname(__FILE__).'/../templates/language/lang.php';
|
require dirname(__FILE__).'/../templates/language/lang.php';
|
||||||
|
|||||||
@@ -13,21 +13,23 @@ require dirname(__FILE__).'/../server/init.php';
|
|||||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||||
// Get query string parameters ?file=settings_table.json&download=true
|
// Get query string parameters ?file=settings_table.json&download=true
|
||||||
$file = isset($_GET['file']) ? $_GET['file'] : null;
|
$file = isset($_GET['file']) ? $_GET['file'] : null;
|
||||||
$download = isset($_GET['download']) ? $_GET['download'] === 'true' : false;
|
$download = isset($_GET['download']) && $_GET['download'] === 'true';
|
||||||
|
|
||||||
// Check if file parameter is provided
|
// Check if file parameter is provided
|
||||||
if ($file) {
|
if ($file) {
|
||||||
// Define the folder where files are located
|
// Define the folder where files are located
|
||||||
$filePath = "/app/config/" . basename($file);
|
$filePath = "/app/config/" . basename($file);
|
||||||
|
|
||||||
// Check if the file exists
|
// Check if the file exists and is readable
|
||||||
if (file_exists($filePath)) {
|
if (file_exists($filePath) && is_readable($filePath)) {
|
||||||
// Handle download behavior
|
// Determine file extension
|
||||||
|
$extension = pathinfo($filePath, PATHINFO_EXTENSION);
|
||||||
|
|
||||||
if ($download) {
|
if ($download) {
|
||||||
// Force file download
|
// Force file download
|
||||||
header('Content-Description: File Transfer');
|
header('Content-Description: File Transfer');
|
||||||
header('Content-Type: application/octet-stream');
|
header('Content-Type: application/octet-stream');
|
||||||
header('Content-Disposition: attachment; filename="' . basename($filePath) . '"');
|
header('Content-Disposition: attachment; filename="' . basename($file) . '"');
|
||||||
header('Expires: 0');
|
header('Expires: 0');
|
||||||
header('Cache-Control: must-revalidate');
|
header('Cache-Control: must-revalidate');
|
||||||
header('Pragma: public');
|
header('Pragma: public');
|
||||||
@@ -35,19 +37,29 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
|||||||
readfile($filePath);
|
readfile($filePath);
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
// Display file content
|
// Serve file based on type
|
||||||
header('Content-Type: text/plain');
|
if ($extension === 'json') {
|
||||||
echo file_get_contents($filePath);
|
header('Content-Type: application/json');
|
||||||
|
echo json_encode(json_decode(file_get_contents($filePath), true), JSON_PRETTY_PRINT);
|
||||||
|
} else {
|
||||||
|
header('Content-Type: text/plain');
|
||||||
|
echo file_get_contents($filePath);
|
||||||
|
}
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// File not found response
|
// File not found response
|
||||||
http_response_code(404);
|
http_response_code(404);
|
||||||
|
header('Content-Type: application/json');
|
||||||
echo json_encode(["error" => "File not found"]);
|
echo json_encode(["error" => "File not found"]);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Missing file parameter response
|
// Missing file parameter response
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
|
header('Content-Type: application/json');
|
||||||
echo json_encode(["error" => "Missing 'file' parameter"]);
|
echo json_encode(["error" => "Missing 'file' parameter"]);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -8,16 +8,24 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
|||||||
require dirname(__FILE__).'/../server/init.php';
|
require dirname(__FILE__).'/../server/init.php';
|
||||||
// ---- IMPORTS ----
|
// ---- IMPORTS ----
|
||||||
|
|
||||||
global $fullConfPath;
|
global $configFolderPath;
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Handle incoming requests
|
// Handle incoming requests
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
// Access the 'config' parameter from the POST request
|
// Access the 'config' parameter from the POST request
|
||||||
$base64Data = $_POST['config'] ?? null;
|
$base64Data = $_POST['base64data'] ?? null;
|
||||||
|
|
||||||
if (!$base64Data) {
|
if (!$base64Data) {
|
||||||
$msg = "Missing 'config' parameter.";
|
$msg = "Missing 'base64data' parameter.";
|
||||||
|
echo $msg;
|
||||||
|
http_response_code(400); // Bad request
|
||||||
|
die($msg);
|
||||||
|
}
|
||||||
|
$fileName = $_POST['fileName'] ?? null;
|
||||||
|
|
||||||
|
if (!$fileName) {
|
||||||
|
$msg = "Missing 'fileName' parameter.";
|
||||||
echo $msg;
|
echo $msg;
|
||||||
http_response_code(400); // Bad request
|
http_response_code(400); // Bad request
|
||||||
die($msg);
|
die($msg);
|
||||||
@@ -33,15 +41,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
die($msg);
|
die($msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$fullPath = $configFolderPath.$fileName;
|
||||||
|
|
||||||
// Backup the original file
|
// Backup the original file
|
||||||
if (file_exists($fullConfPath)) {
|
if (file_exists($fullPath)) {
|
||||||
copy($fullConfPath, $fullConfPath . ".bak");
|
copy($fullPath, $fullPath . ".bak");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the new configuration
|
// Write the new configuration
|
||||||
$file = fopen($fullConfPath, "w");
|
$file = fopen($fullPath, "w");
|
||||||
if (!$file) {
|
if (!$file) {
|
||||||
$msg = "Unable to open file!";
|
$msg = "Unable to open file: ". $fullPath;
|
||||||
echo $msg;
|
echo $msg;
|
||||||
http_response_code(500); // Server error
|
http_response_code(500); // Server error
|
||||||
die($msg);
|
die($msg);
|
||||||
@@ -50,6 +60,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
fwrite($file, $input);
|
fwrite($file, $input);
|
||||||
fclose($file);
|
fclose($file);
|
||||||
|
|
||||||
echo "Configuration saved successfully.";
|
echo "Configuration file saved successfully: " .$fileName ;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
# Puche 2021 / 2022+ jokob jokob@duck.com GNU GPLv3
|
# Puche 2021 / 2022+ jokob jokob@duck.com GNU GPLv3
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
require dirname(__FILE__).'/../templates/timezone.php';
|
require dirname(__FILE__).'/../templates/globals.php';
|
||||||
require dirname(__FILE__).'/../templates/skinUI.php';
|
require dirname(__FILE__).'/../templates/skinUI.php';
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require dirname(__FILE__).'/../templates/timezone.php';
|
require dirname(__FILE__).'/../templates/globals.php';
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// check if authenticated
|
// check if authenticated
|
||||||
|
|||||||
@@ -1,17 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// ###################################
|
// ######################################################################
|
||||||
// ## TimeZone processing start
|
// ## Global constants and TimeZone processing
|
||||||
// ###################################
|
// ######################################################################
|
||||||
|
|
||||||
$configFolderPath = dirname(__FILE__)."/../../../config/";
|
$configFolderPath = "/app/config/";
|
||||||
$config_file = "app.conf";
|
|
||||||
$logFolderPath = "/app/log/";
|
$logFolderPath = "/app/log/";
|
||||||
|
|
||||||
|
$config_file = "app.conf";
|
||||||
|
$workflows_file = "workflows.json";
|
||||||
|
|
||||||
$log_file = "app_front.log";
|
$log_file = "app_front.log";
|
||||||
$default_tz = "Europe/Berlin";
|
$default_tz = "Europe/Berlin";
|
||||||
|
|
||||||
|
|
||||||
$fullConfPath = $configFolderPath.$config_file;
|
$fullConfPath = $configFolderPath.$config_file;
|
||||||
|
$fullWorkflowsPath = $configFolderPath.$workflows_file;
|
||||||
|
|
||||||
$config_file_lines = file($fullConfPath);
|
$config_file_lines = file($fullConfPath);
|
||||||
$config_file_lines_timezone = array_values(preg_grep('/^TIMEZONE\s.*/', $config_file_lines));
|
$config_file_lines_timezone = array_values(preg_grep('/^TIMEZONE\s.*/', $config_file_lines));
|
||||||
@@ -44,7 +48,7 @@ date_default_timezone_set($timeZone);
|
|||||||
$date = new DateTime("now", new DateTimeZone($timeZone) );
|
$date = new DateTime("now", new DateTimeZone($timeZone) );
|
||||||
$timestamp = $date->format('Y-m-d_H-i-s');
|
$timestamp = $date->format('Y-m-d_H-i-s');
|
||||||
|
|
||||||
// ###################################
|
// ######################################################################
|
||||||
// ## TimeZone processing end
|
// ## Global constants and TimeZone processing
|
||||||
// ###################################
|
// ######################################################################
|
||||||
|
|
||||||
@@ -5,19 +5,19 @@
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
<section class="content workflows col-sm-12">
|
<section class="content workflows col-sm-12 col-xs-12">
|
||||||
<div id="workflowContainerWrap" class="bg-grey-dark color-palette col-sm-12 box-default box-info ">
|
<div id="workflowContainerWrap" class="bg-grey-dark color-palette col-sm-12 col-xs-12 box-default box-info ">
|
||||||
<div id="workflowContainer"></div>
|
<div id="workflowContainer"></div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div id="buttons" class="bottom-buttons col-sm-12">
|
<div id="buttons" class="bottom-buttons col-sm-12 col-xs-12">
|
||||||
<div class="add-workflow col-sm-12">
|
<div class="add-workflow col-sm-12 col-xs-12">
|
||||||
<button type="button" class="btn btn-primary add-workflow-btn col-sm-12" id="save">
|
<button type="button" class="btn btn-primary add-workflow-btn col-sm-12 col-xs-12" id="save">
|
||||||
<?= lang('Gen_Add');?>
|
<?= lang('Gen_Add');?>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="save-workflows col-sm-12">
|
<div class="save-workflows col-sm-12 col-xs-12">
|
||||||
<button type="button" class="btn btn-primary col-sm-12" id="save" onclick="saveWorkflows()">
|
<button type="button" class="btn btn-primary col-sm-12 col-xs-12" id="save" onclick="saveWorkflows()">
|
||||||
<?= lang('DevDetail_button_Save');?>
|
<?= lang('DevDetail_button_Save');?>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -46,7 +46,7 @@ let operatorTypes = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
let actionTypes = [
|
let actionTypes = [
|
||||||
"update_field", "run_plugin", "delete_device"
|
"update_field", "delete_device"
|
||||||
];
|
];
|
||||||
|
|
||||||
// --------------------------------------
|
// --------------------------------------
|
||||||
@@ -57,13 +57,23 @@ function getData() {
|
|||||||
|
|
||||||
getSetting()
|
getSetting()
|
||||||
|
|
||||||
$.get('php/server/query_json.php?file=workflows.json', function (res) {
|
$.get('php/server/query_json.php?file=workflows.json')
|
||||||
|
.done(function (res) {
|
||||||
workflows = res;
|
workflows = res;
|
||||||
|
console.log("here workflows");
|
||||||
console.log(workflows);
|
console.log(workflows);
|
||||||
|
|
||||||
updateWorkflowsJson(workflows);
|
updateWorkflowsJson(workflows);
|
||||||
renderWorkflows();
|
renderWorkflows();
|
||||||
hideSpinner();
|
})
|
||||||
|
.fail(function (jqXHR, textStatus, errorThrown) {
|
||||||
|
console.warn("Failed to load workflows.json:", textStatus, errorThrown);
|
||||||
|
workflows = []; // Set a default empty array to prevent crashes
|
||||||
|
updateWorkflowsJson(workflows);
|
||||||
|
renderWorkflows();
|
||||||
|
})
|
||||||
|
.always(function () {
|
||||||
|
hideSpinner(); // Ensure the spinner is hidden in all cases
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,21 +101,21 @@ function renderWorkflows() {
|
|||||||
function generateWorkflowUI(wf, wfIndex) {
|
function generateWorkflowUI(wf, wfIndex) {
|
||||||
|
|
||||||
let $wfContainer = $("<div>", {
|
let $wfContainer = $("<div>", {
|
||||||
class: "workflow-card col-sm-12 col-sx-12",
|
class: "workflow-card panel col-sm-12 col-sx-12",
|
||||||
id: `wf-${wfIndex}-container`
|
id: `wf-${wfIndex}-container`
|
||||||
});
|
});
|
||||||
|
|
||||||
// Workflow Name
|
// Workflow Name
|
||||||
let $wfLinkWrap = $("<div>",
|
let $wfLinkWrap = $("<div>",
|
||||||
{
|
{
|
||||||
class: "box box-solid box-primary ",
|
class: " ",
|
||||||
id: `wf-${wfIndex}-header`
|
id: `wf-${wfIndex}-header`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
let $wfHeaderLink = $("<a>",
|
let $wfHeaderLink = $("<a>",
|
||||||
{
|
{
|
||||||
"class": "",
|
"class": "pointer ",
|
||||||
"data-toggle": "collapse",
|
"data-toggle": "collapse",
|
||||||
"data-parent": "#workflowContainer",
|
"data-parent": "#workflowContainer",
|
||||||
"aria-expanded": false,
|
"aria-expanded": false,
|
||||||
@@ -131,7 +141,7 @@ function generateWorkflowUI(wf, wfIndex) {
|
|||||||
|
|
||||||
|
|
||||||
let $wfCollapsiblePanel = $("<div>", {
|
let $wfCollapsiblePanel = $("<div>", {
|
||||||
class: `box panel-collapse collapse ${isOpen ? 'in' : ''}`,
|
class: ` panel-collapse collapse ${isOpen ? 'in' : ''}`,
|
||||||
id: `wf-${wfIndex}-collapsible-panel`
|
id: `wf-${wfIndex}-collapsible-panel`
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -185,7 +195,11 @@ function generateWorkflowUI(wf, wfIndex) {
|
|||||||
}
|
}
|
||||||
).text("Conditions:")
|
).text("Conditions:")
|
||||||
|
|
||||||
let $conditionsContainer = $("<div>").append($conditionsTitle);
|
let $conditionsContainer = $("<div>",
|
||||||
|
{
|
||||||
|
class: "col-sm-12 col-sx-12"
|
||||||
|
}
|
||||||
|
).append($conditionsTitle);
|
||||||
|
|
||||||
$conditionsContainer.append(renderConditions(wfIndex, `[${wfIndex}]`, 0, wf.conditions));
|
$conditionsContainer.append(renderConditions(wfIndex, `[${wfIndex}]`, 0, wf.conditions));
|
||||||
|
|
||||||
@@ -229,7 +243,7 @@ function generateWorkflowUI(wf, wfIndex) {
|
|||||||
`[${wfIndex}].actions[${actionIndex}].type`,
|
`[${wfIndex}].actions[${actionIndex}].type`,
|
||||||
"Type",
|
"Type",
|
||||||
actionTypes,
|
actionTypes,
|
||||||
action.field,
|
action.type,
|
||||||
`wf-${wfIndex}-actionIndex-${actionIndex}-type`
|
`wf-${wfIndex}-actionIndex-${actionIndex}-type`
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -255,8 +269,8 @@ function generateWorkflowUI(wf, wfIndex) {
|
|||||||
class: "fa-solid fa-trash"
|
class: "fa-solid fa-trash"
|
||||||
});
|
});
|
||||||
|
|
||||||
let $actionRemoveButton = $("<button>", {
|
let $actionRemoveButton = $("<div>", {
|
||||||
class: "btn btn-secondary remove-action btn-orange",
|
class: "pointer remove-action ",
|
||||||
actionIndex: actionIndex,
|
actionIndex: actionIndex,
|
||||||
wfIndex: wfIndex
|
wfIndex: wfIndex
|
||||||
})
|
})
|
||||||
@@ -277,8 +291,8 @@ function generateWorkflowUI(wf, wfIndex) {
|
|||||||
let $actionAddIcon = $("<i>", {
|
let $actionAddIcon = $("<i>", {
|
||||||
class: "fa-solid fa-plus"
|
class: "fa-solid fa-plus"
|
||||||
});
|
});
|
||||||
let $actionAddButton = $("<button>", {
|
let $actionAddButton = $("<div>", {
|
||||||
class : "btn btn-secondary add-action",
|
class : "pointer add-action",
|
||||||
lastActionIndex : lastActionIndex,
|
lastActionIndex : lastActionIndex,
|
||||||
wfIndex: wfIndex
|
wfIndex: wfIndex
|
||||||
}).append($actionAddIcon).append("Add Action")
|
}).append($actionAddIcon).append("Add Action")
|
||||||
@@ -293,8 +307,8 @@ function generateWorkflowUI(wf, wfIndex) {
|
|||||||
class: "fa-solid fa-trash"
|
class: "fa-solid fa-trash"
|
||||||
});
|
});
|
||||||
|
|
||||||
let $wfRemoveButton = $("<button>", {
|
let $wfRemoveButton = $("<div>", {
|
||||||
class: "btn btn-secondary remove-wf",
|
class: "pointer remove-wf",
|
||||||
wfIndex: wfIndex
|
wfIndex: wfIndex
|
||||||
})
|
})
|
||||||
.append($wfRemoveIcon) // Add icon
|
.append($wfRemoveIcon) // Add icon
|
||||||
@@ -404,8 +418,8 @@ function renderConditions(wfIndex, parentIndexPath, conditionGroupsIndex, condit
|
|||||||
let $conditionRemoveButtonIcon = $("<i>", {
|
let $conditionRemoveButtonIcon = $("<i>", {
|
||||||
class: "fa-solid fa-trash"
|
class: "fa-solid fa-trash"
|
||||||
});
|
});
|
||||||
let $conditionRemoveButton = $("<button>", {
|
let $conditionRemoveButton = $("<div>", {
|
||||||
class : "btn btn-secondary remove-condition ",
|
class : "pointer remove-condition ",
|
||||||
conditionIndex : conditionIndex,
|
conditionIndex : conditionIndex,
|
||||||
wfIndex: wfIndex,
|
wfIndex: wfIndex,
|
||||||
parentIndexPath: parentIndexPath
|
parentIndexPath: parentIndexPath
|
||||||
@@ -431,8 +445,8 @@ function renderConditions(wfIndex, parentIndexPath, conditionGroupsIndex, condit
|
|||||||
let $conditionAddIcon = $("<i>", {
|
let $conditionAddIcon = $("<i>", {
|
||||||
class: "fa-solid fa-plus"
|
class: "fa-solid fa-plus"
|
||||||
});
|
});
|
||||||
let $conditionAddButton = $("<button>", {
|
let $conditionAddButton = $("<div>", {
|
||||||
class: "btn btn-secondary add-condition col-sx-12",
|
class: "pointer add-condition col-sx-12",
|
||||||
wfIndex: wfIndex,
|
wfIndex: wfIndex,
|
||||||
parentIndexPath: parentIndexPath
|
parentIndexPath: parentIndexPath
|
||||||
}).append($conditionAddIcon).append("Add Condition");
|
}).append($conditionAddIcon).append("Add Condition");
|
||||||
@@ -443,8 +457,8 @@ function renderConditions(wfIndex, parentIndexPath, conditionGroupsIndex, condit
|
|||||||
let $conditionGroupRemoveIcon = $("<i>", {
|
let $conditionGroupRemoveIcon = $("<i>", {
|
||||||
class: "fa-solid fa-trash"
|
class: "fa-solid fa-trash"
|
||||||
});
|
});
|
||||||
let $conditionGroupRemoveButton = $("<button>", {
|
let $conditionGroupRemoveButton = $("<div>", {
|
||||||
class: "btn btn-secondary remove-condition-group col-sx-12",
|
class: "pointer remove-condition-group col-sx-12",
|
||||||
lastConditionIndex: lastConditionIndex,
|
lastConditionIndex: lastConditionIndex,
|
||||||
wfIndex: wfIndex,
|
wfIndex: wfIndex,
|
||||||
parentIndexPath: parentIndexPath
|
parentIndexPath: parentIndexPath
|
||||||
@@ -461,11 +475,11 @@ function renderConditions(wfIndex, parentIndexPath, conditionGroupsIndex, condit
|
|||||||
let $conditionsGroupAddIcon = $("<i>", {
|
let $conditionsGroupAddIcon = $("<i>", {
|
||||||
class: "fa-solid fa-plus"
|
class: "fa-solid fa-plus"
|
||||||
});
|
});
|
||||||
let $conditionsGroupAddButton = $("<button>", {
|
let $conditionsGroupAddButton = $("<div>", {
|
||||||
class: "btn btn-secondary add-condition-group col-sx-12",
|
class: "pointer add-condition-group col-sx-12",
|
||||||
wfIndex: wfIndex,
|
wfIndex: wfIndex,
|
||||||
parentIndexPath: parentIndexPath
|
parentIndexPath: parentIndexPath
|
||||||
}).append($conditionsGroupAddIcon).append("Add Condition Group");
|
}).append($conditionsGroupAddIcon).append("Add Group");
|
||||||
$conditionsGroupAddWrap.append($conditionsGroupAddButton);
|
$conditionsGroupAddWrap.append($conditionsGroupAddButton);
|
||||||
|
|
||||||
$addButtonWrap.append($conditionsGroupAddWrap);
|
$addButtonWrap.append($conditionsGroupAddWrap);
|
||||||
@@ -910,6 +924,21 @@ function getEmptyWorkflowJson()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------
|
||||||
|
// Save workflows JSON
|
||||||
|
function saveWorkflows()
|
||||||
|
{
|
||||||
|
// encode for import
|
||||||
|
appConfBase64 = btoa(JSON.stringify(getWorkflowsJson()))
|
||||||
|
|
||||||
|
// import
|
||||||
|
$.post('php/server/query_replace_config.php', { base64data: appConfBase64, fileName: "workflows.json" }, function(msg) {
|
||||||
|
console.log(msg);
|
||||||
|
// showMessage(msg);
|
||||||
|
write_notification(`[WF]: ${msg}`, 'interrupt');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------
|
// ---------------------------------------------------
|
||||||
// Event listeners
|
// Event listeners
|
||||||
$(document).on("click", ".add-workflow-btn", function () {
|
$(document).on("click", ".add-workflow-btn", function () {
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class WorkflowManager:
|
|||||||
|
|
||||||
if evaluator.evaluate(trigger): # If any group evaluates to True
|
if evaluator.evaluate(trigger): # If any group evaluates to True
|
||||||
|
|
||||||
mylog('none', [f"[WF] Workflow {workflow["name"]} will be executed - conditions were evalueted as TRUE"])
|
mylog('none', [f"[WF] Workflow {workflow["name"]} will be executed - conditions were evaluated as TRUE"])
|
||||||
mylog('debug', [f"[WF] Workflow condition_group: {condition_group}"])
|
mylog('debug', [f"[WF] Workflow condition_group: {condition_group}"])
|
||||||
|
|
||||||
self.execute_actions(workflow["actions"], trigger)
|
self.execute_actions(workflow["actions"], trigger)
|
||||||
|
|||||||
Reference in New Issue
Block a user