summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-pbr/htdocs/luci-static/resources/view/status
diff options
context:
space:
mode:
authorStan Grishin <stangri@melmac.ca>2024-03-18 02:03:13 +0000
committerStan Grishin <stangri@melmac.ca>2024-03-18 02:04:15 +0000
commite55d184e9f9e14f60d0229687c0c4676ae4201c2 (patch)
tree5de335884569377eb4d13c980c9d7f3210157b70 /applications/luci-app-pbr/htdocs/luci-static/resources/view/status
parentf2a49104c4839cc61c0c6a32cf0b616ca7b7d667 (diff)
luci-app-pbr: update to 1.1.4-5
* sync with the principal package * add the status include file Signed-off-by: Stan Grishin <stangri@melmac.ca>
Diffstat (limited to 'applications/luci-app-pbr/htdocs/luci-static/resources/view/status')
-rw-r--r--applications/luci-app-pbr/htdocs/luci-static/resources/view/status/include/72_pbr.js88
1 files changed, 88 insertions, 0 deletions
diff --git a/applications/luci-app-pbr/htdocs/luci-static/resources/view/status/include/72_pbr.js b/applications/luci-app-pbr/htdocs/luci-static/resources/view/status/include/72_pbr.js
new file mode 100644
index 0000000000..536c3983c3
--- /dev/null
+++ b/applications/luci-app-pbr/htdocs/luci-static/resources/view/status/include/72_pbr.js
@@ -0,0 +1,88 @@
+"require ui";
+"require rpc";
+"require form";
+"require baseclass";
+
+var pkg = {
+ get Name() {
+ return "pbr";
+ },
+ get URL() {
+ return "https://docs.openwrt.melmac.net/" + pkg.Name + "/";
+ },
+};
+
+var getInitStatus = rpc.declare({
+ object: "luci." + pkg.Name,
+ method: "getInitStatus",
+ params: ["name"],
+});
+
+return baseclass.extend({
+ title: _("Policy Based Routing"),
+
+ load: function () {
+ return Promise.all([getInitStatus(pkg.Name)]);
+ },
+
+ render: function (data) {
+ var reply;
+ if (data[0] && data[0][pkg.Name]) {
+ reply = data[0][pkg.Name];
+ } else {
+ reply = {
+ enabled: null,
+ running: null,
+ running_iptables: null,
+ running_nft: null,
+ running_nft_file: null,
+ version: null,
+ gateways: null,
+ errors: [],
+ warnings: [],
+ };
+ }
+
+ var versionText,
+ statusText = "",
+ modeText = "";
+ if (reply.version) {
+ versionText = reply.version;
+ if (reply.running) {
+ statusText = _("Active");
+ if (reply.running_iptables) {
+ modeText = _("iptables mode");
+ } else if (reply.running_nft_file) {
+ modeText = _("fw4 nft file mode");
+ } else if (reply.running_nft) {
+ modeText = _("nft mode");
+ } else {
+ modeText = _("unknown");
+ }
+ } else {
+ if (reply.enabled) {
+ statusText = _("Inactive");
+ } else {
+ statusText = _("Inactive (Disabled)");
+ }
+ }
+ } else {
+ versionText = _("Not installed or not found");
+ }
+
+ var table = E("table", { class: "table", id: "pbr_status_table" }, [
+ E("tr", { class: "tr table-titles" }, [
+ E("th", { class: "th" }, _("Status")),
+ E("th", { class: "th" }, _("Version")),
+ E("th", { class: "th" }, _("Mode")),
+ ]),
+ E("tr", { class: "tr" }, [
+ E("td", { class: "td" }, statusText),
+ E("td", { class: "td" }, versionText),
+ E("td", { class: "td" }, modeText),
+ ]),
+ ]);
+
+ return table;
+ },
+});