Wizard for software update plugin
This commit is contained in:
parent
c7da95e91a
commit
aecedfa57f
6 changed files with 73 additions and 20 deletions
|
|
@ -32,7 +32,8 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
|||
octoprint.plugin.SettingsPlugin,
|
||||
octoprint.plugin.AssetPlugin,
|
||||
octoprint.plugin.TemplatePlugin,
|
||||
octoprint.plugin.StartupPlugin):
|
||||
octoprint.plugin.StartupPlugin,
|
||||
octoprint.plugin.WizardPlugin):
|
||||
def __init__(self):
|
||||
self._update_in_progress = False
|
||||
self._configured_checks_mutex = threading.Lock()
|
||||
|
|
@ -177,12 +178,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
|||
|
||||
checks = self._get_configured_checks()
|
||||
if "octoprint" in checks:
|
||||
if "checkout_folder" in checks["octoprint"]:
|
||||
data["octoprint_checkout_folder"] = checks["octoprint"]["checkout_folder"]
|
||||
elif "update_folder" in checks["octoprint"]:
|
||||
data["octoprint_checkout_folder"] = checks["octoprint"]["update_folder"]
|
||||
else:
|
||||
data["octoprint_checkout_folder"] = None
|
||||
data["octoprint_checkout_folder"] = self._get_octoprint_checkout_folder(checks=checks)
|
||||
data["octoprint_type"] = checks["octoprint"].get("type", None)
|
||||
else:
|
||||
data["octoprint_checkout_folder"] = None
|
||||
|
|
@ -410,6 +406,14 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
|||
dict(type="settings", name=gettext("Software Update"))
|
||||
]
|
||||
|
||||
##~~
|
||||
|
||||
def is_wizard_required(self):
|
||||
checks = self._get_configured_checks()
|
||||
check = checks.get("octoprint", None)
|
||||
checkout_folder = self._get_octoprint_checkout_folder(checks=checks)
|
||||
return check and "update_script" in check and not checkout_folder
|
||||
|
||||
#~~ Updater
|
||||
|
||||
def get_current_versions(self, check_targets=None, force=False):
|
||||
|
|
@ -780,6 +784,20 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
|||
else:
|
||||
raise exceptions.UnknownUpdateType()
|
||||
|
||||
def _get_octoprint_checkout_folder(self, checks=None):
|
||||
if checks is None:
|
||||
checks = self._get_configured_checks()
|
||||
|
||||
if not "octoprint" in checks:
|
||||
return None
|
||||
|
||||
if "checkout_folder" in checks["octoprint"]:
|
||||
return checks["octoprint"]["checkout_folder"]
|
||||
elif "update_folder" in checks["octoprint"]:
|
||||
return checks["octoprint"]["update_folder"]
|
||||
|
||||
return None
|
||||
|
||||
|
||||
__plugin_name__ = "Software Update"
|
||||
__plugin_author__ = "Gina Häußge"
|
||||
|
|
|
|||
|
|
@ -169,6 +169,11 @@ $(function() {
|
|||
self.config_checkType(self.settings.settings.plugins.softwareupdate.octoprint_type());
|
||||
};
|
||||
|
||||
self._copyConfigBack = function() {
|
||||
self.settings.settings.plugins.softwareupdate.octoprint_checkout_folder(self.config_checkoutFolder());
|
||||
self.settings.settings.plugins.softwareupdate.octoprint_type(self.config_checkType());
|
||||
};
|
||||
|
||||
self.fromCheckResponse = function(data, ignoreSeen, showIfNothingNew) {
|
||||
var versions = [];
|
||||
_.each(data.information, function(value, key) {
|
||||
|
|
@ -415,6 +420,18 @@ $(function() {
|
|||
self.workingOutput.scrollTop(self.workingOutput[0].scrollHeight - self.workingOutput.height());
|
||||
};
|
||||
|
||||
self.onWizardTabChange = function(current, next) {
|
||||
if (next && _.startsWith(next, "wizard_plugin_softwareupdate")) {
|
||||
// switching to the plugin wizard tab
|
||||
self._copyConfig();
|
||||
} else if (current && _.startsWith(current, "wizard_plugin_softwareupdate")) {
|
||||
// switching away from the plugin wizard tab
|
||||
self._copyConfigBack();
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
self.onStartup = function() {
|
||||
self.workingDialog = $("#settings_plugin_softwareupdate_workingdialog");
|
||||
self.workingOutput = $("#settings_plugin_softwareupdate_workingdialog_output");
|
||||
|
|
@ -616,6 +633,6 @@ $(function() {
|
|||
ADDITIONAL_VIEWMODELS.push([
|
||||
SoftwareUpdateViewModel,
|
||||
["loginStateViewModel", "printerStateViewModel", "settingsViewModel"],
|
||||
["#settings_plugin_softwareupdate", "#softwareupdate_confirmation_dialog"]
|
||||
["#settings_plugin_softwareupdate", "#softwareupdate_confirmation_dialog", "#wizard_plugin_softwareupdate"]
|
||||
]);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
<div class="control-group">
|
||||
<label class="control-label">{{ _('OctoPrint checkout folder') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: config_checkoutFolder">
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<div class="control-group">
|
||||
<label class="control-label">{{ _('OctoPrint version tracking') }}</label>
|
||||
<div class="controls">
|
||||
<select data-bind="value: config_checkType, options: config_availableCheckTypes, optionsText: 'name', optionsValue: 'key'"></select>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -74,18 +74,8 @@
|
|||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('OctoPrint checkout folder') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: config_checkoutFolder">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('OctoPrint version tracking') }}</label>
|
||||
<div class="controls">
|
||||
<select data-bind="value: config_checkType, options: config_availableCheckTypes, optionsText: 'name', optionsValue: 'key'"></select>
|
||||
</div>
|
||||
</div>
|
||||
{% include "_snippets/plugins/softwareupdate/checkoutFolder.jinja2" %}
|
||||
{% include "_snippets/plugins/softwareupdate/versionTracking.jinja2" %}
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Version cache TTL') }}</label>
|
||||
<div class="controls">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
<h3>{{ _('Software Update') }}</h3>
|
||||
|
||||
{% trans %}<p>
|
||||
OctoPrint can update itself via <code>git</code>, but it needs to know its checkout folder and the way
|
||||
it should track available updates in order to be able to do that. You can configure that here.
|
||||
</p>{% endtrans %}
|
||||
|
||||
<form class="form-horizontal">
|
||||
{% include "_snippets/plugins/softwareupdate/checkoutFolder.jinja2" %}
|
||||
{% include "_snippets/plugins/softwareupdate/versionTracking.jinja2" %}
|
||||
</form>
|
||||
|
||||
{% trans %}<p>
|
||||
If you are running a release version of OctoPrint, leave at "Release" tracking. If you are running a different
|
||||
branch however, you should setup "Commit" tracking.
|
||||
</p>{% endtrans %}
|
||||
Loading…
Reference in a new issue