1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-13 03:19:54 +03:00

Pass FC.CONFIG as reference

This commit is contained in:
Pawel Spychalski (DzikuVx) 2024-05-10 14:37:39 +02:00
parent 1f3c55b075
commit a1f51b866f
2 changed files with 8 additions and 31 deletions

View file

@ -24,17 +24,17 @@ function zeroPad(value, width) {
return value;
}
function generateFilename(prefix, suffix) { // TODO, code used directly in cli.js instead
function generateFilename(config, prefix, suffix) {
var date = new Date();
var filename = prefix;
if (CONFIG) {
if (CONFIG.flightControllerIdentifier) {
filename = CONFIG.flightControllerIdentifier + '_' + CONFIG.flightControllerVersion + "_" + filename;
if (config) {
if (config.flightControllerIdentifier) {
filename = config.flightControllerIdentifier + '_' + config.flightControllerVersion + "_" + filename;
}
if (CONFIG.name && CONFIG.name.trim() !== '') {
filename = filename + '_' + CONFIG.name.trim().replace(' ', '_');
if (config.name && config.name.trim() !== '') {
filename = filename + '_' + config.name.trim().replace(' ', '_');
}
}

View file

@ -17,6 +17,7 @@ const jBox = require('./../js/libraries/jBox/jBox.min');
const mspDeduplicationQueue = require('./../js/msp/mspDeduplicationQueue');
const { zeroPad } = require('./../js/helpers');
const FC = require('./../js/fc');
const { generateFilename } = require('./../js/helpers');
TABS.cli = {
lineDelayMs: 50,
@ -164,7 +165,7 @@ TABS.cli.initialize = function (callback) {
$('.tab-cli .save').on('click', function () {
var prefix = 'cli';
var suffix = 'txt';
var filename = generateFilename(prefix, suffix);
var filename = generateFilename(FC.CONFIG, prefix, suffix);
var options = {
defaultPath: filename,
filters: [
@ -416,30 +417,6 @@ function setPrompt(text) {
$('.tab-cli textarea').val(text);
}
function generateFilename(prefix, suffix) {
var date = new Date();
var filename = prefix;
if (FC.CONFIG) {
if (FC.CONFIG.flightControllerIdentifier) {
filename = FC.CONFIG.flightControllerIdentifier + '_' + FC.CONFIG.flightControllerVersion + "_" + filename;
}
if (FC.CONFIG.name && FC.CONFIG.name.trim() !== '') {
filename = filename + '_' + FC.CONFIG.name.trim().replace(' ', '_');
}
}
filename = filename + '_' + date.getFullYear()
+ zeroPad(date.getMonth() + 1, 2)
+ zeroPad(date.getDate(), 2)
+ '_' + zeroPad(date.getHours(), 2)
+ zeroPad(date.getMinutes(), 2)
+ zeroPad(date.getSeconds(), 2);
return filename + '.' + suffix;
}
TABS.cli.read = function (readInfo) {
/* Some info about handling line feeds and carriage return