mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-15 12:25:13 +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;
|
||||
}
|
||||
|
||||
function generateFilename(prefix, suffix) {
|
||||
function generateFilename(prefix, suffix) { // TODO, code used directly in cli.js instead
|
||||
var date = new Date();
|
||||
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 jBox = require('./../js/libraries/jBox/jBox.min');
|
||||
const mspDeduplicationQueue = require('./../js/msp/mspDeduplicationQueue');
|
||||
const { zeroPad } = require('./../js/helpers');
|
||||
const FC = require('./../js/fc');
|
||||
|
||||
TABS.cli = {
|
||||
lineDelayMs: 50,
|
||||
|
@ -160,11 +162,14 @@ TABS.cli.initialize = function (callback) {
|
|||
});
|
||||
|
||||
$('.tab-cli .save').on('click', function () {
|
||||
|
||||
var prefix = 'cli';
|
||||
var suffix = 'txt';
|
||||
var filename = generateFilename(prefix, suffix);
|
||||
var options = {
|
||||
defaultPath: filename,
|
||||
filters: [
|
||||
{ name: 'CLI', extensions: ['cli'] } ,
|
||||
{ name: 'TXT', extensions: ['txt'] }
|
||||
{ name: suffix.toUpperCase(), extensions: [suffix] },
|
||||
{ name: prefix.toUpperCase(), extensions: [prefix] }
|
||||
],
|
||||
};
|
||||
dialog.showSaveDialog(options).then(result => {
|
||||
|
@ -411,6 +416,30 @@ 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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue