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
|
|
@ -56,7 +56,8 @@ const API_DOMAINS={
|
|||
leftTab:{kind:'enum',values:['goals','deals','noc','nets']},
|
||||
netFilter:{kind:'enum',values:['all','out']},
|
||||
pniFilter:{kind:'enum',values:['all','t','worth','pni']},
|
||||
listPage:{kind:'enum',values:['conn','cust','nets','pni']},
|
||||
listPage:{kind:'enum',values:['conn','cust','nets','pni','pops']},
|
||||
popsSortKey:{kind:'enum',values:['eye','cost','name']},
|
||||
custSortKey:{kind:'enum',values:['mood','mo','name','city']},
|
||||
connFilter:{kind:'enum',values:['all','k']},
|
||||
connSortKey:{kind:'enum',values:['k','city','name','use','mo']},
|
||||
|
|
|
|||
|
|
@ -443,6 +443,9 @@ const API_VIEW={
|
|||
custCity:{args:[['v','string']],doc:'Filter the customers list by city.'},
|
||||
custSort:{args:[['k','custSortKey']],doc:'Flip the customers list sort.'},
|
||||
custOpen:{args:[['sad','boolean',false]],doc:'Open the customers dashboard tab.'},
|
||||
popGo:{args:[['city','cityId']],doc:'Jump from the dashboard to a city with no POP yet.'},
|
||||
popsReg:{args:[['v','string']],doc:'Filter the list of cities with no POP by region.'},
|
||||
popsSort:{args:[['k','popsSortKey']],doc:'Flip the sort of the list of cities with no POP.'},
|
||||
goConn:{args:[['city','cityId'],['k','connKind']],doc:'Open a city\'s connections tab.'},
|
||||
goEgress:{args:[['city','cityId'],['k','egressKind']],doc:'Open a city\'s connections tab (l2 for the customer list).'},
|
||||
connOpen:{args:[],doc:'Open the connections dashboard tab.'},
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
Object.assign(ACT,{
|
||||
custGo:({id})=>{const b=S.biz.find(x=>x.id===id);if(!b)return;$('dash').hidden=true;ACT.focusCity({city:b.city});UI.tab='cust';renderPanel();},
|
||||
listMore:({k})=>{if(k!=='conn'&&k!=='cust'&&k!=='nets'&&k!=='pni')return;UI.listN=UI.listN||{};UI.listN[k]=listN(k)+LIST_PAGE;if(k==='nets'){renderLeft();return;}if(k==='pni'){renderPanel();return;}renderDash();},
|
||||
listMore:({k})=>{if(k!=='conn'&&k!=='cust'&&k!=='nets'&&k!=='pni'&&k!=='pops')return;UI.listN=UI.listN||{};UI.listN[k]=listN(k)+LIST_PAGE;if(k==='nets'){renderLeft();return;}if(k==='pni'){renderPanel();return;}renderDash();},
|
||||
custF:({v})=>{UI.kf=UI.kf||{};UI.kf.f=v==='sad'?'sad':'';listReset('cust');renderDash();},
|
||||
custCity:({v})=>{UI.kf=UI.kf||{};UI.kf.city=isCity(v)?v:'';listReset('cust');renderDash();},
|
||||
custSort:({k})=>{if(!['mood','mo','name','city'].includes(k))return;listReset('cust');if(UI.custSort===k)UI.custDir=-(UI.custDir||1);else{UI.custSort=k;UI.custDir=k==='mo'?-1:1;}renderDash();},
|
||||
custOpen:({sad}={})=>{if(!S)return;UI.kf=sad?{f:'sad'}:{};listReset('cust');UI.dtab='cust';const d=$('dash');d.hidden=false;renderDash();d.scrollTop=0;},
|
||||
popGo:({city})=>{if(!isCity(city)||!cityOn(city))return;$('dash').hidden=true;ACT.focusCity({city});},
|
||||
popsReg:({v})=>{UI.popF=UI.popF||{};UI.popF.reg=own(REG,v)?v:'';listReset('pops');renderDash();},
|
||||
popsSort:({k})=>{if(!['eye','cost','name'].includes(k))return;listReset('pops');const sk=UI.popSort||'eye',d0=k==='eye'?-1:1;UI.popDir=sk===k?-(UI.popDir||d0):d0;UI.popSort=k;renderDash();},
|
||||
goConn:({city,k})=>{if(!isCity(city)||!own(CONN_K,k))return;$('dash').hidden=true;ACT.goEgress({city,k});},
|
||||
connF:({f,v})=>{const F=UI.cf=UI.cf||{};listReset('conn');if(f==='all'){UI.cf={};}else if(f==='k'){F.k=own(CONN_K,v)?v:'';}renderDash();},
|
||||
connCity:({v})=>{UI.cf=UI.cf||{};listReset('conn');UI.cf.city=isCity(v)?v:'';renderDash();},
|
||||
|
|
|
|||
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){}
|
||||
|
|
|
|||
|
|
@ -4147,6 +4147,16 @@
|
|||
"tutorial.your_customers_want_the_whole":"Your customers want the whole internet. Open the Transit tab and buy a port from a carrier.",
|
||||
"tutorial.your_router_is_live_press_launch":"Your router is live. Press “Launch broadband” to sell internet to the people of your city.",
|
||||
"ui.n_d_left":"{n}d left",
|
||||
"unbuilt_pops.all_regions":"All regions",
|
||||
"unbuilt_pops.cities_without_a_pop_n":"Cities without a POP ({n})",
|
||||
"unbuilt_pops.cost_then_mo":"{cost}, then {mo}/mo",
|
||||
"unbuilt_pops.every_city_where_you_could_still":"Every city where you could still open a POP. Open one to see what it offers and build there.",
|
||||
"unbuilt_pops.n_more_city":{"one":"{n} more city","other":"{n} more cities"},
|
||||
"unbuilt_pops.needs_a_license_first":"Needs a license first",
|
||||
"unbuilt_pops.no_pop_yet":"No POP yet",
|
||||
"unbuilt_pops.nothing_left_to_build_in_this":"Nothing left to build in this region.",
|
||||
"unbuilt_pops.region":"Region",
|
||||
"unbuilt_pops.you_have_a_pop_in_every":"You have a POP in every city on the map. The map may need more cities.",
|
||||
"utilities.apply_kit":"Apply redundancy kit",
|
||||
"utilities.cache_moves":"Cache boxes to move: {n} (balanced per provider)",
|
||||
"utilities.cache_note":"Request one cache per eligible provider at each existing site. Existing boxes are kept; providers still require sufficient traffic.",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue