mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-16 04:45:18 +03:00
cli filename fix
This commit is contained in:
parent
30765ae731
commit
1f3c55b075
2 changed files with 47 additions and 18 deletions
|
@ -24,7 +24,7 @@ function zeroPad(value, width) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateFilename(prefix, suffix) {
|
function generateFilename(prefix, suffix) { // TODO, code used directly in cli.js instead
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
var filename = prefix;
|
var filename = prefix;
|
||||||
|
|
||||||
|
|
35
tabs/cli.js
35
tabs/cli.js
|
@ -15,6 +15,8 @@ const CliAutoComplete = require('./../js/CliAutoComplete');
|
||||||
const { ConnectionType } = require('./../js/connection/connection');
|
const { ConnectionType } = require('./../js/connection/connection');
|
||||||
const jBox = require('./../js/libraries/jBox/jBox.min');
|
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 FC = require('./../js/fc');
|
||||||
|
|
||||||
TABS.cli = {
|
TABS.cli = {
|
||||||
lineDelayMs: 50,
|
lineDelayMs: 50,
|
||||||
|
@ -160,11 +162,14 @@ TABS.cli.initialize = function (callback) {
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.tab-cli .save').on('click', function () {
|
$('.tab-cli .save').on('click', function () {
|
||||||
|
var prefix = 'cli';
|
||||||
|
var suffix = 'txt';
|
||||||
|
var filename = generateFilename(prefix, suffix);
|
||||||
var options = {
|
var options = {
|
||||||
|
defaultPath: filename,
|
||||||
filters: [
|
filters: [
|
||||||
{ name: 'CLI', extensions: ['cli'] } ,
|
{ name: suffix.toUpperCase(), extensions: [suffix] },
|
||||||
{ name: 'TXT', extensions: ['txt'] }
|
{ name: prefix.toUpperCase(), extensions: [prefix] }
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
dialog.showSaveDialog(options).then(result => {
|
dialog.showSaveDialog(options).then(result => {
|
||||||
|
@ -411,6 +416,30 @@ 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