@@ -3321,65 +3321,65 @@ function checkVersionUpgrade(info) {
33213321 fetch ( getURL ( '/edit?func=edit&path=/version-info.json' ) , {
33223322 method : 'get'
33233323 } )
3324- . then ( res => {
3325- if ( res . status === 404 ) {
3326- // File doesn't exist - first install, show install prompt
3327- showVersionUpgradePrompt ( info , null , info . ver ) ;
3328- return null ;
3329- }
3330- if ( ! res . ok ) {
3331- throw new Error ( 'Failed to fetch version-info.json' ) ;
3332- }
3333- return res . json ( ) ;
3334- } )
3335- . then ( versionInfo => {
3336- if ( ! versionInfo ) return ; // 404 case already handled
3337-
3338- // Check if user opted out
3339- if ( versionInfo . neverAsk ) return ;
3340-
3341- // Check if version has changed
3342- const currentVersion = info . ver ;
3343- const storedVersion = versionInfo . version || '' ;
3344-
3345- if ( storedVersion && storedVersion !== currentVersion ) {
3346- // Version has changed, show upgrade prompt
3347- showVersionUpgradePrompt ( info , storedVersion , currentVersion ) ;
3348- } else if ( ! storedVersion ) {
3349- // Empty version in file, show install prompt
3350- showVersionUpgradePrompt ( info , null , currentVersion ) ;
3351- }
3352- } )
3353- . catch ( e => {
3354- console . log ( 'Failed to load version-info.json' , e ) ;
3355- // On error, save current version for next time
3356- if ( info && info . ver ) {
3357- updateVersionInfo ( info . ver , false ) ;
3358- }
3359- } ) ;
3324+ . then ( res => {
3325+ if ( res . status === 404 ) {
3326+ // File doesn't exist - first install, show install prompt
3327+ showVersionUpgradePrompt ( info , null , info . ver ) ;
3328+ return null ;
3329+ }
3330+ if ( ! res . ok ) {
3331+ throw new Error ( 'Failed to fetch version-info.json' ) ;
3332+ }
3333+ return res . json ( ) ;
3334+ } )
3335+ . then ( versionInfo => {
3336+ if ( ! versionInfo ) return ; // 404 case already handled
3337+
3338+ // Check if user opted out
3339+ if ( versionInfo . neverAsk ) return ;
3340+
3341+ // Check if version has changed
3342+ const currentVersion = info . ver ;
3343+ const storedVersion = versionInfo . version || '' ;
3344+
3345+ if ( storedVersion && storedVersion !== currentVersion ) {
3346+ // Version has changed, show upgrade prompt
3347+ showVersionUpgradePrompt ( info , storedVersion , currentVersion ) ;
3348+ } else if ( ! storedVersion ) {
3349+ // Empty version in file, show install prompt
3350+ showVersionUpgradePrompt ( info , null , currentVersion ) ;
3351+ }
3352+ } )
3353+ . catch ( e => {
3354+ console . log ( 'Failed to load version-info.json' , e ) ;
3355+ // On error, save current version for next time
3356+ if ( info && info . ver ) {
3357+ updateVersionInfo ( info . ver , false ) ;
3358+ }
3359+ } ) ;
33603360}
33613361
33623362function showVersionUpgradePrompt ( info , oldVersion , newVersion ) {
33633363 // Determine if this is an install or upgrade
33643364 const isInstall = ! oldVersion ;
3365-
3365+
33663366 // Create overlay and dialog
33673367 const overlay = d . createElement ( 'div' ) ;
33683368 overlay . id = 'versionUpgradeOverlay' ;
33693369 overlay . style . cssText = 'position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.7);z-index:10000;display:flex;align-items:center;justify-content:center;' ;
3370-
3370+
33713371 const dialog = d . createElement ( 'div' ) ;
33723372 dialog . style . cssText = 'background:var(--c-1);border-radius:10px;padding:25px;max-width:500px;margin:20px;box-shadow:0 4px 6px rgba(0,0,0,0.3);' ;
3373-
3373+
33743374 // Build contextual message based on install vs upgrade
3375- const title = isInstall
3376- ? '🎉 Thank you for installing WLED!'
3375+ const title = isInstall
3376+ ? '🎉 Thank you for installing WLED!'
33773377 : '🎉 WLED Upgrade Detected!' ;
3378-
3378+
33793379 const description = isInstall
33803380 ? `You are now running WLED <strong style="text-wrap: nowrap">${ newVersion } </strong>.`
33813381 : `Your WLED has been upgraded from <strong style="text-wrap: nowrap">${ oldVersion } </strong> to <strong style="text-wrap: nowrap">${ newVersion } </strong>.` ;
3382-
3382+
33833383 const question = 'Help make WLED better with a one-time hardware report? It includes only device details like chip type, LED count, etc. — never personal data or your activities.'
33843384
33853385 dialog . innerHTML = `
@@ -3395,21 +3395,21 @@ function showVersionUpgradePrompt(info, oldVersion, newVersion) {
33953395 <button id="versionReportNever" class="btn">Never Ask</button>
33963396 </div>
33973397 ` ;
3398-
3398+
33993399 overlay . appendChild ( dialog ) ;
34003400 d . body . appendChild ( overlay ) ;
3401-
3401+
34023402 // Add event listeners
34033403 gId ( 'versionReportYes' ) . addEventListener ( 'click' , ( ) => {
34043404 reportUpgradeEvent ( info , oldVersion ) ;
34053405 d . body . removeChild ( overlay ) ;
34063406 } ) ;
3407-
3407+
34083408 gId ( 'versionReportNo' ) . addEventListener ( 'click' , ( ) => {
34093409 // Don't update version, will ask again on next load
34103410 d . body . removeChild ( overlay ) ;
34113411 } ) ;
3412-
3412+
34133413 gId ( 'versionReportNever' ) . addEventListener ( 'click' , ( ) => {
34143414 updateVersionInfo ( newVersion , true ) ;
34153415 d . body . removeChild ( overlay ) ;
@@ -3419,80 +3419,80 @@ function showVersionUpgradePrompt(info, oldVersion, newVersion) {
34193419
34203420function reportUpgradeEvent ( info , oldVersion ) {
34213421 showToast ( 'Reporting upgrade...' ) ;
3422-
3422+
34233423 // Fetch fresh data from /json/info endpoint as requested
34243424 fetch ( getURL ( '/json/info' ) , {
34253425 method : 'get'
34263426 } )
3427- . then ( res => res . json ( ) )
3428- . then ( infoData => {
3429- // Map to UpgradeEventRequest structure per OpenAPI spec
3430- // Required fields: deviceId, version, previousVersion, releaseName, chip, ledCount, isMatrix, bootloaderSHA256
3431- const upgradeData = {
3432- deviceId : infoData . deviceId , // Use anonymous unique device ID
3433- version : infoData . ver || '' , // Current version string
3434- previousVersion : oldVersion || '' , // Previous version from version-info.json
3435- releaseName : infoData . release || '' , // Release name (e.g., "WLED 0.15.0")
3436- chip : infoData . arch || '' , // Chip architecture (esp32, esp8266, etc)
3437- ledCount : infoData . leds ? infoData . leds . count : 0 , // Number of LEDs
3438- isMatrix : ! ! ( infoData . leds && infoData . leds . matrix ) , // Whether it's a 2D matrix setup
3439- bootloaderSHA256 : infoData . bootloaderSHA256 || '' , // Bootloader SHA256 hash
3440- brand : infoData . brand , // Device brand (always present)
3441- product : infoData . product , // Product name (always present)
3442- flashSize : infoData . flash // Flash size (always present)
3443- } ;
3444-
3445- // Add optional fields if available
3446- if ( infoData . psram !== undefined ) upgradeData . psramSize = infoData . psram ;
3447- // Note: partitionSizes not currently available in /json/info endpoint
3448-
3449- // Make AJAX call to postUpgradeEvent API
3450- return fetch ( 'https://usage.wled.me/api/usage/upgrade' , {
3451- method : 'POST' ,
3452- headers : {
3453- 'Content-Type' : 'application/json'
3454- } ,
3455- body : JSON . stringify ( upgradeData )
3456- } ) ;
3457- } )
3458- . then ( res => {
3459- if ( res . ok ) {
3460- showToast ( 'Thank you for reporting!' ) ;
3461- updateVersionInfo ( info . ver , false ) ;
3462- } else {
3427+ . then ( res => res . json ( ) )
3428+ . then ( infoData => {
3429+ // Map to UpgradeEventRequest structure per OpenAPI spec
3430+ // Required fields: deviceId, version, previousVersion, releaseName, chip, ledCount, isMatrix, bootloaderSHA256
3431+ const upgradeData = {
3432+ deviceId : infoData . deviceId , // Use anonymous unique device ID
3433+ version : infoData . ver || '' , // Current version string
3434+ previousVersion : oldVersion || '' , // Previous version from version-info.json
3435+ releaseName : infoData . release || '' , // Release name (e.g., "WLED 0.15.0")
3436+ chip : infoData . arch || '' , // Chip architecture (esp32, esp8266, etc)
3437+ ledCount : infoData . leds ? infoData . leds . count : 0 , // Number of LEDs
3438+ isMatrix : ! ! ( infoData . leds && infoData . leds . matrix ) , // Whether it's a 2D matrix setup
3439+ bootloaderSHA256 : infoData . bootloaderSHA256 || '' , // Bootloader SHA256 hash
3440+ brand : infoData . brand , // Device brand (always present)
3441+ product : infoData . product , // Product name (always present)
3442+ flashSize : infoData . flash // Flash size (always present)
3443+ } ;
3444+
3445+ // Add optional fields if available
3446+ if ( infoData . psram !== undefined ) upgradeData . psramSize = infoData . psram ;
3447+ // Note: partitionSizes not currently available in /json/info endpoint
3448+
3449+ // Make AJAX call to postUpgradeEvent API
3450+ return fetch ( 'https://usage.wled.me/api/usage/upgrade' , {
3451+ method : 'POST' ,
3452+ headers : {
3453+ 'Content-Type' : 'application/json'
3454+ } ,
3455+ body : JSON . stringify ( upgradeData )
3456+ } ) ;
3457+ } )
3458+ . then ( res => {
3459+ if ( res . ok ) {
3460+ showToast ( 'Thank you for reporting!' ) ;
3461+ updateVersionInfo ( info . ver , false ) ;
3462+ } else {
3463+ showToast ( 'Report failed. Please try again later.' , true ) ;
3464+ // Do NOT update version info on failure - user will be prompted again
3465+ }
3466+ } )
3467+ . catch ( e => {
3468+ console . log ( 'Failed to report upgrade' , e ) ;
34633469 showToast ( 'Report failed. Please try again later.' , true ) ;
3464- // Do NOT update version info on failure - user will be prompted again
3465- }
3466- } )
3467- . catch ( e => {
3468- console . log ( 'Failed to report upgrade' , e ) ;
3469- showToast ( 'Report failed. Please try again later.' , true ) ;
3470- // Do NOT update version info on error - user will be prompted again
3471- } ) ;
3470+ // Do NOT update version info on error - user will be prompted again
3471+ } ) ;
34723472}
34733473
34743474function updateVersionInfo ( version , neverAsk ) {
34753475 const versionInfo = {
34763476 version : version ,
34773477 neverAsk : neverAsk
34783478 } ;
3479-
3479+
34803480 // Create a Blob with JSON content and use /upload endpoint
3481- const blob = new Blob ( [ JSON . stringify ( versionInfo ) ] , { type : 'application/json' } ) ;
3481+ const blob = new Blob ( [ JSON . stringify ( versionInfo ) ] , { type : 'application/json' } ) ;
34823482 const formData = new FormData ( ) ;
34833483 formData . append ( 'data' , blob , 'version-info.json' ) ;
3484-
3484+
34853485 fetch ( getURL ( '/upload' ) , {
34863486 method : 'POST' ,
34873487 body : formData
34883488 } )
3489- . then ( res => res . text ( ) )
3490- . then ( data => {
3491- console . log ( 'Version info updated' , data ) ;
3492- } )
3493- . catch ( e => {
3494- console . log ( 'Failed to update version-info.json' , e ) ;
3495- } ) ;
3489+ . then ( res => res . text ( ) )
3490+ . then ( data => {
3491+ console . log ( 'Version info updated' , data ) ;
3492+ } )
3493+ . catch ( e => {
3494+ console . log ( 'Failed to update version-info.json' , e ) ;
3495+ } ) ;
34963496}
34973497
34983498size ( ) ;
0 commit comments