🗽 Sync 2026-11-11 15:31:38

This commit is contained in:
github-actions[bot] committed 2026-11-11 15:31:38 +08:00
1 parent da9e4bea36
commit 2e3c0a9b33
189 files changed
+29797 -10433

No files matched your search

File diff suppressed because it is too large. Load diff
@@ -9,21 +9,19 @@
--qos-hd: var(--background-color-low, rgba(128, 128, 128, .06));
--qos-r: 4px;
--qos-gap: .75em;
--qos-pad: .45em 1em;
/* The table cell padding; every box and row uses it, so all tabs line up. */
--qos-pad: .45em .75em;
}
/* The service bar sits outside any section, so it gets its own box. Flex
items ignore float, so the theme's page-actions floats cannot reorder the
buttons and they stay in declared order whatever their colour class. */
/* The service bar is the theme's own .cbi-page-actions, sized and drawn as
the quick settings Save & Apply bar above it. Flex items ignore float, so the
theme's page-actions floats cannot reorder the buttons and they stay in
declared order whatever their colour class. */
#qos-svc-btns {
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: .4em;
margin: 0 0 var(--qos-gap);
padding: var(--qos-pad);
border: 1px solid var(--qos-bd);
border-radius: var(--qos-r);
}
#qos-svc-btns::after {
@@ -46,7 +44,7 @@
}
#qos-app .table .td {
padding: .45em .75em;
padding: var(--qos-pad);
vertical-align: middle;
border-top-color: var(--qos-ln);
}
@@ -101,12 +99,6 @@
padding: 0;
}
/* The fold box sits just clear of its heading; the theme's h3 line-height
would otherwise double its depth. */
#qos-app .qa > details.cbi-section {
padding: .4em .75em;
}
#qos-app .qos-box > h3 {
margin: 0 0 var(--qos-gap);
}
@@ -162,6 +154,16 @@
padding: .15em .3em;
}
/* The Dynamic Entries list is a table, not a form row: full cell padding. */
#qos-app .qa #qos-dyn .th,
#qos-app .qa #qos-dyn .td {
padding: var(--qos-pad);
}
#qos-app .qa .cbi-section-descr {
margin: 0 0 .4em;
}
#qos-app .qa .th {
font-size: .85em;
overflow: hidden;
@@ -197,7 +199,7 @@
}
#qos-app .qa details:not(.cbi-section) .td {
padding: .2em .5em;
padding: var(--qos-pad);
border-top: 1px solid var(--qos-ln);
}
@@ -286,7 +288,8 @@
}
/* A header table above a boxed body; bars and figures are updated in place. */
#qos-cn .qbox {
#qos-cn .qbox,
#qos-dyn .qbox {
overflow: hidden;
border: 1px solid var(--qos-bd);
border-radius: var(--qos-r);
@@ -296,19 +299,23 @@
margin-top: var(--qos-gap);
}
#qos-cn .qhead {
#qos-cn .qhead,
#qos-dyn .qhead {
background: var(--qos-hd);
border-bottom: 1px solid var(--qos-ln);
}
#qos-cn .qhead .th,
#qos-cn .qbox .td {
#qos-cn .qbox .td,
#qos-dyn .qhead .th,
#qos-dyn .qbox .td {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
#qos-cn .qbox .tr:not(.table-titles):hover .td {
#qos-cn .qbox .tr:not(.table-titles):hover .td,
#qos-dyn .qbox .tr:not(.table-titles):hover .td {
background: var(--qos-hd);
}
@@ -319,7 +326,8 @@
border-radius: var(--qos-r);
}
#qos-cn .qn {
#qos-cn .qn,
#qos-dyn .qn {
width: 1%;
text-align: right;
white-space: nowrap;
@@ -330,50 +338,229 @@
font-weight: 600;
}
#qos-cn-map-box {
/* The measure sits above the sections, at the right, as a plain select. */
#qos-cn-measure {
display: flex;
justify-content: flex-end;
align-items: center;
gap: .5em;
}
#qos-cn-measure select {
width: auto;
}
/* Traffic by CAKE Tin: a box per direction, side by side while they fit. The
banner holds the direction over the donut and the column titles over the
table; in a narrow box both wrap, so the titles stay above the table and the
donut drops below it. */
#qos-cn .qos-tins {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 26em), 1fr));
gap: var(--qos-gap);
}
#qos-cn .qos-tins .qbox {
min-width: 0;
}
#qos-cn .qos-tins .qbox + .qbox {
margin-top: 0;
}
#qos-cn .qos-tin-head,
#qos-cn .qos-tin-body {
display: flex;
flex-wrap: wrap;
align-items: center;
}
#qos-cn .qos-tin-head {
column-gap: var(--qos-gap);
}
/* As wide as the donut and its margin, so the titles sit over their columns. */
#qos-cn .qos-tin-head > div {
flex: none;
box-sizing: border-box;
width: calc(9.5em + var(--qos-gap));
padding: var(--qos-pad);
padding-right: 0;
}
#qos-cn .qos-tin-body {
flex-wrap: wrap-reverse;
justify-content: center;
}
#qos-cn .qos-tin-head .table,
#qos-cn .qos-tin-body .table {
flex: 1 1 18em;
margin: 0;
}
/* Arcs are stroked circles over a ring that shows where a tin has none. */
#qos-cn .qos-donut {
position: relative;
flex: none;
width: 9.5em;
height: 9.5em;
margin: var(--qos-gap);
}
#qos-cn .qos-donut svg {
display: block;
width: 100%;
height: 100%;
fill: none;
stroke-width: 15;
}
#qos-cn .qos-donut .qos-ring {
stroke: var(--qos-ln);
}
#qos-cn .qos-donut div {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: .9em;
font-variant-numeric: tabular-nums;
white-space: nowrap;
}
/* Traffic by Class under one mode: tin rows are shaded as the header is. Class
rows sit under the tin name, by the cell padding plus a swatch and its margin,
with their codepoints muted. The bars' column takes what the names and figures
leave. */
#qos-cn .qos-bar {
width: 100%;
min-width: 4em;
}
#qos-cn .qbox .qos-grp .td {
background: var(--qos-hd);
}
/* Footstrap pins a table's titles under its top bar while the page scrolls.
In this clipped box they would pin to the box and cover the first rows. */
#qos-cn .qos-cls .th {
position: static;
}
#qos-cn .qos-cls .qos-in > .td:first-child {
padding-left: 1.85em;
}
#qos-cn .qos-mk {
opacity: .75;
}
#qos-cn .qos-sw {
display: inline-block;
width: .7em;
height: .7em;
margin-right: .4em;
border-radius: 2px;
}
#qos-cn .qos-cn-info {
margin: var(--qos-gap) 0 0;
font-size: 90%;
}
#qos-cn-map-box,
#qos-dyn-box {
height: 24rem;
min-height: 6rem;
overflow-y: scroll;
resize: vertical;
}
/* Quick settings: one inner box per tab, rows split by the same line as the
tables, and the control then its hint on one line so every hint starts in
the same column. */
/* A handful of dynamic entries is usual, so the box fits its rows up to the same height. */
#qos-dyn-box {
height: auto;
min-height: 0;
max-height: 24rem;
overflow-y: auto;
}
/* Quick settings: unboxed, like the Service table above it, with its rows laid
out as that table's: the same cell padding, a 33% label column in the theme's
normal weight and a line above every row. The control then its hint on one
line, so every hint starts in the same column. */
/* Clear of the Service table above, which ends without a bar of its own. */
#qos-qs-sect {
--qos-ctl: 2.4em;
margin-top: 2em;
}
/* Every row is as deep as one holding an input box, checkbox rows included, and
the box fits its rows, with no blank space under the last one. */
#qos-app .qs-box {
min-width: 0;
min-height: 13em;
padding: .3em 1.5em;
border: 1px solid var(--qos-bd);
border-radius: var(--qos-r);
padding: 0;
}
/* The theme wraps .cbi-value; a row here never wraps on a wide screen, and the
field takes what the label leaves (basis 0), not its content's width, so a
long hint cannot push the field onto a line of its own. */
#qos-qs-sect .cbi-value {
align-items: flex-start;
flex-wrap: nowrap;
align-items: center;
margin: 0;
padding: .25em 0;
}
#qos-qs-sect .cbi-value + .cbi-value {
padding: 0;
border-top: 1px solid var(--qos-ln);
}
/* No line above a tab's first row: the tab bar already draws one there. */
#qos-qs-sect .qs-box > .cbi-value:first-child {
border-top: 0;
}
#qos-qs-sect .cbi-value label.cbi-value-title {
flex: 0 0 16em;
padding-top: 0;
line-height: 30px;
font-weight: 600;
flex: 0 0 33%;
box-sizing: border-box;
padding: var(--qos-pad);
text-align: left;
font-weight: normal;
}
#qos-qs-sect .cbi-value-field {
display: grid;
grid-template-columns: minmax(0, 18em) minmax(0, 1fr);
grid-template-columns: minmax(0, 28em) minmax(0, 1fr);
align-items: center;
gap: .3em 1.5em;
flex: 1 1 auto;
margin-left: 1.5em;
flex: 1 1 0;
box-sizing: border-box;
min-height: calc(var(--qos-ctl) + .9em);
margin: 0;
padding: var(--qos-pad);
min-width: 0;
line-height: 30px;
}
/* The tab panes share one grid cell, so the box is as deep as the tallest tab
and switching tabs never moves the page; a shorter tab leaves a gap under its
last row. A hidden pane keeps its size but cannot be seen, clicked or focused. */
#qos-qs-sect .qs-panes {
display: grid;
}
#qos-qs-sect .qs-panes > [data-tab] {
grid-area: 1 / 1;
height: auto;
max-height: none;
overflow: visible;
}
#qos-qs-sect .qs-panes > [data-tab]:not([data-tab-active="true"]) {
visibility: hidden;
}
#qos-qs-sect .cbi-value-description {
@@ -398,6 +585,7 @@
#qos-qs-sect .cbi-value-field input[type=text],
#qos-qs-sect .cbi-value-field input[type=number],
#qos-qs-sect .cbi-value-field select {
height: var(--qos-ctl);
max-width: 100%;
box-sizing: border-box;
}
@@ -424,10 +612,6 @@
width: 18em;
}
#qos-qs-sect .qs-wide .cbi-value-field {
grid-template-columns: minmax(0, 28em) minmax(0, 1fr);
}
#qos-qs-sect [data-q$=opts] {
width: 100%;
}
@@ -439,15 +623,28 @@
}
#qos-qs-sect .cbi-value label.cbi-value-title {
line-height: 1.5;
padding-bottom: 0;
}
#qos-qs-sect .cbi-value-field {
grid-template-columns: minmax(0, 1fr);
margin-left: 0;
}
#qos-qs-sect .cbi-value-field > * {
grid-column: 1;
}
/* Traffic by Class leaves its bars out and lets a codepoint, or a class name
too long for the line, wrap, so the figures keep their width. */
#qos-cn .qos-bar {
display: none;
}
#qos-cn .qos-cls .td:first-child {
white-space: normal;
}
#qos-cn .qos-cls code {
overflow-wrap: anywhere;
}
}
@@ -0,0 +1,86 @@
// SPDX-License-Identifier: MIT
'use strict';
'require baseclass';
'require fs';
'require rpc';
'require uci';
// Status > Overview card: the Service rows of the app's Overview tab, with the
// shaped rates. Three ubus calls a tick and the qosify config, which uci.load()
// reads once per page, so nothing forks. index.js stops drawing a card whose
// load() rejects, so each call settles to null, shown as unknown.
var callServiceList=rpc.declare({object:'service',method:'list',params:['name'],expect:{'':{}},reject:true});
// skip_running_check keeps rc.list from forking `qosify running`.
var callRcList=rpc.declare({object:'rc',method:'list',params:['name','skip_running_check'],expect:{'':{}},reject:true});
var callQosifyStatus=rpc.declare({object:'qosify',method:'status',expect:{'':{}},reject:true});
// Bootstrap and OpenWrt 2020 have no .label.danger; the app's own rule from
// qosify.css. Footstrap drops the row lines of a two-cell table on this page:
// a rule outside its layers draws them, and :where() keeps it under any theme's
// .table .td, so bootstrap and its phone layout keep their own lines.
var STYLE='.qos-ov .label.danger{background-color:var(--error-color-high,#e8210d);color:var(--on-error-color,#fff)}'+
':where(.qos-ov .tr+.tr)>.td{border-top:1px solid var(--border-color-medium,rgba(128,128,128,.35))}';
function nul(){return null;}
function tx(v){return typeof v==='string'?[v]:v;}
function badge(kind,t){return E('span',{'class':'label '+kind},tx(t));}
function unk(){return badge('warning',_('Unknown'));}
function kvRow(k,v){return E('tr',{'class':'tr'},[E('td',{'class':'td left','width':'33%'},tx(k)),E('td',{'class':'td left'},tx(v))]);}
function isRunning(r){try{var i=r.qosify.instances;for(var k in i)if(i[k].running)return true;}catch(e){}return false;}
function runPid(r){try{var i=r.qosify.instances;for(var k in i)if(i[k].running&&i[k].pid)return i[k].pid;}catch(e){}return 0;}
// The status keys are option name; qosify.init sends no disabled section
// (config_get_bool) and falls back to bandwidth for an unset direction. A
// shaped direction without one runs CAKE unlimited.
function ifSect(type,name){
return uci.sections('qosify',type).filter(function(s){return s.name===name&&!/^(1|on|true|yes|enabled)$/.test(s.disabled);})[0]||null;
}
function rate(s,on,k){return !on?_('no'):!s?_('yes'):s['bandwidth_'+k]||s.bandwidth||_('unlimited');}
return baseclass.extend({
title:_('qosify'),
load:function(){
var self=this;
return Promise.all([
callServiceList('qosify').catch(nul),
callRcList('qosify',true).catch(nul),
callQosifyStatus().catch(nul),
uci.load('qosify').catch(nul)
]).then(function(d){return self.uptime(d[0]).then(function(u){d.push(u);return d;});});
},
// As on the Overview tab: service list carries the pid but no start time, so
// starttime (field 22 of /proc/<pid>/stat, USER_HZ ticks since boot) is set
// against /proc/uptime, once per pid; later ticks add performance.now().
uptime:function(r){
var self=this,pid=runPid(r);
if(!pid){self._up=null;return Promise.resolve(null);}
if(self._up&&self._up.pid===pid)return Promise.resolve(self._up.up+(performance.now()-self._up.t)/1000);
return Promise.all([fs.read('/proc/'+pid+'/stat'),fs.read('/proc/uptime')]).then(function(d){
var st=String(d[0]),f=st.slice(st.lastIndexOf(')')+2).split(' '),up=parseFloat(d[1])-f[19]/100;
if(!(up>=0))return null;
self._up={pid:pid,up:up,t:performance.now()};
return up;
}).catch(nul);
},
// The Overview tab's rows and wording, each interface with its rates in place
// of yes. The qosify object goes with the daemon, so an unanswered status
// call only reads unknown while it runs.
render:function(d){
var run=d[0]!==null?isRunning(d[0]):null,rc=d[1]&&d[1].qosify,st=d[2]||(run===false?{}:null),n=0,ifs=[];
if(st)['interfaces','devices'].forEach(function(g){
for(var k in st[g]){
var e=st[g][k]||{},s=d[3]!==null?ifSect(g==='devices'?'device':'interface',k):null;
if(e.active)n++;
ifs.push(kvRow((g==='devices'?_('device %s'):_('interface %s')).format(k),[badge(e.active?'success':'danger',e.active?_('active'):_('inactive')),' ',
_('device: %s, ingress: %s, egress: %s').format(e.ifname||'-',rate(s,e.ingress,'down'),rate(s,e.egress,'up'))]));
}
});
return E([E('style',{},[STYLE]),E('table',{'class':'table qos-ov'},[
kvRow(_('Status'),run==null?unk():run&&!st?badge('warning',_('Running — Shaping Unknown')):run&&n?badge('success',_('Running & Shaping')):
run?badge('warning',_('Running — Not Shaping')):badge('danger',_('Not Running'))),
kvRow(_('Uptime'),d[4]!=null?'%t'.format(Math.floor(d[4])):'-'),
kvRow(_('Autostart'),d[1]===null?unk():rc&&rc.enabled?badge('success',_('Enabled')):badge('danger',_('Disabled')))
].concat(ifs))]);
}
});