Skip to content

Commit

Permalink
Plugin works now
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethjiang committed Apr 19, 2022
1 parent eb9dc89 commit f1ebaad
Show file tree
Hide file tree
Showing 22 changed files with 90 additions and 90 deletions.
6 changes: 3 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include README.md
recursive-include octoprint_thespaghettidetective/templates *
recursive-include octoprint_thespaghettidetective/translations *
recursive-include octoprint_thespaghettidetective/static *
recursive-include octoprint_obico/templates *
recursive-include octoprint_obico/translations *
recursive-include octoprint_obico/static *
6 changes: 3 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ var less = require('gulp-less');
var sourcemaps = require('gulp-sourcemaps');

gulp.task('less', function() {
return gulp.src('octoprint_thespaghettidetective/static/less/**/*.less') // Gets all files ending with .scss in app/scss and children dirs
return gulp.src('octoprint_obico/static/less/**/*.less') // Gets all files ending with .scss in app/scss and children dirs
.pipe(sourcemaps.init())
.pipe(less())
.pipe(sourcemaps.write())
.pipe(gulp.dest('octoprint_thespaghettidetective/static/css'));
.pipe(gulp.dest('octoprint_obico/static/css'));
});

gulp.task('watch', function() {
gulp.watch('octoprint_thespaghettidetective/static/less/**/*.less', gulp.series('less'));
gulp.watch('octoprint_obico/static/less/**/*.less', gulp.series('less'));
});
2 changes: 1 addition & 1 deletion octoprint_obico/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

__python_version__ = 3 if sys.version_info >= (3, 0) else 2

_logger = logging.getLogger('octoprint.plugins.thespaghettidetective')
_logger = logging.getLogger('octoprint.plugins.obico')

POST_STATUS_INTERVAL_SECONDS = 50.0

Expand Down
2 changes: 1 addition & 1 deletion octoprint_obico/client_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

__python_version__ = 3 if sys.version_info >= (3, 0) else 2

_logger = logging.getLogger('octoprint.plugins.thespaghettidetective')
_logger = logging.getLogger('octoprint.plugins.obico')

class ClientConn:

Expand Down
2 changes: 1 addition & 1 deletion octoprint_obico/file_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import io
from .utils import get_tags

_logger = logging.getLogger('octoprint.plugins.thespaghettidetective')
_logger = logging.getLogger('octoprint.plugins.obico')
UPLOAD_FOLDER = 'TheSpaghettiDetectiveUpload'


Expand Down
2 changes: 1 addition & 1 deletion octoprint_obico/gcode_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import re

_logger = logging.getLogger('octoprint.plugins.thespaghettidetective')
_logger = logging.getLogger('octoprint.plugins.obico')


class GCodeHooks:
Expand Down
6 changes: 3 additions & 3 deletions octoprint_obico/janus.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from .utils import ExpoBackoff, get_tags, pi_version
from .ws import WebSocketClient

_logger = logging.getLogger('octoprint.plugins.thespaghettidetective')
_logger = logging.getLogger('octoprint.plugins.obico')

JANUS_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'bin', 'janus')
JANUS_SERVER = os.getenv('JANUS_SERVER', '127.0.0.1')
Expand Down Expand Up @@ -138,14 +138,14 @@ def process_janus_msg(self, raw_msg):
try:
msg = json.loads(raw_msg)

# when plugindata.data.thespaghettidetective is set, this is a incoming message from webrtc data channel
# when plugindata.data.obico is set, this is a incoming message from webrtc data channel
# https://github.com/TheSpaghettiDetective/janus-gateway/commit/e0bcc6b40f145ce72e487204354486b2977393ea
to_plugin = msg.get(
'plugindata', {}
).get(
'data', {}
).get(
'thespaghettidetective', {}
'obico', {}
)

if to_plugin:
Expand Down
2 changes: 1 addition & 1 deletion octoprint_obico/pause_resume_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import re

_logger = logging.getLogger('octoprint.plugins.thespaghettidetective')
_logger = logging.getLogger('octoprint.plugins.obico')


class PauseResumeGCodeSequence:
Expand Down
2 changes: 1 addition & 1 deletion octoprint_obico/plugin_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .lib.error_stats import error_stats
from .lib import alert_queue

_logger = logging.getLogger('octoprint.plugins.thespaghettidetective')
_logger = logging.getLogger('octoprint.plugins.obico')

