luci-mod-admin-full: handle infinite lease times in output
authorJo-Philipp Wich <jo@mein.io>
Fri, 9 Dec 2016 12:07:42 +0000 (13:07 +0100)
committerJo-Philipp Wich <jo@mein.io>
Fri, 9 Dec 2016 12:07:42 +0000 (13:07 +0100)
When a lease objects expires property is set to "false", its expiry time is
unlimited, so adjust the templates to properly display that state.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-mod-admin-full/luasrc/view/admin_network/lease_status.htm
modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm

index f7787dd1ea3a1b60e5db28d95c66143afdcaffc0..b4baedff28b772158b20e093712960dd9b7abc82 100644 (file)
                                {
                                        var timestr;
 
-                                       if (st[0][i].expires <= 0)
-                                       {
+                                       if (st[0][i].expires === false)
+                                               timestr = '<em><%:unlimited%></em>';
+                                       else if (st[0][i].expires <= 0)
                                                timestr = '<em><%:expired%></em>';
-                                       }
                                        else
-                                       {
                                                timestr = String.format('%t', st[0][i].expires);
-                                       }
 
                                        var tr = tb.insertRow(-1);
                                                tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
                                {
                                        var timestr;
 
-                                       if (st[1][i].expires <= 0)
-                                       {
+                                       if (st[1][i].expires === false)
+                                               timestr = '<em><%:unlimited%></em>';
+                                       else if (st[1][i].expires <= 0)
                                                timestr = '<em><%:expired%></em>';
-                                       }
                                        else
-                                       {
                                                timestr = String.format('%t', st[1][i].expires);
-                                       }
 
                                        var tr = tb6.insertRow(-1);
                                                tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
index eb4648806227782138451b7ce6f2496c538f2eb9..8976e30cba3ef0ee08e8dbdd4c4921b2d8800488 100644 (file)
                                {
                                        var timestr;
 
-                                       if (info.leases[i].expires <= 0)
+                                       if (info.leases[i].expires === false)
+                                               timestr = '<em><%:unlimited%></em>';
+                                       else if (info.leases[i].expires <= 0)
                                                timestr = '<em><%:expired%></em>';
                                        else
                                                timestr = String.format('%t', info.leases[i].expires);
                                {
                                        var timestr;
 
-                                       if (info.leases6[i].expires <= 0)
+                                       if (info.leases6[i].expires === false)
+                                               timestr = '<em><%:unlimited%></em>';
+                                       else if (info.leases6[i].expires <= 0)
                                                timestr = '<em><%:expired%></em>';
                                        else
                                                timestr = String.format('%t', info.leases6[i].expires);