Skip to content

Commit

Permalink
Fix options and expost local options
Browse files Browse the repository at this point in the history
  • Loading branch information
haslinghuis committed May 2, 2024
1 parent 9e25c16 commit ee10bb8
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 35 deletions.
12 changes: 12 additions & 0 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
84 changes: 49 additions & 35 deletions src/js/tabs/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 = `<span class="buildInfoBtn" title="${i18n.getMessage('initialSetupInfoBuildConfig')}: ${buildRoot}/json">
<a href="${buildRoot}/json" target="_blank"><strong>${i18n.getMessage('initialSetupInfoBuildConfig')}</strong></a></span>`;
const buildLog = `<span class="buildInfoBtn" title="${i18n.getMessage('initialSetupInfoBuildLog')}: ${buildRoot}/log">
<a href="${buildRoot}/log" target="_blank"><strong>${i18n.getMessage('initialSetupInfoBuildLog')}</strong></a></span>`;
build_info_e.html(`<span class="buildInfoBtn" title="${i18n.getMessage('initialSetupInfoBuildOptions')}">
<a class="buildOptions" href=#"><strong>${i18n.getMessage('initialSetupInfoBuildOptionList')}</strong></a></span>`);
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 = `<div class="dialogBuildInfoGrid-container">`;
for (const buildOptionElement of FC.CONFIG.buildOptions) {
buildOptionList += `<div class="dialogBuildInfoGrid-item">${buildOptionElement}</div>`;
}
buildOptionList += `</div>`;
build_info_e.html(`<span class="buildInfoBtn" title="${i18n.getMessage('initialSetupInfoBuildOptions')}">
<a class="buildOptions" href=#"><strong>${i18n.getMessage('initialSetupInfoBuildOptionList')}</strong></a></span>`);
if (supported) {
let buildOptionList = `<div class="dialogBuildInfoGrid-container">`;
for (const buildOptionElement of FC.CONFIG.buildOptions) {
buildOptionList += `<div class="dialogBuildInfoGrid-item">${buildOptionElement}</div>`;
}
buildOptionList += `</div>`;

if (FC.CONFIG.buildKey.length === 32) {
const buildRoot = `https://build.betaflight.com/api/builds/${FC.CONFIG.buildKey}`;
const buildConfig = `<span class="buildInfoBtn" title="${i18n.getMessage('initialSetupInfoBuildConfig')}: ${buildRoot}/json">
<a href="${buildRoot}/json" target="_blank"><strong>${i18n.getMessage('initialSetupInfoBuildConfig')}</strong></a></span>`;
build_options_e.html(`<span class="buildInfoBtn" title="${i18n.getMessage('initialSetupInfoBuildOptions')}">
<a class="buildOptions" href=#"><strong>${i18n.getMessage('initialSetupInfoBuildOptionList')}</strong></a></span>`);

const buildLog = `<span class="buildInfoBtn" title="${i18n.getMessage('initialSetupInfoBuildLog')}: ${buildRoot}/log">
<a href="${buildRoot}/log" target="_blank"><strong>${i18n.getMessage('initialSetupInfoBuildLog')}</strong></a></span>`;
const buildOptions = `<span class="buildInfoBtn" title="${i18n.getMessage('initialSetupInfoBuildOptionList')}">
<a class="buildOptions" href=#"><strong>${i18n.getMessage('initialSetupInfoBuildOptions')}</strong></a></span>`;

const buildOptions = `<span class="buildInfoBtn" title="${i18n.getMessage('initialSetupInfoBuildOptionList')}">
<a class="buildOptions disabled" href=#"><strong>${i18n.getMessage('initialSetupInfoBuildOptions')}</strong></a></span>`;
build_options_e.html(buildOptions);

build_info_e.html(`${buildConfig} ${buildLog} ${buildOptions}`);
$('a.buildOptions').on('click', async function() {
showDialogBuildInfo(`<h3>${i18n.getMessage('initialSetupInfoBuildOptionList')}</h3>`, 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(`<h3>${i18n.getMessage('initialSetupInfoBuildOptionList')}</h3>`, 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();
Expand Down
8 changes: 8 additions & 0 deletions src/tabs/setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,19 @@
<td id="build-date" i18n="initialSetupInfoBuildDate"></td>
<td class="build-date"></td>
</tr>
<tr>
<td id="build-type" i18n="initialSetupInfoBuildType"></td>
<td class="build-type"></td>
</tr>
</tr>
<tr>
<td id="build-info" i18n="initialSetupInfoBuildInfo"></td>
<td class="build-info"></td>
</tr>
<tr>
<td id="build-options" i18n="initialSetupInfoBuildOptions"></td>
<td class="build-options"></td>
</tr>
</tbody>
</table>
</div>
Expand Down

0 comments on commit ee10bb8

Please sign in to comment.