5dd3d9079ce41a0d10f08ae793ebebf825738d84
[openwrt-luci.git] /
1 "require ui";
2 "require rpc";
3 "require form";
4 "require baseclass";
5
6 var pkg = {
7         get Name() {
8                 return "adblock-fast";
9         },
10         get URL() {
11                 return "https://docs.openwrt.melmac.net/" + pkg.Name + "/";
12         },
13 };
14
15 var getInitStatus = rpc.declare({
16         object: "luci." + pkg.Name,
17         method: "getInitStatus",
18         params: ["name"],
19 });
20
21 return baseclass.extend({
22         title: _("AdBlock-Fast"),
23
24         load: function () {
25                 return Promise.all([getInitStatus(pkg.Name)]);
26         },
27
28         render: function (data) {
29                 var reply = {
30                         status: (data[0] && data[0][pkg.Name]) || {
31                                 enabled: false,
32                                 status: null,
33                                 running: null,
34                                 version: null,
35                                 errors: [],
36                                 warnings: [],
37                                 force_dns_active: null,
38                                 force_dns_ports: [],
39                                 entries: null,
40                                 dns: null,
41                                 outputFile: null,
42                                 outputCache: null,
43                                 outputGzip: null,
44                                 outputFileExists: null,
45                                 outputCacheExists: null,
46                                 outputGzipExists: null,
47                                 leds: [],
48                         },
49                 };
50                 var statusTable = {
51                         statusNoInstall: _("%s is not installed or not found").format(pkg.Name),
52                         statusStopped: _("Stopped"),
53                         statusStarting: _("Starting"),
54                         statusProcessing: _("Processing lists"),
55                         statusRestarting: _("Restarting"),
56                         statusForceReloading: _("Force Reloading"),
57                         statusDownloading: _("Downloading lists"),
58                         statusError: _("Error"),
59                         statusWarning: _("Warning"),
60                         statusFail: _("Fail"),
61                         statusSuccess: _("Active"),
62                 };
63
64                 var cacheText;
65                 if (reply.status.outputCacheExists) {
66                         cacheText = _("Cache file");
67                 } else if (reply.status.outputGzipExists) {
68                         cacheText = _("Compressed cache");
69                 }
70                 var forceDnsText = "";
71                 if (reply.status.force_dns_active) {
72                         reply.status.force_dns_ports.forEach((element) => {
73                                 forceDnsText += element + " ";
74                         });
75                 } else {
76                         forceDnsText = "-";
77                 }
78
79                 var table = E(
80                         "table",
81                         { class: "table", id: "adblock-fast_status_table" },
82                         [
83                                 E("tr", { class: "tr table-titles" }, [
84                                         E("th", { class: "th" }, _("Status")),
85                                         E("th", { class: "th" }, _("Version")),
86                                         E("th", { class: "th" }, _("DNS Service")),
87                                         E("th", { class: "th" }, _("Blocked Domains")),
88                                         E("th", { class: "th" }, _("Cache")),
89                                         E("th", { class: "th" }, _("Force DNS Ports")),
90                                 ]),
91                                 E("tr", { class: "tr" }, [
92                                         E(
93                                                 "td",
94                                                 { class: "td" },
95                                                 statusTable[reply.status.status] || _("Unknown")
96                                         ),
97                                         E("td", { class: "td" }, reply.status.version || _("-")),
98                                         E("td", { class: "td" }, reply.status.dns || _("-")),
99                                         E("td", { class: "td" }, reply.status.entries || _("-")),
100                                         E("td", { class: "td" }, cacheText || _("-")),
101                                         E("td", { class: "td" }, forceDnsText || _("-")),
102                                 ]),
103                         ]
104                 );
105
106                 return table;
107         },
108 });
git clone https://git.99rst.org/PROJECT