From ee10bb80815489173cb826e5a68a7e55d659472f Mon Sep 17 00:00:00 2001 From: Mark Haslinghuis Date: Thu, 2 May 2024 23:18:20 +0200 Subject: [PATCH] Fix options and expost local options --- locales/en/messages.json | 12 ++++++ src/js/tabs/setup.js | 84 +++++++++++++++++++++++----------------- src/tabs/setup.html | 8 ++++ 3 files changed, 69 insertions(+), 35 deletions(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index dadb73d390..2768576ae6 100755 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -1119,6 +1119,18 @@ "initialSetupInfoBuildEmpty": { "message": "Local Build - no Cloud information" }, + "initialSetupInfoBuildType": { + "message": "Build type" + }, + "initialSetupInfoBuildLocal": { + "message": "Local Build" + }, + "initialSetupInfoBuildCloud": { + "message": "Cloud Build" + }, + "initialSetupNoBuildInfo": { + "message": "No build information available" + }, "initialSetupNotOnline": { "message": "Server unavailable" }, diff --git a/src/js/tabs/setup.js b/src/js/tabs/setup.js index 328508887e..5e0d806e30 100644 --- a/src/js/tabs/setup.js +++ b/src/js/tabs/setup.js @@ -9,7 +9,7 @@ import FC from '../fc'; import MSP from '../msp'; import Model from '../model'; import MSPCodes from '../msp/MSPCodes'; -import CONFIGURATOR, { API_VERSION_1_42, API_VERSION_1_43, API_VERSION_1_46 } from '../data_storage'; +import CONFIGURATOR, { API_VERSION_1_42, API_VERSION_1_43, API_VERSION_1_45, API_VERSION_1_46 } from '../data_storage'; import { gui_log } from '../gui_log'; import $ from 'jquery'; @@ -223,7 +223,9 @@ setup.initialize = function (callback) { // Firmware info msp_api_e = $('.api-version'), build_date_e = $('.build-date'), - build_info_e = $('.build-info'); + build_type_e = $('.build-type'), + build_info_e = $('.build-info'), + build_options_e = $('.build-options'); // DISARM FLAGS // We add all the arming/disarming flags available, and show/hide them if needed. @@ -445,50 +447,62 @@ setup.initialize = function (callback) { } } - const showFirmwareInfo = function() { - // Firmware info - msp_api_e.text([FC.CONFIG.apiVersion]); - build_date_e.text([FC.CONFIG.buildInfo]); + const showBuildInfo = function() { + const supported = FC.CONFIG.buildKey.length === 32; + + if (supported && navigator.onLine) { + const buildRoot = `https://build.betaflight.com/api/builds/${FC.CONFIG.buildKey}`; + const buildConfig = ` + ${i18n.getMessage('initialSetupInfoBuildConfig')}`; + const buildLog = ` + ${i18n.getMessage('initialSetupInfoBuildLog')}`; + build_info_e.html(` + ${i18n.getMessage('initialSetupInfoBuildOptionList')}`); + build_info_e.html(`${buildConfig} ${buildLog}`); + } else { + build_info_e.html(supported ? i18n.getMessage('initialSetupNotOnline') : i18n.getMessage('initialSetupNoBuildInfo')); + } + }; - if (navigator.onLine) { - let buildOptionList = ""; + const showBuildOptions = function() { + const supported = (semver.eq(FC.CONFIG.apiVersion, API_VERSION_1_45) && navigator.onLine || semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) && FC.CONFIG.buildOptions.length; - if (FC.CONFIG.buildOptions.length) { - buildOptionList = `
`; - for (const buildOptionElement of FC.CONFIG.buildOptions) { - buildOptionList += `
${buildOptionElement}
`; - } - buildOptionList += `
`; - build_info_e.html(` - ${i18n.getMessage('initialSetupInfoBuildOptionList')}`); + if (supported) { + let buildOptionList = `
`; + for (const buildOptionElement of FC.CONFIG.buildOptions) { + buildOptionList += `
${buildOptionElement}
`; } + buildOptionList += `
`; - if (FC.CONFIG.buildKey.length === 32) { - const buildRoot = `https://build.betaflight.com/api/builds/${FC.CONFIG.buildKey}`; - const buildConfig = ` - ${i18n.getMessage('initialSetupInfoBuildConfig')}`; + build_options_e.html(` + ${i18n.getMessage('initialSetupInfoBuildOptionList')}`); - const buildLog = ` - ${i18n.getMessage('initialSetupInfoBuildLog')}`; + const buildOptions = ` + ${i18n.getMessage('initialSetupInfoBuildOptions')}`; - const buildOptions = ` - ${i18n.getMessage('initialSetupInfoBuildOptions')}`; + build_options_e.html(buildOptions); - build_info_e.html(`${buildConfig} ${buildLog} ${buildOptions}`); - $('a.buildOptions').on('click', async function() { - showDialogBuildInfo(`

${i18n.getMessage('initialSetupInfoBuildOptionList')}

`, buildOptionList); - }); - $('.build-info a').removeClass('disabled'); - } else { - build_info_e.html(i18n.getMessage('initialSetupInfoBuildEmpty')); - $('.build-info a').addClass('disabled'); - } + $('a.buildOptions').on('click', async function() { + showDialogBuildInfo(`

${i18n.getMessage('initialSetupInfoBuildOptionList')}

`, buildOptionList); + }); } else { - build_info_e.html(i18n.getMessage('initialSetupNotOnline')); - $('.build-info a').addClass('disabled'); + // should not happen, but just in case + build_options_e.html(`${i18n.getMessage('initialSetupNoBuildInfo')}`); } }; + function showFirmwareInfo() { + // Firmware info + msp_api_e.text(FC.CONFIG.apiVersion); + build_date_e.text(FC.CONFIG.buildInfo); + + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) { + build_type_e.html(FC.CONFIG.buildKey.length === 32 ? i18n.getMessage("initialSetupInfoBuildCloud") : i18n.getMessage("initialSetupInfoBuildLocal")); + showBuildInfo(); + showBuildOptions(); + } + } + prepareDisarmFlags(); showSensorInfo(); showFirmwareInfo(); diff --git a/src/tabs/setup.html b/src/tabs/setup.html index cda9cf4c9e..1b6c806d6f 100644 --- a/src/tabs/setup.html +++ b/src/tabs/setup.html @@ -234,11 +234,19 @@ + + + + + + + +