Skip to content

Commit d4862da

Browse files
authored
Add files via upload
1 parent 39edd66 commit d4862da

File tree

6 files changed

+100
-0
lines changed

6 files changed

+100
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# coding=utf-8
2+
from __future__ import absolute_import
3+
4+
import octoprint.plugin
5+
6+
class shellinaboxtabPlugin(octoprint.plugin.StartupPlugin,
7+
octoprint.plugin.TemplatePlugin,
8+
octoprint.plugin.SettingsPlugin,
9+
octoprint.plugin.AssetPlugin):
10+
def on_after_startup(self):
11+
self._logger.info("Shell In A Box TAB (more: %s)" % self._settings.get(["url"]))
12+
13+
def get_settings_defaults(self):
14+
return dict(url="https://octoprint.local:4200")
15+
16+
def get_template_configs(self):
17+
return [
18+
#dict(type="navbar", custom_bindings=False),
19+
dict(type="settings", custom_bindings=False)
20+
]
21+
22+
def get_assets(self):
23+
return dict(
24+
js=["js/shellinaboxtab.js"],
25+
css=["css/shellinaboxtab.css"],
26+
less=["less/shellinaboxtab.less"]
27+
)
28+
29+
__plugin_name__ = "Shell In A Box TAB"
30+
__plugin_pythoncompat__ = ">=2.7,<4"
31+
__plugin_implementation__ = shellinaboxtabPlugin()
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#tab_plugin_shellinaboxtab iframe {
2+
width: 100%;
3+
height: 600px;
4+
border: 1px solid #808080;
5+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
$(function() {
2+
function shellinaboxtabViewModel(parameters) {
3+
var self = this;
4+
5+
self.loginState = parameters[0];
6+
self.settings = parameters[1];
7+
8+
// this will hold the URL currently displayed by the iframe
9+
self.currentUrl = ko.observable();
10+
11+
// this will hold the URL entered in the text field
12+
self.newUrl = ko.observable();
13+
14+
// this will be called when the user clicks the "Go" button and set the iframe's URL to the entered URL
15+
self.goToUrl = function() {
16+
self.currentUrl(self.newUrl());
17+
};
18+
19+
// This will get called before the shellinaboxtabViewModel gets bound to the DOM, but after its depedencies have
20+
// already been initialized. It is especially guaranteed that this method gets called _after_ the settings
21+
// have been retrieved from the OctoPrint backend and thus the SettingsViewModel been properly populated.
22+
self.onBeforeBinding = function() {
23+
self.newUrl(self.settings.settings.plugins.shellinaboxtab.url());
24+
self.goToUrl();
25+
}
26+
}
27+
28+
// This is how our plugin registers itself with the application, by adding some configuration information to
29+
// the global variable ADDITIONAL_VIEWMODELS
30+
ADDITIONAL_VIEWMODELS.push([
31+
// This is the constructor to call for instantiating the plugin
32+
shellinaboxtabViewModel,
33+
34+
// This is a list of dependencies to inject into the plugin, the order which you request here is the order
35+
// in which the dependencies will be injected into your view model upon instantiation via the parameters
36+
// argument
37+
["loginStateViewModel", "settingsViewModel"],
38+
39+
// Finally, this is the list of all elements we want this view model to be bound to.
40+
[document.getElementById("tab_plugin_shellinaboxtab")]
41+
]);
42+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#tab_plugin_shellinaboxtab {
2+
iframe {
3+
width: 100%;
4+
height: 600px;
5+
border: 1px solid #808080;
6+
}
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<form class="form-horizontal">
2+
<div class="control-group">
3+
<label class="control-label">{{ _('URL') }}</label>
4+
<div class="controls">
5+
<input type="text" class="input-block-level" data-bind="value: settings.plugins.shellinaboxtab.url">
6+
</div>
7+
</div>
8+
</form>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div class="input-append">
2+
<input type="text" class="input-xxlarge" data-bind="value: newUrl">
3+
<button class="btn btn-primary" data-bind="click: goToUrl">Go</button>
4+
</div>
5+
6+
7+
<iframe data-bind="attr: {src: currentUrl}"></iframe>

0 commit comments

Comments
 (0)