A dashboard tab listing the cities with no POP yet
The dashboard shows what you have built, not what you haven't. The new tab lists every city you could still open, with its eyeballs, exchange and price, and sorts, filters by region and pages like the other long lists. Open selects the city on the map, so a build still goes through the city panel and its warnings. The tab also works in the NOC window.
This commit is contained in:
parent
b8d313b029
commit
0cdbef97fe
17 changed files with 227 additions and 8 deletions
13
src/game/94-dashboard/35-unbuilt-pops.js
Normal file
13
src/game/94-dashboard/35-unbuilt-pops.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/* ---------- cities with no POP of yours yet ---------- */
|
||||
function popsSection(){const F=UI.popF||{},q=popStdQuote(),cost=c=>popCost(c)+(q?q.cost:0),mo=c=>popMo(c)+(q?q.mo:0);
|
||||
const all=CITIES.filter(C=>cityOn(C.id)&&!S.pops[C.id]);
|
||||
let h=`<div class="panel2" id="popsSec" style="margin-top:12px"><h3>${tr('unbuilt_pops.cities_without_a_pop_n',{n:all.length})}</h3>`;
|
||||
if(!all.length)return h+`<p class="empty">${tr('unbuilt_pops.you_have_a_pop_in_every')}</p></div>`;
|
||||
h+=`<p class="note" style="margin-top:0">${tr('unbuilt_pops.every_city_where_you_could_still')}</p>`;
|
||||
const sk=UI.popSort||'eye',dir=UI.popDir||-1,val=C=>sk==='name'?C.name.toLowerCase():sk==='cost'?cost(C.id):eyeP(C.id);
|
||||
h+=`<div class="trsel" style="display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-bottom:6px"><label>${tr('unbuilt_pops.region')} <select data-chg="popsReg"><option value="">${tr('unbuilt_pops.all_regions')}</option>${Object.keys(REG).map(r=>`<option value="${r}"${F.reg===r?' selected':''}>${esc(REG[r])}</option>`).join('')}</select></label></div>`;
|
||||
h+=`<div class="seg" style="margin-bottom:4px">${[['eye',tr('common.eyeballs')],['cost',tr('common.cost')],['name',tr('common.name')]].map(([k,l])=>btn(l+(sk===k?(dir>0?' ▲':' ▼'):''),'popsSort',{k},sk===k?'pink sm':'ghost sm')).join('')}</div>`;
|
||||
const rows=all.filter(C=>!F.reg||C.reg===F.reg).sort((a,b)=>{const A=val(a),B=val(b);return (A<B?-1:A>B?1:0)*dir||a.name.localeCompare(b.name);});
|
||||
if(!rows.length)return h+`<p class="empty">${tr('unbuilt_pops.nothing_left_to_build_in_this')}</p></div>`;
|
||||
h+=rows.slice(0,listN('pops')).map(C=>{const ix=ixName(C.id);return `<div class="row"><div class="grow"><div class="nm">${esc(C.name)} <span class="meta">${esc(REG[C.reg])}</span></div><div class="meta">${tr('city_panel.g_of_eyeballs',{g:fmtG(eyeP(C.id))})}${ix?` · ${tr('city_panel.ix_ix',{ix:esc(ix)})}`:''} · ${tr('unbuilt_pops.cost_then_mo',{cost:fmt$(cost(C.id)),mo:fmt$(mo(C.id))})}</div>${C.cn&&!cnOk()?`<div class="why">${tr('unbuilt_pops.needs_a_license_first')}</div>`:''}</div>${btn(tr('common.open'),'popGo',{city:C.id},'ghost sm')}</div>`;}).join('');
|
||||
return h+listMore('pops',rows.length,n=>trn('unbuilt_pops.n_more_city',n))+`</div>`;}
|
||||
|
|
@ -64,4 +64,4 @@ function netWhereIdx(){const B={t:{},p:{},ix:{},c:{}},add=(k,id,x)=>(B[k][id]||(
|
|||
function netWhere(n,where){const ch=(where||netWhereIdx())(n.id);
|
||||
if(!ch.length)return '';const MAX=6;
|
||||
return `<div class="btns">${ch.slice(0,MAX).map(([l,c,k])=>btn(`${esc(l)} <small>${esc(CITY[c].name)}</small>`,'goConn',{city:c,k},'ghost sm')).join('')}${ch.length>MAX?btn(tr('dashboard.n_more',{n:ch.length-MAX}),'connFor',{net:n.id},'ghost sm'):''}</div>`;}
|
||||
const DTABS=['overview','cust','conn','traffic','infra','lease'];
|
||||
const DTABS=['overview','cust','conn','traffic','infra','pops','lease'];
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
function dashTabs(){const u=custStats().unhappy,cur=UI.dtab||'overview',L={overview:tr('common.overview'),cust:tr('common.customers'),conn:tr('common.connections'),traffic:tr('common.traffic'),infra:tr('common.links_routers'),lease:tr('common.leased_lines')};
|
||||
function dashTabs(){const u=custStats().unhappy,cur=UI.dtab||'overview',L={overview:tr('common.overview'),cust:tr('common.customers'),conn:tr('common.connections'),traffic:tr('common.traffic'),infra:tr('common.links_routers'),pops:tr('unbuilt_pops.no_pop_yet'),lease:tr('common.leased_lines')};
|
||||
return `<nav class="dtabs">${DTABS.map(k=>`<button class="${cur===k?'on':''}" data-act="dashTab" data-args='{"k":"${k}"}'>${L[k]}${k==='cust'&&u?`<span class="cnt red">${u}</span>`:''}</button>`).join('')}</nav>`;}
|
||||
function renderDash(){checkLayer();
|
||||
const H=S.hist||[],rows=H.slice(-90),last30=H.slice(-30);
|
||||
|
|
@ -29,6 +29,7 @@ function renderDash(){checkLayer();
|
|||
if(DT==='infra')h+=`<div class="dcols" style="margin-top:12px"><div class="panel2"><h3>${tr('common.busiest_links')}</h3>${ls.length?ls.map(({l,u})=>`<div class="row"><div class="grow"><div class="nm">${CITY[l.a].name} ⇄ ${CITY[l.b].name} <span class="meta">${capName(l)} · ${linkLat(l).toFixed(1)} ms</span></div><div class="bar ${barCls(u)}"><i style="width:${Math.min(100,u*100)}%"></i></div></div><b class="num" style="min-width:42px;text-align:right">${pct(u)}</b>${btn(tr('common.open'),'dashLink',{id:l.id},'ghost sm')}</div>`).join(''):'<p class="empty">'+tr('common.no_links_yet')+'</p>'}</div>
|
||||
<div class="panel2"><h3>${tr('common.router_load')}</h3>${rs.map(({c,u})=>`<div class="row"><div class="grow"><div class="nm">${CITY[c].name} <span class="meta">${(S.pops[c].routers||1)} × ${esc(RG[S.pops[c].rgen||0].n)}</span></div><div class="bar ${barCls(u)}"><i style="width:${Math.min(100,u*100)}%"></i></div></div><b class="num" style="min-width:42px;text-align:right">${pct(u)}</b></div>`).join('')}
|
||||
<h3 style="margin-top:10px">${tr('common.your_as')}</h3><div class="kv"><span>${tr('common.as_number')}</span><b>AS${S.asn}</b></div><div class="kv"><span>${tr('common.prefixes')}</span><b>${Math.max(1,Math.ceil(Object.keys(S.pops).length/3))} × /22 IPv4, 1 × /32 IPv6</b></div><div class="kv"><span>${tr('common.bgp_sessions')}</span><b>${R.sessions}</b></div><div class="kv"><span>${tr('common.upstreams')}</span><b>${new Set(S.transit.map(t=>t.net)).size}</b></div><div class="kv"><span>${tr('common.reach')}</span><b>${pct(R.reach)}</b></div><div class="kv"><span>${tr('common.customers')}</span><b>${tr('dashboard.n_businesses',{n:S.biz.length})}</b></div></div></div>`;
|
||||
if(DT==='pops')h+=popsSection();
|
||||
if(DT==='lease')h+=leaseTab();
|
||||
if(h!==UI._dh){UI._dh=h;morph($('dashCard'),h);}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
per network, opened once a window says hello, so other games' tabs never unpack them. With no window nothing is sent. */
|
||||
const NOC_HB=3000,NOC_LOST=10000,NOC_GAP=1000;
|
||||
// What a click in the window does: changes only its own view, or runs in the game. Every button the dashboard draws is in one list.
|
||||
const NOC_LOCAL=['chartToggle','connCity','connF','connNet','connSort','custCity','custF','custSort','dashClose','dashSort','dashTab','listMore'];
|
||||
const NOC_GO=['buyIx','buyNni','buyTransit','cache','connCancel','custGo','dashLink','goConn','lagIx','lagP','lagT','leaseSwap','netFocus','opsOpen','pni','pniAllOpen'];
|
||||
const NOC_LOCAL=['chartToggle','connCity','connF','connNet','connSort','custCity','custF','custSort','dashClose','dashSort','dashTab','listMore','popsReg','popsSort'];
|
||||
const NOC_GO=['buyIx','buyNni','buyTransit','cache','connCancel','custGo','dashLink','goConn','lagIx','lagP','lagT','leaseSwap','netFocus','opsOpen','pni','pniAllOpen','popGo'];
|
||||
const NOC={win:false,id:null,ctl:null,st:null,stId:null,peer:false,until:0,dirty:false,sent:0,speed:1,hid:false,yoAt:0,gone:false};
|
||||
{const id=RW_IN?null:new URLSearchParams(location.search).get('noc');if(slotOkId(id)){NOC.win=true;NOC.id=id;}}
|
||||
if(!RW_IN)try{if(typeof BroadcastChannel==='function'){NOC.ctl=new BroadcastChannel('sot-noc');NOC.ctl.onmessage=e=>{const m=e.data;if(!m||typeof m!=='object'||!slotOkId(m.id))return;if(NOC.win)nocWinMsg(m);else nocGameMsg(m);};}}catch(e){}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue