diff --git a/site/i18n/it.js b/site/i18n/it.js index d510475..f01cbb5 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -2372,7 +2372,6 @@ "Every wave, fabric circuit and dark fiber IRU you rent between two of your POPs, next to what leased dark fiber or your own fiber would cost. Estimates include the line system, amplifiers and enough optics for today’s capacity. Build first, move the traffic, then cancel the lease.":"Ogni wave, circuito fabric e dark fiber IRU che affitti tra due tuoi POP, accanto a quanto costerebbe una dark fiber in affitto o la tua fibra. Le stime includono il sistema di linea, gli amplificatori e abbastanza ottiche per la capacità di oggi. Prima costruisci, poi sposta il traffico, infine disdici l’affitto.", "You pay for leases":"Paghi di affitti", "land":"terrestre", -"You already own fiber here. Light more channels on it, then cancel the lease to save {price}/mo.":"Qui hai già la tua fibra. Accendi altri canali, poi disdici l’affitto e risparmi {price}/mese.", "Your own cable: {up} up front, {mo}/mo, about {n} days to build.":"Il tuo cavo: {up} subito, {mo}/mese, circa {n} giorni di lavori.", "Your own fiber: {up} up front, {mo}/mo, about {n} days to build.":"La tua fibra: {up} subito, {mo}/mese, circa {n} giorni di lavori.", "Saves {price}/mo, pays for itself in about {n} months.":"Risparmi {price}/mese, si ripaga in circa {n} mesi.", @@ -2384,7 +2383,10 @@ "You do not lease any lines between your POPs.":"Non affitti nessuna linea tra i tuoi POP.", "Lease dark fiber: {up} up front, {mo}/mo, ready in about {n} days.":"Dark fiber in affitto: {up} subito, {mo}/mese, pronta in circa {n} giorni.", "Plan dark fiber":"Progetta la dark fiber", -"You already lease dark fiber here. Light more channels on it, then cancel the waves to save {price}/mo.":"Qui affitti già una dark fiber. Accendi altri canali, poi disdici le wave e risparmi {price}/mese.", "Open your dark fiber":"Apri la tua dark fiber", "− box":"− box", +"You already own fiber here. Light {n} more channels for {up}, then cancel the lease to save {price}/mo.":"Qui hai già la tua fibra. Accendi altri {n} canali per {up}, poi disdici l'affitto e risparmi {price}/mese.", +"You already lease dark fiber here. Light {n} more channels for {up}, then cancel the waves to save {price}/mo.":"Qui affitti già una dark fiber. Accendi altri {n} canali per {up}, poi disdici le wave e risparmi {price}/mese.", +"Your fiber here has room for {free} more channels, and moving these leases needs {n}. Light another fiber pair or upgrade the line system first.":"La tua fibra qui ha spazio per altri {free} canali, e spostare questi affitti ne richiede {n}. Prima accendi un'altra coppia di fibre o aggiorna il line system.", +"No optic you can buy works on your fiber here yet.":"Nessuna ottica che puoi comprare funziona ancora sulla tua fibra qui.", }; diff --git a/site/index.html b/site/index.html index ace47c6..7130746 100644 --- a/site/index.html +++ b/site/index.html @@ -2568,10 +2568,10 @@ const ACT={ lagT:({id,d})=>{d=+d;if(d!==1&&d!==-1)return;const t=S.transit.find(x=>x.id===id);if(!t)return;const n=(t.n||1)+(+d);if(n<1||n>LAG_MAX)return;if(+d>0){if(!portOk(t.city,t.tier)||!portGate(t.city,PORT_SLOT(t.tier)))return;if(!spend(PORT[t.tier].setup))return;}t.n=n;if(n<2&&t.site==='ab')t.site='a';toast(+d>0?tr('LAG member added.
{net} in {city} is now {lag}.',{net:esc(NET[t.net].name),city:CITY[t.city].name,lag:lagName(t.tier,n)}):tr(`LAG member removed.`),'good');after();}, lagP:({id,d})=>{d=+d;if(d!==1&&d!==-1)return;const p=S.pni.find(x=>x.id===id);if(!p)return;const n=(p.n||1)+(+d);if(n<1||n>LAG_MAX)return;if(+d>0&&(!portGate(p.city,PORT_SLOT(p.tier))||!spend(1500+PORT[p.tier].setup/2)))return;p.n=n;if(n<2&&p.site==='ab')p.site='a';sfx('build');after();}, lagIx:({city,d})=>{d=+d;if(d!==1&&d!==-1)return;if(!isIx(city)||S.ixp[city]===undefined||S.myIx[city]||!S.pops[ixCity(city)])return;S.ixn=S.ixn||{};const n=(S.ixn[city]||1)+(+d);if(n<1||n>LAG_MAX)return;if(+d>0&&(!portGate(ixCity(city),PORT_SLOT(S.ixp[city]))||!spend(ixPortMo(city,S.ixp[city]))))return;S.ixn[city]=n;if(n<2&&S.ixSite&&S.ixSite[city]==='ab')S.ixSite[city]='a';sfx('build');after();}, - cancelTransit:({id})=>{if(UI.confirm!==id){UI.confirm=id;renderPanel();return;}S.transit=S.transit.filter(t=>t.id!==id);UI.confirm=null;after();}, + cancelTransit:({id,ok})=>{if(!ok&&UI.confirm!==id){UI.confirm=id;renderPanel();return;}S.transit=S.transit.filter(t=>t.id!==id);UI.confirm=null;after();}, buyIx:({city,tier,signed})=>{tier=+tier;if(!PORT[tier]||!ixName(city)||(!S.pops[ixCity(city)]&&(!remoteCities().includes(ixCity(city))||tier>1))||(S.ixp[city]!==undefined&&tier<=S.ixp[city]))return;if(S.pops[ixCity(city)]&&!portOk(ixCity(city),tier)){toast(tr("Your router can't take a {port} port.
Upgrade it in the Infra tab.",{port:PORT[tier].n}),'bad');sfx('err');return;}{const h0=S.ixp[city]!==undefined;if(!S.myIx[city]&&!portGate(ixCity(city),h0?(PORT_SLOT(tier)-PORT_SLOT(S.ixp[city]))*((S.ixn||{})[city]||1):PORT_SLOT(tier)))return;} if(isDk(city)&&S.ixp[city]===undefined&&!signed){const dk=dkState();if(dk.stall>S.day){toast(tr('DE-KICKS sales is still "aligning".
They will get back to you in {n} days.',{n:dk.stall-S.day}),'bad');sfx('err');return;}dk.lastQ=dk.lastQ||{};const lq=dk.lastQ[city];dk.q={city,tier,m:lq&&lq.until>S.day?lq.m:dkQuoteMult(),h:lq&&lq.until>S.day?lq.h:0};dk.lastQ[city]={m:dk.q.m,h:dk.q.h,until:S.day+90};dkQuoteModal();return;}const had=S.ixp[city]!==undefined;if(!spend(ixPortMo(city,tier)*(had?((S.ixn||{})[city]||1):1)))return;S.ixp[city]=tier;if(!had)toast(S.pops[ixCity(city)]?tr('Port up at {ix}!
Now request peering, or join the route server.',{ix:esc(ixName(city))}):tr("Remote port up at {ix}.
It came through a reseller, so expect a markup, a crowded port and some networks that won't talk to you. The route server is your friend here.",{ix:esc(ixName(city))}),'good');after();}, - cancelIx:({city,sure})=>{if(UI.confirm!=='ix'+city){UI.confirm='ix'+city;renderPanel();return;} + cancelIx:({city,sure,ok})=>{if(!ok&&UI.confirm!=='ix'+city){UI.confirm='ix'+city;renderPanel();return;} if(isDk(city)&&!sure){const dk=dkState();if(!dk.retUsed[city]){openModal(`
${tr('DE-KICKS Group · Customer Success')}

${tr('Wait! Before you go…')}

${tr('We value our partnership too much to let a little thing like price get in the way.')}

${tr('Retention offer')}${tr('40% off for 6 months')}

${tr('After that, the normal price returns, plus a small loyalty administration fee.')}

${btn(tr('Stay, take the discount'),'dkStay',{city},'pink')}${btn(tr('Leave anyway'),'cancelIx',{city,sure:1},'ghost')}
`);return;}} closeModal();if(S.dk){if(S.dk.m[city]){S.dk.lastQ=S.dk.lastQ||{};S.dk.lastQ[city]={m:S.dk.m[city],h:3,until:S.day+365};}delete S.dk.m[city];delete S.dk.add[city];delete S.dk.ret[city];}delete S.ixp[city];delete S.rs[city];if(S.ixn)delete S.ixn[city];for(const k in S.peers)if(k.endsWith('@'+city))delete S.peers[k];UI.confirm=null;after();}, rs:({city})=>{if(!isIx(city)||S.ixp[city]===undefined)return;S.rs[city]=!S.rs[city];if(S.rs[city])toast(tr('Route server session up.
You now peer with every open network on this IX, in one go.'),'good');sfx('build');after();}, @@ -2617,7 +2617,7 @@ const ACT={ pni:({city,net,tier})=>{tier=+tier;if(!S.pops[city]||!NET[net]||!NET[net].pops.includes(city)||!PORT[tier])return;if(!portOk(city,tier)){toast(tr("Your router can't take a {port} port.
Upgrade it in the Infra tab.",{port:PORT[tier].n}),'bad');sfx('err');return;}const r=peerOk(net,'pni',city);if(!r.ok){toast(tr('{net} declined the PNI.
{why}',{net:esc(NET[net].name),why:esc(r.why)}),'bad');sfx('err');after();return;}if(S.conf&&S.conf.until>S.day)S.stats.beerPni=1; const ex=S.pni.find(p=>p.city===city&&p.net===net);if(ex&&tier<=ex.tier)return;if(!portGate(city,ex?(PORT_SLOT(tier)-PORT_SLOT(ex.tier))*(ex.n||1):PORT_SLOT(tier)))return;if(!spend((1500+PORT[tier].setup/2)*(ex&&ex.n||1)))return;if(ex)ex.tier=tier;else S.pni.push({id:uid(),city,net,tier}); toast(tr('PNI with {net} is up.
A cross-connect in {dc}. Private and fast.',{net:esc(NET[net].name),dc:esc(CITY[city].dc)}),'good');after();}, - cancelPni:({id})=>{if(UI.confirm!==id){UI.confirm=id;renderPanel();return;}S.pni=S.pni.filter(p=>p.id!==id);UI.confirm=null;after();}, + cancelPni:({id,ok})=>{if(!ok&&UI.confirm!==id){UI.confirm=id;renderPanel();return;}S.pni=S.pni.filter(p=>p.id!==id);UI.confirm=null;after();}, cache:({city,net})=>{const n=NET[net];if(!n||!n.cache||!S.pops[city])return;if((R.demTo[net]||0){net} says not yet.
Send them {min}+ Gbps first.',{net:esc(n.name),min:n.cache.min}),'bad');sfx('err');return;}if(!portGate(city,1))return; S.caches.push({id:uid(),city,net});toast(tr('{cache} installed in {city}!
{net} shipped it for free. You pay {mo}/mo power.',{cache:esc(n.cache.name),city:CITY[city].name,net:esc(n.name),mo:fmt$(CACHE_MO)}),'good');sfx('build');after();}, rmCache:({id})=>{S.caches=S.caches.filter(c=>c.id!==id);after();}, @@ -2670,7 +2670,7 @@ const ACT={ connSort:({k})=>{if(!['k','city','name','use','mo'].includes(k))return;if(UI.connSort===k)UI.connDir=-(UI.connDir||1);else{UI.connSort=k;UI.connDir=k==='use'||k==='mo'?-1:1;}renderDash();}, connFor:({net})=>{if(!NET[net])return;UI.cf={net};ACT.connOpen();}, connCancel:({k,id})=>{const r=conns().find(x=>x.k===k&&x.id===id);if(!r||r.mine)return;const key='cc:'+k+':'+id;if(UI.confirm!==key){UI.confirm=key;renderDash();return;}UI.confirm=null; - if(k==='t'){UI.confirm=id;ACT.cancelTransit({id});}else if(k==='p'){UI.confirm=id;ACT.cancelPni({id});}else if(k==='ix'){UI.confirm='ix'+id;ACT.cancelIx({city:id});}else if(k==='c')ACT.rmCache({id});else{const [city,prov]=id.split('|');ACT.rmNni({city,prov});}renderDash();}, + if(k==='t')ACT.cancelTransit({id,ok:1});else if(k==='p')ACT.cancelPni({id,ok:1});else if(k==='ix')ACT.cancelIx({city:id,ok:1});else if(k==='c')ACT.rmCache({id});else{const [city,prov]=id.split('|');ACT.rmNni({city,prov});}renderDash();}, connOpen:()=>{if(!S)return;UI.dtab='conn';const d=$('dash');d.hidden=false;renderDash();d.scrollTop=0;}, applyCn:()=>{if(S.cnLic.state!=='none')return;if(!spend(CN_LIC))return;S.cnLic={state:'pending',ready:S.day+45};toast(tr('Application filed.
Your local partner says about 45 days. Probably.'),'goal');after();}, togglePrem:({id})=>{const t=S.transit.find(x=>x.id===id);if(!t)return;t.premium=!t.premium;sfx('click');after();}, @@ -3336,13 +3336,17 @@ function swapOptics(km,cap,sub,sys){for(let r=0;r<=(sub?0:REGEN_MAX);r++){const if(b){const n=Math.ceil(cap/b.g);return {n,r,up:Math.round(n*b.c*(1+REGEN_CH*r))+r*REGEN_COST,mo:r*REGEN_MO};}}return null;} const leaseCap=ls=>ls.reduce((s,l)=>s+(l.kind==='vxc'?VXC[l.vt].g:l.kind==='df'?(l.ch||[]).reduce((t,o)=>t+optG(o,l),0):LT[l.tier].g),0); const swapOpt=(k,up,omo,days,mo)=>{const save=mo-omo;return {k,up,omo,days,save,pay:save>0?Math.ceil(up/save):0};}; +// Lighting leased capacity on a fiber you already have (#72 review): needs free channels, and optics cost money. +function litOn(L,cap){const free=chMax(L)-(L.ch||[]).length-soldSlots(L);let b=null; + for(const o in OPT){const O=OPT[o];if(O.lvl>lvl()||(O.sys==='roadm'&&!isRdm(L.sys))||[L.a,L.b].some(c=>S.pops[c]&&RG[S.pops[c].rgen||0].cls{const [a,b]=k.split('|'),sub=isSub(a,b),mo=ls.reduce((s,l)=>s+(l.mo||0),0),cap=leaseCap(ls); - const x={a,b,sub,ls,mo,cap,opts:[],own:pairLinks(a,b).find(l=>l.kind==='df'&&l.own)};if(x.own){x.best=mo;return x;} + const x={a,b,sub,ls,mo,cap,opts:[],own:pairLinks(a,b).find(l=>l.kind==='df'&&l.own&&l.ready<=S.day)};if(x.own){x.fit=litOn(x.own,cap);if(x.fit.fits)x.best=mo;return x;} // Waves and fabric circuits can also move onto a leased fiber pair: cheaper glass, but you buy the gear. const ws=ls.filter(l=>l.kind!=='df'),wmo=ws.reduce((s,l)=>s+(l.mo||0),0),sc=sub?subDfCable(a,b):null;x.iru=ls.find(l=>l.kind==='df'); - if(ws.length&&x.iru)x.lit=wmo; + if(ws.length&&x.iru){x.fit=litOn(x.iru,leaseCap(ws));if(x.fit.fits)x.lit=wmo;} else if(ws.length&&lvl()>=2&&(sub?sc:dfAllowed(a,b))){const km=sc?sc.km:kmBetween(a,b),sys=lvl()>=3?'roadm':'lite',wc=leaseCap(ws),op=swapOptics(km,wc,sub,sys); if(op&&op.n<=DF_SYS[sys].max)x.opts.push(swapOpt('iru',DF_SYS[sys].cost+ampCount(km)*AMP_COST+op.up,dfLeaseMo(km)+ampCount(km)*AMP_MO+op.mo,30,wmo));} // Dig on land, lay a cable between landing stations (even ones that share a landmass), or both. @@ -3360,8 +3364,8 @@ function leaseTab(){const xs=leaseSwaps(),tot=xs.reduce((s,x)=>s+x.mo,0); const plan=(x,o)=>btn(o.k==='iru'?tr('Plan dark fiber'):o.k==='cab'?tr('Plan a cable'):tr('Plan your own fiber'),'leaseSwap',{a:x.a,b:x.b,src:o.k==='iru'?'lease':o.k==='cab'?'cable':'build'},o.save>0&&o.save===x.best?'pink sm':'ghost sm'); return `

${tr('Leased lines')}

${tr('Every wave, fabric circuit and dark fiber IRU you rent between two of your POPs, next to what leased dark fiber or your own fiber would cost. Estimates include the line system, amplifiers and enough optics for today’s capacity. Build first, move the traffic, then cancel the lease.')}

${xs.length?`
${tr('You pay for leases')}${tr('{price}/mo',{price:fmt$(tot)})}
`+xs.map(x=>`
${CITY[x.a].name} ⇄ ${CITY[x.b].name} ${x.sub?tr('subsea'):tr('land')}
${Object.entries(x.ls.reduce((m,l)=>(m[kind(l)]=(m[kind(l)]||0)+1,m),{})).map(([k,n])=>n>1?`${n} × ${k}`:k).join(', ')} · ${tr('{price}/mo',{price:fmt$(x.mo)})}
- ${x.own?`
${tr('You already own fiber here. Light more channels on it, then cancel the lease to save {price}/mo.',{price:fmt$(x.best)})}
`:''}${x.lit!==undefined?`
${tr('You already lease dark fiber here. Light more channels on it, then cancel the waves to save {price}/mo.',{price:fmt$(x.lit)})}
`:''}${x.opts.map(o=>line(x,o)).join('')}${!x.own&&x.why?`
${esc(x.why)}
`:''} -
${x.own?btn(tr('Open your fiber'),'dashLink',{id:x.own.id},'pink sm'):''}${x.lit!==undefined?btn(tr('Open your dark fiber'),'dashLink',{id:x.iru.id},'pink sm'):''}${x.opts.map(o=>plan(x,o)).join('')}${btn(tr('Open lease'),'dashLink',{id:(x.ls.find(l=>l.kind!=='df')||x.ls[0]).id},'ghost sm')}
`).join(''):`

${tr('You do not lease any lines between your POPs.')}

`}
`;} + ${x.fit&&x.fit.fits?`
${x.own?tr('You already own fiber here. Light {n} more channels for {up}, then cancel the lease to save {price}/mo.',{n:x.fit.n,up:fmt$(x.fit.up),price:fmt$(x.best)}):tr('You already lease dark fiber here. Light {n} more channels for {up}, then cancel the waves to save {price}/mo.',{n:x.fit.n,up:fmt$(x.fit.up),price:fmt$(x.lit)})}
`:x.fit?`
${x.fit.n?tr('Your fiber here has room for {free} more channels, and moving these leases needs {n}. Light another fiber pair or upgrade the line system first.',{free:Math.max(0,x.fit.free),n:x.fit.n}):tr('No optic you can buy works on your fiber here yet.')}
`:''}${x.opts.map(o=>line(x,o)).join('')}${!x.own&&x.why?`
${esc(x.why)}
`:''} +
${x.own?btn(tr('Open your fiber'),'dashLink',{id:x.own.id},'pink sm'):''}${x.iru&&x.fit?btn(tr('Open your dark fiber'),'dashLink',{id:x.iru.id},x.lit!==undefined?'pink sm':'ghost sm'):''}${x.opts.map(o=>plan(x,o)).join('')}${btn(tr('Open lease'),'dashLink',{id:(x.ls.find(l=>l.kind!=='df')||x.ls[0]).id},'ghost sm')}
`).join(''):`

${tr('You do not lease any lines between your POPs.')}

`}`;} function dashTabs(){const u=custStats().unhappy,cur=UI.dtab||'overview',L={overview:tr('Overview'),cust:tr('Customers'),conn:tr('Connections'),traffic:tr('Traffic'),infra:tr('Links & routers'),lease:tr('Leased lines')}; return ``;} function renderDash(){checkLayer(); diff --git a/tests/issues.test.js b/tests/issues.test.js index 96a8209..e28da7e 100644 --- a/tests/issues.test.js +++ b/tests/issues.test.js @@ -769,3 +769,44 @@ test('connections in the NOC dashboard can be upgraded and grown into LAGs right assert.equal(ev("document.getElementById('dash').hidden"), false); assert.deepEqual(errors, []); }); + +test('leased-line savings only count when your own glass has room, and include the optics', () => { + const { ev, errors } = load(); + ev("ACT.start({});S.cash=1e9;S.lvl=4;for(const g of GOALS)S.done[g.id]=0;ACT.launchBB({city:'fra'});ACT.buildPop({city:'ams'});S.pops.fra.rgen=S.pops.ams.rgen=3"); + // a 400G leased wave next to your own, almost full Rainbow fiber + ev("S.links.push({id:'w',a:'fra',b:'ams',kind:'wave',tier:2,km:450,mo:3000,mult:1,trench:'t',cut:0,day:0},{id:'own',a:'fra',b:'ams',kind:'df',own:true,km:450,sys:'lite',ch:Array(16).fill('zr4'),ready:0,mo:100,day:0,cut:0});compute()"); + let x = JSON.parse(ev("JSON.stringify(leaseSwaps().find(x=>x.a==='ams'||x.b==='ams'))")); + assert.equal(x.best, undefined, 'a full fiber saves nothing'); + assert.equal(x.fit.fits, false); + ev("UI.dtab='lease';$('dash').hidden=false;renderDash()"); + assert.match(ev("$('dash').textContent"), /room for 0 more channels/); + // with room on the fiber: savings, and the optics are priced + ev("S.links.find(l=>l.id==='own').ch=Array(10).fill('zr4');compute()"); + x = JSON.parse(ev("JSON.stringify(leaseSwaps().find(x=>x.a==='ams'||x.b==='ams'))")); + assert.equal(x.best, 3000); + assert.equal(x.fit.n, 1); + assert.equal(x.fit.up, ev("chCost(S.links.find(l=>l.id==='own'),'zr8')"), 'the cheapest optic per gigabit both routers take'); + ev("S.pops.ams.rgen=1;compute()"); + assert.equal(ev("litOn(S.links.find(l=>l.id==='own'),400).up"), ev("chCost(S.links.find(l=>l.id==='own'),'zr4')"), 'an Edge Lord at one end only takes 400ZR+'); + ev("S.pops.ams.rgen=3;compute()"); + // the same for waves next to a leased IRU + ev("S.links=S.links.filter(l=>l.id!=='own');S.links.push({id:'iru',a:'fra',b:'ams',kind:'df',own:false,km:450,sys:'lite',ch:Array(16).fill('zr4'),ready:0,mo:900,day:0,cut:0});compute()"); + x = JSON.parse(ev("JSON.stringify(leaseSwaps().find(x=>x.a==='ams'||x.b==='ams'))")); + assert.equal(x.lit, undefined, 'a full IRU cannot take the waves'); + assert.deepEqual(errors, []); +}); + +test('cancelling from the Connections list confirms once, without forging the panel state', () => { + const { ev, errors } = load(); + ev("ACT.start({});S.cash=1e8;for(const g of GOALS)S.done[g.id]=0;ACT.launchBB({city:'fra'});ACT.buyTransit({city:'fra',net:'cog',tier:1});compute()"); + const id = ev("S.transit[0].id"); + ev(`ACT.connCancel({k:'t',id:'${id}'})`); + assert.equal(ev('S.transit.length'), 1, 'first tap asks'); + ev(`ACT.connCancel({k:'t',id:'${id}'})`); + assert.equal(ev('S.transit.length'), 0, 'second tap cancels'); + assert.equal(ev('UI.confirm'), null); + ev(`ACT.buyTransit({city:'fra',net:'cog',tier:1})`); + ev(`ACT.cancelTransit({id:S.transit[0].id})`); + assert.equal(ev('S.transit.length'), 1, 'the POP panel still asks first'); + assert.deepEqual(errors, []); +});