-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from SimplyPrint/devel
- Loading branch information
Showing
7 changed files
with
148 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,29 @@ $(function () { | |
|
||
self.loading = ko.observable(true); | ||
|
||
self.ws_connected_server = ko.observable(); | ||
self.is_online = ko.observable(false); | ||
self.ws_connected = ko.observable(false); | ||
self.current_endpoint = ko.observable(); | ||
self.SimplyPrintPanelURL = ko.pureComputed(function(){ | ||
return (self.current_endpoint() === "test") ? "https://rewrite.simplyprint.io/panel" : "https://simplyprint.io/panel"; | ||
}); | ||
self.SimplyPrintEndpoint = ko.pureComputed(function(){ | ||
return "SimplyPrint active on " + self.current_endpoint() + " endpoint."; | ||
}); | ||
self.online_label = ko.pureComputed(function(){ | ||
return self.is_online() ? 'has internet connection' : 'no internet connection'; | ||
}); | ||
self.online_label_class = ko.pureComputed(function(){ | ||
return self.is_online() ? 'label label-success' : 'label label-warning'; | ||
}); | ||
self.ws_connected_label = ko.pureComputed(function(){ | ||
return self.ws_connected() ? 'connected' : 'disconnected'; | ||
}); | ||
self.ws_connected_label_class = ko.pureComputed(function(){ | ||
return self.ws_connected() ? 'label label-success' : 'label label-warning'; | ||
}); | ||
|
||
self.onAfterBinding = function () { | ||
// Chose #wizard_plugin_corewizard_onlinecheck because it seemed likely it would be there for all first time | ||
if (!self.settingsViewModel.settings.plugins.SimplyPrint.is_set_up() && !$('#wizard_plugin_corewizard_onlinecheck').length) { | ||
|
@@ -78,14 +101,14 @@ $(function () { | |
} | ||
|
||
self.loading(false); | ||
} | ||
}; | ||
|
||
self.onWizardFinish = function(){ | ||
// Show the welcome dialog if corewizard was open | ||
if (!self.settingsViewModel.settings.plugins.SimplyPrint.is_set_up() && $('#wizard_plugin_corewizard_onlinecheck').length) { | ||
$('#SimplyPrintWelcome').modal("show"); | ||
} | ||
} | ||
}; | ||
|
||
function SetupRecommended() { | ||
setTimeout(function () { | ||
|
@@ -112,7 +135,7 @@ $(function () { | |
SetupRecommended(); | ||
} | ||
}); | ||
} | ||
}; | ||
|
||
$("body").on("click", "#navbar_systemmenu ul li:nth-child(4)", function () { | ||
if (!self.settingsViewModel.settings.plugins.SimplyPrint.is_set_up()) { | ||
|
@@ -240,10 +263,10 @@ $(function () { | |
/*$("#wizard_dialog .button-finish[name='finish']").on("click", function () { | ||
$("#simplyprint_dialog").modal("show"); | ||
});*/ | ||
} | ||
}; | ||
|
||
self.pluginsLoadedCheck = function () { | ||
let pluginSettings = self.settingsViewModel.settings.plugins.SimplyPrint | ||
let pluginSettings = self.settingsViewModel.settings.plugins.SimplyPrint; | ||
if ($("#settings_plugin_pluginmanager_pluginlist tbody").html().length) { | ||
//Plugins have been loaded (being called from the API async, not loaded with the page) | ||
if (typeof pluginSettings.sp_installed_plugins === "undefined" || !Array.isArray(pluginSettings.sp_installed_plugins) || !pluginSettings.sp_installed_plugins.length) { | ||
|
@@ -271,14 +294,14 @@ $(function () { | |
} else { | ||
setTimeout(self.pluginsLoadedCheck, 500); | ||
} | ||
} | ||
}; | ||
|
||
self.ManagedBySimplyPrintAlert = function (extra = "", onlyPartly = false) { | ||
return `<div class="alert"> | ||
<img alt="SimplyPrint logo (all rights reserved)" src="plugin/SimplyPrint/static/img/sp_logo.png" style="margin-left: 10px;width: 19px;"> | ||
${onlyPartly ? "Some features here are managed by SimplyPrint" : "This feature is managed by SimplyPrint"}${extra.length ? ". " + extra : ""} | ||
</div>`; | ||
} | ||
}; | ||
|
||
self.DisableOverwrittenUI = function () { | ||
//Printer profiles | ||
|
@@ -301,18 +324,17 @@ $(function () { | |
$("#settings_gcodeScripts [data-bind=\"value: scripts_gcode_afterPrintCancelled\"]").prop("disabled", true); | ||
$("#settings_gcodeScripts [data-bind=\"value: scripts_gcode_afterPrintPaused\"]").prop("disabled", true); | ||
$("#settings_gcodeScripts [data-bind=\"value: scripts_gcode_beforePrintResumed\"]").prop("disabled", true); | ||
} | ||
}; | ||
|
||
self.DisableOverwrittenUI(); | ||
self.OctoSetupChanges(); | ||
|
||
// Support for installing and uninstalling the SimplyPrintRpiSoftware (CP) | ||
self.requestInProgress = ko.observable() | ||
self.requestInProgress = ko.observable(); | ||
self.doSetup = function () { | ||
console.log("installing") | ||
self.requestInProgress(true); | ||
OctoPrint.simpleApiCommand("SimplyPrint", "setup") | ||
} | ||
OctoPrint.simpleApiCommand("SimplyPrint", "setup"); | ||
}; | ||
|
||
self.onDataUpdaterPluginMessage = function (plugin, data) { | ||
if (plugin !== "SimplyPrint") { | ||
|
@@ -333,19 +355,25 @@ $(function () { | |
"text": "It looks like the dependency has been uninstalled. Please reinstall the plugin or contact us at [email protected]", | ||
"type": "error", | ||
"hide": false, | ||
}) | ||
}); | ||
} else if (data.message === "sp-rpi_error") { | ||
new PNotify({ | ||
"title": "Unknown error enabling the SimplyPrint software", | ||
"text": "Please get in contact so we can resolve this! [email protected]", | ||
"type": "error", | ||
"hide": false, | ||
}) | ||
}); | ||
} else if (data.message === "sp-connection") { | ||
self.ws_connected_server(data.server); | ||
self.current_endpoint(data.endpoint); | ||
self.is_online(data.is_online); | ||
self.ws_connected(data.ws_connected); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
self.doUninstall = function () { | ||
self.requestInProgress(true) | ||
self.requestInProgress(true); | ||
OctoPrint.simpleApiCommand("SimplyPrint", "uninstall") | ||
.done(function (response) { | ||
self.requestInProgress(false); | ||
|
@@ -362,11 +390,11 @@ $(function () { | |
"text": "It looks like the dependency has already been uninstalled. Failed to uninstall it again or contact us at [email protected]", | ||
"type": "error", | ||
"hide": false, | ||
}) | ||
}); | ||
} | ||
} | ||
}) | ||
} | ||
}); | ||
}; | ||
} | ||
|
||
OCTOPRINT_VIEWMODELS.push({ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.