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:
@@ -1858,9 +1858,9 @@ input[readonly] {
|
|||||||
margin: 2px;
|
margin: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.workflows button
|
.button-container button
|
||||||
{
|
{
|
||||||
/* width:100%; */
|
width:100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#workflowContainerWrap
|
#workflowContainerWrap
|
||||||
|
|||||||
@@ -220,6 +220,15 @@ function generateWorkflowUI(wf, wfIndex) {
|
|||||||
$actionEl.append($fieldDropdown);
|
$actionEl.append($fieldDropdown);
|
||||||
$actionEl.append($actionValueInput);
|
$actionEl.append($actionValueInput);
|
||||||
|
|
||||||
|
// add actions group button
|
||||||
|
let $actionRemoveButton = $("<button>", {
|
||||||
|
class : "btn btn-secondary remove-action",
|
||||||
|
actionIndex : actionIndex,
|
||||||
|
wfIndex: wfIndex
|
||||||
|
}).text("Remove Action")
|
||||||
|
|
||||||
|
$actionEl.append($actionRemoveButton);
|
||||||
|
|
||||||
$actionsContainer.append($actionEl);
|
$actionsContainer.append($actionEl);
|
||||||
|
|
||||||
lastActionIndex = actionIndex
|
lastActionIndex = actionIndex
|
||||||
@@ -317,6 +326,7 @@ function renderConditions(wfIndex, parentIndexPath, conditionGroupsIndex, condit
|
|||||||
$conditionItem.append($operatorDropdown); // Append operator dropdown
|
$conditionItem.append($operatorDropdown); // Append operator dropdown
|
||||||
$conditionItem.append($editableInput); // Append editable input for condition value
|
$conditionItem.append($editableInput); // Append editable input for condition value
|
||||||
|
|
||||||
|
let $conditionRemoveButtonWrap = $("<div>", { class: "button-container col-sm-12 col-sx-12" });
|
||||||
let $conditionRemoveButton = $("<button>", {
|
let $conditionRemoveButton = $("<button>", {
|
||||||
class : "btn btn-secondary remove-condition",
|
class : "btn btn-secondary remove-condition",
|
||||||
lastConditionIndex : lastConditionIndex,
|
lastConditionIndex : lastConditionIndex,
|
||||||
@@ -324,7 +334,8 @@ function renderConditions(wfIndex, parentIndexPath, conditionGroupsIndex, condit
|
|||||||
parentIndexPath: parentIndexPath
|
parentIndexPath: parentIndexPath
|
||||||
}).text("Remove Condition")
|
}).text("Remove Condition")
|
||||||
|
|
||||||
$conditionItem.append($conditionRemoveButton);
|
$conditionRemoveButtonWrap .append($conditionRemoveButton);
|
||||||
|
$conditionItem.append($conditionRemoveButtonWrap);
|
||||||
|
|
||||||
$conditionList.append($conditionItem);
|
$conditionList.append($conditionItem);
|
||||||
}
|
}
|
||||||
@@ -332,38 +343,47 @@ function renderConditions(wfIndex, parentIndexPath, conditionGroupsIndex, condit
|
|||||||
lastConditionIndex = conditionIndex
|
lastConditionIndex = conditionIndex
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let $buttonWrap = $("<div>", {
|
||||||
|
class: "button-wrap col-sm-12 col-sx-12"
|
||||||
|
});
|
||||||
|
|
||||||
if (conditionGroupsIndex != 0) {
|
if (conditionGroupsIndex != 0) {
|
||||||
// add conditions group button
|
// Add Condition button
|
||||||
|
let $conditionAddWrap = $("<div>", { class: "button-container col-sm-6 col-sx-12" });
|
||||||
let $conditionAddButton = $("<button>", {
|
let $conditionAddButton = $("<button>", {
|
||||||
class : "btn btn-secondary add-condition",
|
class: "btn btn-secondary add-condition col-sx-12",
|
||||||
lastConditionIndex: lastConditionIndex,
|
lastConditionIndex: lastConditionIndex,
|
||||||
wfIndex: wfIndex,
|
wfIndex: wfIndex,
|
||||||
parentIndexPath: parentIndexPath
|
parentIndexPath: parentIndexPath
|
||||||
}).text("Add Condition")
|
}).text("Add Condition");
|
||||||
|
$conditionAddWrap.append($conditionAddButton);
|
||||||
|
|
||||||
// add conditions group button
|
// Remove Condition Group button
|
||||||
|
let $conditionGroupRemoveWrap = $("<div>", { class: "button-container col-sm-6 col-sx-12" });
|
||||||
let $conditionGroupRemoveButton = $("<button>", {
|
let $conditionGroupRemoveButton = $("<button>", {
|
||||||
class : "btn btn-secondary remove-condition-group",
|
class: "btn btn-secondary remove-condition-group col-sx-12",
|
||||||
lastConditionIndex: lastConditionIndex,
|
lastConditionIndex: lastConditionIndex,
|
||||||
wfIndex: wfIndex,
|
wfIndex: wfIndex,
|
||||||
parentIndexPath: parentIndexPath
|
parentIndexPath: parentIndexPath
|
||||||
}).text("Remove Condition Group")
|
}).text("Remove Condition Group");
|
||||||
|
$conditionGroupRemoveWrap.append($conditionGroupRemoveButton);
|
||||||
|
|
||||||
$conditionList.append($conditionAddButton);
|
$buttonWrap.append($conditionAddWrap);
|
||||||
$conditionList.append($conditionGroupRemoveButton);
|
$buttonWrap.append($conditionGroupRemoveWrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add Condition Group button
|
||||||
// add conditions group button
|
let $conditionsGroupAddWrap = $("<div>", { class: "button-container col-sm-12 col-sx-12" });
|
||||||
let $conditionsGroupAddButton = $("<button>", {
|
let $conditionsGroupAddButton = $("<button>", {
|
||||||
class : "btn btn-secondary add-condition-group",
|
class: "btn btn-secondary add-condition-group col-sx-12",
|
||||||
wfIndex: wfIndex,
|
wfIndex: wfIndex,
|
||||||
parentIndexPath: parentIndexPath
|
parentIndexPath: parentIndexPath
|
||||||
}).text("Add Condition Group")
|
}).text("Add Condition Group");
|
||||||
|
$conditionsGroupAddWrap.append($conditionsGroupAddButton);
|
||||||
|
|
||||||
|
$buttonWrap.append($conditionsGroupAddWrap);
|
||||||
|
$conditionList.append($buttonWrap);
|
||||||
|
|
||||||
$conditionList.append($conditionsGroupAddButton);
|
|
||||||
|
|
||||||
return $conditionList;
|
return $conditionList;
|
||||||
}
|
}
|
||||||
@@ -652,6 +672,32 @@ function removeCondition(wfIndex, parentIndexPath, lastConditionIndex) {
|
|||||||
renderWorkflows();
|
renderWorkflows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeAction(wfIndex, actionIndex) {
|
||||||
|
if (!actionIndex || actionIndex === undefined) return;
|
||||||
|
|
||||||
|
// // Navigate to the target nested object
|
||||||
|
// let target = getNestedObject(workflows, parentIndexPath);
|
||||||
|
|
||||||
|
// console.log("Target before removal:", target);
|
||||||
|
|
||||||
|
// if (!target || !Array.isArray(target.conditions)) {
|
||||||
|
// console.error("❌ Invalid path or conditions array missing:", parentIndexPath);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Remove the specified condition
|
||||||
|
// target.conditions.splice(lastConditionIndex, 1);
|
||||||
|
|
||||||
|
// // 🔥 Ensure the workflows object is updated in memory
|
||||||
|
// workflows[wfIndex] = { ...workflows[wfIndex] };
|
||||||
|
|
||||||
|
// // 🔥 Update the cache with the modified workflows object
|
||||||
|
// setCache("workflows", JSON.stringify(workflows));
|
||||||
|
|
||||||
|
// // Re-render the UI
|
||||||
|
// renderWorkflows();
|
||||||
|
}
|
||||||
|
|
||||||
function removeConditionGroup(wfIndex, parentIndexPath) {
|
function removeConditionGroup(wfIndex, parentIndexPath) {
|
||||||
if (!parentIndexPath) return;
|
if (!parentIndexPath) return;
|
||||||
|
|
||||||
@@ -739,6 +785,14 @@ $(document).on("click", ".remove-condition", function () {
|
|||||||
removeCondition(wfIndex, parentIndexPath, lastConditionIndex);
|
removeCondition(wfIndex, parentIndexPath, lastConditionIndex);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Event Listeners for Removing Actions
|
||||||
|
$(document).on("click", ".remove-action", function () {
|
||||||
|
let wfIndex = $(this).attr("wfindex");
|
||||||
|
let actionIndex = $(this).attr("actionIndex");
|
||||||
|
|
||||||
|
removeAction(wfIndex, actionIndex);
|
||||||
|
});
|
||||||
|
|
||||||
// Event Listeners for Removing Condition Groups
|
// Event Listeners for Removing Condition Groups
|
||||||
$(document).on("click", ".remove-condition-group", function () {
|
$(document).on("click", ".remove-condition-group", function () {
|
||||||
let wfIndex = $(this).attr("wfindex");
|
let wfIndex = $(this).attr("wfindex");
|
||||||
|
|||||||
Reference in New Issue
Block a user