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('We value our partnership too much to let a little thing like price get in the way.')}
${tr('After that, the normal price returns, plus a small loyalty administration fee.')}
${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 do not lease any lines between your POPs.')}
`}${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, []); +});