-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Add Firmware/Download to Setup tab, add ':', formatting (#4444) #4450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -212,7 +212,7 @@ setup.initialize = function (callback) { | |
| build_date_e = $(".build-date"), | ||
| build_type_e = $(".build-type"), | ||
| build_info_e = $(".build-info"), | ||
| build_options_e = $(".build-options"); | ||
| build_firmware_e = $(".build-firmware"); | ||
|
|
||
| // DISARM FLAGS | ||
| // We add all the arming/disarming flags available, and show/hide them if needed. | ||
|
|
@@ -364,80 +364,104 @@ setup.initialize = function (callback) { | |
| } | ||
| } | ||
|
|
||
| // Gets the build root base URI for build.betaflight.com | ||
| const getBuildRootBaseUri = function () { | ||
| return `https://build.betaflight.com/api/builds/${FC.CONFIG.buildKey}`; | ||
| }; | ||
|
|
||
| // Fills in the "Build info" part of the "Firmware info" box | ||
| const showBuildInfo = function () { | ||
| const supported = FC.CONFIG.buildKey.length === 32; | ||
| const isIspConnected = ispConnected(); | ||
| const buildKeyValid = FC.CONFIG.buildKey.length === 32; | ||
|
|
||
| if (supported && ispConnected()) { | ||
| const buildRoot = `https://build.betaflight.com/api/builds/${FC.CONFIG.buildKey}`; | ||
| if (buildKeyValid && isIspConnected) { | ||
| const buildRoot = getBuildRootBaseUri(); | ||
|
|
||
| // Creates the "Config" button | ||
| const buildConfig = `<span class="buildInfoBtn" title="${i18n.getMessage( | ||
| "initialSetupInfoBuildConfig", | ||
| )}: ${buildRoot}/json"> | ||
| <a href="${buildRoot}/json" target="_blank"><strong>${i18n.getMessage( | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ask me how much I like prettier some day... ;) |
||
| <a href="${buildRoot}/json" target="_blank"><strong>${i18n.getMessage( | ||
| "initialSetupInfoBuildConfig", | ||
| )}</strong></a></span>`; | ||
|
|
||
| // Creates the "Log" button | ||
| const buildLog = `<span class="buildInfoBtn" title="${i18n.getMessage( | ||
| "initialSetupInfoBuildLog", | ||
| )}: ${buildRoot}/log"> | ||
| <a href="${buildRoot}/log" target="_blank"><strong>${i18n.getMessage( | ||
| <a href="${buildRoot}/log" target="_blank"><strong>${i18n.getMessage( | ||
| "initialSetupInfoBuildLog", | ||
| )}</strong></a></span>`; | ||
| build_info_e.html(`<span class="buildInfoBtn" title="${i18n.getMessage( | ||
haslinghuis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "initialSetupInfoBuildOptions", | ||
| )}"> | ||
| <a class="buildOptions" href=#"><strong>${i18n.getMessage( | ||
| "initialSetupInfoBuildOptionList", | ||
| )}</strong></a></span>`); | ||
|
|
||
| // Shows the "Config" and "Log" buttons | ||
| build_info_e.html(`${buildConfig} ${buildLog}`); | ||
| } else { | ||
| build_info_e.html( | ||
| supported ? i18n.getMessage("initialSetupNotOnline") : i18n.getMessage("initialSetupNoBuildInfo"), | ||
| isIspConnected | ||
| ? i18n.getMessage("initialSetupNoBuildInfo") | ||
| : i18n.getMessage("initialSetupNotOnline"), | ||
| ); | ||
| } | ||
| }; | ||
|
|
||
| const showBuildOptions = function () { | ||
| const supported = | ||
| ((semver.eq(FC.CONFIG.apiVersion, API_VERSION_1_45) && ispConnected()) || | ||
| // Fills in the "Firmware" part of the "Firmware info" box | ||
| const showBuildFirmware = function () { | ||
| const isIspConnected = ispConnected(); | ||
| const buildOptionsValid = | ||
| ((semver.eq(FC.CONFIG.apiVersion, API_VERSION_1_45) && isIspConnected) || | ||
| semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) && | ||
| FC.CONFIG.buildOptions.length; | ||
|
|
||
| if (supported) { | ||
| let buildOptionList = `<div class="dialogBuildInfoGrid-container">`; | ||
| for (const buildOptionElement of FC.CONFIG.buildOptions) { | ||
| buildOptionList += `<div class="dialogBuildInfoGrid-item">${buildOptionElement}</div>`; | ||
| } | ||
| buildOptionList += `</div>`; | ||
|
|
||
| build_options_e.html(`<span class="buildInfoBtn" title="${i18n.getMessage( | ||
haslinghuis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "initialSetupInfoBuildOptions", | ||
| )}"> | ||
| <a class="buildOptions" href=#"><strong>${i18n.getMessage( | ||
| "initialSetupInfoBuildOptionList", | ||
| )}</strong></a></span>`); | ||
|
|
||
| const buildOptions = `<span class="buildInfoBtn" title="${i18n.getMessage( | ||
| "initialSetupInfoBuildOptionList", | ||
| )}"> | ||
| <a class="buildOptions" href=#"><strong>${i18n.getMessage( | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pure consistency change, this matches the formatting 7 lines above. I think prettier should have made this itself. |
||
| const buildKeyValid = FC.CONFIG.buildKey.length === 32; | ||
| const buildRoot = getBuildRootBaseUri(); | ||
|
|
||
| if (buildOptionsValid || buildKeyValid) { | ||
| // Creates the "Options" button (if possible) | ||
| const buildOptions = buildOptionsValid | ||
| ? `<span class="buildInfoBtn" title="${i18n.getMessage("initialSetupInfoBuildOptionList")}"> | ||
| <a class="buildOptions" href="#"><strong>${i18n.getMessage( | ||
| "initialSetupInfoBuildOptions", | ||
| )}</strong></a></span>`; | ||
|
|
||
| build_options_e.html(buildOptions); | ||
| )}</strong></a></span>` | ||
| : ""; | ||
|
|
||
| // Creates the "Download" button (if possible) | ||
| const buildDownload = buildKeyValid | ||
| ? `<span class="buildInfoBtn" title="${i18n.getMessage( | ||
| "initialSetupInfoBuildDownload", | ||
| )}: ${buildRoot}/hex"> | ||
| <a href="${buildRoot}/hex" target="_blank"><strong>${i18n.getMessage( | ||
| "initialSetupInfoBuildDownload", | ||
| )}</strong></a></span>` | ||
| : ""; | ||
|
|
||
| // Shows the "Options" and/or "Download" buttons | ||
| build_firmware_e.html(`${buildOptions} ${buildDownload}`); | ||
|
|
||
| if (buildOptionsValid) { | ||
| // Creates and attaches the "Options" dialog | ||
| let buildOptionList = `<div class="dialogBuildInfoGrid-container">`; | ||
| for (const buildOptionElement of FC.CONFIG.buildOptions) { | ||
| buildOptionList += `<div class="dialogBuildInfoGrid-item">${buildOptionElement}</div>`; | ||
| } | ||
| buildOptionList += `</div>`; | ||
|
|
||
| $("a.buildOptions").on("click", async function () { | ||
| showDialogBuildInfo( | ||
| `<h3>${i18n.getMessage("initialSetupInfoBuildOptionList")}</h3>`, | ||
| buildOptionList, | ||
| ); | ||
| }); | ||
| $("a.buildOptions").on("click", async function () { | ||
| showDialogBuildInfo( | ||
| `<h3>${i18n.getMessage("initialSetupInfoBuildOptionList")}</h3>`, | ||
| buildOptionList, | ||
| ); | ||
| }); | ||
| } | ||
| } else { | ||
| // should not happen, but just in case | ||
| build_options_e.html(`${i18n.getMessage("initialSetupNoBuildInfo")}`); | ||
| build_firmware_e.html( | ||
| isIspConnected | ||
| ? i18n.getMessage("initialSetupNoBuildInfo") | ||
| : i18n.getMessage("initialSetupNotOnline"), | ||
| ); | ||
| } | ||
| }; | ||
|
|
||
| // Fills in the "Firmware info" box | ||
| function showFirmwareInfo() { | ||
| // Firmware info | ||
| msp_api_e.text(FC.CONFIG.apiVersion); | ||
| build_date_e.text(FC.CONFIG.buildInfo); | ||
|
|
||
|
|
@@ -448,7 +472,7 @@ setup.initialize = function (callback) { | |
| : i18n.getMessage("initialSetupInfoBuildLocal"), | ||
| ); | ||
| showBuildInfo(); | ||
| showBuildOptions(); | ||
| showBuildFirmware(); | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.