mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-13 11:29:53 +03:00
Pass FC.CONFIG as reference
This commit is contained in:
parent
1f3c55b075
commit
a1f51b866f
2 changed files with 8 additions and 31 deletions
|
@ -24,17 +24,17 @@ function zeroPad(value, width) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateFilename(prefix, suffix) { // TODO, code used directly in cli.js instead
|
function generateFilename(config, prefix, suffix) {
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
var filename = prefix;
|
var filename = prefix;
|
||||||
|
|
||||||
if (CONFIG) {
|
if (config) {
|
||||||
if (CONFIG.flightControllerIdentifier) {
|
if (config.flightControllerIdentifier) {
|
||||||
filename = CONFIG.flightControllerIdentifier + '_' + CONFIG.flightControllerVersion + "_" + filename;
|
filename = config.flightControllerIdentifier + '_' + config.flightControllerVersion + "_" + filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CONFIG.name && CONFIG.name.trim() !== '') {
|
if (config.name && config.name.trim() !== '') {
|
||||||
filename = filename + '_' + CONFIG.name.trim().replace(' ', '_');
|
filename = filename + '_' + config.name.trim().replace(' ', '_');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
27
tabs/cli.js
27
tabs/cli.js
|
@ -17,6 +17,7 @@ const jBox = require('./../js/libraries/jBox/jBox.min');
|
||||||
const mspDeduplicationQueue = require('./../js/msp/mspDeduplicationQueue');
|
const mspDeduplicationQueue = require('./../js/msp/mspDeduplicationQueue');
|
||||||
const { zeroPad } = require('./../js/helpers');
|
const { zeroPad } = require('./../js/helpers');
|
||||||
const FC = require('./../js/fc');
|
const FC = require('./../js/fc');
|
||||||
|
const { generateFilename } = require('./../js/helpers');
|
||||||
|
|
||||||
TABS.cli = {
|
TABS.cli = {
|
||||||
lineDelayMs: 50,
|
lineDelayMs: 50,
|
||||||
|
@ -164,7 +165,7 @@ TABS.cli.initialize = function (callback) {
|
||||||
$('.tab-cli .save').on('click', function () {
|
$('.tab-cli .save').on('click', function () {
|
||||||
var prefix = 'cli';
|
var prefix = 'cli';
|
||||||
var suffix = 'txt';
|
var suffix = 'txt';
|
||||||
var filename = generateFilename(prefix, suffix);
|
var filename = generateFilename(FC.CONFIG, prefix, suffix);
|
||||||
var options = {
|
var options = {
|
||||||
defaultPath: filename,
|
defaultPath: filename,
|
||||||
filters: [
|
filters: [
|
||||||
|
@ -416,30 +417,6 @@ function setPrompt(text) {
|
||||||
$('.tab-cli textarea').val(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) {
|
TABS.cli.read = function (readInfo) {
|
||||||
/* Some info about handling line feeds and carriage return
|
/* Some info about handling line feeds and carriage return
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue