diff --git a/frontend/src/tools/devtools.jsx b/frontend/src/tools/devtools.jsx index 1bd78ba..148ca7a 100644 --- a/frontend/src/tools/devtools.jsx +++ b/frontend/src/tools/devtools.jsx @@ -270,10 +270,210 @@ function CronBuilder() { } // ── Tool-Definitionen ───────────────────────────────────────────────────────── +// ── Elektro-Rechner ─────────────────────────────────────────────────────────── +function ElektroRechner({ mobile }) { + // Eingabe-State für alle Formeln + const [vals, setVals] = useState({}); + const set = (k, v) => setVals(p => ({ ...p, [k]: v })); + const n = k => { const v = parseFloat(vals[k]); return isNaN(v) ? null : v; }; + const fmt = (v, unit, digits=3) => v == null ? '—' : `${parseFloat(v.toPrecision(digits))} ${unit}`; + + // Strompreis für Kostenrechner + const [preis, setPreis] = useState('0.30'); + + const Inp = ({ k, label, unit, placeholder }) => ( +
+
{label} [{unit}]
+ set(k,e.target.value)} + placeholder={placeholder||''} + style={{ ...S.inp, fontSize:13, padding:'7px 9px', width:'100%', boxSizing:'border-box' }}/> +
+ ); + + const Result = ({ label, value, highlight }) => ( +
+ {label} + {value} +
+ ); + + const Section = ({ title, children }) => ( +
+
{title}
+ {children} +
+ ); + + const cols = mobile ? '1fr' : '1fr 1fr'; + + // ── Ohmsches Gesetz ── + const U1=n('u1'), I1=n('i1'), R1=n('r1'); + const ohmRes = { + U: U1 ?? (I1!=null&&R1!=null ? I1*R1 : null), + I: I1 ?? (U1!=null&&R1!=null ? U1/R1 : null), + R: R1 ?? (U1!=null&&I1!=null ? U1/I1 : null), + }; + + // ── Leistung P = U * I ── + const U2=n('u2'), I2=n('i2'), P2=n('p2'), R2=n('r2'); + const leistRes = (() => { + if (U2!=null&&I2!=null) return { P:U2*I2, U:U2, I:I2, R:U2/I2 }; + if (P2!=null&&U2!=null) return { P:P2, I:P2/U2, U:U2, R:U2*U2/P2 }; + if (P2!=null&&I2!=null) return { P:P2, U:P2/I2, I:I2, R:P2/(I2*I2) }; + if (P2!=null&&R2!=null) return { P:P2, U:Math.sqrt(P2*R2), I:Math.sqrt(P2/R2), R:R2 }; + if (U2!=null&&R2!=null) return { P:U2*U2/R2, U:U2, I:U2/R2, R:R2 }; + if (I2!=null&&R2!=null) return { P:I2*I2*R2, U:I2*R2, I:I2, R:R2 }; + return null; + })(); + + // ── Energie & Kosten ── + const Pw=n('pw'), Std=n('std'), Tage=n('tage'); + const kwhTag = Pw!=null&&Std!=null ? (Pw/1000)*Std : null; + const kwhMonat= kwhTag!=null&&Tage!=null ? kwhTag*Tage : (kwhTag!=null ? kwhTag*30 : null); + const kwhJahr = kwhTag!=null ? kwhTag*365 : null; + const ep = parseFloat(preis); + const kostenTag = kwhTag!=null ? kwhTag*ep : null; + const kostenMonat = kwhMonat!=null ? kwhMonat*ep : null; + const kostenJahr = kwhJahr!=null ? kwhJahr*ep : null; + + // ── Wirkungsgrad ── + const Pa=n('pa'), Pe=n('pe'); + const eta = Pa!=null&&Pe!=null&&Pe>0 ? (Pa/Pe)*100 : null; + const verlust = Pa!=null&&Pe!=null ? Pe-Pa : null; + + // ── Serienschaltung Widerstände ── + const r_ser = ['rs1','rs2','rs3','rs4'].map(k=>n(k)).filter(v=>v!=null); + const R_ser = r_ser.reduce((a,b)=>a+b, 0) || null; + + // ── Parallelschaltung Widerstände ── + const r_par = ['rp1','rp2','rp3','rp4'].map(k=>n(k)).filter(v=>v!=null); + const R_par = r_par.length ? 1/(r_par.reduce((a,b)=>a+1/b, 0)) : null; + + // ── Kondensator Ladestrom ── + const Cap=n('cap'), Uc=n('uc'), Tc=n('tc'); + const Ic = Cap!=null&&Uc!=null&&Tc!=null ? Cap*(Uc/Tc) : null; + + return ( +
+ {/* Info */} +
+ Felder ausfüllen → Ergebnis erscheint automatisch · Mindestens 2 bekannte Größen eingeben +
+ +
+
+ {/* Ohmsches Gesetz */} +
+
+ + + +
+ + + +
+ + {/* Leistung */} +
+
+ + + + +
+ {leistRes ? <> + + + + + :
Mindestens 2 Werte eingeben
} +
+ + {/* Wirkungsgrad */} +
+
+ + +
+ + +
+
+ +
+ {/* Stromkosten */} +
+
+ + + +
+
+
+ Strompreis [€/kWh] +
+ setPreis(e.target.value)} + step="0.01" min="0" + style={{ ...S.inp, fontSize:13, padding:'7px 9px', width:'100%', boxSizing:'border-box' }}/> +
+ + + + + + +
+ + {/* Widerstände */} +
+
+
SERIE (R = R1+R2+…)
+
+ {['rs1','rs2','rs3','rs4'].map(k=>)} +
+ =2 ? fmt(R_ser,'Ω') : '—'} highlight={r_ser.length>=2}/> +
+
+
PARALLEL (1/R = 1/R1+1/R2+…)
+
+ {['rp1','rp2','rp3','rp4'].map(k=>)} +
+ =2 ? fmt(R_par,'Ω') : '—'} highlight={r_par.length>=2}/> +
+
+ + {/* Kondensator */} +
+
+ + + +
+ +
+
+
+ + {/* Reset */} + +
+ ); +} + const TOOL_DEFS = [ - {id:'cron', label:'⏱ Crontab', desc:'Crontab erklären und erstellen', ready:true, + {id:'cron', label:'⏱ Crontab', desc:'Crontab erklären und erstellen', ready:true, tabs:[{id:'explain',label:'Erklären'},{id:'build',label:'Erstellen'}], components:{explain:CronExplainer,build:CronBuilder}}, + {id:'elektro', label:'⚡ Elektro', desc:'Ohm, Leistung, Kosten, Widerstände', ready:true, component:ElektroRechner}, {id:'json', label:'{ } JSON', desc:'JSON formatieren', ready:false}, {id:'base64', label:'🔐 Base64', desc:'Text ↔ Base64', ready:false}, {id:'regex', label:'🔍 Regex', desc:'Regex testen', ready:false},