mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-24 16:55:24 +03:00
fix: presets styling for web (#3585)
* fix: presets styling for web * feat: add `isWeb` helper
This commit is contained in:
parent
4b3f218674
commit
5e5aa4f980
5 changed files with 16 additions and 12 deletions
|
@ -21,12 +21,10 @@ import "../css/tabs/led_strip.less";
|
|||
import "../css/tabs/sensors.less";
|
||||
import "../css/tabs/cli.less";
|
||||
import "../tabs/presets/presets.less";
|
||||
// TODO: for some reason can't resolve these less files
|
||||
// import "../tabs/presets/TitlePanel/PresetTitlePanel.less";
|
||||
import "../tabs/presets/TitlePanel/PresetTitlePanel.css";
|
||||
import "../tabs/presets/DetailedDialog/PresetsDetailedDialog.less";
|
||||
// TODO: for some reason can't resolve these less files
|
||||
// import "../tabs/presets/SourcesDialog/SourcesDialog.less";
|
||||
// import "../tabs/presets/SourcesDialog/SourcePanel.less";
|
||||
import "../tabs/presets/SourcesDialog/SourcesDialog.css";
|
||||
import "../tabs/presets/SourcesDialog/SourcePanel.css";
|
||||
import "../css/tabs/logging.less";
|
||||
import "../css/tabs/onboard_logging.less";
|
||||
import "../css/tabs/firmware_flasher.less";
|
||||
|
|
|
@ -2,8 +2,9 @@ import GUI from "./gui.js";
|
|||
import CONFIGURATOR from "./data_storage.js";
|
||||
import serialNWJS from "./serial.js";
|
||||
import serialWeb from "./webSerial.js";
|
||||
import { isWeb } from "./utils/isWeb.js";
|
||||
|
||||
const serial = import.meta.env ? serialWeb : serialNWJS;
|
||||
const serial = isWeb() ? serialWeb : serialNWJS;
|
||||
|
||||
const MSP = {
|
||||
symbols: {
|
||||
|
@ -307,7 +308,7 @@ const MSP = {
|
|||
return bufferOut;
|
||||
},
|
||||
send_message(code, data, callback_sent, callback_msp, doCallbackOnError) {
|
||||
const connected = import.meta.env ? serial.connected : serial.connectionId;
|
||||
const connected = isWeb ? serial.connected : serial.connectionId;
|
||||
if (code === undefined || !connected || CONFIGURATOR.virtualMode) {
|
||||
if (callback_msp) {
|
||||
callback_msp();
|
||||
|
@ -324,7 +325,7 @@ const MSP = {
|
|||
}
|
||||
}
|
||||
|
||||
if (import.meta.env && (code === undefined || !serial.connectionInfo)) {
|
||||
if (isWeb() && (code === undefined || !serial.connectionInfo)) {
|
||||
console.log('ERROR: code undefined or no connectionId');
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import { get as getConfig } from "./ConfigStorage";
|
|||
import serial from "./serial";
|
||||
import MdnsDiscovery from "./mdns_discovery";
|
||||
import $ from 'jquery';
|
||||
import { isWeb } from "./utils/isWeb";
|
||||
|
||||
const TIMEOUT_CHECK = 500 ; // With 250 it seems that it produces a memory leak and slowdown in some versions, reason unknown
|
||||
|
||||
|
@ -32,7 +33,7 @@ PortHandler.initialize = function () {
|
|||
|
||||
// currently web build doesn't need port handler,
|
||||
// so just bail out.
|
||||
if (import.meta.env) {
|
||||
if (isWeb()) {
|
||||
return 'not implemented';
|
||||
}
|
||||
|
||||
|
|
|
@ -26,8 +26,9 @@ import BuildApi from "./BuildApi";
|
|||
|
||||
import serialNWJS from "./serial.js";
|
||||
import serialWeb from "./webSerial.js";
|
||||
import { isWeb } from "./utils/isWeb";
|
||||
|
||||
const serial = import.meta.env ? serialWeb : serialNWJS;
|
||||
const serial = isWeb() ? serialWeb : serialNWJS;
|
||||
|
||||
let mspHelper;
|
||||
let connectionTimestamp;
|
||||
|
@ -118,7 +119,7 @@ export function initializeSerialBackend() {
|
|||
CONFIGURATOR.virtualApiVersion = $('#firmware-version-dropdown :selected').val();
|
||||
|
||||
serial.connect('virtual', {}, onOpenVirtual);
|
||||
} else if (import.meta.env) {
|
||||
} else if (isWeb()) {
|
||||
// Explicitly disconnect the event listeners before attaching the new ones.
|
||||
serial.removeEventListener('connect', connectHandler);
|
||||
serial.addEventListener('connect', connectHandler);
|
||||
|
@ -327,7 +328,7 @@ function onOpen(openInfo) {
|
|||
result = getConfig('expertMode')?.expertMode ?? false;
|
||||
$('input[name="expertModeCheckbox"]').prop('checked', result).trigger('change');
|
||||
|
||||
if(import.meta.env) {
|
||||
if(isWeb()) {
|
||||
serial.removeEventListener('receive', read_serial_adapter);
|
||||
serial.addEventListener('receive', read_serial_adapter);
|
||||
} else {
|
||||
|
|
3
src/js/utils/isWeb.js
Normal file
3
src/js/utils/isWeb.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
export function isWeb() {
|
||||
return !!import.meta.env;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue