Skip to content

Commit

Permalink
Allow resetting the documentation URL
Browse files Browse the repository at this point in the history
  • Loading branch information
costas-basdekis committed May 20, 2022
1 parent bb96b9b commit 3fac48f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions octoprint_marlingcodedocumentation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ def get_settings_defaults(self):
"https://raw.githubusercontent.com/costas-basdekis/"
"gcode-documentation-parser/output/output/all_codes.json"
),
"update_documentation_url_default": (
"https://raw.githubusercontent.com/costas-basdekis/"
"gcode-documentation-parser/output/output/all_codes.json"
),
"update_documentation_last_update": None,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,8 @@ $(function() {
favouriteCommands: 'favourite_commands',
collapseAllByDefault: 'collapse_all_by_default',
showSourcesCheckboxes: 'show_sources_checkboxes',
updateDocumentationUrl: 'update_documentation_url',
updateDocumentationUrlDefault: 'update_documentation_url_default',
updateDocumentationLastUpdate: 'update_documentation_last_update',
}, {
includeSourceMarlin: true,
Expand All @@ -544,6 +546,8 @@ $(function() {
favouriteCommands: [],
collapseAllByDefault: false,
showSourcesCheckboxes: true,
updateDocumentationUrl: null,
updateDocumentationUrlDefault: null,
updateDocumentationLastUpdate: null,
}, self);
self.mySettings = null;
Expand Down Expand Up @@ -680,6 +684,9 @@ $(function() {
}
self.documentationService.update(newData);
};
self.onResetUrlToDefault = () => {
document.getElementById("settings-update_documentation_url").value = self.updateDocumentationUrlDefault();
};
self.refreshDocumentation = async () => {
const response = await fetch("/api/plugin/marlingcodedocumentation");
if (!response.ok) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,8 @@ $(function () {
favouriteCommands: 'favourite_commands',
collapseAllByDefault: 'collapse_all_by_default',
showSourcesCheckboxes: 'show_sources_checkboxes',
updateDocumentationUrl: 'update_documentation_url',
updateDocumentationUrlDefault: 'update_documentation_url_default',
updateDocumentationLastUpdate: 'update_documentation_last_update'
}, {
includeSourceMarlin: true,
Expand All @@ -740,6 +742,8 @@ $(function () {
favouriteCommands: [],
collapseAllByDefault: false,
showSourcesCheckboxes: true,
updateDocumentationUrl: null,
updateDocumentationUrlDefault: null,
updateDocumentationLastUpdate: null
}, self);
self.mySettings = null;
Expand Down Expand Up @@ -902,6 +906,10 @@ $(function () {
self.documentationService.update(newData);
};

self.onResetUrlToDefault = function () {
document.getElementById("settings-update_documentation_url").value = self.updateDocumentationUrlDefault();
};

self.refreshDocumentation = async function () {
var response = await fetch("/api/plugin/marlingcodedocumentation");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@
<div>
<label>
Documentation URL
<input type="url" data-bind="value: settings.plugins.marlingcodedocumentation.update_documentation_url" style="width: 50em">
<input type="url" data-bind="value: settings.plugins.marlingcodedocumentation.update_documentation_url" id="settings-update_documentation_url" style="width: 50em">
</label>
<br/>
<button type="button" data-bind="click: marlinGcodeDocumentation.onUpdateDocumentation">Reset to default URL</button>
<button type="button" data-bind="click: marlinGcodeDocumentation.onResetUrlToDefault">Reset to default URL</button>
<br/>
Normally documentation is compiled monthly by
<a href="https://github.com/costas-basdekis/gcode-documentation-parser" target="_blank">gcode-documentation-parser</a>
Expand Down

0 comments on commit 3fac48f

Please sign in to comment.