This commit is contained in:
David Zingg
2019-11-19 21:55:31 +01:00
parent 4c159fbabc
commit 5119ab736d
7 changed files with 113 additions and 113 deletions

View File

@ -0,0 +1,38 @@
/* #touch body #sidebar_plugin_mystromswitch_wrapper .accordion-heading { */
/* display: block !important; */
/* pointer-events: none; */
/* margin: 40px -30px 0; */
/* padding: .5rem 30px; */
/* background-color: #00B0FF; */
/* color: black; */
/* } */
/* #touch body #sidebar_plugin_mystromswitch_wrapper .accordion-heading>a, #touch body #sidebar_plugin_mystromswitch_wrapper .accordion-heading>a i { */
/* color: black; */
/* font-size: 1.4375rem; */
/* padding-right: 0; */
/* padding-left: 0; */
/* } */
/* #touch body #sidebar_plugin_mystromswitch > label { */
/* display: block; */
/* background:#333; */
/* padding-left: 50px; */
/* padding-top: 15px; */
/* padding-bottom: 15px; */
/* } */
/* #touch body #sidebar_plugin_mystromswitch { */
/* pointer-events: auto; */
/* margin: 0px -30px 0; */
/* padding-right: 15px; */
/* padding-left: 15px; */
/* } */
.shutdownPrinterHideCancelBtnConfirm {
display:none;
}
#touch body #tabs #sidebar_plugin_mystromswitch_wrapper_link a:before, #touch body #navbar #all_touchui_settings #sidebar_plugin_mystromswitch_wrapper_link a:before,#touch body #tabs #sidebar_plugin_mystromswitch_wrapper_link2 a:before, #touch body #navbar #all_touchui_settings #sidebar_plugin_mystromswitch_wrapper_link2 a:before {
content: "\f011";
}

View File

@ -1,38 +0,0 @@
/* #touch body #sidebar_plugin_shutdownprinter_wrapper .accordion-heading { */
/* display: block !important; */
/* pointer-events: none; */
/* margin: 40px -30px 0; */
/* padding: .5rem 30px; */
/* background-color: #00B0FF; */
/* color: black; */
/* } */
/* #touch body #sidebar_plugin_shutdownprinter_wrapper .accordion-heading>a, #touch body #sidebar_plugin_shutdownprinter_wrapper .accordion-heading>a i { */
/* color: black; */
/* font-size: 1.4375rem; */
/* padding-right: 0; */
/* padding-left: 0; */
/* } */
/* #touch body #sidebar_plugin_shutdownprinter > label { */
/* display: block; */
/* background:#333; */
/* padding-left: 50px; */
/* padding-top: 15px; */
/* padding-bottom: 15px; */
/* } */
/* #touch body #sidebar_plugin_shutdownprinter { */
/* pointer-events: auto; */
/* margin: 0px -30px 0; */
/* padding-right: 15px; */
/* padding-left: 15px; */
/* } */
.shutdownPrinterHideCancelBtnConfirm {
display:none;
}
#touch body #tabs #sidebar_plugin_shutdownprinter_wrapper_link a:before, #touch body #navbar #all_touchui_settings #sidebar_plugin_shutdownprinter_wrapper_link a:before,#touch body #tabs #sidebar_plugin_shutdownprinter_wrapper_link2 a:before, #touch body #navbar #all_touchui_settings #sidebar_plugin_shutdownprinter_wrapper_link2 a:before {
content: "\f011";
}

View File

