Files
pyMC_Repeater/repeater/web/html/assets/TxPowerNoticeModal-CqoLot4C.js
T
2026-07-12 22:35:57 +01:00

1 line
8.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{N as e,T as t,U as n,X as r,_t as i,c as a,h as o,i as s,l as c,m as l,o as u,s as d,u as f}from"./runtime-core.esm-bundler-CINEgm0a.js";import{l as p,t as m}from"./runtime-dom.esm-bundler-B3VeUO8l.js";import{v as h}from"./api-GPpxWKdp.js";import{t as g}from"./createLucideIcon-D-_sbJKW.js";var _=g(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),v=h(`setup`,()=>{let e=n(1),t=n(6),r=n(`pyRpt${Math.floor(Math.random()*1e4).toString().padStart(4,`0`)}`),i=n(null),a=n(null),o=n(null),s=n(``),c=n(``),l=n(`/dev/ttyACM0`),d=n(``),f=n(5055),p=n(``),m=n(!1),h=n({frequency:`915.0`,spreading_factor:`7`,bandwidth:`125`,coding_rate:`5`,tx_power:`14`}),g=n([]),_=n([]),v=n(!1),y=n(!1),b=n(null),x=u(()=>{switch(e.value){case 1:return!0;case 2:return r.value.trim().length>0;case 3:return a.value!==null;case 4:{if(!i.value)return!1;let e=i.value.key.toLowerCase();return e===`kiss`||e===`pymc_usb`?l.value.trim().length>0:e===`pymc_tcp`?d.value.trim().length>0:!0}case 5:return m.value?h.value.frequency&&h.value.spreading_factor&&h.value.bandwidth&&h.value.coding_rate&&h.value.tx_power:o.value!==null;case 6:return s.value.length>=6&&s.value===c.value;default:return!1}}),S=u(()=>e.value>1),C=u(()=>e.value===t.value);async function w(){v.value=!0,b.value=null;try{let e=await(await fetch(`/api/hardware_options`)).json();if(e.error)throw Error(e.error);g.value=e.hardware||[]}catch(e){b.value=e instanceof Error?e.message:`Failed to load hardware options`,console.error(`Error fetching hardware options:`,e)}finally{v.value=!1}}let T=e=>({title:String(e.title??``),description:String(e.description??``),frequency:String(e.frequency??``),spreading_factor:String(e.spreading_factor??``),bandwidth:String(e.bandwidth??``),coding_rate:String(e.coding_rate??``),tx_power:String(e.tx_power??`14`)});async function E(){v.value=!0,b.value=null;try{try{let e=new AbortController,t=setTimeout(()=>e.abort(),4e3);try{let t=await fetch(`https://api.meshcore.nz/api/v1/config`,{signal:e.signal});if(t.ok){let e=(await t.json())?.config?.suggested_radio_settings?.entries??[];if(e.length>0){_.value=e.map(e=>T(e));return}}}finally{clearTimeout(t)}}catch{}let e=await(await fetch(`/api/radio_presets`)).json();if(e.error)throw Error(e.error);_.value=(e.presets??[]).map(e=>T(e))}catch(e){b.value=e instanceof Error?e.message:`Failed to load radio presets`,console.error(`Error fetching radio presets:`,e)}finally{v.value=!1}}async function D(){if(!x.value)return{success:!1,error:`Please complete all required fields`};y.value=!0,b.value=null;try{let e=m.value?{title:`Custom Configuration`,description:`Custom radio settings`,frequency:h.value.frequency,spreading_factor:h.value.spreading_factor,bandwidth:h.value.bandwidth,coding_rate:h.value.coding_rate,tx_power:h.value.tx_power}:{...o.value},t=i.value?.config?.tx_power;t!=null&&t!==``&&(e.tx_power=String(t));let n=Number(e.tx_power??14);if(!Number.isFinite(n)||n<-9||n>22)throw Error(`TX power must be between -9 and +22 dBm`);let a=await(await fetch(`/api/setup_wizard`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({node_name:r.value.trim(),hardware_key:i.value?.key,radio_preset:e,admin_password:s.value,...i.value&&(()=>{let e=i.value.key.toLowerCase();return e===`kiss`?{kiss_port:l.value.trim()||`/dev/ttyUSB0`,kiss_baud_rate:115200}:e===`pymc_usb`?{pymc_usb_port:l.value.trim()||`/dev/ttyACM0`,pymc_usb_baudrate:921600}:e===`pymc_tcp`?{pymc_tcp_host:d.value.trim(),pymc_tcp_port:f.value,pymc_tcp_token:p.value.trim()}:{}})()})})).json();if(!a.success)throw Error(a.error||`Setup failed`);return{success:!0,data:a}}catch(e){let t=e instanceof Error?e.message:`Failed to complete setup`;return b.value=t,{success:!1,error:t}}finally{y.value=!1}}function O(){x.value&&e.value<t.value&&e.value++}function k(){S.value&&e.value--}function A(n){n>=1&&n<=t.value&&(e.value=n)}function j(){e.value=1,r.value=`pyRpt${Math.floor(Math.random()*1e4).toString().padStart(4,`0`)}`,i.value=null,a.value=null,o.value=null,m.value=!1,h.value={frequency:`915.0`,spreading_factor:`7`,bandwidth:`125`,coding_rate:`5`,tx_power:`14`},s.value=``,c.value=``,l.value=`/dev/ttyACM0`,d.value=``,f.value=5055,p.value=``,b.value=null}return{currentStep:e,totalSteps:t,nodeName:r,selectedHardware:i,selectedHardwareConnection:a,selectedRadioPreset:o,useCustomRadio:m,usbPort:l,tcpHost:d,tcpPort:f,tcpToken:p,customRadio:h,adminPassword:s,confirmPassword:c,hardwareOptions:g,radioPresets:_,isLoading:v,isSubmitting:y,error:b,canGoNext:x,canGoBack:S,isLastStep:C,fetchHardwareOptions:w,fetchRadioPresets:E,completeSetup:D,nextStep:O,previousStep:k,goToStep:A,reset:j}}),y={class:`w-full max-w-2xl rounded-3xl border border-accent-amber/opacity-medium bg-white dark:bg-surface-elevated shadow-[0_20px_80px_color-mix(in_srgb,var(--color-shadow-strong)_35%,transparent)] overflow-hidden`},b={class:`p-5 border-b border-accent-amber/opacity-medium bg-accent-amber/opacity-light`},x={class:`flex items-start gap-3`},S={class:`rounded-full bg-accent-amber/opacity-light text-accent-amber p-2`},C={key:0,class:`text-xs text-content-secondary dark:text-content-muted mt-1`},w={key:1,class:`text-xs text-content-secondary dark:text-content-muted mt-1`},T={class:`p-5 space-y-3 text-sm text-content-secondary dark:text-content-muted max-h-[60vh] overflow-y-auto`},E={class:`flex items-start gap-2 pt-1`},D=[`checked`],O={class:`modal-actions`},k=[`disabled`],A=o({__name:`TxPowerNoticeModal`,props:{show:{type:Boolean},confirmed:{type:Boolean},selectedTxPower:{default:null},actionLabel:{default:`I Understand, Continue`},busy:{type:Boolean,default:!1}},emits:[`update:show`,`update:confirmed`,`confirm`],setup(n,{emit:o}){let u=n,h=o;function g(){h(`update:show`,!1)}function v(){!u.confirmed||u.busy||h(`confirm`)}return(o,u)=>(t(),a(s,{to:`body`},[l(m,{name:`fade`},{default:e(()=>[n.show?(t(),f(`div`,{key:0,class:`modal-backdrop`,onClick:p(g,[`self`])},[d(`div`,y,[d(`div`,b,[d(`div`,x,[d(`div`,S,[l(r(_),{class:`w-5 h-5`})]),d(`div`,null,[u[1]||=d(`h4`,{class:`text-content-primary text-base font-semibold`},` TX Power & PA Configuration Notice `,-1),n.selectedTxPower===null?(t(),f(`p`,w,` Review this safety notice before applying TX power changes. `)):(t(),f(`p`,C,` Selected TX power: `+i(n.selectedTxPower)+` dBm `,1))])])]),d(`div`,T,[u[3]||=d(`p`,{class:`leading-relaxed`},` Always ensure your configured TX power complies with local country and regional radio regulations before transmitting. `,-1),u[4]||=d(`p`,{class:`leading-relaxed`},` Before changing TX power settings, research your specific LoRa board/module design carefully. Many SX1262-based boards include an external Power Amplifier (PA) and RF switching circuitry, which may require different configuration values, TX paths, or firmware settings than a standard SX1262 reference design. `,-1),u[5]||=d(`p`,{class:`leading-relaxed`},` Do not assume all boards support the same maximum power levels or PA configuration methods. `,-1),u[6]||=d(`div`,{class:`rounded-xl border border-stroke-subtle dark:border-white/opacity-light bg-background-mute/opacity-heavy dark:bg-white/opacity-subtle p-3`},[d(`p`,{class:`text-content-primary font-medium mb-2`},`Recommended checks before applying changes:`),d(`ul`,{class:`list-disc pl-5 space-y-1`},[d(`li`,null,`Verify whether your board includes an external PA/LNA stage`),d(`li`,null,`Confirm the manufacturers recommended TX power limits`),d(`li`,null,`Check required RXen/TXen or RF switch pin configuration`),d(`li`,null,`Use board-specific library settings where available`),d(`li`,null,`Ensure thermal limits and duty cycle recommendations are respected`),d(`li`,null,`Never transmit without a correctly connected antenna or suitable load`)])],-1),u[7]||=d(`p`,{class:`leading-relaxed text-accent-amber font-medium`},` Incorrect PA configuration can damage hardware, lock the radio into a busy state, or cause illegal RF output levels. `,-1),d(`label`,E,[d(`input`,{checked:n.confirmed,type:`checkbox`,class:`mt-0.5`,onChange:u[0]||=e=>h(`update:confirmed`,e.target.checked)},null,40,D),u[2]||=d(`span`,{class:`text-content-primary`},`I have read and understood this warning.`,-1)])]),d(`div`,O,[d(`button`,{type:`button`,class:`modal-btn-cancel`,onClick:g},` Cancel `),d(`button`,{type:`button`,class:`modal-btn-primary`,disabled:!n.confirmed||n.busy,onClick:v},i(n.actionLabel),9,k)])])])):c(``,!0)]),_:1})]))}});export{v as n,A as t};