Add ARE rule button for testing. Created author, name and chain_mode fields.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
* deleteFn: callback function to delete this rule.
|
||||
* updateFn: callback function to update this rule.
|
||||
*/
|
||||
AutoRunRuleForm = function(rule, deleteFn, updateFn) {
|
||||
AutoRunRuleForm = function(rule, deleteFn, updateFn, addFn) {
|
||||
|
||||
AutoRunRuleForm.superclass.constructor.call(this, {
|
||||
padding:'10 10 10 10',
|
||||
@@ -14,13 +14,32 @@ AutoRunRuleForm = function(rule, deleteFn, updateFn) {
|
||||
xtype: 'textfield',
|
||||
value: rule.name ? rule.name : '',
|
||||
fieldLabel: 'Name',
|
||||
}],
|
||||
},
|
||||
{
|
||||
xtype: 'displayfield',
|
||||
fieldLabel: 'Author',
|
||||
value: rule.author ? rule.author : 'anonymous',
|
||||
},{
|
||||
xtype: 'combo',
|
||||
fieldLabel: 'Chain Mode',
|
||||
store: ['sequential', 'nested-forward'],
|
||||
queryMode: 'local', // Use local data.
|
||||
triggerAction: 'all', // Show both options instead of just the default.
|
||||
editable: false, // Disable manual text input.
|
||||
forceSelection: true,
|
||||
value: rule.chain_mode ? rule.chain_mode : 'sequential'
|
||||
}
|
||||
],
|
||||
buttons: [{
|
||||
text: 'Delete',
|
||||
handler: deleteFn
|
||||
}, {
|
||||
text: 'Save',
|
||||
handler: updateFn
|
||||
},
|
||||
{
|
||||
text: 'Add New',
|
||||
handler: addFn
|
||||
}],
|
||||
border: false,
|
||||
closable: false
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
const areNotification = {
|
||||
"name": "Display an alert",
|
||||
"author": "mgeeky",
|
||||
"modules": [
|
||||
{
|
||||
"name": "alert_dialog",
|
||||
"condition": null,
|
||||
"options": {
|
||||
"text":"You've been BeEFed ;>"
|
||||
}
|
||||
}
|
||||
],
|
||||
"execution_order": [0],
|
||||
"execution_delay": [0],
|
||||
"chain_mode": "nested-forward"
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Asynchronously returns the currently active rules in an array.
|
||||
@@ -48,6 +66,17 @@ AutoRunTab = function() {
|
||||
}
|
||||
});
|
||||
|
||||
async function addRule() {
|
||||
const res = fetch(`/api/autorun/rule/add?token=${token}`, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify(areNotification)
|
||||
});
|
||||
if (!res.ok) {
|
||||
console.error(`Failed when adding a new rule with status ${res.status}.`);
|
||||
}
|
||||
}
|
||||
|
||||
async function updateRules() {
|
||||
const rules = await getCurrentRules(token);
|
||||
if (rules !== null) {
|
||||
@@ -55,7 +84,12 @@ AutoRunTab = function() {
|
||||
container.update(`<p>Number of Auto Run rules enabled: ${rules.length}.</p>`);
|
||||
|
||||
for (let i = 0; i < rules.length; i++) {
|
||||
ruleForm = new AutoRunRuleForm(rules[i], function() {console.log('delete')}, function() {console.log('update')});
|
||||
ruleForm = new AutoRunRuleForm(
|
||||
rules[i],
|
||||
function() {console.log('delete')},
|
||||
function() {console.log('update')},
|
||||
addRule
|
||||
);
|
||||
container.add(ruleForm);
|
||||
}
|
||||
container.doLayout();
|
||||
|
||||
Reference in New Issue
Block a user