mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-23 00:05:19 +03:00
Add settings framework
This commit is contained in:
parent
e0ef5b0261
commit
cf57493fdb
5 changed files with 763 additions and 705 deletions
|
@ -43,46 +43,60 @@ helper.defaultsDialog = (function (data) {
|
||||||
privateScope.wizard(selectedDefaultPreset, wizardStep + 1);
|
privateScope.wizard(selectedDefaultPreset, wizardStep + 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
privateScope.wizard = function (selectedDefaultPreset, wizardStep) {
|
privateScope.handleTabLoadReceiver = function ($content) {
|
||||||
|
console.log('ready to handle receiver');
|
||||||
|
|
||||||
const steps = selectedDefaultPreset.wizardPages;
|
|
||||||
const stepsCount = selectedDefaultPreset.wizardPages.length;
|
|
||||||
const stepName = steps[wizardStep];
|
|
||||||
|
|
||||||
console.log(steps[wizardStep], wizardStep, stepsCount);
|
|
||||||
|
|
||||||
if (wizardStep >= stepsCount - 1) {
|
},
|
||||||
//This is the last step, time to finalize
|
|
||||||
$container.hide();
|
|
||||||
privateScope.saveAndReboot();
|
|
||||||
} else {
|
|
||||||
const $content = $container.find('.defaults-dialog__wizard');
|
|
||||||
|
|
||||||
$.get("./wizard/" + stepName + ".html", function(data) {
|
privateScope.wizard = function (selectedDefaultPreset, wizardStep) {
|
||||||
$content.html(data);
|
|
||||||
});
|
|
||||||
|
|
||||||
$.get("./wizard/buttons.html", function(data) {
|
const steps = selectedDefaultPreset.wizardPages;
|
||||||
$(data).appendTo($content);
|
const stepsCount = selectedDefaultPreset.wizardPages.length;
|
||||||
});
|
const stepName = steps[wizardStep];
|
||||||
|
|
||||||
$container.on('click', '#wizard-next', function () {
|
console.log(steps[wizardStep], wizardStep, stepsCount);
|
||||||
privateScope.saveWizardStep(selectedDefaultPreset, wizardStep);
|
|
||||||
});
|
|
||||||
|
|
||||||
$container.on('click', '#wizard-skip', function () {
|
if (wizardStep >= stepsCount - 1) {
|
||||||
privateScope.wizard(selectedDefaultPreset, wizardStep + 1);
|
//This is the last step, time to finalize
|
||||||
});
|
$container.hide();
|
||||||
|
privateScope.saveAndReboot();
|
||||||
|
} else {
|
||||||
|
const $content = $container.find('.defaults-dialog__wizard');
|
||||||
|
|
||||||
$container.find('.defaults-dialog__content').hide();
|
$.get("./wizard/" + stepName + ".html", function (data) {
|
||||||
$container.find('.defaults-dialog__wizard').show();
|
$(data).appendTo($content);
|
||||||
|
|
||||||
savingDefaultsModal.close();
|
|
||||||
$container.show();
|
|
||||||
|
|
||||||
}
|
$.get("./wizard/buttons.html", function (data) {
|
||||||
|
$(data).appendTo($content);
|
||||||
|
|
||||||
};
|
$container.on('click', '#wizard-next', function () {
|
||||||
|
privateScope.saveWizardStep(selectedDefaultPreset, wizardStep);
|
||||||
|
});
|
||||||
|
|
||||||
|
$container.on('click', '#wizard-skip', function () {
|
||||||
|
privateScope.wizard(selectedDefaultPreset, wizardStep + 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (stepName == "receiver") {
|
||||||
|
privateScope.handleTabLoadReceiver($container);
|
||||||
|
}
|
||||||
|
|
||||||
|
Settings.configureInputs().then(
|
||||||
|
function () {
|
||||||
|
console.log('configure done');
|
||||||
|
$container.find('.defaults-dialog__content').hide();
|
||||||
|
$container.find('.defaults-dialog__wizard').show();
|
||||||
|
|
||||||
|
savingDefaultsModal.close();
|
||||||
|
$container.show();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
privateScope.saveAndReboot = function () {
|
privateScope.saveAndReboot = function () {
|
||||||
GUI.tab_switch_cleanup(function () {
|
GUI.tab_switch_cleanup(function () {
|
||||||
|
@ -166,14 +180,14 @@ helper.defaultsDialog = (function (data) {
|
||||||
|
|
||||||
if (selectedDefaultPreset.id == 0) {
|
if (selectedDefaultPreset.id == 0) {
|
||||||
// Close applying preset dialog if keeping current settings.
|
// Close applying preset dialog if keeping current settings.
|
||||||
savingDefaultsModal.close();
|
savingDefaultsModal.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
mspHelper.loadFeatures(function () {
|
mspHelper.loadFeatures(function () {
|
||||||
privateScope.setFeaturesBits(selectedDefaultPreset)
|
privateScope.setFeaturesBits(selectedDefaultPreset)
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
savingDefaultsModal.close();
|
savingDefaultsModal.close();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3263,6 +3263,9 @@ var mspHelper = (function (gui) {
|
||||||
MSP.send_message(MSPCodes.MSP2_INAV_PROGRAMMING_PID_STATUS, false, false, callback);
|
MSP.send_message(MSPCodes.MSP2_INAV_PROGRAMMING_PID_STATUS, false, false, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.loadSerialPorts = function (callback) {
|
||||||
|
MSP.send_message(MSPCodes.MSP2_CF_SERIAL_CONFIG, false, false, callback);
|
||||||
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
})(GUI);
|
})(GUI);
|
||||||
|
|
|
@ -25,7 +25,8 @@ TABS.setup.initialize = function (callback) {
|
||||||
mspHelper.loadFeatures,
|
mspHelper.loadFeatures,
|
||||||
mspHelper.queryFcStatus,
|
mspHelper.queryFcStatus,
|
||||||
mspHelper.loadMixerConfig,
|
mspHelper.loadMixerConfig,
|
||||||
mspHelper.loadMiscV2
|
mspHelper.loadMiscV2,
|
||||||
|
mspHelper.loadSerialPorts
|
||||||
];
|
];
|
||||||
|
|
||||||
loadChainer.setChain(loadChain);
|
loadChainer.setChain(loadChain);
|
||||||
|
|
|
@ -1 +1,7 @@
|
||||||
<h2>Receiver wizard</h2>
|
<h2>Receiver wizard</h2>
|
||||||
|
<div>
|
||||||
|
<label for="wizard-receiver-port">Receiver Serial Port</label><select id="wizard-receiver-port"/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="wizard-receiver-protocol">Receiver Protocol</label><select id="wizard-receiver-protocol" data-setting="serialrx_provider"></select>
|
||||||
|
</div>
|
Loading…
Add table
Add a link
Reference in a new issue