@ -1,5 +1,5 @@
$(function() {
function ShutdownPrinterViewModel(parameters) {
function mystromswitchViewModel(parameters) {
var self = this;
self.loginState = parameters[0];
@ -7,12 +7,12 @@ $(function() {
self.printer = parameters[2];
self.shutdownprinterEnabled = ko.observable();
self.mystromswitchEnabled = ko.observable();
self.testButtonChangeStatus = function (stat) {
$("#tester_shutdownprinter_gcode").prop("disabled", stat);
$("#tester_shutdownprinter_api").prop("disabled", stat);
$("#tester_shutdownprinter_api_custom").prop("disabled", stat);
$("#tester_mystromswitch_gcode").prop("disabled", stat);
$("#tester_mystromswitch_api").prop("disabled", stat);
$("#tester_mystromswitch_api_custom").prop("disabled", stat);
}
self.eventChangeCheckToRadio = function (id, listOff) {
@ -34,12 +34,12 @@ $(function() {
})
}
$("#tester_shutdownprinter_gcode").on("click", function () {
$("#tester_mystromswitch_gcode").on("click", function () {
self.settings.saveData();
$(this).children("i").show();
setTimeout(function (current) {
$.ajax({
url: API_BASEURL + "plugin/shutdownprinter",
url: API_BASEURL + "plugin/mystromswitch",
type: "POST",
dataType: "json",
data: JSON.stringify({
@ -55,12 +55,12 @@ $(function() {
}, 1000, $(this));
});
$("#tester_shutdownprinter_api").on("click", function () {
$("#tester_mystromswitch_api").on("click", function () {
self.settings.saveData();
$(this).children("i").show();
setTimeout(function (current) {
$.ajax({
url: API_BASEURL + "plugin/shutdownprinter",
url: API_BASEURL + "plugin/mystromswitch",
type: "POST",
dataType: "json",
data: JSON.stringify({
@ -76,12 +76,12 @@ $(function() {
});
$("#tester_shutdownprinter_api_custom").on("click", function () {
$("#tester_mystromswitch_api_custom").on("click", function () {
self.settings.saveData();
$(this).children("i").show();
setTimeout(function (current) {
$.ajax({
url: API_BASEURL + "plugin/shutdownprinter",
url: API_BASEURL + "plugin/mystromswitch",
type: "POST",
dataType: "json",
data: JSON.stringify({
@ -97,22 +97,22 @@ $(function() {
});
self.listOffMode = [
{"id" : "#shutdownprinter_mode_shutdown_gcode"},
{"id" : "#shutdownprinter_mode_shutdown_api"},
{"id" : "#shutdownprinter_mode_shutdown_api_custom"},
{"id" : "#mystromswitch_mode_shutdown_gcode"},
{"id" : "#mystromswitch_mode_shutdown_api"},
{"id" : "#mystromswitch_mode_shutdown_api_custom"},
]
self.listOffHTTPMethode = [
{"id" : "#shutdownprinter_api_custom_GET"},
{"id" : "#shutdownprinter_api_custom_POST"},
{"id" : "#shutdownprinter_api_custom_PUT"}
{"id" : "#mystromswitch_api_custom_GET"},
{"id" : "#mystromswitch_api_custom_POST"},
{"id" : "#mystromswitch_api_custom_PUT"}
]
self.eventChangeCheckToRadio("#shutdownprinter_mode_shutdown_gcode", self.listOffMode);
self.eventChangeCheckToRadio("#shutdownprinter_mode_shutdown_api", self.listOffMode);
self.eventChangeCheckToRadio("#shutdownprinter_mode_shutdown_api_custom", self.listOffMode);
self.eventChangeCheckToRadio("#mystromswitch_mode_shutdown_gcode", self.listOffMode);
self.eventChangeCheckToRadio("#mystromswitch_mode_shutdown_api", self.listOffMode);
self.eventChangeCheckToRadio("#mystromswitch_mode_shutdown_api_custom", self.listOffMode);
self.eventChangeCheckToRadio("#shutdownprinter_api_custom_GET", self.listOffHTTPMethode);
self.eventChangeCheckToRadio("#shutdownprinter_api_custom_POST", self.listOffHTTPMethode);
self.eventChangeCheckToRadio("#shutdownprinter_api_custom_PUT", self.listOffHTTPMethode);
self.eventChangeCheckToRadio("#mystromswitch_api_custom_GET", self.listOffHTTPMethode);
self.eventChangeCheckToRadio("#mystromswitch_api_custom_POST", self.listOffHTTPMethode);
self.eventChangeCheckToRadio("#mystromswitch_api_custom_PUT", self.listOffHTTPMethode);
// Hack to remove automatically added Cancel button
// See https://github.com/sciactive/pnotify/issues/141
@ -135,7 +135,7 @@ $(function() {
notice.get().trigger("pnotify.cancel", [notice, value]);
}
}, {
addClass: 'shutdownPrinterHideCancelBtnConfirm',
addClass: 'mystromswitchHideCancelBtnConfirm',
promptTrigger: true,
click: function(notice, value){
notice.remove();
@ -162,7 +162,7 @@ $(function() {
if (counter < 10) {
if (document.getElementById("touch") != null && document.getElementById("printer") != null && document.getElementById("printer") != null && document.getElementById("touch").querySelector("#printer").querySelector("#files_wrapper")) {
var newParent = document.getElementById("files_wrapper").parentNode;
newParent.insertBefore(document.getElementById('sidebar_plugin_shutdownprinter_wrapper'), document.getElementById("files_wrapper"));
newParent.insertBefore(document.getElementById('sidebar_plugin_mystromswitch_wrapper'), document.getElementById("files_wrapper"));
} else {
setTimeout(self.touchUIMoveElement, 1000, self, ++counter);
}
@ -183,7 +183,7 @@ $(function() {
self.onUserLoggedIn = function() {
$.ajax({
url: API_BASEURL + "plugin/shutdownprinter",
url: API_BASEURL + "plugin/mystromswitch",
type: "POST",
dataType: "json",
data: JSON.stringify({
@ -193,7 +193,7 @@ $(function() {
contentType: "application/json; charset=UTF-8"
})
$.ajax({
url: API_BASEURL + "plugin/shutdownprinter",
url: API_BASEURL + "plugin/mystromswitch",
type: "POST",
data: JSON.stringify({
command: "status"
@ -201,7 +201,7 @@ $(function() {
context:self,
contentType: "application/json; charset=UTF-8"
}).done(function(data, textStatus, jqXHR ){
this.shutdownprinterEnabled(data == "True" ? true : false);
this.mystromswitchEnabled(data == "True" ? true : false);
})
}
@ -216,10 +216,10 @@ $(function() {
}
}
self.onShutdownPrinterEvent = function() {
if (self.shutdownprinterEnabled()) {
self.onmystromswitchEvent = function() {
if (self.mystromswitchEnabled()) {
$.ajax({
url: API_BASEURL + "plugin/shutdownprinter",
url: API_BASEURL + "plugin/mystromswitch",
type: "POST",
dataType: "json",
data: JSON.stringify({
@ -230,7 +230,7 @@ $(function() {
})
} else {
$.ajax({
url: API_BASEURL + "plugin/shutdownprinter",
url: API_BASEURL + "plugin/mystromswitch",
type: "POST",
dataType: "json",
data: JSON.stringify({
@ -242,14 +242,14 @@ $(function() {
}
}
self.shutdownprinterEnabled.subscribe(self.onShutdownPrinterEvent, self);
self.mystromswitchEnabled.subscribe(self.onmystromswitchEvent, self);
self.onDataUpdaterPluginMessage = function(plugin, data) {
if (plugin != "shutdownprinter" && plugin != "octoprint_shutdownprinter") {
if (plugin != "mystromswitch" && plugin != "octoprint_mystromswitch") {
return;
}
self.shutdownprinterEnabled(data.shutdownprinterEnabled);
self.mystromswitchEnabled(data.mystromswitchEnabled);
if (data.type == "timeout") {
if ((data.timeout_value != null) && (data.timeout_value > 0)) {
self.timeoutPopupOptions.text = self.timeoutPopupText + data.timeout_value;
@ -272,7 +272,7 @@ $(function() {
self.timeoutPopup.remove();
self.timeoutPopup = undefined;
$.ajax({
url: API_BASEURL + "plugin/shutdownprinter",
url: API_BASEURL + "plugin/mystromswitch",
type: "POST",
dataType: "json",
data: JSON.stringify({
@ -285,8 +285,8 @@ $(function() {
}
OCTOPRINT_VIEWMODELS.push([
ShutdownPrinterViewModel,
mystromswitchViewModel,
["loginStateViewModel", "settingsViewModel", "printerStateViewModel"],
$(".sidebar_plugin_shutdownprinter").get(0)
$(".sidebar_plugin_mystromswitch").get(0)
]);
});