[Pkg-mozext-commits] [requestpolicy] 06/100: Display temporary rules alongside user rules in the manage policies page. Display extra column indicating source of each rule.
David Prévot
taffit at moszumanska.debian.org
Fri Dec 12 22:56:46 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository requestpolicy.
commit 2fa2bb5dca557b9ec4456f604e3c0ee9fd535927
Author: Christopher Bura <christopher.bura at gmail.com>
Date: Mon Sep 1 04:10:44 2014 -0400
Display temporary rules alongside user rules in the manage policies page. Display extra column indicating source of each rule.
---
src/content/settings/yourpolicy.html | 6 ++++
src/content/settings/yourpolicy.js | 58 ++++++++++++++++++++----------------
2 files changed, 38 insertions(+), 26 deletions(-)
diff --git a/src/content/settings/yourpolicy.html b/src/content/settings/yourpolicy.html
index af3c531..5dbcd17 100644
--- a/src/content/settings/yourpolicy.html
+++ b/src/content/settings/yourpolicy.html
@@ -46,11 +46,15 @@
<col class="type"/>
<col class="origin"/>
<col class="destination"/>
+ <col class="source"/>
+ <col class="remove"/>
</colgroup>
<tr>
<th data-string="type"></th>
<th data-string="origin"></th>
<th data-string="destination"></th>
+ <th data-string="source"></th>
+ <th data-string="remove"></th>
</tr>
</table>
</div>
@@ -60,6 +64,8 @@
<col class="type"/>
<col class="origin"/>
<col class="destination"/>
+ <col class="source"/>
+ <col class="remove"/>
</colgroup>
<tbody id="rules"></tbody>
</table>
diff --git a/src/content/settings/yourpolicy.js b/src/content/settings/yourpolicy.js
index c53c118..1dc1a46 100644
--- a/src/content/settings/yourpolicy.js
+++ b/src/content/settings/yourpolicy.js
@@ -37,7 +37,7 @@ $(function () {
});
-const SEARCH_DELAY = 500;
+const SEARCH_DELAY = 100;
var searchTimeoutId = null;
@@ -46,33 +46,36 @@ function populateRuleTable(filter) {
var policyMgr = rpService._policyMgr;
- var user = policyMgr._userPolicies['user'];
var table = document.getElementById('policy-user');
- var entries = user.rawPolicy.toJSON()['entries'];
clearPolicyTable(table);
- for (var i = 0; i < entries['allow'].length; i++) {
- var entry = entries['allow'][i];
- var origin = entry['o'] ? ruleDataPartToDisplayString(entry['o']) : '';
- var dest = entry['d'] ? ruleDataPartToDisplayString(entry['d']) : '';
- if (filter) {
- if (origin.indexOf(filter) == -1 && dest.indexOf(filter) == -1) {
- continue;
- }
- }
- addPolicyTableRow(table, 'allow', origin, dest, entry);
- }
- for (var i = 0; i < entries['deny'].length; i++) {
- var entry = entries['deny'][i];
- var origin = entry['o'] ? ruleDataPartToDisplayString(entry['o']) : '';
- var dest = entry['d'] ? ruleDataPartToDisplayString(entry['d']) : '';
- if (filter) {
- if (origin.indexOf(filter) == -1 && dest.indexOf(filter) == -1) {
- continue;
+ // Get and display user policies
+ var user = policyMgr._userPolicies['user'];
+ var entries = user.rawPolicy.toJSON()['entries'];
+ addPolicies(entries, 'User', filter);
+
+ // Get and display temorary policies
+ var temp = policyMgr._userPolicies['temp'];
+ var entries = temp.rawPolicy.toJSON()['entries'];
+ addPolicies(entries, 'Temporary', filter);
+
+}
+
+function addPolicies(entries, source, filter) {
+ var table = document.getElementById('policy-user');
+ for (var entry_type in entries) {
+ for (var i = 0; i < entries[entry_type].length; i++) {
+ var entry = entries[entry_type][i];
+ var origin = entry['o'] ? ruleDataPartToDisplayString(entry['o']) : '';
+ var dest = entry['d'] ? ruleDataPartToDisplayString(entry['d']) : '';
+ if (filter) {
+ if (origin.indexOf(filter) == -1 && dest.indexOf(filter) == -1) {
+ continue;
+ }
}
+ addPolicyTableRow(table, entry_type, origin, dest, entry, source);
}
- addPolicyTableRow(table, 'deny', origin, dest, entry);
}
}
@@ -97,7 +100,7 @@ function clearPolicyTable(table) {
}
}
-function addPolicyTableRow(table, type, origin, dest, ruleData) {
+function addPolicyTableRow(table, type, origin, dest, ruleData, source) {
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
@@ -113,15 +116,18 @@ function addPolicyTableRow(table, type, origin, dest, ruleData) {
var destCell = row.insertCell(2);
destCell.textContent = dest;
- var destCell = row.insertCell(3);
- //destCell.innerHTML = '<a href="#" class="deleterule">X</a>';
+ // Source Cell
+ var sourceCell = row.insertCell(3);
+ sourceCell.textContent = source;
+
+ var removeCell = row.insertCell(4);
var anchor = document.createElement('a');
anchor.appendChild(document.createTextNode('X'));
anchor.setAttribute('class', 'deleterule');
anchor.setAttribute('onclick', 'deleteRule(event);');
anchor.requestpolicyRuleType = type;
anchor.requestpolicyRuleData = ruleData;
- destCell.appendChild(anchor);
+ removeCell.appendChild(anchor);
}
// TODO: remove code duplication with menu.js
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git
More information about the Pkg-mozext-commits
mailing list