def get_api_commands():
return dict(
Expand Down
2 changes: 1 addition & 1 deletion octoprint_obico/print_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import threading
from octoprint.filemanager.analysis import QueueEntry

_logger = logging.getLogger('octoprint.plugins.thespaghettidetective')
_logger = logging.getLogger('octoprint.plugins.obico')


class PrintEventTracker:
Expand Down
4 changes: 2 additions & 2 deletions octoprint_obico/printer_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def token_hex(n):
server_request, OctoPrintSettingsUpdater,
get_tags, raise_for_status)

_logger = logging.getLogger('octoprint.plugins.thespaghettidetective')
_logger = logging.getLogger('octoprint.plugins.obico')

# we count steps instead of tracking timestamps;
# timestamps happened to be unreliable on rpi-s (NTP issue?)
Expand Down Expand Up @@ -148,7 +148,7 @@ def get_remote_address(request):
else:
resp = flask.Response(
flask.render_template(
'thespaghettidetective_discovery.jinja2',
'obico_discovery.jinja2',
device_secret=self.device_secret
)
)
Expand Down
36 changes: 18 additions & 18 deletions octoprint_obico/static/js/TheSpaghettiDetectiveSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $(function () {
})
});

function TheSpaghettiDetectiveSettingsViewModel(parameters) {
function ObicoSettingsViewModel(parameters) {
var self = this;

const defaultServerAddress = 'https://app.thespaghettidetective.com';
Expand All @@ -22,7 +22,7 @@ $(function () {

// assign the injected parameters, e.g.:
// self.loginStateViewModel = parameters[0];
self.thespaghettidetectiveWizardViewModel = parameters[0];
self.obicoWizardViewModel = parameters[0];
self.settingsViewModel = parameters[1];
self.wizardViewModel = parameters[2];

Expand All @@ -39,23 +39,23 @@ $(function () {
self.serverTestStatusCode = ko.observable(null);
self.serverTested = ko.observable('never');
self.sentryOptedIn = ko.pureComputed(function () {
return self.settingsViewModel.settings.plugins.thespaghettidetective.sentry_opt() === "in";
return self.settingsViewModel.settings.plugins.obico.sentry_opt() === "in";
}, self);
self.configured = ko.pureComputed(function () {
return self.settingsViewModel.settings.plugins.thespaghettidetective.auth_token
&& self.settingsViewModel.settings.plugins.thespaghettidetective.auth_token();
return self.settingsViewModel.settings.plugins.obico.auth_token
&& self.settingsViewModel.settings.plugins.obico.auth_token();
}, self);
self.wizardAutoPoppedup = ko.observable(false);
self.disableWizardAutoPopUp = ko.observable(false);
self.serverType = ko.observable('cloud');

self.onStartupComplete = function (plugin, data) {
self.fetchPluginStatus();
self.serverType(getServerType(self.settingsViewModel.settings.plugins.thespaghettidetective.endpoint_prefix()));
self.serverType(getServerType(self.settingsViewModel.settings.plugins.obico.endpoint_prefix()));
};

self.onSettingsBeforeSave = function() {
self.serverType(getServerType(self.settingsViewModel.settings.plugins.thespaghettidetective.endpoint_prefix()));
self.serverType(getServerType(self.settingsViewModel.settings.plugins.obico.endpoint_prefix()));
}

self.hasServerErrors = function() {
Expand Down Expand Up @@ -137,12 +137,12 @@ $(function () {
};

self.resetEndpointPrefix = function () {
self.settingsViewModel.settings.plugins.thespaghettidetective.endpoint_prefix(defaultServerAddress);
self.settingsViewModel.settings.plugins.obico.endpoint_prefix(defaultServerAddress);
return true;
};

self.clearEndpointPrefix = function () {
self.settingsViewModel.settings.plugins.thespaghettidetective.endpoint_prefix('');
self.settingsViewModel.settings.plugins.obico.endpoint_prefix('');
return true;
};

Expand Down Expand Up @@ -172,7 +172,7 @@ $(function () {
/*** Plugin error alerts */

self.onDataUpdaterPluginMessage = function (plugin, data) {
if (plugin != "thespaghettidetective") {
if (plugin != "obico") {
return;
}

Expand All @@ -182,8 +182,8 @@ $(function () {

if (data.printer_autolinked) {
self.fetchPluginStatus();
self.thespaghettidetectiveWizardViewModel.toStep(5);
self.thespaghettidetectiveWizardViewModel.startAutoCloseTimout();
self.obicoWizardViewModel.toStep(5);
self.obicoWizardViewModel.startAutoCloseTimout();
}
}

Expand Down Expand Up @@ -301,7 +301,7 @@ $(function () {
};

$('#wizardModal').on('shown', function(){
self.thespaghettidetectiveWizardViewModel.reset();
self.obicoWizardViewModel.reset();
});
$('#wizardModal').on('hidden', function(){
if (self.disableWizardAutoPopUp()) {
Expand All @@ -313,7 +313,7 @@ $(function () {

// Helper methods
function apiCommand(data) {
return $.ajax("api/plugin/thespaghettidetective", {
return $.ajax("api/plugin/obico", {
method: "POST",
contentType: "application/json",
data: JSON.stringify(data)
Expand Down Expand Up @@ -346,12 +346,12 @@ $(function () {
* and a full list of the available options.
*/
OCTOPRINT_VIEWMODELS.push({
construct: TheSpaghettiDetectiveSettingsViewModel,
construct: ObicoSettingsViewModel,
// ViewModels your plugin depends on, e.g. loginStateViewModel, settingsViewModel, ...
dependencies: ["thespaghettidetectiveWizardViewModel", "settingsViewModel", "wizardViewModel"],
// Elements to bind to, e.g. #settings_plugin_thespaghettidetective, #tab_plugin_thespaghettidetective, ...
dependencies: ["obicoWizardViewModel", "settingsViewModel", "wizardViewModel"],
// Elements to bind to, e.g. #settings_plugin_obico, #tab_plugin_obico, ...
elements: [
"#settings_plugin_thespaghettidetective",
"#settings_plugin_obico",
]
});

Expand Down
22 changes: 11 additions & 11 deletions octoprint_obico/static/js/TheSpaghettiDetectiveWizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
$(function () {

function apiCommand(data) {
return $.ajax("api/plugin/thespaghettidetective", {
return $.ajax("api/plugin/obico", {
method: "POST",
contentType: "application/json",
data: JSON.stringify(data)
});
}

function ThespaghettidetectiveWizardViewModel(parameters) {
function ObicoWizardViewModel(parameters) {
var self = this;

const defaultServerAddress = 'https://app.thespaghettidetective.com';
Expand All @@ -38,7 +38,7 @@ $(function () {
self.serverType = ko.observable('cloud');

self.onStartupComplete = function () {
self.serverType(getServerType(self.settingsViewModel.settings.plugins.thespaghettidetective.endpoint_prefix()));
self.serverType(getServerType(self.settingsViewModel.settings.plugins.obico.endpoint_prefix()));
};

self.isServerInvalid = ko.observable(false);
Expand Down Expand Up @@ -143,7 +143,7 @@ $(function () {

self.nextStep = function() {
if (self.step() === 1) {
let url = self.settingsViewModel.settings.plugins.thespaghettidetective.endpoint_prefix()
let url = self.settingsViewModel.settings.plugins.obico.endpoint_prefix()

if (self.serverType() === 'self-hosted') {
if (self.checkSeverValidity(url)) {
Expand All @@ -155,7 +155,7 @@ $(function () {
}

self.serverType(getServerType(url))
self.settingsViewModel.saveData({plugins: {thespaghettidetective: {endpoint_prefix: url}}});
self.settingsViewModel.saveData({plugins: {obico: {endpoint_prefix: url}}});
}

self.toStep(self.step() + 1);
Expand Down Expand Up @@ -225,12 +225,12 @@ $(function () {
};

self.resetEndpointPrefix = function () {
self.settingsViewModel.settings.plugins.thespaghettidetective.endpoint_prefix(defaultServerAddress);
self.settingsViewModel.settings.plugins.obico.endpoint_prefix(defaultServerAddress);
return true;
};

self.clearEndpointPrefix = function () {
self.settingsViewModel.settings.plugins.thespaghettidetective.endpoint_prefix('');
self.settingsViewModel.settings.plugins.obico.endpoint_prefix('');
return true;
};

Expand Down Expand Up @@ -284,13 +284,13 @@ $(function () {
* and a full list of the available options.
*/
OCTOPRINT_VIEWMODELS.push({
construct: ThespaghettidetectiveWizardViewModel,
construct: ObicoWizardViewModel,
// ViewModels your plugin depends on, e.g. loginStateViewModel, settingsViewModel, ...
dependencies: ["settingsViewModel"],
// Elements to bind to, e.g. #settings_plugin_thespaghettidetective, #tab_plugin_thespaghettidetective, ...
// Elements to bind to, e.g. #settings_plugin_obico, #tab_plugin_obico, ...
elements: [
"#wizard_plugin_thespaghettidetective",
"#tsd_wizard",
"#wizard_plugin_obico",
"#obico_wizard",
]
});

Expand Down
Loading

0 comments on commit f1ebaad

Please sign in to comment.