Skip to content

Commit

Permalink
Merge pull request #49 from SimplyPrint/devel
Browse files Browse the repository at this point in the history
  • Loading branch information
jneilliii authored Jan 13, 2023
2 parents 7e3c7d4 + 577b8cc commit 09d4828
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 40 deletions.
1 change: 1 addition & 0 deletions octoprint_simplyprint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
Events.CONNECTED,
Events.DISCONNECTING,
Events.DISCONNECTED,
Events.CLIENT_AUTHED,

Events.STARTUP,
Events.SHUTDOWN,
Expand Down
66 changes: 47 additions & 19 deletions octoprint_simplyprint/static/js/SimplyPrint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 () {
Expand All @@ -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()) {
Expand Down Expand 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) {
Expand Down Expand Up @@ -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
Expand All @@ -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") {
Expand All @@ -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);
Expand All @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion octoprint_simplyprint/templates/SimplyPrint_navbar.jinja2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div id="simplyprint_plugin_navbar">
<div class="nav navbar-text">
<a href="https://simplyprint.io/panel" target="_blank"><img alt="SimplyPrint logo (all rights reserved)" src="plugin/SimplyPrint/static/img/sp_logo.png" title="SimplyPrint active" style="width: 28px;"></a>
<a data-bind="attr: {href: SimplyPrintPanelURL, title: SimplyPrintEndpoint}" href="https://simplyprint.io/panel" target="_blank"><img alt="SimplyPrint logo (all rights reserved)" src="plugin/SimplyPrint/static/img/sp_logo.png" style="width: 28px;"></a>

<strong>
<span id="simplyprint_version_wrapper">v{{ plugin_SimplyPrint_version }}</span>
Expand Down
3 changes: 2 additions & 1 deletion octoprint_simplyprint/templates/SimplyPrint_settings.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<p>There isn't much to see in here :) All settings are located in the SimplyPrint panel, and everything that needs to be
synced to OctoPrint and your Raspberry Pi, will do so automatically.</p>

<a href="https://simplyprint.io/panel" target="_blank" class="btn btn-primary">Go to the SimplyPrint panel</a>
<p>Currently <span class="label" data-bind="text: online_label, class: online_label_class"></span> and <span class="label" data-bind="text: ws_connected_label, class: ws_connected_label_class"></span> <span data-bind="text: ws_connected() ? 'to' : 'from'"></span> <span class="label label-info" data-bind="text: current_endpoint"></span> endpoint <!-- ko if: ws_connected -->on server <span class="label label-info" data-bind="text: ws_connected_server, css: {'label-error': ws_connected_server == 'error'}"></span><!-- /ko --></p>
<a data-bind="attr: {href: SimplyPrintPanelURL, title: SimplyPrintEndpoint}" href="https://simplyprint.io/panel" target="_blank" class="btn btn-primary">Go to the SimplyPrint panel</a>

{#
<p>
Expand Down
4 changes: 3 additions & 1 deletion octoprint_simplyprint/websocket/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
#

SP_BACKEND_VERSION = "0.1"
WS_TEST_ENDPOINT = "wss://testws.simplyprint.io/%s/p" % (SP_BACKEND_VERSION, )
WS_TEST_ENDPOINT = "wss://testws2.simplyprint.io/%s/p" % (SP_BACKEND_VERSION, )
WS_PROD_ENDPOINT = "wss://ws.simplyprint.io/%s/p" % (SP_BACKEND_VERSION, )

PLUGIN_INSTALL_URL = "https://github.com/SimplyPrint/OctoPrint-SimplyPrint/archive/master.zip"
TEST_PLUGIN_INSTALL_URL = "https://github.com/Arksine/OctoPrint-SimplyPrint/dev-sp-websocket-20220414/master.zip"

LOGS_UPLOAD_URL = "https://apirewrite.simplyprint.io/printers/ReceiveLogs?pid="
Loading

0 comments on commit 09d4828

Please sign in to comment.